mirror of
https://github.com/morluto/rea.git
synced 2026-11-19 13:12:26 +00:00
refactor(ida): launch stdio registrations through the owned MCP transport (#10739)
* refactor(ida): launch stdio registrations through the owned MCP transport IDA stdio servers now run as an owned process group (POSIX) or job (Windows) through OwnedMcpStdioTransport instead of the SDK's unowned child. Windows bare commands resolve against the registration PATH/PATHEXT and .cmd/.bat launchers run through the shared WindowsBatchCommand cmd.exe invocation. The frame limit is classified from the transport's typed OwnedMcpOutputLimitError instead of parsing SDK error text, detach no longer reaches into the SDK's private _process, and the per-operation byte budget is optional. * fix(ida): keep owned stdio cleanup observable and resolve Windows interpreter paths - StructuredContentMcpClient observes SDK-initiated closes like OwnedMcpClient, so a failed handshake with incomplete owned cleanup cannot reject unhandled. - OwnedMcpStdioTransport attaches an owner-redacted captured output to cleanup failures; IDA passes its retained stderr tail. - findWindowsExecutable resolves path-qualified commands at their own location with PATHEXT; IDA routes every Windows registration through it and refuses non-drive paths with an actionable remedy before the owned launcher. * fix(process): end a stalled stdio launch when the owned MCP transport closes OwnedMcpStdioTransport passes the launcher a signal it aborts with OwnerCancellation.ownerClosed when it stops, so IDA's Windows PATH/PATHEXT lookup stalled on an unreachable directory no longer holds close() open; IDA reports the interrupted lookup by its abort reason. The IDA environment tests use createTestTempDirectory for owned temporary roots. * fix(ida): bound the Windows command lookup by the registration timeout The PATH/PATHEXT search for a stdio registration now runs under a ProviderStartupDeadline of the registration's timeoutMs that also follows the transport's close signal. A lookup stalled on an unreachable PATH directory ends as an AnalysisTimeoutError (phase windows_path_lookup) instead of leaving connect() pending, matching Apktool's Windows lookup. * test(ida): stub REA's PATH again now that process inspection runs ps from fixed locations * test(ida): pass the required registration protocol in owned-stdio fixtures * fix(ida): report an uninspectable Windows command candidate with its path and code * refactor(ida): take the host platform from composition, not an ambient read * fix(verify): pass the host platform to the real IDA upstream check * fix(process): keep a failed launch's preparation cleanup owned by the stdio transport's close OwnedMcpStdioTransport discarded the launch rejection before a supervisor existed, so an ownership-helper preparation that transferred a cleanup owner (or reported a cleanup failure without one) was dropped and close() reported success. The transport's close now closes each transferred owner from processInspectionCleanupFailures, and reports a ProviderCleanupError naming the preparation resource until it does; a later close retries it.
This commit is contained in:
1 parent
607a7872bb
commit
998faa4118
12 files changed
+777
-120
No files matched your search
@@ -115,10 +115,12 @@ export interface WindowsPathSearchFailure {
|
||||
}
|
||||
|
||||
/**
|
||||
* The files Windows' PATH/PATHEXT search tries for bare commands, in order:
|
||||
* for each PATH entry (relative ones resolve against `cwd`, or against this
|
||||
* process's directory, read only when such an entry is reached and skipped
|
||||
* once removed), each command with every PATHEXT extension,
|
||||
* The files Windows' PATH/PATHEXT search tries for commands, in order: a
|
||||
* path-qualified command (`C:\Python\python`, `.venv\Scripts\python`) only at
|
||||
* its own location, resolved against `cwd`, and never on PATH; then for each
|
||||
* PATH entry (relative ones resolve against `cwd`, or against this process's
|
||||
* directory, read only when such an entry is reached and skipped once
|
||||
* removed), each bare command with every PATHEXT extension,
|
||||
* or as written when it already names an extension. Only `.com` and `.exe`
|
||||
* images are searched unless `allowBatch`; a `.bat` or `.cmd` launcher must
|
||||
* then be started through src/process/WindowsBatchCommand. An invalid
|
||||
@@ -147,16 +149,33 @@ export const windowsPathCandidates = (
|
||||
const runnable = (extension: string) =>
|
||||
search.allowBatch === true ||
|
||||
WINDOWS_IMAGE_EXTENSIONS.has(extension.toLowerCase());
|
||||
const names = listed.flatMap((command) => {
|
||||
const spelled = (command: string): string[] => {
|
||||
const explicit = win32.extname(command);
|
||||
if (explicit !== "") return runnable(explicit) ? [command] : [];
|
||||
return extensions
|
||||
.filter(runnable)
|
||||
.map((extension) => `${command}${extension}`);
|
||||
});
|
||||
};
|
||||
const qualified = (command: string): boolean =>
|
||||
/[\\/]/u.test(command) || win32.parse(command).root !== "";
|
||||
const located = listed.filter(qualified).flatMap(spelled);
|
||||
const names = listed
|
||||
.filter((command) => !qualified(command))
|
||||
.flatMap(spelled);
|
||||
const entries = windowsPathEntries(selected.PATH ?? "");
|
||||
return ok({
|
||||
*[Symbol.iterator]() {
|
||||
for (const name of located) {
|
||||
const workingDirectory = win32.isAbsolute(name)
|
||||
? name
|
||||
: (search.cwd ?? currentDirectory());
|
||||
if (workingDirectory === undefined) continue;
|
||||
yield {
|
||||
path: win32.resolve(workingDirectory, name),
|
||||
relativeEntry: false,
|
||||
};
|
||||
}
|
||||
if (names.length === 0) return;
|
||||
for (const directory of entries) {
|
||||
// Only an entry without a drive or UNC root reads the working
|
||||
// directory; a removed one holds nothing, and later entries count.
|
||||
|
||||
Reference in new issue
Block a user