@tangle-network/sandbox 1.0.363 → 1.0.364
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/index.d.ts +4 -4
- package/dist/agent/index.js +4 -4
- package/dist/agent/preview.d.ts +1 -1
- package/dist/agent/preview.js +2 -2
- package/dist/{agent-execution-preparation-CatenlMs.js → agent-execution-preparation-BhQ48V9p.js} +3 -3
- package/dist/{agent-execution-preparation-receipt-BFGr2nAM.js → agent-execution-preparation-receipt-CtgxEFAM.js} +4 -4
- package/dist/{agent-run-outcome-BtjH6dyu.d.ts → agent-run-outcome-CknrV3ti.d.ts} +2 -2
- package/dist/{api-request-BsfC_osj.js → api-request-CkWYsj-R.js} +1 -1
- package/dist/auth/index.d.ts +1 -1
- package/dist/auth/index.js +2 -2
- package/dist/{browser-interactive-control-controller-45o0sl7B.d.ts → browser-interactive-control-controller-Bn-BjzfG.d.ts} +2 -2
- package/dist/{browser-interactive-control-controller-CDxMXDLF.js → browser-interactive-control-controller-DkGvy9Nv.js} +14 -14
- package/dist/cli-auth-bundle-BWjzJnzs.js +2 -0
- package/dist/{cli-auth-bundle-B4SGUcYM-B5SuPHb_.js → cli-auth-bundle-DD2Pk8DR-DJ060J_J.js} +96 -7
- package/dist/{cli-auth-bundle-DTAVpYLy.d.ts → cli-auth-bundle-YOchLsUH.d.ts} +1 -1
- package/dist/{client-D164Xl4l.d.ts → client-BJJ6SWxX.d.ts} +36 -6
- package/dist/{client-CyoN1mXb.js → client-CQzg0BDY.js} +6 -6
- package/dist/collaboration/index.js +1 -1
- package/dist/{collaboration-Dgt-k_KQ.js → collaboration-CWNLpWmU.js} +1 -1
- package/dist/core.d.ts +6 -6
- package/dist/core.js +3 -3
- package/dist/{file-download-CdYQq4-A.js → file-download-Di-P3rqM.js} +1 -1
- package/dist/gpu-lease/index.js +1 -1
- package/dist/{harness-DW2I_kp7.js → harness-D5WLFgHg.js} +6 -5
- package/dist/{index-Dxxq7J79.d.ts → index-M0we6p4e.d.ts} +22 -15
- package/dist/{index-DHtNG3FT.d.ts → index-TjL2jLDU.d.ts} +7 -7
- package/dist/index.d.ts +10 -10
- package/dist/index.js +10 -10
- package/dist/intelligence/index.js +2 -2
- package/dist/interactive-control.d.ts +1 -1
- package/dist/interactive-control.js +1 -1
- package/dist/{interactive-controller-Eb7GnX4u.d.ts → interactive-controller-CplK0quE.d.ts} +4 -4
- package/dist/{interactive-controller-kUR-DvYp.js → interactive-controller-kwJ_pT5-.js} +7 -6
- package/dist/{lines-CRgDflYa.d.ts → lines-Bm4goAoE.d.ts} +1 -1
- package/dist/lines.d.ts +1 -1
- package/dist/{local-cli-auth-CZBHxG9t.js → local-cli-auth-DrYGFcad.js} +1 -1
- package/dist/{mcp-local-CNvugl37.js → mcp-local-JlM6gWBR.js} +2 -2
- package/dist/{preview-CMvkk3F1.d.ts → preview-B53rn00t.d.ts} +3 -3
- package/dist/{profile-schema-C_MbI9mE.js → profile-schema-CpFXvaXd.js} +11 -11
- package/dist/{public-templates-D_Iihr73.d.ts → public-templates-CKTbZRM-.d.ts} +2 -2
- package/dist/public-templates.d.ts +1 -1
- package/dist/{raw-evidence-archive-DM5sTcFG.js → raw-evidence-archive-DYaA-RPM.js} +1 -1
- package/dist/runtime.d.ts +5 -5
- package/dist/runtime.js +3 -3
- package/dist/{sandbox-BImD2gYp.js → sandbox-BzIpECKU.js} +79 -1673
- package/dist/{select-seat-8g9DtFO5.js → select-seat-CzZkbxE8.js} +4 -4
- package/dist/select-seat-command.d.ts +2 -2
- package/dist/select-seat-command.js +1 -1
- package/dist/session-gateway/index.js +1 -1
- package/dist/tangle/index.d.ts +1 -1
- package/dist/tangle/index.js +1 -1
- package/dist/{tangle-D9XgxG4a.js → tangle-Sk9UFIpt.js} +2 -2
- package/dist/{terminal-stream-types-CygV-MYy.d.ts → terminal-stream-types-DhIlRpuF.d.ts} +28 -1
- package/dist/{types-9ZHVgluv.d.ts → types-DyYgdFKO.d.ts} +4 -3
- package/package.json +6 -6
- package/dist/cli-auth-bundle-vWBeEFSk.js +0 -2
- /package/dist/{sha2-BIoWepwn.js → sha2--74Uh_Sg.js} +0 -0
|
@@ -1,24 +1,23 @@
|
|
|
1
|
-
import { A as requestedPublicProfileDigest, C as runtimeFilesystemPath, D as assertCurrentBackendType, E as applyRequestedModel, F as createAgentRunOutcomeTracker, I as deriveAgentResultOutcome, O as mergeRuntimeBackendConfig, P as withoutRuntimeSecrets, S as encodeTextForWire,
|
|
2
|
-
import { C as boundedIdentifierSchema
|
|
3
|
-
import { a as ProxySecretReceiptSchema
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { t as canonicalAgentProfileDigest } from "./agent-execution-preparation-CatenlMs.js";
|
|
1
|
+
import { A as requestedPublicProfileDigest, B as AgentRuntimeAttachmentsSchema, C as runtimeFilesystemPath, D as assertCurrentBackendType, E as applyRequestedModel, F as createAgentRunOutcomeTracker, I as deriveAgentResultOutcome, O as mergeRuntimeBackendConfig, P as withoutRuntimeSecrets, S as encodeTextForWire, W as normalizeEffectiveBackend, _ as mintTraceId, a as assertScopedTokenActive, b as validateAcceptedDispatchRunRef, c as SandboxRuntimeApi, d as appendSessionIdQuery, f as callHeaders, g as isTraceId, h as TRACE_ID_HEADER, i as terminalUpgradeHeadersSupported, j as requestedSecretProfilePublicDigest, k as normalizeRuntimeBackendConfig, l as normalizeSessionInfo, m as assertFileWritePreconditions, n as InteractiveSessionController, p as sessionHeaders, r as TerminalStream, s as requestScopedToken, u as sessionMessageRequestBody, v as resolveTraceId, w as canUseNodeHttp2, x as encodePromptForWire, y as resolveDispatchRunIdentity } from "./interactive-controller-kwJ_pT5-.js";
|
|
2
|
+
import { C as boundedIdentifierSchema, E as boundedStringSchema, g as sha256DigestSchema, o as canonicalCandidateDigest, s as canonicalCandidateJson } from "./harness-D5WLFgHg.js";
|
|
3
|
+
import { a as ProxySecretReceiptSchema, r as agentProfileSchema } from "./profile-schema-CpFXvaXd.js";
|
|
4
|
+
import { A as agentInteractiveSessionStatusMatchesRef, B as PlanContinuationSchema, C as AgentInteractiveSessionStopAcknowledgementSchema, D as agentInteractiveSessionControlClaimMatchesRef, E as agentInteractiveSessionControlClaimIsNewer, F as AgentRunCancellationAcknowledgementSchema, G as InteractionResponseSchema, H as InteractionBindingSchema, I as AgentRunCancellationRequestSchema, L as agentRunCancellationAcknowledgementMatchesRequest, M as agentInteractiveDimensionSchema, N as sameAgentExactRun, O as agentInteractiveSessionPromptAcknowledgementMatchesCommand, P as AgentExactRunControlRefSchema, S as AgentInteractiveSessionStatusSchema, T as agentInteractiveSessionControlClaimAcknowledgementMatchesRequest, U as InteractionRequestSchema, V as InteractionAcknowledgementSchema, W as InteractionResponseCommandSchema, _ as AgentInteractiveSessionControlClaimRequestSchema, b as AgentInteractiveSessionPromptCommandSchema, d as interactiveSessionControlClaimResponseSchema, f as interactiveSessionControlReleaseResponseSchema, g as AgentInteractiveSessionControlClaimAcknowledgementSchema, h as AgentInteractiveSessionAttachSchema, j as agentInteractiveSessionStopAcknowledgementMatchesCommand, l as createInteractiveControlHolderId, m as interactiveSessionStatusResponseSchema, p as interactiveSessionControlValidationResponseSchema, v as AgentInteractiveSessionControlClaimSchema, w as AgentInteractiveSessionStopCommandSchema, x as AgentInteractiveSessionRefSchema, y as AgentInteractiveSessionPromptAcknowledgementSchema } from "./browser-interactive-control-controller-DkGvy9Nv.js";
|
|
5
|
+
import { t as canonicalAgentProfileDigest } from "./agent-execution-preparation-BhQ48V9p.js";
|
|
7
6
|
import { C as SandboxError, D as TimeoutError, E as StreamInterruptedError, O as ValidationError, T as StateError, _ as NetworkError, a as readResponseJson, b as ProfileFileMountPathError, c as AuthError, f as EdgeNotReadyError, i as parseResponseError, n as isTransientWrite, o as responseMetadata, r as parseErrorResponse, s as retryWhen, t as TerminalStreamError, u as CapabilityError, v as NotFoundError, w as ServerError, y as PartialFailureError } from "./errors-vuyhjefs.js";
|
|
8
7
|
import { t as parseSandboxRetryAfterHeader } from "./retry-after-header-BZbs5rig.js";
|
|
9
8
|
import { n as combineAbortSignals, t as awaitWithAbort } from "./abort-signal-BsriwJ8L.js";
|
|
10
9
|
import { a as backoffDelayMs, o as isUndelivered, r as abortableSleep } from "./retry-policy-oW3_ljoc.js";
|
|
11
|
-
import { a as isReplayableBody, i as fetchSandboxApi, n as SDK_TIMEOUTS, o as rewrapResponse, t as IDEMPOTENT_METHODS } from "./api-request-
|
|
10
|
+
import { a as isReplayableBody, i as fetchSandboxApi, n as SDK_TIMEOUTS, o as rewrapResponse, t as IDEMPOTENT_METHODS } from "./api-request-CkWYsj-R.js";
|
|
12
11
|
import { a as SANDBOX_PROXY_REQUEST_MAX_BYTES, c as PROFILE_FILE_MOUNT_OUTSIDE_ROOTS_CODE, d as isProfileFileMountOutsideRoots, f as profileFileMountOutsideRootsMessage, l as SANDBOX_AGENT_HOME, o as FILE_OPERATION_LIMITS, u as SANDBOX_FILE_API_ABSOLUTE_ROOTS } from "./file-transfer-DOSTbUSR.js";
|
|
13
12
|
import { c as awaitSdkResend, l as takeSdkTurn, s as uploadChunked } from "./chunked-upload-wSXiVX7I.js";
|
|
14
13
|
import { n as fetchWithKeepAlive, t as emitTiming } from "./keep-alive-fetch-sGVP8skk.js";
|
|
15
14
|
import { t as SIDECAR_PROXY_ERROR_HEADER } from "./sidecar-proxy-error-DTdbCbUM.js";
|
|
16
15
|
import { t as parseSSEStream } from "./sse-parser-BCG3iL9j.js";
|
|
17
16
|
import { t as runPreparedProcess } from "./prepared-process-DQ_68Ofg.js";
|
|
18
|
-
import { a as isBackendType, r as cliAuthReferenceSchema } from "./cli-auth-bundle-
|
|
19
|
-
import "./cli-auth-bundle-
|
|
17
|
+
import { a as isBackendType, r as cliAuthReferenceSchema } from "./cli-auth-bundle-DD2Pk8DR-DJ060J_J.js";
|
|
18
|
+
import "./cli-auth-bundle-BWjzJnzs.js";
|
|
20
19
|
import { n as SandboxLines } from "./lines-vZDk8YYb.js";
|
|
21
|
-
import { t as downloadFile } from "./file-download-
|
|
20
|
+
import { t as downloadFile } from "./file-download-Di-P3rqM.js";
|
|
22
21
|
import { z } from "zod";
|
|
23
22
|
import { createHash } from "node:crypto";
|
|
24
23
|
import { constants } from "node:fs";
|
|
@@ -28,12 +27,27 @@ import { PART_TEXT, PART_TEXT_SUFFIX, locatePart } from "@tangle-network/agent-c
|
|
|
28
27
|
import { readTokenUsage } from "@tangle-network/agent-core";
|
|
29
28
|
import "@tangle-network/agent-interface/environment-provider";
|
|
30
29
|
import { OTLP_SPAN_KIND, OTLP_STATUS_CODE, msToUnixNano, otlpTraceExport, toOtlpAttributes, toW3CSpanId, toW3CTraceId } from "@tangle-network/agent-trace-contract/otlp";
|
|
31
|
-
//#region ../../../node_modules/.pnpm/@tangle-network+agent-interface@5.10.
|
|
30
|
+
//#region ../../../node_modules/.pnpm/@tangle-network+agent-interface@5.10.22/node_modules/@tangle-network/agent-interface/dist/provider-config.js
|
|
31
|
+
const nativeWebSearchKeys = new Set(["websearch"]);
|
|
32
|
+
const nativeWebFetchKeys = new Set(["webfetch", "fetch"]);
|
|
33
|
+
function resolveNativeWebTools(tools) {
|
|
34
|
+
if (!tools) return {};
|
|
35
|
+
const posture = {};
|
|
36
|
+
for (const [key, value] of Object.entries(tools)) {
|
|
37
|
+
if (typeof value !== "boolean") continue;
|
|
38
|
+
const normalized = key.replace(/[^a-z0-9]/gi, "").toLowerCase();
|
|
39
|
+
if (nativeWebSearchKeys.has(normalized)) posture.search = value;
|
|
40
|
+
else if (nativeWebFetchKeys.has(normalized)) posture.fetch = value;
|
|
41
|
+
}
|
|
42
|
+
return posture;
|
|
43
|
+
}
|
|
44
|
+
//#endregion
|
|
45
|
+
//#region ../../../node_modules/.pnpm/@tangle-network+agent-interface@5.10.22/node_modules/@tangle-network/agent-interface/dist/environment-interactive-start.js
|
|
32
46
|
const AgentInteractiveSessionRunCoordinatesSchema = z.strictObject({
|
|
33
|
-
provider: boundedIdentifierSchema
|
|
34
|
-
environmentId: boundedIdentifierSchema
|
|
35
|
-
sessionId: boundedIdentifierSchema
|
|
36
|
-
executionId: boundedIdentifierSchema
|
|
47
|
+
provider: boundedIdentifierSchema,
|
|
48
|
+
environmentId: boundedIdentifierSchema,
|
|
49
|
+
sessionId: boundedIdentifierSchema,
|
|
50
|
+
executionId: boundedIdentifierSchema
|
|
37
51
|
});
|
|
38
52
|
/**
|
|
39
53
|
* Start one native coding-agent TUI from caller-owned request material.
|
|
@@ -44,11 +58,11 @@ const AgentInteractiveSessionRunCoordinatesSchema = z.strictObject({
|
|
|
44
58
|
*/
|
|
45
59
|
const AgentInteractiveSessionStartSchema = z.strictObject({
|
|
46
60
|
run: AgentExactRunControlRefSchema,
|
|
47
|
-
profile: agentProfileSchema
|
|
48
|
-
requestedProfileDigest: sha256DigestSchema
|
|
61
|
+
profile: agentProfileSchema,
|
|
62
|
+
requestedProfileDigest: sha256DigestSchema,
|
|
49
63
|
authMode: z.literal("oauth").optional(),
|
|
50
|
-
initialPrompt: boundedStringSchema
|
|
51
|
-
cwd: boundedStringSchema
|
|
64
|
+
initialPrompt: boundedStringSchema.optional(),
|
|
65
|
+
cwd: boundedStringSchema.min(1).optional(),
|
|
52
66
|
cols: agentInteractiveDimensionSchema.optional(),
|
|
53
67
|
rows: agentInteractiveDimensionSchema.optional()
|
|
54
68
|
});
|
|
@@ -56,7 +70,7 @@ const AgentInteractiveSessionStartSchema = z.strictObject({
|
|
|
56
70
|
function agentInteractiveSessionRequestDigest(coordinates, input) {
|
|
57
71
|
const exactCoordinates = AgentInteractiveSessionRunCoordinatesSchema.parse(coordinates);
|
|
58
72
|
const exactInput = AgentInteractiveSessionStartSchema.omit({ run: true }).parse(input);
|
|
59
|
-
return canonicalCandidateDigest
|
|
73
|
+
return canonicalCandidateDigest({
|
|
60
74
|
kind: "agent-interactive-session-start.v1",
|
|
61
75
|
run: exactCoordinates,
|
|
62
76
|
requestedProfileDigest: exactInput.requestedProfileDigest,
|
|
@@ -105,7 +119,7 @@ function runCoordinates(run) {
|
|
|
105
119
|
};
|
|
106
120
|
}
|
|
107
121
|
//#endregion
|
|
108
|
-
//#region ../../../node_modules/.pnpm/@tangle-network+agent-interface@5.10.
|
|
122
|
+
//#region ../../../node_modules/.pnpm/@tangle-network+agent-interface@5.10.22/node_modules/@tangle-network/agent-interface/dist/environment-terminal.js
|
|
109
123
|
const terminalDimensionSchema = z.number().int().positive().max(1e4);
|
|
110
124
|
/**
|
|
111
125
|
* Provider-neutral handle for one interactive terminal.
|
|
@@ -116,39 +130,39 @@ const terminalDimensionSchema = z.number().int().positive().max(1e4);
|
|
|
116
130
|
* or an expired terminal fails closed at the call sites that read it.
|
|
117
131
|
*/
|
|
118
132
|
const TerminalSessionRefSchema = z.strictObject({
|
|
119
|
-
terminalSessionId: boundedIdentifierSchema
|
|
120
|
-
parentExecutionId: boundedIdentifierSchema
|
|
121
|
-
name: boundedIdentifierSchema
|
|
122
|
-
shell: boundedStringSchema
|
|
123
|
-
command: boundedStringSchema
|
|
124
|
-
cwd: boundedStringSchema
|
|
133
|
+
terminalSessionId: boundedIdentifierSchema,
|
|
134
|
+
parentExecutionId: boundedIdentifierSchema,
|
|
135
|
+
name: boundedIdentifierSchema,
|
|
136
|
+
shell: boundedStringSchema.min(1),
|
|
137
|
+
command: boundedStringSchema.optional(),
|
|
138
|
+
cwd: boundedStringSchema.min(1),
|
|
125
139
|
cols: terminalDimensionSchema,
|
|
126
140
|
rows: terminalDimensionSchema,
|
|
127
|
-
connectionId: boundedIdentifierSchema
|
|
141
|
+
connectionId: boundedIdentifierSchema.optional(),
|
|
128
142
|
createdAt: z.iso.datetime().max(64),
|
|
129
143
|
lastActivityAt: z.iso.datetime().max(64),
|
|
130
144
|
expiresAt: z.iso.datetime().max(64),
|
|
131
145
|
isRunning: z.boolean(),
|
|
132
146
|
exitCode: z.number().int().optional(),
|
|
133
|
-
exitSignal: boundedIdentifierSchema
|
|
147
|
+
exitSignal: boundedIdentifierSchema.optional(),
|
|
134
148
|
attachCount: z.number().int().nonnegative()
|
|
135
149
|
});
|
|
136
150
|
/** Raw bytes written to the terminal, normalized to UTF-8 text. */
|
|
137
|
-
const TerminalInputSchema = z.strictObject({ data: boundedStringSchema
|
|
151
|
+
const TerminalInputSchema = z.strictObject({ data: boundedStringSchema });
|
|
138
152
|
/** New terminal geometry. */
|
|
139
153
|
const TerminalResizeSchema = z.strictObject({
|
|
140
154
|
cols: terminalDimensionSchema,
|
|
141
155
|
rows: terminalDimensionSchema
|
|
142
156
|
});
|
|
143
157
|
z.strictObject({
|
|
144
|
-
parentExecutionId: boundedIdentifierSchema
|
|
145
|
-
terminalSessionId: boundedIdentifierSchema
|
|
146
|
-
connectionId: boundedIdentifierSchema
|
|
158
|
+
parentExecutionId: boundedIdentifierSchema,
|
|
159
|
+
terminalSessionId: boundedIdentifierSchema.optional(),
|
|
160
|
+
connectionId: boundedIdentifierSchema.optional(),
|
|
147
161
|
mode: z.enum(["attach", "logical"]),
|
|
148
162
|
cols: terminalDimensionSchema.optional(),
|
|
149
163
|
rows: terminalDimensionSchema.optional(),
|
|
150
|
-
command: boundedStringSchema
|
|
151
|
-
cwd: boundedStringSchema
|
|
164
|
+
command: boundedStringSchema.optional(),
|
|
165
|
+
cwd: boundedStringSchema.optional()
|
|
152
166
|
});
|
|
153
167
|
z.discriminatedUnion("status", [
|
|
154
168
|
z.strictObject({
|
|
@@ -159,11 +173,11 @@ z.discriminatedUnion("status", [
|
|
|
159
173
|
}),
|
|
160
174
|
z.strictObject({
|
|
161
175
|
status: z.literal("unavailable"),
|
|
162
|
-
reason: boundedStringSchema
|
|
176
|
+
reason: boundedStringSchema.min(1)
|
|
163
177
|
}),
|
|
164
178
|
z.strictObject({
|
|
165
179
|
status: z.literal("unknown"),
|
|
166
|
-
message: boundedStringSchema
|
|
180
|
+
message: boundedStringSchema.min(1),
|
|
167
181
|
retryable: z.boolean()
|
|
168
182
|
})
|
|
169
183
|
]);
|
|
@@ -181,7 +195,7 @@ const TerminalOutputEventSchema = z.discriminatedUnion("type", [
|
|
|
181
195
|
z.strictObject({
|
|
182
196
|
type: z.literal("output"),
|
|
183
197
|
seq: z.number().int().nonnegative(),
|
|
184
|
-
data: boundedStringSchema
|
|
198
|
+
data: boundedStringSchema
|
|
185
199
|
}),
|
|
186
200
|
z.strictObject({
|
|
187
201
|
type: z.literal("resize"),
|
|
@@ -191,29 +205,29 @@ const TerminalOutputEventSchema = z.discriminatedUnion("type", [
|
|
|
191
205
|
z.strictObject({
|
|
192
206
|
type: z.literal("exit"),
|
|
193
207
|
exitCode: z.number().int().optional(),
|
|
194
|
-
exitSignal: boundedIdentifierSchema
|
|
208
|
+
exitSignal: boundedIdentifierSchema.optional()
|
|
195
209
|
}),
|
|
196
210
|
z.strictObject({
|
|
197
211
|
type: z.literal("error"),
|
|
198
|
-
message: boundedStringSchema
|
|
212
|
+
message: boundedStringSchema.min(1)
|
|
199
213
|
})
|
|
200
214
|
]);
|
|
201
215
|
z.discriminatedUnion("status", [
|
|
202
216
|
z.strictObject({
|
|
203
217
|
status: z.literal("detached"),
|
|
204
|
-
terminalSessionId: boundedIdentifierSchema
|
|
205
|
-
connectionId: boundedIdentifierSchema
|
|
218
|
+
terminalSessionId: boundedIdentifierSchema,
|
|
219
|
+
connectionId: boundedIdentifierSchema.optional()
|
|
206
220
|
}),
|
|
207
221
|
z.strictObject({
|
|
208
222
|
status: z.literal("closed"),
|
|
209
|
-
terminalSessionId: boundedIdentifierSchema
|
|
223
|
+
terminalSessionId: boundedIdentifierSchema,
|
|
210
224
|
exitCode: z.number().int().optional(),
|
|
211
|
-
exitSignal: boundedIdentifierSchema
|
|
225
|
+
exitSignal: boundedIdentifierSchema.optional()
|
|
212
226
|
}),
|
|
213
227
|
z.strictObject({
|
|
214
228
|
status: z.literal("unknown"),
|
|
215
|
-
terminalSessionId: boundedIdentifierSchema
|
|
216
|
-
message: boundedStringSchema
|
|
229
|
+
terminalSessionId: boundedIdentifierSchema,
|
|
230
|
+
message: boundedStringSchema.min(1),
|
|
217
231
|
retryable: z.boolean()
|
|
218
232
|
})
|
|
219
233
|
]);
|
|
@@ -420,7 +434,7 @@ function normalizeEgressPolicyFields(data) {
|
|
|
420
434
|
/** Shape and resource identity are required before exposing current credential metadata. */
|
|
421
435
|
function normalizeProxySecretReceipt(raw, sandboxId) {
|
|
422
436
|
if (raw === void 0) return void 0;
|
|
423
|
-
const receipt = ProxySecretReceiptSchema
|
|
437
|
+
const receipt = ProxySecretReceiptSchema.parse(raw);
|
|
424
438
|
if (receipt.sandboxId !== sandboxId) throw new ServerError("Proxy secret receipt names another sandbox", { status: 502 });
|
|
425
439
|
return receipt;
|
|
426
440
|
}
|
|
@@ -444,7 +458,7 @@ const PROFILE_IMPORT_PART_BYTES = 512 * 1024;
|
|
|
444
458
|
const MANAGED_PROFILE_TRANSPORT = "managed-profile-reference-v1";
|
|
445
459
|
/** Cache identity follows JSON wire semantics and RFC 8785 key ordering. */
|
|
446
460
|
function profileCacheSha256(profile) {
|
|
447
|
-
return canonicalCandidateDigest
|
|
461
|
+
return canonicalCandidateDigest(JSON.parse(JSON.stringify(profile))).slice(7);
|
|
448
462
|
}
|
|
449
463
|
//#endregion
|
|
450
464
|
//#region ../../../packages/runtime-contracts/dist/direct-read.js
|
|
@@ -719,7 +733,7 @@ async function responseNeedsProfileImport(response) {
|
|
|
719
733
|
}
|
|
720
734
|
/** Upload the public profile only. Runtime grants remain in the turn backend. */
|
|
721
735
|
async function primeManagedProfile(profile, fetchRuntime) {
|
|
722
|
-
const bytes = new TextEncoder().encode(canonicalCandidateJson
|
|
736
|
+
const bytes = new TextEncoder().encode(canonicalCandidateJson(profile));
|
|
723
737
|
const sha256 = profileCacheSha256(profile);
|
|
724
738
|
if (bytes.length > 8388608) throw new ValidationError("Managed profile exceeds the profile import bound");
|
|
725
739
|
const post = async (body) => {
|
|
@@ -3245,1614 +3259,6 @@ var SandboxOperation = class SandboxOperation {
|
|
|
3245
3259
|
}
|
|
3246
3260
|
};
|
|
3247
3261
|
//#endregion
|
|
3248
|
-
//#region ../../../node_modules/.pnpm/@tangle-network+agent-interface@5.10.11/node_modules/@tangle-network/agent-interface/dist/provider-config.js
|
|
3249
|
-
const nativeWebSearchKeys = new Set(["websearch"]);
|
|
3250
|
-
const nativeWebFetchKeys = new Set(["webfetch", "fetch"]);
|
|
3251
|
-
function resolveNativeWebTools(tools) {
|
|
3252
|
-
if (!tools) return {};
|
|
3253
|
-
const posture = {};
|
|
3254
|
-
for (const [key, value] of Object.entries(tools)) {
|
|
3255
|
-
if (typeof value !== "boolean") continue;
|
|
3256
|
-
const normalized = key.replace(/[^a-z0-9]/gi, "").toLowerCase();
|
|
3257
|
-
if (nativeWebSearchKeys.has(normalized)) posture.search = value;
|
|
3258
|
-
else if (nativeWebFetchKeys.has(normalized)) posture.fetch = value;
|
|
3259
|
-
}
|
|
3260
|
-
return posture;
|
|
3261
|
-
}
|
|
3262
|
-
//#endregion
|
|
3263
|
-
//#region ../../../node_modules/.pnpm/@tangle-network+agent-interface@5.10.11/node_modules/@tangle-network/agent-interface/dist/contract-limits.js
|
|
3264
|
-
/** Limits applied before a value is hashed, copied, or sent to a provider. */
|
|
3265
|
-
const CONTRACT_MAX_STRING_LENGTH = 16384;
|
|
3266
|
-
/** Maximum length of one canonical confidential-attestation quote. */
|
|
3267
|
-
const CONTRACT_MAX_CONFIDENTIAL_ATTESTATION_QUOTE_LENGTH = 32768;
|
|
3268
|
-
const CONTRACT_MAX_ARRAY_LENGTH = 1024;
|
|
3269
|
-
const CONTRACT_MAX_JSON_NODES = 8192;
|
|
3270
|
-
const boundedStringSchema = z.string().max(CONTRACT_MAX_STRING_LENGTH);
|
|
3271
|
-
z.string().max(CONTRACT_MAX_CONFIDENTIAL_ATTESTATION_QUOTE_LENGTH);
|
|
3272
|
-
const boundedIdentifierSchema = boundedStringSchema.min(1).max(512).refine((value) => value.trim() === value, "identifier cannot have outer whitespace");
|
|
3273
|
-
/** Admit ordinary JSON before recursive parsing, copying or hashing. */
|
|
3274
|
-
function isBoundedJsonValue(value) {
|
|
3275
|
-
return boundedJson(value);
|
|
3276
|
-
}
|
|
3277
|
-
/** Exact serialized JSON UTF-8 byte count for one string scalar. */
|
|
3278
|
-
function serializedJsonStringBytes(value) {
|
|
3279
|
-
let bytes = 2;
|
|
3280
|
-
for (let index = 0; index < value.length; index += 1) {
|
|
3281
|
-
const code = value.charCodeAt(index);
|
|
3282
|
-
if (code === 34 || code === 92 || code === 8 || code === 12 || code === 10 || code === 13 || code === 9) bytes += 2;
|
|
3283
|
-
else if (code < 32) bytes += 6;
|
|
3284
|
-
else if (code >= 55296 && code <= 56319 && index + 1 < value.length) {
|
|
3285
|
-
const next = value.charCodeAt(index + 1);
|
|
3286
|
-
if (next >= 56320 && next <= 57343) {
|
|
3287
|
-
bytes += 4;
|
|
3288
|
-
index += 1;
|
|
3289
|
-
} else bytes += 6;
|
|
3290
|
-
} else if (code >= 55296 && code <= 57343) bytes += 6;
|
|
3291
|
-
else if (code < 128) bytes += 1;
|
|
3292
|
-
else if (code < 2048) bytes += 2;
|
|
3293
|
-
else bytes += 3;
|
|
3294
|
-
if (bytes > 1048576) return bytes;
|
|
3295
|
-
}
|
|
3296
|
-
return bytes;
|
|
3297
|
-
}
|
|
3298
|
-
/** Event content permits large strings within the exact serialized UTF-8 budget. */
|
|
3299
|
-
function isBoundedEventContentJson(value, { omitUndefinedObjectFields = false } = {}) {
|
|
3300
|
-
return boundedJson(value, {
|
|
3301
|
-
content: true,
|
|
3302
|
-
omitUndefinedObjectFields
|
|
3303
|
-
});
|
|
3304
|
-
}
|
|
3305
|
-
/**
|
|
3306
|
-
* Digest material omits undefined object fields; portable profile values require data properties.
|
|
3307
|
-
* `content` bounds strings by the serialized UTF-8 budget instead of each string's length, for
|
|
3308
|
-
* opaque values that may legitimately copy unbounded typed fields such as inline file content.
|
|
3309
|
-
*/
|
|
3310
|
-
function isBoundedJsonMaterial(value, { dataPropertiesOnly = false, content = false } = {}) {
|
|
3311
|
-
return boundedJson(value, {
|
|
3312
|
-
material: true,
|
|
3313
|
-
omitUndefinedObjectFields: true,
|
|
3314
|
-
dataPropertiesOnly,
|
|
3315
|
-
content
|
|
3316
|
-
});
|
|
3317
|
-
}
|
|
3318
|
-
/** One iterative walker owns structural admission; typed domains keep their own schema limits. */
|
|
3319
|
-
function boundedJson(value, options = {}) {
|
|
3320
|
-
const pending = [{
|
|
3321
|
-
value,
|
|
3322
|
-
depth: 0
|
|
3323
|
-
}];
|
|
3324
|
-
const ancestors = /* @__PURE__ */ new Set();
|
|
3325
|
-
let nodes = 0;
|
|
3326
|
-
let bytes = 0;
|
|
3327
|
-
const addBytes = (count) => !options.content || (bytes += count) <= 1048576;
|
|
3328
|
-
while (pending.length) {
|
|
3329
|
-
const item = pending.pop();
|
|
3330
|
-
const current = item.value;
|
|
3331
|
-
if ((!item.leave || !options.material) && ++nodes > 8192) return false;
|
|
3332
|
-
if (current === void 0 && item.omitUndefined) continue;
|
|
3333
|
-
if (item.leave) {
|
|
3334
|
-
ancestors.delete(current);
|
|
3335
|
-
continue;
|
|
3336
|
-
}
|
|
3337
|
-
if (current === null || typeof current === "boolean") {
|
|
3338
|
-
if (!addBytes(current === null ? 4 : current ? 4 : 5)) return false;
|
|
3339
|
-
continue;
|
|
3340
|
-
}
|
|
3341
|
-
if (typeof current === "string") {
|
|
3342
|
-
if (options.content ? !addBytes(serializedJsonStringBytes(current)) : current.length > 16384) return false;
|
|
3343
|
-
continue;
|
|
3344
|
-
}
|
|
3345
|
-
if (typeof current === "number") {
|
|
3346
|
-
if (!Number.isFinite(current) || !addBytes(JSON.stringify(current).length)) return false;
|
|
3347
|
-
continue;
|
|
3348
|
-
}
|
|
3349
|
-
if (typeof current !== "object" || item.depth >= 16 || ancestors.has(current)) return false;
|
|
3350
|
-
ancestors.add(current);
|
|
3351
|
-
pending.push({
|
|
3352
|
-
value: current,
|
|
3353
|
-
depth: item.depth,
|
|
3354
|
-
leave: true
|
|
3355
|
-
});
|
|
3356
|
-
const array = Array.isArray(current);
|
|
3357
|
-
if (array && current.length > 1024) return false;
|
|
3358
|
-
const prototype = Object.getPrototypeOf(current);
|
|
3359
|
-
if (!array && prototype !== Object.prototype && prototype !== null || array && options.content && prototype !== Array.prototype && prototype !== null) return false;
|
|
3360
|
-
if (options.content || options.dataPropertiesOnly) {
|
|
3361
|
-
const keys = Reflect.ownKeys(current).filter((key) => !array || key !== "length");
|
|
3362
|
-
if (array ? keys.length !== current.length : keys.length > 256) return false;
|
|
3363
|
-
let entries = 0;
|
|
3364
|
-
for (const key of keys) {
|
|
3365
|
-
if (typeof key !== "string" || !array && key.length > 512) return false;
|
|
3366
|
-
if (array && (!/^(?:0|[1-9][0-9]*)$/u.test(key) || Number(key) >= current.length || Number(key) >= 4294967295)) return false;
|
|
3367
|
-
const descriptor = Object.getOwnPropertyDescriptor(current, key);
|
|
3368
|
-
if (!descriptor?.enumerable || !("value" in descriptor)) return false;
|
|
3369
|
-
if (!array && descriptor.value === void 0 && options.omitUndefinedObjectFields) {
|
|
3370
|
-
if (++nodes > 8192) return false;
|
|
3371
|
-
continue;
|
|
3372
|
-
}
|
|
3373
|
-
if (++entries > (array ? 1024 : 256)) return false;
|
|
3374
|
-
if (!array && !addBytes(serializedJsonStringBytes(key) + 1)) return false;
|
|
3375
|
-
pending.push({
|
|
3376
|
-
value: descriptor.value,
|
|
3377
|
-
depth: item.depth + 1
|
|
3378
|
-
});
|
|
3379
|
-
}
|
|
3380
|
-
if (!addBytes(2 + Math.max(entries - 1, 0))) return false;
|
|
3381
|
-
} else if (array) for (const entry of current) pending.push({
|
|
3382
|
-
value: entry,
|
|
3383
|
-
depth: item.depth + 1
|
|
3384
|
-
});
|
|
3385
|
-
else {
|
|
3386
|
-
const keys = Object.keys(current);
|
|
3387
|
-
if (keys.length > 256) return false;
|
|
3388
|
-
for (const key of keys) {
|
|
3389
|
-
if (key.length > 512) return false;
|
|
3390
|
-
pending.push({
|
|
3391
|
-
value: current[key],
|
|
3392
|
-
depth: item.depth + 1,
|
|
3393
|
-
omitUndefined: options.omitUndefinedObjectFields
|
|
3394
|
-
});
|
|
3395
|
-
}
|
|
3396
|
-
}
|
|
3397
|
-
}
|
|
3398
|
-
return true;
|
|
3399
|
-
}
|
|
3400
|
-
const boundedJsonSchema = z.custom(isBoundedJsonValue, { message: "value exceeds the contract bounds or is not finite JSON" });
|
|
3401
|
-
z.custom((value) => typeof value === "object" && value !== null && !Array.isArray(value) && isBoundedJsonValue(value), { message: "metadata exceeds the contract bounds or is not a JSON object" });
|
|
3402
|
-
z.custom(isBoundedEventContentJson, { message: "event content exceeds its serialized byte bound or is not finite JSON" });
|
|
3403
|
-
z.custom((value) => typeof value === "object" && value !== null && !Array.isArray(value) && isBoundedEventContentJson(value), { message: "event content exceeds its serialized byte bound or is not a JSON object" });
|
|
3404
|
-
z.custom((value) => typeof value === "string" && isBoundedEventContentJson(value), { message: "event content exceeds its serialized byte bound or is not a string" });
|
|
3405
|
-
//#endregion
|
|
3406
|
-
//#region ../../../node_modules/.pnpm/@tangle-network+agent-interface@5.10.11/node_modules/@tangle-network/agent-interface/dist/agent-candidate-schema-common.js
|
|
3407
|
-
const sha256Pattern = /^sha256:[a-f0-9]{64}$/;
|
|
3408
|
-
const gitObjectPattern = /^(?:[a-f0-9]{40}|[a-f0-9]{64})$/;
|
|
3409
|
-
const environmentNamePattern = /^[A-Za-z_][A-Za-z0-9_]*$/;
|
|
3410
|
-
const headerNamePattern = /^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/;
|
|
3411
|
-
const mediaTypePattern = /^[a-z0-9][a-z0-9!#$&^_.+-]{0,126}\/[a-z0-9][a-z0-9!#$&^_.+-]{0,126}$/;
|
|
3412
|
-
const githubComponentPattern = /^[A-Za-z0-9][A-Za-z0-9_.-]{0,99}$/;
|
|
3413
|
-
const secretNamePattern = /(?:^|[_-])(?:api[_-]?key|access[_-]?key|private[_-]?key|token|secret|password|credentials?|authorization|cookie|database[_-]?url|dsn|pat)(?:[_-]|$)/i;
|
|
3414
|
-
const obviousSecretValuePattern = /(?:\bsk[-_][-_A-Za-z0-9]{10,}\b|\bgh[pousr]_[A-Za-z0-9]{12,}\b|\bgithub_pat_[A-Za-z0-9_]{12,}\b|\bAKIA[A-Z0-9]{12,}\b|-----BEGIN [A-Z ]*PRIVATE KEY-----|\bBearer\s+\S+)/;
|
|
3415
|
-
const controlCharacterPattern$1 = /[\u0000-\u001f\u007f]/;
|
|
3416
|
-
const reservedWorkspaceRoots = new Set([".git", ".sidecar"]);
|
|
3417
|
-
const shellNames = new Set([
|
|
3418
|
-
"sh",
|
|
3419
|
-
"bash",
|
|
3420
|
-
"zsh",
|
|
3421
|
-
"fish",
|
|
3422
|
-
"cmd",
|
|
3423
|
-
"cmd.exe",
|
|
3424
|
-
"powershell",
|
|
3425
|
-
"pwsh"
|
|
3426
|
-
]);
|
|
3427
|
-
const sha256DigestSchema = z.string().regex(sha256Pattern);
|
|
3428
|
-
z.string().regex(gitObjectPattern);
|
|
3429
|
-
const environmentNameSchema = z.string().regex(environmentNamePattern);
|
|
3430
|
-
const headerNameSchema = z.string().regex(headerNamePattern);
|
|
3431
|
-
z.string().regex(mediaTypePattern);
|
|
3432
|
-
function sha256Bytes(value) {
|
|
3433
|
-
const bytes = sha256$1(value);
|
|
3434
|
-
return `sha256:${Array.from(bytes, (byte) => byte.toString(16).padStart(2, "0")).join("")}`;
|
|
3435
|
-
}
|
|
3436
|
-
/** RFC 8785 serialization used by every candidate-producing package. */
|
|
3437
|
-
function canonicalCandidateJson(value) {
|
|
3438
|
-
if (!isCanonicalJsonValue(value)) throw new Error("candidate document must be finite, acyclic RFC 8785 JSON");
|
|
3439
|
-
return serializeCanonicalCandidate(value);
|
|
3440
|
-
}
|
|
3441
|
-
function canonicalCandidateBytes(value) {
|
|
3442
|
-
return new TextEncoder().encode(canonicalCandidateJson(value));
|
|
3443
|
-
}
|
|
3444
|
-
function canonicalCandidateDigest(value) {
|
|
3445
|
-
return sha256Bytes(canonicalCandidateBytes(value));
|
|
3446
|
-
}
|
|
3447
|
-
function serializeCanonicalCandidate(value) {
|
|
3448
|
-
if (value === null || typeof value === "boolean" || typeof value === "number") return JSON.stringify(value);
|
|
3449
|
-
if (typeof value === "string") return JSON.stringify(value);
|
|
3450
|
-
if (Array.isArray(value)) return `[${value.map(serializeCanonicalCandidate).join(",")}]`;
|
|
3451
|
-
return `{${Object.keys(value).sort().map((key) => `${JSON.stringify(key)}:${serializeCanonicalCandidate(value[key])}`).join(",")}}`;
|
|
3452
|
-
}
|
|
3453
|
-
function isWellFormedUnicode(value) {
|
|
3454
|
-
for (let index = 0; index < value.length; index++) {
|
|
3455
|
-
const code = value.charCodeAt(index);
|
|
3456
|
-
if (code >= 55296 && code <= 56319) {
|
|
3457
|
-
const next = value.charCodeAt(index + 1);
|
|
3458
|
-
if (!(next >= 56320 && next <= 57343)) return false;
|
|
3459
|
-
index++;
|
|
3460
|
-
} else if (code >= 56320 && code <= 57343) return false;
|
|
3461
|
-
}
|
|
3462
|
-
return true;
|
|
3463
|
-
}
|
|
3464
|
-
/** Return shared boundary violations for path strings. */
|
|
3465
|
-
function pathSafetyIssues(value) {
|
|
3466
|
-
const issues = [];
|
|
3467
|
-
if (controlCharacterPattern$1.test(value)) issues.push("control-character");
|
|
3468
|
-
if (!isWellFormedUnicode(value)) issues.push("malformed-unicode");
|
|
3469
|
-
return issues;
|
|
3470
|
-
}
|
|
3471
|
-
/** Return shared boundary violations for paths that must stay inside a workspace. */
|
|
3472
|
-
function relativePathSafetyIssues(value) {
|
|
3473
|
-
const issues = [...pathSafetyIssues(value)];
|
|
3474
|
-
if (value.length === 0) issues.push("empty");
|
|
3475
|
-
if (value.startsWith("/") || /^[A-Za-z]:/.test(value)) issues.push("absolute");
|
|
3476
|
-
if (value.includes("\\")) issues.push("backslash");
|
|
3477
|
-
if (value.split("/").includes("..")) issues.push("parent-traversal");
|
|
3478
|
-
return issues;
|
|
3479
|
-
}
|
|
3480
|
-
function isSafeRelativePath(value, allowDot) {
|
|
3481
|
-
if (relativePathSafetyIssues(value).length > 0) return false;
|
|
3482
|
-
if (value === ".") return allowDot;
|
|
3483
|
-
const parts = value.split("/");
|
|
3484
|
-
return parts.every((part) => part.length > 0 && part !== ".") && !parts.some((part) => reservedWorkspaceRoots.has(part));
|
|
3485
|
-
}
|
|
3486
|
-
function isSafeExecutable(value) {
|
|
3487
|
-
if (value.length === 0 || controlCharacterPattern$1.test(value) || !isWellFormedUnicode(value) || /\s/.test(value) || value.includes("\\") || !/^[A-Za-z0-9._+/-]+$/.test(value)) return false;
|
|
3488
|
-
const parts = value.split("/");
|
|
3489
|
-
if (value.startsWith("/")) parts.shift();
|
|
3490
|
-
if (parts.length === 0 || parts.some((part) => part.length === 0 || part === "." || part === "..")) return false;
|
|
3491
|
-
return !shellNames.has(parts.at(-1)?.toLowerCase() ?? "");
|
|
3492
|
-
}
|
|
3493
|
-
function isCanonicalJsonValue(value, ancestors = /* @__PURE__ */ new Set()) {
|
|
3494
|
-
if (value === null || typeof value === "boolean") return true;
|
|
3495
|
-
if (typeof value === "string") return isWellFormedUnicode(value);
|
|
3496
|
-
if (typeof value === "number") return Number.isFinite(value);
|
|
3497
|
-
if (typeof value !== "object" || ancestors.has(value)) return false;
|
|
3498
|
-
const prototype = Object.getPrototypeOf(value);
|
|
3499
|
-
if (!Array.isArray(value) && prototype !== Object.prototype && prototype !== null) return false;
|
|
3500
|
-
const nextAncestors = new Set(ancestors).add(value);
|
|
3501
|
-
if (Array.isArray(value)) {
|
|
3502
|
-
for (let index = 0; index < value.length; index += 1) {
|
|
3503
|
-
if (!(index in value)) return false;
|
|
3504
|
-
if (!isCanonicalJsonValue(value[index], nextAncestors)) return false;
|
|
3505
|
-
}
|
|
3506
|
-
return true;
|
|
3507
|
-
}
|
|
3508
|
-
return Object.entries(value).every(([key, entry]) => isWellFormedUnicode(key) && isCanonicalJsonValue(entry, nextAncestors));
|
|
3509
|
-
}
|
|
3510
|
-
function hasCredentialBearingUrl(value) {
|
|
3511
|
-
try {
|
|
3512
|
-
const url = new URL(value);
|
|
3513
|
-
if (url.username !== "" || url.password !== "") return true;
|
|
3514
|
-
return [...url.searchParams.keys()].some((key) => secretNamePattern.test(key));
|
|
3515
|
-
} catch {
|
|
3516
|
-
return false;
|
|
3517
|
-
}
|
|
3518
|
-
}
|
|
3519
|
-
/**
|
|
3520
|
-
* Whether a string holds an obvious credential: a provider key (`sk-`, `gh*_`,
|
|
3521
|
-
* `github_pat_`, `AKIA`), a PEM private key, a bearer token, or a URL with
|
|
3522
|
-
* userinfo or a credential-named query parameter. The agent-eval redaction
|
|
3523
|
-
* core calls it, so candidate validation and trace redaction agree.
|
|
3524
|
-
*/
|
|
3525
|
-
function looksLikeCredential(value) {
|
|
3526
|
-
return obviousSecretValuePattern.test(value) || hasCredentialBearingUrl(value);
|
|
3527
|
-
}
|
|
3528
|
-
function isPublicConfigValue(value) {
|
|
3529
|
-
return !controlCharacterPattern$1.test(value) && isWellFormedUnicode(value) && !looksLikeCredential(value);
|
|
3530
|
-
}
|
|
3531
|
-
/** Shared public reference owner; resolution belongs to the trusted executor. */
|
|
3532
|
-
const agentCandidateSecretRefSchema = z.strictObject({
|
|
3533
|
-
kind: z.literal("secret-ref"),
|
|
3534
|
-
key: z.string().min(1).max(500).refine((value) => value.trim().length > 0 && isPublicConfigValue(value), "secret reference key must be a public non-credential identity"),
|
|
3535
|
-
format: z.enum(["raw", "bearer"]).optional()
|
|
3536
|
-
});
|
|
3537
|
-
const agentCandidatePublicValueSchema = z.strictObject({
|
|
3538
|
-
kind: z.literal("public"),
|
|
3539
|
-
value: z.string().refine(isPublicConfigValue, "candidate config cannot carry credentials; the evaluator owns model authorization")
|
|
3540
|
-
});
|
|
3541
|
-
const agentCandidateConfigValueSchema = z.discriminatedUnion("kind", [agentCandidatePublicValueSchema, agentCandidateSecretRefSchema]);
|
|
3542
|
-
function configRecordSchema(keySchema) {
|
|
3543
|
-
return z.record(keySchema, agentCandidateConfigValueSchema).superRefine((config, ctx) => {
|
|
3544
|
-
for (const name of Object.keys(config)) if (secretNamePattern.test(name) && config[name]?.kind !== "secret-ref") ctx.addIssue({
|
|
3545
|
-
code: "custom",
|
|
3546
|
-
path: [name],
|
|
3547
|
-
message: "candidate config cannot declare credential-bearing names"
|
|
3548
|
-
});
|
|
3549
|
-
});
|
|
3550
|
-
}
|
|
3551
|
-
configRecordSchema(environmentNameSchema);
|
|
3552
|
-
z.object({
|
|
3553
|
-
kind: z.literal("github"),
|
|
3554
|
-
owner: z.string().regex(githubComponentPattern).refine((value) => value !== "." && value !== ".."),
|
|
3555
|
-
repo: z.string().regex(githubComponentPattern).refine((value) => value !== "." && value !== "..")
|
|
3556
|
-
}).strict();
|
|
3557
|
-
//#endregion
|
|
3558
|
-
//#region ../../../node_modules/.pnpm/@tangle-network+agent-interface@5.10.11/node_modules/@tangle-network/agent-interface/dist/agent-profile.js
|
|
3559
|
-
/**
|
|
3560
|
-
* Portable reasoning/thinking effort. Backends map it to their native control at materialization:
|
|
3561
|
-
* codex `model_reasoning_effort`, kimi `--thinking`/`--no-thinking`, claude thinking budget.
|
|
3562
|
-
* Ordered low→high:
|
|
3563
|
-
* - `none` — extended thinking OFF (no reasoning budget at all)
|
|
3564
|
-
* - `minimal` — thinking ON, the lowest budget (distinct from `none`)
|
|
3565
|
-
* - `low` / `medium` / `high` / `xhigh`
|
|
3566
|
-
* - `ultracode` — maximum (Claude Code's `max` and Codex's `ultra` reconcile here).
|
|
3567
|
-
* A backend without a matching native tier may clamp down to its strongest supported level, but it
|
|
3568
|
-
* must never turn reasoning on for `none` or silently increase a requested effort.
|
|
3569
|
-
*/
|
|
3570
|
-
const REASONING_EFFORTS = Object.freeze([
|
|
3571
|
-
"none",
|
|
3572
|
-
"minimal",
|
|
3573
|
-
"low",
|
|
3574
|
-
"medium",
|
|
3575
|
-
"high",
|
|
3576
|
-
"xhigh",
|
|
3577
|
-
"ultracode"
|
|
3578
|
-
]);
|
|
3579
|
-
/** Router namespace reserved for checkpoint-backed models. Receipt-free profiles cannot use it. */
|
|
3580
|
-
const TRAINED_MODEL_PREFIX = "tangle-trained/";
|
|
3581
|
-
/** An immutable Router alias; serving must independently attest this artifact-to-route binding. */
|
|
3582
|
-
function trainedModelIdForArtifact(digest) {
|
|
3583
|
-
return `${TRAINED_MODEL_PREFIX}${digest.slice(7)}`;
|
|
3584
|
-
}
|
|
3585
|
-
//#endregion
|
|
3586
|
-
//#region ../../../node_modules/.pnpm/@tangle-network+agent-interface@5.10.11/node_modules/@tangle-network/agent-interface/dist/profile-knowledge.js
|
|
3587
|
-
/** Immutable Hub generation identities, never aliases such as latest or a caller's scope. */
|
|
3588
|
-
const agentProfileKnowledgeRefSchema = z.strictObject({
|
|
3589
|
-
sourceId: z.string().regex(/^[A-Za-z0-9_-]{1,128}$/),
|
|
3590
|
-
generation: z.string().regex(/^kg_[a-f0-9]{64}$/)
|
|
3591
|
-
});
|
|
3592
|
-
const agentProfileKnowledgeRefsSchema = z.array(agentProfileKnowledgeRefSchema).max(16).superRefine((refs, context) => {
|
|
3593
|
-
const seen = /* @__PURE__ */ new Set();
|
|
3594
|
-
refs.forEach((ref, index) => {
|
|
3595
|
-
if (seen.has(ref.sourceId)) context.addIssue({
|
|
3596
|
-
code: "custom",
|
|
3597
|
-
path: [index, "sourceId"],
|
|
3598
|
-
message: "A profile must pin exactly one generation per knowledge source"
|
|
3599
|
-
});
|
|
3600
|
-
seen.add(ref.sourceId);
|
|
3601
|
-
});
|
|
3602
|
-
});
|
|
3603
|
-
//#endregion
|
|
3604
|
-
//#region ../../../node_modules/.pnpm/@tangle-network+agent-interface@5.10.11/node_modules/@tangle-network/agent-interface/dist/harness.js
|
|
3605
|
-
/**
|
|
3606
|
-
* Recognized execution identities, not a deployment's list of installed runners.
|
|
3607
|
-
* A profile's authored harness remains part of its canonical identity; execution
|
|
3608
|
-
* receipts record authored identity, effective identity and selected harness
|
|
3609
|
-
* separately. Retiring an executable must not invalidate historical profiles,
|
|
3610
|
-
* sessions or receipts. Availability is admitted against the selected deployment.
|
|
3611
|
-
*
|
|
3612
|
-
* `cli-base` names router-backed execution without a full coding-agent harness.
|
|
3613
|
-
* `prime` is a distinct Pi-line fork. A shared identity does not assert protocol compatibility.
|
|
3614
|
-
*/
|
|
3615
|
-
const harnessTypeSchema = z.enum([
|
|
3616
|
-
"claude-code",
|
|
3617
|
-
"nanoclaw",
|
|
3618
|
-
"codex",
|
|
3619
|
-
"opencode",
|
|
3620
|
-
"kimi-code",
|
|
3621
|
-
"pi",
|
|
3622
|
-
"prime",
|
|
3623
|
-
"gemini",
|
|
3624
|
-
"hermes",
|
|
3625
|
-
"openclaw",
|
|
3626
|
-
"amp",
|
|
3627
|
-
"factory-droids",
|
|
3628
|
-
"forge",
|
|
3629
|
-
"cursor",
|
|
3630
|
-
"grok",
|
|
3631
|
-
"acp",
|
|
3632
|
-
"cli-base"
|
|
3633
|
-
]);
|
|
3634
|
-
//#endregion
|
|
3635
|
-
//#region ../../../node_modules/.pnpm/@tangle-network+agent-interface@5.10.11/node_modules/@tangle-network/agent-interface/dist/agent-profile-canonical.js
|
|
3636
|
-
/** Why a value cannot be AgentProfile JSON, with the path of the offending entry. */
|
|
3637
|
-
var AgentProfileValueError = class extends Error {
|
|
3638
|
-
path;
|
|
3639
|
-
constructor(path, reason) {
|
|
3640
|
-
super(`AgentProfile ${renderPath(path)} ${reason}`);
|
|
3641
|
-
this.path = path;
|
|
3642
|
-
this.name = "AgentProfileValueError";
|
|
3643
|
-
}
|
|
3644
|
-
};
|
|
3645
|
-
/**
|
|
3646
|
-
* Normalize profile-shaped data into the canonical JSON domain used for public
|
|
3647
|
-
* profile identity. Undefined object entries are omitted; unsupported values,
|
|
3648
|
-
* sparse arrays, and cycles are rejected with their profile path.
|
|
3649
|
-
*
|
|
3650
|
-
* This module is intentionally internal. Public callers should use the
|
|
3651
|
-
* profile-level operations that own validation, identity, or diff semantics.
|
|
3652
|
-
*/
|
|
3653
|
-
function canonicalAgentProfileValue(value) {
|
|
3654
|
-
return normalizeAgentProfileValue(value, [], /* @__PURE__ */ new Set());
|
|
3655
|
-
}
|
|
3656
|
-
/**
|
|
3657
|
-
* Throw the path-specific reason a value refused by the bounded admission walker is
|
|
3658
|
-
* not profile JSON. Reads no accessor and throws at the contract node and depth
|
|
3659
|
-
* bounds, so hostile input stays cheap; returns only when the refusal was a bound
|
|
3660
|
-
* this walker does not model, such as string or entry length.
|
|
3661
|
-
*/
|
|
3662
|
-
function assertAgentProfileValue(value, path) {
|
|
3663
|
-
normalizeAgentProfileValue(value, path, /* @__PURE__ */ new Set(), {
|
|
3664
|
-
nodes: CONTRACT_MAX_JSON_NODES,
|
|
3665
|
-
base: path.length
|
|
3666
|
-
});
|
|
3667
|
-
}
|
|
3668
|
-
/** Canonical serialization after applying AgentProfile normalization rules. */
|
|
3669
|
-
function canonicalAgentProfileJson(value) {
|
|
3670
|
-
const normalized = canonicalAgentProfileValue(value);
|
|
3671
|
-
return normalized === void 0 ? void 0 : canonicalCandidateJson(normalized);
|
|
3672
|
-
}
|
|
3673
|
-
function normalizeAgentProfileValue(value, path, ancestors, bounds) {
|
|
3674
|
-
const refuse = (reason, at = path) => {
|
|
3675
|
-
throw new AgentProfileValueError(at, reason);
|
|
3676
|
-
};
|
|
3677
|
-
if (bounds && --bounds.nodes < 0) refuse("exceeds the contract node bound");
|
|
3678
|
-
if (value === void 0 || value === null || typeof value === "boolean" || typeof value === "string") return value;
|
|
3679
|
-
if (typeof value === "number") return Number.isFinite(value) ? value : refuse("must be finite");
|
|
3680
|
-
if (typeof value !== "object") return refuse("is not JSON serializable");
|
|
3681
|
-
if (ancestors.has(value)) refuse("must be acyclic");
|
|
3682
|
-
const prototype = Object.getPrototypeOf(value);
|
|
3683
|
-
if (!Array.isArray(value) && prototype !== Object.prototype && prototype !== null) refuse("must be a plain JSON object");
|
|
3684
|
-
if (bounds && path.length - bounds.base >= 16) refuse("exceeds the contract depth");
|
|
3685
|
-
const nextAncestors = new Set(ancestors).add(value);
|
|
3686
|
-
const entry = (key) => {
|
|
3687
|
-
const descriptor = Object.getOwnPropertyDescriptor(value, key);
|
|
3688
|
-
if (!descriptor) return refuse("cannot be a sparse array hole", [...path, key]);
|
|
3689
|
-
if (!("value" in descriptor)) return refuse("must be a data property", [...path, key]);
|
|
3690
|
-
const normalized = normalizeAgentProfileValue(descriptor.value, [...path, key], nextAncestors, bounds);
|
|
3691
|
-
return normalized === void 0 && typeof key === "number" ? refuse("cannot be undefined", [...path, key]) : normalized;
|
|
3692
|
-
};
|
|
3693
|
-
if (Array.isArray(value)) return Array.from({ length: value.length }, (_, index) => entry(index));
|
|
3694
|
-
const material = Object.create(null);
|
|
3695
|
-
for (const key of Object.keys(value)) {
|
|
3696
|
-
if (!isWellFormedUnicode(key)) refuse("has a record key that is not valid Unicode");
|
|
3697
|
-
const normalized = entry(key);
|
|
3698
|
-
if (normalized !== void 0) Object.defineProperty(material, key, {
|
|
3699
|
-
value: normalized,
|
|
3700
|
-
enumerable: true,
|
|
3701
|
-
configurable: true,
|
|
3702
|
-
writable: true
|
|
3703
|
-
});
|
|
3704
|
-
}
|
|
3705
|
-
return material;
|
|
3706
|
-
}
|
|
3707
|
-
function renderPath(path) {
|
|
3708
|
-
return path.length === 0 ? "root" : path.join(".");
|
|
3709
|
-
}
|
|
3710
|
-
//#endregion
|
|
3711
|
-
//#region ../../../node_modules/.pnpm/@tangle-network+agent-interface@5.10.11/node_modules/@tangle-network/agent-interface/dist/own-property-record.js
|
|
3712
|
-
/**
|
|
3713
|
-
* Zod records currently assign parsed values onto an ordinary object. The
|
|
3714
|
-
* special own key `__proto__` therefore invokes the legacy prototype setter
|
|
3715
|
-
* and disappears instead of being validated. Encode every own key before Zod
|
|
3716
|
-
* sees it, then restore the exact UTF-16 key with defineProperty so all string
|
|
3717
|
-
* keys allowed by `Record<string, ...>` remain data rather than object syntax.
|
|
3718
|
-
*/
|
|
3719
|
-
function ownPropertyRecordSchema(valueSchema, { maxEntries = 256, prepareValue } = {}) {
|
|
3720
|
-
return z.preprocess((value, context) => {
|
|
3721
|
-
if (value === null || typeof value !== "object" || Array.isArray(value)) return value;
|
|
3722
|
-
const prototype = Object.getPrototypeOf(value);
|
|
3723
|
-
if (prototype !== Object.prototype && prototype !== null) return [];
|
|
3724
|
-
let entries = 0;
|
|
3725
|
-
for (const key in value) {
|
|
3726
|
-
if (!Object.hasOwn(value, key)) continue;
|
|
3727
|
-
if (++entries > maxEntries || key.length > 512) {
|
|
3728
|
-
context.addIssue({
|
|
3729
|
-
code: "custom",
|
|
3730
|
-
message: "record exceeds the contract bounds"
|
|
3731
|
-
});
|
|
3732
|
-
return z.NEVER;
|
|
3733
|
-
}
|
|
3734
|
-
}
|
|
3735
|
-
const encoded = Object.create(null);
|
|
3736
|
-
for (const key of Object.keys(value)) {
|
|
3737
|
-
const descriptor = Object.getOwnPropertyDescriptor(value, key);
|
|
3738
|
-
if (!descriptor || !("value" in descriptor)) {
|
|
3739
|
-
context.addIssue({
|
|
3740
|
-
code: "custom",
|
|
3741
|
-
message: "record entries must be data properties"
|
|
3742
|
-
});
|
|
3743
|
-
return z.NEVER;
|
|
3744
|
-
}
|
|
3745
|
-
let entry;
|
|
3746
|
-
try {
|
|
3747
|
-
entry = prepareValue ? prepareValue(key, descriptor.value) : descriptor.value;
|
|
3748
|
-
} catch (error) {
|
|
3749
|
-
if (!(error instanceof AgentProfileValueError)) throw error;
|
|
3750
|
-
context.addIssue({
|
|
3751
|
-
code: "custom",
|
|
3752
|
-
path: [...error.path],
|
|
3753
|
-
message: error.message
|
|
3754
|
-
});
|
|
3755
|
-
return z.NEVER;
|
|
3756
|
-
}
|
|
3757
|
-
if (entry === z.NEVER) {
|
|
3758
|
-
context.addIssue({
|
|
3759
|
-
code: "custom",
|
|
3760
|
-
message: "record value exceeds the contract bounds or is not portable JSON"
|
|
3761
|
-
});
|
|
3762
|
-
return z.NEVER;
|
|
3763
|
-
}
|
|
3764
|
-
encoded[encodeRecordKey(key)] = entry;
|
|
3765
|
-
}
|
|
3766
|
-
return encoded;
|
|
3767
|
-
}, z.record(z.string().regex(/^u(?:[0-9a-f]{4})*$/, "record keys must contain valid Unicode"), valueSchema).superRefine((_record, context) => {
|
|
3768
|
-
for (const issue of context.issues) {
|
|
3769
|
-
const key = issue.path?.[0];
|
|
3770
|
-
if (typeof key === "string" && /^[ui](?:[0-9a-f]{4})*$/.test(key)) issue.path[0] = decodeRecordKey(key);
|
|
3771
|
-
}
|
|
3772
|
-
}, { when: () => true }).transform((record) => {
|
|
3773
|
-
const restored = {};
|
|
3774
|
-
for (const [encodedKey, value] of Object.entries(record)) Object.defineProperty(restored, decodeRecordKey(encodedKey), {
|
|
3775
|
-
value,
|
|
3776
|
-
enumerable: true,
|
|
3777
|
-
configurable: true,
|
|
3778
|
-
writable: true
|
|
3779
|
-
});
|
|
3780
|
-
return restored;
|
|
3781
|
-
}));
|
|
3782
|
-
}
|
|
3783
|
-
function encodeRecordKey(value) {
|
|
3784
|
-
let encoded = isWellFormedUnicode(value) ? "u" : "i";
|
|
3785
|
-
for (let index = 0; index < value.length; index += 1) encoded += value.charCodeAt(index).toString(16).padStart(4, "0");
|
|
3786
|
-
return encoded;
|
|
3787
|
-
}
|
|
3788
|
-
function decodeRecordKey(value) {
|
|
3789
|
-
let decoded = "";
|
|
3790
|
-
for (let index = 1; index < value.length; index += 4) decoded += String.fromCharCode(Number.parseInt(value.slice(index, index + 4), 16));
|
|
3791
|
-
return decoded;
|
|
3792
|
-
}
|
|
3793
|
-
//#endregion
|
|
3794
|
-
//#region ../../../node_modules/.pnpm/@tangle-network+agent-interface@5.10.11/node_modules/@tangle-network/agent-interface/dist/proxy-secrets.js
|
|
3795
|
-
/**
|
|
3796
|
-
* Declarations request authority. The issuer intersects scope/expiry with authenticated tenant,
|
|
3797
|
-
* issuer policy and lineage, without personal/team fallback, pinning immutable secret ID/revision.
|
|
3798
|
-
* Trusted lifecycle owners mint unpredictable per-epoch placeholders, never from secret/public
|
|
3799
|
-
* refs. JWT claims are synthetic public sub/aud/exp, without upstream identity or authority.
|
|
3800
|
-
* The sandbox is the isolation boundary; schemas cannot authenticate guest processes.
|
|
3801
|
-
*/
|
|
3802
|
-
const unique = (values) => new Set(values).size === values.length;
|
|
3803
|
-
const hostSchema = z.string().max(253).regex(/^(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z](?:[a-z0-9-]{0,61}[a-z0-9])?$/, "host must be an exact lowercase FQDN without scheme, port, wildcard or trailing dot");
|
|
3804
|
-
const methodSchema = z.string().max(32).regex(/^[A-Z]+$/);
|
|
3805
|
-
/** Paths are exact or terminal slash-star subtrees. /v1/* includes /v1/ and /v1/a, never /v1
|
|
3806
|
-
* or /v10. V1 rejects all percent encoding, dot segments, repeated slashes, query, fragments,
|
|
3807
|
-
* semicolons, backslashes, non-ASCII and controls, rather than normalizing ambiguous spellings.
|
|
3808
|
-
*/
|
|
3809
|
-
const pathSchema = z.string().max(2048).refine((path) => {
|
|
3810
|
-
const exact = path.endsWith("/*") ? path.slice(0, -1) : path;
|
|
3811
|
-
return /^\/[A-Za-z0-9._~!$&'()+,=:@/-]*$/.test(exact) && !exact.includes("//") && !exact.split("/").some((part) => part === "." || part === "..");
|
|
3812
|
-
}, "path must be canonical ASCII, exact or a terminal /* subtree");
|
|
3813
|
-
const list = (schema) => z.array(schema).min(1).max(CONTRACT_MAX_ARRAY_LENGTH).refine(unique, "selectors must be unique");
|
|
3814
|
-
const envNameSchema = z.string().max(256).regex(/^[A-Za-z_][A-Za-z0-9_]*$/);
|
|
3815
|
-
const headerSchema = z.string().max(256).regex(/^[!#$%&'*+.^_\x60|~0-9A-Za-z-]+$/).refine((name) => ![
|
|
3816
|
-
"authorization",
|
|
3817
|
-
"proxy-authorization",
|
|
3818
|
-
"proxy-authenticate",
|
|
3819
|
-
"host",
|
|
3820
|
-
"connection",
|
|
3821
|
-
"keep-alive",
|
|
3822
|
-
"proxy-connection",
|
|
3823
|
-
"content-length",
|
|
3824
|
-
"transfer-encoding",
|
|
3825
|
-
"trailer",
|
|
3826
|
-
"upgrade",
|
|
3827
|
-
"te"
|
|
3828
|
-
].includes(name.toLowerCase()), "use bearer/basic for Authorization; routing and framing headers cannot carry secrets");
|
|
3829
|
-
/** Match complete components only. Selected header names are case-insensitive; duplicate fields
|
|
3830
|
-
* are refused before coalescing. Query names are case-sensitive after one strict UTF-8 percent
|
|
3831
|
-
* decode (+ means space); malformed encoding and duplicate decoded selector names are refused.
|
|
3832
|
-
* Never scan other query fields. Basic is one strict base64 value decoding to exactly public
|
|
3833
|
-
* username:placeholder; the username is printable ASCII without colon. Bearer is exactly
|
|
3834
|
-
* "Bearer SP placeholder". Embedded placeholders never match. Authority, TLS SNI and validated
|
|
3835
|
-
* destination must agree on the declared FQDN and effective port over HTTPS.
|
|
3836
|
-
*/
|
|
3837
|
-
const ProxySecretPresentationSchema = z.discriminatedUnion("type", [
|
|
3838
|
-
z.strictObject({ type: z.literal("bearer") }),
|
|
3839
|
-
z.strictObject({
|
|
3840
|
-
type: z.literal("basic"),
|
|
3841
|
-
username: z.string().min(1).max(256).regex(/^[\x21-\x39\x3b-\x7e]+$/)
|
|
3842
|
-
}),
|
|
3843
|
-
z.strictObject({
|
|
3844
|
-
type: z.literal("header"),
|
|
3845
|
-
name: headerSchema
|
|
3846
|
-
}),
|
|
3847
|
-
z.strictObject({
|
|
3848
|
-
type: z.literal("query"),
|
|
3849
|
-
name: z.string().max(256).regex(/^[A-Za-z0-9._~-]+$/)
|
|
3850
|
-
})
|
|
3851
|
-
]);
|
|
3852
|
-
const ProxySecretScopeSchema = z.strictObject({
|
|
3853
|
-
hosts: list(hostSchema).readonly(),
|
|
3854
|
-
methods: list(methodSchema).readonly().optional(),
|
|
3855
|
-
paths: list(pathSchema).readonly().optional()
|
|
3856
|
-
});
|
|
3857
|
-
ProxySecretScopeSchema.strip();
|
|
3858
|
-
const ProxySecretBindingSchema = ProxySecretScopeSchema.extend({
|
|
3859
|
-
envName: envNameSchema,
|
|
3860
|
-
secretRef: agentCandidateSecretRefSchema.omit({ format: true }),
|
|
3861
|
-
presentation: ProxySecretPresentationSchema,
|
|
3862
|
-
placeholderFormat: z.enum(["opaque", "jwt"]).optional(),
|
|
3863
|
-
ttlSeconds: z.number().int().positive().max(Number.MAX_SAFE_INTEGER).optional()
|
|
3864
|
-
});
|
|
3865
|
-
const ProxySecretsSchema = z.array(ProxySecretBindingSchema).max(CONTRACT_MAX_ARRAY_LENGTH).refine((bindings) => unique(bindings.map((binding) => binding.envName)), "proxy secret env names must be unique");
|
|
3866
|
-
ownPropertyRecordSchema(boundedIdentifierSchema.nullable(), { maxEntries: CONTRACT_MAX_ARRAY_LENGTH }).refine((parents) => Object.keys(parents).every((name) => envNameSchema.safeParse(name).success), "invalid parent selection keys");
|
|
3867
|
-
z.literal(1);
|
|
3868
|
-
const ProxySecretResolvedIdentitySchema = z.strictObject({
|
|
3869
|
-
tenantId: boundedIdentifierSchema,
|
|
3870
|
-
issuerId: boundedIdentifierSchema,
|
|
3871
|
-
secretId: boundedIdentifierSchema,
|
|
3872
|
-
revision: boundedIdentifierSchema
|
|
3873
|
-
});
|
|
3874
|
-
const timestamp = z.iso.datetime();
|
|
3875
|
-
const ProxySecretGrantSchema = z.strictObject({
|
|
3876
|
-
protocolVersion: z.literal(1),
|
|
3877
|
-
grantId: boundedIdentifierSchema,
|
|
3878
|
-
sandboxId: boundedIdentifierSchema,
|
|
3879
|
-
epoch: boundedIdentifierSchema,
|
|
3880
|
-
identity: ProxySecretResolvedIdentitySchema,
|
|
3881
|
-
scope: ProxySecretScopeSchema,
|
|
3882
|
-
presentation: ProxySecretPresentationSchema,
|
|
3883
|
-
placeholderFormat: z.enum(["opaque", "jwt"]),
|
|
3884
|
-
issuedAt: timestamp,
|
|
3885
|
-
expiresAt: timestamp,
|
|
3886
|
-
sourceExpiresAt: timestamp.optional(),
|
|
3887
|
-
parentGrantId: boundedIdentifierSchema.optional()
|
|
3888
|
-
}).refine((grant) => grant.parentGrantId !== grant.grantId && Date.parse(grant.expiresAt) > Date.parse(grant.issuedAt) && (grant.sourceExpiresAt === void 0 || Date.parse(grant.expiresAt) <= Date.parse(grant.sourceExpiresAt)), "grant expiry must follow issuance");
|
|
3889
|
-
const receiptShape = {
|
|
3890
|
-
protocolVersion: z.literal(1),
|
|
3891
|
-
sandboxId: boundedIdentifierSchema,
|
|
3892
|
-
generation: z.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER),
|
|
3893
|
-
bindings: z.array(z.strictObject({
|
|
3894
|
-
envName: envNameSchema,
|
|
3895
|
-
secretRef: agentCandidateSecretRefSchema.omit({ format: true }),
|
|
3896
|
-
grant: ProxySecretGrantSchema
|
|
3897
|
-
})).max(CONTRACT_MAX_ARRAY_LENGTH),
|
|
3898
|
-
proxyAcknowledged: z.literal(true)
|
|
3899
|
-
};
|
|
3900
|
-
z.discriminatedUnion("status", [
|
|
3901
|
-
z.strictObject({
|
|
3902
|
-
...receiptShape,
|
|
3903
|
-
status: z.literal("proxy-installed"),
|
|
3904
|
-
materializationAcknowledged: z.literal(false)
|
|
3905
|
-
}),
|
|
3906
|
-
z.strictObject({
|
|
3907
|
-
...receiptShape,
|
|
3908
|
-
status: z.literal("installed"),
|
|
3909
|
-
materializationAcknowledged: z.literal(true)
|
|
3910
|
-
}),
|
|
3911
|
-
z.strictObject({
|
|
3912
|
-
...receiptShape,
|
|
3913
|
-
status: z.literal("revoked"),
|
|
3914
|
-
materializationAcknowledged: z.literal(true)
|
|
3915
|
-
})
|
|
3916
|
-
]).superRefine((receipt, ctx) => {
|
|
3917
|
-
if (!unique(receipt.bindings.map((binding) => binding.envName)) || !unique(receipt.bindings.map((binding) => binding.grant.grantId))) ctx.addIssue({
|
|
3918
|
-
code: "custom",
|
|
3919
|
-
path: ["bindings"],
|
|
3920
|
-
message: "receipt binding names and grant IDs must be unique"
|
|
3921
|
-
});
|
|
3922
|
-
if (receipt.bindings.some((binding) => binding.grant.sandboxId !== receipt.sandboxId)) ctx.addIssue({
|
|
3923
|
-
code: "custom",
|
|
3924
|
-
path: ["bindings"],
|
|
3925
|
-
message: "receipt grants must belong to its sandbox"
|
|
3926
|
-
});
|
|
3927
|
-
if (new Set(receipt.bindings.map((binding) => binding.grant.epoch)).size > 1) ctx.addIssue({
|
|
3928
|
-
code: "custom",
|
|
3929
|
-
path: ["bindings"],
|
|
3930
|
-
message: "receipt grants must share one sandbox lifecycle epoch"
|
|
3931
|
-
});
|
|
3932
|
-
if (receipt.status === "revoked" && receipt.bindings.length !== 0) ctx.addIssue({
|
|
3933
|
-
code: "custom",
|
|
3934
|
-
path: ["bindings"],
|
|
3935
|
-
message: "revoked receipt cannot retain bindings"
|
|
3936
|
-
});
|
|
3937
|
-
});
|
|
3938
|
-
z.strictObject({
|
|
3939
|
-
protocolVersion: z.literal(1),
|
|
3940
|
-
supportedDrivers: list(boundedIdentifierSchema),
|
|
3941
|
-
presentations: list(z.enum([
|
|
3942
|
-
"bearer",
|
|
3943
|
-
"basic",
|
|
3944
|
-
"header",
|
|
3945
|
-
"query"
|
|
3946
|
-
])),
|
|
3947
|
-
placeholderFormats: list(z.enum(["opaque", "jwt"])),
|
|
3948
|
-
enforcement: z.literal("exact"),
|
|
3949
|
-
transports: z.tuple([z.enum(["https:443", "https"])]),
|
|
3950
|
-
lifecycle: z.literal(true),
|
|
3951
|
-
placementReceiptRequired: z.literal(true)
|
|
3952
|
-
});
|
|
3953
|
-
z.strictObject({
|
|
3954
|
-
expectedProxySecretGeneration: z.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER).optional(),
|
|
3955
|
-
requireInPlace: z.boolean().optional()
|
|
3956
|
-
});
|
|
3957
|
-
//#endregion
|
|
3958
|
-
//#region ../../../node_modules/.pnpm/@tangle-network+agent-interface@5.10.11/node_modules/@tangle-network/agent-interface/dist/harness-capabilities.js
|
|
3959
|
-
/** Canonical harness/model, effort and prompt controls. Model-specific capability comes from the serving catalog. */
|
|
3960
|
-
/** low → high. `none` = thinking off; `ultracode` = max (claude-code mode). */
|
|
3961
|
-
const reasoningLadder = REASONING_EFFORTS;
|
|
3962
|
-
/**
|
|
3963
|
-
* Vendor locks, before the measured {@link harnessModelExclusions}. Absent means router-backed.
|
|
3964
|
-
* Claude Code and Codex run any Router model: their native vendor wire passes through for vendor
|
|
3965
|
-
* models and translates others to chat completions (including images/tools; hosted tools drop).
|
|
3966
|
-
* A caller's vendor key/login remains vendor-limited; this table does not know credentials.
|
|
3967
|
-
* NanoClaw also routes every provider through the Router, so it has no Anthropic lock.
|
|
3968
|
-
* {@link vendorHarness} chooses a default harness; it is not a provider restriction.
|
|
3969
|
-
*/
|
|
3970
|
-
const harnessProviderLock = { "kimi-code": ["moonshot"] };
|
|
3971
|
-
/** Provider prefix of a canonical model id (`anthropic/claude-…` → `anthropic`), or null. */
|
|
3972
|
-
function modelProvider(modelId) {
|
|
3973
|
-
const slash = modelId.indexOf("/");
|
|
3974
|
-
return slash > 0 ? modelId.slice(0, slash) : null;
|
|
3975
|
-
}
|
|
3976
|
-
/**
|
|
3977
|
-
* Model families whose bare ids belong to one provider. The Router catalog serves most ids without a
|
|
3978
|
-
* prefix (`claude-sonnet-5-5`, `gpt-5.5`, `glm-5.3`) and names the provider beside them, so a check
|
|
3979
|
-
* that read every bare id as "any provider" offered `claude-code` with `glm-5.3`.
|
|
3980
|
-
*/
|
|
3981
|
-
const bareModelFamilyProviders = [
|
|
3982
|
-
[/^claude-/, "anthropic"],
|
|
3983
|
-
[/^(gpt-|chatgpt-|codex-|o\d+(-|$))/, "openai"],
|
|
3984
|
-
[/^(kimi-|moonshot-)/, "moonshot"],
|
|
3985
|
-
[/^gemini-/, "google"],
|
|
3986
|
-
[/^glm-/, "zai"],
|
|
3987
|
-
[/^deepseek-/, "deepseek"],
|
|
3988
|
-
[/^grok-/, "xai"]
|
|
3989
|
-
];
|
|
3990
|
-
/**
|
|
3991
|
-
* The provider a model id belongs to: its explicit prefix, else the provider of its bare-id family
|
|
3992
|
-
* (`claude-sonnet-5-5` → `anthropic`). `null` for an id outside every family, such as the `default`
|
|
3993
|
-
* sentinel, whose provider only the serving harness knows.
|
|
3994
|
-
*/
|
|
3995
|
-
function resolveModelProvider(modelId) {
|
|
3996
|
-
const explicit = modelProvider(modelId);
|
|
3997
|
-
if (explicit) return explicit;
|
|
3998
|
-
const id = modelId.trim().toLowerCase();
|
|
3999
|
-
for (const [family, provider] of bareModelFamilyProviders) if (family.test(id)) return provider;
|
|
4000
|
-
return null;
|
|
4001
|
-
}
|
|
4002
|
-
/** The providers a harness is locked to, or `null` when it is router-backed (any model). */
|
|
4003
|
-
function harnessProviders(harness) {
|
|
4004
|
-
return harnessProviderLock[harness] ?? null;
|
|
4005
|
-
}
|
|
4006
|
-
const SANDBOX_HARNESS_MATRIX_EVIDENCE = "https://github.com/tangle-network/agent-container/issues/9382";
|
|
4007
|
-
/**
|
|
4008
|
-
* Pairs a router-backed harness cannot run, measured on production with the Router credential: one
|
|
4009
|
-
* prompt per pair, profile reasoning effort `medium` (2026-10-05). The same run passed pi with
|
|
4010
|
-
* `openai/gpt-5.5` and `zai/glm-5.3`, and opencode with every model listed here. Pairs not listed
|
|
4011
|
-
* were not measured to fail. An entry is removed when its harness adapter or the Router is fixed and
|
|
4012
|
-
* the pair passes a new production measurement.
|
|
4013
|
-
*
|
|
4014
|
-
* pi's chat-completions client (pi-ai 0.85.1) marks a model as reasoning only when the profile asks
|
|
4015
|
-
* for a reasoning effort, and only a reasoning model is sent the `developer` role and
|
|
4016
|
-
* `reasoning_effort`; that is why the first two entries need a reasoning effort.
|
|
4017
|
-
*/
|
|
4018
|
-
const harnessModelExclusions = [
|
|
4019
|
-
{
|
|
4020
|
-
harness: "pi",
|
|
4021
|
-
models: /^anthropic\//,
|
|
4022
|
-
onlyWithReasoningEffort: true,
|
|
4023
|
-
reason: "the Router's chat-completions route for Anthropic models rejects the \"developer\" role pi sends to a reasoning model (400 Unexpected role \"developer\")",
|
|
4024
|
-
measuredOn: "2026-10-05",
|
|
4025
|
-
evidence: SANDBOX_HARNESS_MATRIX_EVIDENCE
|
|
4026
|
-
},
|
|
4027
|
-
{
|
|
4028
|
-
harness: "pi",
|
|
4029
|
-
models: /^openai\/gpt-5\.6-luna$/,
|
|
4030
|
-
onlyWithReasoningEffort: true,
|
|
4031
|
-
reason: "OpenAI does not accept function tools together with reasoning_effort for this model on /v1/chat/completions, the only route pi speaks",
|
|
4032
|
-
measuredOn: "2026-10-05",
|
|
4033
|
-
evidence: SANDBOX_HARNESS_MATRIX_EVIDENCE
|
|
4034
|
-
},
|
|
4035
|
-
{
|
|
4036
|
-
harness: "pi",
|
|
4037
|
-
models: /^google\/gemini-3\.8-flash$/,
|
|
4038
|
-
onlyWithReasoningEffort: false,
|
|
4039
|
-
reason: "the model requires each function call to return its thought_signature, which pi's chat-completions client does not send back (400 Function call is missing a thought_signature)",
|
|
4040
|
-
measuredOn: "2026-10-05",
|
|
4041
|
-
evidence: SANDBOX_HARNESS_MATRIX_EVIDENCE
|
|
4042
|
-
}
|
|
4043
|
-
];
|
|
4044
|
-
/**
|
|
4045
|
-
* Whether a harness can run a model, and why not. A bare id resolves its provider through
|
|
4046
|
-
* {@link resolveModelProvider}; an id whose provider cannot be resolved (a sentinel like `default`)
|
|
4047
|
-
* is left to the harness, because its provider only the serving harness knows. A vendor-locked
|
|
4048
|
-
* harness refuses every other provider; a router-backed harness refuses only the measured
|
|
4049
|
-
* {@link harnessModelExclusions}.
|
|
4050
|
-
*/
|
|
4051
|
-
function harnessModelSupport(harness, modelId, options = {}) {
|
|
4052
|
-
const trimmed = modelId.trim();
|
|
4053
|
-
const provider = resolveModelProvider(trimmed);
|
|
4054
|
-
const model = provider !== null && modelProvider(trimmed) === null ? `${provider}/${trimmed}` : trimmed;
|
|
4055
|
-
if (provider === null) return {
|
|
4056
|
-
supported: true,
|
|
4057
|
-
model,
|
|
4058
|
-
provider
|
|
4059
|
-
};
|
|
4060
|
-
const allowedProviders = harnessProviders(harness);
|
|
4061
|
-
if (allowedProviders && !allowedProviders.includes(provider)) return {
|
|
4062
|
-
supported: false,
|
|
4063
|
-
model,
|
|
4064
|
-
provider,
|
|
4065
|
-
allowedProviders,
|
|
4066
|
-
message: `Harness ${harness} runs only ${allowedProviders.join(" or ")} models, not ${model} (provider ${provider}). Choose a model whose id starts with ${allowedProviders.map((p) => `${p}/`).join(" or ")}, or a harness that runs ${provider} models, such as opencode.`
|
|
4067
|
-
};
|
|
4068
|
-
const reasoning = options.reasoningEffort !== void 0 && options.reasoningEffort !== null && options.reasoningEffort !== "none";
|
|
4069
|
-
const exclusion = harnessModelExclusions.find((entry) => entry.harness === harness && entry.models.test(model) && (!entry.onlyWithReasoningEffort || reasoning));
|
|
4070
|
-
if (exclusion) return {
|
|
4071
|
-
supported: false,
|
|
4072
|
-
model,
|
|
4073
|
-
provider,
|
|
4074
|
-
exclusion,
|
|
4075
|
-
message: `Harness ${harness} cannot run ${model}` + (exclusion.onlyWithReasoningEffort ? " with a reasoning effort" : "") + `: ${exclusion.reason} (measured ${exclusion.measuredOn}, ${exclusion.evidence}). ` + (exclusion.onlyWithReasoningEffort ? "Remove model.reasoningEffort, or choose another harness or model." : "Choose another harness or model.")
|
|
4076
|
-
};
|
|
4077
|
-
return {
|
|
4078
|
-
supported: true,
|
|
4079
|
-
model,
|
|
4080
|
-
provider
|
|
4081
|
-
};
|
|
4082
|
-
}
|
|
4083
|
-
new Intl.Collator(void 0, {
|
|
4084
|
-
numeric: true,
|
|
4085
|
-
sensitivity: "base"
|
|
4086
|
-
});
|
|
4087
|
-
/**
|
|
4088
|
-
* The explicit reasoning-effort set a harness's runtime accepts when it ISN'T a plain `none…ceiling`
|
|
4089
|
-
* slice — measured against the pinned CLI binaries, NOT inferred from the canonical ladder:
|
|
4090
|
-
* - codex: `model_reasoning_effort` accepts `none|minimal|low|medium|high|xhigh|max`, plus `ultra`
|
|
4091
|
-
* which the API's own enumeration omits but accepts end-to-end; canonical `ultracode` maps to
|
|
4092
|
-
* native `ultra`. Per-model catalog data narrows this list.
|
|
4093
|
-
* - claude-code: `--effort` accepts `low|medium|high|xhigh|max`; canonical `ultracode` maps to
|
|
4094
|
-
* native `max`. It cannot express `none` or `minimal`, and an unsupported value is warned about
|
|
4095
|
-
* and silently replaced with the default rather than rejected — so the set must not overstate.
|
|
4096
|
-
* - pi: `--thinking` accepts `off|minimal|low|medium|high|xhigh|max` (pi 1.4.0
|
|
4097
|
-
* `cli/args.js`); canonical `none` maps to `off` and `ultracode` to `max`.
|
|
4098
|
-
* - prime: the prime fork of the pi line accepts the same `--thinking` set
|
|
4099
|
-
* (`off|minimal|low|medium|high|xhigh|max`); canonical `none` maps to `off` and `ultracode` to
|
|
4100
|
-
* `max`.
|
|
4101
|
-
* - openclaw: `--thinking` accepts `off|minimal|low|medium|high|xhigh|max` (and `adaptive`, which
|
|
4102
|
-
* defers the choice rather than naming a rung); canonical `none` maps to `off` and `ultracode`
|
|
4103
|
-
* to `max`.
|
|
4104
|
-
* - kimi-code: `--thinking` is binary. Canonical `none` emits `--no-thinking`; any non-none level
|
|
4105
|
-
* emits `--thinking`, represented here by `high`.
|
|
4106
|
-
*/
|
|
4107
|
-
const harnessReasoningEffortsOverride = {
|
|
4108
|
-
"claude-code": [
|
|
4109
|
-
"low",
|
|
4110
|
-
"medium",
|
|
4111
|
-
"high",
|
|
4112
|
-
"xhigh",
|
|
4113
|
-
"ultracode"
|
|
4114
|
-
],
|
|
4115
|
-
"kimi-code": ["none", "high"]
|
|
4116
|
-
};
|
|
4117
|
-
/**
|
|
4118
|
-
* The ceiling for harnesses whose set IS a plain `none…ceiling` slice. Only the no-thinking runners
|
|
4119
|
-
* need an entry (`cli-base` has no agent; `nanoclaw` sends no thinking flag). Harnesses with a
|
|
4120
|
-
* provider-clamped or non-contiguous set live in {@link harnessReasoningEffortsOverride}; router /
|
|
4121
|
-
* model-driven harnesses (opencode, gemini, …) have no entry → default to the full ladder, narrowed
|
|
4122
|
-
* by the model's own capability.
|
|
4123
|
-
*/
|
|
4124
|
-
const harnessReasoningCeiling = {
|
|
4125
|
-
"cli-base": "none",
|
|
4126
|
-
nanoclaw: "none"
|
|
4127
|
-
};
|
|
4128
|
-
/** The reasoning efforts a harness can express, independent of model — its explicit override set, or
|
|
4129
|
-
* `none` up to its ceiling (default `ultracode` for router/model-driven harnesses). */
|
|
4130
|
-
function harnessReasoningEfforts(harness) {
|
|
4131
|
-
const override = harnessReasoningEffortsOverride[harness];
|
|
4132
|
-
if (override) return override;
|
|
4133
|
-
const ceiling = harnessReasoningCeiling[harness] ?? "ultracode";
|
|
4134
|
-
return reasoningLadder.slice(0, reasoningLadder.indexOf(ceiling) + 1);
|
|
4135
|
-
}
|
|
4136
|
-
/**
|
|
4137
|
-
* Harnesses whose runner DROPS a per-turn selector — grounded in the cli-bridge adapter audit, NOT a
|
|
4138
|
-
* guess. Most harnesses honor both selectors, so only the exceptions are listed; a harness absent from
|
|
4139
|
-
* a set honors that selector.
|
|
4140
|
-
*
|
|
4141
|
-
* - model dropped: `amp` (own agent picks the model), `openclaw` (dispatcher routes by its own
|
|
4142
|
-
* config), `nanoclaw` (socket-bridge runner is config/env-driven).
|
|
4143
|
-
* - effort dropped: `amp`, `factory-droids`, `hermes`, `nanoclaw`, and `acp` (no thinking flag is
|
|
4144
|
-
* plumbed to the underlying CLI — the runner reads no `reasoningEffort`).
|
|
4145
|
-
*
|
|
4146
|
-
* This is distinct from {@link reasoningEffortsFor} (which levels a harness can EXPRESS): a picker uses
|
|
4147
|
-
* these to trim or mark harnesses up front, so a user's model/effort choice is never silently ignored.
|
|
4148
|
-
*/
|
|
4149
|
-
const harnessIgnoresModel = new Set([
|
|
4150
|
-
"amp",
|
|
4151
|
-
"openclaw",
|
|
4152
|
-
"nanoclaw"
|
|
4153
|
-
]);
|
|
4154
|
-
const harnessIgnoresEffort = new Set([
|
|
4155
|
-
"amp",
|
|
4156
|
-
"factory-droids",
|
|
4157
|
-
"hermes",
|
|
4158
|
-
"nanoclaw",
|
|
4159
|
-
"acp"
|
|
4160
|
-
]);
|
|
4161
|
-
/** Whether the harness's runner honors a per-turn MODEL override (vs. picking the model itself). */
|
|
4162
|
-
function harnessHonorsModel(harness) {
|
|
4163
|
-
return !harnessIgnoresModel.has(harness);
|
|
4164
|
-
}
|
|
4165
|
-
/** Whether the harness's runner honors a reasoning-EFFORT override (vs. dropping it). */
|
|
4166
|
-
function harnessHonorsEffort(harness) {
|
|
4167
|
-
return !harnessIgnoresEffort.has(harness);
|
|
4168
|
-
}
|
|
4169
|
-
/**
|
|
4170
|
-
* The system-prompt intents a harness's own controls can execute, measured by reading the request
|
|
4171
|
-
* each installed CLI sends — NOT taken from its help text:
|
|
4172
|
-
*
|
|
4173
|
-
* - claude-code 2.1.222 and pi 0.83.0 own both. `--system-prompt` drops the built-in prompt from
|
|
4174
|
-
* the request (27,673 B → the caller's bytes on claude-code, 2,582 B → the caller's on pi);
|
|
4175
|
-
* `--append-system-prompt` leaves it in place and adds the caller's text after it.
|
|
4176
|
-
* - codex 0.146.0 owns replacement only: the `model_instructions_file` config key becomes the
|
|
4177
|
-
* request's entire instructions text. It has no additive control — its AGENTS.md lands in a
|
|
4178
|
-
* developer/user message, not the system channel.
|
|
4179
|
-
* - gemini 0.26.0 owns replacement only: `.gemini/system.md` under `GEMINI_SYSTEM_MD=1` replaces
|
|
4180
|
-
* the base prompt. Its one additive path is GEMINI.md memory, which IS the `instructions`
|
|
4181
|
-
* surface, so an addition lowered there would be byte-indistinguishable from `instructions`.
|
|
4182
|
-
* - opencode 1.17.18 owns addition only THROUGH A WORKSPACE: config-declared `instructions[]`
|
|
4183
|
-
* files compose into the same single `role: "system"` message as its built-in prompt, which
|
|
4184
|
-
* stays in place. Its replacement control (`agent.<name>.prompt`) binds to one agent chosen at
|
|
4185
|
-
* launch, which a workspace plan cannot guarantee — but an executor that selects that agent
|
|
4186
|
-
* can, so `replace: false` here is the plan-forwarding answer, not opencode's ceiling.
|
|
4187
|
-
*
|
|
4188
|
-
* Every other harness owns NEITHER, including the ones whose prompt path is a `role: "system"` chat
|
|
4189
|
-
* message: that message is flattened into the user turn before the CLI sees it, so it is not a
|
|
4190
|
-
* system-prompt channel at all — honoring an intent through it would put the caller's text in
|
|
4191
|
-
* ordinary user content while the harness's own prompt ran unchanged. A harness with no entry
|
|
4192
|
-
* refuses both, so one added later cannot inherit a capability by omission.
|
|
4193
|
-
*/
|
|
4194
|
-
const harnessSystemPromptControls = {
|
|
4195
|
-
"claude-code": {
|
|
4196
|
-
replace: true,
|
|
4197
|
-
append: true
|
|
4198
|
-
},
|
|
4199
|
-
pi: {
|
|
4200
|
-
replace: true,
|
|
4201
|
-
append: true
|
|
4202
|
-
},
|
|
4203
|
-
prime: {
|
|
4204
|
-
replace: true,
|
|
4205
|
-
append: true
|
|
4206
|
-
},
|
|
4207
|
-
codex: {
|
|
4208
|
-
replace: true,
|
|
4209
|
-
append: false
|
|
4210
|
-
},
|
|
4211
|
-
gemini: {
|
|
4212
|
-
replace: true,
|
|
4213
|
-
append: false
|
|
4214
|
-
},
|
|
4215
|
-
opencode: {
|
|
4216
|
-
replace: false,
|
|
4217
|
-
append: true
|
|
4218
|
-
}
|
|
4219
|
-
};
|
|
4220
|
-
const noSystemPromptControls = {
|
|
4221
|
-
replace: false,
|
|
4222
|
-
append: false
|
|
4223
|
-
};
|
|
4224
|
-
/**
|
|
4225
|
-
* Which system-prompt intents a harness honors THROUGH A WORKSPACE — the value an adapter that
|
|
4226
|
-
* lowers a profile to files, env vars, and CLI flags and then hands the result to a launcher it
|
|
4227
|
-
* does not own should declare as {@link AgentProfileCapabilities.systemPrompt}. That is the shape
|
|
4228
|
-
* of every caller today (the cli-bridge and tangle providers both forward a plan), which is why
|
|
4229
|
-
* this answer depends on the harness alone.
|
|
4230
|
-
*
|
|
4231
|
-
* It is NOT the whole truth for an adapter that starts the harness itself, because one control in
|
|
4232
|
-
* the table above lives outside any workspace: opencode's `agent.<name>.prompt` really does replace
|
|
4233
|
-
* its built-in prompt, but it binds to the single agent whoever starts the server selects. A plan
|
|
4234
|
-
* cannot name that agent, so `opencode` reads `replace: false` here — while an adapter that writes
|
|
4235
|
-
* opencode's server config AND picks the primary agent (`sdk-provider-opencode`) does honor
|
|
4236
|
-
* replacement, and declares `replace: true` for itself. The capability is a property of the
|
|
4237
|
-
* (harness, executor) pair; this function answers it for the plan-forwarding executor.
|
|
4238
|
-
*
|
|
4239
|
-
* Do not widen the table to close that gap: a harness-keyed `true` would promise the intent to
|
|
4240
|
-
* every plan-forwarding caller, and those callers cannot deliver it. An executor that owns a
|
|
4241
|
-
* launcher control states so where it binds it — `materializeProfile`'s `binds` option in
|
|
4242
|
-
* `@tangle-network/agent-profile-materialize`, which turns the plan's refusal into a binding that
|
|
4243
|
-
* executor must then apply.
|
|
4244
|
-
*
|
|
4245
|
-
* Pass `undefined` when the harness is not known at declaration time: the answer is then
|
|
4246
|
-
* `{ replace: false, append: false }`, because an adapter that cannot name its harness cannot
|
|
4247
|
-
* promise either intent, and `false` means "refuse" rather than "silently substitute the other".
|
|
4248
|
-
* An adapter that forwards a profile to some other layer must still declare what that layer's
|
|
4249
|
-
* harness really does — being able to put the field on the wire is not the same as honoring it.
|
|
4250
|
-
*/
|
|
4251
|
-
function harnessSystemPromptIntents(harness) {
|
|
4252
|
-
if (!harness) return noSystemPromptControls;
|
|
4253
|
-
return harnessSystemPromptControls[harness] ?? noSystemPromptControls;
|
|
4254
|
-
}
|
|
4255
|
-
//#endregion
|
|
4256
|
-
//#region ../../../node_modules/.pnpm/@tangle-network+agent-interface@5.10.11/node_modules/@tangle-network/agent-interface/dist/sandbox-size.js
|
|
4257
|
-
/**
|
|
4258
|
-
* Portable sandbox size vocabulary.
|
|
4259
|
-
*
|
|
4260
|
-
* A size preset is a provider-neutral NAME for a compute tier (cpu / memory /
|
|
4261
|
-
* disk). This module owns only the vocabulary — the names and their smallest→
|
|
4262
|
-
* largest ordering — so the lowest shared layer can reference a size without
|
|
4263
|
-
* depending on the sandbox SDK (`Capability.recommendedSize` lives here, and
|
|
4264
|
-
* agent-interface must not depend on `@tangle-network/sandbox`).
|
|
4265
|
-
*
|
|
4266
|
-
* The concrete cpu/memory/disk numbers for each preset are the sandbox SDK's
|
|
4267
|
-
* single source of truth (`@tangle-network/sandbox` → `SANDBOX_SIZE_PRESETS`),
|
|
4268
|
-
* which imports these names. Mirrors how this package owns the `ReasoningEffort`
|
|
4269
|
-
* vocabulary while backends own its native mapping.
|
|
4270
|
-
*/
|
|
4271
|
-
/** Compute tiers, ordered smallest → largest. */
|
|
4272
|
-
const SANDBOX_SIZE_PRESET_NAMES = [
|
|
4273
|
-
"nano",
|
|
4274
|
-
"small",
|
|
4275
|
-
"medium",
|
|
4276
|
-
"large"
|
|
4277
|
-
];
|
|
4278
|
-
//#endregion
|
|
4279
|
-
//#region ../../../node_modules/.pnpm/@tangle-network+agent-interface@5.10.11/node_modules/@tangle-network/agent-interface/dist/profile-schema.js
|
|
4280
|
-
const profileOpaqueValueSchema = z.unknown().transform((value, context) => {
|
|
4281
|
-
if (value === void 0 || isBoundedJsonMaterial(value, {
|
|
4282
|
-
dataPropertiesOnly: true,
|
|
4283
|
-
content: true
|
|
4284
|
-
})) return structuredClone(value);
|
|
4285
|
-
try {
|
|
4286
|
-
assertAgentProfileValue(value, []);
|
|
4287
|
-
} catch (error) {
|
|
4288
|
-
if (!(error instanceof AgentProfileValueError)) throw error;
|
|
4289
|
-
context.addIssue({
|
|
4290
|
-
code: "custom",
|
|
4291
|
-
path: [...error.path],
|
|
4292
|
-
message: error.message
|
|
4293
|
-
});
|
|
4294
|
-
return z.NEVER;
|
|
4295
|
-
}
|
|
4296
|
-
context.addIssue({
|
|
4297
|
-
code: "custom",
|
|
4298
|
-
message: "profile metadata exceeds contract bounds or is not portable JSON"
|
|
4299
|
-
});
|
|
4300
|
-
return z.NEVER;
|
|
4301
|
-
});
|
|
4302
|
-
const agentProfilePermissionValueSchema = z.enum([
|
|
4303
|
-
"allow",
|
|
4304
|
-
"deny",
|
|
4305
|
-
"ask"
|
|
4306
|
-
]);
|
|
4307
|
-
const agentProfilePermissionSchema = z.union([agentProfilePermissionValueSchema, ownPropertyRecordSchema(agentProfilePermissionValueSchema)]);
|
|
4308
|
-
const agentProfileResourceRefSchema = z.union([z.strictObject({
|
|
4309
|
-
kind: z.literal("inline"),
|
|
4310
|
-
name: z.string(),
|
|
4311
|
-
content: z.string()
|
|
4312
|
-
}), z.strictObject({
|
|
4313
|
-
kind: z.literal("github"),
|
|
4314
|
-
repository: z.string().optional(),
|
|
4315
|
-
path: z.string(),
|
|
4316
|
-
ref: z.string().optional(),
|
|
4317
|
-
name: z.string().optional()
|
|
4318
|
-
})]);
|
|
4319
|
-
const agentProfileFileMountSchema = z.strictObject({
|
|
4320
|
-
path: z.string(),
|
|
4321
|
-
resource: agentProfileResourceRefSchema,
|
|
4322
|
-
executable: z.boolean().optional()
|
|
4323
|
-
});
|
|
4324
|
-
const agentProfileResourcesSchema = z.strictObject({
|
|
4325
|
-
knowledge: agentProfileKnowledgeRefsSchema.optional(),
|
|
4326
|
-
files: z.array(agentProfileFileMountSchema).max(CONTRACT_MAX_ARRAY_LENGTH).optional(),
|
|
4327
|
-
tools: z.array(agentProfileResourceRefSchema).max(CONTRACT_MAX_ARRAY_LENGTH).optional(),
|
|
4328
|
-
skills: z.array(agentProfileResourceRefSchema).max(CONTRACT_MAX_ARRAY_LENGTH).optional(),
|
|
4329
|
-
agents: z.array(agentProfileResourceRefSchema).max(CONTRACT_MAX_ARRAY_LENGTH).optional(),
|
|
4330
|
-
commands: z.array(agentProfileResourceRefSchema).max(CONTRACT_MAX_ARRAY_LENGTH).optional(),
|
|
4331
|
-
instructions: z.union([z.string(), agentProfileResourceRefSchema]).optional(),
|
|
4332
|
-
failOnError: z.boolean().optional()
|
|
4333
|
-
});
|
|
4334
|
-
const reasoningEffortSchema = z.enum(REASONING_EFFORTS);
|
|
4335
|
-
/**
|
|
4336
|
-
* Enforce the token ceilings that live together: each single ceiling must not
|
|
4337
|
-
* exceed the total. It fails loud on a violation and never clamps a value.
|
|
4338
|
-
* `reasoningEffort` is a separate quality dial and is not a bound here.
|
|
4339
|
-
*/
|
|
4340
|
-
function enforceModelTokenBounds(hints, context) {
|
|
4341
|
-
const { maxVisibleOutputTokens, maxReasoningTokens, maxTotalOutputTokens } = hints;
|
|
4342
|
-
if (maxTotalOutputTokens === void 0) return;
|
|
4343
|
-
if (maxVisibleOutputTokens !== void 0 && maxVisibleOutputTokens > maxTotalOutputTokens) context.addIssue({
|
|
4344
|
-
code: "custom",
|
|
4345
|
-
path: ["maxVisibleOutputTokens"],
|
|
4346
|
-
message: "maxVisibleOutputTokens must not exceed maxTotalOutputTokens"
|
|
4347
|
-
});
|
|
4348
|
-
if (maxReasoningTokens !== void 0 && maxReasoningTokens > maxTotalOutputTokens) context.addIssue({
|
|
4349
|
-
code: "custom",
|
|
4350
|
-
path: ["maxReasoningTokens"],
|
|
4351
|
-
message: "maxReasoningTokens must not exceed maxTotalOutputTokens"
|
|
4352
|
-
});
|
|
4353
|
-
}
|
|
4354
|
-
const agentProfileModelHintsSchema = z.strictObject({
|
|
4355
|
-
default: z.string().optional(),
|
|
4356
|
-
small: z.string().optional(),
|
|
4357
|
-
provider: z.string().optional(),
|
|
4358
|
-
reasoningEffort: reasoningEffortSchema.optional(),
|
|
4359
|
-
maxVisibleOutputTokens: z.number().int().positive().optional(),
|
|
4360
|
-
maxReasoningTokens: z.number().int().positive().optional(),
|
|
4361
|
-
maxTotalOutputTokens: z.number().int().positive().optional(),
|
|
4362
|
-
metadata: ownPropertyRecordSchema(profileOpaqueValueSchema).optional()
|
|
4363
|
-
}).superRefine(enforceModelTokenBounds);
|
|
4364
|
-
/** Ordered account selection policy, without credentials or ambient model defaults. */
|
|
4365
|
-
const agentProfileSeatSchema = z.strictObject({
|
|
4366
|
-
harness: harnessTypeSchema,
|
|
4367
|
-
provider: z.string().regex(/^[a-z][a-z0-9-]*$/),
|
|
4368
|
-
model: z.string().min(1).refine((value) => value.trim() === value, "model must be canonical"),
|
|
4369
|
-
reasoningEffort: reasoningEffortSchema.optional(),
|
|
4370
|
-
selector: z.union([z.strictObject({ kind: z.literal("all-eligible") }), z.strictObject({
|
|
4371
|
-
kind: z.literal("seat"),
|
|
4372
|
-
id: z.string().min(1).refine((value) => value.trim() === value, "seat id must be canonical")
|
|
4373
|
-
})]),
|
|
4374
|
-
tools: ownPropertyRecordSchema(z.boolean()).optional(),
|
|
4375
|
-
permissions: ownPropertyRecordSchema(agentProfilePermissionSchema).optional()
|
|
4376
|
-
});
|
|
4377
|
-
/**
|
|
4378
|
-
* Replacement and addition are separate, independently optional fields, and the
|
|
4379
|
-
* pair is admitted on purpose: the effective prompt is `systemPrompt` followed
|
|
4380
|
-
* by `appendSystemPrompt`. No cross-field refinement rejects the combination,
|
|
4381
|
-
* because {@link mergeAgentProfiles} can produce it from two valid profiles.
|
|
4382
|
-
*/
|
|
4383
|
-
const agentProfilePromptSchema = z.strictObject({
|
|
4384
|
-
systemPrompt: z.string().optional(),
|
|
4385
|
-
appendSystemPrompt: z.string().optional(),
|
|
4386
|
-
instructions: z.array(z.string()).max(CONTRACT_MAX_ARRAY_LENGTH).optional()
|
|
4387
|
-
});
|
|
4388
|
-
const controlCharacterPattern = /[\u0000-\u001f\u007f]/;
|
|
4389
|
-
const secretCapableNamePattern = /(?:^|[_-])(?:api[_-]?key|access[_-]?key|private[_-]?key|token|secret|password|credentials?|authorization|cookie|database[_-]?url|dsn|pat)(?:[_-]|$)/i;
|
|
4390
|
-
/** Return true when a public config name denotes credential material. */
|
|
4391
|
-
function isCredentialBearingProfileConfigName(name) {
|
|
4392
|
-
return secretCapableNamePattern.test(name);
|
|
4393
|
-
}
|
|
4394
|
-
const publicProfileConfigStringSchema = z.string().refine((value) => isWellFormedUnicode(value) && !controlCharacterPattern.test(value) && !looksLikeCredential(value), "public profile config cannot carry credential-like material");
|
|
4395
|
-
const agentProfilePublicConfigValueSchema = z.strictObject({
|
|
4396
|
-
kind: z.literal("public"),
|
|
4397
|
-
value: publicProfileConfigStringSchema
|
|
4398
|
-
});
|
|
4399
|
-
const agentProfileSecretRefSchema = agentCandidateSecretRefSchema;
|
|
4400
|
-
const agentProfileConfigValueSchema = z.discriminatedUnion("kind", [agentProfilePublicConfigValueSchema, agentProfileSecretRefSchema]);
|
|
4401
|
-
function profileConfigRecordSchema(keySchema) {
|
|
4402
|
-
return ownPropertyRecordSchema(agentProfileConfigValueSchema).superRefine((record, context) => {
|
|
4403
|
-
for (const [name, value] of Object.entries(record)) {
|
|
4404
|
-
if (!keySchema.safeParse(name).success) context.addIssue({
|
|
4405
|
-
code: "custom",
|
|
4406
|
-
path: [name],
|
|
4407
|
-
message: "profile config key is invalid for this field"
|
|
4408
|
-
});
|
|
4409
|
-
if (value.kind === "public" && isCredentialBearingProfileConfigName(name)) context.addIssue({
|
|
4410
|
-
code: "custom",
|
|
4411
|
-
path: [name],
|
|
4412
|
-
message: "credential-bearing config names require a secret-ref"
|
|
4413
|
-
});
|
|
4414
|
-
}
|
|
4415
|
-
});
|
|
4416
|
-
}
|
|
4417
|
-
const agentProfileEnvironmentSchema = profileConfigRecordSchema(environmentNameSchema);
|
|
4418
|
-
const agentProfileHeaderSchema = profileConfigRecordSchema(headerNameSchema);
|
|
4419
|
-
const agentSubagentProfileSchema = z.strictObject({
|
|
4420
|
-
description: z.string().optional(),
|
|
4421
|
-
prompt: z.string().optional(),
|
|
4422
|
-
model: z.string().optional(),
|
|
4423
|
-
tools: ownPropertyRecordSchema(z.boolean()).optional(),
|
|
4424
|
-
permissions: ownPropertyRecordSchema(agentProfilePermissionSchema).optional(),
|
|
4425
|
-
maxSteps: z.number().optional(),
|
|
4426
|
-
metadata: ownPropertyRecordSchema(profileOpaqueValueSchema).optional()
|
|
4427
|
-
});
|
|
4428
|
-
const agentProfileHookCommandSchema = z.strictObject({
|
|
4429
|
-
command: z.string(),
|
|
4430
|
-
timeoutMs: z.number().positive().optional(),
|
|
4431
|
-
blocking: z.boolean().optional(),
|
|
4432
|
-
matcher: z.string().optional(),
|
|
4433
|
-
env: agentProfileEnvironmentSchema.optional()
|
|
4434
|
-
});
|
|
4435
|
-
const agentProfileModeSchema = z.strictObject({
|
|
4436
|
-
description: z.string().optional(),
|
|
4437
|
-
model: z.string().optional(),
|
|
4438
|
-
prompt: z.string().optional(),
|
|
4439
|
-
tools: ownPropertyRecordSchema(z.boolean()).optional(),
|
|
4440
|
-
permissions: ownPropertyRecordSchema(agentProfilePermissionSchema).optional(),
|
|
4441
|
-
metadata: ownPropertyRecordSchema(profileOpaqueValueSchema).optional()
|
|
4442
|
-
});
|
|
4443
|
-
const agentProfileConfidentialSchema = z.strictObject({
|
|
4444
|
-
tee: z.string().optional(),
|
|
4445
|
-
attestationNonce: z.string().optional(),
|
|
4446
|
-
sealed: z.boolean().optional(),
|
|
4447
|
-
attestationRefresh: z.boolean().optional()
|
|
4448
|
-
});
|
|
4449
|
-
const nonBlankMcpValueSchema = z.string().refine((value) => value.trim().length > 0, "value cannot be blank");
|
|
4450
|
-
const remoteMcpUrlSchema = nonBlankMcpValueSchema.refine((value) => {
|
|
4451
|
-
try {
|
|
4452
|
-
const url = new URL(value);
|
|
4453
|
-
return url.protocol === "http:" || url.protocol === "https:";
|
|
4454
|
-
} catch {
|
|
4455
|
-
return false;
|
|
4456
|
-
}
|
|
4457
|
-
}, "remote MCP url must be an absolute HTTP(S) URL").refine((value) => !looksLikeCredential(value), "remote MCP url cannot contain credentials or credential-named query parameters");
|
|
4458
|
-
const agentProfileLocalMcpServerSchema = z.strictObject({
|
|
4459
|
-
transport: z.literal("stdio").optional(),
|
|
4460
|
-
command: nonBlankMcpValueSchema.refine(isSafeExecutable, "local MCP command must be a canonical public executable"),
|
|
4461
|
-
args: z.array(agentProfileConfigValueSchema).max(CONTRACT_MAX_ARRAY_LENGTH).optional(),
|
|
4462
|
-
env: agentProfileEnvironmentSchema.optional(),
|
|
4463
|
-
cwd: z.string().refine((value) => isSafeRelativePath(value, true), "local MCP cwd must be a canonical workspace-relative path").optional(),
|
|
4464
|
-
url: z.undefined().optional(),
|
|
4465
|
-
headers: z.undefined().optional(),
|
|
4466
|
-
enabled: z.literal(true).optional(),
|
|
4467
|
-
metadata: ownPropertyRecordSchema(profileOpaqueValueSchema).optional()
|
|
4468
|
-
});
|
|
4469
|
-
const agentProfileRemoteMcpServerSchema = z.strictObject({
|
|
4470
|
-
transport: z.enum(["sse", "http"]).optional(),
|
|
4471
|
-
command: z.undefined().optional(),
|
|
4472
|
-
args: z.undefined().optional(),
|
|
4473
|
-
env: z.undefined().optional(),
|
|
4474
|
-
cwd: z.undefined().optional(),
|
|
4475
|
-
url: remoteMcpUrlSchema,
|
|
4476
|
-
headers: agentProfileHeaderSchema.optional(),
|
|
4477
|
-
enabled: z.literal(true).optional(),
|
|
4478
|
-
metadata: ownPropertyRecordSchema(profileOpaqueValueSchema).optional()
|
|
4479
|
-
});
|
|
4480
|
-
const agentProfileDisabledMcpServerSchema = z.strictObject({
|
|
4481
|
-
enabled: z.literal(false),
|
|
4482
|
-
transport: z.undefined().optional(),
|
|
4483
|
-
command: z.undefined().optional(),
|
|
4484
|
-
args: z.undefined().optional(),
|
|
4485
|
-
env: z.undefined().optional(),
|
|
4486
|
-
cwd: z.undefined().optional(),
|
|
4487
|
-
url: z.undefined().optional(),
|
|
4488
|
-
headers: z.undefined().optional(),
|
|
4489
|
-
metadata: ownPropertyRecordSchema(profileOpaqueValueSchema).optional()
|
|
4490
|
-
});
|
|
4491
|
-
const agentProfileMcpServerSchema = z.union([
|
|
4492
|
-
agentProfileLocalMcpServerSchema,
|
|
4493
|
-
agentProfileRemoteMcpServerSchema,
|
|
4494
|
-
agentProfileDisabledMcpServerSchema
|
|
4495
|
-
]);
|
|
4496
|
-
const agentProfileConnectionSchema = z.strictObject({
|
|
4497
|
-
connectionId: z.string().min(1),
|
|
4498
|
-
capabilities: z.array(z.string().min(1)).max(CONTRACT_MAX_ARRAY_LENGTH).min(1),
|
|
4499
|
-
alias: z.string().min(1).optional()
|
|
4500
|
-
});
|
|
4501
|
-
const removeListSchema = z.union([z.literal(true), z.array(z.string().min(1)).max(CONTRACT_MAX_ARRAY_LENGTH)]);
|
|
4502
|
-
const agentProfilePromptRemovalSchema = z.strictObject({
|
|
4503
|
-
systemPrompt: z.literal(true).optional(),
|
|
4504
|
-
appendSystemPrompt: z.literal(true).optional(),
|
|
4505
|
-
instructions: removeListSchema.optional()
|
|
4506
|
-
});
|
|
4507
|
-
const agentProfileResourceRemovalSchema = z.strictObject({
|
|
4508
|
-
knowledge: removeListSchema.optional(),
|
|
4509
|
-
files: removeListSchema.optional(),
|
|
4510
|
-
tools: removeListSchema.optional(),
|
|
4511
|
-
skills: removeListSchema.optional(),
|
|
4512
|
-
agents: removeListSchema.optional(),
|
|
4513
|
-
commands: removeListSchema.optional(),
|
|
4514
|
-
instructions: z.literal(true).optional(),
|
|
4515
|
-
failOnError: z.literal(true).optional()
|
|
4516
|
-
});
|
|
4517
|
-
const agentProfileDiffRemovalSchema = z.strictObject({
|
|
4518
|
-
identity: z.literal(true).optional(),
|
|
4519
|
-
tags: removeListSchema.optional(),
|
|
4520
|
-
prompt: z.union([z.literal(true), agentProfilePromptRemovalSchema]).optional(),
|
|
4521
|
-
model: removeListSchema.optional(),
|
|
4522
|
-
harness: z.literal(true).optional(),
|
|
4523
|
-
seats: z.literal(true).optional(),
|
|
4524
|
-
proxySecrets: z.literal(true).optional(),
|
|
4525
|
-
permissions: removeListSchema.optional(),
|
|
4526
|
-
tools: removeListSchema.optional(),
|
|
4527
|
-
mcp: removeListSchema.optional(),
|
|
4528
|
-
connections: removeListSchema.optional(),
|
|
4529
|
-
subagents: removeListSchema.optional(),
|
|
4530
|
-
resources: z.union([z.literal(true), agentProfileResourceRemovalSchema]).optional(),
|
|
4531
|
-
hooks: removeListSchema.optional(),
|
|
4532
|
-
modes: removeListSchema.optional(),
|
|
4533
|
-
confidential: z.literal(true).optional(),
|
|
4534
|
-
metadata: removeListSchema.optional(),
|
|
4535
|
-
extensions: removeListSchema.optional()
|
|
4536
|
-
});
|
|
4537
|
-
const trainingIdentitySchema = z.string().min(1).max(500).refine((value) => value.trim() === value && isWellFormedUnicode(value) && !controlCharacterPattern.test(value) && !looksLikeCredential(value), "training identity must be canonical public text");
|
|
4538
|
-
const agentTrainingTaskSchema = z.strictObject({
|
|
4539
|
-
benchmark: trainingIdentitySchema,
|
|
4540
|
-
task: trainingIdentitySchema,
|
|
4541
|
-
contentDigest: sha256DigestSchema
|
|
4542
|
-
});
|
|
4543
|
-
/** The same order is used by dataset ingestion, receipt admission and holdout checks. */
|
|
4544
|
-
function agentTrainingTaskKey(task) {
|
|
4545
|
-
return JSON.stringify([
|
|
4546
|
-
task.benchmark,
|
|
4547
|
-
task.task,
|
|
4548
|
-
task.contentDigest
|
|
4549
|
-
]);
|
|
4550
|
-
}
|
|
4551
|
-
const agentTrainingDatasetIdentitySchema = z.strictObject({
|
|
4552
|
-
digest: sha256DigestSchema,
|
|
4553
|
-
taskSetDigest: sha256DigestSchema,
|
|
4554
|
-
tasks: z.array(agentTrainingTaskSchema).min(1).max(1e4)
|
|
4555
|
-
}).superRefine((dataset, context) => {
|
|
4556
|
-
const keys = dataset.tasks.map(agentTrainingTaskKey);
|
|
4557
|
-
if (keys.some((key, index) => index > 0 && key <= keys[index - 1])) context.addIssue({
|
|
4558
|
-
code: "custom",
|
|
4559
|
-
path: ["tasks"],
|
|
4560
|
-
message: "training tasks must be sorted and unique"
|
|
4561
|
-
});
|
|
4562
|
-
if (canonicalCandidateDigest(dataset.tasks) !== dataset.taskSetDigest) context.addIssue({
|
|
4563
|
-
code: "custom",
|
|
4564
|
-
path: ["taskSetDigest"],
|
|
4565
|
-
message: "training task inventory digest mismatch"
|
|
4566
|
-
});
|
|
4567
|
-
});
|
|
4568
|
-
const agentTrainingParametersSchema = ownPropertyRecordSchema(z.union([
|
|
4569
|
-
z.string().max(2048).pipe(publicProfileConfigStringSchema),
|
|
4570
|
-
z.number().finite(),
|
|
4571
|
-
z.boolean(),
|
|
4572
|
-
z.null()
|
|
4573
|
-
]), { maxEntries: 100 }).superRefine((parameters, context) => {
|
|
4574
|
-
for (const name of Object.keys(parameters)) if (!trainingIdentitySchema.safeParse(name).success || isCredentialBearingProfileConfigName(name)) context.addIssue({
|
|
4575
|
-
code: "custom",
|
|
4576
|
-
path: [name],
|
|
4577
|
-
message: "training parameter name must be public and non-credential"
|
|
4578
|
-
});
|
|
4579
|
-
});
|
|
4580
|
-
const agentTrainingReceiptSchema = z.strictObject({
|
|
4581
|
-
version: z.literal(1),
|
|
4582
|
-
dataset: agentTrainingDatasetIdentitySchema,
|
|
4583
|
-
parentProfileDigest: sha256DigestSchema,
|
|
4584
|
-
parentReceiptDigest: sha256DigestSchema.nullable(),
|
|
4585
|
-
executionRef: sha256DigestSchema,
|
|
4586
|
-
trainer: z.strictObject({
|
|
4587
|
-
mode: z.enum(["command", "managed"]),
|
|
4588
|
-
id: trainingIdentitySchema,
|
|
4589
|
-
revision: sha256DigestSchema,
|
|
4590
|
-
parameters: agentTrainingParametersSchema
|
|
4591
|
-
}),
|
|
4592
|
-
checkpoint: z.strictObject({
|
|
4593
|
-
artifactDigest: sha256DigestSchema,
|
|
4594
|
-
artifactBytes: z.number().int().positive().max(Number.MAX_SAFE_INTEGER),
|
|
4595
|
-
routerModelId: trainingIdentitySchema,
|
|
4596
|
-
servingDigest: sha256DigestSchema
|
|
4597
|
-
})
|
|
4598
|
-
}).superRefine((receipt, context) => {
|
|
4599
|
-
if (receipt.checkpoint.routerModelId !== trainedModelIdForArtifact(receipt.checkpoint.artifactDigest)) context.addIssue({
|
|
4600
|
-
code: "custom",
|
|
4601
|
-
path: ["checkpoint", "routerModelId"],
|
|
4602
|
-
message: "trained Router model must be artifact-addressed"
|
|
4603
|
-
});
|
|
4604
|
-
});
|
|
4605
|
-
const agentProfileTrainingSchema = z.strictObject({
|
|
4606
|
-
receipt: agentTrainingReceiptSchema,
|
|
4607
|
-
ancestors: z.array(agentTrainingReceiptSchema).max(8)
|
|
4608
|
-
}).superRefine((training, context) => {
|
|
4609
|
-
const chain = [training.receipt, ...training.ancestors];
|
|
4610
|
-
const digests = chain.map(canonicalCandidateDigest);
|
|
4611
|
-
if (new Set(digests).size !== digests.length) context.addIssue({
|
|
4612
|
-
code: "custom",
|
|
4613
|
-
message: "training receipt ancestry must not repeat"
|
|
4614
|
-
});
|
|
4615
|
-
for (let index = 0; index < chain.length; index++) if (chain[index].parentReceiptDigest !== (digests[index + 1] ?? null)) context.addIssue({
|
|
4616
|
-
code: "custom",
|
|
4617
|
-
message: "training receipt ancestry is incomplete or has been altered"
|
|
4618
|
-
});
|
|
4619
|
-
});
|
|
4620
|
-
const agentProfileMetadataSchema = ownPropertyRecordSchema(z.unknown(), { prepareValue: (key, value) => {
|
|
4621
|
-
if (key === "training") return value;
|
|
4622
|
-
if (value === void 0 || isBoundedJsonMaterial(value, {
|
|
4623
|
-
dataPropertiesOnly: true,
|
|
4624
|
-
content: true
|
|
4625
|
-
})) return structuredClone(value);
|
|
4626
|
-
assertAgentProfileValue(value, [key]);
|
|
4627
|
-
return z.NEVER;
|
|
4628
|
-
} }).superRefine((metadata, context) => {
|
|
4629
|
-
if (!Object.hasOwn(metadata, "training")) return;
|
|
4630
|
-
const result = agentProfileTrainingSchema.safeParse(metadata.training);
|
|
4631
|
-
if (result.success) metadata.training = result.data;
|
|
4632
|
-
else {
|
|
4633
|
-
delete metadata.training;
|
|
4634
|
-
for (const issue of result.error.issues) context.addIssue({
|
|
4635
|
-
code: "custom",
|
|
4636
|
-
path: ["training", ...issue.path],
|
|
4637
|
-
message: issue.message,
|
|
4638
|
-
continue: false
|
|
4639
|
-
});
|
|
4640
|
-
}
|
|
4641
|
-
});
|
|
4642
|
-
/**
|
|
4643
|
-
* The complete provider-neutral agent profile schema — the runtime validator for
|
|
4644
|
-
* the canonical {@link AgentProfile} TS contract. Kept structurally in lock-step
|
|
4645
|
-
* with that interface by the compile-time guard at the bottom of this file.
|
|
4646
|
-
*/
|
|
4647
|
-
const agentProfileSchema = z.strictObject({
|
|
4648
|
-
name: z.string().optional(),
|
|
4649
|
-
description: z.string().optional(),
|
|
4650
|
-
version: z.string().optional(),
|
|
4651
|
-
tags: z.array(z.string()).max(CONTRACT_MAX_ARRAY_LENGTH).optional(),
|
|
4652
|
-
prompt: agentProfilePromptSchema.optional(),
|
|
4653
|
-
model: agentProfileModelHintsSchema.optional(),
|
|
4654
|
-
harness: harnessTypeSchema.optional(),
|
|
4655
|
-
seats: z.array(agentProfileSeatSchema).max(CONTRACT_MAX_ARRAY_LENGTH).nonempty().optional(),
|
|
4656
|
-
proxySecrets: ProxySecretsSchema.optional(),
|
|
4657
|
-
permissions: ownPropertyRecordSchema(agentProfilePermissionSchema).optional(),
|
|
4658
|
-
tools: ownPropertyRecordSchema(z.boolean()).optional(),
|
|
4659
|
-
mcp: ownPropertyRecordSchema(agentProfileMcpServerSchema).optional(),
|
|
4660
|
-
connections: z.array(agentProfileConnectionSchema).max(CONTRACT_MAX_ARRAY_LENGTH).optional(),
|
|
4661
|
-
subagents: ownPropertyRecordSchema(agentSubagentProfileSchema).optional(),
|
|
4662
|
-
resources: agentProfileResourcesSchema.optional(),
|
|
4663
|
-
hooks: ownPropertyRecordSchema(z.array(agentProfileHookCommandSchema).max(CONTRACT_MAX_ARRAY_LENGTH)).optional(),
|
|
4664
|
-
modes: ownPropertyRecordSchema(agentProfileModeSchema).optional(),
|
|
4665
|
-
confidential: agentProfileConfidentialSchema.optional(),
|
|
4666
|
-
metadata: agentProfileMetadataSchema.optional(),
|
|
4667
|
-
extensions: ownPropertyRecordSchema(z.union([ownPropertyRecordSchema(profileOpaqueValueSchema), z.undefined()])).optional()
|
|
4668
|
-
}).superRefine((profile, context) => {
|
|
4669
|
-
validateNestedRecordKeys(profile, context, [], /* @__PURE__ */ new Set());
|
|
4670
|
-
if (profile.seats?.length) {
|
|
4671
|
-
const first = profile.seats[0];
|
|
4672
|
-
if (first.harness !== profile.harness || first.provider !== profile.model?.provider || first.model !== profile.model?.default) context.addIssue({
|
|
4673
|
-
code: "custom",
|
|
4674
|
-
path: ["seats", 0],
|
|
4675
|
-
message: "first seat must match profile harness, model.provider, and model.default"
|
|
4676
|
-
});
|
|
4677
|
-
if (first.reasoningEffort !== void 0 && first.reasoningEffort !== profile.model?.reasoningEffort) context.addIssue({
|
|
4678
|
-
code: "custom",
|
|
4679
|
-
path: [
|
|
4680
|
-
"seats",
|
|
4681
|
-
0,
|
|
4682
|
-
"reasoningEffort"
|
|
4683
|
-
],
|
|
4684
|
-
message: "first seat reasoningEffort must match profile model.reasoningEffort"
|
|
4685
|
-
});
|
|
4686
|
-
if (first.tools !== void 0 && canonicalAgentProfileJson(first.tools) !== canonicalAgentProfileJson(profile.tools)) context.addIssue({
|
|
4687
|
-
code: "custom",
|
|
4688
|
-
path: [
|
|
4689
|
-
"seats",
|
|
4690
|
-
0,
|
|
4691
|
-
"tools"
|
|
4692
|
-
],
|
|
4693
|
-
message: "first seat tools must match profile tools"
|
|
4694
|
-
});
|
|
4695
|
-
if (first.permissions !== void 0 && canonicalAgentProfileJson(first.permissions) !== canonicalAgentProfileJson(profile.permissions)) context.addIssue({
|
|
4696
|
-
code: "custom",
|
|
4697
|
-
path: [
|
|
4698
|
-
"seats",
|
|
4699
|
-
0,
|
|
4700
|
-
"permissions"
|
|
4701
|
-
],
|
|
4702
|
-
message: "first seat permissions must match profile permissions"
|
|
4703
|
-
});
|
|
4704
|
-
for (const [index, seat] of profile.seats.entries()) {
|
|
4705
|
-
if (resolveModelProvider(seat.model) !== seat.provider) context.addIssue({
|
|
4706
|
-
code: "custom",
|
|
4707
|
-
path: [
|
|
4708
|
-
"seats",
|
|
4709
|
-
index,
|
|
4710
|
-
"provider"
|
|
4711
|
-
],
|
|
4712
|
-
message: "seat provider must match the model provider"
|
|
4713
|
-
});
|
|
4714
|
-
if (!harnessHonorsModel(seat.harness)) context.addIssue({
|
|
4715
|
-
code: "custom",
|
|
4716
|
-
path: [
|
|
4717
|
-
"seats",
|
|
4718
|
-
index,
|
|
4719
|
-
"harness"
|
|
4720
|
-
],
|
|
4721
|
-
message: "seat harness does not honor an exact model choice"
|
|
4722
|
-
});
|
|
4723
|
-
const effort = seat.reasoningEffort ?? profile.model?.reasoningEffort;
|
|
4724
|
-
const support = harnessModelSupport(seat.harness, seat.model, { reasoningEffort: effort });
|
|
4725
|
-
if (!support.supported) context.addIssue({
|
|
4726
|
-
code: "custom",
|
|
4727
|
-
path: [
|
|
4728
|
-
"seats",
|
|
4729
|
-
index,
|
|
4730
|
-
"model"
|
|
4731
|
-
],
|
|
4732
|
-
message: support.message
|
|
4733
|
-
});
|
|
4734
|
-
if (effort !== void 0 && (!harnessHonorsEffort(seat.harness) || !harnessReasoningEfforts(seat.harness).includes(effort))) context.addIssue({
|
|
4735
|
-
code: "custom",
|
|
4736
|
-
path: [
|
|
4737
|
-
"seats",
|
|
4738
|
-
index,
|
|
4739
|
-
"reasoningEffort"
|
|
4740
|
-
],
|
|
4741
|
-
message: "seat harness cannot honor the stage reasoning effort"
|
|
4742
|
-
});
|
|
4743
|
-
const prompt = harnessSystemPromptIntents(seat.harness);
|
|
4744
|
-
if (profile.prompt?.systemPrompt !== void 0 && !prompt.replace) context.addIssue({
|
|
4745
|
-
code: "custom",
|
|
4746
|
-
path: [
|
|
4747
|
-
"seats",
|
|
4748
|
-
index,
|
|
4749
|
-
"harness"
|
|
4750
|
-
],
|
|
4751
|
-
message: "seat harness cannot replace the system prompt"
|
|
4752
|
-
});
|
|
4753
|
-
if (profile.prompt?.appendSystemPrompt !== void 0 && !prompt.append) context.addIssue({
|
|
4754
|
-
code: "custom",
|
|
4755
|
-
path: [
|
|
4756
|
-
"seats",
|
|
4757
|
-
index,
|
|
4758
|
-
"harness"
|
|
4759
|
-
],
|
|
4760
|
-
message: "seat harness cannot append the system prompt"
|
|
4761
|
-
});
|
|
4762
|
-
}
|
|
4763
|
-
}
|
|
4764
|
-
const training = agentProfileTrainingSchema.safeParse(profile.metadata?.training);
|
|
4765
|
-
if (profile.model?.default?.startsWith("tangle-trained/") && !training.success) context.addIssue({
|
|
4766
|
-
code: "custom",
|
|
4767
|
-
path: ["metadata", "training"],
|
|
4768
|
-
message: "trained model requires a checkpoint receipt"
|
|
4769
|
-
});
|
|
4770
|
-
if ([
|
|
4771
|
-
profile.model?.small,
|
|
4772
|
-
...Object.values(profile.subagents ?? {}).map((agent) => agent.model),
|
|
4773
|
-
...Object.values(profile.modes ?? {}).map((mode) => mode.model)
|
|
4774
|
-
].some((model) => model?.startsWith("tangle-trained/") && (!training.success || model !== training.data.receipt.checkpoint.routerModelId))) context.addIssue({
|
|
4775
|
-
code: "custom",
|
|
4776
|
-
message: "trained auxiliary models require the same receipted checkpoint"
|
|
4777
|
-
});
|
|
4778
|
-
if (training.success && profile.model?.default !== training.data.receipt.checkpoint.routerModelId) context.addIssue({
|
|
4779
|
-
code: "custom",
|
|
4780
|
-
path: ["model", "default"],
|
|
4781
|
-
message: "trained profile model must equal the receipt's Router model"
|
|
4782
|
-
});
|
|
4783
|
-
});
|
|
4784
|
-
const encodedRecordKeyPattern = "^u(?:[0-9a-f]{4})*$";
|
|
4785
|
-
function isEncodedRecordKeyPropertyNames(value) {
|
|
4786
|
-
if (value === null || typeof value !== "object" || Array.isArray(value)) return false;
|
|
4787
|
-
const propertyNames = value;
|
|
4788
|
-
return propertyNames.type === "string" && propertyNames.pattern === encodedRecordKeyPattern;
|
|
4789
|
-
}
|
|
4790
|
-
function removeModelInputSchemaArtifacts(value) {
|
|
4791
|
-
if (Array.isArray(value)) return value.map(removeModelInputSchemaArtifacts);
|
|
4792
|
-
if (value === null || typeof value !== "object") return value;
|
|
4793
|
-
const result = {};
|
|
4794
|
-
for (const [key, entry] of Object.entries(value)) {
|
|
4795
|
-
if (key === "$schema") continue;
|
|
4796
|
-
if (key === "propertyNames" && isEncodedRecordKeyPropertyNames(entry)) continue;
|
|
4797
|
-
result[key] = removeModelInputSchemaArtifacts(entry);
|
|
4798
|
-
}
|
|
4799
|
-
return result;
|
|
4800
|
-
}
|
|
4801
|
-
removeModelInputSchemaArtifacts(z.toJSONSchema(agentProfileSchema, {
|
|
4802
|
-
target: "draft-2020-12",
|
|
4803
|
-
io: "input",
|
|
4804
|
-
unrepresentable: "any"
|
|
4805
|
-
}));
|
|
4806
|
-
function validateNestedRecordKeys(value, context, path, seen) {
|
|
4807
|
-
if (value === null || typeof value !== "object" || seen.has(value)) return;
|
|
4808
|
-
seen.add(value);
|
|
4809
|
-
for (const [key, entry] of Object.entries(value)) {
|
|
4810
|
-
if (!isWellFormedUnicode(key)) context.addIssue({
|
|
4811
|
-
code: "custom",
|
|
4812
|
-
path: [...path, key],
|
|
4813
|
-
message: "record keys must contain valid Unicode"
|
|
4814
|
-
});
|
|
4815
|
-
validateNestedRecordKeys(entry, context, [...path, key], seen);
|
|
4816
|
-
}
|
|
4817
|
-
}
|
|
4818
|
-
z.strictObject({
|
|
4819
|
-
kind: z.literal("agent-profile-diff"),
|
|
4820
|
-
id: z.string().min(1).optional(),
|
|
4821
|
-
title: z.string().min(1).optional(),
|
|
4822
|
-
description: z.string().optional(),
|
|
4823
|
-
rationale: z.string().optional(),
|
|
4824
|
-
source: z.strictObject({
|
|
4825
|
-
kind: z.enum([
|
|
4826
|
-
"trace",
|
|
4827
|
-
"frontier-author",
|
|
4828
|
-
"human",
|
|
4829
|
-
"optimizer",
|
|
4830
|
-
"compound"
|
|
4831
|
-
]),
|
|
4832
|
-
artifacts: z.array(z.string().min(1)).max(CONTRACT_MAX_ARRAY_LENGTH).optional(),
|
|
4833
|
-
notes: z.array(z.string()).max(CONTRACT_MAX_ARRAY_LENGTH).optional()
|
|
4834
|
-
}).optional(),
|
|
4835
|
-
set: agentProfileSchema.optional(),
|
|
4836
|
-
remove: agentProfileDiffRemovalSchema.optional(),
|
|
4837
|
-
metadata: ownPropertyRecordSchema(profileOpaqueValueSchema).optional()
|
|
4838
|
-
});
|
|
4839
|
-
z.strictObject({
|
|
4840
|
-
id: z.string().min(1),
|
|
4841
|
-
definition: agentProfileSchema,
|
|
4842
|
-
recommendedSize: z.enum(SANDBOX_SIZE_PRESET_NAMES).optional()
|
|
4843
|
-
});
|
|
4844
|
-
//#endregion
|
|
4845
|
-
//#region ../../../node_modules/.pnpm/@tangle-network+agent-interface@5.10.11/node_modules/@tangle-network/agent-interface/dist/runtime-attachments.js
|
|
4846
|
-
const AgentRuntimeAttachmentsSchema = boundedJsonSchema.pipe(z.strictObject({ mcp: agentProfileSchema.shape.mcp.unwrap().superRefine((servers, context) => {
|
|
4847
|
-
for (const alias of Object.keys(servers)) {
|
|
4848
|
-
const result = boundedIdentifierSchema.safeParse(alias);
|
|
4849
|
-
if (!result.success) for (const issue of result.error.issues) context.addIssue({
|
|
4850
|
-
...issue,
|
|
4851
|
-
path: [alias, ...issue.path]
|
|
4852
|
-
});
|
|
4853
|
-
}
|
|
4854
|
-
}) }));
|
|
4855
|
-
//#endregion
|
|
4856
3262
|
//#region ../../../packages/agent-profile-materialize/dist/index.js
|
|
4857
3263
|
const compareStrings = (a, b) => a < b ? -1 : a > b ? 1 : 0;
|
|
4858
3264
|
constants.O_WRONLY | constants.O_CREAT | constants.O_EXCL | (typeof constants.O_NOFOLLOW === "number" ? constants.O_NOFOLLOW : 0);
|
|
@@ -9538,7 +7944,7 @@ var InteractiveSessionHandle = class {
|
|
|
9538
7944
|
options?.signal?.throwIfAborted();
|
|
9539
7945
|
const binding = this.requireBinding();
|
|
9540
7946
|
const exactCommand = AgentInteractiveSessionPromptCommandSchema.parse(command);
|
|
9541
|
-
if (canonicalCandidateDigest
|
|
7947
|
+
if (canonicalCandidateDigest(exactCommand.ref) !== canonicalCandidateDigest(binding.ref) || canonicalCandidateDigest(exactCommand.control) !== canonicalCandidateDigest(binding.control)) throw new Error(`Interactive session ${this.sessionId} prompt is bound to a different exact ref`);
|
|
9542
7948
|
return (options === void 0 ? this.host._sendInteractivePrompt(this.sessionId, exactCommand) : this.host._sendInteractivePrompt(this.sessionId, exactCommand, options)).then((acknowledgement) => {
|
|
9543
7949
|
const exactAcknowledgement = AgentInteractiveSessionPromptAcknowledgementSchema.parse(acknowledgement);
|
|
9544
7950
|
if (!agentInteractiveSessionPromptAcknowledgementMatchesCommand(exactCommand, exactAcknowledgement)) throw new Error(`Interactive session ${this.sessionId} prompt acknowledgement does not match the command`);
|
|
@@ -9616,8 +8022,8 @@ var InteractiveSessionHandle = class {
|
|
|
9616
8022
|
options?.signal?.throwIfAborted();
|
|
9617
8023
|
const binding = this.requireBinding();
|
|
9618
8024
|
const exactRequest = AgentInteractiveSessionAttachSchema.parse(request);
|
|
9619
|
-
if (!agentInteractiveSessionControlClaimMatchesRef(binding.ref, exactRequest.control) || canonicalCandidateDigest
|
|
9620
|
-
const requestDigest = canonicalCandidateDigest
|
|
8025
|
+
if (!agentInteractiveSessionControlClaimMatchesRef(binding.ref, exactRequest.control) || canonicalCandidateDigest(exactRequest.control) !== canonicalCandidateDigest(binding.control)) throw new Error(`Interactive session ${this.sessionId} terminal attach is bound to a different active control claim`);
|
|
8026
|
+
const requestDigest = canonicalCandidateDigest(exactRequest);
|
|
9621
8027
|
if (this.agentTerminalAttachInFlight !== void 0) {
|
|
9622
8028
|
if (this.agentTerminalAttachDigest !== requestDigest) throw new Error(`Interactive session ${this.sessionId} cannot attach with a different terminal request while another attach is in flight`);
|
|
9623
8029
|
return awaitWithAbort(this.agentTerminalAttachInFlight, options?.signal);
|
|
@@ -9670,7 +8076,7 @@ var InteractiveSessionHandle = class {
|
|
|
9670
8076
|
options?.signal?.throwIfAborted();
|
|
9671
8077
|
const ref = this.requireRef();
|
|
9672
8078
|
const exactRequest = AgentInteractiveSessionControlClaimRequestSchema.parse(request);
|
|
9673
|
-
if (canonicalCandidateDigest
|
|
8079
|
+
if (canonicalCandidateDigest(exactRequest.ref) !== canonicalCandidateDigest(ref)) throw new Error(`Interactive session ${this.sessionId} control claim is bound to a different exact ref`);
|
|
9674
8080
|
return this.host._claimInteractiveControl(this.sessionId, exactRequest, options).then((acknowledgement) => {
|
|
9675
8081
|
const exactAcknowledgement = AgentInteractiveSessionControlClaimAcknowledgementSchema.parse(acknowledgement);
|
|
9676
8082
|
if (!agentInteractiveSessionControlClaimAcknowledgementMatchesRequest(exactRequest, exactAcknowledgement)) throw new Error(`Interactive session ${this.sessionId} control claim acknowledgement does not match the request`);
|
|
@@ -9685,7 +8091,7 @@ var InteractiveSessionHandle = class {
|
|
|
9685
8091
|
options?.signal?.throwIfAborted();
|
|
9686
8092
|
const binding = this.requireBinding();
|
|
9687
8093
|
const exactCommand = AgentInteractiveSessionStopCommandSchema.parse(command);
|
|
9688
|
-
if (canonicalCandidateDigest
|
|
8094
|
+
if (canonicalCandidateDigest(exactCommand.ref) !== canonicalCandidateDigest(binding.ref) || canonicalCandidateDigest(exactCommand.control) !== canonicalCandidateDigest(binding.control)) throw new Error(`Interactive session ${this.sessionId} stop is bound to a different exact ref`);
|
|
9689
8095
|
return (options === void 0 ? this.host._stopInteractive(this.sessionId, exactCommand) : this.host._stopInteractive(this.sessionId, exactCommand, options)).then((acknowledgement) => {
|
|
9690
8096
|
const exactAcknowledgement = AgentInteractiveSessionStopAcknowledgementSchema.parse(acknowledgement);
|
|
9691
8097
|
if (!agentInteractiveSessionStopAcknowledgementMatchesCommand(exactCommand, exactAcknowledgement)) throw new Error(`Interactive session ${this.sessionId} stop acknowledgement does not match the command`);
|
|
@@ -9697,7 +8103,7 @@ var InteractiveSessionHandle = class {
|
|
|
9697
8103
|
const ref = this.requireRef();
|
|
9698
8104
|
return (options === void 0 ? this.host._stopInteractiveLifecycle(this.sessionId, ref) : this.host._stopInteractiveLifecycle(this.sessionId, ref, options)).then((acknowledgement) => {
|
|
9699
8105
|
const exactAcknowledgement = AgentInteractiveSessionStopAcknowledgementSchema.parse(acknowledgement);
|
|
9700
|
-
if (canonicalCandidateDigest
|
|
8106
|
+
if (canonicalCandidateDigest(exactAcknowledgement.ref) !== canonicalCandidateDigest(ref)) throw new Error(`Interactive session ${this.sessionId} lifecycle stop acknowledgement does not match the exact ref`);
|
|
9701
8107
|
if (exactAcknowledgement.status !== "accepted" && exactAcknowledgement.status !== "replayed") throw new Error(`Interactive session ${this.sessionId} lifecycle stop was not confirmed (${exactAcknowledgement.status})`);
|
|
9702
8108
|
if (exactAcknowledgement.effect === "unknown") throw new Error(`Interactive session ${this.sessionId} lifecycle stop returned an unknown outcome`);
|
|
9703
8109
|
return exactAcknowledgement;
|
|
@@ -9901,7 +8307,7 @@ var SandboxRuntimeOperations = class extends SandboxLifecycleCapabilities {
|
|
|
9901
8307
|
});
|
|
9902
8308
|
if (!response.ok) throw parseErrorResponse(response.status, await response.text());
|
|
9903
8309
|
const value = await readResponseJson(response);
|
|
9904
|
-
const pending = value && typeof value === "object" && "proxySecretReceipt" in value ? ProxySecretReceiptSchema
|
|
8310
|
+
const pending = value && typeof value === "object" && "proxySecretReceipt" in value ? ProxySecretReceiptSchema.safeParse(value.proxySecretReceipt) : void 0;
|
|
9905
8311
|
if (!value || typeof value !== "object" || (pending ? !pending.success || pending.data.status !== "proxy-installed" || pending.data.sandboxId !== this.id || !pending.data.bindings.length || pending.data.bindings.some((binding) => binding.secretRef.key !== cliAuth.secretEnv) || "installed" in value : !("installed" in value) || value.installed !== true) || !("harness" in value) || value.harness !== grant.harness || !("cliAuth" in value)) throw new StateError("Native credential grant receipt is invalid", { currentState: "unconfirmed" });
|
|
9906
8312
|
const confirmed = cliAuthReferenceSchema.safeParse(value.cliAuth);
|
|
9907
8313
|
if (!confirmed.success || confirmed.data.account !== cliAuth.account || confirmed.data.secretEnv !== cliAuth.secretEnv || confirmed.data.format !== cliAuth.format) throw new StateError("Native credential grant receipt names another reference", { currentState: "unconfirmed" });
|
|
@@ -10406,7 +8812,7 @@ var SandboxProfileCapabilities = class extends SandboxFileWriteCapabilities {
|
|
|
10406
8812
|
* Throws on transport/HTTP failure; a turn then sends the profile inline.
|
|
10407
8813
|
*/
|
|
10408
8814
|
async primeProfile(profile, options = {}) {
|
|
10409
|
-
const parsed = agentProfileSchema
|
|
8815
|
+
const parsed = agentProfileSchema.safeParse(profile);
|
|
10410
8816
|
if (!parsed.success) throw new ValidationError("Profile priming requires an AgentProfile object");
|
|
10411
8817
|
if (options.preserveManagedProfile) {
|
|
10412
8818
|
const snapshot = JSON.parse(JSON.stringify(profile));
|
|
@@ -10748,7 +9154,7 @@ const interactionResolutionDeliveryStateSchema = z.enum([
|
|
|
10748
9154
|
const interactionResolutionAcknowledgementSchema = z.strictObject({
|
|
10749
9155
|
status: z.enum(["accepted", "already_resolved_same"]),
|
|
10750
9156
|
operationId: z.string().min(1),
|
|
10751
|
-
responseDigest: sha256DigestSchema
|
|
9157
|
+
responseDigest: sha256DigestSchema,
|
|
10752
9158
|
interactionId: z.string().min(1),
|
|
10753
9159
|
sessionId: z.string().min(1),
|
|
10754
9160
|
outcome: z.enum([
|
|
@@ -10776,7 +9182,7 @@ const InteractionConflictEnvelopeSchema = z.object({
|
|
|
10776
9182
|
code: z.string().min(1),
|
|
10777
9183
|
message: z.string().min(1),
|
|
10778
9184
|
status: REFUSED_INTERACTION_STATUS.or(z.string()),
|
|
10779
|
-
existingResponseDigest: sha256DigestSchema
|
|
9185
|
+
existingResponseDigest: sha256DigestSchema.optional(),
|
|
10780
9186
|
existingOperationId: z.string().min(1).optional(),
|
|
10781
9187
|
resolvedAt: z.string().min(1).optional()
|
|
10782
9188
|
})
|
|
@@ -10805,7 +9211,7 @@ function bindingsEqual(left, right) {
|
|
|
10805
9211
|
return left.requestDigest === right.requestDigest && left.runId === right.runId && left.provider === right.provider && left.environmentId === right.environmentId && left.sessionId === right.sessionId && left.executionId === right.executionId && left.interactionId === right.interactionId;
|
|
10806
9212
|
}
|
|
10807
9213
|
function assertResolutionMatches(resolution, sessionId, submitted, response, endpoint) {
|
|
10808
|
-
const expectedDigest = canonicalCandidateDigest
|
|
9214
|
+
const expectedDigest = canonicalCandidateDigest(submitted);
|
|
10809
9215
|
if (resolution.sessionId !== sessionId || resolution.interactionId !== submitted.id || resolution.outcome !== submitted.outcome || resolution.responseDigest !== expectedDigest) throw invalidRuntimeResponse("Sidecar returned a resolution for another interaction response", response, endpoint);
|
|
10810
9216
|
}
|
|
10811
9217
|
/** Parse one interaction response without discarding replay information. */
|
|
@@ -11735,7 +10141,7 @@ var SandboxInteractiveCapabilities = class extends SandboxPromptCapabilities {
|
|
|
11735
10141
|
origin: "runtime",
|
|
11736
10142
|
endpoint: `/agents/sessions/${encodeURIComponent(id)}/interactive`
|
|
11737
10143
|
});
|
|
11738
|
-
if (canonicalCandidateDigest
|
|
10144
|
+
if (canonicalCandidateDigest(status.ref) !== canonicalCandidateDigest(exactCommand.ref)) throw new ValidationError("Interactive prompt ref or control does not match the session");
|
|
11739
10145
|
const endpoint = `/agents/sessions/${encodeURIComponent(id)}/interactive/prompt`;
|
|
11740
10146
|
const response = await this.runtimeFetch(endpoint, {
|
|
11741
10147
|
method: "POST",
|
|
@@ -11923,7 +10329,7 @@ var SandboxInteractiveCapabilities = class extends SandboxPromptCapabilities {
|
|
|
11923
10329
|
origin: "runtime"
|
|
11924
10330
|
});
|
|
11925
10331
|
const acknowledgement = parsed.data.data;
|
|
11926
|
-
if (canonicalCandidateDigest
|
|
10332
|
+
if (canonicalCandidateDigest(acknowledgement.ref) !== canonicalCandidateDigest(exactRef)) throw new ServerError("Interactive lifecycle stop acknowledgement does not match the exact ref", {
|
|
11927
10333
|
status: 502,
|
|
11928
10334
|
endpoint,
|
|
11929
10335
|
origin: "runtime"
|
|
@@ -11936,7 +10342,7 @@ var SandboxInteractiveCapabilities = class extends SandboxPromptCapabilities {
|
|
|
11936
10342
|
var SandboxSessionEvidenceCapabilities = class extends SandboxInteractiveCapabilities {
|
|
11937
10343
|
/** @internal — invoked before the sandbox is deleted. */
|
|
11938
10344
|
async _sessionExportRawEvidence(id, destination, options) {
|
|
11939
|
-
const { exportRawEvidenceDirectory } = await import("./raw-evidence-archive-
|
|
10345
|
+
const { exportRawEvidenceDirectory } = await import("./raw-evidence-archive-DYaA-RPM.js");
|
|
11940
10346
|
await this.ensureRunning();
|
|
11941
10347
|
await this.refresh();
|
|
11942
10348
|
return exportRawEvidenceDirectory((signal, archiveId, cancel) => this.runtimeFetch(`/agents/sessions/${encodeURIComponent(id)}/raw-evidence/archive?${new URLSearchParams([
|
|
@@ -11967,7 +10373,7 @@ var SandboxSessionEvidenceCapabilities = class extends SandboxInteractiveCapabil
|
|
|
11967
10373
|
* and the byte and file bounds are verified before the directory appears.
|
|
11968
10374
|
*/
|
|
11969
10375
|
async exportRawEvidence(destination, options) {
|
|
11970
|
-
const { exportRawEvidenceDirectory } = await import("./raw-evidence-archive-
|
|
10376
|
+
const { exportRawEvidenceDirectory } = await import("./raw-evidence-archive-DYaA-RPM.js");
|
|
11971
10377
|
await this.ensureRunning();
|
|
11972
10378
|
await this.refresh();
|
|
11973
10379
|
return exportRawEvidenceDirectory((signal, archiveId, cancel) => this.runtimeFetch(`/agents/raw-evidence/archive?${new URLSearchParams({
|
|
@@ -14533,7 +12939,7 @@ var SandboxInteractiveTerminalOperations = class {
|
|
|
14533
12939
|
endpoint: `/agents/sessions/${encodeURIComponent(id)}/interactive`,
|
|
14534
12940
|
code: "INTERACTIVE_SESSION_EXITED"
|
|
14535
12941
|
});
|
|
14536
|
-
if (canonicalCandidateDigest
|
|
12942
|
+
if (canonicalCandidateDigest(status.ref) !== canonicalCandidateDigest(exactRef)) throw new ValidationError("Interactive attach ref does not match the current session");
|
|
14537
12943
|
return exactRef;
|
|
14538
12944
|
}
|
|
14539
12945
|
/**
|