@tangle-network/sandbox 0.69.11 → 0.69.13

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.
Files changed (77) hide show
  1. package/dist/agent/index.d.ts +4 -4
  2. package/dist/agent/index.js +5 -5
  3. package/dist/agent/preview.d.ts +1 -1
  4. package/dist/agent/preview.js +3 -3
  5. package/dist/{agent-run-outcome-B5CzWxw4.d.ts → agent-run-outcome-BuebRCWr.d.ts} +2 -2
  6. package/dist/{api-request-D1UVNo16.js → api-request-EseiF9B1.js} +1 -1
  7. package/dist/auth/index.d.ts +2 -2
  8. package/dist/auth/index.js +1 -1
  9. package/dist/browser-interactive-control-controller-Bt1vcu9c.js +4045 -0
  10. package/dist/{browser-interactive-control-controller-SI9hV6r5.d.ts → browser-interactive-control-controller-CVnME80O.d.ts} +5 -7
  11. package/dist/{chunked-upload-l6b9AWFA.js → chunked-upload-Df_5Q2x8.js} +1 -1
  12. package/dist/{chunked-upload-file-CLwAeLrM.js → chunked-upload-file-Dtm1GBkE.js} +2 -2
  13. package/dist/cli-auth-bundle-3LBcaEqw.js +2593 -0
  14. package/dist/{client-Ds3As2SY.d.ts → client-BWnbrifs.d.ts} +40 -42
  15. package/dist/{client-D6b3wBnI.js → client-D-6z6BJb.js} +11 -11
  16. package/dist/collaboration/index.d.ts +1 -1
  17. package/dist/collaboration/index.js +1 -1
  18. package/dist/{collaboration-BwLNv6sy.js → collaboration-BTGTf3We.js} +1 -1
  19. package/dist/{core-BhSZIdRK.js → core-EqIoRKiQ.js} +5 -4
  20. package/dist/core.d.ts +6 -6
  21. package/dist/core.js +5 -5
  22. package/dist/{direct-http2-Pyj3Rvr1.js → direct-http2-B0ra_xhU.js} +1 -1
  23. package/dist/{errors-Bs5G7JdV.js → errors-ZmDrrk4f.js} +1 -1
  24. package/dist/harness-BD_OISom.js +201 -0
  25. package/dist/harness-DWL2MM4q.js +418 -0
  26. package/dist/{index-nXob5TkM.d.ts → index-DdcCRDq8.d.ts} +14 -16
  27. package/dist/index.d.ts +11 -11
  28. package/dist/index.js +11 -11
  29. package/dist/intelligence/index.js +2 -2
  30. package/dist/interactive-control.d.ts +1 -1
  31. package/dist/interactive-control.js +1 -1
  32. package/dist/{interactive-controller-DSDEfapN.js → interactive-controller-B4bQwRJL.js} +21 -8
  33. package/dist/{interactive-controller-FgmcS8_Y.d.ts → interactive-controller-DlFKGQqu.d.ts} +3 -4
  34. package/dist/lib/prepared-evidence.js +1 -1
  35. package/dist/lib/prepared-process.js +1 -1
  36. package/dist/{lines-D_HDAcVt.js → lines-BqZOl_io.js} +1 -1
  37. package/dist/{lines-BoVYnUCM.d.ts → lines-ptj8SyD4.d.ts} +1 -1
  38. package/dist/lines.d.ts +1 -1
  39. package/dist/lines.js +1 -1
  40. package/dist/{local-cli-auth-DaU64laN.js → local-cli-auth-BBdGF3wf.js} +1 -1
  41. package/dist/{mcp-local-Gz1Uygqk.js → mcp-local-BcRLN_Ic.js} +1 -1
  42. package/dist/{prepared-evidence-DUmJSegi.js → prepared-evidence-CuUh_mz6.js} +1 -1
  43. package/dist/{preview-7EJ_80nL.d.ts → preview-ByTCKjiK.d.ts} +3 -3
  44. package/dist/profile-schema-CT3hB1mG.js +1135 -0
  45. package/dist/{public-templates-B6_uwnRZ.d.ts → public-templates-O2mxBX7J.d.ts} +2 -2
  46. package/dist/public-templates.d.ts +1 -1
  47. package/dist/public-templates.js +1 -1
  48. package/dist/{raw-evidence-archive-D60Yg1-5.js → raw-evidence-archive-CqarcYcp.js} +1 -1
  49. package/dist/runtime.d.ts +5 -5
  50. package/dist/runtime.js +5 -5
  51. package/dist/{sandbox-DVOrtcTK.js → sandbox-eUPdjk1p.js} +384 -46
  52. package/dist/{secp256k1-DxHlUI6v.js → secp256k1-CZWrpqxW.js} +1 -1
  53. package/dist/select-seat-command.d.ts +1 -1
  54. package/dist/select-seat-command.js +1 -1
  55. package/dist/session-gateway/index.js +3 -3
  56. package/dist/sha2-BUPMvGTk.js +694 -0
  57. package/dist/tangle/index.d.ts +1 -1
  58. package/dist/tangle/index.js +1 -1
  59. package/dist/{tangle-Br7yT7X8.js → tangle-BmhK_E7e.js} +4 -4
  60. package/dist/terminal-stream-types-DwXQzUbH.d.ts +3328 -0
  61. package/dist/{types-CkLWX7i5.d.ts → types-B28t5Sq1.d.ts} +10 -12
  62. package/package.json +6 -6
  63. package/dist/browser-interactive-control-controller-CLHNi8rG.js +0 -292
  64. package/dist/cli-auth-bundle-B1Mpf18p.js +0 -1590
  65. package/dist/terminal-stream-types-DuzvL1ge.d.ts +0 -676
  66. /package/dist/{abort-signal-BKVZNJul.js → abort-signal-jU-SEjLT.js} +0 -0
  67. /package/dist/{cli-auth-bundle-CeNOYFje.d.ts → cli-auth-bundle-MskLEgtA.d.ts} +0 -0
  68. /package/dist/{index-C0RkLba5.d.ts → index-Dqcr9p97.d.ts} +0 -0
  69. /package/dist/{index-DaIF4c9p.d.ts → index-Dslyq85a.d.ts} +0 -0
  70. /package/dist/{keep-alive-fetch-Bi-zvHpN.js → keep-alive-fetch-C2DX2_rG.js} +0 -0
  71. /package/dist/{prepared-process-Dlk_9JVJ.js → prepared-process-LjBfQnZ5.js} +0 -0
  72. /package/dist/{preview-operations-eTUlPen5.js → preview-operations-BvgwYaoL.js} +0 -0
  73. /package/dist/{response-rewrap-BKkJ5hnn.js → response-rewrap-MBztoTLx.js} +0 -0
  74. /package/dist/{retry-after-header-U_L5Ml9Q.js → retry-after-header-BZbs5rig.js} +0 -0
  75. /package/dist/{sidecar-proxy-error-B2Hxt41g.js → sidecar-proxy-error-Dty4zmN7.js} +0 -0
  76. /package/dist/{sse-parser-CUfurwcm.js → sse-parser-DmO5gP6u.js} +0 -0
  77. /package/dist/{utils-DB8DnUCU.js → utils-vaFoyyiO.js} +0 -0
@@ -0,0 +1,1135 @@
1
+ import { S as boundedIdentifierSchema, _ as CONTRACT_MAX_ARRAY_LENGTH, a as agentCandidateSecretRefSchema, c as environmentNameSchema, d as isSafeExecutable, f as isSafeRelativePath, g as sha256DigestSchema, i as trainedModelIdForArtifact, l as headerNameSchema, m as looksLikeCredential, n as REASONING_EFFORTS, o as canonicalCandidateDigest, p as isWellFormedUnicode, s as canonicalCandidateJson, t as harnessTypeSchema } from "./harness-DWL2MM4q.js";
2
+ import { z } from "zod";
3
+ //#region ../../../node_modules/.pnpm/@tangle-network+agent-interface@5.8.1/node_modules/@tangle-network/agent-interface/dist/profile-knowledge.js
4
+ /** Immutable Hub generation identities, never aliases such as latest or a caller's scope. */
5
+ const agentProfileKnowledgeRefSchema = z.strictObject({
6
+ sourceId: z.string().regex(/^[A-Za-z0-9_-]{1,128}$/),
7
+ generation: z.string().regex(/^kg_[a-f0-9]{64}$/)
8
+ });
9
+ const agentProfileKnowledgeRefsSchema = z.array(agentProfileKnowledgeRefSchema).max(16).superRefine((refs, context) => {
10
+ const seen = /* @__PURE__ */ new Set();
11
+ refs.forEach((ref, index) => {
12
+ if (seen.has(ref.sourceId)) context.addIssue({
13
+ code: "custom",
14
+ path: [index, "sourceId"],
15
+ message: "A profile must pin exactly one generation per knowledge source"
16
+ });
17
+ seen.add(ref.sourceId);
18
+ });
19
+ });
20
+ //#endregion
21
+ //#region ../../../node_modules/.pnpm/@tangle-network+agent-interface@5.8.1/node_modules/@tangle-network/agent-interface/dist/agent-profile-canonical.js
22
+ /**
23
+ * Normalize profile-shaped data into the canonical JSON domain used for public
24
+ * profile identity. Undefined object entries are omitted; unsupported values,
25
+ * sparse arrays, and cycles are rejected with their profile path.
26
+ *
27
+ * This module is intentionally internal. Public callers should use the
28
+ * profile-level operations that own validation, identity, or diff semantics.
29
+ */
30
+ function canonicalAgentProfileValue(value) {
31
+ return normalizeAgentProfileValue(value, [], /* @__PURE__ */ new Set());
32
+ }
33
+ /** Canonical serialization after applying AgentProfile normalization rules. */
34
+ function canonicalAgentProfileJson(value) {
35
+ const normalized = canonicalAgentProfileValue(value);
36
+ return normalized === void 0 ? void 0 : canonicalCandidateJson(normalized);
37
+ }
38
+ function normalizeAgentProfileValue(value, path, ancestors) {
39
+ if (value === void 0) return void 0;
40
+ if (value === null || typeof value === "boolean" || typeof value === "string") return value;
41
+ if (typeof value === "number") {
42
+ if (!Number.isFinite(value)) throw new Error(`AgentProfile ${renderPath(path)} must be finite`);
43
+ return value;
44
+ }
45
+ if (typeof value !== "object") throw new Error(`AgentProfile ${renderPath(path)} is not JSON serializable`);
46
+ if (ancestors.has(value)) throw new Error(`AgentProfile ${renderPath(path)} must be acyclic`);
47
+ const prototype = Object.getPrototypeOf(value);
48
+ if (!Array.isArray(value) && prototype !== Object.prototype && prototype !== null) throw new Error(`AgentProfile ${renderPath(path)} must be a plain JSON object`);
49
+ const nextAncestors = new Set(ancestors).add(value);
50
+ if (Array.isArray(value)) return Array.from({ length: value.length }, (_, index) => {
51
+ if (!Object.prototype.hasOwnProperty.call(value, index)) throw new Error(`AgentProfile ${renderPath([...path, index])} cannot be a sparse array hole`);
52
+ const entry = value[index];
53
+ const normalized = normalizeAgentProfileValue(entry, [...path, index], nextAncestors);
54
+ if (normalized === void 0) throw new Error(`AgentProfile ${renderPath([...path, index])} cannot be undefined`);
55
+ return normalized;
56
+ });
57
+ const material = Object.create(null);
58
+ for (const [key, entry] of Object.entries(value)) {
59
+ if (!isWellFormedUnicode(key)) throw new Error(`AgentProfile ${renderPath(path)} has a record key that is not valid Unicode`);
60
+ const normalized = normalizeAgentProfileValue(entry, [...path, key], nextAncestors);
61
+ if (normalized !== void 0) Object.defineProperty(material, key, {
62
+ value: normalized,
63
+ enumerable: true,
64
+ configurable: true,
65
+ writable: true
66
+ });
67
+ }
68
+ return material;
69
+ }
70
+ function renderPath(path) {
71
+ return path.length === 0 ? "root" : path.join(".");
72
+ }
73
+ //#endregion
74
+ //#region ../../../node_modules/.pnpm/@tangle-network+agent-interface@5.8.1/node_modules/@tangle-network/agent-interface/dist/own-property-record.js
75
+ /**
76
+ * Zod records currently assign parsed values onto an ordinary object. The
77
+ * special own key `__proto__` therefore invokes the legacy prototype setter
78
+ * and disappears instead of being validated. Encode every own key before Zod
79
+ * sees it, then restore the exact UTF-16 key with defineProperty so all string
80
+ * keys allowed by `Record<string, ...>` remain data rather than object syntax.
81
+ */
82
+ function ownPropertyRecordSchema(valueSchema) {
83
+ return z.preprocess(encodeOwnRecordKeys, z.record(z.string().regex(/^u(?:[0-9a-f]{4})*$/, "record keys must contain valid Unicode"), valueSchema).transform((record) => {
84
+ const restored = {};
85
+ for (const [encodedKey, value] of Object.entries(record)) Object.defineProperty(restored, decodeRecordKey(encodedKey), {
86
+ value,
87
+ enumerable: true,
88
+ configurable: true,
89
+ writable: true
90
+ });
91
+ return restored;
92
+ }));
93
+ }
94
+ function encodeOwnRecordKeys(value) {
95
+ if (value === null || typeof value !== "object" || Array.isArray(value)) return value;
96
+ const prototype = Object.getPrototypeOf(value);
97
+ if (prototype !== Object.prototype && prototype !== null) return [];
98
+ const encoded = Object.create(null);
99
+ for (const [key, entry] of Object.entries(value)) encoded[encodeRecordKey(key)] = entry;
100
+ return encoded;
101
+ }
102
+ function encodeRecordKey(value) {
103
+ let encoded = isWellFormedUnicode(value) ? "u" : "i";
104
+ for (let index = 0; index < value.length; index += 1) encoded += value.charCodeAt(index).toString(16).padStart(4, "0");
105
+ return encoded;
106
+ }
107
+ function decodeRecordKey(value) {
108
+ let decoded = "";
109
+ for (let index = 1; index < value.length; index += 4) decoded += String.fromCharCode(Number.parseInt(value.slice(index, index + 4), 16));
110
+ return decoded;
111
+ }
112
+ //#endregion
113
+ //#region ../../../node_modules/.pnpm/@tangle-network+agent-interface@5.8.1/node_modules/@tangle-network/agent-interface/dist/proxy-secrets.js
114
+ /**
115
+ * Declarations request authority, never grant it. Trusted resolution uses authenticated tenant
116
+ * and issuer authority, with no personal/team fallback, and pins immutable secret ID/revision.
117
+ * The issuer intersects requested scope/expiry with its policy and authenticated lineage.
118
+ * Placeholders are independent unpredictable values per sandbox epoch, generated by the trusted
119
+ * lifecycle owner, never from secret bytes or public refs. JWT placeholders carry only synthetic
120
+ * public sub/aud/exp compatibility claims, no upstream claims, account identity or authority.
121
+ * The sandbox is the isolation boundary; these schemas cannot authenticate guest processes.
122
+ */
123
+ const unique = (values) => new Set(values).size === values.length;
124
+ 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");
125
+ const methodSchema = z.string().max(32).regex(/^[A-Z]+$/);
126
+ /** Paths are exact or terminal slash-star subtrees. /v1/* includes /v1/ and /v1/a, never /v1
127
+ * or /v10. V1 rejects all percent encoding, dot segments, repeated slashes, query, fragments,
128
+ * backslashes, non-ASCII and controls, rather than normalizing ambiguous spellings.
129
+ */
130
+ const pathSchema = z.string().max(2048).refine((path) => {
131
+ const exact = path.endsWith("/*") ? path.slice(0, -1) : path;
132
+ return /^\/[A-Za-z0-9._~!$&'()+,;=:@/-]*$/.test(exact) && !exact.includes("//") && !exact.split("/").some((part) => part === "." || part === "..");
133
+ }, "path must be canonical ASCII, exact or a terminal /* subtree");
134
+ const list = (schema) => z.array(schema).min(1).max(CONTRACT_MAX_ARRAY_LENGTH).refine(unique, "selectors must be unique");
135
+ const envNameSchema = z.string().max(256).regex(/^[A-Za-z_][A-Za-z0-9_]*$/);
136
+ const headerSchema = z.string().max(256).regex(/^[!#$%&'*+.^_\x60|~0-9A-Za-z-]+$/).refine((name) => ![
137
+ "authorization",
138
+ "proxy-authorization",
139
+ "proxy-authenticate",
140
+ "host",
141
+ "connection",
142
+ "keep-alive",
143
+ "proxy-connection",
144
+ "content-length",
145
+ "transfer-encoding",
146
+ "trailer",
147
+ "upgrade",
148
+ "te"
149
+ ].includes(name.toLowerCase()), "use bearer/basic for Authorization; routing and framing headers cannot carry secrets");
150
+ /** Match complete components only. Selected header names are case-insensitive; duplicate fields
151
+ * are refused before coalescing. Query names are case-sensitive after one strict UTF-8 percent
152
+ * decode (+ means space); malformed encoding and duplicate decoded selector names are refused.
153
+ * Never scan other query fields. Basic is one strict base64 value decoding to exactly public
154
+ * username:placeholder; the username is printable ASCII without colon. Bearer is exactly
155
+ * "Bearer SP placeholder". Embedded placeholders never match. Authority, TLS SNI and validated
156
+ * destination must agree on the declared FQDN over HTTPS/443; explicit :443 is equivalent.
157
+ */
158
+ const ProxySecretPresentationSchema = z.discriminatedUnion("type", [
159
+ z.strictObject({ type: z.literal("bearer") }),
160
+ z.strictObject({
161
+ type: z.literal("basic"),
162
+ username: z.string().min(1).max(256).regex(/^[\x21-\x39\x3b-\x7e]+$/)
163
+ }),
164
+ z.strictObject({
165
+ type: z.literal("header"),
166
+ name: headerSchema
167
+ }),
168
+ z.strictObject({
169
+ type: z.literal("query"),
170
+ name: z.string().max(256).regex(/^[A-Za-z0-9._~-]+$/)
171
+ })
172
+ ]);
173
+ const ProxySecretScopeSchema = z.strictObject({
174
+ hosts: list(hostSchema).readonly(),
175
+ methods: list(methodSchema).readonly().optional(),
176
+ paths: list(pathSchema).readonly().optional()
177
+ });
178
+ ProxySecretScopeSchema.strip();
179
+ const ProxySecretBindingSchema = ProxySecretScopeSchema.extend({
180
+ envName: envNameSchema,
181
+ secretRef: agentCandidateSecretRefSchema.omit({ format: true }),
182
+ presentation: ProxySecretPresentationSchema,
183
+ placeholderFormat: z.enum(["opaque", "jwt"]).optional(),
184
+ ttlSeconds: z.number().int().positive().max(Number.MAX_SAFE_INTEGER).optional()
185
+ });
186
+ 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");
187
+ ownPropertyRecordSchema(boundedIdentifierSchema.nullable()).refine((parents) => Object.keys(parents).length <= 1024 && Object.keys(parents).every((name) => envNameSchema.safeParse(name).success), "invalid parent selection keys");
188
+ z.literal(1);
189
+ const ProxySecretResolvedIdentitySchema = z.strictObject({
190
+ tenantId: boundedIdentifierSchema,
191
+ issuerId: boundedIdentifierSchema,
192
+ secretId: boundedIdentifierSchema,
193
+ revision: boundedIdentifierSchema
194
+ });
195
+ const timestamp = z.iso.datetime();
196
+ const ProxySecretGrantSchema = z.strictObject({
197
+ protocolVersion: z.literal(1),
198
+ grantId: boundedIdentifierSchema,
199
+ sandboxId: boundedIdentifierSchema,
200
+ epoch: boundedIdentifierSchema,
201
+ identity: ProxySecretResolvedIdentitySchema,
202
+ scope: ProxySecretScopeSchema,
203
+ presentation: ProxySecretPresentationSchema,
204
+ placeholderFormat: z.enum(["opaque", "jwt"]),
205
+ issuedAt: timestamp,
206
+ expiresAt: timestamp,
207
+ sourceExpiresAt: timestamp.optional(),
208
+ parentGrantId: boundedIdentifierSchema.optional()
209
+ }).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");
210
+ const receiptShape = {
211
+ protocolVersion: z.literal(1),
212
+ sandboxId: boundedIdentifierSchema,
213
+ generation: z.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER),
214
+ bindings: z.array(z.strictObject({
215
+ envName: envNameSchema,
216
+ secretRef: agentCandidateSecretRefSchema.omit({ format: true }),
217
+ grant: ProxySecretGrantSchema
218
+ })).max(CONTRACT_MAX_ARRAY_LENGTH),
219
+ proxyAcknowledged: z.literal(true)
220
+ };
221
+ z.discriminatedUnion("status", [
222
+ z.strictObject({
223
+ ...receiptShape,
224
+ status: z.literal("proxy-installed"),
225
+ materializationAcknowledged: z.literal(false)
226
+ }),
227
+ z.strictObject({
228
+ ...receiptShape,
229
+ status: z.literal("installed"),
230
+ materializationAcknowledged: z.literal(true)
231
+ }),
232
+ z.strictObject({
233
+ ...receiptShape,
234
+ status: z.literal("revoked"),
235
+ materializationAcknowledged: z.literal(true)
236
+ })
237
+ ]).superRefine((receipt, ctx) => {
238
+ if (!unique(receipt.bindings.map((binding) => binding.envName)) || !unique(receipt.bindings.map((binding) => binding.grant.grantId))) ctx.addIssue({
239
+ code: "custom",
240
+ path: ["bindings"],
241
+ message: "receipt binding names and grant IDs must be unique"
242
+ });
243
+ if (receipt.bindings.some((binding) => binding.grant.sandboxId !== receipt.sandboxId)) ctx.addIssue({
244
+ code: "custom",
245
+ path: ["bindings"],
246
+ message: "receipt grants must belong to its sandbox"
247
+ });
248
+ if (new Set(receipt.bindings.map((binding) => binding.grant.epoch)).size > 1) ctx.addIssue({
249
+ code: "custom",
250
+ path: ["bindings"],
251
+ message: "receipt grants must share one sandbox lifecycle epoch"
252
+ });
253
+ if (receipt.status === "revoked" && receipt.bindings.length !== 0) ctx.addIssue({
254
+ code: "custom",
255
+ path: ["bindings"],
256
+ message: "revoked receipt cannot retain bindings"
257
+ });
258
+ });
259
+ z.strictObject({
260
+ protocolVersion: z.literal(1),
261
+ supportedDrivers: list(boundedIdentifierSchema),
262
+ presentations: list(z.enum([
263
+ "bearer",
264
+ "basic",
265
+ "header",
266
+ "query"
267
+ ])),
268
+ placeholderFormats: list(z.enum(["opaque", "jwt"])),
269
+ enforcement: z.literal("exact"),
270
+ transports: z.tuple([z.literal("https:443")]),
271
+ lifecycle: z.literal(true),
272
+ placementReceiptRequired: z.literal(true)
273
+ });
274
+ z.strictObject({
275
+ expectedProxySecretGeneration: z.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER).optional(),
276
+ requireInPlace: z.boolean().optional()
277
+ });
278
+ //#endregion
279
+ //#region ../../../node_modules/.pnpm/@tangle-network+agent-interface@5.8.1/node_modules/@tangle-network/agent-interface/dist/harness-capabilities.js
280
+ /** Canonical harness/model, effort and prompt controls. Model-specific capability comes from the serving catalog. */
281
+ /** low → high. `none` = thinking off; `ultracode` = max (claude-code mode). */
282
+ const reasoningLadder = REASONING_EFFORTS;
283
+ /**
284
+ * Vendor locks, before the measured {@link harnessModelExclusions}. Absent means router-backed.
285
+ * Claude Code and Codex run any Router model: their native vendor wire passes through for vendor
286
+ * models and translates others to chat completions (including images/tools; hosted tools drop).
287
+ * A caller's vendor key/login remains vendor-limited; this table does not know credentials.
288
+ * NanoClaw also routes every provider through the Router, so it has no Anthropic lock.
289
+ * {@link vendorHarness} chooses a default harness; it is not a provider restriction.
290
+ */
291
+ const harnessProviderLock = { "kimi-code": ["moonshot"] };
292
+ /** Provider prefix of a canonical model id (`anthropic/claude-…` → `anthropic`), or null. */
293
+ function modelProvider(modelId) {
294
+ const slash = modelId.indexOf("/");
295
+ return slash > 0 ? modelId.slice(0, slash) : null;
296
+ }
297
+ /**
298
+ * Model families whose bare ids belong to one provider. The Router catalog serves most ids without a
299
+ * prefix (`claude-sonnet-5-5`, `gpt-5.5`, `glm-5.3`) and names the provider beside them, so a check
300
+ * that read every bare id as "any provider" offered `claude-code` with `glm-5.3`.
301
+ */
302
+ const bareModelFamilyProviders = [
303
+ [/^claude-/, "anthropic"],
304
+ [/^(gpt-|chatgpt-|codex-|o\d+(-|$))/, "openai"],
305
+ [/^(kimi-|moonshot-)/, "moonshot"],
306
+ [/^gemini-/, "google"],
307
+ [/^glm-/, "zai"],
308
+ [/^deepseek-/, "deepseek"],
309
+ [/^grok-/, "xai"]
310
+ ];
311
+ /**
312
+ * The provider a model id belongs to: its explicit prefix, else the provider of its bare-id family
313
+ * (`claude-sonnet-5-5` → `anthropic`). `null` for an id outside every family, such as the `default`
314
+ * sentinel, whose provider only the serving harness knows.
315
+ */
316
+ function resolveModelProvider(modelId) {
317
+ const explicit = modelProvider(modelId);
318
+ if (explicit) return explicit;
319
+ const id = modelId.trim().toLowerCase();
320
+ for (const [family, provider] of bareModelFamilyProviders) if (family.test(id)) return provider;
321
+ return null;
322
+ }
323
+ /** The providers a harness is locked to, or `null` when it is router-backed (any model). */
324
+ function harnessProviders(harness) {
325
+ return harnessProviderLock[harness] ?? null;
326
+ }
327
+ const SANDBOX_HARNESS_MATRIX_EVIDENCE = "https://github.com/tangle-network/agent-container/issues/9382";
328
+ /**
329
+ * Pairs a router-backed harness cannot run, measured on production with the Router credential: one
330
+ * prompt per pair, profile reasoning effort `medium` (2026-10-05). The same run passed pi with
331
+ * `openai/gpt-5.5` and `zai/glm-5.3`, and opencode with every model listed here. Pairs not listed
332
+ * were not measured to fail. An entry is removed when its harness adapter or the Router is fixed and
333
+ * the pair passes a new production measurement.
334
+ *
335
+ * pi's chat-completions client (pi-ai 0.85.1) marks a model as reasoning only when the profile asks
336
+ * for a reasoning effort, and only a reasoning model is sent the `developer` role and
337
+ * `reasoning_effort`; that is why the first two entries need a reasoning effort.
338
+ */
339
+ const harnessModelExclusions = [
340
+ {
341
+ harness: "pi",
342
+ models: /^anthropic\//,
343
+ onlyWithReasoningEffort: true,
344
+ reason: "the Router's chat-completions route for Anthropic models rejects the \"developer\" role pi sends to a reasoning model (400 Unexpected role \"developer\")",
345
+ measuredOn: "2026-10-05",
346
+ evidence: SANDBOX_HARNESS_MATRIX_EVIDENCE
347
+ },
348
+ {
349
+ harness: "pi",
350
+ models: /^openai\/gpt-5\.6-luna$/,
351
+ onlyWithReasoningEffort: true,
352
+ reason: "OpenAI does not accept function tools together with reasoning_effort for this model on /v1/chat/completions, the only route pi speaks",
353
+ measuredOn: "2026-10-05",
354
+ evidence: SANDBOX_HARNESS_MATRIX_EVIDENCE
355
+ },
356
+ {
357
+ harness: "pi",
358
+ models: /^google\/gemini-3\.8-flash$/,
359
+ onlyWithReasoningEffort: false,
360
+ 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)",
361
+ measuredOn: "2026-10-05",
362
+ evidence: SANDBOX_HARNESS_MATRIX_EVIDENCE
363
+ }
364
+ ];
365
+ /**
366
+ * Whether a harness can run a model, and why not. A bare id resolves its provider through
367
+ * {@link resolveModelProvider}; an id whose provider cannot be resolved (a sentinel like `default`)
368
+ * is left to the harness, because its provider only the serving harness knows. A vendor-locked
369
+ * harness refuses every other provider; a router-backed harness refuses only the measured
370
+ * {@link harnessModelExclusions}.
371
+ */
372
+ function harnessModelSupport(harness, modelId, options = {}) {
373
+ const trimmed = modelId.trim();
374
+ const provider = resolveModelProvider(trimmed);
375
+ const model = provider !== null && modelProvider(trimmed) === null ? `${provider}/${trimmed}` : trimmed;
376
+ if (provider === null) return {
377
+ supported: true,
378
+ model,
379
+ provider
380
+ };
381
+ const allowedProviders = harnessProviders(harness);
382
+ if (allowedProviders && !allowedProviders.includes(provider)) return {
383
+ supported: false,
384
+ model,
385
+ provider,
386
+ allowedProviders,
387
+ 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.`
388
+ };
389
+ const reasoning = options.reasoningEffort !== void 0 && options.reasoningEffort !== null && options.reasoningEffort !== "none";
390
+ const exclusion = harnessModelExclusions.find((entry) => entry.harness === harness && entry.models.test(model) && (!entry.onlyWithReasoningEffort || reasoning));
391
+ if (exclusion) return {
392
+ supported: false,
393
+ model,
394
+ provider,
395
+ exclusion,
396
+ 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.")
397
+ };
398
+ return {
399
+ supported: true,
400
+ model,
401
+ provider
402
+ };
403
+ }
404
+ new Intl.Collator(void 0, {
405
+ numeric: true,
406
+ sensitivity: "base"
407
+ });
408
+ /**
409
+ * The explicit reasoning-effort set a harness's runtime accepts when it ISN'T a plain `none…ceiling`
410
+ * slice — measured against the pinned CLI binaries, NOT inferred from the canonical ladder:
411
+ * - codex: `model_reasoning_effort` accepts `none|minimal|low|medium|high|xhigh|max`, plus `ultra`
412
+ * which the API's own enumeration omits but accepts end-to-end; canonical `ultracode` maps to
413
+ * native `ultra`. Per-model catalog data narrows this list.
414
+ * - claude-code: `--effort` accepts `low|medium|high|xhigh|max`; canonical `ultracode` maps to
415
+ * native `max`. It cannot express `none` or `minimal`, and an unsupported value is warned about
416
+ * and silently replaced with the default rather than rejected — so the set must not overstate.
417
+ * - pi: `--thinking` accepts `off|minimal|low|medium|high|xhigh`; canonical `none` maps to
418
+ * `off` and `ultracode` clamps to `xhigh`, its top rung.
419
+ * - prime: the prime fork of the pi line accepts the same `--thinking` set
420
+ * (`off|minimal|low|medium|high|xhigh|max`); canonical `none` maps to `off` and `ultracode` to
421
+ * `max`.
422
+ * - openclaw: `--thinking` accepts `off|minimal|low|medium|high|xhigh|max` (and `adaptive`, which
423
+ * defers the choice rather than naming a rung); canonical `none` maps to `off` and `ultracode`
424
+ * to `max`.
425
+ * - kimi-code: `--thinking` is binary. Canonical `none` emits `--no-thinking`; any non-none level
426
+ * emits `--thinking`, represented here by `high`.
427
+ */
428
+ const harnessReasoningEffortsOverride = {
429
+ "claude-code": [
430
+ "low",
431
+ "medium",
432
+ "high",
433
+ "xhigh",
434
+ "ultracode"
435
+ ],
436
+ "kimi-code": ["none", "high"]
437
+ };
438
+ /**
439
+ * The ceiling for harnesses whose set IS a plain `none…ceiling` slice. Only the no-thinking runners
440
+ * need an entry (`cli-base` has no agent; `nanoclaw` sends no thinking flag). Harnesses with a
441
+ * provider-clamped or non-contiguous set live in {@link harnessReasoningEffortsOverride}; router /
442
+ * model-driven harnesses (opencode, gemini, …) have no entry → default to the full ladder, narrowed
443
+ * by the model's own capability.
444
+ */
445
+ const harnessReasoningCeiling = {
446
+ "cli-base": "none",
447
+ nanoclaw: "none"
448
+ };
449
+ /** The reasoning efforts a harness can express, independent of model — its explicit override set, or
450
+ * `none` up to its ceiling (default `ultracode` for router/model-driven harnesses). */
451
+ function harnessReasoningEfforts(harness) {
452
+ const override = harnessReasoningEffortsOverride[harness];
453
+ if (override) return override;
454
+ const ceiling = harnessReasoningCeiling[harness] ?? "ultracode";
455
+ return reasoningLadder.slice(0, reasoningLadder.indexOf(ceiling) + 1);
456
+ }
457
+ /**
458
+ * Harnesses whose runner DROPS a per-turn selector — grounded in the cli-bridge adapter audit, NOT a
459
+ * guess. Most harnesses honor both selectors, so only the exceptions are listed; a harness absent from
460
+ * a set honors that selector.
461
+ *
462
+ * - model dropped: `amp` (own agent picks the model), `openclaw` (dispatcher routes by its own
463
+ * config), `nanoclaw` (socket-bridge runner is config/env-driven).
464
+ * - effort dropped: `amp`, `factory-droids`, `hermes`, `nanoclaw`, and `acp` (no thinking flag is
465
+ * plumbed to the underlying CLI — the runner reads no `reasoningEffort`).
466
+ *
467
+ * This is distinct from {@link reasoningEffortsFor} (which levels a harness can EXPRESS): a picker uses
468
+ * these to trim or mark harnesses up front, so a user's model/effort choice is never silently ignored.
469
+ */
470
+ const harnessIgnoresModel = new Set([
471
+ "amp",
472
+ "openclaw",
473
+ "nanoclaw"
474
+ ]);
475
+ const harnessIgnoresEffort = new Set([
476
+ "amp",
477
+ "factory-droids",
478
+ "hermes",
479
+ "nanoclaw",
480
+ "acp"
481
+ ]);
482
+ /** Whether the harness's runner honors a per-turn MODEL override (vs. picking the model itself). */
483
+ function harnessHonorsModel(harness) {
484
+ return !harnessIgnoresModel.has(harness);
485
+ }
486
+ /** Whether the harness's runner honors a reasoning-EFFORT override (vs. dropping it). */
487
+ function harnessHonorsEffort(harness) {
488
+ return !harnessIgnoresEffort.has(harness);
489
+ }
490
+ /**
491
+ * The system-prompt intents a harness's own controls can execute, measured by reading the request
492
+ * each installed CLI sends — NOT taken from its help text:
493
+ *
494
+ * - claude-code 2.1.222 and pi 0.83.0 own both. `--system-prompt` drops the built-in prompt from
495
+ * the request (27,673 B → the caller's bytes on claude-code, 2,582 B → the caller's on pi);
496
+ * `--append-system-prompt` leaves it in place and adds the caller's text after it.
497
+ * - codex 0.146.0 owns replacement only: the `model_instructions_file` config key becomes the
498
+ * request's entire instructions text. It has no additive control — its AGENTS.md lands in a
499
+ * developer/user message, not the system channel.
500
+ * - gemini 0.26.0 owns replacement only: `.gemini/system.md` under `GEMINI_SYSTEM_MD=1` replaces
501
+ * the base prompt. Its one additive path is GEMINI.md memory, which IS the `instructions`
502
+ * surface, so an addition lowered there would be byte-indistinguishable from `instructions`.
503
+ * - opencode 1.17.18 owns addition only THROUGH A WORKSPACE: config-declared `instructions[]`
504
+ * files compose into the same single `role: "system"` message as its built-in prompt, which
505
+ * stays in place. Its replacement control (`agent.<name>.prompt`) binds to one agent chosen at
506
+ * launch, which a workspace plan cannot guarantee — but an executor that selects that agent
507
+ * can, so `replace: false` here is the plan-forwarding answer, not opencode's ceiling.
508
+ *
509
+ * Every other harness owns NEITHER, including the ones whose prompt path is a `role: "system"` chat
510
+ * message: that message is flattened into the user turn before the CLI sees it, so it is not a
511
+ * system-prompt channel at all — honoring an intent through it would put the caller's text in
512
+ * ordinary user content while the harness's own prompt ran unchanged. A harness with no entry
513
+ * refuses both, so one added later cannot inherit a capability by omission.
514
+ */
515
+ const harnessSystemPromptControls = {
516
+ "claude-code": {
517
+ replace: true,
518
+ append: true
519
+ },
520
+ pi: {
521
+ replace: true,
522
+ append: true
523
+ },
524
+ prime: {
525
+ replace: true,
526
+ append: true
527
+ },
528
+ codex: {
529
+ replace: true,
530
+ append: false
531
+ },
532
+ gemini: {
533
+ replace: true,
534
+ append: false
535
+ },
536
+ opencode: {
537
+ replace: false,
538
+ append: true
539
+ }
540
+ };
541
+ const noSystemPromptControls = {
542
+ replace: false,
543
+ append: false
544
+ };
545
+ /**
546
+ * Which system-prompt intents a harness honors THROUGH A WORKSPACE — the value an adapter that
547
+ * lowers a profile to files, env vars, and CLI flags and then hands the result to a launcher it
548
+ * does not own should declare as {@link AgentProfileCapabilities.systemPrompt}. That is the shape
549
+ * of every caller today (the cli-bridge and tangle providers both forward a plan), which is why
550
+ * this answer depends on the harness alone.
551
+ *
552
+ * It is NOT the whole truth for an adapter that starts the harness itself, because one control in
553
+ * the table above lives outside any workspace: opencode's `agent.<name>.prompt` really does replace
554
+ * its built-in prompt, but it binds to the single agent whoever starts the server selects. A plan
555
+ * cannot name that agent, so `opencode` reads `replace: false` here — while an adapter that writes
556
+ * opencode's server config AND picks the primary agent (`sdk-provider-opencode`) does honor
557
+ * replacement, and declares `replace: true` for itself. The capability is a property of the
558
+ * (harness, executor) pair; this function answers it for the plan-forwarding executor.
559
+ *
560
+ * Do not widen the table to close that gap: a harness-keyed `true` would promise the intent to
561
+ * every plan-forwarding caller, and those callers cannot deliver it. An executor that owns a
562
+ * launcher control states so where it binds it — `materializeProfile`'s `binds` option in
563
+ * `@tangle-network/agent-profile-materialize`, which turns the plan's refusal into a binding that
564
+ * executor must then apply.
565
+ *
566
+ * Pass `undefined` when the harness is not known at declaration time: the answer is then
567
+ * `{ replace: false, append: false }`, because an adapter that cannot name its harness cannot
568
+ * promise either intent, and `false` means "refuse" rather than "silently substitute the other".
569
+ * An adapter that forwards a profile to some other layer must still declare what that layer's
570
+ * harness really does — being able to put the field on the wire is not the same as honoring it.
571
+ */
572
+ function harnessSystemPromptIntents(harness) {
573
+ if (!harness) return noSystemPromptControls;
574
+ return harnessSystemPromptControls[harness] ?? noSystemPromptControls;
575
+ }
576
+ //#endregion
577
+ //#region ../../../node_modules/.pnpm/@tangle-network+agent-interface@5.8.1/node_modules/@tangle-network/agent-interface/dist/sandbox-size.js
578
+ /**
579
+ * Portable sandbox size vocabulary.
580
+ *
581
+ * A size preset is a provider-neutral NAME for a compute tier (cpu / memory /
582
+ * disk). This module owns only the vocabulary — the names and their smallest→
583
+ * largest ordering — so the lowest shared layer can reference a size without
584
+ * depending on the sandbox SDK (`Capability.recommendedSize` lives here, and
585
+ * agent-interface must not depend on `@tangle-network/sandbox`).
586
+ *
587
+ * The concrete cpu/memory/disk numbers for each preset are the sandbox SDK's
588
+ * single source of truth (`@tangle-network/sandbox` → `SANDBOX_SIZE_PRESETS`),
589
+ * which imports these names. Mirrors how this package owns the `ReasoningEffort`
590
+ * vocabulary while backends own its native mapping.
591
+ */
592
+ /** Compute tiers, ordered smallest → largest. */
593
+ const SANDBOX_SIZE_PRESET_NAMES = [
594
+ "nano",
595
+ "small",
596
+ "medium",
597
+ "large"
598
+ ];
599
+ //#endregion
600
+ //#region ../../../node_modules/.pnpm/@tangle-network+agent-interface@5.8.1/node_modules/@tangle-network/agent-interface/dist/profile-schema.js
601
+ const agentProfilePermissionValueSchema = z.enum([
602
+ "allow",
603
+ "deny",
604
+ "ask"
605
+ ]);
606
+ const agentProfilePermissionSchema = z.union([agentProfilePermissionValueSchema, ownPropertyRecordSchema(agentProfilePermissionValueSchema)]);
607
+ const agentProfileResourceRefSchema = z.union([z.strictObject({
608
+ kind: z.literal("inline"),
609
+ name: z.string(),
610
+ content: z.string()
611
+ }), z.strictObject({
612
+ kind: z.literal("github"),
613
+ repository: z.string().optional(),
614
+ path: z.string(),
615
+ ref: z.string().optional(),
616
+ name: z.string().optional()
617
+ })]);
618
+ const agentProfileFileMountSchema = z.strictObject({
619
+ path: z.string(),
620
+ resource: agentProfileResourceRefSchema,
621
+ executable: z.boolean().optional()
622
+ });
623
+ const agentProfileResourcesSchema = z.strictObject({
624
+ knowledge: agentProfileKnowledgeRefsSchema.optional(),
625
+ files: z.array(agentProfileFileMountSchema).optional(),
626
+ tools: z.array(agentProfileResourceRefSchema).optional(),
627
+ skills: z.array(agentProfileResourceRefSchema).optional(),
628
+ agents: z.array(agentProfileResourceRefSchema).optional(),
629
+ commands: z.array(agentProfileResourceRefSchema).optional(),
630
+ instructions: z.union([z.string(), agentProfileResourceRefSchema]).optional(),
631
+ failOnError: z.boolean().optional()
632
+ });
633
+ const reasoningEffortSchema = z.enum(REASONING_EFFORTS);
634
+ /**
635
+ * Enforce the token ceilings that live together: each single ceiling must not
636
+ * exceed the total. It fails loud on a violation and never clamps a value.
637
+ * `reasoningEffort` is a separate quality dial and is not a bound here.
638
+ */
639
+ function enforceModelTokenBounds(hints, context) {
640
+ const { maxVisibleOutputTokens, maxReasoningTokens, maxTotalOutputTokens } = hints;
641
+ if (maxTotalOutputTokens === void 0) return;
642
+ if (maxVisibleOutputTokens !== void 0 && maxVisibleOutputTokens > maxTotalOutputTokens) context.addIssue({
643
+ code: "custom",
644
+ path: ["maxVisibleOutputTokens"],
645
+ message: "maxVisibleOutputTokens must not exceed maxTotalOutputTokens"
646
+ });
647
+ if (maxReasoningTokens !== void 0 && maxReasoningTokens > maxTotalOutputTokens) context.addIssue({
648
+ code: "custom",
649
+ path: ["maxReasoningTokens"],
650
+ message: "maxReasoningTokens must not exceed maxTotalOutputTokens"
651
+ });
652
+ }
653
+ const agentProfileModelHintsSchema = z.strictObject({
654
+ default: z.string().optional(),
655
+ small: z.string().optional(),
656
+ provider: z.string().optional(),
657
+ reasoningEffort: reasoningEffortSchema.optional(),
658
+ maxVisibleOutputTokens: z.number().int().positive().optional(),
659
+ maxReasoningTokens: z.number().int().positive().optional(),
660
+ maxTotalOutputTokens: z.number().int().positive().optional(),
661
+ metadata: ownPropertyRecordSchema(z.unknown()).optional()
662
+ }).superRefine(enforceModelTokenBounds);
663
+ /** Ordered account selection policy, without credentials or ambient model defaults. */
664
+ const agentProfileSeatSchema = z.strictObject({
665
+ harness: harnessTypeSchema,
666
+ provider: z.string().regex(/^[a-z][a-z0-9-]*$/),
667
+ model: z.string().min(1).refine((value) => value.trim() === value, "model must be canonical"),
668
+ reasoningEffort: reasoningEffortSchema.optional(),
669
+ selector: z.union([z.strictObject({ kind: z.literal("all-eligible") }), z.strictObject({
670
+ kind: z.literal("seat"),
671
+ id: z.string().min(1).refine((value) => value.trim() === value, "seat id must be canonical")
672
+ })]),
673
+ tools: ownPropertyRecordSchema(z.boolean()).optional(),
674
+ permissions: ownPropertyRecordSchema(agentProfilePermissionSchema).optional()
675
+ });
676
+ /**
677
+ * Replacement and addition are separate, independently optional fields, and the
678
+ * pair is admitted on purpose: the effective prompt is `systemPrompt` followed
679
+ * by `appendSystemPrompt`. No cross-field refinement rejects the combination,
680
+ * because {@link mergeAgentProfiles} can produce it from two valid profiles.
681
+ */
682
+ const agentProfilePromptSchema = z.strictObject({
683
+ systemPrompt: z.string().optional(),
684
+ appendSystemPrompt: z.string().optional(),
685
+ instructions: z.array(z.string()).optional()
686
+ });
687
+ const controlCharacterPattern = /[\u0000-\u001f\u007f]/;
688
+ const secretCapableNamePattern = /(?:^|[_-])(?:api[_-]?key|access[_-]?key|private[_-]?key|token|secret|password|credentials?|authorization|cookie|database[_-]?url|dsn|pat)(?:[_-]|$)/i;
689
+ /** Return true when a public config name denotes credential material. */
690
+ function isCredentialBearingProfileConfigName(name) {
691
+ return secretCapableNamePattern.test(name);
692
+ }
693
+ const publicProfileConfigStringSchema = z.string().refine((value) => isWellFormedUnicode(value) && !controlCharacterPattern.test(value) && !looksLikeCredential(value), "public profile config cannot carry credential-like material");
694
+ const agentProfilePublicConfigValueSchema = z.strictObject({
695
+ kind: z.literal("public"),
696
+ value: publicProfileConfigStringSchema
697
+ });
698
+ const agentProfileSecretRefSchema = agentCandidateSecretRefSchema;
699
+ const agentProfileConfigValueSchema = z.discriminatedUnion("kind", [agentProfilePublicConfigValueSchema, agentProfileSecretRefSchema]);
700
+ function profileConfigRecordSchema(keySchema) {
701
+ return ownPropertyRecordSchema(agentProfileConfigValueSchema).superRefine((record, context) => {
702
+ for (const [name, value] of Object.entries(record)) {
703
+ if (!keySchema.safeParse(name).success) context.addIssue({
704
+ code: "custom",
705
+ path: [name],
706
+ message: "profile config key is invalid for this field"
707
+ });
708
+ if (value.kind === "public" && isCredentialBearingProfileConfigName(name)) context.addIssue({
709
+ code: "custom",
710
+ path: [name],
711
+ message: "credential-bearing config names require a secret-ref"
712
+ });
713
+ }
714
+ });
715
+ }
716
+ const agentProfileEnvironmentSchema = profileConfigRecordSchema(environmentNameSchema);
717
+ const agentProfileHeaderSchema = profileConfigRecordSchema(headerNameSchema);
718
+ const agentSubagentProfileSchema = z.strictObject({
719
+ description: z.string().optional(),
720
+ prompt: z.string().optional(),
721
+ model: z.string().optional(),
722
+ tools: ownPropertyRecordSchema(z.boolean()).optional(),
723
+ permissions: ownPropertyRecordSchema(agentProfilePermissionSchema).optional(),
724
+ maxSteps: z.number().optional(),
725
+ metadata: ownPropertyRecordSchema(z.unknown()).optional()
726
+ });
727
+ const agentProfileHookCommandSchema = z.strictObject({
728
+ command: z.string(),
729
+ timeoutMs: z.number().positive().optional(),
730
+ blocking: z.boolean().optional(),
731
+ matcher: z.string().optional(),
732
+ env: agentProfileEnvironmentSchema.optional()
733
+ });
734
+ const agentProfileModeSchema = z.strictObject({
735
+ description: z.string().optional(),
736
+ model: z.string().optional(),
737
+ prompt: z.string().optional(),
738
+ tools: ownPropertyRecordSchema(z.boolean()).optional(),
739
+ permissions: ownPropertyRecordSchema(agentProfilePermissionSchema).optional(),
740
+ metadata: ownPropertyRecordSchema(z.unknown()).optional()
741
+ });
742
+ const agentProfileConfidentialSchema = z.strictObject({
743
+ tee: z.string().optional(),
744
+ attestationNonce: z.string().optional(),
745
+ sealed: z.boolean().optional(),
746
+ attestationRefresh: z.boolean().optional()
747
+ });
748
+ const nonBlankMcpValueSchema = z.string().refine((value) => value.trim().length > 0, "value cannot be blank");
749
+ const remoteMcpUrlSchema = nonBlankMcpValueSchema.refine((value) => {
750
+ try {
751
+ const url = new URL(value);
752
+ return url.protocol === "http:" || url.protocol === "https:";
753
+ } catch {
754
+ return false;
755
+ }
756
+ }, "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");
757
+ const agentProfileLocalMcpServerSchema = z.strictObject({
758
+ transport: z.literal("stdio").optional(),
759
+ command: nonBlankMcpValueSchema.refine(isSafeExecutable, "local MCP command must be a canonical public executable"),
760
+ args: z.array(agentProfileConfigValueSchema).optional(),
761
+ env: agentProfileEnvironmentSchema.optional(),
762
+ cwd: z.string().refine((value) => isSafeRelativePath(value, true), "local MCP cwd must be a canonical workspace-relative path").optional(),
763
+ url: z.undefined().optional(),
764
+ headers: z.undefined().optional(),
765
+ enabled: z.literal(true).optional(),
766
+ metadata: ownPropertyRecordSchema(z.unknown()).optional()
767
+ });
768
+ const agentProfileRemoteMcpServerSchema = z.strictObject({
769
+ transport: z.enum(["sse", "http"]).optional(),
770
+ command: z.undefined().optional(),
771
+ args: z.undefined().optional(),
772
+ env: z.undefined().optional(),
773
+ cwd: z.undefined().optional(),
774
+ url: remoteMcpUrlSchema,
775
+ headers: agentProfileHeaderSchema.optional(),
776
+ enabled: z.literal(true).optional(),
777
+ metadata: ownPropertyRecordSchema(z.unknown()).optional()
778
+ });
779
+ const agentProfileDisabledMcpServerSchema = z.strictObject({
780
+ enabled: z.literal(false),
781
+ transport: z.undefined().optional(),
782
+ command: z.undefined().optional(),
783
+ args: z.undefined().optional(),
784
+ env: z.undefined().optional(),
785
+ cwd: z.undefined().optional(),
786
+ url: z.undefined().optional(),
787
+ headers: z.undefined().optional(),
788
+ metadata: ownPropertyRecordSchema(z.unknown()).optional()
789
+ });
790
+ const agentProfileMcpServerSchema = z.union([
791
+ agentProfileLocalMcpServerSchema,
792
+ agentProfileRemoteMcpServerSchema,
793
+ agentProfileDisabledMcpServerSchema
794
+ ]);
795
+ const agentProfileConnectionSchema = z.strictObject({
796
+ connectionId: z.string().min(1),
797
+ capabilities: z.array(z.string().min(1)).min(1),
798
+ alias: z.string().min(1).optional()
799
+ });
800
+ const removeListSchema = z.union([z.literal(true), z.array(z.string().min(1))]);
801
+ const agentProfilePromptRemovalSchema = z.strictObject({
802
+ systemPrompt: z.literal(true).optional(),
803
+ appendSystemPrompt: z.literal(true).optional(),
804
+ instructions: removeListSchema.optional()
805
+ });
806
+ const agentProfileResourceRemovalSchema = z.strictObject({
807
+ knowledge: removeListSchema.optional(),
808
+ files: removeListSchema.optional(),
809
+ tools: removeListSchema.optional(),
810
+ skills: removeListSchema.optional(),
811
+ agents: removeListSchema.optional(),
812
+ commands: removeListSchema.optional(),
813
+ instructions: z.literal(true).optional(),
814
+ failOnError: z.literal(true).optional()
815
+ });
816
+ const agentProfileDiffRemovalSchema = z.strictObject({
817
+ identity: z.literal(true).optional(),
818
+ tags: removeListSchema.optional(),
819
+ prompt: z.union([z.literal(true), agentProfilePromptRemovalSchema]).optional(),
820
+ model: removeListSchema.optional(),
821
+ harness: z.literal(true).optional(),
822
+ seats: z.literal(true).optional(),
823
+ proxySecrets: z.literal(true).optional(),
824
+ permissions: removeListSchema.optional(),
825
+ tools: removeListSchema.optional(),
826
+ mcp: removeListSchema.optional(),
827
+ connections: removeListSchema.optional(),
828
+ subagents: removeListSchema.optional(),
829
+ resources: z.union([z.literal(true), agentProfileResourceRemovalSchema]).optional(),
830
+ hooks: removeListSchema.optional(),
831
+ modes: removeListSchema.optional(),
832
+ confidential: z.literal(true).optional(),
833
+ metadata: removeListSchema.optional(),
834
+ extensions: removeListSchema.optional()
835
+ });
836
+ 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");
837
+ const agentTrainingTaskSchema = z.strictObject({
838
+ benchmark: trainingIdentitySchema,
839
+ task: trainingIdentitySchema,
840
+ contentDigest: sha256DigestSchema
841
+ });
842
+ /** The same order is used by dataset ingestion, receipt admission and holdout checks. */
843
+ function agentTrainingTaskKey(task) {
844
+ return JSON.stringify([
845
+ task.benchmark,
846
+ task.task,
847
+ task.contentDigest
848
+ ]);
849
+ }
850
+ const agentTrainingDatasetIdentitySchema = z.strictObject({
851
+ digest: sha256DigestSchema,
852
+ taskSetDigest: sha256DigestSchema,
853
+ tasks: z.array(agentTrainingTaskSchema).min(1).max(1e4)
854
+ }).superRefine((dataset, context) => {
855
+ const keys = dataset.tasks.map(agentTrainingTaskKey);
856
+ if (keys.some((key, index) => index > 0 && key <= keys[index - 1])) context.addIssue({
857
+ code: "custom",
858
+ path: ["tasks"],
859
+ message: "training tasks must be sorted and unique"
860
+ });
861
+ if (canonicalCandidateDigest(dataset.tasks) !== dataset.taskSetDigest) context.addIssue({
862
+ code: "custom",
863
+ path: ["taskSetDigest"],
864
+ message: "training task inventory digest mismatch"
865
+ });
866
+ });
867
+ const agentTrainingParametersSchema = ownPropertyRecordSchema(z.union([
868
+ z.string().max(2048).pipe(publicProfileConfigStringSchema),
869
+ z.number().finite(),
870
+ z.boolean(),
871
+ z.null()
872
+ ])).superRefine((parameters, context) => {
873
+ if (Object.keys(parameters).length > 100) context.addIssue({
874
+ code: "custom",
875
+ message: "at most 100 public training parameters are allowed"
876
+ });
877
+ for (const name of Object.keys(parameters)) if (!trainingIdentitySchema.safeParse(name).success || isCredentialBearingProfileConfigName(name)) context.addIssue({
878
+ code: "custom",
879
+ path: [name],
880
+ message: "training parameter name must be public and non-credential"
881
+ });
882
+ });
883
+ const agentTrainingReceiptSchema = z.strictObject({
884
+ version: z.literal(1),
885
+ dataset: agentTrainingDatasetIdentitySchema,
886
+ parentProfileDigest: sha256DigestSchema,
887
+ parentReceiptDigest: sha256DigestSchema.nullable(),
888
+ executionRef: sha256DigestSchema,
889
+ trainer: z.strictObject({
890
+ mode: z.enum(["command", "managed"]),
891
+ id: trainingIdentitySchema,
892
+ revision: sha256DigestSchema,
893
+ parameters: agentTrainingParametersSchema
894
+ }),
895
+ checkpoint: z.strictObject({
896
+ artifactDigest: sha256DigestSchema,
897
+ artifactBytes: z.number().int().positive().max(Number.MAX_SAFE_INTEGER),
898
+ routerModelId: trainingIdentitySchema,
899
+ servingDigest: sha256DigestSchema
900
+ })
901
+ }).superRefine((receipt, context) => {
902
+ if (receipt.checkpoint.routerModelId !== trainedModelIdForArtifact(receipt.checkpoint.artifactDigest)) context.addIssue({
903
+ code: "custom",
904
+ path: ["checkpoint", "routerModelId"],
905
+ message: "trained Router model must be artifact-addressed"
906
+ });
907
+ });
908
+ const agentProfileTrainingSchema = z.strictObject({
909
+ receipt: agentTrainingReceiptSchema,
910
+ ancestors: z.array(agentTrainingReceiptSchema).max(8)
911
+ }).superRefine((training, context) => {
912
+ const chain = [training.receipt, ...training.ancestors];
913
+ const digests = chain.map(canonicalCandidateDigest);
914
+ if (new Set(digests).size !== digests.length) context.addIssue({
915
+ code: "custom",
916
+ message: "training receipt ancestry must not repeat"
917
+ });
918
+ for (let index = 0; index < chain.length; index++) if (chain[index].parentReceiptDigest !== (digests[index + 1] ?? null)) context.addIssue({
919
+ code: "custom",
920
+ message: "training receipt ancestry is incomplete or has been altered"
921
+ });
922
+ });
923
+ const agentProfileMetadataSchema = ownPropertyRecordSchema(z.unknown()).superRefine((metadata, context) => {
924
+ if (!Object.hasOwn(metadata, "training")) return;
925
+ const result = agentProfileTrainingSchema.safeParse(metadata.training);
926
+ if (!result.success) for (const issue of result.error.issues) context.addIssue({
927
+ code: "custom",
928
+ path: ["training", ...issue.path],
929
+ message: issue.message
930
+ });
931
+ });
932
+ /**
933
+ * The complete provider-neutral agent profile schema — the runtime validator for
934
+ * the canonical {@link AgentProfile} TS contract. Kept structurally in lock-step
935
+ * with that interface by the compile-time guard at the bottom of this file.
936
+ */
937
+ const agentProfileSchema = z.strictObject({
938
+ name: z.string().optional(),
939
+ description: z.string().optional(),
940
+ version: z.string().optional(),
941
+ tags: z.array(z.string()).optional(),
942
+ prompt: agentProfilePromptSchema.optional(),
943
+ model: agentProfileModelHintsSchema.optional(),
944
+ harness: harnessTypeSchema.optional(),
945
+ seats: z.array(agentProfileSeatSchema).nonempty().optional(),
946
+ proxySecrets: ProxySecretsSchema.optional(),
947
+ permissions: ownPropertyRecordSchema(agentProfilePermissionSchema).optional(),
948
+ tools: ownPropertyRecordSchema(z.boolean()).optional(),
949
+ mcp: ownPropertyRecordSchema(agentProfileMcpServerSchema).optional(),
950
+ connections: z.array(agentProfileConnectionSchema).optional(),
951
+ subagents: ownPropertyRecordSchema(agentSubagentProfileSchema).optional(),
952
+ resources: agentProfileResourcesSchema.optional(),
953
+ hooks: ownPropertyRecordSchema(z.array(agentProfileHookCommandSchema)).optional(),
954
+ modes: ownPropertyRecordSchema(agentProfileModeSchema).optional(),
955
+ confidential: agentProfileConfidentialSchema.optional(),
956
+ metadata: agentProfileMetadataSchema.optional(),
957
+ extensions: ownPropertyRecordSchema(z.union([ownPropertyRecordSchema(z.unknown()), z.undefined()])).optional()
958
+ }).superRefine((profile, context) => {
959
+ validateNestedRecordKeys(profile, context, [], /* @__PURE__ */ new Set());
960
+ if (profile.seats?.length) {
961
+ const first = profile.seats[0];
962
+ if (first.harness !== profile.harness || first.provider !== profile.model?.provider || first.model !== profile.model?.default) context.addIssue({
963
+ code: "custom",
964
+ path: ["seats", 0],
965
+ message: "first seat must match profile harness, model.provider, and model.default"
966
+ });
967
+ if (first.reasoningEffort !== void 0 && first.reasoningEffort !== profile.model?.reasoningEffort) context.addIssue({
968
+ code: "custom",
969
+ path: [
970
+ "seats",
971
+ 0,
972
+ "reasoningEffort"
973
+ ],
974
+ message: "first seat reasoningEffort must match profile model.reasoningEffort"
975
+ });
976
+ if (first.tools !== void 0 && canonicalAgentProfileJson(first.tools) !== canonicalAgentProfileJson(profile.tools)) context.addIssue({
977
+ code: "custom",
978
+ path: [
979
+ "seats",
980
+ 0,
981
+ "tools"
982
+ ],
983
+ message: "first seat tools must match profile tools"
984
+ });
985
+ if (first.permissions !== void 0 && canonicalAgentProfileJson(first.permissions) !== canonicalAgentProfileJson(profile.permissions)) context.addIssue({
986
+ code: "custom",
987
+ path: [
988
+ "seats",
989
+ 0,
990
+ "permissions"
991
+ ],
992
+ message: "first seat permissions must match profile permissions"
993
+ });
994
+ for (const [index, seat] of profile.seats.entries()) {
995
+ if (resolveModelProvider(seat.model) !== seat.provider) context.addIssue({
996
+ code: "custom",
997
+ path: [
998
+ "seats",
999
+ index,
1000
+ "provider"
1001
+ ],
1002
+ message: "seat provider must match the model provider"
1003
+ });
1004
+ if (!harnessHonorsModel(seat.harness)) context.addIssue({
1005
+ code: "custom",
1006
+ path: [
1007
+ "seats",
1008
+ index,
1009
+ "harness"
1010
+ ],
1011
+ message: "seat harness does not honor an exact model choice"
1012
+ });
1013
+ const effort = seat.reasoningEffort ?? profile.model?.reasoningEffort;
1014
+ const support = harnessModelSupport(seat.harness, seat.model, { reasoningEffort: effort });
1015
+ if (!support.supported) context.addIssue({
1016
+ code: "custom",
1017
+ path: [
1018
+ "seats",
1019
+ index,
1020
+ "model"
1021
+ ],
1022
+ message: support.message
1023
+ });
1024
+ if (effort !== void 0 && (!harnessHonorsEffort(seat.harness) || !harnessReasoningEfforts(seat.harness).includes(effort))) context.addIssue({
1025
+ code: "custom",
1026
+ path: [
1027
+ "seats",
1028
+ index,
1029
+ "reasoningEffort"
1030
+ ],
1031
+ message: "seat harness cannot honor the stage reasoning effort"
1032
+ });
1033
+ const prompt = harnessSystemPromptIntents(seat.harness);
1034
+ if (profile.prompt?.systemPrompt !== void 0 && !prompt.replace) context.addIssue({
1035
+ code: "custom",
1036
+ path: [
1037
+ "seats",
1038
+ index,
1039
+ "harness"
1040
+ ],
1041
+ message: "seat harness cannot replace the system prompt"
1042
+ });
1043
+ if (profile.prompt?.appendSystemPrompt !== void 0 && !prompt.append) context.addIssue({
1044
+ code: "custom",
1045
+ path: [
1046
+ "seats",
1047
+ index,
1048
+ "harness"
1049
+ ],
1050
+ message: "seat harness cannot append the system prompt"
1051
+ });
1052
+ }
1053
+ }
1054
+ const training = agentProfileTrainingSchema.safeParse(profile.metadata?.training);
1055
+ if (profile.model?.default?.startsWith("tangle-trained/") && !training.success) context.addIssue({
1056
+ code: "custom",
1057
+ path: ["metadata", "training"],
1058
+ message: "trained model requires a checkpoint receipt"
1059
+ });
1060
+ if ([
1061
+ profile.model?.small,
1062
+ ...Object.values(profile.subagents ?? {}).map((agent) => agent.model),
1063
+ ...Object.values(profile.modes ?? {}).map((mode) => mode.model)
1064
+ ].some((model) => model?.startsWith("tangle-trained/") && (!training.success || model !== training.data.receipt.checkpoint.routerModelId))) context.addIssue({
1065
+ code: "custom",
1066
+ message: "trained auxiliary models require the same receipted checkpoint"
1067
+ });
1068
+ if (training.success && profile.model?.default !== training.data.receipt.checkpoint.routerModelId) context.addIssue({
1069
+ code: "custom",
1070
+ path: ["model", "default"],
1071
+ message: "trained profile model must equal the receipt's Router model"
1072
+ });
1073
+ });
1074
+ const encodedRecordKeyPattern = "^u(?:[0-9a-f]{4})*$";
1075
+ function isEncodedRecordKeyPropertyNames(value) {
1076
+ if (value === null || typeof value !== "object" || Array.isArray(value)) return false;
1077
+ const propertyNames = value;
1078
+ return propertyNames.type === "string" && propertyNames.pattern === encodedRecordKeyPattern;
1079
+ }
1080
+ function removeModelInputSchemaArtifacts(value) {
1081
+ if (Array.isArray(value)) return value.map(removeModelInputSchemaArtifacts);
1082
+ if (value === null || typeof value !== "object") return value;
1083
+ const result = {};
1084
+ for (const [key, entry] of Object.entries(value)) {
1085
+ if (key === "$schema") continue;
1086
+ if (key === "propertyNames" && isEncodedRecordKeyPropertyNames(entry)) continue;
1087
+ result[key] = removeModelInputSchemaArtifacts(entry);
1088
+ }
1089
+ return result;
1090
+ }
1091
+ removeModelInputSchemaArtifacts(z.toJSONSchema(agentProfileSchema, {
1092
+ target: "draft-2020-12",
1093
+ io: "input",
1094
+ unrepresentable: "any"
1095
+ }));
1096
+ function validateNestedRecordKeys(value, context, path, seen) {
1097
+ if (value === null || typeof value !== "object" || seen.has(value)) return;
1098
+ seen.add(value);
1099
+ for (const [key, entry] of Object.entries(value)) {
1100
+ if (!isWellFormedUnicode(key)) context.addIssue({
1101
+ code: "custom",
1102
+ path: [...path, key],
1103
+ message: "record keys must contain valid Unicode"
1104
+ });
1105
+ validateNestedRecordKeys(entry, context, [...path, key], seen);
1106
+ }
1107
+ }
1108
+ z.strictObject({
1109
+ kind: z.literal("agent-profile-diff"),
1110
+ id: z.string().min(1).optional(),
1111
+ title: z.string().min(1).optional(),
1112
+ description: z.string().optional(),
1113
+ rationale: z.string().optional(),
1114
+ source: z.strictObject({
1115
+ kind: z.enum([
1116
+ "trace",
1117
+ "frontier-author",
1118
+ "human",
1119
+ "optimizer",
1120
+ "compound"
1121
+ ]),
1122
+ artifacts: z.array(z.string().min(1)).optional(),
1123
+ notes: z.array(z.string()).optional()
1124
+ }).optional(),
1125
+ set: agentProfileSchema.optional(),
1126
+ remove: agentProfileDiffRemovalSchema.optional(),
1127
+ metadata: ownPropertyRecordSchema(z.unknown()).optional()
1128
+ });
1129
+ z.strictObject({
1130
+ id: z.string().min(1),
1131
+ definition: agentProfileSchema,
1132
+ recommendedSize: z.enum(SANDBOX_SIZE_PRESET_NAMES).optional()
1133
+ });
1134
+ //#endregion
1135
+ export { canonicalAgentProfileValue as i, agentProfileSchema as n, SANDBOX_SIZE_PRESET_NAMES as r, agentProfileConfidentialSchema as t };