@opengeni/runtime 0.11.0 → 0.13.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-YUAFQEFY.js → chunk-JGUQSAG5.js} +2605 -279
- package/dist/chunk-JGUQSAG5.js.map +1 -0
- package/dist/chunk-SSB7VOLE.js +301 -0
- package/dist/chunk-SSB7VOLE.js.map +1 -0
- package/dist/{index-D6yi-JcU.d.ts → index-DU-KXVlx.d.ts} +364 -31
- package/dist/index.d.ts +103 -10
- package/dist/index.js +756 -761
- package/dist/index.js.map +1 -1
- package/dist/mcp-network.d.ts +80 -0
- package/dist/mcp-network.js +66 -0
- package/dist/mcp-network.js.map +1 -0
- package/dist/sandbox/index.d.ts +1 -1
- package/dist/sandbox/index.js +39 -1
- package/package.json +9 -4
- package/src/codex-tool-search.ts +20 -1
- package/src/index.ts +502 -85
- package/src/mcp-network.ts +343 -0
- package/src/sandbox/channel-a.ts +92 -71
- package/src/sandbox/display-stack.ts +860 -23
- package/src/sandbox/exec-banner.ts +82 -0
- package/src/sandbox/index.ts +367 -145
- package/src/sandbox/provider-errors.ts +175 -0
- package/src/sandbox/providers/modal.ts +29 -2
- package/src/sandbox/routing/backend-resolver.ts +15 -0
- package/src/sandbox/routing/routing-session.ts +730 -36
- package/src/sandbox/select.ts +8 -0
- package/src/sandbox/turn-tool-cancellation.ts +366 -92
- package/src/sandbox/workspace-archive.ts +289 -0
- package/src/sandbox-computer.ts +3 -1
- package/src/usage-telemetry.ts +495 -51
- package/dist/chunk-YUAFQEFY.js.map +0 -1
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
// The SDK's execCommand/writeStdin fallback returns a formatted response with
|
|
2
|
+
// provider metadata followed by an `Output:` delimiter and command-controlled
|
|
3
|
+
// output. Terminal status is authoritative only in the metadata header; the
|
|
4
|
+
// output body is untrusted and may contain exact copies of SDK banner lines.
|
|
5
|
+
|
|
6
|
+
const EXEC_BANNER_HEADER_MAX_CHARS = 16 * 1024;
|
|
7
|
+
const OUTPUT_DELIMITER = /\r?\nOutput:\r?\n/u;
|
|
8
|
+
const SDK_METADATA_LINE =
|
|
9
|
+
/^(?:Chunk ID:|Wall time:|Original token count:|Output:|Process (?:running with session ID|exited with code))/mu;
|
|
10
|
+
const RUNNING_LINE = /^Process running with session ID (\d+)$/u;
|
|
11
|
+
const EXITED_LINE = /^Process exited with code (-?\d+)$/u;
|
|
12
|
+
const PROCESS_STATUS_PREFIX = /^Process (?:running with session ID|exited with code)/u;
|
|
13
|
+
|
|
14
|
+
export type ExecResponseBanner =
|
|
15
|
+
| { kind: "absent" }
|
|
16
|
+
| { kind: "invalid" }
|
|
17
|
+
| { kind: "running"; sessionId: number }
|
|
18
|
+
| { kind: "exited"; exitCode: number };
|
|
19
|
+
|
|
20
|
+
/** Parse exactly one terminal status from the SDK metadata header. Responses
|
|
21
|
+
* that resemble SDK output but lack a complete delimiter/header are invalid,
|
|
22
|
+
* while raw provider output without SDK metadata remains `absent` so callers
|
|
23
|
+
* may use their provider-specific body markers. */
|
|
24
|
+
export function parseExecResponseBanner(raw: string): ExecResponseBanner {
|
|
25
|
+
const delimiter = OUTPUT_DELIMITER.exec(raw);
|
|
26
|
+
if (!delimiter) {
|
|
27
|
+
return SDK_METADATA_LINE.test(raw) ? { kind: "invalid" } : { kind: "absent" };
|
|
28
|
+
}
|
|
29
|
+
if (delimiter.index > EXEC_BANNER_HEADER_MAX_CHARS) return { kind: "invalid" };
|
|
30
|
+
|
|
31
|
+
const header = raw.slice(0, delimiter.index);
|
|
32
|
+
const status: Array<{ kind: "running"; value: string } | { kind: "exited"; value: string }> = [];
|
|
33
|
+
for (const line of header.split(/\r?\n/u)) {
|
|
34
|
+
const running = RUNNING_LINE.exec(line);
|
|
35
|
+
if (running) {
|
|
36
|
+
status.push({ kind: "running", value: running[1]! });
|
|
37
|
+
continue;
|
|
38
|
+
}
|
|
39
|
+
const exited = EXITED_LINE.exec(line);
|
|
40
|
+
if (exited) {
|
|
41
|
+
status.push({ kind: "exited", value: exited[1]! });
|
|
42
|
+
continue;
|
|
43
|
+
}
|
|
44
|
+
// A status-looking metadata line that is malformed is ambiguous and must
|
|
45
|
+
// not be normalized into another process identity or terminal result.
|
|
46
|
+
if (PROCESS_STATUS_PREFIX.test(line)) return { kind: "invalid" };
|
|
47
|
+
}
|
|
48
|
+
if (status.length !== 1) return { kind: "invalid" };
|
|
49
|
+
|
|
50
|
+
const terminal = status[0]!;
|
|
51
|
+
const value = Number(terminal.value);
|
|
52
|
+
if (!Number.isSafeInteger(value)) return { kind: "invalid" };
|
|
53
|
+
if (terminal.kind === "running") {
|
|
54
|
+
return value >= 0 ? { kind: "running", sessionId: value } : { kind: "invalid" };
|
|
55
|
+
}
|
|
56
|
+
return { kind: "exited", exitCode: value };
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export function parseExecBannerSessionId(raw: string): number | null {
|
|
60
|
+
const banner = parseExecResponseBanner(raw);
|
|
61
|
+
return banner.kind === "running" ? banner.sessionId : null;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export function parseExecBannerExitCode(raw: string): number | null {
|
|
65
|
+
const banner = parseExecResponseBanner(raw);
|
|
66
|
+
return banner.kind === "exited" ? banner.exitCode : null;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// Detect the Modal "the exec-session you're writing to no longer exists" fact.
|
|
70
|
+
// This is process-lifetime authority, so classify only the complete known
|
|
71
|
+
// banner (or its bare provider form) carrying the exact tracked numeric id.
|
|
72
|
+
export function isExecSessionLostBanner(out: string, execSessionId: number): boolean {
|
|
73
|
+
if (!out || !Number.isSafeInteger(execSessionId) || execSessionId < 0) return false;
|
|
74
|
+
const match = out.match(/^(?:write_stdin failed: )?session not found: (\d+)$/);
|
|
75
|
+
// JavaScript's `$` also matches immediately before one final line terminator.
|
|
76
|
+
// Requiring the regex match to consume the entire string keeps even that
|
|
77
|
+
// otherwise-special case fail-closed.
|
|
78
|
+
if (!match || match[0] !== out) return false;
|
|
79
|
+
// String equality is intentional: parseInt would normalize malformed facts
|
|
80
|
+
// such as `01` and can round an out-of-range integer into another identity.
|
|
81
|
+
return match[1] === String(execSessionId);
|
|
82
|
+
}
|