@opengeni/runtime 4.3.0 → 4.4.0-canary.36927100590001
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/agent-instructions/base-behavior.d.ts +8 -0
- package/dist/agent-instructions/compose.d.ts +59 -0
- package/dist/agent-instructions/identity.d.ts +21 -0
- package/dist/agent-instructions/index.d.ts +6 -0
- package/dist/agent-instructions/modules/admin.d.ts +3 -0
- package/dist/agent-instructions/modules/artifacts.d.ts +7 -0
- package/dist/agent-instructions/modules/attachments.d.ts +3 -0
- package/dist/agent-instructions/modules/environment.d.ts +11 -0
- package/dist/agent-instructions/modules/goals.d.ts +3 -0
- package/dist/agent-instructions/modules/knowledge.d.ts +6 -0
- package/dist/agent-instructions/modules/machines.d.ts +3 -0
- package/dist/agent-instructions/modules/renderer-markdown.d.ts +6 -0
- package/dist/agent-instructions/modules/repositories.d.ts +7 -0
- package/dist/agent-instructions/modules/sandbox.d.ts +3 -0
- package/dist/agent-instructions/modules/skills.d.ts +3 -0
- package/dist/agent-instructions/modules/subagents.d.ts +3 -0
- package/dist/agent-instructions/runtime-mechanics.d.ts +7 -0
- package/dist/agent-instructions/types.d.ts +55 -0
- package/dist/assets/codemode-client.json +1 -1
- package/dist/{chunk-JUFVYQCY.js → chunk-VDXKKMMD.js} +457 -165
- package/dist/chunk-VDXKKMMD.js.map +1 -0
- package/dist/{chunk-22M75RJF.js → chunk-ZY655LYR.js} +1636 -709
- package/dist/chunk-ZY655LYR.js.map +1 -0
- package/dist/claude-subscription-usage.d.ts +3 -1
- package/dist/first-party-client.d.ts +1 -0
- package/dist/index.d.ts +37 -28
- package/dist/index.js +28 -2
- package/dist/input-wait-yield.d.ts +4 -0
- package/dist/interaction-tools.d.ts +1 -0
- package/dist/lazy-tool-transport.d.ts +6 -2
- package/dist/mcp-run-credentials.d.ts +3 -2
- package/dist/mcp-transport-logger.d.ts +10 -0
- package/dist/model-context-inspector.d.ts +17 -1
- package/dist/model-preparation-diagnostics.d.ts +9 -0
- package/dist/model-provider-routing.d.ts +4 -0
- package/dist/model-provider.d.ts +1 -0
- package/dist/model-request-capture.d.ts +9 -0
- package/dist/replayable-json-body.d.ts +2 -1
- package/dist/responses-terminal-error.d.ts +17 -0
- package/dist/sandbox/codemode-authority.d.ts +1 -0
- package/dist/sandbox/index.d.ts +3 -3
- package/dist/sandbox/index.js +5 -1
- package/dist/sandbox/provider-command-session.d.ts +6 -0
- package/dist/sandbox/providers/modal-command-control.d.ts +7 -0
- package/dist/sandbox/providers/modal-command-router-wire.d.ts +8 -0
- package/dist/sandbox/providers/modal-command-session.d.ts +2 -1
- package/dist/sandbox/providers/modal-command-start-errors.d.ts +9 -0
- package/dist/sandbox/providers/modal.d.ts +3 -0
- package/dist/sandbox/routing/routing-session.d.ts +5 -4
- package/dist/workspace-tool-gateway.js +2 -2
- package/package.json +12 -12
- package/src/agent-instructions/PROMPT_CHANGELOG.md +149 -0
- package/src/agent-instructions/base-behavior.ts +120 -0
- package/src/agent-instructions/compose.ts +153 -0
- package/src/agent-instructions/identity.ts +42 -0
- package/src/agent-instructions/index.ts +24 -0
- package/src/agent-instructions/modules/admin.ts +25 -0
- package/src/agent-instructions/modules/artifacts.ts +39 -0
- package/src/agent-instructions/modules/attachments.ts +12 -0
- package/src/agent-instructions/modules/environment.ts +60 -0
- package/src/agent-instructions/modules/goals.ts +15 -0
- package/src/agent-instructions/modules/knowledge.ts +21 -0
- package/src/agent-instructions/modules/machines.ts +17 -0
- package/src/agent-instructions/modules/renderer-markdown.ts +17 -0
- package/src/agent-instructions/modules/repositories.ts +28 -0
- package/src/agent-instructions/modules/sandbox.ts +63 -0
- package/src/agent-instructions/modules/skills.ts +19 -0
- package/src/agent-instructions/modules/subagents.ts +42 -0
- package/src/agent-instructions/runtime-mechanics.ts +55 -0
- package/src/agent-instructions/types.ts +83 -0
- package/src/bundled_default_skills/opengeni-client/SKILL.md +116 -37
- package/src/bundled_default_skills/opengeni-client/references/agent-recipes.md +18 -8
- package/src/bundled_default_skills/opengeni-client/references/api-workflows.md +24 -4
- package/src/bundled_default_skills/opengeni-client/references/chat-facade-fallback.md +23 -4
- package/src/bundled_default_skills/opengeni-client/references/compatibility-and-troubleshooting.md +34 -1
- package/src/bundled_default_skills/opengeni-client/references/configure-the-agent.md +248 -0
- package/src/bundled_default_skills/opengeni-client/references/customer-skill-template.md +2 -1
- package/src/bundled_default_skills/opengeni-client/references/data-tools-and-credentials.md +15 -4
- package/src/bundled_default_skills/opengeni-client/references/discovery-and-autonomy.md +2 -2
- package/src/bundled_default_skills/opengeni-client/references/isolation-and-authorization.md +5 -3
- package/src/bundled_default_skills/opengeni-client/references/product-integration-shapes.md +6 -5
- package/src/bundled_default_skills/opengeni-client/references/product-shapes-and-ui.md +36 -3
- package/src/bundled_default_skills/opengeni-client/references/proxy-from-any-backend.md +170 -0
- package/src/bundled_default_skills/opengeni-client/references/session-history-import.md +147 -0
- package/src/bundled_default_skills/opengeni-client/references/usage-allowances.md +189 -0
- package/src/bundled_default_skills/opengeni-help/SKILL.md +1 -1
- package/src/claude-subscription-usage.ts +23 -4
- package/src/first-party-client.ts +4 -0
- package/src/index.ts +260 -146
- package/src/input-wait-yield.ts +7 -0
- package/src/interaction-tools.ts +16 -2
- package/src/lazy-tool-transport.ts +46 -16
- package/src/mcp-run-credentials.ts +18 -3
- package/src/mcp-transport-logger.ts +46 -0
- package/src/model-context-inspector.ts +37 -3
- package/src/model-preparation-diagnostics.ts +48 -1
- package/src/model-provider-client.ts +5 -1
- package/src/model-provider-routing.ts +95 -1
- package/src/model-provider.ts +1 -0
- package/src/model-request-capture.ts +28 -1
- package/src/provider-history-adapter.ts +24 -3
- package/src/replayable-json-body.ts +19 -2
- package/src/responses-terminal-error.ts +136 -0
- package/src/sandbox/codemode-authority.ts +4 -0
- package/src/sandbox/codemode-client.ts +18 -16
- package/src/sandbox/index.ts +45 -9
- package/src/sandbox/provider-command-session.ts +12 -0
- package/src/sandbox/providers/modal-command-control.ts +118 -12
- package/src/sandbox/providers/modal-command-router-wire.ts +40 -4
- package/src/sandbox/providers/modal-command-session.ts +36 -1
- package/src/sandbox/providers/modal-command-start-errors.ts +27 -0
- package/src/sandbox/providers/modal-legacy-command-control.ts +60 -30
- package/src/sandbox/providers/modal.ts +43 -2
- package/src/sandbox/routing/routing-session.ts +61 -6
- package/src/sandbox/turn-tool-cancellation.ts +8 -1
- package/dist/chunk-22M75RJF.js.map +0 -1
- package/dist/chunk-JUFVYQCY.js.map +0 -1
|
@@ -396,9 +396,9 @@ function stdoutFromExecResult(value) {
|
|
|
396
396
|
function execFailureDiagnostic(value) {
|
|
397
397
|
if (!value || typeof value !== "object") return "result=unstructured";
|
|
398
398
|
const result = value;
|
|
399
|
-
const
|
|
399
|
+
const status4 = typeof result.exitCode === "number" ? `exitCode=${result.exitCode}` : typeof result.status === "number" ? `status=${result.status}` : "exitCode=unknown";
|
|
400
400
|
const stderr = typeof result.stderr === "string" ? result.stderr.replace(/\s+/g, " ").trim().slice(0, 240) : "";
|
|
401
|
-
return stderr.length > 0 ? `${
|
|
401
|
+
return stderr.length > 0 ? `${status4}, stderr=${stderr}` : status4;
|
|
402
402
|
}
|
|
403
403
|
function isTransientRootDirectoryFingerprintRace(value) {
|
|
404
404
|
if (!value || typeof value !== "object") return false;
|
|
@@ -1822,12 +1822,12 @@ async function persistRemoteWorkspaceTar(args) {
|
|
|
1822
1822
|
if (error instanceof SandboxArchiveError) {
|
|
1823
1823
|
throw error;
|
|
1824
1824
|
}
|
|
1825
|
-
throw new SandboxArchiveError(`${args.providerName} failed to persist the workspace archive.`, {
|
|
1825
|
+
throw Object.assign(new SandboxArchiveError(`${args.providerName} failed to persist the workspace archive.`, {
|
|
1826
1826
|
provider: args.providerName,
|
|
1827
1827
|
root,
|
|
1828
1828
|
archivePath,
|
|
1829
1829
|
cause: error instanceof Error ? error.message : String(error)
|
|
1830
|
-
});
|
|
1830
|
+
}), { cause: error });
|
|
1831
1831
|
} finally {
|
|
1832
1832
|
await args.io.runCommand(`rm -f -- ${shellQuote(archivePath)}`).catch(() => {
|
|
1833
1833
|
});
|
|
@@ -1869,12 +1869,12 @@ async function hydrateRemoteWorkspaceTar(args) {
|
|
|
1869
1869
|
if (error instanceof SandboxArchiveError) {
|
|
1870
1870
|
throw error;
|
|
1871
1871
|
}
|
|
1872
|
-
throw new SandboxArchiveError(`${args.providerName} failed to hydrate the workspace archive.`, {
|
|
1872
|
+
throw Object.assign(new SandboxArchiveError(`${args.providerName} failed to hydrate the workspace archive.`, {
|
|
1873
1873
|
provider: args.providerName,
|
|
1874
1874
|
root,
|
|
1875
1875
|
archivePath,
|
|
1876
1876
|
cause: error instanceof Error ? error.message : String(error)
|
|
1877
|
-
});
|
|
1877
|
+
}), { cause: error });
|
|
1878
1878
|
} finally {
|
|
1879
1879
|
await args.io.runCommand(`rm -f -- ${shellQuote(archivePath)}`).catch(() => {
|
|
1880
1880
|
});
|
|
@@ -2751,7 +2751,7 @@ async function closeRemoteSessionOnManifestError(providerName, session, manifest
|
|
|
2751
2751
|
try {
|
|
2752
2752
|
await session.close();
|
|
2753
2753
|
} catch (closeError) {
|
|
2754
|
-
throw new UserError(`Failed to apply a ${providerName} sandbox manifest and close the sandbox. Manifest error: ${providerErrorMessage(manifestError)} Close error: ${providerErrorMessage(closeError)}`);
|
|
2754
|
+
throw Object.assign(new UserError(`Failed to apply a ${providerName} sandbox manifest and close the sandbox. Manifest error: ${providerErrorMessage(manifestError)} Close error: ${providerErrorMessage(closeError)}`), { cause: new AggregateError([manifestError, closeError], "Sandbox manifest application and close both failed") });
|
|
2755
2755
|
}
|
|
2756
2756
|
throw manifestError;
|
|
2757
2757
|
}
|
|
@@ -2780,14 +2780,14 @@ async function withProviderError(providerName, provider, operation, fn, context
|
|
|
2780
2780
|
}
|
|
2781
2781
|
const cause = providerErrorMessage(error);
|
|
2782
2782
|
const retryable = providerErrorRetryability(error);
|
|
2783
|
-
throw new SandboxProviderError(`${providerName} failed to ${operation}${cause ? `: ${cause}` : ""}`, {
|
|
2783
|
+
throw Object.assign(new SandboxProviderError(`${providerName} failed to ${operation}${cause ? `: ${cause}` : ""}`, {
|
|
2784
2784
|
provider,
|
|
2785
2785
|
operation,
|
|
2786
2786
|
...context,
|
|
2787
2787
|
...providerErrorDetails(error),
|
|
2788
2788
|
retryable,
|
|
2789
2789
|
cause
|
|
2790
|
-
});
|
|
2790
|
+
}), { cause: error });
|
|
2791
2791
|
}
|
|
2792
2792
|
}
|
|
2793
2793
|
function isProviderSandboxNotFoundError(error) {
|
|
@@ -2887,9 +2887,9 @@ function readProviderErrorRetryability(value, seen, depth) {
|
|
|
2887
2887
|
if (typed !== null) {
|
|
2888
2888
|
return typed;
|
|
2889
2889
|
}
|
|
2890
|
-
const
|
|
2891
|
-
if (
|
|
2892
|
-
const retryable = retryabilityForHttpStatus(
|
|
2890
|
+
const status4 = readProviderStatus(value);
|
|
2891
|
+
if (status4 !== void 0) {
|
|
2892
|
+
const retryable = retryabilityForHttpStatus(status4);
|
|
2893
2893
|
if (retryable !== null) {
|
|
2894
2894
|
return retryable;
|
|
2895
2895
|
}
|
|
@@ -2948,21 +2948,21 @@ function retryabilityForErrorType(value) {
|
|
|
2948
2948
|
}
|
|
2949
2949
|
function readProviderStatus(value) {
|
|
2950
2950
|
for (const key of ["status", "statusCode", "httpStatus", "httpStatusCode"]) {
|
|
2951
|
-
const
|
|
2952
|
-
if (typeof
|
|
2953
|
-
return
|
|
2951
|
+
const status4 = value[key];
|
|
2952
|
+
if (typeof status4 === "number" && Number.isInteger(status4)) {
|
|
2953
|
+
return status4;
|
|
2954
2954
|
}
|
|
2955
|
-
if (typeof
|
|
2956
|
-
return Number(
|
|
2955
|
+
if (typeof status4 === "string" && /^\d+$/u.test(status4)) {
|
|
2956
|
+
return Number(status4);
|
|
2957
2957
|
}
|
|
2958
2958
|
}
|
|
2959
2959
|
return void 0;
|
|
2960
2960
|
}
|
|
2961
|
-
function retryabilityForHttpStatus(
|
|
2962
|
-
if ([408, 425, 429, 500, 502, 503, 504].includes(
|
|
2961
|
+
function retryabilityForHttpStatus(status4) {
|
|
2962
|
+
if ([408, 425, 429, 500, 502, 503, 504].includes(status4)) {
|
|
2963
2963
|
return true;
|
|
2964
2964
|
}
|
|
2965
|
-
if ([400, 401, 403, 404, 409, 422].includes(
|
|
2965
|
+
if ([400, 401, 403, 404, 409, 422].includes(status4)) {
|
|
2966
2966
|
return false;
|
|
2967
2967
|
}
|
|
2968
2968
|
return null;
|
|
@@ -5689,8 +5689,8 @@ function generateBlaxelSandboxName() {
|
|
|
5689
5689
|
return `openai-agents-${Math.random().toString(16).slice(2, 10)}`;
|
|
5690
5690
|
}
|
|
5691
5691
|
function isBlaxelSandboxNonResumable(sandbox) {
|
|
5692
|
-
const
|
|
5693
|
-
return
|
|
5692
|
+
const status4 = sandbox.status?.trim().toUpperCase();
|
|
5693
|
+
return status4 ? BLAXEL_NON_RESUMABLE_SANDBOX_STATUSES.has(status4) : false;
|
|
5694
5694
|
}
|
|
5695
5695
|
function assertBlaxelSandboxReusable(sandbox, sandboxName) {
|
|
5696
5696
|
if (!isBlaxelSandboxNonResumable(sandbox)) {
|
|
@@ -7216,11 +7216,11 @@ async function cloudflareProviderHttpErrorWithBody(operation, response, context
|
|
|
7216
7216
|
...cause ? { cause } : {}
|
|
7217
7217
|
});
|
|
7218
7218
|
}
|
|
7219
|
-
function cloudflareRetryabilityForStatus(
|
|
7220
|
-
if (
|
|
7219
|
+
function cloudflareRetryabilityForStatus(status4) {
|
|
7220
|
+
if (status4 === 500 || status4 === 503) {
|
|
7221
7221
|
return true;
|
|
7222
7222
|
}
|
|
7223
|
-
if (
|
|
7223
|
+
if (status4 === 400) {
|
|
7224
7224
|
return false;
|
|
7225
7225
|
}
|
|
7226
7226
|
return null;
|
|
@@ -14339,9 +14339,9 @@ var ModalSandboxSession = class {
|
|
|
14339
14339
|
stderr += chunk;
|
|
14340
14340
|
});
|
|
14341
14341
|
try {
|
|
14342
|
-
const
|
|
14342
|
+
const status4 = await process2.wait();
|
|
14343
14343
|
await stderrPump.promise;
|
|
14344
|
-
return { status:
|
|
14344
|
+
return { status: status4, stderr };
|
|
14345
14345
|
} catch (error) {
|
|
14346
14346
|
await stderrPump.cancel();
|
|
14347
14347
|
throw error;
|
|
@@ -15966,22 +15966,22 @@ function parseExecResponseBanner(raw) {
|
|
|
15966
15966
|
}
|
|
15967
15967
|
if (delimiter.index > EXEC_BANNER_HEADER_MAX_CHARS) return { kind: "invalid" };
|
|
15968
15968
|
const header = raw.slice(0, delimiter.index);
|
|
15969
|
-
const
|
|
15969
|
+
const status4 = [];
|
|
15970
15970
|
for (const line of header.split(/\r?\n/u)) {
|
|
15971
15971
|
const running = RUNNING_LINE.exec(line);
|
|
15972
15972
|
if (running) {
|
|
15973
|
-
|
|
15973
|
+
status4.push({ kind: "running", value: running[1] });
|
|
15974
15974
|
continue;
|
|
15975
15975
|
}
|
|
15976
15976
|
const exited = EXITED_LINE.exec(line);
|
|
15977
15977
|
if (exited) {
|
|
15978
|
-
|
|
15978
|
+
status4.push({ kind: "exited", value: exited[1] });
|
|
15979
15979
|
continue;
|
|
15980
15980
|
}
|
|
15981
15981
|
if (PROCESS_STATUS_PREFIX.test(line)) return { kind: "invalid" };
|
|
15982
15982
|
}
|
|
15983
|
-
if (
|
|
15984
|
-
const terminal =
|
|
15983
|
+
if (status4.length !== 1) return { kind: "invalid" };
|
|
15984
|
+
const terminal = status4[0];
|
|
15985
15985
|
const value = Number(terminal.value);
|
|
15986
15986
|
if (!Number.isSafeInteger(value)) return { kind: "invalid" };
|
|
15987
15987
|
if (terminal.kind === "running") {
|
|
@@ -16049,6 +16049,26 @@ import { SandboxFilesystemNotFoundError } from "modal";
|
|
|
16049
16049
|
import { Client, Metadata, credentials, status } from "@grpc/grpc-js";
|
|
16050
16050
|
import protobuf from "protobufjs";
|
|
16051
16051
|
|
|
16052
|
+
// src/sandbox/providers/modal-command-start-errors.ts
|
|
16053
|
+
var boundaryBrand = Symbol.for("opengeni.modal.command-start.boundary.v1");
|
|
16054
|
+
function hasModalCommandStartBoundary(error, kind) {
|
|
16055
|
+
if (!error || typeof error !== "object") return false;
|
|
16056
|
+
try {
|
|
16057
|
+
return Object.getOwnPropertyDescriptor(error, boundaryBrand)?.value === kind;
|
|
16058
|
+
} catch {
|
|
16059
|
+
return false;
|
|
16060
|
+
}
|
|
16061
|
+
}
|
|
16062
|
+
var ModalCommandStartOutcomeUnknownError = class extends Error {
|
|
16063
|
+
constructor(taskId, execId, cause) {
|
|
16064
|
+
super("Modal command Start outcome unknown; do not replay this invocation", { cause });
|
|
16065
|
+
this.taskId = taskId;
|
|
16066
|
+
this.execId = execId;
|
|
16067
|
+
this.name = "CommandStartOutcomeUnknownError";
|
|
16068
|
+
Object.defineProperty(this, boundaryBrand, { value: "outcome-unknown" });
|
|
16069
|
+
}
|
|
16070
|
+
};
|
|
16071
|
+
|
|
16052
16072
|
// src/sandbox/provider-command-session.ts
|
|
16053
16073
|
import { AsyncLocalStorage as AsyncLocalStorage2 } from "async_hooks";
|
|
16054
16074
|
var ProviderCommandStartRejectedError = class extends Error {
|
|
@@ -16057,6 +16077,13 @@ var ProviderCommandStartRejectedError = class extends Error {
|
|
|
16057
16077
|
this.name = "ProviderCommandStartRejectedError";
|
|
16058
16078
|
}
|
|
16059
16079
|
};
|
|
16080
|
+
var ProviderCommandStartOutcomeUnknownError = class extends Error {
|
|
16081
|
+
constructor(command, cause) {
|
|
16082
|
+
super("Provider command Start outcome is unknown; the invocation was not replayed", { cause });
|
|
16083
|
+
this.command = command;
|
|
16084
|
+
this.name = "ProviderCommandStartOutcomeUnknownError";
|
|
16085
|
+
}
|
|
16086
|
+
};
|
|
16060
16087
|
var admission = new AsyncLocalStorage2();
|
|
16061
16088
|
var pendingSupervision = new AsyncLocalStorage2();
|
|
16062
16089
|
function withPendingCommandSupervision(state, fn) {
|
|
@@ -16133,6 +16160,20 @@ var ModalCommandStartPreDispatchUnavailableError = class _ModalCommandStartPreDi
|
|
|
16133
16160
|
super("Modal command router was not ready before Start dispatch", { cause });
|
|
16134
16161
|
this.name = "ModalCommandStartPreDispatchUnavailableError";
|
|
16135
16162
|
}
|
|
16163
|
+
/** The supplied operation must contain only read-only preparation, never
|
|
16164
|
+
* Start itself. Its transport failure therefore proves non-dispatch. */
|
|
16165
|
+
static async beforeDispatch(operation, signal) {
|
|
16166
|
+
signal?.throwIfAborted();
|
|
16167
|
+
try {
|
|
16168
|
+
return await operation();
|
|
16169
|
+
} catch (error) {
|
|
16170
|
+
signal?.throwIfAborted();
|
|
16171
|
+
const code = error?.code;
|
|
16172
|
+
if (error instanceof Error && (code === status.UNAVAILABLE || code === status.DEADLINE_EXCEEDED))
|
|
16173
|
+
throw new _ModalCommandStartPreDispatchUnavailableError(error);
|
|
16174
|
+
throw error;
|
|
16175
|
+
}
|
|
16176
|
+
}
|
|
16136
16177
|
static async ensureReady(client, signal) {
|
|
16137
16178
|
signal?.throwIfAborted();
|
|
16138
16179
|
await new Promise((resolve7, reject) => {
|
|
@@ -16152,6 +16193,14 @@ var ModalCommandStartPreDispatchUnavailableError = class _ModalCommandStartPreDi
|
|
|
16152
16193
|
});
|
|
16153
16194
|
}
|
|
16154
16195
|
};
|
|
16196
|
+
var ModalCommandStartNotDispatchedError = class extends Error {
|
|
16197
|
+
constructor(cause) {
|
|
16198
|
+
super(cause instanceof Error ? cause.message : "Modal command Start was never dispatched", {
|
|
16199
|
+
cause
|
|
16200
|
+
});
|
|
16201
|
+
this.name = "ModalCommandStartNotDispatchedError";
|
|
16202
|
+
}
|
|
16203
|
+
};
|
|
16155
16204
|
function encode(type, value) {
|
|
16156
16205
|
const codec = modalRouterWire.lookupType(type);
|
|
16157
16206
|
return Buffer.from(codec.encode(codec.fromObject(value)).finish());
|
|
@@ -16209,12 +16258,18 @@ var ModalCommandRouterWire = class {
|
|
|
16209
16258
|
});
|
|
16210
16259
|
}
|
|
16211
16260
|
async start(request, signal) {
|
|
16212
|
-
if (this.closed) throw new Error("Modal command router is closed");
|
|
16213
16261
|
try {
|
|
16262
|
+
if (this.closed) throw new Error("Modal command router is closed");
|
|
16214
16263
|
await ModalCommandStartPreDispatchUnavailableError.ensureReady(this.client, signal);
|
|
16264
|
+
signal?.throwIfAborted();
|
|
16265
|
+
if (this.closed) throw new Error("Modal command router is closed");
|
|
16215
16266
|
} catch (error) {
|
|
16216
|
-
if (this.closed)
|
|
16217
|
-
|
|
16267
|
+
if (this.closed)
|
|
16268
|
+
throw new ModalCommandStartNotDispatchedError(
|
|
16269
|
+
new Error("Modal command router is closed", { cause: error })
|
|
16270
|
+
);
|
|
16271
|
+
if (error instanceof ModalCommandStartPreDispatchUnavailableError) throw error;
|
|
16272
|
+
throw new ModalCommandStartNotDispatchedError(error);
|
|
16218
16273
|
}
|
|
16219
16274
|
try {
|
|
16220
16275
|
await this.unary(
|
|
@@ -16238,7 +16293,7 @@ var ModalCommandRouterWire = class {
|
|
|
16238
16293
|
status.UNIMPLEMENTED
|
|
16239
16294
|
].includes(code))
|
|
16240
16295
|
throw new ModalCommandStartRejectedError(code, error);
|
|
16241
|
-
throw error;
|
|
16296
|
+
throw new ModalCommandStartOutcomeUnknownError(request.taskId, request.execId, error);
|
|
16242
16297
|
}
|
|
16243
16298
|
}
|
|
16244
16299
|
async write(identity, offset, data, signal) {
|
|
@@ -16881,6 +16936,10 @@ var RoutingRetainedProcessNotFoundError = class extends Error {
|
|
|
16881
16936
|
name = "RoutingRetainedProcessNotFoundError";
|
|
16882
16937
|
retryable = false;
|
|
16883
16938
|
};
|
|
16939
|
+
function renderRoutingMutationOutcomeUnknownToolResult(error) {
|
|
16940
|
+
const locator = error.retainedProcess ? ` Inspect the exact invocation with write_stdin using session_id ${error.retainedProcess.providerSessionId} and empty chars.` : " Inspect state before deciding how to proceed.";
|
|
16941
|
+
return `Sandbox operation outcome unknown; the operation was not replayed. Do not blindly retry the command.${locator} Error: ${error}`;
|
|
16942
|
+
}
|
|
16884
16943
|
function isFenceError(error) {
|
|
16885
16944
|
if (!error || typeof error !== "object") {
|
|
16886
16945
|
return false;
|
|
@@ -17249,7 +17308,8 @@ var RoutingSandboxSession = class {
|
|
|
17249
17308
|
{ cause: error }
|
|
17250
17309
|
);
|
|
17251
17310
|
}
|
|
17252
|
-
|
|
17311
|
+
if (pending.result !== void 0)
|
|
17312
|
+
await this.captureRetainedOutput(record, formatExecResult(pending.result));
|
|
17253
17313
|
}
|
|
17254
17314
|
confirmDurableRejectedPromotion(record, result) {
|
|
17255
17315
|
if (result.status !== "retained_process_durable_output_rejected" || result.retainedProcess.id !== record.process.id || result.retainedProcess.providerSessionId !== record.process.providerSessionId) {
|
|
@@ -17788,8 +17848,43 @@ var RoutingSandboxSession = class {
|
|
|
17788
17848
|
);
|
|
17789
17849
|
}
|
|
17790
17850
|
} catch (error) {
|
|
17851
|
+
if (!reservedProcess && error instanceof ProviderCommandStartOutcomeUnknownError && mutatesWorkspace && this.deps.afterMutation) {
|
|
17852
|
+
const handle = this.deps.providerCommandHandle?.(admission2);
|
|
17853
|
+
if (!handle) throw error;
|
|
17854
|
+
const process2 = {
|
|
17855
|
+
id: crypto.randomUUID(),
|
|
17856
|
+
providerSessionId: handle,
|
|
17857
|
+
providerCommand: error.command
|
|
17858
|
+
};
|
|
17859
|
+
const record = this.registerRetainedProcess(process2, backend);
|
|
17860
|
+
const settlement = {
|
|
17861
|
+
op,
|
|
17862
|
+
backend,
|
|
17863
|
+
admission: admission2,
|
|
17864
|
+
outcome: "outcome_unknown",
|
|
17865
|
+
retainedProcess: process2
|
|
17866
|
+
};
|
|
17867
|
+
record.pendingParentPromotion = settlement;
|
|
17868
|
+
try {
|
|
17869
|
+
const rejected = await this.deps.afterMutation(settlement);
|
|
17870
|
+
if (rejected) this.confirmDurableRejectedPromotion(record, rejected);
|
|
17871
|
+
else record.durable = true;
|
|
17872
|
+
record.pendingParentPromotion = null;
|
|
17873
|
+
} catch (cause) {
|
|
17874
|
+
throw new RoutingMutationOutcomeUnknownError(
|
|
17875
|
+
op,
|
|
17876
|
+
"Command Start outcome is unknown and exact invocation promotion remains unresolved; it was not replayed",
|
|
17877
|
+
{ cause: new AggregateError([error, cause]), retainedProcess: process2 }
|
|
17878
|
+
);
|
|
17879
|
+
}
|
|
17880
|
+
throw new RoutingMutationOutcomeUnknownError(
|
|
17881
|
+
op,
|
|
17882
|
+
"Command Start outcome is unknown; its exact invocation is retained and was not replayed",
|
|
17883
|
+
{ cause: error, retainedProcess: process2 }
|
|
17884
|
+
);
|
|
17885
|
+
}
|
|
17791
17886
|
if (reservedProcess) {
|
|
17792
|
-
if ((error instanceof ProviderCommandStartRejectedError || error instanceof ModalCommandStartPreDispatchUnavailableError) && reservedProcess.providerCommand?.kind === "modal-router-v1") {
|
|
17887
|
+
if ((error instanceof ProviderCommandStartRejectedError || error instanceof ModalCommandStartNotDispatchedError || error instanceof ModalCommandStartPreDispatchUnavailableError) && reservedProcess.providerCommand?.kind === "modal-router-v1") {
|
|
17793
17888
|
const persistence = this.deps.providerCommandPersistence?.(reservedProcess);
|
|
17794
17889
|
if (persistence?.rejectSupervisedLaunch) {
|
|
17795
17890
|
try {
|
|
@@ -18549,20 +18644,20 @@ async function assertProviderCanSeeMaterializedPath(session, path) {
|
|
|
18549
18644
|
causeMessage: cause instanceof Error ? cause.message : String(cause)
|
|
18550
18645
|
});
|
|
18551
18646
|
}
|
|
18552
|
-
const
|
|
18647
|
+
const status4 = parseExecResponseBanner(output);
|
|
18553
18648
|
const markerPresent = stripExecBanner(output).includes(MATERIALIZED_PATH_MARKER);
|
|
18554
|
-
if (markerPresent && (
|
|
18649
|
+
if (markerPresent && (status4.kind === "absent" || status4.kind === "exited" && status4.exitCode === 0)) {
|
|
18555
18650
|
return;
|
|
18556
18651
|
}
|
|
18557
|
-
const reason =
|
|
18652
|
+
const reason = status4.kind === "running" ? "command_pending" : status4.kind === "exited" && status4.exitCode === 1 ? "path_not_visible" : status4.kind === "exited" && status4.exitCode !== 0 ? "command_failed" : "invalid_response";
|
|
18558
18653
|
throw new SandboxMaterializationVerificationError({
|
|
18559
18654
|
reason,
|
|
18560
18655
|
path,
|
|
18561
18656
|
workdir: args.workdir,
|
|
18562
18657
|
command,
|
|
18563
18658
|
output,
|
|
18564
|
-
exitCode:
|
|
18565
|
-
providerSessionId:
|
|
18659
|
+
exitCode: status4.kind === "exited" ? status4.exitCode : null,
|
|
18660
|
+
providerSessionId: status4.kind === "running" ? status4.sessionId : null
|
|
18566
18661
|
});
|
|
18567
18662
|
}
|
|
18568
18663
|
function providerManifestRoot(session) {
|
|
@@ -19022,6 +19117,8 @@ Output:
|
|
|
19022
19117
|
}
|
|
19023
19118
|
} catch {
|
|
19024
19119
|
}
|
|
19120
|
+
if (error instanceof RoutingMutationOutcomeUnknownError)
|
|
19121
|
+
return renderRoutingMutationOutcomeUnknownToolResult(error);
|
|
19025
19122
|
const details = error instanceof Error ? error.toString() : String(error);
|
|
19026
19123
|
return `An error occurred while running the tool. Please try again. Error: ${details}`;
|
|
19027
19124
|
}
|
|
@@ -19475,6 +19572,8 @@ var TurnToolCancellationControllerImpl = class {
|
|
|
19475
19572
|
});
|
|
19476
19573
|
}
|
|
19477
19574
|
pendingStart?.settle();
|
|
19575
|
+
if (error instanceof RoutingMutationOutcomeUnknownError)
|
|
19576
|
+
return renderRoutingMutationOutcomeUnknownToolResult(error);
|
|
19478
19577
|
throw error;
|
|
19479
19578
|
} finally {
|
|
19480
19579
|
remoteExec?.settle();
|
|
@@ -21656,19 +21755,19 @@ var SandboxChannelAService = class {
|
|
|
21656
21755
|
}
|
|
21657
21756
|
async gitStatus(req) {
|
|
21658
21757
|
const repo = assertSafeRelPathOrRoot(req.path, this.workspaceRoot);
|
|
21659
|
-
const
|
|
21758
|
+
const status4 = await this.readConfinedCommandBytes(
|
|
21660
21759
|
repo,
|
|
21661
21760
|
`if [ "$(git rev-parse --is-inside-work-tree 2>/dev/null)" = true ]; then printf '${GIT_STATUS_REPO_FRAME}\\0'; git status --porcelain=v2 --branch -z; else printf '${GIT_STATUS_REPO_FRAME}not-repo\\0'; fi`,
|
|
21662
21761
|
GIT_METADATA_MAX_BYTES
|
|
21663
21762
|
);
|
|
21664
|
-
if (
|
|
21763
|
+
if (status4.truncated) {
|
|
21665
21764
|
throw new ChannelAUnavailableError(
|
|
21666
21765
|
"Workspace Git metadata exceeded the safe capture limit. Retry with a narrower path."
|
|
21667
21766
|
);
|
|
21668
21767
|
}
|
|
21669
21768
|
const repoFrame = Buffer.from(`${GIT_STATUS_REPO_FRAME}${NUL}`);
|
|
21670
21769
|
const notRepoFrame = Buffer.from(`${GIT_STATUS_REPO_FRAME}not-repo${NUL}`);
|
|
21671
|
-
if (
|
|
21770
|
+
if (status4.bytes.equals(notRepoFrame)) {
|
|
21672
21771
|
return {
|
|
21673
21772
|
isRepo: false,
|
|
21674
21773
|
head: null,
|
|
@@ -21681,13 +21780,13 @@ var SandboxChannelAService = class {
|
|
|
21681
21780
|
revision: this.revision
|
|
21682
21781
|
};
|
|
21683
21782
|
}
|
|
21684
|
-
if (!
|
|
21783
|
+
if (!status4.bytes.subarray(0, repoFrame.byteLength).equals(repoFrame)) {
|
|
21685
21784
|
throw new ChannelAUnavailableError(
|
|
21686
21785
|
"Workspace Git data is temporarily unavailable. Retry the operation."
|
|
21687
21786
|
);
|
|
21688
21787
|
}
|
|
21689
21788
|
return {
|
|
21690
|
-
...parsePorcelainV2(decodeGitMetadataUtf8(
|
|
21789
|
+
...parsePorcelainV2(decodeGitMetadataUtf8(status4.bytes.subarray(repoFrame.byteLength))),
|
|
21691
21790
|
revision: this.revision
|
|
21692
21791
|
};
|
|
21693
21792
|
}
|
|
@@ -22072,11 +22171,11 @@ var SandboxChannelAService = class {
|
|
|
22072
22171
|
});
|
|
22073
22172
|
const statusLine = stdout.split("\n").find((line) => line.startsWith(REPOSITORY_DISCOVERY_STATUS_PREFIX));
|
|
22074
22173
|
const embeddedStatus = statusLine ? Number.parseInt(statusLine.slice(REPOSITORY_DISCOVERY_STATUS_PREFIX.length), 10) : null;
|
|
22075
|
-
const
|
|
22076
|
-
if (
|
|
22174
|
+
const status4 = Number.isInteger(embeddedStatus) ? embeddedStatus : null;
|
|
22175
|
+
if (status4 === 124) {
|
|
22077
22176
|
return { repos: [], complete: false, degradedReason: "command_timed_out" };
|
|
22078
22177
|
}
|
|
22079
|
-
if (
|
|
22178
|
+
if (status4 !== 0) {
|
|
22080
22179
|
return { repos: [], complete: false, degradedReason: "command_failed" };
|
|
22081
22180
|
}
|
|
22082
22181
|
const lines = stdout.split("\n").map((l) => l.trim()).filter((line) => Boolean(line) && !line.startsWith(REPOSITORY_DISCOVERY_STATUS_PREFIX));
|
|
@@ -22645,13 +22744,13 @@ var SandboxChannelAService = class {
|
|
|
22645
22744
|
* worker agent-turn side after FS-mutating tools). */
|
|
22646
22745
|
async emitGitChanged(repoPath, reason) {
|
|
22647
22746
|
try {
|
|
22648
|
-
const
|
|
22747
|
+
const status4 = await this.gitStatus({ path: repoPath });
|
|
22649
22748
|
const payload = {
|
|
22650
|
-
head:
|
|
22651
|
-
dirty:
|
|
22652
|
-
ahead:
|
|
22653
|
-
behind:
|
|
22654
|
-
changedFileCount:
|
|
22749
|
+
head: status4.head,
|
|
22750
|
+
dirty: status4.files.length > 0,
|
|
22751
|
+
ahead: status4.ahead,
|
|
22752
|
+
behind: status4.behind,
|
|
22753
|
+
changedFileCount: status4.files.length,
|
|
22655
22754
|
reason,
|
|
22656
22755
|
revision: this.revision,
|
|
22657
22756
|
leaseEpoch: this.leaseEpoch
|
|
@@ -23142,14 +23241,14 @@ function splitUnifiedPatchFiles(patch) {
|
|
|
23142
23241
|
function parseUnifiedPatch(patch) {
|
|
23143
23242
|
const lines = patch.split("\n");
|
|
23144
23243
|
const hunks = [];
|
|
23145
|
-
let
|
|
23244
|
+
let status4 = "modified";
|
|
23146
23245
|
let current = null;
|
|
23147
23246
|
let oldNo = 0;
|
|
23148
23247
|
let newNo = 0;
|
|
23149
23248
|
for (const line of lines) {
|
|
23150
|
-
if (line.startsWith("new file mode"))
|
|
23151
|
-
else if (line.startsWith("deleted file mode"))
|
|
23152
|
-
else if (line.startsWith("rename from") || line.startsWith("rename to"))
|
|
23249
|
+
if (line.startsWith("new file mode")) status4 = "added";
|
|
23250
|
+
else if (line.startsWith("deleted file mode")) status4 = "deleted";
|
|
23251
|
+
else if (line.startsWith("rename from") || line.startsWith("rename to")) status4 = "renamed";
|
|
23153
23252
|
if (line.startsWith("@@")) {
|
|
23154
23253
|
const m = line.match(/^@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@(.*)$/);
|
|
23155
23254
|
if (m) {
|
|
@@ -23187,7 +23286,7 @@ function parseUnifiedPatch(patch) {
|
|
|
23187
23286
|
newNo++;
|
|
23188
23287
|
}
|
|
23189
23288
|
}
|
|
23190
|
-
return { hunks, status:
|
|
23289
|
+
return { hunks, status: status4 };
|
|
23191
23290
|
}
|
|
23192
23291
|
|
|
23193
23292
|
// src/sandbox/providers/modal-command-session.ts
|
|
@@ -23295,6 +23394,24 @@ function installModalCommandSession(session, control) {
|
|
|
23295
23394
|
const originalWrite = session.writeStdin?.bind(session);
|
|
23296
23395
|
const cancelLegacyStart = session.cancelPendingExecCommand?.bind(session);
|
|
23297
23396
|
const pendingStarts = /* @__PURE__ */ new Set();
|
|
23397
|
+
if (control.verifyExecReadiness) {
|
|
23398
|
+
const verify = control.verifyExecReadiness.bind(control);
|
|
23399
|
+
session.verifyExecReadiness = async (signal) => {
|
|
23400
|
+
const cancellation = new AbortController();
|
|
23401
|
+
const abort = () => cancellation.abort(signal.reason);
|
|
23402
|
+
signal.addEventListener("abort", abort, { once: true });
|
|
23403
|
+
if (signal.aborted) abort();
|
|
23404
|
+
pendingStarts.add(cancellation);
|
|
23405
|
+
try {
|
|
23406
|
+
const exit = await verify(cancellation.signal);
|
|
23407
|
+
cancellation.signal.throwIfAborted();
|
|
23408
|
+
return exit;
|
|
23409
|
+
} finally {
|
|
23410
|
+
signal.removeEventListener("abort", abort);
|
|
23411
|
+
pendingStarts.delete(cancellation);
|
|
23412
|
+
}
|
|
23413
|
+
};
|
|
23414
|
+
}
|
|
23298
23415
|
session.verifyCommandSupervisionCapability = async () => {
|
|
23299
23416
|
if (!control.verifySupervisionCapability)
|
|
23300
23417
|
throw new Error("Modal instance lacks supervised command capability verification");
|
|
@@ -23429,6 +23546,16 @@ function installModalCommandSession(session, control) {
|
|
|
23429
23546
|
exitCode: null
|
|
23430
23547
|
});
|
|
23431
23548
|
}
|
|
23549
|
+
} catch (error) {
|
|
23550
|
+
if (error instanceof ProviderCommandStartOutcomeUnknownError) {
|
|
23551
|
+
const entry = entries.get(handle);
|
|
23552
|
+
if (entry && !sameExecution(entry.command, error.command))
|
|
23553
|
+
throw new Error("Reserved Modal command changed during failed dispatch", {
|
|
23554
|
+
cause: error
|
|
23555
|
+
});
|
|
23556
|
+
entries.set(handle, entry ?? { command: error.command });
|
|
23557
|
+
}
|
|
23558
|
+
throw error;
|
|
23432
23559
|
} finally {
|
|
23433
23560
|
pendingStarts.delete(cancellation);
|
|
23434
23561
|
}
|
|
@@ -23542,6 +23669,8 @@ function installModalCommandSession(session, control) {
|
|
|
23542
23669
|
// src/sandbox/providers/modal-command-control.ts
|
|
23543
23670
|
import { randomUUID as randomUUID6, randomBytes } from "crypto";
|
|
23544
23671
|
import { posix as posix3 } from "path";
|
|
23672
|
+
import { status as status3 } from "@grpc/grpc-js";
|
|
23673
|
+
import { setTimeout as delay2 } from "timers/promises";
|
|
23545
23674
|
import {
|
|
23546
23675
|
SandboxProviderCommand,
|
|
23547
23676
|
CommandSupervisionReceipt
|
|
@@ -23550,6 +23679,7 @@ import {
|
|
|
23550
23679
|
// src/sandbox/providers/modal-legacy-command-control.ts
|
|
23551
23680
|
import { posix as posix2 } from "path";
|
|
23552
23681
|
import { ModalClient } from "modal";
|
|
23682
|
+
import { status as status2 } from "@grpc/grpc-js";
|
|
23553
23683
|
import { ModalLegacyProviderCommand } from "@opengeni/contracts";
|
|
23554
23684
|
var modalCommandAbortMiddleware = async function* (call, options) {
|
|
23555
23685
|
options.signal?.throwIfAborted();
|
|
@@ -23626,7 +23756,10 @@ var ModalCommandControl = class _ModalCommandControl {
|
|
|
23626
23756
|
if (workdir !== this.root && !workdir.startsWith(`${this.root.replace(/\/$/u, "")}/`))
|
|
23627
23757
|
throw new Error("Command workdir is outside the sandbox workspace");
|
|
23628
23758
|
const sandboxId = this.sandboxId;
|
|
23629
|
-
const task = await
|
|
23759
|
+
const task = await ModalCommandStartPreDispatchUnavailableError.beforeDispatch(
|
|
23760
|
+
() => this.client.sandboxGetTaskId({ sandboxId }, signal ? { signal } : void 0),
|
|
23761
|
+
signal
|
|
23762
|
+
);
|
|
23630
23763
|
if (!task.taskId || task.taskResult) throw new Error("Modal command task is unavailable");
|
|
23631
23764
|
if (sandboxId !== this.sandboxId)
|
|
23632
23765
|
throw new Error("Modal sandbox changed during command preparation");
|
|
@@ -23672,8 +23805,24 @@ var ModalCommandControl = class _ModalCommandControl {
|
|
|
23672
23805
|
} : {}
|
|
23673
23806
|
},
|
|
23674
23807
|
{ retries: 0, ...signal ? { signal } : {} }
|
|
23675
|
-
)
|
|
23676
|
-
|
|
23808
|
+
).catch((error) => {
|
|
23809
|
+
const code = error?.code;
|
|
23810
|
+
if (typeof code === "number" && [
|
|
23811
|
+
status2.INVALID_ARGUMENT,
|
|
23812
|
+
status2.NOT_FOUND,
|
|
23813
|
+
status2.PERMISSION_DENIED,
|
|
23814
|
+
status2.UNAUTHENTICATED,
|
|
23815
|
+
status2.UNIMPLEMENTED
|
|
23816
|
+
].includes(code))
|
|
23817
|
+
throw new ProviderCommandStartRejectedError(error);
|
|
23818
|
+
throw new ModalCommandStartOutcomeUnknownError(task.taskId, "", error);
|
|
23819
|
+
});
|
|
23820
|
+
if (!result.execId)
|
|
23821
|
+
throw new ModalCommandStartOutcomeUnknownError(
|
|
23822
|
+
task.taskId,
|
|
23823
|
+
"",
|
|
23824
|
+
new Error("Modal command start returned no execution identity")
|
|
23825
|
+
);
|
|
23677
23826
|
return {
|
|
23678
23827
|
kind: "modal-control-v1",
|
|
23679
23828
|
sandboxId,
|
|
@@ -23871,6 +24020,22 @@ var ModalCommandControl2 = class _ModalCommandControl {
|
|
|
23871
24020
|
entry.value.router.close();
|
|
23872
24021
|
}
|
|
23873
24022
|
}
|
|
24023
|
+
/** Access lookup may retry safely, but once the callback enters the Start
|
|
24024
|
+
* boundary only the wire's own dispatch proof can authorize recovery. */
|
|
24025
|
+
async withStartRouter(taskId, signal, run2) {
|
|
24026
|
+
let entered = false;
|
|
24027
|
+
try {
|
|
24028
|
+
return await this.withRouter(taskId, signal, async (router) => {
|
|
24029
|
+
entered = true;
|
|
24030
|
+
return await run2(router);
|
|
24031
|
+
});
|
|
24032
|
+
} catch (error) {
|
|
24033
|
+
if (entered) throw error;
|
|
24034
|
+
return await ModalCommandStartPreDispatchUnavailableError.beforeDispatch(async () => {
|
|
24035
|
+
throw error;
|
|
24036
|
+
}, signal);
|
|
24037
|
+
}
|
|
24038
|
+
}
|
|
23874
24039
|
async start(args, signal) {
|
|
23875
24040
|
signal?.throwIfAborted();
|
|
23876
24041
|
const supervised = admittedCommandSupervisionReady() && !args.tty && !args.runAs;
|
|
@@ -23879,7 +24044,10 @@ var ModalCommandControl2 = class _ModalCommandControl {
|
|
|
23879
24044
|
const workdir = posix3.resolve(this.root, args.workdir ?? this.root);
|
|
23880
24045
|
if (workdir !== this.root && !workdir.startsWith(`${this.root.replace(/\/$/u, "")}/`))
|
|
23881
24046
|
throw new Error("Command workdir is outside the sandbox workspace");
|
|
23882
|
-
const task = await
|
|
24047
|
+
const task = await ModalCommandStartPreDispatchUnavailableError.beforeDispatch(
|
|
24048
|
+
() => this.client.sandboxGetTaskId({ sandboxId }, signal ? { signal } : void 0),
|
|
24049
|
+
signal
|
|
24050
|
+
);
|
|
23883
24051
|
if (!task.taskId || task.taskResult) throw new Error("Modal command task is unavailable");
|
|
23884
24052
|
const taskId = task.taskId;
|
|
23885
24053
|
if (this.sandboxId !== sandboxId)
|
|
@@ -23932,11 +24100,11 @@ var ModalCommandControl2 = class _ModalCommandControl {
|
|
|
23932
24100
|
}
|
|
23933
24101
|
};
|
|
23934
24102
|
if (supervision) await reserveSupervisedLaunch(command);
|
|
24103
|
+
let startAttempted = false;
|
|
23935
24104
|
try {
|
|
23936
|
-
await this.
|
|
23937
|
-
|
|
23938
|
-
|
|
23939
|
-
(router) => router.start(
|
|
24105
|
+
await this.withStartRouter(taskId, signal, async (router) => {
|
|
24106
|
+
startAttempted = true;
|
|
24107
|
+
await router.start(
|
|
23940
24108
|
{
|
|
23941
24109
|
taskId,
|
|
23942
24110
|
execId,
|
|
@@ -23955,11 +24123,12 @@ var ModalCommandControl2 = class _ModalCommandControl {
|
|
|
23955
24123
|
} : {}
|
|
23956
24124
|
},
|
|
23957
24125
|
signal
|
|
23958
|
-
)
|
|
23959
|
-
);
|
|
24126
|
+
);
|
|
24127
|
+
});
|
|
23960
24128
|
} catch (error) {
|
|
23961
|
-
if (!
|
|
24129
|
+
if (!startAttempted || error instanceof ModalCommandStartNotDispatchedError || error instanceof ModalCommandStartRejectedError || error instanceof ModalCommandStartPreDispatchUnavailableError)
|
|
23962
24130
|
throw error;
|
|
24131
|
+
throw new ProviderCommandStartOutcomeUnknownError(command, error);
|
|
23963
24132
|
}
|
|
23964
24133
|
return command;
|
|
23965
24134
|
}
|
|
@@ -23969,9 +24138,12 @@ var ModalCommandControl2 = class _ModalCommandControl {
|
|
|
23969
24138
|
async verifySupervisionCapability() {
|
|
23970
24139
|
const sandboxId = this.sandboxId;
|
|
23971
24140
|
const signal = AbortSignal.timeout(5e3);
|
|
23972
|
-
const task = await
|
|
24141
|
+
const task = await ModalCommandStartPreDispatchUnavailableError.beforeDispatch(
|
|
24142
|
+
() => this.client.sandboxGetTaskId({ sandboxId }, { signal }),
|
|
24143
|
+
signal
|
|
24144
|
+
);
|
|
23973
24145
|
if (!task.taskId || task.taskResult) throw new Error("Modal command task is unavailable");
|
|
23974
|
-
await this.
|
|
24146
|
+
await this.withStartRouter(task.taskId, signal, async (router) => {
|
|
23975
24147
|
const identity = { taskId: task.taskId, execId: randomUUID6() };
|
|
23976
24148
|
await router.start(
|
|
23977
24149
|
{
|
|
@@ -24004,6 +24176,69 @@ var ModalCommandControl2 = class _ModalCommandControl {
|
|
|
24004
24176
|
throw new Error("Modal instance changed during supervision capability verification");
|
|
24005
24177
|
return { sandboxId, taskId: task.taskId };
|
|
24006
24178
|
}
|
|
24179
|
+
/** Fixed provider readiness probe. No shell, user environment, admission or
|
|
24180
|
+
* SDK Start retries. Once Start may have been sent, only observe that exact
|
|
24181
|
+
* invocation; DNS-shaped server replies never authorize another Start. */
|
|
24182
|
+
async verifyExecReadiness(signal) {
|
|
24183
|
+
signal.throwIfAborted();
|
|
24184
|
+
const sandboxId = this.sandboxId;
|
|
24185
|
+
const task = await ModalCommandStartPreDispatchUnavailableError.beforeDispatch(
|
|
24186
|
+
() => this.client.sandboxGetTaskId({ sandboxId }, { signal }),
|
|
24187
|
+
signal
|
|
24188
|
+
);
|
|
24189
|
+
if (!task.taskId || task.taskResult) throw new Error("Modal command task is unavailable");
|
|
24190
|
+
if (sandboxId !== this.sandboxId)
|
|
24191
|
+
throw new Error("Modal sandbox changed during readiness preparation");
|
|
24192
|
+
const identity = { taskId: task.taskId, execId: randomUUID6() };
|
|
24193
|
+
const transientObservation = (error) => [status3.UNAVAILABLE, status3.DEADLINE_EXCEEDED].includes(
|
|
24194
|
+
error?.code ?? -1
|
|
24195
|
+
);
|
|
24196
|
+
const pause = () => delay2(100, void 0, { signal });
|
|
24197
|
+
return await this.withStartRouter(task.taskId, signal, async (router) => {
|
|
24198
|
+
for (; ; ) {
|
|
24199
|
+
signal.throwIfAborted();
|
|
24200
|
+
try {
|
|
24201
|
+
await router.start(
|
|
24202
|
+
{ ...identity, commandArgs: ["/bin/true"], workdir: "/tmp", env: {} },
|
|
24203
|
+
signal
|
|
24204
|
+
);
|
|
24205
|
+
break;
|
|
24206
|
+
} catch (error) {
|
|
24207
|
+
signal.throwIfAborted();
|
|
24208
|
+
if (error instanceof ModalCommandStartPreDispatchUnavailableError) {
|
|
24209
|
+
await pause();
|
|
24210
|
+
continue;
|
|
24211
|
+
}
|
|
24212
|
+
if (error instanceof ModalCommandStartRejectedError || error instanceof ModalCommandStartNotDispatchedError)
|
|
24213
|
+
throw error;
|
|
24214
|
+
break;
|
|
24215
|
+
}
|
|
24216
|
+
}
|
|
24217
|
+
const streams = {
|
|
24218
|
+
stdout: { offset: 0, eof: false },
|
|
24219
|
+
stderr: { offset: 0, eof: false }
|
|
24220
|
+
};
|
|
24221
|
+
for (; ; ) {
|
|
24222
|
+
signal.throwIfAborted();
|
|
24223
|
+
try {
|
|
24224
|
+
for (const stream of ["stdout", "stderr"]) {
|
|
24225
|
+
const cursor = streams[stream];
|
|
24226
|
+
if (cursor.eof) continue;
|
|
24227
|
+
const page = await router.read(identity, stream, cursor.offset, 1e3, signal);
|
|
24228
|
+
cursor.offset += page.bytes.length;
|
|
24229
|
+
cursor.eof = page.eof;
|
|
24230
|
+
}
|
|
24231
|
+
const exit = await router.poll(identity, signal);
|
|
24232
|
+
signal.throwIfAborted();
|
|
24233
|
+
if (exit !== null && streams.stdout.eof && streams.stderr.eof) return exit;
|
|
24234
|
+
} catch (error) {
|
|
24235
|
+
signal.throwIfAborted();
|
|
24236
|
+
if (!transientObservation(error)) throw error;
|
|
24237
|
+
}
|
|
24238
|
+
await pause();
|
|
24239
|
+
}
|
|
24240
|
+
});
|
|
24241
|
+
}
|
|
24007
24242
|
/** Separate authenticated provider execution of the installed control helper.
|
|
24008
24243
|
* User command streams are never inspected for control evidence. */
|
|
24009
24244
|
async supervisionControl(command, action, receiptId) {
|
|
@@ -24013,7 +24248,7 @@ var ModalCommandControl2 = class _ModalCommandControl {
|
|
|
24013
24248
|
throw new Error("Supervised command identity is unavailable");
|
|
24014
24249
|
const identity = { taskId: command.taskId, execId: randomUUID6() };
|
|
24015
24250
|
const signal = AbortSignal.timeout(5e3);
|
|
24016
|
-
return await this.
|
|
24251
|
+
return await this.withStartRouter(command.taskId, signal, async (router) => {
|
|
24017
24252
|
await router.start(
|
|
24018
24253
|
{
|
|
24019
24254
|
...identity,
|
|
@@ -24559,8 +24794,8 @@ var MODAL_TASK_EXEC_START_ERROR_MAX_NODES = 64;
|
|
|
24559
24794
|
var MODAL_TASK_EXEC_START_ERROR_MAX_AGGREGATE_ERRORS = 32;
|
|
24560
24795
|
function modalHttpStatus(value) {
|
|
24561
24796
|
if (typeof value !== "number" && typeof value !== "string") return null;
|
|
24562
|
-
const
|
|
24563
|
-
return Number.isInteger(
|
|
24797
|
+
const status4 = Number(value);
|
|
24798
|
+
return Number.isInteger(status4) && status4 >= 100 && status4 <= 599 ? status4 : null;
|
|
24564
24799
|
}
|
|
24565
24800
|
function hasContradictoryModalHttpStatus(record) {
|
|
24566
24801
|
const values = [record.status, record.statusCode, record.httpStatus, record.httpStatusCode];
|
|
@@ -24593,8 +24828,10 @@ function isModalTaskExecStartPreDispatchUnavailableError(error) {
|
|
|
24593
24828
|
try {
|
|
24594
24829
|
const record = current.value;
|
|
24595
24830
|
if (isRoutingMutationOutcomeUnknownError(current.value)) return false;
|
|
24831
|
+
if (hasModalCommandStartBoundary(current.value, "outcome-unknown")) return false;
|
|
24832
|
+
if (current.value instanceof ModalCommandStartNotDispatchedError) return false;
|
|
24596
24833
|
if (hasContradictoryModalHttpStatus(record)) return false;
|
|
24597
|
-
if (current.value instanceof ModalCommandStartPreDispatchUnavailableError) {
|
|
24834
|
+
if (current.value instanceof ModalCommandStartPreDispatchUnavailableError || hasModalCommandStartBoundary(current.value, "pre-dispatch-unavailable")) {
|
|
24598
24835
|
matchingLeaves += 1;
|
|
24599
24836
|
continue;
|
|
24600
24837
|
}
|
|
@@ -24621,6 +24858,30 @@ function isModalTaskExecStartPreDispatchUnavailableError(error) {
|
|
|
24621
24858
|
}
|
|
24622
24859
|
return matchingLeaves > 0;
|
|
24623
24860
|
}
|
|
24861
|
+
function isModalCommandStartOutcomeUnknownError(error) {
|
|
24862
|
+
const pending = [{ depth: 0, value: error }];
|
|
24863
|
+
const seen = /* @__PURE__ */ new WeakSet();
|
|
24864
|
+
for (let inspected = 0; pending.length && inspected < MODAL_TASK_EXEC_START_ERROR_MAX_NODES; inspected++) {
|
|
24865
|
+
const { depth, value } = pending.shift();
|
|
24866
|
+
if (!value || typeof value !== "object" || seen.has(value)) continue;
|
|
24867
|
+
seen.add(value);
|
|
24868
|
+
if (hasModalCommandStartBoundary(value, "outcome-unknown")) return true;
|
|
24869
|
+
if (depth >= MODAL_TASK_EXEC_START_ERROR_MAX_DEPTH) continue;
|
|
24870
|
+
try {
|
|
24871
|
+
const record = value;
|
|
24872
|
+
for (const key of ["cause", "error"])
|
|
24873
|
+
if (record[key] !== void 0) pending.push({ depth: depth + 1, value: record[key] });
|
|
24874
|
+
if (Array.isArray(record.errors))
|
|
24875
|
+
for (const nested of record.errors.slice(
|
|
24876
|
+
0,
|
|
24877
|
+
MODAL_TASK_EXEC_START_ERROR_MAX_AGGREGATE_ERRORS
|
|
24878
|
+
))
|
|
24879
|
+
pending.push({ depth: depth + 1, value: nested });
|
|
24880
|
+
} catch {
|
|
24881
|
+
}
|
|
24882
|
+
}
|
|
24883
|
+
return false;
|
|
24884
|
+
}
|
|
24624
24885
|
function isModalExecAlreadyCompletedError(error) {
|
|
24625
24886
|
if (!error || typeof error !== "object") return false;
|
|
24626
24887
|
const record = error;
|
|
@@ -25807,7 +26068,7 @@ function commandForArgs(args) {
|
|
|
25807
26068
|
if (!requestedShell) return args.cmd;
|
|
25808
26069
|
return `${shellQuote(requestedShell)}${args.login === false ? "" : " -l"} -c ${shellQuote(args.cmd)}`;
|
|
25809
26070
|
}
|
|
25810
|
-
function
|
|
26071
|
+
function delay3(ms) {
|
|
25811
26072
|
return new Promise((resolve7) => setTimeout(resolve7, Math.max(0, ms)));
|
|
25812
26073
|
}
|
|
25813
26074
|
function consumeProcessOutput(process2) {
|
|
@@ -26150,23 +26411,23 @@ var OpenSandboxSession = class {
|
|
|
26150
26411
|
const provider = await this.ensureStarted();
|
|
26151
26412
|
while (true) {
|
|
26152
26413
|
try {
|
|
26153
|
-
const
|
|
26154
|
-
if (
|
|
26155
|
-
if (
|
|
26156
|
-
process2.events.push({ stream: "stderr", text: `${
|
|
26414
|
+
const status4 = await provider.commands.getCommandStatus(executionId);
|
|
26415
|
+
if (status4.running === false) {
|
|
26416
|
+
if (status4.error) {
|
|
26417
|
+
process2.events.push({ stream: "stderr", text: `${status4.error}
|
|
26157
26418
|
` });
|
|
26158
26419
|
}
|
|
26159
26420
|
process2.settled = true;
|
|
26160
26421
|
process2.transportUncertain = false;
|
|
26161
26422
|
this.processesByOpId.delete(process2.opId);
|
|
26162
26423
|
return {
|
|
26163
|
-
exitCode:
|
|
26164
|
-
...
|
|
26424
|
+
exitCode: status4.exitCode ?? 1,
|
|
26425
|
+
...status4.error ? { error: status4.error } : {}
|
|
26165
26426
|
};
|
|
26166
26427
|
}
|
|
26167
26428
|
} catch {
|
|
26168
26429
|
}
|
|
26169
|
-
await
|
|
26430
|
+
await delay3(DEFAULT_WRITE_STDIN_YIELD_TIME_MS3);
|
|
26170
26431
|
}
|
|
26171
26432
|
}
|
|
26172
26433
|
async execToCompletion(args) {
|
|
@@ -26207,7 +26468,7 @@ var OpenSandboxSession = class {
|
|
|
26207
26468
|
const yieldTimeMs = requestedYieldMs >= DEFAULT_EXEC_YIELD_TIME_MS3 ? requestedYieldMs + COMMAND_API_SETTLE_GRACE_MS : requestedYieldMs;
|
|
26208
26469
|
const outcome = await Promise.race([
|
|
26209
26470
|
process2.completed.then((value) => ({ done: true, value })),
|
|
26210
|
-
|
|
26471
|
+
delay3(yieldTimeMs).then(() => ({ done: false }))
|
|
26211
26472
|
]);
|
|
26212
26473
|
const consumed = consumeProcessOutput(process2);
|
|
26213
26474
|
const output = truncateOutput(consumed.output, args.maxOutputTokens);
|
|
@@ -26292,14 +26553,14 @@ var OpenSandboxSession = class {
|
|
|
26292
26553
|
);
|
|
26293
26554
|
}
|
|
26294
26555
|
const provider = await this.ensureStarted();
|
|
26295
|
-
const
|
|
26296
|
-
if (
|
|
26297
|
-
process2.events.push({ stream: "stderr", text: `${
|
|
26556
|
+
const status4 = await provider.commands.getCommandStatus(executionId);
|
|
26557
|
+
if (status4.error) {
|
|
26558
|
+
process2.events.push({ stream: "stderr", text: `${status4.error}
|
|
26298
26559
|
` });
|
|
26299
26560
|
}
|
|
26300
26561
|
const consumed2 = consumeProcessOutput(process2);
|
|
26301
26562
|
const output2 = truncateOutput(consumed2.output, args.maxOutputTokens);
|
|
26302
|
-
if (
|
|
26563
|
+
if (status4.running !== false) {
|
|
26303
26564
|
return formatExecResponse({
|
|
26304
26565
|
output: output2.text,
|
|
26305
26566
|
wallTimeSeconds: elapsedSeconds(startedAt),
|
|
@@ -26313,13 +26574,13 @@ var OpenSandboxSession = class {
|
|
|
26313
26574
|
return formatExecResponse({
|
|
26314
26575
|
output: output2.text,
|
|
26315
26576
|
wallTimeSeconds: elapsedSeconds(startedAt),
|
|
26316
|
-
exitCode:
|
|
26577
|
+
exitCode: status4.exitCode ?? 1,
|
|
26317
26578
|
...output2.originalTokenCount !== void 0 ? { originalTokenCount: output2.originalTokenCount } : {}
|
|
26318
26579
|
});
|
|
26319
26580
|
}
|
|
26320
26581
|
const outcome = await Promise.race([
|
|
26321
26582
|
process2.completed.then((value) => ({ done: true, value })),
|
|
26322
|
-
|
|
26583
|
+
delay3(args.yieldTimeMs ?? DEFAULT_WRITE_STDIN_YIELD_TIME_MS3).then(() => ({
|
|
26323
26584
|
done: false
|
|
26324
26585
|
}))
|
|
26325
26586
|
]);
|
|
@@ -28073,8 +28334,8 @@ function isRunloopConflictError(error) {
|
|
|
28073
28334
|
if (!isRecord(error)) {
|
|
28074
28335
|
return false;
|
|
28075
28336
|
}
|
|
28076
|
-
const
|
|
28077
|
-
if (
|
|
28337
|
+
const status4 = error.status ?? error.statusCode;
|
|
28338
|
+
if (status4 === 409 || status4 === "409") {
|
|
28078
28339
|
return true;
|
|
28079
28340
|
}
|
|
28080
28341
|
const code = error.code;
|
|
@@ -29058,12 +29319,12 @@ var OpConsumer = class {
|
|
|
29058
29319
|
if (result.$case !== "opStart") {
|
|
29059
29320
|
throw protocolError(`op-stream start: unexpected result ${result.$case}`);
|
|
29060
29321
|
}
|
|
29061
|
-
const
|
|
29322
|
+
const status4 = result.opStart.status;
|
|
29062
29323
|
if (!result.opStart.accepted) {
|
|
29063
|
-
throw this.refusedStart(
|
|
29324
|
+
throw this.refusedStart(status4);
|
|
29064
29325
|
}
|
|
29065
|
-
if (
|
|
29066
|
-
throw lostToControlError(
|
|
29326
|
+
if (status4?.state === OpState2.OP_STATE_LOST) {
|
|
29327
|
+
throw lostToControlError(status4);
|
|
29067
29328
|
}
|
|
29068
29329
|
return drainingRetries + blipRetries;
|
|
29069
29330
|
} catch (error) {
|
|
@@ -29095,8 +29356,8 @@ var OpConsumer = class {
|
|
|
29095
29356
|
}
|
|
29096
29357
|
}
|
|
29097
29358
|
}
|
|
29098
|
-
refusedStart(
|
|
29099
|
-
if (
|
|
29359
|
+
refusedStart(status4) {
|
|
29360
|
+
if (status4?.exit?.cancelled) {
|
|
29100
29361
|
return new SelfhostedControlError({
|
|
29101
29362
|
message: "The command was cancelled before the machine admitted it.",
|
|
29102
29363
|
code: ErrorCode3.ERROR_CODE_TIMEOUT,
|
|
@@ -29105,8 +29366,8 @@ var OpConsumer = class {
|
|
|
29105
29366
|
detail: { cancelled: "true" }
|
|
29106
29367
|
});
|
|
29107
29368
|
}
|
|
29108
|
-
if (
|
|
29109
|
-
return lostToControlError(
|
|
29369
|
+
if (status4?.state === OpState2.OP_STATE_LOST) {
|
|
29370
|
+
return lostToControlError(status4);
|
|
29110
29371
|
}
|
|
29111
29372
|
return protocolError("op-stream start: the runner refused the op without a typed reason");
|
|
29112
29373
|
}
|
|
@@ -29342,12 +29603,12 @@ var OpConsumer = class {
|
|
|
29342
29603
|
if (result.$case !== "opStatus") {
|
|
29343
29604
|
throw protocolError(`op-stream query: unexpected result ${result.$case}`);
|
|
29344
29605
|
}
|
|
29345
|
-
const
|
|
29346
|
-
if (
|
|
29347
|
-
reject(lostToControlError(
|
|
29606
|
+
const status4 = result.opStatus;
|
|
29607
|
+
if (status4.state === OpState2.OP_STATE_LOST) {
|
|
29608
|
+
reject(lostToControlError(status4));
|
|
29348
29609
|
return;
|
|
29349
29610
|
}
|
|
29350
|
-
if (BigInt(
|
|
29611
|
+
if (BigInt(status4.nextSeq) > this.lastApplied + 1n) {
|
|
29351
29612
|
this.requestAttachHeal();
|
|
29352
29613
|
}
|
|
29353
29614
|
} catch (error) {
|
|
@@ -29415,14 +29676,14 @@ function protocolError(message) {
|
|
|
29415
29676
|
retryable: false
|
|
29416
29677
|
});
|
|
29417
29678
|
}
|
|
29418
|
-
function lostToControlError(
|
|
29419
|
-
const reason =
|
|
29679
|
+
function lostToControlError(status4) {
|
|
29680
|
+
const reason = status4.lostReason === OpLostReason.OP_LOST_REASON_EVICTED ? "its retained result was evicted before collection" : status4.lostReason === OpLostReason.OP_LOST_REASON_AGENT_RESTARTED ? "the machine agent restarted and the op did not survive" : "the runner reported it lost";
|
|
29420
29681
|
return new SelfhostedControlError({
|
|
29421
29682
|
message: `The command's result is no longer available on the machine (${reason}). Check whether its effects already took place before re-running it.`,
|
|
29422
29683
|
code: ErrorCode3.ERROR_CODE_STREAM,
|
|
29423
29684
|
reason: null,
|
|
29424
29685
|
retryable: false,
|
|
29425
|
-
detail: { lost_reason: String(
|
|
29686
|
+
detail: { lost_reason: String(status4.lostReason) }
|
|
29426
29687
|
});
|
|
29427
29688
|
}
|
|
29428
29689
|
function runnerFailureToControlError(exit) {
|
|
@@ -32561,7 +32822,7 @@ async function runWithLegacyVercelAuthenticationFallback(state, credentials2, op
|
|
|
32561
32822
|
}
|
|
32562
32823
|
function isVercelUnauthorizedError(error) {
|
|
32563
32824
|
const details = providerErrorDetails(error);
|
|
32564
|
-
return [details.status, details.httpStatus, details.responseStatus].some((
|
|
32825
|
+
return [details.status, details.httpStatus, details.responseStatus].some((status4) => status4 === 401 || status4 === "401");
|
|
32565
32826
|
}
|
|
32566
32827
|
function applyVercelAuthentication(state, authentication) {
|
|
32567
32828
|
applyVercelCredentials(state, authentication.credentials);
|
|
@@ -33169,7 +33430,7 @@ function safeDiagnostic(signals) {
|
|
|
33169
33430
|
return [code ? `code=${code}` : "", numeric !== void 0 ? `status=${numeric}` : ""].filter(Boolean).join(" ");
|
|
33170
33431
|
}
|
|
33171
33432
|
function hasTransientSignal(signals) {
|
|
33172
|
-
return signals.codes.some((code) => TRANSIENT_CODES.has(code)) || signals.numbers.some((
|
|
33433
|
+
return signals.codes.some((code) => TRANSIENT_CODES.has(code)) || signals.numbers.some((status4) => GRPC_TRANSIENT.has(status4));
|
|
33173
33434
|
}
|
|
33174
33435
|
function hasModalTerminalSandboxMessage(signals) {
|
|
33175
33436
|
return signals.messages.some(
|
|
@@ -33200,7 +33461,7 @@ function classifyProviderSandboxFailure(backendId, error) {
|
|
|
33200
33461
|
if (hasTransientSignal(signals)) {
|
|
33201
33462
|
return { kind: "transient_transport", diagnostic };
|
|
33202
33463
|
}
|
|
33203
|
-
if (signals.numbers.some((
|
|
33464
|
+
if (signals.numbers.some((status4) => status4 === 404) || signals.codes.some((code) => NOT_FOUND_CODES.has(code))) {
|
|
33204
33465
|
return { kind: "not_found", diagnostic };
|
|
33205
33466
|
}
|
|
33206
33467
|
if (backendId === "modal" && hasModalTerminalSandboxMessage(signals)) {
|
|
@@ -33872,10 +34133,10 @@ async function cleanupDisplayStackProcess(session, pending, deadline) {
|
|
|
33872
34133
|
deadline
|
|
33873
34134
|
);
|
|
33874
34135
|
const output = execResultOutput(result);
|
|
33875
|
-
const
|
|
34136
|
+
const status4 = /OPENGENI_DISPLAY_CLEANUP status=(stopped|absent|alive|invalid)/u.exec(
|
|
33876
34137
|
output
|
|
33877
34138
|
)?.[1];
|
|
33878
|
-
return
|
|
34139
|
+
return status4 === "stopped";
|
|
33879
34140
|
} catch {
|
|
33880
34141
|
return false;
|
|
33881
34142
|
}
|
|
@@ -33906,13 +34167,13 @@ function telemetryReporter(options, started, now = monotonicNow) {
|
|
|
33906
34167
|
const context = options.telemetryContext;
|
|
33907
34168
|
const sink = options.onTelemetry ?? (context ? (event) => console.info(`[display-stack] ${JSON.stringify(event)}`) : void 0);
|
|
33908
34169
|
const emittedSandboxStages = /* @__PURE__ */ new Set();
|
|
33909
|
-
const emit = (stage,
|
|
34170
|
+
const emit = (stage, status4, fields = {}) => {
|
|
33910
34171
|
if (!sink) return;
|
|
33911
34172
|
const event = {
|
|
33912
34173
|
type: "display_stack.stage",
|
|
33913
34174
|
requestId: id,
|
|
33914
34175
|
stage,
|
|
33915
|
-
status:
|
|
34176
|
+
status: status4,
|
|
33916
34177
|
elapsedMs: fields.elapsedMs ?? now() - started,
|
|
33917
34178
|
source: fields.source ?? "host",
|
|
33918
34179
|
classification: fields.classification ?? "unknown",
|
|
@@ -34461,9 +34722,9 @@ var ComputerFrameEvidenceMismatchError = class extends BrowserControlProtocolErr
|
|
|
34461
34722
|
}
|
|
34462
34723
|
};
|
|
34463
34724
|
var BrowserControlRequestError = class extends Error {
|
|
34464
|
-
constructor(
|
|
34725
|
+
constructor(status4, error) {
|
|
34465
34726
|
super(error.message);
|
|
34466
|
-
this.status =
|
|
34727
|
+
this.status = status4;
|
|
34467
34728
|
this.error = error;
|
|
34468
34729
|
this.retryable = error.retryable;
|
|
34469
34730
|
}
|
|
@@ -35013,7 +35274,7 @@ var BrowserControlClient = class {
|
|
|
35013
35274
|
`browser controller transport failed (curl exit ${curlExit})`
|
|
35014
35275
|
);
|
|
35015
35276
|
}
|
|
35016
|
-
const
|
|
35277
|
+
const status4 = parseHttpStatus(await readText(this.session, statusPath, 32, timeoutMs));
|
|
35017
35278
|
const responseText = await readText(
|
|
35018
35279
|
this.session,
|
|
35019
35280
|
responsePath,
|
|
@@ -35023,7 +35284,7 @@ var BrowserControlClient = class {
|
|
|
35023
35284
|
if (Buffer.byteLength(responseText) > BROWSER_CONTROL_MAX_JSON_BYTES) {
|
|
35024
35285
|
throw new BrowserControlProtocolError("browser controller response is too large");
|
|
35025
35286
|
}
|
|
35026
|
-
return parseEnvelope(responseText,
|
|
35287
|
+
return parseEnvelope(responseText, status4);
|
|
35027
35288
|
} catch (error) {
|
|
35028
35289
|
if (error instanceof BrowserControlRequestError || error instanceof BrowserControlProtocolError || error instanceof RangeError) {
|
|
35029
35290
|
throw error;
|
|
@@ -35130,15 +35391,15 @@ var BrowserControlClient = class {
|
|
|
35130
35391
|
`browser controller transport failed (curl exit ${curlExit})`
|
|
35131
35392
|
);
|
|
35132
35393
|
}
|
|
35133
|
-
const
|
|
35134
|
-
if (
|
|
35394
|
+
const status4 = parseHttpStatus(await readText(this.session, statusPath, 32, timeoutMs));
|
|
35395
|
+
if (status4 < 200 || status4 >= 300) {
|
|
35135
35396
|
const responseText = await readText(
|
|
35136
35397
|
this.session,
|
|
35137
35398
|
responsePath,
|
|
35138
35399
|
BROWSER_CONTROL_MAX_JSON_BYTES + 1,
|
|
35139
35400
|
timeoutMs
|
|
35140
35401
|
);
|
|
35141
|
-
parseEnvelope(responseText,
|
|
35402
|
+
parseEnvelope(responseText, status4);
|
|
35142
35403
|
throw new BrowserControlProtocolError("browser controller image response is invalid");
|
|
35143
35404
|
}
|
|
35144
35405
|
const headers = parseCurlResponseHeaders(
|
|
@@ -35940,12 +36201,12 @@ function looksLikeBrowserControlEnvelope(body) {
|
|
|
35940
36201
|
return false;
|
|
35941
36202
|
}
|
|
35942
36203
|
}
|
|
35943
|
-
function rejectProviderGatewayResponse(body,
|
|
35944
|
-
if ([502, 503, 504].includes(
|
|
35945
|
-
throw new BrowserControlTransportError(`browser controller returned HTTP ${
|
|
36204
|
+
function rejectProviderGatewayResponse(body, status4) {
|
|
36205
|
+
if ([502, 503, 504].includes(status4) && !looksLikeBrowserControlEnvelope(body)) {
|
|
36206
|
+
throw new BrowserControlTransportError(`browser controller returned HTTP ${status4}`);
|
|
35946
36207
|
}
|
|
35947
36208
|
}
|
|
35948
|
-
function parseEnvelope(body,
|
|
36209
|
+
function parseEnvelope(body, status4) {
|
|
35949
36210
|
let value;
|
|
35950
36211
|
try {
|
|
35951
36212
|
value = JSON.parse(body);
|
|
@@ -35955,10 +36216,10 @@ function parseEnvelope(body, status2) {
|
|
|
35955
36216
|
if (!isRecord3(value) || value.protocolVersion !== BROWSER_CONTROL_PROTOCOL_VERSION) {
|
|
35956
36217
|
throw new BrowserControlProtocolError("browser controller protocol version is invalid");
|
|
35957
36218
|
}
|
|
35958
|
-
if (value.ok === true &&
|
|
35959
|
-
if (value.ok === false &&
|
|
36219
|
+
if (value.ok === true && status4 >= 200 && status4 < 300 && "data" in value) return value.data;
|
|
36220
|
+
if (value.ok === false && status4 >= 400 && status4 <= 599) {
|
|
35960
36221
|
const parsed = InteractionError.safeParse(value.error);
|
|
35961
|
-
if (parsed.success) throw new BrowserControlRequestError(
|
|
36222
|
+
if (parsed.success) throw new BrowserControlRequestError(status4, parsed.data);
|
|
35962
36223
|
}
|
|
35963
36224
|
throw new BrowserControlProtocolError("browser controller response envelope is invalid");
|
|
35964
36225
|
}
|
|
@@ -36718,11 +36979,11 @@ function parseUnsignedInteger(value, label) {
|
|
|
36718
36979
|
return parsed;
|
|
36719
36980
|
}
|
|
36720
36981
|
function parseHttpStatus(value) {
|
|
36721
|
-
const
|
|
36722
|
-
if (
|
|
36982
|
+
const status4 = parseUnsignedInteger(value, "HTTP status");
|
|
36983
|
+
if (status4 < 100 || status4 > 599) {
|
|
36723
36984
|
throw new BrowserControlProtocolError("HTTP status is invalid");
|
|
36724
36985
|
}
|
|
36725
|
-
return
|
|
36986
|
+
return status4;
|
|
36726
36987
|
}
|
|
36727
36988
|
function isRecord3(value) {
|
|
36728
36989
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
@@ -37447,32 +37708,29 @@ for (const name of ['package.json', 'ogtool', 'client.mjs']) {
|
|
|
37447
37708
|
} catch (error) {
|
|
37448
37709
|
installationFailure = { error };
|
|
37449
37710
|
}
|
|
37450
|
-
let cleanupFailure;
|
|
37451
37711
|
try {
|
|
37452
37712
|
await editor.deleteFile({ type: "delete_file", path: stage });
|
|
37453
|
-
} catch
|
|
37713
|
+
} catch {
|
|
37454
37714
|
try {
|
|
37455
37715
|
const cleanup = await run2(
|
|
37456
37716
|
`node -e ${quote(`require('node:fs').rmSync(${JSON.stringify(stage)}, {force: true})`)}`
|
|
37457
37717
|
);
|
|
37458
37718
|
if (sandboxCommandExitCode(cleanup) !== 0) {
|
|
37459
|
-
throw new Error("Staging file removal failed"
|
|
37719
|
+
throw new Error("Staging file removal failed");
|
|
37720
|
+
}
|
|
37721
|
+
} catch {
|
|
37722
|
+
try {
|
|
37723
|
+
console.warn(
|
|
37724
|
+
"Managed Codemode client staging cleanup failed; installation result preserved",
|
|
37725
|
+
{
|
|
37726
|
+
stageFile: posix5.basename(stage),
|
|
37727
|
+
installation: installationFailure ? "failed" : "verified"
|
|
37728
|
+
}
|
|
37729
|
+
);
|
|
37730
|
+
} catch {
|
|
37460
37731
|
}
|
|
37461
|
-
} catch (commandFailure2) {
|
|
37462
|
-
cleanupFailure = new AggregateError(
|
|
37463
|
-
[editorFailure, commandFailure2],
|
|
37464
|
-
"Both cleanup paths failed",
|
|
37465
|
-
{ cause: commandFailure2 }
|
|
37466
|
-
);
|
|
37467
37732
|
}
|
|
37468
37733
|
}
|
|
37469
|
-
if (cleanupFailure) {
|
|
37470
|
-
throw new AggregateError(
|
|
37471
|
-
installationFailure ? [installationFailure.error, cleanupFailure] : [cleanupFailure],
|
|
37472
|
-
"Managed Codemode client staging cleanup failed; restore sandbox file ingress/command execution before retrying",
|
|
37473
|
-
{ cause: installationFailure?.error ?? cleanupFailure }
|
|
37474
|
-
);
|
|
37475
|
-
}
|
|
37476
37734
|
if (installationFailure) throw installationFailure.error;
|
|
37477
37735
|
}
|
|
37478
37736
|
function managedCodemodeClientEnvironment(directory) {
|
|
@@ -37598,6 +37856,7 @@ async function mintSandboxCodemodeToken(settings, scope, authority, nowMs = Date
|
|
|
37598
37856
|
turnId: authority.turnId,
|
|
37599
37857
|
attemptId: authority.attemptId,
|
|
37600
37858
|
executionGeneration: authority.executionGeneration,
|
|
37859
|
+
...authority.credentialRestriction ? { credentialRestriction: authority.credentialRestriction } : {},
|
|
37601
37860
|
principalKind: "agent_attempt",
|
|
37602
37861
|
exp: expiresAtSeconds
|
|
37603
37862
|
});
|
|
@@ -38547,18 +38806,18 @@ function errorResponse2(requestId2, code, message) {
|
|
|
38547
38806
|
result: void 0
|
|
38548
38807
|
};
|
|
38549
38808
|
}
|
|
38550
|
-
function startResponse(requestId2,
|
|
38809
|
+
function startResponse(requestId2, status4, accepted = true) {
|
|
38551
38810
|
return {
|
|
38552
38811
|
requestId: requestId2,
|
|
38553
38812
|
error: void 0,
|
|
38554
|
-
result: { $case: "opStart", opStart: { accepted, status:
|
|
38813
|
+
result: { $case: "opStart", opStart: { accepted, status: status4 } }
|
|
38555
38814
|
};
|
|
38556
38815
|
}
|
|
38557
|
-
function statusOnly(requestId2,
|
|
38816
|
+
function statusOnly(requestId2, status4) {
|
|
38558
38817
|
return {
|
|
38559
38818
|
requestId: requestId2,
|
|
38560
38819
|
error: void 0,
|
|
38561
|
-
result: { $case: "opStatus", opStatus:
|
|
38820
|
+
result: { $case: "opStatus", opStatus: status4 }
|
|
38562
38821
|
};
|
|
38563
38822
|
}
|
|
38564
38823
|
function lostStatus(opId) {
|
|
@@ -39085,11 +39344,13 @@ function sandboxExecProbeSessionId(result) {
|
|
|
39085
39344
|
}
|
|
39086
39345
|
return null;
|
|
39087
39346
|
}
|
|
39088
|
-
async function verifySandboxExecReadiness(established, timeoutMs = MODAL_EXEC_READINESS_TIMEOUT_MS) {
|
|
39347
|
+
async function verifySandboxExecReadiness(established, timeoutMs = MODAL_EXEC_READINESS_TIMEOUT_MS, signal) {
|
|
39348
|
+
signal?.throwIfAborted();
|
|
39089
39349
|
if (established.backendId !== "modal" && established.backendId !== "opensandbox") return;
|
|
39090
39350
|
const session = established.session;
|
|
39091
39351
|
const run2 = session.exec ?? session.execCommand;
|
|
39092
|
-
|
|
39352
|
+
const nativeModalProbe = established.backendId === "modal" ? session.verifyExecReadiness : void 0;
|
|
39353
|
+
if (!run2 && !nativeModalProbe) {
|
|
39093
39354
|
throw new SandboxExecReadinessError(
|
|
39094
39355
|
established.backendId,
|
|
39095
39356
|
"exec_probe_unavailable",
|
|
@@ -39107,21 +39368,50 @@ async function verifySandboxExecReadiness(established, timeoutMs = MODAL_EXEC_RE
|
|
|
39107
39368
|
);
|
|
39108
39369
|
const deadline = Date.now() + timeoutMs;
|
|
39109
39370
|
const withinDeadline = async (operation) => {
|
|
39371
|
+
signal?.throwIfAborted();
|
|
39110
39372
|
const remainingMs = deadline - Date.now();
|
|
39111
39373
|
if (remainingMs <= 0) throw timeoutError();
|
|
39112
39374
|
let timer;
|
|
39375
|
+
let abort;
|
|
39113
39376
|
try {
|
|
39114
|
-
|
|
39115
|
-
|
|
39116
|
-
|
|
39117
|
-
|
|
39118
|
-
|
|
39119
|
-
|
|
39120
|
-
|
|
39377
|
+
const interrupted = new Promise((_, reject) => {
|
|
39378
|
+
abort = () => reject(signal?.reason);
|
|
39379
|
+
signal?.addEventListener("abort", abort, { once: true });
|
|
39380
|
+
if (signal?.aborted) abort();
|
|
39381
|
+
timer = setTimeout(() => reject(timeoutError()), remainingMs);
|
|
39382
|
+
if (timer && "unref" in timer && typeof timer.unref === "function") timer.unref();
|
|
39383
|
+
});
|
|
39384
|
+
const result2 = await Promise.race([operation(), interrupted]);
|
|
39385
|
+
signal?.throwIfAborted();
|
|
39386
|
+
return result2;
|
|
39121
39387
|
} finally {
|
|
39122
39388
|
if (timer) clearTimeout(timer);
|
|
39389
|
+
if (abort) signal?.removeEventListener("abort", abort);
|
|
39123
39390
|
}
|
|
39124
39391
|
};
|
|
39392
|
+
if (nativeModalProbe) {
|
|
39393
|
+
const cancellation = new AbortController();
|
|
39394
|
+
const abort = () => cancellation.abort(signal?.reason);
|
|
39395
|
+
signal?.addEventListener("abort", abort, { once: true });
|
|
39396
|
+
if (signal?.aborted) abort();
|
|
39397
|
+
try {
|
|
39398
|
+
const exitCode = await withinDeadline(
|
|
39399
|
+
() => nativeModalProbe.call(session, cancellation.signal)
|
|
39400
|
+
);
|
|
39401
|
+
if (exitCode !== 0)
|
|
39402
|
+
throw new SandboxExecReadinessError(
|
|
39403
|
+
established.backendId,
|
|
39404
|
+
"exec_probe_failed",
|
|
39405
|
+
timeoutMs,
|
|
39406
|
+
exitCode,
|
|
39407
|
+
established.instanceId
|
|
39408
|
+
);
|
|
39409
|
+
return;
|
|
39410
|
+
} finally {
|
|
39411
|
+
signal?.removeEventListener("abort", abort);
|
|
39412
|
+
cancellation.abort(new Error("Sandbox readiness observation finished"));
|
|
39413
|
+
}
|
|
39414
|
+
}
|
|
39125
39415
|
const execProbe = () => withinDeadline(
|
|
39126
39416
|
() => run2.call(session, {
|
|
39127
39417
|
cmd: "true",
|
|
@@ -39974,6 +40264,7 @@ export {
|
|
|
39974
40264
|
RoutingMutationOutcomeUnknownError,
|
|
39975
40265
|
isRoutingMutationOutcomeUnknownError,
|
|
39976
40266
|
RoutingRetainedProcessNotFoundError,
|
|
40267
|
+
renderRoutingMutationOutcomeUnknownToolResult,
|
|
39977
40268
|
RoutingSandboxSession,
|
|
39978
40269
|
ModalCloudBucketMountStrategy,
|
|
39979
40270
|
captureWorkspaceArchiveForStorage,
|
|
@@ -39996,6 +40287,7 @@ export {
|
|
|
39996
40287
|
modalSandboxAttributionEnvironment,
|
|
39997
40288
|
modalSandboxAttributionTags,
|
|
39998
40289
|
isModalTaskExecStartPreDispatchUnavailableError,
|
|
40290
|
+
isModalCommandStartOutcomeUnknownError,
|
|
39999
40291
|
ensureModalRegistryImage,
|
|
40000
40292
|
resolveModalCheckpointProviderBindingForSession,
|
|
40001
40293
|
modalSessionMatchesCheckpointProviderBinding,
|
|
@@ -40179,4 +40471,4 @@ export {
|
|
|
40179
40471
|
collectSandboxEnvironment2 as collectSandboxEnvironment,
|
|
40180
40472
|
parseExposedPorts2 as parseExposedPorts
|
|
40181
40473
|
};
|
|
40182
|
-
//# sourceMappingURL=chunk-
|
|
40474
|
+
//# sourceMappingURL=chunk-VDXKKMMD.js.map
|