@opengeni/runtime 4.3.0 → 4.4.0-canary.36919050519001
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-22M75RJF.js → chunk-NJQKRY6Z.js} +1633 -709
- package/dist/chunk-NJQKRY6Z.js.map +1 -0
- package/dist/{chunk-JUFVYQCY.js → chunk-QKROIZOB.js} +453 -165
- package/dist/chunk-QKROIZOB.js.map +1 -0
- package/dist/claude-subscription-usage.d.ts +3 -1
- package/dist/index.d.ts +35 -28
- package/dist/index.js +28 -2
- package/dist/input-wait-yield.d.ts +4 -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/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 +110 -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 +13 -4
- package/src/bundled_default_skills/opengeni-client/references/compatibility-and-troubleshooting.md +1 -1
- package/src/bundled_default_skills/opengeni-client/references/configure-the-agent.md +223 -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 +8 -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/index.ts +255 -146
- package/src/input-wait-yield.ts +7 -0
- package/src/interaction-tools.ts +12 -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-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 +115 -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,66 @@ 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 this.client.sandboxGetTaskId({ sandboxId }, { signal });
|
|
24186
|
+
if (!task.taskId || task.taskResult) throw new Error("Modal command task is unavailable");
|
|
24187
|
+
if (sandboxId !== this.sandboxId)
|
|
24188
|
+
throw new Error("Modal sandbox changed during readiness preparation");
|
|
24189
|
+
const identity = { taskId: task.taskId, execId: randomUUID6() };
|
|
24190
|
+
const transientObservation = (error) => [status3.UNAVAILABLE, status3.DEADLINE_EXCEEDED].includes(
|
|
24191
|
+
error?.code ?? -1
|
|
24192
|
+
);
|
|
24193
|
+
const pause = () => delay2(100, void 0, { signal });
|
|
24194
|
+
return await this.withRouter(task.taskId, signal, async (router) => {
|
|
24195
|
+
for (; ; ) {
|
|
24196
|
+
signal.throwIfAborted();
|
|
24197
|
+
try {
|
|
24198
|
+
await router.start(
|
|
24199
|
+
{ ...identity, commandArgs: ["/bin/true"], workdir: "/tmp", env: {} },
|
|
24200
|
+
signal
|
|
24201
|
+
);
|
|
24202
|
+
break;
|
|
24203
|
+
} catch (error) {
|
|
24204
|
+
signal.throwIfAborted();
|
|
24205
|
+
if (error instanceof ModalCommandStartPreDispatchUnavailableError) {
|
|
24206
|
+
await pause();
|
|
24207
|
+
continue;
|
|
24208
|
+
}
|
|
24209
|
+
if (error instanceof ModalCommandStartRejectedError || error instanceof ModalCommandStartNotDispatchedError)
|
|
24210
|
+
throw error;
|
|
24211
|
+
break;
|
|
24212
|
+
}
|
|
24213
|
+
}
|
|
24214
|
+
const streams = {
|
|
24215
|
+
stdout: { offset: 0, eof: false },
|
|
24216
|
+
stderr: { offset: 0, eof: false }
|
|
24217
|
+
};
|
|
24218
|
+
for (; ; ) {
|
|
24219
|
+
signal.throwIfAborted();
|
|
24220
|
+
try {
|
|
24221
|
+
for (const stream of ["stdout", "stderr"]) {
|
|
24222
|
+
const cursor = streams[stream];
|
|
24223
|
+
if (cursor.eof) continue;
|
|
24224
|
+
const page = await router.read(identity, stream, cursor.offset, 1e3, signal);
|
|
24225
|
+
cursor.offset += page.bytes.length;
|
|
24226
|
+
cursor.eof = page.eof;
|
|
24227
|
+
}
|
|
24228
|
+
const exit = await router.poll(identity, signal);
|
|
24229
|
+
signal.throwIfAborted();
|
|
24230
|
+
if (exit !== null && streams.stdout.eof && streams.stderr.eof) return exit;
|
|
24231
|
+
} catch (error) {
|
|
24232
|
+
signal.throwIfAborted();
|
|
24233
|
+
if (!transientObservation(error)) throw error;
|
|
24234
|
+
}
|
|
24235
|
+
await pause();
|
|
24236
|
+
}
|
|
24237
|
+
});
|
|
24238
|
+
}
|
|
24007
24239
|
/** Separate authenticated provider execution of the installed control helper.
|
|
24008
24240
|
* User command streams are never inspected for control evidence. */
|
|
24009
24241
|
async supervisionControl(command, action, receiptId) {
|
|
@@ -24013,7 +24245,7 @@ var ModalCommandControl2 = class _ModalCommandControl {
|
|
|
24013
24245
|
throw new Error("Supervised command identity is unavailable");
|
|
24014
24246
|
const identity = { taskId: command.taskId, execId: randomUUID6() };
|
|
24015
24247
|
const signal = AbortSignal.timeout(5e3);
|
|
24016
|
-
return await this.
|
|
24248
|
+
return await this.withStartRouter(command.taskId, signal, async (router) => {
|
|
24017
24249
|
await router.start(
|
|
24018
24250
|
{
|
|
24019
24251
|
...identity,
|
|
@@ -24559,8 +24791,8 @@ var MODAL_TASK_EXEC_START_ERROR_MAX_NODES = 64;
|
|
|
24559
24791
|
var MODAL_TASK_EXEC_START_ERROR_MAX_AGGREGATE_ERRORS = 32;
|
|
24560
24792
|
function modalHttpStatus(value) {
|
|
24561
24793
|
if (typeof value !== "number" && typeof value !== "string") return null;
|
|
24562
|
-
const
|
|
24563
|
-
return Number.isInteger(
|
|
24794
|
+
const status4 = Number(value);
|
|
24795
|
+
return Number.isInteger(status4) && status4 >= 100 && status4 <= 599 ? status4 : null;
|
|
24564
24796
|
}
|
|
24565
24797
|
function hasContradictoryModalHttpStatus(record) {
|
|
24566
24798
|
const values = [record.status, record.statusCode, record.httpStatus, record.httpStatusCode];
|
|
@@ -24593,8 +24825,10 @@ function isModalTaskExecStartPreDispatchUnavailableError(error) {
|
|
|
24593
24825
|
try {
|
|
24594
24826
|
const record = current.value;
|
|
24595
24827
|
if (isRoutingMutationOutcomeUnknownError(current.value)) return false;
|
|
24828
|
+
if (hasModalCommandStartBoundary(current.value, "outcome-unknown")) return false;
|
|
24829
|
+
if (current.value instanceof ModalCommandStartNotDispatchedError) return false;
|
|
24596
24830
|
if (hasContradictoryModalHttpStatus(record)) return false;
|
|
24597
|
-
if (current.value instanceof ModalCommandStartPreDispatchUnavailableError) {
|
|
24831
|
+
if (current.value instanceof ModalCommandStartPreDispatchUnavailableError || hasModalCommandStartBoundary(current.value, "pre-dispatch-unavailable")) {
|
|
24598
24832
|
matchingLeaves += 1;
|
|
24599
24833
|
continue;
|
|
24600
24834
|
}
|
|
@@ -24621,6 +24855,30 @@ function isModalTaskExecStartPreDispatchUnavailableError(error) {
|
|
|
24621
24855
|
}
|
|
24622
24856
|
return matchingLeaves > 0;
|
|
24623
24857
|
}
|
|
24858
|
+
function isModalCommandStartOutcomeUnknownError(error) {
|
|
24859
|
+
const pending = [{ depth: 0, value: error }];
|
|
24860
|
+
const seen = /* @__PURE__ */ new WeakSet();
|
|
24861
|
+
for (let inspected = 0; pending.length && inspected < MODAL_TASK_EXEC_START_ERROR_MAX_NODES; inspected++) {
|
|
24862
|
+
const { depth, value } = pending.shift();
|
|
24863
|
+
if (!value || typeof value !== "object" || seen.has(value)) continue;
|
|
24864
|
+
seen.add(value);
|
|
24865
|
+
if (hasModalCommandStartBoundary(value, "outcome-unknown")) return true;
|
|
24866
|
+
if (depth >= MODAL_TASK_EXEC_START_ERROR_MAX_DEPTH) continue;
|
|
24867
|
+
try {
|
|
24868
|
+
const record = value;
|
|
24869
|
+
for (const key of ["cause", "error"])
|
|
24870
|
+
if (record[key] !== void 0) pending.push({ depth: depth + 1, value: record[key] });
|
|
24871
|
+
if (Array.isArray(record.errors))
|
|
24872
|
+
for (const nested of record.errors.slice(
|
|
24873
|
+
0,
|
|
24874
|
+
MODAL_TASK_EXEC_START_ERROR_MAX_AGGREGATE_ERRORS
|
|
24875
|
+
))
|
|
24876
|
+
pending.push({ depth: depth + 1, value: nested });
|
|
24877
|
+
} catch {
|
|
24878
|
+
}
|
|
24879
|
+
}
|
|
24880
|
+
return false;
|
|
24881
|
+
}
|
|
24624
24882
|
function isModalExecAlreadyCompletedError(error) {
|
|
24625
24883
|
if (!error || typeof error !== "object") return false;
|
|
24626
24884
|
const record = error;
|
|
@@ -25807,7 +26065,7 @@ function commandForArgs(args) {
|
|
|
25807
26065
|
if (!requestedShell) return args.cmd;
|
|
25808
26066
|
return `${shellQuote(requestedShell)}${args.login === false ? "" : " -l"} -c ${shellQuote(args.cmd)}`;
|
|
25809
26067
|
}
|
|
25810
|
-
function
|
|
26068
|
+
function delay3(ms) {
|
|
25811
26069
|
return new Promise((resolve7) => setTimeout(resolve7, Math.max(0, ms)));
|
|
25812
26070
|
}
|
|
25813
26071
|
function consumeProcessOutput(process2) {
|
|
@@ -26150,23 +26408,23 @@ var OpenSandboxSession = class {
|
|
|
26150
26408
|
const provider = await this.ensureStarted();
|
|
26151
26409
|
while (true) {
|
|
26152
26410
|
try {
|
|
26153
|
-
const
|
|
26154
|
-
if (
|
|
26155
|
-
if (
|
|
26156
|
-
process2.events.push({ stream: "stderr", text: `${
|
|
26411
|
+
const status4 = await provider.commands.getCommandStatus(executionId);
|
|
26412
|
+
if (status4.running === false) {
|
|
26413
|
+
if (status4.error) {
|
|
26414
|
+
process2.events.push({ stream: "stderr", text: `${status4.error}
|
|
26157
26415
|
` });
|
|
26158
26416
|
}
|
|
26159
26417
|
process2.settled = true;
|
|
26160
26418
|
process2.transportUncertain = false;
|
|
26161
26419
|
this.processesByOpId.delete(process2.opId);
|
|
26162
26420
|
return {
|
|
26163
|
-
exitCode:
|
|
26164
|
-
...
|
|
26421
|
+
exitCode: status4.exitCode ?? 1,
|
|
26422
|
+
...status4.error ? { error: status4.error } : {}
|
|
26165
26423
|
};
|
|
26166
26424
|
}
|
|
26167
26425
|
} catch {
|
|
26168
26426
|
}
|
|
26169
|
-
await
|
|
26427
|
+
await delay3(DEFAULT_WRITE_STDIN_YIELD_TIME_MS3);
|
|
26170
26428
|
}
|
|
26171
26429
|
}
|
|
26172
26430
|
async execToCompletion(args) {
|
|
@@ -26207,7 +26465,7 @@ var OpenSandboxSession = class {
|
|
|
26207
26465
|
const yieldTimeMs = requestedYieldMs >= DEFAULT_EXEC_YIELD_TIME_MS3 ? requestedYieldMs + COMMAND_API_SETTLE_GRACE_MS : requestedYieldMs;
|
|
26208
26466
|
const outcome = await Promise.race([
|
|
26209
26467
|
process2.completed.then((value) => ({ done: true, value })),
|
|
26210
|
-
|
|
26468
|
+
delay3(yieldTimeMs).then(() => ({ done: false }))
|
|
26211
26469
|
]);
|
|
26212
26470
|
const consumed = consumeProcessOutput(process2);
|
|
26213
26471
|
const output = truncateOutput(consumed.output, args.maxOutputTokens);
|
|
@@ -26292,14 +26550,14 @@ var OpenSandboxSession = class {
|
|
|
26292
26550
|
);
|
|
26293
26551
|
}
|
|
26294
26552
|
const provider = await this.ensureStarted();
|
|
26295
|
-
const
|
|
26296
|
-
if (
|
|
26297
|
-
process2.events.push({ stream: "stderr", text: `${
|
|
26553
|
+
const status4 = await provider.commands.getCommandStatus(executionId);
|
|
26554
|
+
if (status4.error) {
|
|
26555
|
+
process2.events.push({ stream: "stderr", text: `${status4.error}
|
|
26298
26556
|
` });
|
|
26299
26557
|
}
|
|
26300
26558
|
const consumed2 = consumeProcessOutput(process2);
|
|
26301
26559
|
const output2 = truncateOutput(consumed2.output, args.maxOutputTokens);
|
|
26302
|
-
if (
|
|
26560
|
+
if (status4.running !== false) {
|
|
26303
26561
|
return formatExecResponse({
|
|
26304
26562
|
output: output2.text,
|
|
26305
26563
|
wallTimeSeconds: elapsedSeconds(startedAt),
|
|
@@ -26313,13 +26571,13 @@ var OpenSandboxSession = class {
|
|
|
26313
26571
|
return formatExecResponse({
|
|
26314
26572
|
output: output2.text,
|
|
26315
26573
|
wallTimeSeconds: elapsedSeconds(startedAt),
|
|
26316
|
-
exitCode:
|
|
26574
|
+
exitCode: status4.exitCode ?? 1,
|
|
26317
26575
|
...output2.originalTokenCount !== void 0 ? { originalTokenCount: output2.originalTokenCount } : {}
|
|
26318
26576
|
});
|
|
26319
26577
|
}
|
|
26320
26578
|
const outcome = await Promise.race([
|
|
26321
26579
|
process2.completed.then((value) => ({ done: true, value })),
|
|
26322
|
-
|
|
26580
|
+
delay3(args.yieldTimeMs ?? DEFAULT_WRITE_STDIN_YIELD_TIME_MS3).then(() => ({
|
|
26323
26581
|
done: false
|
|
26324
26582
|
}))
|
|
26325
26583
|
]);
|
|
@@ -28073,8 +28331,8 @@ function isRunloopConflictError(error) {
|
|
|
28073
28331
|
if (!isRecord(error)) {
|
|
28074
28332
|
return false;
|
|
28075
28333
|
}
|
|
28076
|
-
const
|
|
28077
|
-
if (
|
|
28334
|
+
const status4 = error.status ?? error.statusCode;
|
|
28335
|
+
if (status4 === 409 || status4 === "409") {
|
|
28078
28336
|
return true;
|
|
28079
28337
|
}
|
|
28080
28338
|
const code = error.code;
|
|
@@ -29058,12 +29316,12 @@ var OpConsumer = class {
|
|
|
29058
29316
|
if (result.$case !== "opStart") {
|
|
29059
29317
|
throw protocolError(`op-stream start: unexpected result ${result.$case}`);
|
|
29060
29318
|
}
|
|
29061
|
-
const
|
|
29319
|
+
const status4 = result.opStart.status;
|
|
29062
29320
|
if (!result.opStart.accepted) {
|
|
29063
|
-
throw this.refusedStart(
|
|
29321
|
+
throw this.refusedStart(status4);
|
|
29064
29322
|
}
|
|
29065
|
-
if (
|
|
29066
|
-
throw lostToControlError(
|
|
29323
|
+
if (status4?.state === OpState2.OP_STATE_LOST) {
|
|
29324
|
+
throw lostToControlError(status4);
|
|
29067
29325
|
}
|
|
29068
29326
|
return drainingRetries + blipRetries;
|
|
29069
29327
|
} catch (error) {
|
|
@@ -29095,8 +29353,8 @@ var OpConsumer = class {
|
|
|
29095
29353
|
}
|
|
29096
29354
|
}
|
|
29097
29355
|
}
|
|
29098
|
-
refusedStart(
|
|
29099
|
-
if (
|
|
29356
|
+
refusedStart(status4) {
|
|
29357
|
+
if (status4?.exit?.cancelled) {
|
|
29100
29358
|
return new SelfhostedControlError({
|
|
29101
29359
|
message: "The command was cancelled before the machine admitted it.",
|
|
29102
29360
|
code: ErrorCode3.ERROR_CODE_TIMEOUT,
|
|
@@ -29105,8 +29363,8 @@ var OpConsumer = class {
|
|
|
29105
29363
|
detail: { cancelled: "true" }
|
|
29106
29364
|
});
|
|
29107
29365
|
}
|
|
29108
|
-
if (
|
|
29109
|
-
return lostToControlError(
|
|
29366
|
+
if (status4?.state === OpState2.OP_STATE_LOST) {
|
|
29367
|
+
return lostToControlError(status4);
|
|
29110
29368
|
}
|
|
29111
29369
|
return protocolError("op-stream start: the runner refused the op without a typed reason");
|
|
29112
29370
|
}
|
|
@@ -29342,12 +29600,12 @@ var OpConsumer = class {
|
|
|
29342
29600
|
if (result.$case !== "opStatus") {
|
|
29343
29601
|
throw protocolError(`op-stream query: unexpected result ${result.$case}`);
|
|
29344
29602
|
}
|
|
29345
|
-
const
|
|
29346
|
-
if (
|
|
29347
|
-
reject(lostToControlError(
|
|
29603
|
+
const status4 = result.opStatus;
|
|
29604
|
+
if (status4.state === OpState2.OP_STATE_LOST) {
|
|
29605
|
+
reject(lostToControlError(status4));
|
|
29348
29606
|
return;
|
|
29349
29607
|
}
|
|
29350
|
-
if (BigInt(
|
|
29608
|
+
if (BigInt(status4.nextSeq) > this.lastApplied + 1n) {
|
|
29351
29609
|
this.requestAttachHeal();
|
|
29352
29610
|
}
|
|
29353
29611
|
} catch (error) {
|
|
@@ -29415,14 +29673,14 @@ function protocolError(message) {
|
|
|
29415
29673
|
retryable: false
|
|
29416
29674
|
});
|
|
29417
29675
|
}
|
|
29418
|
-
function lostToControlError(
|
|
29419
|
-
const reason =
|
|
29676
|
+
function lostToControlError(status4) {
|
|
29677
|
+
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
29678
|
return new SelfhostedControlError({
|
|
29421
29679
|
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
29680
|
code: ErrorCode3.ERROR_CODE_STREAM,
|
|
29423
29681
|
reason: null,
|
|
29424
29682
|
retryable: false,
|
|
29425
|
-
detail: { lost_reason: String(
|
|
29683
|
+
detail: { lost_reason: String(status4.lostReason) }
|
|
29426
29684
|
});
|
|
29427
29685
|
}
|
|
29428
29686
|
function runnerFailureToControlError(exit) {
|
|
@@ -32561,7 +32819,7 @@ async function runWithLegacyVercelAuthenticationFallback(state, credentials2, op
|
|
|
32561
32819
|
}
|
|
32562
32820
|
function isVercelUnauthorizedError(error) {
|
|
32563
32821
|
const details = providerErrorDetails(error);
|
|
32564
|
-
return [details.status, details.httpStatus, details.responseStatus].some((
|
|
32822
|
+
return [details.status, details.httpStatus, details.responseStatus].some((status4) => status4 === 401 || status4 === "401");
|
|
32565
32823
|
}
|
|
32566
32824
|
function applyVercelAuthentication(state, authentication) {
|
|
32567
32825
|
applyVercelCredentials(state, authentication.credentials);
|
|
@@ -33169,7 +33427,7 @@ function safeDiagnostic(signals) {
|
|
|
33169
33427
|
return [code ? `code=${code}` : "", numeric !== void 0 ? `status=${numeric}` : ""].filter(Boolean).join(" ");
|
|
33170
33428
|
}
|
|
33171
33429
|
function hasTransientSignal(signals) {
|
|
33172
|
-
return signals.codes.some((code) => TRANSIENT_CODES.has(code)) || signals.numbers.some((
|
|
33430
|
+
return signals.codes.some((code) => TRANSIENT_CODES.has(code)) || signals.numbers.some((status4) => GRPC_TRANSIENT.has(status4));
|
|
33173
33431
|
}
|
|
33174
33432
|
function hasModalTerminalSandboxMessage(signals) {
|
|
33175
33433
|
return signals.messages.some(
|
|
@@ -33200,7 +33458,7 @@ function classifyProviderSandboxFailure(backendId, error) {
|
|
|
33200
33458
|
if (hasTransientSignal(signals)) {
|
|
33201
33459
|
return { kind: "transient_transport", diagnostic };
|
|
33202
33460
|
}
|
|
33203
|
-
if (signals.numbers.some((
|
|
33461
|
+
if (signals.numbers.some((status4) => status4 === 404) || signals.codes.some((code) => NOT_FOUND_CODES.has(code))) {
|
|
33204
33462
|
return { kind: "not_found", diagnostic };
|
|
33205
33463
|
}
|
|
33206
33464
|
if (backendId === "modal" && hasModalTerminalSandboxMessage(signals)) {
|
|
@@ -33872,10 +34130,10 @@ async function cleanupDisplayStackProcess(session, pending, deadline) {
|
|
|
33872
34130
|
deadline
|
|
33873
34131
|
);
|
|
33874
34132
|
const output = execResultOutput(result);
|
|
33875
|
-
const
|
|
34133
|
+
const status4 = /OPENGENI_DISPLAY_CLEANUP status=(stopped|absent|alive|invalid)/u.exec(
|
|
33876
34134
|
output
|
|
33877
34135
|
)?.[1];
|
|
33878
|
-
return
|
|
34136
|
+
return status4 === "stopped";
|
|
33879
34137
|
} catch {
|
|
33880
34138
|
return false;
|
|
33881
34139
|
}
|
|
@@ -33906,13 +34164,13 @@ function telemetryReporter(options, started, now = monotonicNow) {
|
|
|
33906
34164
|
const context = options.telemetryContext;
|
|
33907
34165
|
const sink = options.onTelemetry ?? (context ? (event) => console.info(`[display-stack] ${JSON.stringify(event)}`) : void 0);
|
|
33908
34166
|
const emittedSandboxStages = /* @__PURE__ */ new Set();
|
|
33909
|
-
const emit = (stage,
|
|
34167
|
+
const emit = (stage, status4, fields = {}) => {
|
|
33910
34168
|
if (!sink) return;
|
|
33911
34169
|
const event = {
|
|
33912
34170
|
type: "display_stack.stage",
|
|
33913
34171
|
requestId: id,
|
|
33914
34172
|
stage,
|
|
33915
|
-
status:
|
|
34173
|
+
status: status4,
|
|
33916
34174
|
elapsedMs: fields.elapsedMs ?? now() - started,
|
|
33917
34175
|
source: fields.source ?? "host",
|
|
33918
34176
|
classification: fields.classification ?? "unknown",
|
|
@@ -34461,9 +34719,9 @@ var ComputerFrameEvidenceMismatchError = class extends BrowserControlProtocolErr
|
|
|
34461
34719
|
}
|
|
34462
34720
|
};
|
|
34463
34721
|
var BrowserControlRequestError = class extends Error {
|
|
34464
|
-
constructor(
|
|
34722
|
+
constructor(status4, error) {
|
|
34465
34723
|
super(error.message);
|
|
34466
|
-
this.status =
|
|
34724
|
+
this.status = status4;
|
|
34467
34725
|
this.error = error;
|
|
34468
34726
|
this.retryable = error.retryable;
|
|
34469
34727
|
}
|
|
@@ -35013,7 +35271,7 @@ var BrowserControlClient = class {
|
|
|
35013
35271
|
`browser controller transport failed (curl exit ${curlExit})`
|
|
35014
35272
|
);
|
|
35015
35273
|
}
|
|
35016
|
-
const
|
|
35274
|
+
const status4 = parseHttpStatus(await readText(this.session, statusPath, 32, timeoutMs));
|
|
35017
35275
|
const responseText = await readText(
|
|
35018
35276
|
this.session,
|
|
35019
35277
|
responsePath,
|
|
@@ -35023,7 +35281,7 @@ var BrowserControlClient = class {
|
|
|
35023
35281
|
if (Buffer.byteLength(responseText) > BROWSER_CONTROL_MAX_JSON_BYTES) {
|
|
35024
35282
|
throw new BrowserControlProtocolError("browser controller response is too large");
|
|
35025
35283
|
}
|
|
35026
|
-
return parseEnvelope(responseText,
|
|
35284
|
+
return parseEnvelope(responseText, status4);
|
|
35027
35285
|
} catch (error) {
|
|
35028
35286
|
if (error instanceof BrowserControlRequestError || error instanceof BrowserControlProtocolError || error instanceof RangeError) {
|
|
35029
35287
|
throw error;
|
|
@@ -35130,15 +35388,15 @@ var BrowserControlClient = class {
|
|
|
35130
35388
|
`browser controller transport failed (curl exit ${curlExit})`
|
|
35131
35389
|
);
|
|
35132
35390
|
}
|
|
35133
|
-
const
|
|
35134
|
-
if (
|
|
35391
|
+
const status4 = parseHttpStatus(await readText(this.session, statusPath, 32, timeoutMs));
|
|
35392
|
+
if (status4 < 200 || status4 >= 300) {
|
|
35135
35393
|
const responseText = await readText(
|
|
35136
35394
|
this.session,
|
|
35137
35395
|
responsePath,
|
|
35138
35396
|
BROWSER_CONTROL_MAX_JSON_BYTES + 1,
|
|
35139
35397
|
timeoutMs
|
|
35140
35398
|
);
|
|
35141
|
-
parseEnvelope(responseText,
|
|
35399
|
+
parseEnvelope(responseText, status4);
|
|
35142
35400
|
throw new BrowserControlProtocolError("browser controller image response is invalid");
|
|
35143
35401
|
}
|
|
35144
35402
|
const headers = parseCurlResponseHeaders(
|
|
@@ -35940,12 +36198,12 @@ function looksLikeBrowserControlEnvelope(body) {
|
|
|
35940
36198
|
return false;
|
|
35941
36199
|
}
|
|
35942
36200
|
}
|
|
35943
|
-
function rejectProviderGatewayResponse(body,
|
|
35944
|
-
if ([502, 503, 504].includes(
|
|
35945
|
-
throw new BrowserControlTransportError(`browser controller returned HTTP ${
|
|
36201
|
+
function rejectProviderGatewayResponse(body, status4) {
|
|
36202
|
+
if ([502, 503, 504].includes(status4) && !looksLikeBrowserControlEnvelope(body)) {
|
|
36203
|
+
throw new BrowserControlTransportError(`browser controller returned HTTP ${status4}`);
|
|
35946
36204
|
}
|
|
35947
36205
|
}
|
|
35948
|
-
function parseEnvelope(body,
|
|
36206
|
+
function parseEnvelope(body, status4) {
|
|
35949
36207
|
let value;
|
|
35950
36208
|
try {
|
|
35951
36209
|
value = JSON.parse(body);
|
|
@@ -35955,10 +36213,10 @@ function parseEnvelope(body, status2) {
|
|
|
35955
36213
|
if (!isRecord3(value) || value.protocolVersion !== BROWSER_CONTROL_PROTOCOL_VERSION) {
|
|
35956
36214
|
throw new BrowserControlProtocolError("browser controller protocol version is invalid");
|
|
35957
36215
|
}
|
|
35958
|
-
if (value.ok === true &&
|
|
35959
|
-
if (value.ok === false &&
|
|
36216
|
+
if (value.ok === true && status4 >= 200 && status4 < 300 && "data" in value) return value.data;
|
|
36217
|
+
if (value.ok === false && status4 >= 400 && status4 <= 599) {
|
|
35960
36218
|
const parsed = InteractionError.safeParse(value.error);
|
|
35961
|
-
if (parsed.success) throw new BrowserControlRequestError(
|
|
36219
|
+
if (parsed.success) throw new BrowserControlRequestError(status4, parsed.data);
|
|
35962
36220
|
}
|
|
35963
36221
|
throw new BrowserControlProtocolError("browser controller response envelope is invalid");
|
|
35964
36222
|
}
|
|
@@ -36718,11 +36976,11 @@ function parseUnsignedInteger(value, label) {
|
|
|
36718
36976
|
return parsed;
|
|
36719
36977
|
}
|
|
36720
36978
|
function parseHttpStatus(value) {
|
|
36721
|
-
const
|
|
36722
|
-
if (
|
|
36979
|
+
const status4 = parseUnsignedInteger(value, "HTTP status");
|
|
36980
|
+
if (status4 < 100 || status4 > 599) {
|
|
36723
36981
|
throw new BrowserControlProtocolError("HTTP status is invalid");
|
|
36724
36982
|
}
|
|
36725
|
-
return
|
|
36983
|
+
return status4;
|
|
36726
36984
|
}
|
|
36727
36985
|
function isRecord3(value) {
|
|
36728
36986
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
@@ -37447,32 +37705,29 @@ for (const name of ['package.json', 'ogtool', 'client.mjs']) {
|
|
|
37447
37705
|
} catch (error) {
|
|
37448
37706
|
installationFailure = { error };
|
|
37449
37707
|
}
|
|
37450
|
-
let cleanupFailure;
|
|
37451
37708
|
try {
|
|
37452
37709
|
await editor.deleteFile({ type: "delete_file", path: stage });
|
|
37453
|
-
} catch
|
|
37710
|
+
} catch {
|
|
37454
37711
|
try {
|
|
37455
37712
|
const cleanup = await run2(
|
|
37456
37713
|
`node -e ${quote(`require('node:fs').rmSync(${JSON.stringify(stage)}, {force: true})`)}`
|
|
37457
37714
|
);
|
|
37458
37715
|
if (sandboxCommandExitCode(cleanup) !== 0) {
|
|
37459
|
-
throw new Error("Staging file removal failed"
|
|
37716
|
+
throw new Error("Staging file removal failed");
|
|
37717
|
+
}
|
|
37718
|
+
} catch {
|
|
37719
|
+
try {
|
|
37720
|
+
console.warn(
|
|
37721
|
+
"Managed Codemode client staging cleanup failed; installation result preserved",
|
|
37722
|
+
{
|
|
37723
|
+
stageFile: posix5.basename(stage),
|
|
37724
|
+
installation: installationFailure ? "failed" : "verified"
|
|
37725
|
+
}
|
|
37726
|
+
);
|
|
37727
|
+
} catch {
|
|
37460
37728
|
}
|
|
37461
|
-
} catch (commandFailure2) {
|
|
37462
|
-
cleanupFailure = new AggregateError(
|
|
37463
|
-
[editorFailure, commandFailure2],
|
|
37464
|
-
"Both cleanup paths failed",
|
|
37465
|
-
{ cause: commandFailure2 }
|
|
37466
|
-
);
|
|
37467
37729
|
}
|
|
37468
37730
|
}
|
|
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
37731
|
if (installationFailure) throw installationFailure.error;
|
|
37477
37732
|
}
|
|
37478
37733
|
function managedCodemodeClientEnvironment(directory) {
|
|
@@ -38547,18 +38802,18 @@ function errorResponse2(requestId2, code, message) {
|
|
|
38547
38802
|
result: void 0
|
|
38548
38803
|
};
|
|
38549
38804
|
}
|
|
38550
|
-
function startResponse(requestId2,
|
|
38805
|
+
function startResponse(requestId2, status4, accepted = true) {
|
|
38551
38806
|
return {
|
|
38552
38807
|
requestId: requestId2,
|
|
38553
38808
|
error: void 0,
|
|
38554
|
-
result: { $case: "opStart", opStart: { accepted, status:
|
|
38809
|
+
result: { $case: "opStart", opStart: { accepted, status: status4 } }
|
|
38555
38810
|
};
|
|
38556
38811
|
}
|
|
38557
|
-
function statusOnly(requestId2,
|
|
38812
|
+
function statusOnly(requestId2, status4) {
|
|
38558
38813
|
return {
|
|
38559
38814
|
requestId: requestId2,
|
|
38560
38815
|
error: void 0,
|
|
38561
|
-
result: { $case: "opStatus", opStatus:
|
|
38816
|
+
result: { $case: "opStatus", opStatus: status4 }
|
|
38562
38817
|
};
|
|
38563
38818
|
}
|
|
38564
38819
|
function lostStatus(opId) {
|
|
@@ -39085,11 +39340,13 @@ function sandboxExecProbeSessionId(result) {
|
|
|
39085
39340
|
}
|
|
39086
39341
|
return null;
|
|
39087
39342
|
}
|
|
39088
|
-
async function verifySandboxExecReadiness(established, timeoutMs = MODAL_EXEC_READINESS_TIMEOUT_MS) {
|
|
39343
|
+
async function verifySandboxExecReadiness(established, timeoutMs = MODAL_EXEC_READINESS_TIMEOUT_MS, signal) {
|
|
39344
|
+
signal?.throwIfAborted();
|
|
39089
39345
|
if (established.backendId !== "modal" && established.backendId !== "opensandbox") return;
|
|
39090
39346
|
const session = established.session;
|
|
39091
39347
|
const run2 = session.exec ?? session.execCommand;
|
|
39092
|
-
|
|
39348
|
+
const nativeModalProbe = established.backendId === "modal" ? session.verifyExecReadiness : void 0;
|
|
39349
|
+
if (!run2 && !nativeModalProbe) {
|
|
39093
39350
|
throw new SandboxExecReadinessError(
|
|
39094
39351
|
established.backendId,
|
|
39095
39352
|
"exec_probe_unavailable",
|
|
@@ -39107,21 +39364,50 @@ async function verifySandboxExecReadiness(established, timeoutMs = MODAL_EXEC_RE
|
|
|
39107
39364
|
);
|
|
39108
39365
|
const deadline = Date.now() + timeoutMs;
|
|
39109
39366
|
const withinDeadline = async (operation) => {
|
|
39367
|
+
signal?.throwIfAborted();
|
|
39110
39368
|
const remainingMs = deadline - Date.now();
|
|
39111
39369
|
if (remainingMs <= 0) throw timeoutError();
|
|
39112
39370
|
let timer;
|
|
39371
|
+
let abort;
|
|
39113
39372
|
try {
|
|
39114
|
-
|
|
39115
|
-
|
|
39116
|
-
|
|
39117
|
-
|
|
39118
|
-
|
|
39119
|
-
|
|
39120
|
-
|
|
39373
|
+
const interrupted = new Promise((_, reject) => {
|
|
39374
|
+
abort = () => reject(signal?.reason);
|
|
39375
|
+
signal?.addEventListener("abort", abort, { once: true });
|
|
39376
|
+
if (signal?.aborted) abort();
|
|
39377
|
+
timer = setTimeout(() => reject(timeoutError()), remainingMs);
|
|
39378
|
+
if (timer && "unref" in timer && typeof timer.unref === "function") timer.unref();
|
|
39379
|
+
});
|
|
39380
|
+
const result2 = await Promise.race([operation(), interrupted]);
|
|
39381
|
+
signal?.throwIfAborted();
|
|
39382
|
+
return result2;
|
|
39121
39383
|
} finally {
|
|
39122
39384
|
if (timer) clearTimeout(timer);
|
|
39385
|
+
if (abort) signal?.removeEventListener("abort", abort);
|
|
39123
39386
|
}
|
|
39124
39387
|
};
|
|
39388
|
+
if (nativeModalProbe) {
|
|
39389
|
+
const cancellation = new AbortController();
|
|
39390
|
+
const abort = () => cancellation.abort(signal?.reason);
|
|
39391
|
+
signal?.addEventListener("abort", abort, { once: true });
|
|
39392
|
+
if (signal?.aborted) abort();
|
|
39393
|
+
try {
|
|
39394
|
+
const exitCode = await withinDeadline(
|
|
39395
|
+
() => nativeModalProbe.call(session, cancellation.signal)
|
|
39396
|
+
);
|
|
39397
|
+
if (exitCode !== 0)
|
|
39398
|
+
throw new SandboxExecReadinessError(
|
|
39399
|
+
established.backendId,
|
|
39400
|
+
"exec_probe_failed",
|
|
39401
|
+
timeoutMs,
|
|
39402
|
+
exitCode,
|
|
39403
|
+
established.instanceId
|
|
39404
|
+
);
|
|
39405
|
+
return;
|
|
39406
|
+
} finally {
|
|
39407
|
+
signal?.removeEventListener("abort", abort);
|
|
39408
|
+
cancellation.abort(new Error("Sandbox readiness observation finished"));
|
|
39409
|
+
}
|
|
39410
|
+
}
|
|
39125
39411
|
const execProbe = () => withinDeadline(
|
|
39126
39412
|
() => run2.call(session, {
|
|
39127
39413
|
cmd: "true",
|
|
@@ -39974,6 +40260,7 @@ export {
|
|
|
39974
40260
|
RoutingMutationOutcomeUnknownError,
|
|
39975
40261
|
isRoutingMutationOutcomeUnknownError,
|
|
39976
40262
|
RoutingRetainedProcessNotFoundError,
|
|
40263
|
+
renderRoutingMutationOutcomeUnknownToolResult,
|
|
39977
40264
|
RoutingSandboxSession,
|
|
39978
40265
|
ModalCloudBucketMountStrategy,
|
|
39979
40266
|
captureWorkspaceArchiveForStorage,
|
|
@@ -39996,6 +40283,7 @@ export {
|
|
|
39996
40283
|
modalSandboxAttributionEnvironment,
|
|
39997
40284
|
modalSandboxAttributionTags,
|
|
39998
40285
|
isModalTaskExecStartPreDispatchUnavailableError,
|
|
40286
|
+
isModalCommandStartOutcomeUnknownError,
|
|
39999
40287
|
ensureModalRegistryImage,
|
|
40000
40288
|
resolveModalCheckpointProviderBindingForSession,
|
|
40001
40289
|
modalSessionMatchesCheckpointProviderBinding,
|
|
@@ -40179,4 +40467,4 @@ export {
|
|
|
40179
40467
|
collectSandboxEnvironment2 as collectSandboxEnvironment,
|
|
40180
40468
|
parseExposedPorts2 as parseExposedPorts
|
|
40181
40469
|
};
|
|
40182
|
-
//# sourceMappingURL=chunk-
|
|
40470
|
+
//# sourceMappingURL=chunk-QKROIZOB.js.map
|