@opengeni/runtime 0.7.1 → 0.13.0
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/THIRD_PARTY_NOTICES +32 -0
- package/dist/agent-UMUIWWD2.js +8 -0
- package/dist/agent-UMUIWWD2.js.map +1 -0
- package/dist/chunk-4YJ5Z52Z.js +1789 -0
- package/dist/chunk-4YJ5Z52Z.js.map +1 -0
- package/dist/chunk-65UDUFUO.js +22133 -0
- package/dist/chunk-65UDUFUO.js.map +1 -0
- package/dist/chunk-DPULLAJG.js +215 -0
- package/dist/chunk-DPULLAJG.js.map +1 -0
- package/dist/chunk-HAN5D27J.js +292 -0
- package/dist/chunk-HAN5D27J.js.map +1 -0
- package/dist/chunk-K4V4QYCL.js +37683 -0
- package/dist/chunk-K4V4QYCL.js.map +1 -0
- package/dist/chunk-PZ5AY32C.js +10 -0
- package/dist/chunk-PZ5AY32C.js.map +1 -0
- package/dist/{index-DIiiwQY2.d.ts → index-DGUrY_yR.d.ts} +171 -18
- package/dist/index.d.ts +404 -125
- package/dist/index.js +8857 -412
- package/dist/index.js.map +1 -1
- package/dist/localSources-T3HZ6KY4.js +15 -0
- package/dist/localSources-T3HZ6KY4.js.map +1 -0
- package/dist/mcp-network.d.ts +78 -0
- package/dist/mcp-network.js +62 -0
- package/dist/mcp-network.js.map +1 -0
- package/dist/sandbox/index.d.ts +1 -1
- package/dist/sandbox/index.js +42 -5
- package/dist/skill-library.d.ts +74 -0
- package/dist/skill-library.js +18 -0
- package/dist/skill-library.js.map +1 -0
- package/package.json +18 -5
- package/src/bundled_hashicorp_terraform_skills/README.md +3 -3
- package/src/bundled_hashicorp_terraform_skills/checkov/SKILL.md +1 -1
- package/src/codex-tool-search.ts +20 -1
- package/src/context-compaction.ts +421 -24
- package/src/history-sanitizer.ts +14 -5
- package/src/index.ts +1806 -347
- package/src/mcp-network.ts +330 -0
- package/src/sandbox/channel-a.ts +526 -113
- package/src/sandbox/display-stack.ts +860 -23
- package/src/sandbox/exec-banner.ts +67 -0
- package/src/sandbox/index.ts +43 -2
- package/src/sandbox/providers/modal.ts +29 -2
- package/src/sandbox/routing/routing-session.ts +10 -2
- package/src/sandbox/run-credentials.ts +818 -0
- package/src/sandbox/select.ts +3 -3
- package/src/sandbox/selfhosted/capabilities.ts +1 -1
- package/src/sandbox/selfhosted/op-stream.ts +40 -0
- package/src/sandbox/selfhosted/op-testing.ts +50 -3
- package/src/sandbox/selfhosted/session.ts +17 -4
- package/src/sandbox/selfhosted/testing.ts +1 -1
- package/src/sandbox/stream-port.ts +1 -1
- package/src/sandbox/stream-token.ts +1 -1
- package/src/sandbox/terminal-server.ts +6 -2
- package/src/sandbox/toolspace-token.ts +147 -0
- package/src/sandbox/turn-tool-cancellation.ts +940 -0
- package/src/sandbox-computer.ts +3 -1
- package/src/skill-library.ts +323 -0
- package/src/usage-telemetry.ts +495 -51
- package/dist/chunk-RYDCVTMW.js +0 -5531
- package/dist/chunk-RYDCVTMW.js.map +0 -1
- /package/src/{bundled_hashicorp_terraform_skills → bundled_skill_library}/azure-verified-modules/SKILL.md +0 -0
|
@@ -0,0 +1,67 @@
|
|
|
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
|
+
}
|
package/src/sandbox/index.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// @opengeni/runtime/sandbox — the agent-loop-free sandbox leaf.
|
|
2
2
|
//
|
|
3
3
|
// This module is the load-bearing pre-req for the API-direct control plane
|
|
4
|
-
// (docs/
|
|
4
|
+
// (docs/connected-machines.md). It exposes the sandbox client factory plus
|
|
5
5
|
// the resume / recovery-envelope helpers that the API needs to touch a box by
|
|
6
6
|
// id (resume-by-id, file/exec/port ops) WITHOUT importing the @openai/agents
|
|
7
7
|
// agent-loop graph.
|
|
@@ -72,7 +72,9 @@ export {
|
|
|
72
72
|
type LiveModalSandboxLeaseAttribution,
|
|
73
73
|
type ModalModuleLoader,
|
|
74
74
|
type ModalOrphanSweepResult,
|
|
75
|
+
type ModalOrphanSweepTermination,
|
|
75
76
|
type ModalSandboxAttribution,
|
|
77
|
+
type RevalidateModalOrphanTermination,
|
|
76
78
|
} from "./providers/modal";
|
|
77
79
|
export {
|
|
78
80
|
selectBackend,
|
|
@@ -106,6 +108,11 @@ export {
|
|
|
106
108
|
ensureDisplayStack,
|
|
107
109
|
tearDownDisplayStack,
|
|
108
110
|
type DesktopGeometry,
|
|
111
|
+
type DisplayStackCallerKind,
|
|
112
|
+
type DisplayStackClassification,
|
|
113
|
+
type DisplayStackTelemetryContext,
|
|
114
|
+
type DisplayStackTelemetryEvent,
|
|
115
|
+
type DisplayStackTelemetryStatus,
|
|
109
116
|
type EnsureDisplayStackOptions,
|
|
110
117
|
type EnsureDisplayStackResult,
|
|
111
118
|
} from "./display-stack";
|
|
@@ -125,6 +132,39 @@ export {
|
|
|
125
132
|
type EnsureTerminalServerResult,
|
|
126
133
|
} from "./terminal-server";
|
|
127
134
|
|
|
135
|
+
// Host-owned rotating run credentials. Material lives outside the persisted
|
|
136
|
+
// workspace/manifest and is activated atomically per session generation.
|
|
137
|
+
export {
|
|
138
|
+
RunCredentialValidationError,
|
|
139
|
+
normalizeRunCredentialsResolution,
|
|
140
|
+
runCredentialRoot,
|
|
141
|
+
runCredentialPointerFile,
|
|
142
|
+
materializeRunCredentials,
|
|
143
|
+
clearRunCredentials,
|
|
144
|
+
clearRunCredentialsForAttempt,
|
|
145
|
+
withRunCredentialEnvironment,
|
|
146
|
+
withRunCredentialsSession,
|
|
147
|
+
withRunCredentialsClient,
|
|
148
|
+
type RunCredentialExpectedScope,
|
|
149
|
+
type NormalizedRunCredentialMaterial,
|
|
150
|
+
type RunCredentialCommandSession,
|
|
151
|
+
type RunCredentialCommandRunner,
|
|
152
|
+
type RunCredentialSessionReady,
|
|
153
|
+
type MaterializeRunCredentialsOptions,
|
|
154
|
+
} from "./run-credentials";
|
|
155
|
+
|
|
156
|
+
// Session-specific Toolspace token routing. The manifest retains one stable
|
|
157
|
+
// legacy pointer for warm-box env parity; every session command selects its own
|
|
158
|
+
// hashed token file off-manifest.
|
|
159
|
+
export {
|
|
160
|
+
ToolspaceTokenPathError,
|
|
161
|
+
toolspaceTokenFileForSession,
|
|
162
|
+
toolspaceTokenFileFromEnvironment,
|
|
163
|
+
withToolspaceTokenEnvironment,
|
|
164
|
+
withToolspaceTokenSession,
|
|
165
|
+
withToolspaceTokenClient,
|
|
166
|
+
} from "./toolspace-token";
|
|
167
|
+
|
|
128
168
|
// The Channel-B pixel DATA PLANE (P4.2). Resolves the provider's scoped tunnel
|
|
129
169
|
// for port 6080 (client → provider-tunnel direct), assembles the WS URL, and
|
|
130
170
|
// mints the scoped stream token. Called API-direct on the resumed handle.
|
|
@@ -164,12 +204,13 @@ export {
|
|
|
164
204
|
export {
|
|
165
205
|
SandboxChannelAService,
|
|
166
206
|
ChannelAValidationError,
|
|
207
|
+
ChannelAUnavailableError,
|
|
167
208
|
ChannelAConflictError,
|
|
168
209
|
ChannelANotFoundError,
|
|
169
210
|
ChannelAUnsupportedError,
|
|
170
211
|
stripExecBanner,
|
|
171
212
|
parseExecBannerSessionId,
|
|
172
|
-
|
|
213
|
+
parseExecBannerExitCode,
|
|
173
214
|
isExecSessionLostBanner,
|
|
174
215
|
assertSafeRelPath,
|
|
175
216
|
parsePorcelainV2,
|
|
@@ -38,6 +38,10 @@ export type ModalOrphanSweepResult = {
|
|
|
38
38
|
skipped: number;
|
|
39
39
|
};
|
|
40
40
|
|
|
41
|
+
export type RevalidateModalOrphanTermination = (
|
|
42
|
+
candidate: ModalOrphanSweepTermination,
|
|
43
|
+
) => Promise<boolean>;
|
|
44
|
+
|
|
41
45
|
export function modalSandboxAttributionEnvironment(
|
|
42
46
|
input: ModalSandboxAttribution,
|
|
43
47
|
): Record<string, string> {
|
|
@@ -337,6 +341,9 @@ export async function sweepModalOrphanSandboxes(
|
|
|
337
341
|
maxTerminations?: number;
|
|
338
342
|
unattributedGraceMs?: number;
|
|
339
343
|
client?: ModalClientLike;
|
|
344
|
+
/** Re-read durable ownership immediately before provider termination. A
|
|
345
|
+
* false result or callback failure skips the destructive action. */
|
|
346
|
+
revalidateTermination?: RevalidateModalOrphanTermination;
|
|
340
347
|
} = {},
|
|
341
348
|
): Promise<ModalOrphanSweepResult> {
|
|
342
349
|
const nowMs = options.now?.getTime() ?? Date.now();
|
|
@@ -437,10 +444,30 @@ export async function sweepModalOrphanSandboxes(
|
|
|
437
444
|
skipped += 1;
|
|
438
445
|
continue;
|
|
439
446
|
}
|
|
447
|
+
const candidate = { sandboxId: info.id, reason, tags };
|
|
448
|
+
let sandbox: Awaited<ReturnType<typeof modal.sandboxes.fromId>>;
|
|
449
|
+
try {
|
|
450
|
+
sandbox = await modal.sandboxes.fromId(info.id);
|
|
451
|
+
} catch {
|
|
452
|
+
skipped += 1;
|
|
453
|
+
continue;
|
|
454
|
+
}
|
|
455
|
+
if (options.revalidateTermination) {
|
|
456
|
+
try {
|
|
457
|
+
if (!(await options.revalidateTermination(candidate))) {
|
|
458
|
+
skipped += 1;
|
|
459
|
+
continue;
|
|
460
|
+
}
|
|
461
|
+
} catch {
|
|
462
|
+
// Destructive provider cleanup fails closed when the fresh durable
|
|
463
|
+
// ownership read is unavailable or otherwise inconclusive.
|
|
464
|
+
skipped += 1;
|
|
465
|
+
continue;
|
|
466
|
+
}
|
|
467
|
+
}
|
|
440
468
|
try {
|
|
441
|
-
const sandbox = await modal.sandboxes.fromId(info.id);
|
|
442
469
|
await sandbox.terminate();
|
|
443
|
-
terminated.push(
|
|
470
|
+
terminated.push(candidate);
|
|
444
471
|
} catch {
|
|
445
472
|
skipped += 1;
|
|
446
473
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// `RoutingSandboxSession` — the per-session hot-swap routing proxy (M7).
|
|
2
2
|
//
|
|
3
|
-
// THE load-bearing SDK finding
|
|
3
|
+
// THE load-bearing SDK finding: when a box is injected
|
|
4
4
|
// NON-OWNED into a turn (`ownedSandbox.session`), the agent SDK's sandbox
|
|
5
5
|
// capabilities bind to that ONE session OBJECT ONCE and call ITS methods
|
|
6
6
|
// (`exec`/`execCommand`/`readFile`/`listDir`/`resolveExposedPort`/…) per tool
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
// per-session active pointer `(active_sandbox_id, active_epoch)` and DISPATCHES
|
|
11
11
|
// to the CURRENTLY-active backend session (Modal or selfhosted).
|
|
12
12
|
//
|
|
13
|
-
// The contract
|
|
13
|
+
// The contract:
|
|
14
14
|
// - ONE stable object implementing the `SandboxSessionLike` structural surface.
|
|
15
15
|
// - On EVERY op, re-read `(activeSandboxId, activeEpoch)` via `readPointer`.
|
|
16
16
|
// - Cache the resolved backend session keyed by `activeEpoch`; when the epoch
|
|
@@ -58,6 +58,7 @@ export interface RoutableBackendSession {
|
|
|
58
58
|
exec?(args: unknown): Promise<unknown>;
|
|
59
59
|
execCommand?(args: unknown): Promise<string>;
|
|
60
60
|
writeStdin?(args: unknown): Promise<string>;
|
|
61
|
+
cancelExecCommand?(opId: string): Promise<boolean>;
|
|
61
62
|
readFile?(args: unknown): Promise<string | Uint8Array>;
|
|
62
63
|
writeFile?(args: unknown): Promise<unknown>;
|
|
63
64
|
createEditor?(runAs?: string): unknown;
|
|
@@ -430,6 +431,13 @@ export class RoutingSandboxSession implements RoutableBackendSession {
|
|
|
430
431
|
});
|
|
431
432
|
}
|
|
432
433
|
|
|
434
|
+
async cancelExecCommand(opId: string): Promise<boolean> {
|
|
435
|
+
return await this.dispatch("cancelExecCommand", async (session) => {
|
|
436
|
+
if (!session.cancelExecCommand) return false;
|
|
437
|
+
return await session.cancelExecCommand(opId);
|
|
438
|
+
});
|
|
439
|
+
}
|
|
440
|
+
|
|
433
441
|
async readFile(args: unknown): Promise<string | Uint8Array> {
|
|
434
442
|
return this.dispatch("readFile", async (s) => {
|
|
435
443
|
if (!s.readFile) {
|