@tangle-network/sandbox 1.0.231 → 1.0.233
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/README.md +22 -1
- package/dist/agent/index.d.ts +4 -4
- package/dist/agent/index.js +5 -5
- package/dist/agent/preview.d.ts +1 -1
- package/dist/agent/preview.js +2 -2
- package/dist/agent-execution-preparation-BJChICex.js +18 -0
- package/dist/agent-execution-preparation-receipt-BIFxqyr5.js +250 -0
- package/dist/{agent-run-outcome-DMaHbXAk.d.ts → agent-run-outcome-B0nURFpG.d.ts} +3 -2
- package/dist/{api-request-_SFFNVqY.js → api-request-dyabkosT.js} +34 -9
- package/dist/auth/index.d.ts +2 -2
- package/dist/auth/index.js +2 -2
- package/dist/{browser-interactive-control-controller-BiP6TJFP.js → browser-interactive-control-controller-BM2p1dBp.js} +16 -252
- package/dist/{browser-interactive-control-controller-qv26Bpfx.d.ts → browser-interactive-control-controller-CcUjQEfa.d.ts} +1 -1
- package/dist/{chunked-upload-BjkxykZD.js → chunked-upload-BlvgxPWx.js} +4 -5
- package/dist/{chunked-upload-file-B2KFimpz.js → chunked-upload-file-DOeLpMO0.js} +2 -2
- package/dist/cli-auth-bundle-BLAtE6Dc.js +2 -0
- package/dist/{client-OlxlnLwV.js → client-BS-PR_-j.js} +38 -47
- package/dist/{client-DvvRMxKx.d.ts → client-DlTDphmI.d.ts} +38 -32
- package/dist/collaboration/index.d.ts +1 -1
- package/dist/collaboration/index.js +1 -1
- package/dist/{collaboration-DZ8ptALs.js → collaboration-Dz20mN9a.js} +20 -27
- package/dist/core-CUZyz-U8.js +161 -0
- package/dist/core.d.ts +6 -6
- package/dist/core.js +6 -5
- package/dist/{direct-http2-DU2SK2Wo.js → direct-http2-Bgb2lHte.js} +1 -1
- package/dist/{errors-A-bhwwsE.js → error-catalog-CAbzw67O.js} +1 -382
- package/dist/errors-nXGKGVFe.js +382 -0
- package/dist/{file-download-UhMKbMbD.js → file-download-BjkrYzy_.js} +1 -1
- package/dist/{index-Cip3q_xe.d.ts → index-DE5n6mot.d.ts} +13 -23
- package/dist/index.d.ts +12 -12
- package/dist/index.js +29 -25
- package/dist/intelligence/index.d.ts +41 -109
- package/dist/intelligence/index.js +60 -73
- package/dist/interactive-control.d.ts +1 -1
- package/dist/interactive-control.js +1 -1
- package/dist/{interactive-controller-D4gZ4f2I.js → interactive-controller-DDPdZa2H.js} +20 -54
- package/dist/{interactive-controller-P0yy6sGl.d.ts → interactive-controller-sEU_J6Bc.d.ts} +3 -3
- package/dist/lib/prepared-evidence.js +1 -1
- package/dist/lib/prepared-process.js +1 -1
- package/dist/{lines-7VecgiGd.js → lines-CSGBHEjR.js} +1 -1
- package/dist/{lines-DNXdVbGO.d.ts → lines-qvpmwN_2.d.ts} +1 -1
- package/dist/lines.d.ts +1 -1
- package/dist/lines.js +1 -1
- package/dist/{local-cli-auth-CPS9yuTc.js → local-cli-auth-CO0byocv.js} +1 -1
- package/dist/{mcp-local-CIXZFqF4.js → mcp-local-Dz_Sehz0.js} +4 -4
- package/dist/{prepared-evidence-Byty5p51.js → prepared-evidence-ibAysmX8.js} +2 -2
- package/dist/{prepared-process-u1B0b94R.js → prepared-process-DQ_68Ofg.js} +2 -2
- package/dist/{preview-CNfYklE6.d.ts → preview-BC_wLaA2.d.ts} +3 -3
- package/dist/{public-templates-CPvDf8CH.d.ts → public-templates-WuvmbvzY.d.ts} +2 -2
- package/dist/public-templates.d.ts +1 -1
- package/dist/public-templates.js +1 -1
- package/dist/{raw-evidence-archive-BgWqaQcM.js → raw-evidence-archive-Cz4j8VMw.js} +2 -2
- package/dist/{retry-policy-Dh-VezcE.js → retry-policy-oW3_ljoc.js} +2 -24
- package/dist/runtime.d.ts +7 -7
- package/dist/runtime.js +9 -9
- package/dist/{sandbox-Dvk2PYnL.js → sandbox-OyCRplrI.js} +65 -91
- package/dist/{secp256k1-Cbp9tbkX.js → secp256k1-ZiYFbGjz.js} +1 -1
- package/dist/{core-D7czAW25.js → select-seat-B4Y-7vIq.js} +40 -171
- package/dist/select-seat-command.d.ts +9 -3
- package/dist/select-seat-command.js +69 -57
- package/dist/session-gateway/index.js +11 -20
- package/dist/sidecar-proxy-error-DTdbCbUM.js +4 -0
- package/dist/tangle/index.d.ts +1 -1
- package/dist/tangle/index.js +1 -1
- package/dist/{tangle-DWzUnb1Y.js → tangle-Crxw_6V-.js} +22 -17
- package/dist/{terminal-stream-types-DB8V0hiG.d.ts → terminal-stream-types-eE97lZ-5.d.ts} +0 -1
- package/dist/{types-Cmv31xBh.d.ts → types-Cs5eJzOK.d.ts} +17 -57
- package/package.json +5 -5
- package/dist/cli-auth-bundle-CMJWI99l.js +0 -2
- package/dist/sidecar-proxy-error-DpBLxIof.js +0 -24
- /package/dist/{abort-signal-BbJTt2QJ.js → abort-signal-CRxC2dlT.js} +0 -0
- /package/dist/{cli-auth-bundle-C6DtK7GX-BbbiAn-Z.js → cli-auth-bundle-C6DtK7GX-mBUPER0R.js} +0 -0
- /package/dist/{cli-auth-bundle-Wg3x2hd2.d.ts → cli-auth-bundle-CjSu4D9W.d.ts} +0 -0
- /package/dist/{file-transfer-BSe4ayU9.js → file-transfer-DOSTbUSR.js} +0 -0
- /package/dist/{index-CDtEPygc.d.ts → index-C-_HY5NY.d.ts} +0 -0
- /package/dist/{index-YbAo-so_.d.ts → index-o31uwAkX.d.ts} +0 -0
- /package/dist/{keep-alive-fetch-BIaDMUtu.js → keep-alive-fetch-sGVP8skk.js} +0 -0
- /package/dist/{preview-operations-B3TTvqlm.js → preview-operations-DWL78boI.js} +0 -0
- /package/dist/{retry-after-header-DUdCC0KJ.js → retry-after-header-BZbs5rig.js} +0 -0
- /package/dist/{sse-parser-DOCszo1K.js → sse-parser-BCG3iL9j.js} +0 -0
- /package/dist/{utils-CK-x8vXj.js → utils-BT2q9nkO.js} +0 -0
|
@@ -1,106 +1,90 @@
|
|
|
1
|
-
import { E as TimeoutError, g as NetworkError, r as parseErrorResponse } from "../errors-
|
|
2
|
-
import {
|
|
3
|
-
import { n as verifyDownload } from "../file-download-
|
|
1
|
+
import { E as TimeoutError, g as NetworkError, l as CapabilityError, r as parseErrorResponse } from "../errors-nXGKGVFe.js";
|
|
2
|
+
import { i as fetchSandboxApi } from "../api-request-dyabkosT.js";
|
|
3
|
+
import { n as verifyDownload } from "../file-download-BjkrYzy_.js";
|
|
4
4
|
//#region src/intelligence/index.ts
|
|
5
|
-
/**
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* (`https://intelligence.tangle.tools`, default port 3030).
|
|
9
|
-
*
|
|
10
|
-
* This is a SEPARATE host from the Sandbox API. The SDK's `IntelligenceClient`
|
|
11
|
-
* (exposed as `client.intelligence`) routes intelligence-*report* calls through
|
|
12
|
-
* `Sandbox.fetch` against the **sandbox** `baseUrl` — that is the
|
|
13
|
-
* sandbox-api intelligence-report surface, a different service. The trace-read
|
|
14
|
-
* routes (`/v1/traces`, `/v1/runs*`, `/v1/sessions*`) live on intelligence-api
|
|
15
|
-
* and are tenant-scoped by the customer key, so this client does NOT reuse
|
|
16
|
-
* `Sandbox.fetch`; it carries its own intelligence-host base URL.
|
|
17
|
-
*
|
|
18
|
-
* Auth is the customer key (`sk-tan-*`) sent as `Authorization: Bearer ...`;
|
|
19
|
-
* the platform resolves it to the caller's tenant and filters `tenant_id`
|
|
20
|
-
* first and unconditionally on every route, so a cross-tenant id returns an
|
|
21
|
-
* empty result or 404, never the row.
|
|
22
|
-
*
|
|
23
|
-
* Nothing here uses a Node API — `globalThis.fetch` only — so it runs in the
|
|
24
|
-
* browser, Cloudflare Workers, Deno, and Node 20+ unchanged. The base URL must
|
|
25
|
-
* be supplied by the caller (e.g. from `TANGLE_INTELLIGENCE_BASE_URL`) or it
|
|
26
|
-
* falls back to the production host.
|
|
27
|
-
*
|
|
28
|
-
* @example
|
|
29
|
-
* ```typescript
|
|
30
|
-
* import { createIntelligenceClient } from "@tangle-network/sandbox/intelligence";
|
|
31
|
-
*
|
|
32
|
-
* const intel = createIntelligenceClient({
|
|
33
|
-
* apiKey: process.env.TANGLE_API_KEY!,
|
|
34
|
-
* baseUrl: process.env.TANGLE_INTELLIGENCE_BASE_URL,
|
|
35
|
-
* });
|
|
36
|
-
*
|
|
37
|
-
* const { items } = await intel.listTraces({ status: "ERROR", limit: 20 });
|
|
38
|
-
* for await (const span of intel.iterateTraceSpans(items[0].traceId)) {
|
|
39
|
-
* console.log(span.name, span.durationMs);
|
|
40
|
-
* }
|
|
41
|
-
* ```
|
|
42
|
-
*
|
|
43
|
-
* @packageDocumentation
|
|
44
|
-
*/
|
|
45
|
-
/**
|
|
46
|
-
* Production intelligence-api host. Mirrors the api-side
|
|
47
|
-
* `DEFAULT_INTELLIGENCE_BASE_URL` so the SDK default and the server default
|
|
48
|
-
* never drift.
|
|
5
|
+
/** Browser-safe tenant trace and run-session reads from Tangle Intelligence.
|
|
6
|
+
* Its base URL is independent of the Sandbox API. Customer keys scope reads;
|
|
7
|
+
* trusted backend session reads require serviceToken plus an explicit tenantId.
|
|
49
8
|
*/
|
|
50
9
|
const DEFAULT_INTELLIGENCE_BASE_URL = "https://intelligence.tangle.tools";
|
|
51
10
|
function appendParam(search, key, value) {
|
|
52
11
|
if (value === void 0) return;
|
|
53
12
|
search.set(key, String(value));
|
|
54
13
|
}
|
|
55
|
-
|
|
56
|
-
* Create a browser-safe client for the Tangle Intelligence trace-read surface.
|
|
57
|
-
*
|
|
58
|
-
* @param config.apiKey Customer key (`sk-tan-*`) — Bearer auth, resolved to a tenant.
|
|
59
|
-
* @param config.baseUrl Intelligence-api host; defaults to {@link DEFAULT_INTELLIGENCE_BASE_URL}.
|
|
60
|
-
*/
|
|
61
|
-
function createIntelligenceClient(config) {
|
|
62
|
-
if (!config.apiKey) throw new Error("createIntelligenceClient: apiKey is required");
|
|
14
|
+
function createIntelligenceRequest(config) {
|
|
63
15
|
const transport = {
|
|
64
|
-
apiKey: config.apiKey,
|
|
16
|
+
apiKey: config.apiKey ?? "",
|
|
65
17
|
baseUrl: config.baseUrl ?? "https://intelligence.tangle.tools",
|
|
66
18
|
timeoutMs: config.timeoutMs,
|
|
67
19
|
signal: config.signal
|
|
68
20
|
};
|
|
69
|
-
/**
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
async function request(path, read) {
|
|
21
|
+
/** The transport deadline covers read(); returned streams transfer pacing to the caller. */
|
|
22
|
+
return async function request(path, read, signal) {
|
|
23
|
+
let endpoint = path;
|
|
24
|
+
if (config.serviceToken && !path.startsWith("/v1/run-sessions/")) throw new Error("Trusted service auth is limited to run-session reads");
|
|
25
|
+
if (config.serviceToken) {
|
|
26
|
+
const url = new URL(path.replace("/v1/run-sessions/", "/v1/insights/internal/run-sessions/"), transport.baseUrl);
|
|
27
|
+
url.searchParams.set("tenantId", config.tenantId);
|
|
28
|
+
endpoint = `${url.pathname}${url.search}`;
|
|
29
|
+
}
|
|
79
30
|
return fetchSandboxApi({
|
|
80
31
|
...transport,
|
|
81
32
|
timeoutError: (ms) => new TimeoutError(`Request timed out after ${ms}ms`, {
|
|
82
33
|
timeoutMs: ms,
|
|
83
|
-
endpoint
|
|
34
|
+
endpoint
|
|
84
35
|
}),
|
|
85
36
|
networkError: (err) => new NetworkError(`Failed to connect to Intelligence API: ${err instanceof Error ? err.message : String(err)}`, {
|
|
86
37
|
cause: err instanceof Error ? err : void 0,
|
|
87
|
-
endpoint
|
|
38
|
+
endpoint,
|
|
88
39
|
origin: "sandbox-api"
|
|
89
40
|
})
|
|
90
|
-
},
|
|
41
|
+
}, endpoint, {
|
|
42
|
+
headers: {
|
|
43
|
+
Accept: "application/json",
|
|
44
|
+
...config.serviceToken ? { "X-Service-Token": config.serviceToken } : {}
|
|
45
|
+
},
|
|
46
|
+
...config.serviceToken ? { redirect: "error" } : {},
|
|
47
|
+
...signal ? { signal } : {}
|
|
48
|
+
}, { read: async (response) => {
|
|
91
49
|
if (!response.ok) throw parseErrorResponse(response.status, await response.text(), {
|
|
92
50
|
method: "GET",
|
|
93
|
-
path
|
|
51
|
+
path: endpoint
|
|
94
52
|
}, response.headers);
|
|
95
53
|
return read(response);
|
|
96
54
|
} });
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
async function waitForRunSessionFiles(request, config, runId, params = {}) {
|
|
58
|
+
if (params.requireCompleteSeal && !params.sandboxId) throw new Error("A complete-seal wait requires sandboxId");
|
|
59
|
+
const timeoutMs = params.timeoutMs ?? 12e4;
|
|
60
|
+
if (!Number.isSafeInteger(timeoutMs) || timeoutMs <= 0) throw new Error("Invalid run-session wait timeout");
|
|
61
|
+
const deadline = Date.now() + timeoutMs;
|
|
62
|
+
const signal = AbortSignal.any([AbortSignal.timeout(timeoutMs), ...[config.signal, params.signal].filter((s) => s !== void 0)]);
|
|
63
|
+
for (;;) {
|
|
64
|
+
signal.throwIfAborted();
|
|
65
|
+
if (Date.now() >= deadline) throw new TimeoutError("Run-session files did not arrive before the deadline", { timeoutMs });
|
|
66
|
+
const search = new URLSearchParams({ waitMs: String(Math.min(25e3, Math.max(1, Math.floor((config.timeoutMs ?? 3e4) * .8)), deadline - Date.now())) });
|
|
67
|
+
appendParam(search, "sandboxId", params.sandboxId);
|
|
68
|
+
appendParam(search, "executionId", params.executionId);
|
|
69
|
+
if (params.requireCompleteSeal) search.set("completeSeal", "true");
|
|
70
|
+
const page = await request(`/v1/run-sessions/${encodeURIComponent(runId)}?${search}`, async (response) => {
|
|
71
|
+
if (response.headers.get("X-Run-Session-Wait") !== "1") throw new CapabilityError("Intelligence does not support capture notification waits");
|
|
72
|
+
return await response.json();
|
|
73
|
+
}, signal);
|
|
74
|
+
if (params.requireCompleteSeal ? page.seals.some((seal) => seal.sandboxId === params.sandboxId && seal.complete) : page.files.some((file) => file.final === true && file.state === "stored")) return page;
|
|
75
|
+
if (Date.now() >= deadline) throw new TimeoutError("Run-session files did not arrive before the deadline", { timeoutMs });
|
|
97
76
|
}
|
|
77
|
+
}
|
|
78
|
+
/** Create tenant-scoped trace and capture reads. */
|
|
79
|
+
function createIntelligenceClient(config) {
|
|
80
|
+
if (Boolean(config.apiKey) === Boolean(config.serviceToken) || config.serviceToken && !config.tenantId) throw new Error("createIntelligenceClient requires either apiKey or serviceToken with tenantId");
|
|
81
|
+
const request = createIntelligenceRequest(config);
|
|
98
82
|
/** GET a JSON route, raising the SDK's typed error on a non-2xx response. */
|
|
99
|
-
function getJson(path) {
|
|
83
|
+
function getJson(path, signal) {
|
|
100
84
|
return request(path, async (response) => {
|
|
101
85
|
const text = await response.text();
|
|
102
86
|
return JSON.parse(text);
|
|
103
|
-
});
|
|
87
|
+
}, signal);
|
|
104
88
|
}
|
|
105
89
|
async function listTraces(params = {}) {
|
|
106
90
|
const search = new URLSearchParams();
|
|
@@ -152,6 +136,8 @@ function createIntelligenceClient(config) {
|
|
|
152
136
|
const search = new URLSearchParams();
|
|
153
137
|
appendParam(search, "limit", params.limit);
|
|
154
138
|
appendParam(search, "cursor", params.cursor);
|
|
139
|
+
appendParam(search, "sandboxId", params.sandboxId);
|
|
140
|
+
appendParam(search, "executionId", params.executionId);
|
|
155
141
|
const suffix = search.size > 0 ? `?${search}` : "";
|
|
156
142
|
return getJson(`/v1/run-sessions/${encodeURIComponent(runId)}${suffix}`);
|
|
157
143
|
}
|
|
@@ -183,7 +169,7 @@ function createIntelligenceClient(config) {
|
|
|
183
169
|
const stream = verifyDownload(response, {
|
|
184
170
|
expectedSha256: digest,
|
|
185
171
|
expectedSize: storedBytes,
|
|
186
|
-
signal:
|
|
172
|
+
signal: config.signal
|
|
187
173
|
});
|
|
188
174
|
return options?.stream ? stream : new Uint8Array(await new Response(stream).arrayBuffer());
|
|
189
175
|
} catch (error) {
|
|
@@ -253,6 +239,7 @@ function createIntelligenceClient(config) {
|
|
|
253
239
|
getRun,
|
|
254
240
|
getRunTraces,
|
|
255
241
|
listRunSessionFiles,
|
|
242
|
+
waitForRunSessionFiles: (runId, params) => waitForRunSessionFiles(request, config, runId, params),
|
|
256
243
|
iterateRunSessionFiles,
|
|
257
244
|
downloadRunSessionFile,
|
|
258
245
|
listSessions,
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { c as InteractiveSessionIdentity, l as InteractiveSessionNotRunningError, n as BrowserInteractiveSessionControlControllerOptions, r as browserInteractiveControlHolderId, t as BrowserInteractiveSessionControlController } from "./browser-interactive-control-controller-
|
|
1
|
+
import { c as InteractiveSessionIdentity, l as InteractiveSessionNotRunningError, n as BrowserInteractiveSessionControlControllerOptions, r as browserInteractiveControlHolderId, t as BrowserInteractiveSessionControlController } from "./browser-interactive-control-controller-CcUjQEfa.js";
|
|
2
2
|
export { BrowserInteractiveSessionControlController, type BrowserInteractiveSessionControlControllerOptions, type InteractiveSessionIdentity, InteractiveSessionNotRunningError, browserInteractiveControlHolderId };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as browserInteractiveControlHolderId, s as InteractiveSessionNotRunningError, t as BrowserInteractiveSessionControlController } from "./browser-interactive-control-controller-
|
|
1
|
+
import { n as browserInteractiveControlHolderId, s as InteractiveSessionNotRunningError, t as BrowserInteractiveSessionControlController } from "./browser-interactive-control-controller-BM2p1dBp.js";
|
|
2
2
|
export { BrowserInteractiveSessionControlController, InteractiveSessionNotRunningError, browserInteractiveControlHolderId };
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { C as boundedIdentifierSchema, T as boundedJsonSchema, o as canonicalCandidateDigest } from "./harness-DMaNgn0S.js";
|
|
2
|
-
import { B as PlanContinuationSchema, D as agentInteractiveSessionControlClaimMatchesRef, P as AgentExactRunControlRefSchema, R as AgentExecutionOutcomeSchema, U as InteractionRequestSchema, c as assertInteractiveSessionRef, h as AgentInteractiveSessionAttachSchema, i as createBrowserInteractiveSessionControlTransport, o as InteractiveSessionControlController, r as browserInteractiveTerminalEndpoint, v as AgentInteractiveSessionControlClaimSchema, x as AgentInteractiveSessionRefSchema, z as DurablePlanSchema } from "./browser-interactive-control-controller-
|
|
2
|
+
import { B as PlanContinuationSchema, D as agentInteractiveSessionControlClaimMatchesRef, P as AgentExactRunControlRefSchema, R as AgentExecutionOutcomeSchema, U as InteractionRequestSchema, c as assertInteractiveSessionRef, h as AgentInteractiveSessionAttachSchema, i as createBrowserInteractiveSessionControlTransport, o as InteractiveSessionControlController, r as browserInteractiveTerminalEndpoint, v as AgentInteractiveSessionControlClaimSchema, x as AgentInteractiveSessionRefSchema, z as DurablePlanSchema } from "./browser-interactive-control-controller-BM2p1dBp.js";
|
|
3
3
|
import { r as agentProfileSchema } from "./profile-schema-C1KpT-wS.js";
|
|
4
|
-
import { C as ServerError, D as ValidationError,
|
|
5
|
-
import { n as combineAbortSignals, t as awaitWithAbort } from "./abort-signal-
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
4
|
+
import { C as ServerError, D as ValidationError, g as NetworkError, i as parseResponseError, l as CapabilityError, o as retryWhen, t as TerminalStreamError } from "./errors-nXGKGVFe.js";
|
|
5
|
+
import { n as combineAbortSignals, t as awaitWithAbort } from "./abort-signal-CRxC2dlT.js";
|
|
6
|
+
import { n as SDK_TIMEOUTS } from "./api-request-dyabkosT.js";
|
|
7
|
+
import { c as awaitSdkResend, s as uploadChunked } from "./chunked-upload-BlvgxPWx.js";
|
|
8
|
+
import { t as parseSSEStream } from "./sse-parser-BCG3iL9j.js";
|
|
8
9
|
import { z } from "zod";
|
|
9
10
|
import { PART_TEXT, PART_TEXT_SUFFIX } from "@tangle-network/agent-core/sse";
|
|
10
11
|
/** Stable declaration order; registry tests check the shipped spec composition. */
|
|
@@ -510,6 +511,7 @@ function observeEvent(state, event) {
|
|
|
510
511
|
return;
|
|
511
512
|
}
|
|
512
513
|
if (type === "error") {
|
|
514
|
+
state.failure ??= plainRecord(data.failure);
|
|
513
515
|
state.runError ??= readError(data) ?? "Agent execution failed";
|
|
514
516
|
state.runErrorCode ??= readString(data.code);
|
|
515
517
|
state.runErrorStatusCode ??= readHttpFailureStatus(data.statusCode);
|
|
@@ -560,6 +562,7 @@ function observeOutcomeFrame(state, type, data, terminal) {
|
|
|
560
562
|
}
|
|
561
563
|
const outcome = plainRecord(data.outcome);
|
|
562
564
|
const nestedResult = plainRecord(data.result);
|
|
565
|
+
state.failure ??= plainRecord(data.failure ?? nestedResult?.failure ?? outcome?.failure);
|
|
563
566
|
for (const [field, value] of Object.entries({
|
|
564
567
|
status: data.status,
|
|
565
568
|
"outcome.type": outcome?.type,
|
|
@@ -684,6 +687,7 @@ function outcomeDetails(state) {
|
|
|
684
687
|
if (question) details.question = question;
|
|
685
688
|
if (state.plan) details.plan = state.plan;
|
|
686
689
|
if (state.resetAt) details.resetAt = state.resetAt;
|
|
690
|
+
if (state.failure) details.failure = state.failure;
|
|
687
691
|
return details;
|
|
688
692
|
}
|
|
689
693
|
function failed(error, errorCode, common, statusCode) {
|
|
@@ -1096,9 +1100,9 @@ function traceHeaders(traceId) {
|
|
|
1096
1100
|
}
|
|
1097
1101
|
//#endregion
|
|
1098
1102
|
//#region src/runtime-credential-retry.ts
|
|
1099
|
-
/** A 503 the runtime answers before any work starts; the request may be resent. */
|
|
1103
|
+
/** A 503 the runtime answers before any work starts and the catalog marks retryable; the request may be resent. */
|
|
1100
1104
|
function isRetryableCredentialRefusal(error) {
|
|
1101
|
-
return error
|
|
1105
|
+
return retryWhen(error) && error.status === 503 && (error.code === "MODEL_CREDENTIAL_SUPERSEDED" || error.code === "MODEL_CREDENTIAL_PLATFORM_UNAVAILABLE" || error.code === "HUB_CREDENTIAL_REFRESH_UNAVAILABLE" || error.code === "HUB_CREDENTIAL_REFRESH_FAILED" && Number.isFinite(error.retryAfterMs));
|
|
1102
1106
|
}
|
|
1103
1107
|
//#endregion
|
|
1104
1108
|
//#region src/generated/file-write-preconditions.ts
|
|
@@ -1712,8 +1716,6 @@ var SandboxRuntimeApi = class extends RuntimeFiles {
|
|
|
1712
1716
|
};
|
|
1713
1717
|
//#endregion
|
|
1714
1718
|
//#region src/scoped-token.ts
|
|
1715
|
-
/** Maximum time for the exact interactive terminal-token request. */
|
|
1716
|
-
const SCOPED_TOKEN_REQUEST_TIMEOUT_MS = 5e3;
|
|
1717
1719
|
const scopedTokenResponseSchema = z.object({
|
|
1718
1720
|
token: z.string().min(1),
|
|
1719
1721
|
expiresAt: z.number().finite().nonnegative(),
|
|
@@ -1808,7 +1810,7 @@ function interactiveSessionTokenOptions(ref, options = {}) {
|
|
|
1808
1810
|
}
|
|
1809
1811
|
function requestInteractiveSessionToken(client, ref, options) {
|
|
1810
1812
|
const exact = interactiveSessionTokenOptions(ref, options);
|
|
1811
|
-
return requestScopedToken(client, exact.sandboxId, exact.request, { timeoutMs:
|
|
1813
|
+
return requestScopedToken(client, exact.sandboxId, exact.request, { timeoutMs: SDK_TIMEOUTS.interactiveToken });
|
|
1812
1814
|
}
|
|
1813
1815
|
//#endregion
|
|
1814
1816
|
//#region src/terminal-stream-protocol.ts
|
|
@@ -2070,49 +2072,13 @@ function* chunkInput(text) {
|
|
|
2070
2072
|
//#endregion
|
|
2071
2073
|
//#region src/terminal-stream.ts
|
|
2072
2074
|
/**
|
|
2073
|
-
*
|
|
2074
|
-
*
|
|
2075
|
-
*
|
|
2076
|
-
*
|
|
2077
|
-
*
|
|
2078
|
-
*
|
|
2079
|
-
*
|
|
2080
|
-
*
|
|
2081
|
-
* client → server (TEXT JSON):
|
|
2082
|
-
* init {connectionId?, cols, rows, command?, cwd?, env?} — MUST be first
|
|
2083
|
-
* input {data}
|
|
2084
|
-
* resize {cols, rows}
|
|
2085
|
-
*
|
|
2086
|
-
* Interactive-agent init frames add the exact process authority:
|
|
2087
|
-
* {incarnationId, control: {refDigest, generation, leaseId, holderId, expiresAt}}
|
|
2088
|
-
* Subsequent input and resize frames carry only their operation fields; the
|
|
2089
|
-
* server binds authority to the init for the socket lifetime.
|
|
2090
|
-
* server → client (TEXT JSON):
|
|
2091
|
-
* ready {connectionId, sessionId, restored, detachTimeoutMs,
|
|
2092
|
-
* attachCount?, cursors?}
|
|
2093
|
-
* output {seq, data} — exact interactive output as base64 UTF-8 bytes
|
|
2094
|
-
* exit {exitCode?, exitSignal?}
|
|
2095
|
-
* error {code, message}
|
|
2096
|
-
* rec / rec.done — recording tee frames for the platform's session
|
|
2097
|
-
* capture consumer; not part of the client surface
|
|
2098
|
-
* server → client (BINARY): raw PTY output bytes
|
|
2099
|
-
*
|
|
2100
|
-
* A default-shell attach (no `command`, `cwd`, `env` or interactive identity)
|
|
2101
|
-
* also puts `cols`, `rows` and `defaultShell=1` on the upgrade URL. A server
|
|
2102
|
-
* that reads them starts the PTY when it accepts the upgrade and sends `ready`
|
|
2103
|
-
* without waiting for `init`; the `init` frame is still sent, first, and that
|
|
2104
|
-
* server ignores it. A server that does not read them waits for `init` exactly
|
|
2105
|
-
* as before. `command` and `cwd` travel only in the `init` frame, inside the
|
|
2106
|
-
* WebSocket: the URL and the request headers reach access logs.
|
|
2107
|
-
*
|
|
2108
|
-
* Detach/reconnect: the server keeps the PTY alive for `detachTimeoutMs`
|
|
2109
|
-
* (5 minutes today) after the socket closes; re-dialing with the SAME
|
|
2110
|
-
* connectionId reattaches and replays the buffered output history, so a
|
|
2111
|
-
* fresh client repaints the current screen.
|
|
2112
|
-
*
|
|
2113
|
-
* Browser-safe: uses the global `WebSocket` (browsers, Workers, Node >= 22)
|
|
2114
|
-
* and never imports `ws` — the same environment contract as
|
|
2115
|
-
* `session-gateway/client.ts`.
|
|
2075
|
+
* Browser-safe PTY client; TerminalWire owns the frame contract.
|
|
2076
|
+
* Send init first. Interactive authority binds to that socket; input and resize
|
|
2077
|
+
* do not resend it. Binary frames carry PTY bytes; JSON frames carry control.
|
|
2078
|
+
* Command, cwd and env stay in init, outside URLs and access logs. Only a
|
|
2079
|
+
* default-shell attach may put dimensions/defaultShell on the upgrade URL.
|
|
2080
|
+
* Reconnecting with the same connectionId replays output while the server's
|
|
2081
|
+
* detach window remains open. Uses global WebSocket, never the Node ws package.
|
|
2116
2082
|
*/
|
|
2117
2083
|
/**
|
|
2118
2084
|
* Client for one terminal WebSocket connection. Construct via
|
|
@@ -2179,7 +2145,7 @@ var TerminalStream = class TerminalStream {
|
|
|
2179
2145
|
return new Promise((resolve, reject) => {
|
|
2180
2146
|
let settled = false;
|
|
2181
2147
|
let opened = false;
|
|
2182
|
-
const timeoutMs = this.#options.connectTimeoutMs ??
|
|
2148
|
+
const timeoutMs = this.#options.connectTimeoutMs ?? SDK_TIMEOUTS.terminalConnect;
|
|
2183
2149
|
const timer = setTimeout(() => {
|
|
2184
2150
|
fail(new TerminalStreamError(`Terminal attach timed out after ${timeoutMs}ms waiting for ready`, { code: "CONNECT_TIMEOUT" }));
|
|
2185
2151
|
this.ws.close(1e3, "connect timeout");
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { dt as AgentInteractiveSessionRef, o as TerminalStreamReconnectAuthority, u as ScopedToken } from "./terminal-stream-types-
|
|
2
|
-
import { Cn as TerminalStream } from "./types-
|
|
3
|
-
import { a as InteractiveSessionControlController, c as InteractiveSessionIdentity, f as InteractiveAttachOptions, g as InteractiveRequestOptions, n as BrowserInteractiveSessionControlControllerOptions, o as InteractiveSessionControlControllerOptions, s as InteractiveSessionControlTransport } from "./browser-interactive-control-controller-
|
|
1
|
+
import { dt as AgentInteractiveSessionRef, o as TerminalStreamReconnectAuthority, u as ScopedToken } from "./terminal-stream-types-eE97lZ-5.js";
|
|
2
|
+
import { Cn as TerminalStream } from "./types-Cs5eJzOK.js";
|
|
3
|
+
import { a as InteractiveSessionControlController, c as InteractiveSessionIdentity, f as InteractiveAttachOptions, g as InteractiveRequestOptions, n as BrowserInteractiveSessionControlControllerOptions, o as InteractiveSessionControlControllerOptions, s as InteractiveSessionControlTransport } from "./browser-interactive-control-controller-CcUjQEfa.js";
|
|
4
4
|
|
|
5
5
|
//#region src/interactive-controller.d.ts
|
|
6
6
|
/** The request fields supplied by an attach caller before control is claimed. */
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as runPreparedEvidence } from "../prepared-evidence-
|
|
1
|
+
import { t as runPreparedEvidence } from "../prepared-evidence-ibAysmX8.js";
|
|
2
2
|
export { runPreparedEvidence };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as withPreparedProcessCalls, t as runPreparedProcess } from "../prepared-process-
|
|
1
|
+
import { n as withPreparedProcessCalls, t as runPreparedProcess } from "../prepared-process-DQ_68Ofg.js";
|
|
2
2
|
export { runPreparedProcess, withPreparedProcessCalls };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { D as ValidationError, r as parseErrorResponse } from "./errors-
|
|
1
|
+
import { D as ValidationError, r as parseErrorResponse } from "./errors-nXGKGVFe.js";
|
|
2
2
|
//#region src/line-identity.ts
|
|
3
3
|
/**
|
|
4
4
|
* The instance key that serves one member: `keyPrefix` plus the first 32 hex
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Tn as CreateSandboxOptions, ga as BackendConfig } from "./types-
|
|
1
|
+
import { Tn as CreateSandboxOptions, ga as BackendConfig } from "./types-Cs5eJzOK.js";
|
|
2
2
|
|
|
3
3
|
//#region src/line-application.d.ts
|
|
4
4
|
/** Bounded callback request bytes after canonicalization, including JSON framing. */
|
package/dist/lines.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { A as LineRespondAgent, B as LineVoiceOptions, C as LineMessage, D as LineReplyCode, E as LineReminderPreferences, F as LineSenderVerification, I as LineSenderVerificationStart, L as LineThread, M as LineRole, N as LineSendInput, O as LineReplyCodeInput, P as LineSendReceipt, R as LineTransport, S as LineMemberSpec, T as LineProvider, V as LinesHttpClient, _ as LineInstanceCreate, a as Line, b as LineMemberInstance, c as LineAllowanceSubject, d as LineAttachment, f as LineAttachmentReauthorization, g as LineInstanceAttachOptions, h as LineImage, i as profileChannelReference, j as LineRespondView, k as LineReplyGate, l as LineApplicationAttachOptions, m as LineFromConnectionInput, n as SandboxLines, o as LineAgentRolePolicy, p as LineExecutionKey, r as lineInstanceKey, s as LineAllowance, t as LinesClient, u as LineAttachOptions, v as LineLimits, w as LineNumberInventory, x as LineMemberPatch, y as LineMember, z as LineVoice } from "./lines-
|
|
1
|
+
import { A as LineRespondAgent, B as LineVoiceOptions, C as LineMessage, D as LineReplyCode, E as LineReminderPreferences, F as LineSenderVerification, I as LineSenderVerificationStart, L as LineThread, M as LineRole, N as LineSendInput, O as LineReplyCodeInput, P as LineSendReceipt, R as LineTransport, S as LineMemberSpec, T as LineProvider, V as LinesHttpClient, _ as LineInstanceCreate, a as Line, b as LineMemberInstance, c as LineAllowanceSubject, d as LineAttachment, f as LineAttachmentReauthorization, g as LineInstanceAttachOptions, h as LineImage, i as profileChannelReference, j as LineRespondView, k as LineReplyGate, l as LineApplicationAttachOptions, m as LineFromConnectionInput, n as SandboxLines, o as LineAgentRolePolicy, p as LineExecutionKey, r as lineInstanceKey, s as LineAllowance, t as LinesClient, u as LineAttachOptions, v as LineLimits, w as LineNumberInventory, x as LineMemberPatch, y as LineMember, z as LineVoice } from "./lines-qvpmwN_2.js";
|
|
2
2
|
export { Line, LineAgentRolePolicy, LineAllowance, LineAllowanceSubject, LineApplicationAttachOptions, LineAttachOptions, LineAttachment, LineAttachmentReauthorization, LineExecutionKey, LineFromConnectionInput, LineImage, LineInstanceAttachOptions, LineInstanceCreate, LineLimits, LineMember, LineMemberInstance, LineMemberPatch, LineMemberSpec, LineMessage, LineNumberInventory, LineProvider, LineReminderPreferences, LineReplyCode, LineReplyCodeInput, LineReplyGate, LineRespondAgent, LineRespondView, LineRole, LineSendInput, LineSendReceipt, LineSenderVerification, LineSenderVerificationStart, LineThread, LineTransport, LineVoice, LineVoiceOptions, LinesClient, LinesHttpClient, SandboxLines, lineInstanceKey, profileChannelReference };
|
package/dist/lines.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { i as profileChannelReference, n as SandboxLines, r as lineInstanceKey, t as LinesClient } from "./lines-
|
|
1
|
+
import { i as profileChannelReference, n as SandboxLines, r as lineInstanceKey, t as LinesClient } from "./lines-CSGBHEjR.js";
|
|
2
2
|
export { LinesClient, SandboxLines, lineInstanceKey, profileChannelReference };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as AUTH_BUNDLE_PATHS } from "./cli-auth-bundle-C6DtK7GX-
|
|
1
|
+
import { t as AUTH_BUNDLE_PATHS } from "./cli-auth-bundle-C6DtK7GX-mBUPER0R.js";
|
|
2
2
|
import { existsSync, readFileSync } from "node:fs";
|
|
3
3
|
import { basename, dirname, join } from "node:path";
|
|
4
4
|
import { homedir } from "node:os";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
import "./
|
|
3
|
-
import { a as listAgentPreviews, i as getAgentPreview, o as publishAgentPreview, r as ensureAgentPreview, s as removeAgentPreview, t as AgentPreviewError } from "./preview-operations-
|
|
1
|
+
import "./api-request-dyabkosT.js";
|
|
2
|
+
import { u as SANDBOX_FILE_API_ABSOLUTE_ROOTS } from "./file-transfer-DOSTbUSR.js";
|
|
3
|
+
import { a as listAgentPreviews, i as getAgentPreview, o as publishAgentPreview, r as ensureAgentPreview, s as removeAgentPreview, t as AgentPreviewError } from "./preview-operations-DWL78boI.js";
|
|
4
4
|
//#region \0rolldown/runtime.js
|
|
5
5
|
var __defProp = Object.defineProperty;
|
|
6
6
|
var __exportAll = (all, no_symbols) => {
|
|
@@ -396,7 +396,7 @@ async function createMcpServer(box, options = {}) {
|
|
|
396
396
|
const { bindings, handlers } = bindToolSpecs(box, options);
|
|
397
397
|
const server = new serverModule.Server({
|
|
398
398
|
name: options.name ?? "tangle-sandbox",
|
|
399
|
-
version: options.version ?? "1.0.
|
|
399
|
+
version: options.version ?? "1.0.233"
|
|
400
400
|
}, { capabilities: { tools: {} } });
|
|
401
401
|
server.setRequestHandler(typesModule.ListToolsRequestSchema, async () => ({ tools: bindings.map(({ spec: s }) => ({
|
|
402
402
|
name: s.name,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { t as parseSandboxRetryAfterHeader } from "./retry-after-header-
|
|
2
|
-
import { r as abortableSleep } from "./retry-policy-
|
|
1
|
+
import { t as parseSandboxRetryAfterHeader } from "./retry-after-header-BZbs5rig.js";
|
|
2
|
+
import { r as abortableSleep } from "./retry-policy-oW3_ljoc.js";
|
|
3
3
|
//#region src/lib/prepared-evidence.mjs
|
|
4
4
|
async function receipt(response, idField) {
|
|
5
5
|
const reader = response.body?.getReader();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { t as parseSandboxRetryAfterHeader } from "./retry-after-header-
|
|
2
|
-
import { n as SANDBOX_API_RETRY_SCOPE, r as abortableSleep, s as planResend } from "./retry-policy-
|
|
1
|
+
import { t as parseSandboxRetryAfterHeader } from "./retry-after-header-BZbs5rig.js";
|
|
2
|
+
import { n as SANDBOX_API_RETRY_SCOPE, r as abortableSleep, s as planResend } from "./retry-policy-oW3_ljoc.js";
|
|
3
3
|
//#region src/lib/prepared-process.mjs
|
|
4
4
|
/** Request and pause share one deadline, including independent cancellation cleanup. */
|
|
5
5
|
function processRequests(request, deadline, signal) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { O as SandboxInstance } from "./index-
|
|
2
|
-
import { F as EnsureDevServerOptions, H as PreviewLinkInfo } from "./types-
|
|
3
|
-
import { t as Sandbox } from "./client-
|
|
1
|
+
import { O as SandboxInstance } from "./index-DE5n6mot.js";
|
|
2
|
+
import { F as EnsureDevServerOptions, H as PreviewLinkInfo } from "./types-Cs5eJzOK.js";
|
|
3
|
+
import { t as Sandbox } from "./client-DlTDphmI.js";
|
|
4
4
|
|
|
5
5
|
//#region src/agent/preview-operations.d.ts
|
|
6
6
|
type AgentPreviewOptions = Pick<EnsureDevServerOptions, "sessionId" | "cwd"> & {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { L as SandboxError } from "./terminal-stream-types-
|
|
2
|
-
import { Cr as PublishPublicTemplateVersionOptions, Sr as PublishPublicTemplateOptions, Xr as HttpClient, br as PublicTemplateInfo, xr as PublicTemplateVersionInfo } from "./types-
|
|
1
|
+
import { L as SandboxError } from "./terminal-stream-types-eE97lZ-5.js";
|
|
2
|
+
import { Cr as PublishPublicTemplateVersionOptions, Sr as PublishPublicTemplateOptions, Xr as HttpClient, br as PublicTemplateInfo, xr as PublicTemplateVersionInfo } from "./types-Cs5eJzOK.js";
|
|
3
3
|
import { z } from "zod";
|
|
4
4
|
|
|
5
5
|
//#region src/public-templates.d.ts
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as PublicTemplatesClient, i as PublicTemplatePublishRequestOptions, n as PublicTemplatePublishError, r as PublicTemplatePublishJob, t as PublicTemplatePublishArtifact } from "./public-templates-
|
|
1
|
+
import { a as PublicTemplatesClient, i as PublicTemplatePublishRequestOptions, n as PublicTemplatePublishError, r as PublicTemplatePublishJob, t as PublicTemplatePublishArtifact } from "./public-templates-WuvmbvzY.js";
|
|
2
2
|
export { PublicTemplatePublishArtifact, PublicTemplatePublishError, PublicTemplatePublishJob, PublicTemplatePublishRequestOptions, PublicTemplatesClient };
|
package/dist/public-templates.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { n as verifyDownload } from "./file-download-
|
|
2
|
-
import { t as runPreparedEvidence } from "./prepared-evidence-
|
|
1
|
+
import { n as verifyDownload } from "./file-download-BjkrYzy_.js";
|
|
2
|
+
import { t as runPreparedEvidence } from "./prepared-evidence-ibAysmX8.js";
|
|
3
3
|
import { z } from "zod";
|
|
4
4
|
//#region src/lib/raw-evidence-archive.ts
|
|
5
5
|
const digest = z.string().regex(/^sha256:[a-f0-9]{64}$/).transform((value) => `sha256:${value.slice(7)}`);
|
|
@@ -1,11 +1,5 @@
|
|
|
1
1
|
//#region ../../../packages/runtime-contracts/dist/retry-policy.js
|
|
2
|
-
/**
|
|
3
|
-
* The one pacing every lifecycle hop re-sends with: the server's Retry-After,
|
|
4
|
-
* else full-jitter exponential backoff, inside a retry budget per downstream
|
|
5
|
-
* holding a storm near a tenth of the requests sent. Whether a failure reached
|
|
6
|
-
* the server is read here; whether it may be re-sent stays with the catalog
|
|
7
|
-
* and the verb. Imports nothing.
|
|
8
|
-
*/
|
|
2
|
+
/** Shared resend pacing and downstream budgets; the catalog and verb own eligibility. */
|
|
9
3
|
/** Raised before a request byte left: a dial refused, unresolved, unroutable or timed out, or a refused certificate. */
|
|
10
4
|
const UNDELIVERED_CODES = new Set([
|
|
11
5
|
"ECONNREFUSED",
|
|
@@ -21,15 +15,8 @@ const UNDELIVERED_CODES = new Set([
|
|
|
21
15
|
"UNABLE_TO_GET_ISSUER_CERT_LOCALLY",
|
|
22
16
|
"CERT_HAS_EXPIRED"
|
|
23
17
|
]);
|
|
24
|
-
/** A Worker's fetch names the failure only in its message. */
|
|
25
18
|
const UNDELIVERED_MESSAGE = /\b(?:connection refused|DNS lookup failed|TLS handshake failed|before secure TLS connection was established)\b/i;
|
|
26
|
-
/**
|
|
27
|
-
* Whether a thrown failure proves no request reached the peer, so any verb may
|
|
28
|
-
* dial again: a code above or a `syscall: "connect"` failure under it (fetch
|
|
29
|
-
* nests the socket error in `cause`, a dual-stack dial in `errors`), or a
|
|
30
|
-
* Worker's message for one. A reset or timeout off the connect syscall may
|
|
31
|
-
* follow a request sent on a reused socket, so it proves nothing.
|
|
32
|
-
*/
|
|
19
|
+
/** Connect failures prove no delivery, even nested under cause/errors; later resets do not. */
|
|
33
20
|
function isUndelivered(cause) {
|
|
34
21
|
const pending = [cause];
|
|
35
22
|
for (let read = 0; pending.length > 0 && read < 16; read++) {
|
|
@@ -44,23 +31,17 @@ function isUndelivered(cause) {
|
|
|
44
31
|
return false;
|
|
45
32
|
}
|
|
46
33
|
const RETRY_POLICY = {
|
|
47
|
-
/** The first re-send waits up to baseMs; each later one doubles it, up to capMs. */
|
|
48
34
|
baseMs: 250,
|
|
49
35
|
capMs: 8e3,
|
|
50
|
-
/** Re-sends one request earns. */
|
|
51
36
|
budgetRatio: .1,
|
|
52
|
-
/** Re-sends an idle downstream may spend at once: 10 s of the floor. */
|
|
53
37
|
budgetCapacity: 100,
|
|
54
|
-
/** Re-sends earned each second however quiet the caller (Finagle's default). */
|
|
55
38
|
budgetFloorPerSecond: 10
|
|
56
39
|
};
|
|
57
|
-
/** Re-send `resend` (1 = first) waits the server's `retryAfterMs` (its pushback, as in gRPC), else U[0, min(cap, base * 2^(resend-1))). */
|
|
58
40
|
function backoffDelayMs(resend, retryAfterMs, capMs = RETRY_POLICY.capMs) {
|
|
59
41
|
const ceilingMs = Math.min(capMs, RETRY_POLICY.baseMs * 2 ** (resend - 1));
|
|
60
42
|
return retryAfterMs ?? Math.random() * ceilingMs;
|
|
61
43
|
}
|
|
62
44
|
const budgets = /* @__PURE__ */ new Map();
|
|
63
|
-
/** The re-send budget for `scope`, one per downstream in this isolate or process. */
|
|
64
45
|
function retryBudget(scope) {
|
|
65
46
|
const { budgetCapacity, budgetFloorPerSecond, budgetRatio } = RETRY_POLICY;
|
|
66
47
|
let budget = budgets.get(scope);
|
|
@@ -87,7 +68,6 @@ function retryBudget(scope) {
|
|
|
87
68
|
budgets.set(scope, budget);
|
|
88
69
|
return budget;
|
|
89
70
|
}
|
|
90
|
-
/** Resolve after `ms`; reject with the signal's reason the moment it aborts. */
|
|
91
71
|
function abortableSleep(ms, signal) {
|
|
92
72
|
if (signal?.aborted) return Promise.reject(signal.reason);
|
|
93
73
|
if (ms <= 0) return Promise.resolve();
|
|
@@ -103,7 +83,6 @@ function abortableSleep(ms, signal) {
|
|
|
103
83
|
signal?.addEventListener("abort", onAbort, { once: true });
|
|
104
84
|
});
|
|
105
85
|
}
|
|
106
|
-
/** The Sandbox API downstream: every SDK request earns its budget and every SDK re-send spends it. */
|
|
107
86
|
const SANDBOX_API_RETRY_SCOPE = "sandbox-api";
|
|
108
87
|
/** Re-send `resend`'s wait: its backoff and, unless the server paced it, its budget turn (taken now); `undefined`, spending nothing, past `deadlineAt` (default: one cap past the backoff). */
|
|
109
88
|
function planResend(scope, resend, o = {}) {
|
|
@@ -114,7 +93,6 @@ function planResend(scope, resend, o = {}) {
|
|
|
114
93
|
const turnMs = retryBudget(scope).take(remainingMs);
|
|
115
94
|
return turnMs === void 0 ? void 0 : Math.max(backoffMs, turnMs);
|
|
116
95
|
}
|
|
117
|
-
/** Wait out {@link planResend}; `false` when it could not go. `spent` hears the wait first, for a loop whose window counts only waits. */
|
|
118
96
|
async function awaitResend(scope, resend, o = {}) {
|
|
119
97
|
const waitMs = planResend(scope, resend, o);
|
|
120
98
|
if (waitMs === void 0) return false;
|
package/dist/runtime.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { B as ServerError, C as CapabilityError, D as FileWriteConflictError, F as QuotaError, G as ValidationError, L as SandboxError, M as NotFoundError, N as PartialFailureError, P as ProfileFileMountPathError, R as SandboxErrorJson, V as StateError, W as TimeoutError, j as NetworkError, u as ScopedToken, x as AuthError, z as SandboxFailureDetail } from "./terminal-stream-types-
|
|
2
|
-
import { $i as SessionExecutionStatus, Bi as CreateSessionOptions, Cn as TerminalStream, Di as SandboxEvent, Fi as CommitTaskSessionOptions, Gi as ListMessagesOptions, Gn as ChunkedUploadResult, Ji as SendSessionMessageRequest, Qi as SessionExecutionInfo, Qn as FileReadBatchResult, Vi as CreateTaskSessionOptions, Wn as ChunkedUploadOptions, Yi as SentSessionMessage, Zi as SessionEventStreamOptions, Zn as FileReadBatchOptions, aa as SessionMessage, ar as FileTreeResult, cr as FileWriteResult, dn as SandboxTerminalCreateOptions, dr as RenameOptions, fa as TaskSessionInfo, fn as SandboxTerminalInfo, ir as FileTreeOptions, la as TaskSessionChanges, ln as SandboxRuntimeHealth, mn as SandboxTerminalRequestOptions, mr as WriteFileOptions, na as SessionInfo, oa as SessionMessageAdmission, on as SandboxPortBinding, or as FileUsageOptions, pn as SandboxTerminalManager, pr as UploadProgress, qi as SendSessionMessageOptions, sr as FileUsageResult, tr as FileRenameResult, ua as TaskSessionCommitResult } from "./types-
|
|
3
|
-
import { c as InteractiveSessionIdentity, l as InteractiveSessionNotRunningError, r as browserInteractiveControlHolderId } from "./browser-interactive-control-controller-
|
|
4
|
-
import { t as BrowserInteractiveSessionController } from "./interactive-controller-
|
|
5
|
-
import { a as deriveAgentRunOutcome, i as deriveAgentResultOutcome, n as AgentRunOutcomeTracker, o as projectAgentTerminalRecord, r as createAgentRunOutcomeTracker, t as AgentRunOutcome } from "./agent-run-outcome-
|
|
1
|
+
import { B as ServerError, C as CapabilityError, D as FileWriteConflictError, F as QuotaError, G as ValidationError, L as SandboxError, M as NotFoundError, N as PartialFailureError, P as ProfileFileMountPathError, R as SandboxErrorJson, V as StateError, W as TimeoutError, j as NetworkError, u as ScopedToken, x as AuthError, z as SandboxFailureDetail } from "./terminal-stream-types-eE97lZ-5.js";
|
|
2
|
+
import { $i as SessionExecutionStatus, Bi as CreateSessionOptions, Cn as TerminalStream, Di as SandboxEvent, Fi as CommitTaskSessionOptions, Gi as ListMessagesOptions, Gn as ChunkedUploadResult, Ji as SendSessionMessageRequest, Qi as SessionExecutionInfo, Qn as FileReadBatchResult, Vi as CreateTaskSessionOptions, Wn as ChunkedUploadOptions, Xr as HttpClient, Yi as SentSessionMessage, Zi as SessionEventStreamOptions, Zn as FileReadBatchOptions, aa as SessionMessage, ar as FileTreeResult, cr as FileWriteResult, dn as SandboxTerminalCreateOptions, dr as RenameOptions, fa as TaskSessionInfo, fn as SandboxTerminalInfo, ir as FileTreeOptions, la as TaskSessionChanges, ln as SandboxRuntimeHealth, mn as SandboxTerminalRequestOptions, mr as WriteFileOptions, na as SessionInfo, oa as SessionMessageAdmission, on as SandboxPortBinding, or as FileUsageOptions, pn as SandboxTerminalManager, pr as UploadProgress, qi as SendSessionMessageOptions, sr as FileUsageResult, tr as FileRenameResult, ua as TaskSessionCommitResult } from "./types-Cs5eJzOK.js";
|
|
3
|
+
import { c as InteractiveSessionIdentity, l as InteractiveSessionNotRunningError, r as browserInteractiveControlHolderId } from "./browser-interactive-control-controller-CcUjQEfa.js";
|
|
4
|
+
import { t as BrowserInteractiveSessionController } from "./interactive-controller-sEU_J6Bc.js";
|
|
5
|
+
import { a as deriveAgentRunOutcome, i as deriveAgentResultOutcome, n as AgentRunOutcomeTracker, o as projectAgentTerminalRecord, r as createAgentRunOutcomeTracker, t as AgentRunOutcome } from "./agent-run-outcome-B0nURFpG.js";
|
|
6
6
|
|
|
7
7
|
//#region src/lib/chunked-upload.d.ts
|
|
8
8
|
/** The transport a caller wires this module to — {@link SandboxInstance.runtimeFetch}
|
|
@@ -32,7 +32,7 @@ declare function uploadChunked(transport: ChunkedUploadTransport, remotePath: st
|
|
|
32
32
|
//#region src/runtime-transport.d.ts
|
|
33
33
|
interface RuntimeTransport {
|
|
34
34
|
ensureRunning(): Promise<void>;
|
|
35
|
-
fetch
|
|
35
|
+
fetch: HttpClient["fetch"];
|
|
36
36
|
}
|
|
37
37
|
declare class RuntimeApiTransport {
|
|
38
38
|
protected readonly transport: RuntimeTransport;
|
|
@@ -121,7 +121,7 @@ interface SandboxRuntimeClientConfig {
|
|
|
121
121
|
baseUrl: string;
|
|
122
122
|
/** Short-lived `session-runtime` or `read-only` token. */
|
|
123
123
|
token: string;
|
|
124
|
-
/** Request timeout in milliseconds. Defaults to
|
|
124
|
+
/** Request timeout in milliseconds. Defaults to `SDK_TIMEOUTS.default`. */
|
|
125
125
|
timeoutMs?: number;
|
|
126
126
|
/** Fetch implementation override for Workers, tests, or custom runtimes. */
|
|
127
127
|
fetch?: typeof globalThis.fetch;
|