@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
package/README.md
CHANGED
|
@@ -20,7 +20,28 @@ export SANDBOX_BASE_URL=https://sandbox.tangle.tools
|
|
|
20
20
|
The oldest supported SDK is `@tangle-network/sandbox@1.0.151`, the first version that accepts a capability or enum value it does not know instead of refusing the whole response.
|
|
21
21
|
Older versions fail when the Sandbox API advertises a new value; upgrade to this version or later.
|
|
22
22
|
This line is the one place the floor is stated: the production journey (`scripts/production-journey.sh`) reads it and runs every cell's journey on it.
|
|
23
|
-
Every request from the [shared raw transport](src/lib/api-request.mjs) and the Python SDK sends `x-sdk-version: <package version>`, and the Sandbox Worker's invocation log records it as `$workers.event.request.headers.x-sdk-version`, so the versions customers run can be counted.
|
|
23
|
+
Every account-authenticated request from the [shared raw transport](src/lib/api-request.mjs) and the Python SDK sends `x-sdk-version: <package version>`, and the Sandbox Worker's invocation log records it as `$workers.event.request.headers.x-sdk-version`, so the versions customers run can be counted.
|
|
24
|
+
|
|
25
|
+
## Timeouts and retries
|
|
26
|
+
|
|
27
|
+
Every HTTP request has a default deadline, including direct runtime, Platform, browser control, collaboration and Tangle operator calls. [`SDK_TIMEOUTS`](src/lib/api-request.mjs) owns the values (milliseconds); import it from `@tangle-network/sandbox`. `SandboxConfig.timeoutMs` replaces `default`; an operation's own timeout replaces that client default. Caller cancellation still applies.
|
|
28
|
+
|
|
29
|
+
| Calls | Default policy |
|
|
30
|
+
|---|---|
|
|
31
|
+
| Calls without an exception below | `default` |
|
|
32
|
+
| `create()` | `create`, or `gpuCreate` for a GPU lease, including retries; a capacity ETA may extend an omitted timeout within the create recovery window |
|
|
33
|
+
| `exec()` | Execution limit from the operation contract plus `margin` |
|
|
34
|
+
| `runCode()` | Kernel limit (`runCode`), plus `margin`; a zero kernel limit leaves a finite default request deadline |
|
|
35
|
+
| Fleet `dispatchExec` / `dispatchPrompt` | Larger of the requested duration and `fleetDispatch`, plus `margin` |
|
|
36
|
+
| `snapshot`, retained `stop`, snapshot restore, image build | `snapshot`; image build accepts `timeout` |
|
|
37
|
+
| Workspace image publication | `workspaceImage` |
|
|
38
|
+
| `deleteMatching` | `deleteMatching`, or `deleteMatchingUntilRemoved` |
|
|
39
|
+
| Operation wait / preview readiness / terminal token / terminal connect | `operationWait` / `previewReady` / `interactiveToken` / `terminalConnect` |
|
|
40
|
+
| Session gateway status read / attestation signing keys | Their bounded read limits in the owning modules |
|
|
41
|
+
|
|
42
|
+
JSON and error bodies remain bounded through consumption. Successful event streams, downloads and batch streams use the request deadline through response headers; their lifetime is controlled by caller cancellation and the operation's stream policy. A timeout ends the client's wait; work already accepted by the server may continue. Rejoin a keyed create or batch using its original key.
|
|
43
|
+
|
|
44
|
+
Retries require both a replay-safe request and a retryable catalog error. Recovery may first refresh an expired bearer, supply a missing profile or wait for a retained snapshot's copy; these state changes preserve their existing recovery behavior. Transport retries retain shared pacing, `Retry-After`, caller cancellation and their deadline. `x-no-retry` disables transport replay.
|
|
24
45
|
|
|
25
46
|
## Choose an entrypoint
|
|
26
47
|
|
package/dist/agent/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { I as SandboxTaskSession, O as SandboxInstance, R as SandboxSession } from "../index-
|
|
2
|
-
import { Bt as SandboxFleetParent, Ha as CodeExecutionResult, Ua as CodeLanguage, Ur as CodeExecutionOptions, Wa as CodeResultPart, ga as BackendConfig, ia as SessionListOptions, mo as BackendType, na as SessionInfo } from "../types-
|
|
3
|
-
import { t as Sandbox } from "../client-
|
|
4
|
-
import { u as PreviewAuthorizer } from "../preview-
|
|
1
|
+
import { I as SandboxTaskSession, O as SandboxInstance, R as SandboxSession } from "../index-DE5n6mot.js";
|
|
2
|
+
import { Bt as SandboxFleetParent, Ha as CodeExecutionResult, Ua as CodeLanguage, Ur as CodeExecutionOptions, Wa as CodeResultPart, ga as BackendConfig, ia as SessionListOptions, mo as BackendType, na as SessionInfo } from "../types-Cs5eJzOK.js";
|
|
3
|
+
import { t as Sandbox } from "../client-DlTDphmI.js";
|
|
4
|
+
import { u as PreviewAuthorizer } from "../preview-BC_wLaA2.js";
|
|
5
5
|
import * as _$_modelcontextprotocol_sdk_server_index_js0 from "@modelcontextprotocol/sdk/server/index.js";
|
|
6
6
|
import { JSONSchema } from "zod/v4/core";
|
|
7
7
|
import { ToolSet } from "ai";
|
package/dist/agent/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { a as TOOL_SPECS, i as ALL_TOOL_SPECS, o as serializeToolResult, r as bindToolSpecs, t as createMcpServer } from "../mcp-local-
|
|
2
|
-
import { D as assertCurrentBackendType } from "../interactive-controller-
|
|
3
|
-
import { t as SandboxInstance } from "../sandbox-
|
|
4
|
-
import { D as ValidationError, _ as NotFoundError, w as StateError } from "../errors-
|
|
5
|
-
import { t as Sandbox } from "../client-
|
|
1
|
+
import { a as TOOL_SPECS, i as ALL_TOOL_SPECS, o as serializeToolResult, r as bindToolSpecs, t as createMcpServer } from "../mcp-local-Dz_Sehz0.js";
|
|
2
|
+
import { D as assertCurrentBackendType } from "../interactive-controller-DDPdZa2H.js";
|
|
3
|
+
import { t as SandboxInstance } from "../sandbox-OyCRplrI.js";
|
|
4
|
+
import { D as ValidationError, _ as NotFoundError, w as StateError } from "../errors-nXGKGVFe.js";
|
|
5
|
+
import { t as Sandbox } from "../client-BS-PR_-j.js";
|
|
6
6
|
import { z } from "zod";
|
|
7
7
|
//#region src/agent/instances.ts
|
|
8
8
|
const managers = /* @__PURE__ */ new WeakMap();
|
package/dist/agent/preview.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { _ as publishAgentPreview, a as previewOperationTool, c as AgentPreviewOptions, d as PreviewExecutionContext, f as PublishAgentPreviewOptions, g as listAgentPreviews, h as getAgentPreview, i as PreviewTool, l as PreviewAuthorizationRequest, m as ensureAgentPreview, n as PREVIEW_MCP_ALIAS, o as previewToolsForProfile, p as assertPreviewId, r as PREVIEW_TOOLS, s as AgentPreviewError, t as servePreviewMcp, u as PreviewAuthorizer, v as removeAgentPreview, y as resolveSelfSandbox } from "../preview-
|
|
1
|
+
import { _ as publishAgentPreview, a as previewOperationTool, c as AgentPreviewOptions, d as PreviewExecutionContext, f as PublishAgentPreviewOptions, g as listAgentPreviews, h as getAgentPreview, i as PreviewTool, l as PreviewAuthorizationRequest, m as ensureAgentPreview, n as PREVIEW_MCP_ALIAS, o as previewToolsForProfile, p as assertPreviewId, r as PREVIEW_TOOLS, s as AgentPreviewError, t as servePreviewMcp, u as PreviewAuthorizer, v as removeAgentPreview, y as resolveSelfSandbox } from "../preview-BC_wLaA2.js";
|
|
2
2
|
export { AgentPreviewError, AgentPreviewOptions, PREVIEW_MCP_ALIAS, PREVIEW_TOOLS, PreviewAuthorizationRequest, PreviewAuthorizer, PreviewExecutionContext, PreviewTool, PublishAgentPreviewOptions, assertPreviewId, ensureAgentPreview, getAgentPreview, listAgentPreviews, previewOperationTool, previewToolsForProfile, publishAgentPreview, removeAgentPreview, resolveSelfSandbox, servePreviewMcp };
|
package/dist/agent/preview.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { r as agentProfileSchema } from "../profile-schema-C1KpT-wS.js";
|
|
2
|
-
import { a as listAgentPreviews, c as resolveSelfSandbox, i as getAgentPreview, n as assertPreviewId, o as publishAgentPreview, r as ensureAgentPreview, s as removeAgentPreview, t as AgentPreviewError } from "../preview-operations-
|
|
2
|
+
import { a as listAgentPreviews, c as resolveSelfSandbox, i as getAgentPreview, n as assertPreviewId, o as publishAgentPreview, r as ensureAgentPreview, s as removeAgentPreview, t as AgentPreviewError } from "../preview-operations-DWL78boI.js";
|
|
3
3
|
//#region src/agent/preview-policy.ts
|
|
4
4
|
/** Channel-neutral preview tool selection from a host-authored profile. */
|
|
5
5
|
const PREVIEW_TOOLS = [
|
|
@@ -66,7 +66,7 @@ async function servePreviewMcp(request, config) {
|
|
|
66
66
|
if (typeof config.authorize !== "function") throw new Error("Preview MCP requires a host authorization callback");
|
|
67
67
|
const tools = config.tools ?? PREVIEW_TOOLS;
|
|
68
68
|
if (!tools.length || tools.some((tool) => !PREVIEW_TOOLS.includes(tool))) throw new Error("Preview MCP requires an explicit nonempty preview-only tool grant");
|
|
69
|
-
const [{ createMcpServer }, { WebStandardStreamableHTTPServerTransport }] = await Promise.all([import("../mcp-local-
|
|
69
|
+
const [{ createMcpServer }, { WebStandardStreamableHTTPServerTransport }] = await Promise.all([import("../mcp-local-Dz_Sehz0.js").then((n) => n.n), import("@modelcontextprotocol/sdk/server/webStandardStreamableHttp.js")]);
|
|
70
70
|
const handle = await createMcpServer(config.box, {
|
|
71
71
|
name: "tangle-previews",
|
|
72
72
|
sessionId: config.sessionId,
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { o as canonicalCandidateDigest, u as isCanonicalJsonValue } from "./harness-DMaNgn0S.js";
|
|
2
|
+
import { o as canonicalAgentProfileValue, r as agentProfileSchema } from "./profile-schema-C1KpT-wS.js";
|
|
3
|
+
//#region ../../../node_modules/.pnpm/@tangle-network+agent-interface@5.10.13/node_modules/@tangle-network/agent-interface/dist/agent-execution-preparation.js
|
|
4
|
+
/**
|
|
5
|
+
* Canonical RFC 8785/SHA-256 identity for one validated, public AgentProfile.
|
|
6
|
+
* Secret-capable MCP/hook fields are tagged. Other prompt, resource, metadata,
|
|
7
|
+
* and tool text is ordinary public profile data: it may legitimately discuss
|
|
8
|
+
* credentials, security incidents, or examples that resemble credentials, so
|
|
9
|
+
* pattern matching cannot decide whether it is secret. Resolve opaque secret
|
|
10
|
+
* references only after this public identity is fixed.
|
|
11
|
+
*/
|
|
12
|
+
function canonicalAgentProfileDigest(profile) {
|
|
13
|
+
const material = canonicalAgentProfileValue(agentProfileSchema.parse(profile));
|
|
14
|
+
if (material === void 0 || !isCanonicalJsonValue(material)) throw new Error("AgentProfile must contain finite, acyclic RFC 8785 JSON values");
|
|
15
|
+
return canonicalCandidateDigest(material);
|
|
16
|
+
}
|
|
17
|
+
//#endregion
|
|
18
|
+
export { canonicalAgentProfileDigest as t };
|
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
import { g as sha256DigestSchema, h as omitTopLevelDigest, m as looksLikeCredential, n as REASONING_EFFORTS, o as canonicalCandidateDigest, p as isWellFormedUnicode, s as canonicalCandidateJson, t as harnessTypeSchema, u as isCanonicalJsonValue } from "./harness-DMaNgn0S.js";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
//#region ../../../node_modules/.pnpm/@tangle-network+agent-interface@5.10.13/node_modules/@tangle-network/agent-interface/dist/agent-workspace-source-snapshot.js
|
|
4
|
+
const controlCharacterPattern = /[\u0000-\u001f\u007f]/;
|
|
5
|
+
/** Shared public identifier used by workspace lifecycle contracts. */
|
|
6
|
+
const agentWorkspacePublicIdentifierSchema = z.string().min(1).max(500).refine((value) => value.trim().length > 0 && isWellFormedUnicode(value) && !controlCharacterPattern.test(value) && !looksLikeCredential(value), "public workspace identity cannot carry credential-like material");
|
|
7
|
+
const agentWorkspaceSourceSnapshotPolicySchema = z.strictObject({
|
|
8
|
+
kind: z.literal("provider-declared"),
|
|
9
|
+
name: agentWorkspacePublicIdentifierSchema,
|
|
10
|
+
version: z.number().int().positive().max(Number.MAX_SAFE_INTEGER),
|
|
11
|
+
digest: sha256DigestSchema
|
|
12
|
+
});
|
|
13
|
+
//#endregion
|
|
14
|
+
//#region ../../../node_modules/.pnpm/@tangle-network+agent-interface@5.10.13/node_modules/@tangle-network/agent-interface/dist/agent-profile-materialization.js
|
|
15
|
+
/**
|
|
16
|
+
* The canonical AgentProfile leaves that can affect one execution.
|
|
17
|
+
*
|
|
18
|
+
* Compound parents such as `model`, `prompt`, and `resources` are deliberately
|
|
19
|
+
* absent. A producer must report the exact requested leaf instead of claiming
|
|
20
|
+
* a parent while silently dropping one of its children. `systemPrompt` and
|
|
21
|
+
* `appendSystemPrompt` are separate leaves for the same reason: a backend that
|
|
22
|
+
* can only add text must report the requested replacement as unsatisfied rather
|
|
23
|
+
* than acknowledge it.
|
|
24
|
+
*/
|
|
25
|
+
const AGENT_PROFILE_MATERIALIZATION_AXES = [
|
|
26
|
+
"name",
|
|
27
|
+
"description",
|
|
28
|
+
"version",
|
|
29
|
+
"tags",
|
|
30
|
+
"systemPrompt",
|
|
31
|
+
"appendSystemPrompt",
|
|
32
|
+
"instructions",
|
|
33
|
+
"modelDefault",
|
|
34
|
+
"modelSmall",
|
|
35
|
+
"modelProvider",
|
|
36
|
+
"modelReasoningEffort",
|
|
37
|
+
"modelMaxVisibleOutputTokens",
|
|
38
|
+
"modelMaxReasoningTokens",
|
|
39
|
+
"modelMaxTotalOutputTokens",
|
|
40
|
+
"modelMetadata",
|
|
41
|
+
"harness",
|
|
42
|
+
"seats",
|
|
43
|
+
"proxySecrets",
|
|
44
|
+
"permissions",
|
|
45
|
+
"tools",
|
|
46
|
+
"mcp",
|
|
47
|
+
"connections",
|
|
48
|
+
"subagents",
|
|
49
|
+
"files",
|
|
50
|
+
"resourceTools",
|
|
51
|
+
"skills",
|
|
52
|
+
"resourceAgents",
|
|
53
|
+
"commands",
|
|
54
|
+
"knowledge",
|
|
55
|
+
"resourceInstructions",
|
|
56
|
+
"resourceFailOnError",
|
|
57
|
+
"hooks",
|
|
58
|
+
"modes",
|
|
59
|
+
"confidential",
|
|
60
|
+
"metadata",
|
|
61
|
+
"extensions"
|
|
62
|
+
];
|
|
63
|
+
[...Object.entries({
|
|
64
|
+
default: "modelDefault",
|
|
65
|
+
small: "modelSmall",
|
|
66
|
+
provider: "modelProvider",
|
|
67
|
+
reasoningEffort: "modelReasoningEffort",
|
|
68
|
+
maxVisibleOutputTokens: "modelMaxVisibleOutputTokens",
|
|
69
|
+
maxReasoningTokens: "modelMaxReasoningTokens",
|
|
70
|
+
maxTotalOutputTokens: "modelMaxTotalOutputTokens",
|
|
71
|
+
metadata: "modelMetadata"
|
|
72
|
+
}).map(([property, axis]) => ({
|
|
73
|
+
axis,
|
|
74
|
+
rootPath: `/model/${property}`,
|
|
75
|
+
value: (profile) => profile.model?.[property]
|
|
76
|
+
}))];
|
|
77
|
+
//#endregion
|
|
78
|
+
//#region ../../../node_modules/.pnpm/@tangle-network+agent-interface@5.10.13/node_modules/@tangle-network/agent-interface/dist/agent-execution-preparation-receipt.js
|
|
79
|
+
const nonBlankStringSchema = z.string().refine((value) => value.trim().length > 0, "value cannot be blank");
|
|
80
|
+
const publicMechanismIdentifierSchema = z.string().regex(/^[A-Za-z0-9][A-Za-z0-9._:/-]{0,199}$/, "mechanism must be a public identifier, not launch arguments").refine((value) => !looksLikeCredential(value), "mechanism cannot carry credential-like material");
|
|
81
|
+
const publicLifecycleIdentifierSchema = z.string().regex(/^[A-Za-z0-9][A-Za-z0-9._~:/+-]{0,499}$/, "lifecycle identity must be a public identifier").refine((value) => !looksLikeCredential(value), "lifecycle identity cannot carry credential-like material");
|
|
82
|
+
const publicReasonSchema = nonBlankStringSchema.max(4e3).refine((value) => !looksLikeCredential(value), "reason cannot carry credential-like material");
|
|
83
|
+
const jsonPointerSchema = z.string().refine(isCanonicalJsonPointer, "path must be a canonical RFC 6901 JSON Pointer");
|
|
84
|
+
const agentExecutionPreparationAxisResultSchema = z.strictObject({
|
|
85
|
+
axis: z.enum(AGENT_PROFILE_MATERIALIZATION_AXES),
|
|
86
|
+
disposition: z.enum([
|
|
87
|
+
"behavior",
|
|
88
|
+
"control",
|
|
89
|
+
"overridden",
|
|
90
|
+
"unsupported"
|
|
91
|
+
]),
|
|
92
|
+
owner: z.enum(["runtime", "executor"]),
|
|
93
|
+
mechanism: publicMechanismIdentifierSchema,
|
|
94
|
+
evidenceDigest: sha256DigestSchema.optional(),
|
|
95
|
+
path: jsonPointerSchema.optional(),
|
|
96
|
+
reason: publicReasonSchema.optional()
|
|
97
|
+
}).superRefine((result, context) => {
|
|
98
|
+
const requiresReason = result.disposition === "overridden" || result.disposition === "unsupported";
|
|
99
|
+
if (requiresReason && result.reason === void 0) context.addIssue({
|
|
100
|
+
code: "custom",
|
|
101
|
+
path: ["reason"],
|
|
102
|
+
message: `${result.disposition} profile coverage requires a reason`
|
|
103
|
+
});
|
|
104
|
+
if (!requiresReason && result.reason !== void 0) context.addIssue({
|
|
105
|
+
code: "custom",
|
|
106
|
+
path: ["reason"],
|
|
107
|
+
message: `${result.disposition} profile coverage cannot carry an override reason`
|
|
108
|
+
});
|
|
109
|
+
});
|
|
110
|
+
const reasoningEffortSchema = z.enum(REASONING_EFFORTS);
|
|
111
|
+
const agentExecutionPreparationReasoningEffortSchema = z.strictObject({
|
|
112
|
+
requested: reasoningEffortSchema,
|
|
113
|
+
resolved: reasoningEffortSchema.optional(),
|
|
114
|
+
fidelity: z.enum([
|
|
115
|
+
"exact",
|
|
116
|
+
"clamped",
|
|
117
|
+
"unsupported"
|
|
118
|
+
])
|
|
119
|
+
}).superRefine((effort, context) => {
|
|
120
|
+
if (effort.fidelity === "unsupported") {
|
|
121
|
+
if (effort.resolved !== void 0) context.addIssue({
|
|
122
|
+
code: "custom",
|
|
123
|
+
path: ["resolved"],
|
|
124
|
+
message: "unsupported reasoning effort cannot claim a resolved value"
|
|
125
|
+
});
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
if (effort.resolved === void 0) {
|
|
129
|
+
context.addIssue({
|
|
130
|
+
code: "custom",
|
|
131
|
+
path: ["resolved"],
|
|
132
|
+
message: `${effort.fidelity} reasoning fidelity requires a resolved value`
|
|
133
|
+
});
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
if (effort.fidelity === "exact" && effort.resolved !== effort.requested) context.addIssue({
|
|
137
|
+
code: "custom",
|
|
138
|
+
path: ["resolved"],
|
|
139
|
+
message: "exact reasoning fidelity must preserve the requested effort"
|
|
140
|
+
});
|
|
141
|
+
if (effort.fidelity === "clamped") {
|
|
142
|
+
if (effort.resolved === effort.requested) context.addIssue({
|
|
143
|
+
code: "custom",
|
|
144
|
+
path: ["resolved"],
|
|
145
|
+
message: "clamped reasoning fidelity must change the requested effort"
|
|
146
|
+
});
|
|
147
|
+
else if (!isDownwardReasoningClamp(effort.requested, effort.resolved)) context.addIssue({
|
|
148
|
+
code: "custom",
|
|
149
|
+
path: ["resolved"],
|
|
150
|
+
message: "reasoning effort may clamp down but must never increase"
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
});
|
|
154
|
+
const agentExecutionPreparationReceiptSchema = z.strictObject({
|
|
155
|
+
kind: z.literal("agent-execution-preparation"),
|
|
156
|
+
schemaVersion: z.literal(1),
|
|
157
|
+
preparationId: nonBlankStringSchema.max(500),
|
|
158
|
+
requestDigest: sha256DigestSchema,
|
|
159
|
+
authoredProfileDigest: sha256DigestSchema,
|
|
160
|
+
effectiveProfileDigest: sha256DigestSchema,
|
|
161
|
+
backend: nonBlankStringSchema.max(200),
|
|
162
|
+
harness: harnessTypeSchema,
|
|
163
|
+
harnessVersion: nonBlankStringSchema.max(200),
|
|
164
|
+
resolvedModel: z.strictObject({
|
|
165
|
+
requested: z.string().max(500),
|
|
166
|
+
resolved: nonBlankStringSchema.max(500),
|
|
167
|
+
provider: z.string().max(200).optional(),
|
|
168
|
+
reasoningEffort: agentExecutionPreparationReasoningEffortSchema.optional()
|
|
169
|
+
}),
|
|
170
|
+
workspace: z.strictObject({
|
|
171
|
+
leaseId: publicLifecycleIdentifierSchema,
|
|
172
|
+
provider: publicLifecycleIdentifierSchema,
|
|
173
|
+
identityDigest: sha256DigestSchema,
|
|
174
|
+
isolation: z.enum(["per-run", "shared"]),
|
|
175
|
+
sourceSnapshotDigest: sha256DigestSchema,
|
|
176
|
+
sourceSnapshotPolicy: agentWorkspaceSourceSnapshotPolicySchema,
|
|
177
|
+
preparedWorkspaceDigest: sha256DigestSchema,
|
|
178
|
+
profileActivationDigest: sha256DigestSchema
|
|
179
|
+
}),
|
|
180
|
+
axisResults: z.array(agentExecutionPreparationAxisResultSchema),
|
|
181
|
+
executionPlanDigest: sha256DigestSchema,
|
|
182
|
+
materializer: z.strictObject({
|
|
183
|
+
name: nonBlankStringSchema.max(200),
|
|
184
|
+
version: nonBlankStringSchema.max(200)
|
|
185
|
+
}),
|
|
186
|
+
expiresAtMs: z.number().int().positive().safe(),
|
|
187
|
+
digest: sha256DigestSchema
|
|
188
|
+
}).superRefine((receipt, context) => {
|
|
189
|
+
const seen = /* @__PURE__ */ new Map();
|
|
190
|
+
for (const [index, result] of receipt.axisResults.entries()) {
|
|
191
|
+
const key = agentExecutionPreparationAxisResultKey(result.axis, result.path);
|
|
192
|
+
const previous = seen.get(key);
|
|
193
|
+
if (previous !== void 0) context.addIssue({
|
|
194
|
+
code: "custom",
|
|
195
|
+
path: ["axisResults", index],
|
|
196
|
+
message: agentExecutionPreparationAxisResultsEqual(previous, result) ? "duplicate profile axis/path result" : "conflicting profile axis/path results"
|
|
197
|
+
});
|
|
198
|
+
else seen.set(key, result);
|
|
199
|
+
if (index > 0 && compareAgentExecutionPreparationAxisResults(receipt.axisResults[index - 1], result) >= 0) context.addIssue({
|
|
200
|
+
code: "custom",
|
|
201
|
+
path: ["axisResults", index],
|
|
202
|
+
message: "profile axis/path results must be canonically sorted"
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
if (!isCanonicalJsonValue(receipt)) context.addIssue({
|
|
206
|
+
code: "custom",
|
|
207
|
+
message: "execution preparation receipt must contain only RFC 8785 JSON values"
|
|
208
|
+
});
|
|
209
|
+
else if (canonicalCandidateDigest(omitTopLevelDigest(receipt)) !== receipt.digest) context.addIssue({
|
|
210
|
+
code: "custom",
|
|
211
|
+
path: ["digest"],
|
|
212
|
+
message: "execution preparation receipt digest is invalid"
|
|
213
|
+
});
|
|
214
|
+
});
|
|
215
|
+
/** @internal Canonical identity for one preparation axis and path. */
|
|
216
|
+
function agentExecutionPreparationAxisResultKey(axis, path) {
|
|
217
|
+
return `${axis}\u0000${path ?? ""}`;
|
|
218
|
+
}
|
|
219
|
+
/** @internal Exact public equality for preparation axis rows. */
|
|
220
|
+
function agentExecutionPreparationAxisResultsEqual(left, right) {
|
|
221
|
+
try {
|
|
222
|
+
return canonicalCandidateJson(left) === canonicalCandidateJson(right);
|
|
223
|
+
} catch {
|
|
224
|
+
return false;
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
const AXIS_ORDER = new Map(AGENT_PROFILE_MATERIALIZATION_AXES.map((axis, index) => [axis, index]));
|
|
228
|
+
/** @internal Canonical order for preparation axis rows. */
|
|
229
|
+
function compareAgentExecutionPreparationAxisResults(left, right) {
|
|
230
|
+
const axisDifference = (AXIS_ORDER.get(left.axis) ?? Number.MAX_SAFE_INTEGER) - (AXIS_ORDER.get(right.axis) ?? Number.MAX_SAFE_INTEGER);
|
|
231
|
+
if (axisDifference !== 0) return axisDifference;
|
|
232
|
+
const leftPath = left.path ?? "";
|
|
233
|
+
const rightPath = right.path ?? "";
|
|
234
|
+
return leftPath < rightPath ? -1 : leftPath > rightPath ? 1 : 0;
|
|
235
|
+
}
|
|
236
|
+
function isCanonicalJsonPointer(value) {
|
|
237
|
+
if (!value.startsWith("/") || !isWellFormedUnicode(value)) return false;
|
|
238
|
+
for (let index = 0; index < value.length; index += 1) {
|
|
239
|
+
if (value[index] !== "~") continue;
|
|
240
|
+
const escape = value[index + 1];
|
|
241
|
+
if (escape !== "0" && escape !== "1") return false;
|
|
242
|
+
index += 1;
|
|
243
|
+
}
|
|
244
|
+
return true;
|
|
245
|
+
}
|
|
246
|
+
function isDownwardReasoningClamp(requested, resolved) {
|
|
247
|
+
return REASONING_EFFORTS.indexOf(resolved) < REASONING_EFFORTS.indexOf(requested);
|
|
248
|
+
}
|
|
249
|
+
//#endregion
|
|
250
|
+
export { agentExecutionPreparationReceiptSchema as t };
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { Ct as InteractionRequest } from "./terminal-stream-types-
|
|
2
|
-
import { Di as SandboxEvent, _i as DurablePlanSnapshot, ci as AgentApprovalRequirement, di as AgentToolInvocation, li as AgentQuestionRequest, ui as AgentRunStatus } from "./types-
|
|
1
|
+
import { Ct as InteractionRequest } from "./terminal-stream-types-eE97lZ-5.js";
|
|
2
|
+
import { Di as SandboxEvent, _i as DurablePlanSnapshot, ci as AgentApprovalRequirement, di as AgentToolInvocation, li as AgentQuestionRequest, ui as AgentRunStatus } from "./types-Cs5eJzOK.js";
|
|
3
3
|
|
|
4
4
|
//#region src/agent-run-outcome.d.ts
|
|
5
5
|
interface AgentRunOutcome {
|
|
6
|
+
failure?: Readonly<Record<string, unknown>>;
|
|
6
7
|
success: boolean;
|
|
7
8
|
status: AgentRunStatus;
|
|
8
9
|
error?: string;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { t as
|
|
2
|
-
import {
|
|
1
|
+
import { r as catalogEntry, t as ERROR_CATALOG } from "./error-catalog-CAbzw67O.js";
|
|
2
|
+
import { t as parseSandboxRetryAfterHeader } from "./retry-after-header-BZbs5rig.js";
|
|
3
|
+
import { c as retryBudget, n as SANDBOX_API_RETRY_SCOPE, o as isUndelivered, r as abortableSleep, s as planResend } from "./retry-policy-oW3_ljoc.js";
|
|
3
4
|
//#region src/lib/response-rewrap.mjs
|
|
4
5
|
/**
|
|
5
6
|
* Response wrappers that must outlive the fetch Response they wrap.
|
|
@@ -29,13 +30,30 @@ function rewrapResponse(original, headers, body = original.body) {
|
|
|
29
30
|
//#endregion
|
|
30
31
|
//#region src/lib/api-request.mjs
|
|
31
32
|
/** The package version tsdown.config.ts defines; unbuilt source reports 0.0.0. */
|
|
32
|
-
const SDK_VERSION = "1.0.
|
|
33
|
+
const SDK_VERSION = "1.0.233";
|
|
33
34
|
function withRequestContextHeaders(response, path, method, body = response.body) {
|
|
34
35
|
const headers = new Headers(response.headers);
|
|
35
36
|
headers.set("x-tangle-request-path", path);
|
|
36
37
|
if (method) headers.set("x-tangle-request-method", method);
|
|
37
38
|
return rewrapResponse(response, headers, body);
|
|
38
39
|
}
|
|
40
|
+
/** The SDK's one timeout table, in ms (documented in api-request.d.mts). */
|
|
41
|
+
const SDK_TIMEOUTS = Object.freeze({
|
|
42
|
+
default: 3e4,
|
|
43
|
+
margin: 15e3,
|
|
44
|
+
create: 12e4,
|
|
45
|
+
gpuCreate: 9e5,
|
|
46
|
+
runCode: 6e4,
|
|
47
|
+
fleetDispatch: 6e5,
|
|
48
|
+
deleteMatching: 12e4,
|
|
49
|
+
deleteMatchingUntilRemoved: 3e5,
|
|
50
|
+
snapshot: 6e5,
|
|
51
|
+
workspaceImage: 99e4,
|
|
52
|
+
operationWait: 6e5,
|
|
53
|
+
previewReady: 12e4,
|
|
54
|
+
interactiveToken: 5e3,
|
|
55
|
+
terminalConnect: 15e3
|
|
56
|
+
});
|
|
39
57
|
/** RFC 9110 idempotent methods: applying one twice leaves what once did. */
|
|
40
58
|
const IDEMPOTENT_METHODS = new Set([
|
|
41
59
|
"GET",
|
|
@@ -51,10 +69,15 @@ function isReplayableBody(body) {
|
|
|
51
69
|
return !(Symbol.asyncIterator in body);
|
|
52
70
|
}
|
|
53
71
|
/** The wait before resending after `response` (none: connection lost) on the shared pacing, or undefined when it is final or cannot go before `deadline`. */
|
|
54
|
-
function retryDelayMs(response, attempt, deadline) {
|
|
72
|
+
async function retryDelayMs(response, attempt, deadline) {
|
|
55
73
|
const after = parseSandboxRetryAfterHeader(response?.headers.get("retry-after"));
|
|
56
74
|
const status = response?.status ?? 503;
|
|
57
75
|
if (!(status >= 502 && status <= 504 || status === 429 && after !== void 0)) return void 0;
|
|
76
|
+
if (response) {
|
|
77
|
+
const body = await response.clone().json().catch(() => null);
|
|
78
|
+
const code = body?.error?.code ?? body?.code;
|
|
79
|
+
if (typeof code === "string" && Object.hasOwn(ERROR_CATALOG, code) && !catalogEntry(code).retryable) return void 0;
|
|
80
|
+
}
|
|
58
81
|
return planResend(SANDBOX_API_RETRY_SCOPE, attempt, {
|
|
59
82
|
retryAfterMs: after,
|
|
60
83
|
deadlineAt: deadline,
|
|
@@ -63,7 +86,7 @@ function retryDelayMs(response, attempt, deadline) {
|
|
|
63
86
|
}
|
|
64
87
|
/** SDK/probe transport retries replayable idempotent/keyed calls, or any verb after a proven failed dial.
|
|
65
88
|
* x-no-retry forbids replay; the caller deadline bounds attempts, and headers finalize an answer. */
|
|
66
|
-
async function fetchSandboxApi({ baseUrl, apiKey, timeoutMs =
|
|
89
|
+
async function fetchSandboxApi({ baseUrl, apiKey, timeoutMs = SDK_TIMEOUTS.default, signal, fetchImpl = fetch, networkError = (error) => error, timeoutError = () => new DOMException("The operation was aborted due to timeout", "TimeoutError") }, path, options, fetchOptions) {
|
|
67
90
|
const url = `${baseUrl.replace(/\/+$/, "")}${path}`;
|
|
68
91
|
const requestTimeoutMs = typeof fetchOptions?.timeoutMs === "number" && fetchOptions.timeoutMs > 0 ? fetchOptions.timeoutMs : timeoutMs;
|
|
69
92
|
const deadline = Date.now() + requestTimeoutMs;
|
|
@@ -83,8 +106,10 @@ async function fetchSandboxApi({ baseUrl, apiKey, timeoutMs = 3e4, signal, fetch
|
|
|
83
106
|
};
|
|
84
107
|
try {
|
|
85
108
|
const headers = new Headers(options?.headers);
|
|
86
|
-
|
|
87
|
-
|
|
109
|
+
if (apiKey) {
|
|
110
|
+
headers.set("Authorization", `Bearer ${apiKey}`);
|
|
111
|
+
headers.set("x-sdk-version", SDK_VERSION);
|
|
112
|
+
}
|
|
88
113
|
const isFormDataBody = typeof FormData !== "undefined" && options?.body instanceof FormData;
|
|
89
114
|
if (!headers.has("Content-Type") && !isFormDataBody) headers.set("Content-Type", "application/json");
|
|
90
115
|
const method = (options?.method ?? "GET").toUpperCase();
|
|
@@ -106,7 +131,7 @@ async function fetchSandboxApi({ baseUrl, apiKey, timeoutMs = 3e4, signal, fetch
|
|
|
106
131
|
lost = error;
|
|
107
132
|
}
|
|
108
133
|
const undelivered = !response && isUndelivered(lost);
|
|
109
|
-
const delayMs = repeatable && (undelivered || safe) && attempt < 4 ? retryDelayMs(response, attempt, deadline) : void 0;
|
|
134
|
+
const delayMs = repeatable && (undelivered || safe) && attempt < 4 ? await retryDelayMs(response, attempt, deadline) : void 0;
|
|
110
135
|
if (delayMs === void 0) {
|
|
111
136
|
if (!response) throw lost;
|
|
112
137
|
break;
|
|
@@ -166,4 +191,4 @@ async function fetchSandboxApi({ baseUrl, apiKey, timeoutMs = 3e4, signal, fetch
|
|
|
166
191
|
}
|
|
167
192
|
}
|
|
168
193
|
//#endregion
|
|
169
|
-
export {
|
|
194
|
+
export { isReplayableBody as a, fetchSandboxApi as i, SDK_TIMEOUTS as n, rewrapResponse as o, SDK_VERSION as r, IDEMPOTENT_METHODS as t };
|
package/dist/auth/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { i as materializeCliAuthBundle, n as assertCliAuthReferenceSupported, r as cliAuthReferenceSchema, t as CliAuthReference } from "../cli-auth-bundle-
|
|
2
|
-
import { _ as ReadTokenPayload, a as issueCollaborationToken, c as issueSessionScopedToken, d as AnyTokenPayload, f as BatchScopedTokenPayload, g as ProjectScopedTokenPayload, h as IssueCollaborationTokenOptions, i as issueBatchScopedToken, l as unsafeDecodeToken, m as CollaborationTokenPayload, n as getTokenTTL, o as issueProjectScopedToken, p as CollaborationAccess, r as isTokenExpiringSoon, s as issueReadToken, t as ProductTokenIssuer, u as verifyToken, v as SessionScopedTokenPayload, y as TokenScope } from "../index-
|
|
1
|
+
import { i as materializeCliAuthBundle, n as assertCliAuthReferenceSupported, r as cliAuthReferenceSchema, t as CliAuthReference } from "../cli-auth-bundle-CjSu4D9W.js";
|
|
2
|
+
import { _ as ReadTokenPayload, a as issueCollaborationToken, c as issueSessionScopedToken, d as AnyTokenPayload, f as BatchScopedTokenPayload, g as ProjectScopedTokenPayload, h as IssueCollaborationTokenOptions, i as issueBatchScopedToken, l as unsafeDecodeToken, m as CollaborationTokenPayload, n as getTokenTTL, o as issueProjectScopedToken, p as CollaborationAccess, r as isTokenExpiringSoon, s as issueReadToken, t as ProductTokenIssuer, u as verifyToken, v as SessionScopedTokenPayload, y as TokenScope } from "../index-C-_HY5NY.js";
|
|
3
3
|
export { AnyTokenPayload, BatchScopedTokenPayload, CliAuthReference, CollaborationAccess, CollaborationTokenPayload, IssueCollaborationTokenOptions, ProductTokenIssuer, ProjectScopedTokenPayload, ReadTokenPayload, SessionScopedTokenPayload, TokenScope, assertCliAuthReferenceSupported, cliAuthReferenceSchema, getTokenTTL, isTokenExpiringSoon, issueBatchScopedToken, issueCollaborationToken, issueProjectScopedToken, issueReadToken, issueSessionScopedToken, materializeCliAuthBundle, unsafeDecodeToken, verifyToken };
|
package/dist/auth/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { i as materializeCliAuthBundle, n as assertCliAuthReferenceSupported, r as cliAuthReferenceSchema } from "../cli-auth-bundle-C6DtK7GX-
|
|
2
|
-
import "../cli-auth-bundle-
|
|
1
|
+
import { i as materializeCliAuthBundle, n as assertCliAuthReferenceSupported, r as cliAuthReferenceSchema } from "../cli-auth-bundle-C6DtK7GX-mBUPER0R.js";
|
|
2
|
+
import "../cli-auth-bundle-BLAtE6Dc.js";
|
|
3
3
|
//#region src/auth/tokens.ts
|
|
4
4
|
const textEncoder = new TextEncoder();
|
|
5
5
|
const textDecoder = new TextDecoder();
|