@tangle-network/sandbox 1.0.21 → 1.0.22

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 (75) 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-I1nMkkrz.d.ts → agent-run-outcome-DQjHjmTQ.d.ts} +2 -2
  6. package/dist/{api-request-EseiF9B1.js → api-request-DNrodWdz.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 → browser-interactive-control-controller-EhML8YjF.js} +186 -2131
  10. package/dist/{browser-interactive-control-controller-CVnME80O.d.ts → browser-interactive-control-controller-i9JtmJDf.d.ts} +1 -1
  11. package/dist/{chunked-upload-Df_5Q2x8.js → chunked-upload-KRWmiJsw.js} +1 -1
  12. package/dist/{chunked-upload-file-Dtm1GBkE.js → chunked-upload-file-DPSyrGUb.js} +2 -2
  13. package/dist/cli-auth-bundle-V7sPQYej.js +1594 -0
  14. package/dist/{client-DEvdnu0z.d.ts → client-1bgxaNQD.d.ts} +5 -5
  15. package/dist/{client-HMGk7nNW.js → client-DC1Q6oJb.js} +11 -11
  16. package/dist/collaboration/index.d.ts +1 -1
  17. package/dist/collaboration/index.js +1 -1
  18. package/dist/{collaboration-BTGTf3We.js → collaboration-DPukGUcF.js} +1 -1
  19. package/dist/{core-DvYE_89H.js → core-0iCiDt_5.js} +5 -5
  20. package/dist/core.d.ts +6 -6
  21. package/dist/core.js +5 -5
  22. package/dist/{direct-http2-B0ra_xhU.js → direct-http2-C0H7zN9h.js} +1 -1
  23. package/dist/{errors-ZmDrrk4f.js → errors-BUPIDjn4.js} +1 -1
  24. package/dist/{sha2-BUPMvGTk.js → harness-DkCl2wJv.js} +417 -1
  25. package/dist/{index-C3GQDkDm.d.ts → index-vcweImuL.d.ts} +6 -6
  26. package/dist/index.d.ts +11 -11
  27. package/dist/index.js +11 -11
  28. package/dist/intelligence/index.js +2 -2
  29. package/dist/interactive-control.d.ts +1 -1
  30. package/dist/interactive-control.js +1 -1
  31. package/dist/{interactive-controller-Bf8yrdzR.d.ts → interactive-controller-B16SZKZt.d.ts} +3 -3
  32. package/dist/{interactive-controller-BkfV4Cs_.js → interactive-controller-kZk52Eff.js} +19 -21
  33. package/dist/lib/prepared-evidence.js +1 -1
  34. package/dist/lib/prepared-process.js +1 -1
  35. package/dist/{lines-BqZOl_io.js → lines-BnAWHGX3.js} +1 -1
  36. package/dist/{lines-CA1IbRzE.d.ts → lines-BxCEZUkf.d.ts} +1 -1
  37. package/dist/lines.d.ts +1 -1
  38. package/dist/lines.js +1 -1
  39. package/dist/{local-cli-auth-DzovETOu.js → local-cli-auth-CJuKPr1j.js} +1 -1
  40. package/dist/{mcp-local-BcRLN_Ic.js → mcp-local-C88efQL3.js} +1 -1
  41. package/dist/{prepared-evidence-CuUh_mz6.js → prepared-evidence-DC-M4WEF.js} +1 -1
  42. package/dist/{preview-DQs0Zh9L.d.ts → preview-QcwZWgzk.d.ts} +3 -3
  43. package/dist/{profile-schema-CT3hB1mG.js → profile-schema-1WmjXjE9.js} +23 -12
  44. package/dist/{public-templates-COGktcNu.d.ts → public-templates-GNIKn_wg.d.ts} +2 -2
  45. package/dist/public-templates.d.ts +1 -1
  46. package/dist/public-templates.js +1 -1
  47. package/dist/{raw-evidence-archive-CqarcYcp.js → raw-evidence-archive-Bc-OdA_Q.js} +1 -1
  48. package/dist/runtime.d.ts +5 -5
  49. package/dist/runtime.js +5 -5
  50. package/dist/{sandbox-BAhF5QaX.js → sandbox-Qn9ScVvS.js} +46 -48
  51. package/dist/{secp256k1-CZWrpqxW.js → secp256k1-BGtA1PsN.js} +1 -1
  52. package/dist/select-seat-command.d.ts +1 -1
  53. package/dist/select-seat-command.js +1 -1
  54. package/dist/session-gateway/index.js +3 -3
  55. package/dist/tangle/index.d.ts +1 -1
  56. package/dist/tangle/index.js +1 -1
  57. package/dist/{tangle-CwfZovBM.js → tangle-DOwUAne4.js} +4 -4
  58. package/dist/{terminal-stream-types-DwXQzUbH.d.ts → terminal-stream-types-BM5J4lt0.d.ts} +155 -769
  59. package/dist/{types-BF8se4_x.d.ts → types-MYaFNkH5.d.ts} +7 -7
  60. package/package.json +5 -5
  61. package/dist/cli-auth-bundle-KtV88h1f.js +0 -2597
  62. package/dist/harness-BD_OISom.js +0 -201
  63. package/dist/harness-DWL2MM4q.js +0 -418
  64. /package/dist/{abort-signal-jU-SEjLT.js → abort-signal-CDxyloxz.js} +0 -0
  65. /package/dist/{cli-auth-bundle-MskLEgtA.d.ts → cli-auth-bundle-CFZx0muA.d.ts} +0 -0
  66. /package/dist/{index-Dqcr9p97.d.ts → index-DnZdhFs2.d.ts} +0 -0
  67. /package/dist/{index-Dslyq85a.d.ts → index-rbeL2Rct.d.ts} +0 -0
  68. /package/dist/{keep-alive-fetch-C2DX2_rG.js → keep-alive-fetch-BbSFbRCd.js} +0 -0
  69. /package/dist/{prepared-process-LjBfQnZ5.js → prepared-process-BQUSksTH.js} +0 -0
  70. /package/dist/{preview-operations-BvgwYaoL.js → preview-operations-D2fXB_dc.js} +0 -0
  71. /package/dist/{response-rewrap-MBztoTLx.js → response-rewrap-CpNkboDX.js} +0 -0
  72. /package/dist/{retry-after-header-BZbs5rig.js → retry-after-header-DUdCC0KJ.js} +0 -0
  73. /package/dist/{sidecar-proxy-error-Dty4zmN7.js → sidecar-proxy-error-5DpLmHeN.js} +0 -0
  74. /package/dist/{sse-parser-CJ52bhG3.js → sse-parser-CKkE9zWy.js} +0 -0
  75. /package/dist/{utils-vaFoyyiO.js → utils-CoawKwX_.js} +0 -0
@@ -1,2597 +0,0 @@
1
- import { n as BACKEND_TYPE } from "./backend-types-CLvdSX8V.js";
2
- import { a as canonicalCandidateDigest, c as headerNameSchema, d as isSafeRelativePath, f as isWellFormedUnicode, h as sha256DigestSchema, i as trainedModelIdForArtifact, n as REASONING_EFFORTS, o as canonicalCandidateJson, p as looksLikeCredential, s as environmentNameSchema, t as harnessTypeSchema, u as isSafeExecutable } from "./harness-BD_OISom.js";
3
- import { z } from "zod";
4
- import "@tangle-network/agent-interface/harness-capabilities";
5
- //#region ../../../node_modules/.pnpm/@tangle-network+agent-interface@4.0.0/node_modules/@tangle-network/agent-interface/dist/agent-profile-canonical.js
6
- /**
7
- * Normalize profile-shaped data into the canonical JSON domain used for public
8
- * profile identity. Undefined object entries are omitted; unsupported values,
9
- * sparse arrays, and cycles are rejected with their profile path.
10
- *
11
- * This module is intentionally internal. Public callers should use the
12
- * profile-level operations that own validation, identity, or diff semantics.
13
- */
14
- function canonicalAgentProfileValue(value) {
15
- return normalizeAgentProfileValue(value, [], /* @__PURE__ */ new Set());
16
- }
17
- /** Canonical serialization after applying AgentProfile normalization rules. */
18
- function canonicalAgentProfileJson(value) {
19
- const normalized = canonicalAgentProfileValue(value);
20
- return normalized === void 0 ? void 0 : canonicalCandidateJson(normalized);
21
- }
22
- function normalizeAgentProfileValue(value, path, ancestors) {
23
- if (value === void 0) return void 0;
24
- if (value === null || typeof value === "boolean" || typeof value === "string") return value;
25
- if (typeof value === "number") {
26
- if (!Number.isFinite(value)) throw new Error(`AgentProfile ${renderPath(path)} must be finite`);
27
- return value;
28
- }
29
- if (typeof value !== "object") throw new Error(`AgentProfile ${renderPath(path)} is not JSON serializable`);
30
- if (ancestors.has(value)) throw new Error(`AgentProfile ${renderPath(path)} must be acyclic`);
31
- const prototype = Object.getPrototypeOf(value);
32
- if (!Array.isArray(value) && prototype !== Object.prototype && prototype !== null) throw new Error(`AgentProfile ${renderPath(path)} must be a plain JSON object`);
33
- const nextAncestors = new Set(ancestors).add(value);
34
- if (Array.isArray(value)) return Array.from({ length: value.length }, (_, index) => {
35
- if (!Object.prototype.hasOwnProperty.call(value, index)) throw new Error(`AgentProfile ${renderPath([...path, index])} cannot be a sparse array hole`);
36
- const entry = value[index];
37
- const normalized = normalizeAgentProfileValue(entry, [...path, index], nextAncestors);
38
- if (normalized === void 0) throw new Error(`AgentProfile ${renderPath([...path, index])} cannot be undefined`);
39
- return normalized;
40
- });
41
- const material = Object.create(null);
42
- for (const [key, entry] of Object.entries(value)) {
43
- if (!isWellFormedUnicode(key)) throw new Error(`AgentProfile ${renderPath(path)} has a record key that is not valid Unicode`);
44
- const normalized = normalizeAgentProfileValue(entry, [...path, key], nextAncestors);
45
- if (normalized !== void 0) Object.defineProperty(material, key, {
46
- value: normalized,
47
- enumerable: true,
48
- configurable: true,
49
- writable: true
50
- });
51
- }
52
- return material;
53
- }
54
- function renderPath(path) {
55
- return path.length === 0 ? "root" : path.join(".");
56
- }
57
- //#endregion
58
- //#region ../../../node_modules/.pnpm/@tangle-network+agent-interface@4.0.0/node_modules/@tangle-network/agent-interface/dist/harness-capabilities.js
59
- /**
60
- * The unified harness capability layer — the single source of truth for:
61
- * 1. harness ↔ model compatibility (which models a harness can run),
62
- * 2. reasoning-effort support (which thinking levels a harness/model expresses), and
63
- * 3. system-prompt intents (whether a harness can replace its own prompt, add to it, or neither).
64
- *
65
- * All are facets of the same question — "what can this (harness, model) pair actually do" — and
66
- * apply to BOTH harness-backed systems (vendor-locked CLIs like claude-code/codex/kimi) AND
67
- * router-backed systems (opencode, cli-base: any model the router serves). Lifted here so the
68
- * cli-bridge backends, the sandbox UI pickers, and the router all read one truth instead of each
69
- * hand-rolling a divergent copy.
70
- *
71
- * Grounded in the native CLI controls (Codex is `minimal..ultra`, Kimi is binary on/off, Claude is
72
- * `low..max`, cli-base has no agent) — NOT a guessed matrix. The
73
- * per-MODEL reasoning capability (does this specific model reason at all) is dynamic catalog data the
74
- * caller supplies.
75
- */
76
- /** low → high. `none` = thinking off; `ultracode` = max (claude-code mode). */
77
- const reasoningLadder = REASONING_EFFORTS;
78
- /**
79
- * Provider prefixes a harness is vendor-locked to (canonical-id prefix, e.g. `anthropic`, `openai`).
80
- * A harness with no entry is router-backed: it runs any model, except the measured exclusions in
81
- * {@link harnessModelExclusions}.
82
- *
83
- * `nanoclaw` is deliberately absent despite the "claw" name: its runner routes every provider through
84
- * the Tangle router (canonical model id straight to the gateway), so it is router-backed like
85
- * `opencode` — not Anthropic-locked.
86
- */
87
- const harnessProviderLock = {
88
- "claude-code": ["anthropic"],
89
- codex: ["openai"],
90
- "kimi-code": ["moonshot"]
91
- };
92
- /** Provider prefix of a canonical model id (`anthropic/claude-…` → `anthropic`), or null. */
93
- function modelProvider(modelId) {
94
- const slash = modelId.indexOf("/");
95
- return slash > 0 ? modelId.slice(0, slash) : null;
96
- }
97
- /**
98
- * Model families whose bare ids belong to one provider. The Router catalog serves most ids without a
99
- * prefix (`claude-sonnet-5-5`, `gpt-5.5`, `glm-5.3`) and names the provider beside them, so a check
100
- * that read every bare id as "any provider" offered `claude-code` with `glm-5.3`.
101
- */
102
- const bareModelFamilyProviders = [
103
- [/^claude-/, "anthropic"],
104
- [/^(gpt-|chatgpt-|codex-|o\d+(-|$))/, "openai"],
105
- [/^(kimi-|moonshot-)/, "moonshot"],
106
- [/^gemini-/, "google"],
107
- [/^glm-/, "zai"],
108
- [/^deepseek-/, "deepseek"],
109
- [/^grok-/, "xai"]
110
- ];
111
- /**
112
- * The provider a model id belongs to: its explicit prefix, else the provider of its bare-id family
113
- * (`claude-sonnet-5-5` → `anthropic`). `null` for an id outside every family, such as the `default`
114
- * sentinel, whose provider only the serving harness knows.
115
- */
116
- function resolveModelProvider(modelId) {
117
- const explicit = modelProvider(modelId);
118
- if (explicit) return explicit;
119
- const id = modelId.trim().toLowerCase();
120
- for (const [family, provider] of bareModelFamilyProviders) if (family.test(id)) return provider;
121
- return null;
122
- }
123
- /** The providers a harness is locked to, or `null` when it is router-backed (any model). */
124
- function harnessProviders(harness) {
125
- return harnessProviderLock[harness] ?? null;
126
- }
127
- const SANDBOX_HARNESS_MATRIX_EVIDENCE = "https://github.com/tangle-network/agent-dev-container/issues/9382";
128
- /**
129
- * Pairs a router-backed harness cannot run, measured on production with the Router credential: one
130
- * prompt per pair, profile reasoning effort `medium` (2026-10-05). The same run passed pi with
131
- * `openai/gpt-5.5` and `zai/glm-5.3`, and opencode with every model listed here. Pairs not listed
132
- * were not measured to fail. An entry is removed when its harness adapter or the Router is fixed and
133
- * the pair passes a new production measurement.
134
- *
135
- * pi's chat-completions client (pi-ai 0.85.1) marks a model as reasoning only when the profile asks
136
- * for a reasoning effort, and only a reasoning model is sent the `developer` role and
137
- * `reasoning_effort`; that is why the first two entries need a reasoning effort.
138
- */
139
- const harnessModelExclusions = [
140
- {
141
- harness: "pi",
142
- models: /^anthropic\//,
143
- onlyWithReasoningEffort: true,
144
- reason: "the Router's chat-completions route for Anthropic models rejects the \"developer\" role pi sends to a reasoning model (400 Unexpected role \"developer\")",
145
- measuredOn: "2026-10-05",
146
- evidence: SANDBOX_HARNESS_MATRIX_EVIDENCE
147
- },
148
- {
149
- harness: "pi",
150
- models: /^openai\/gpt-5\.6-luna$/,
151
- onlyWithReasoningEffort: true,
152
- reason: "OpenAI does not accept function tools together with reasoning_effort for this model on /v1/chat/completions, the only route pi speaks",
153
- measuredOn: "2026-10-05",
154
- evidence: SANDBOX_HARNESS_MATRIX_EVIDENCE
155
- },
156
- {
157
- harness: "pi",
158
- models: /^google\/gemini-3\.8-flash$/,
159
- onlyWithReasoningEffort: false,
160
- 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)",
161
- measuredOn: "2026-10-05",
162
- evidence: SANDBOX_HARNESS_MATRIX_EVIDENCE
163
- }
164
- ];
165
- /**
166
- * Whether a harness can run a model, and why not. A bare id resolves its provider through
167
- * {@link resolveModelProvider}; an id whose provider cannot be resolved (a sentinel like `default`)
168
- * is left to the harness, because its provider only the serving harness knows. A vendor-locked
169
- * harness refuses every other provider; a router-backed harness refuses only the measured
170
- * {@link harnessModelExclusions}.
171
- */
172
- function harnessModelSupport(harness, modelId, options = {}) {
173
- const trimmed = modelId.trim();
174
- const provider = resolveModelProvider(trimmed);
175
- const model = provider !== null && modelProvider(trimmed) === null ? `${provider}/${trimmed}` : trimmed;
176
- if (provider === null) return {
177
- supported: true,
178
- model,
179
- provider
180
- };
181
- const allowedProviders = harnessProviders(harness);
182
- if (allowedProviders && !allowedProviders.includes(provider)) return {
183
- supported: false,
184
- model,
185
- provider,
186
- allowedProviders,
187
- 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.`
188
- };
189
- const reasoning = options.reasoningEffort !== void 0 && options.reasoningEffort !== null && options.reasoningEffort !== "none";
190
- const exclusion = harnessModelExclusions.find((entry) => entry.harness === harness && entry.models.test(model) && (!entry.onlyWithReasoningEffort || reasoning));
191
- if (exclusion) return {
192
- supported: false,
193
- model,
194
- provider,
195
- exclusion,
196
- 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.")
197
- };
198
- return {
199
- supported: true,
200
- model,
201
- provider
202
- };
203
- }
204
- new Intl.Collator(void 0, {
205
- numeric: true,
206
- sensitivity: "base"
207
- });
208
- /**
209
- * The explicit reasoning-effort set a harness's runtime accepts when it ISN'T a plain `none…ceiling`
210
- * slice — measured against the pinned CLI binaries, NOT inferred from the canonical ladder:
211
- * - codex: `model_reasoning_effort` accepts `none|minimal|low|medium|high|xhigh|max`, plus `ultra`
212
- * which the API's own enumeration omits but accepts end-to-end; canonical `ultracode` maps to
213
- * native `ultra`. Per-model catalog data narrows this list.
214
- * - claude-code: `--effort` accepts `low|medium|high|xhigh|max`; canonical `ultracode` maps to
215
- * native `max`. It cannot express `none` or `minimal`, and an unsupported value is warned about
216
- * and silently replaced with the default rather than rejected — so the set must not overstate.
217
- * - pi: `--thinking` accepts `off|minimal|low|medium|high|xhigh`; canonical `none` maps to
218
- * `off` and `ultracode` clamps to `xhigh`, its top rung.
219
- * - prime: the prime fork of the pi line accepts the same `--thinking` set
220
- * (`off|minimal|low|medium|high|xhigh|max`); canonical `none` maps to `off` and `ultracode` to
221
- * `max`.
222
- * - openclaw: `--thinking` accepts `off|minimal|low|medium|high|xhigh|max` (and `adaptive`, which
223
- * defers the choice rather than naming a rung); canonical `none` maps to `off` and `ultracode`
224
- * to `max`.
225
- * - kimi-code: `--thinking` is binary. Canonical `none` emits `--no-thinking`; any non-none level
226
- * emits `--thinking`, represented here by `high`.
227
- */
228
- const harnessReasoningEffortsOverride = {
229
- codex: [
230
- "none",
231
- "minimal",
232
- "low",
233
- "medium",
234
- "high",
235
- "xhigh",
236
- "ultracode"
237
- ],
238
- "claude-code": [
239
- "low",
240
- "medium",
241
- "high",
242
- "xhigh",
243
- "ultracode"
244
- ],
245
- pi: [
246
- "none",
247
- "minimal",
248
- "low",
249
- "medium",
250
- "high",
251
- "xhigh",
252
- "ultracode"
253
- ],
254
- prime: [
255
- "none",
256
- "minimal",
257
- "low",
258
- "medium",
259
- "high",
260
- "xhigh",
261
- "ultracode"
262
- ],
263
- openclaw: [
264
- "none",
265
- "minimal",
266
- "low",
267
- "medium",
268
- "high",
269
- "xhigh",
270
- "ultracode"
271
- ],
272
- "kimi-code": ["none", "high"]
273
- };
274
- /**
275
- * The ceiling for harnesses whose set IS a plain `none…ceiling` slice. Only the no-thinking runners
276
- * need an entry (`cli-base` has no agent; `nanoclaw` sends no thinking flag). Harnesses with a
277
- * provider-clamped or non-contiguous set live in {@link harnessReasoningEffortsOverride}; router /
278
- * model-driven harnesses (opencode, gemini, …) have no entry → default to the full ladder, narrowed
279
- * by the model's own capability.
280
- */
281
- const harnessReasoningCeiling = {
282
- "cli-base": "none",
283
- nanoclaw: "none"
284
- };
285
- /** The reasoning efforts a harness can express, independent of model — its explicit override set, or
286
- * `none` up to its ceiling (default `ultracode` for router/model-driven harnesses). */
287
- function harnessReasoningEfforts(harness) {
288
- const override = harnessReasoningEffortsOverride[harness];
289
- if (override) return override;
290
- const ceiling = harnessReasoningCeiling[harness] ?? "ultracode";
291
- return reasoningLadder.slice(0, reasoningLadder.indexOf(ceiling) + 1);
292
- }
293
- /**
294
- * Harnesses whose runner DROPS a per-turn selector — grounded in the cli-bridge adapter audit, NOT a
295
- * guess. Most harnesses honor both selectors, so only the exceptions are listed; a harness absent from
296
- * a set honors that selector.
297
- *
298
- * - model dropped: `amp` (own agent picks the model), `openclaw` (dispatcher routes by its own
299
- * config), `nanoclaw` (socket-bridge runner is config/env-driven).
300
- * - effort dropped: `amp`, `factory-droids`, `hermes`, `nanoclaw`, and `acp` (no thinking flag is
301
- * plumbed to the underlying CLI — the runner reads no `reasoningEffort`).
302
- *
303
- * This is distinct from {@link reasoningEffortsFor} (which levels a harness can EXPRESS): a picker uses
304
- * these to trim or mark harnesses up front, so a user's model/effort choice is never silently ignored.
305
- */
306
- const harnessIgnoresModel = new Set([
307
- "amp",
308
- "openclaw",
309
- "nanoclaw"
310
- ]);
311
- const harnessIgnoresEffort = new Set([
312
- "amp",
313
- "factory-droids",
314
- "hermes",
315
- "nanoclaw",
316
- "acp"
317
- ]);
318
- /** Whether the harness's runner honors a per-turn MODEL override (vs. picking the model itself). */
319
- function harnessHonorsModel(harness) {
320
- return !harnessIgnoresModel.has(harness);
321
- }
322
- /** Whether the harness's runner honors a reasoning-EFFORT override (vs. dropping it). */
323
- function harnessHonorsEffort(harness) {
324
- return !harnessIgnoresEffort.has(harness);
325
- }
326
- /**
327
- * The system-prompt intents a harness's own controls can execute, measured by reading the request
328
- * each installed CLI sends — NOT taken from its help text:
329
- *
330
- * - claude-code 2.1.222 and pi 0.83.0 own both. `--system-prompt` drops the built-in prompt from
331
- * the request (27,673 B → the caller's bytes on claude-code, 2,582 B → the caller's on pi);
332
- * `--append-system-prompt` leaves it in place and adds the caller's text after it.
333
- * - codex 0.146.0 owns replacement only: the `model_instructions_file` config key becomes the
334
- * request's entire instructions text. It has no additive control — its AGENTS.md lands in a
335
- * developer/user message, not the system channel.
336
- * - gemini 0.26.0 owns replacement only: `.gemini/system.md` under `GEMINI_SYSTEM_MD=1` replaces
337
- * the base prompt. Its one additive path is GEMINI.md memory, which IS the `instructions`
338
- * surface, so an addition lowered there would be byte-indistinguishable from `instructions`.
339
- * - opencode 1.17.18 owns addition only THROUGH A WORKSPACE: config-declared `instructions[]`
340
- * files compose into the same single `role: "system"` message as its built-in prompt, which
341
- * stays in place. Its replacement control (`agent.<name>.prompt`) binds to one agent chosen at
342
- * launch, which a workspace plan cannot guarantee — but an executor that selects that agent
343
- * can, so `replace: false` here is the plan-forwarding answer, not opencode's ceiling.
344
- *
345
- * Every other harness owns NEITHER, including the ones whose prompt path is a `role: "system"` chat
346
- * message: that message is flattened into the user turn before the CLI sees it, so it is not a
347
- * system-prompt channel at all — honoring an intent through it would put the caller's text in
348
- * ordinary user content while the harness's own prompt ran unchanged. A harness with no entry
349
- * refuses both, so one added later cannot inherit a capability by omission.
350
- */
351
- const harnessSystemPromptControls = {
352
- "claude-code": {
353
- replace: true,
354
- append: true
355
- },
356
- pi: {
357
- replace: true,
358
- append: true
359
- },
360
- prime: {
361
- replace: true,
362
- append: true
363
- },
364
- codex: {
365
- replace: true,
366
- append: false
367
- },
368
- gemini: {
369
- replace: true,
370
- append: false
371
- },
372
- opencode: {
373
- replace: false,
374
- append: true
375
- }
376
- };
377
- const noSystemPromptControls = {
378
- replace: false,
379
- append: false
380
- };
381
- /**
382
- * Which system-prompt intents a harness honors THROUGH A WORKSPACE — the value an adapter that
383
- * lowers a profile to files, env vars, and CLI flags and then hands the result to a launcher it
384
- * does not own should declare as {@link AgentProfileCapabilities.systemPrompt}. That is the shape
385
- * of every caller today (the cli-bridge and tangle providers both forward a plan), which is why
386
- * this answer depends on the harness alone.
387
- *
388
- * It is NOT the whole truth for an adapter that starts the harness itself, because one control in
389
- * the table above lives outside any workspace: opencode's `agent.<name>.prompt` really does replace
390
- * its built-in prompt, but it binds to the single agent whoever starts the server selects. A plan
391
- * cannot name that agent, so `opencode` reads `replace: false` here — while an adapter that writes
392
- * opencode's server config AND picks the primary agent (`sdk-provider-opencode`) does honor
393
- * replacement, and declares `replace: true` for itself. The capability is a property of the
394
- * (harness, executor) pair; this function answers it for the plan-forwarding executor.
395
- *
396
- * Do not widen the table to close that gap: a harness-keyed `true` would promise the intent to
397
- * every plan-forwarding caller, and those callers cannot deliver it. An executor that owns a
398
- * launcher control states so where it binds it — `materializeProfile`'s `binds` option in
399
- * `@tangle-network/agent-profile-materialize`, which turns the plan's refusal into a binding that
400
- * executor must then apply.
401
- *
402
- * Pass `undefined` when the harness is not known at declaration time: the answer is then
403
- * `{ replace: false, append: false }`, because an adapter that cannot name its harness cannot
404
- * promise either intent, and `false` means "refuse" rather than "silently substitute the other".
405
- * An adapter that forwards a profile to some other layer must still declare what that layer's
406
- * harness really does — being able to put the field on the wire is not the same as honoring it.
407
- */
408
- function harnessSystemPromptIntents(harness) {
409
- if (!harness) return noSystemPromptControls;
410
- return harnessSystemPromptControls[harness] ?? noSystemPromptControls;
411
- }
412
- //#endregion
413
- //#region ../../../node_modules/.pnpm/@tangle-network+agent-interface@4.0.0/node_modules/@tangle-network/agent-interface/dist/sandbox-size.js
414
- /**
415
- * Portable sandbox size vocabulary.
416
- *
417
- * A size preset is a provider-neutral NAME for a compute tier (cpu / memory /
418
- * disk). This module owns only the vocabulary — the names and their smallest→
419
- * largest ordering — so the lowest shared layer can reference a size without
420
- * depending on the sandbox SDK (`Capability.recommendedSize` lives here, and
421
- * agent-interface must not depend on `@tangle-network/sandbox`).
422
- *
423
- * The concrete cpu/memory/disk numbers for each preset are the sandbox SDK's
424
- * single source of truth (`@tangle-network/sandbox` → `SANDBOX_SIZE_PRESETS`),
425
- * which imports these names. Mirrors how this package owns the `ReasoningEffort`
426
- * vocabulary while backends own its native mapping.
427
- */
428
- /** Compute tiers, ordered smallest → largest. */
429
- const SANDBOX_SIZE_PRESET_NAMES = [
430
- "nano",
431
- "small",
432
- "medium",
433
- "large"
434
- ];
435
- //#endregion
436
- //#region ../../../node_modules/.pnpm/@tangle-network+agent-interface@4.0.0/node_modules/@tangle-network/agent-interface/dist/profile-schema.js
437
- /**
438
- * Zod records currently assign parsed values onto an ordinary object. The
439
- * special own key `__proto__` therefore invokes the legacy prototype setter
440
- * and disappears instead of being validated. Encode every own key before Zod
441
- * sees it, then restore the exact UTF-16 key with defineProperty so all string
442
- * keys allowed by `Record<string, ...>` remain data rather than object syntax.
443
- */
444
- function ownPropertyRecordSchema(valueSchema) {
445
- return z.preprocess(encodeOwnRecordKeys, z.record(z.string().regex(/^u(?:[0-9a-f]{4})*$/, "record keys must contain valid Unicode"), valueSchema).transform((record) => {
446
- const restored = {};
447
- for (const [encodedKey, value] of Object.entries(record)) Object.defineProperty(restored, decodeRecordKey(encodedKey), {
448
- value,
449
- enumerable: true,
450
- configurable: true,
451
- writable: true
452
- });
453
- return restored;
454
- }));
455
- }
456
- function encodeOwnRecordKeys(value) {
457
- if (value === null || typeof value !== "object" || Array.isArray(value)) return value;
458
- const encoded = Object.create(null);
459
- for (const [key, entry] of Object.entries(value)) encoded[encodeRecordKey(key)] = entry;
460
- return encoded;
461
- }
462
- function encodeRecordKey(value) {
463
- let encoded = isWellFormedUnicode(value) ? "u" : "i";
464
- for (let index = 0; index < value.length; index += 1) encoded += value.charCodeAt(index).toString(16).padStart(4, "0");
465
- return encoded;
466
- }
467
- function decodeRecordKey(value) {
468
- let decoded = "";
469
- for (let index = 1; index < value.length; index += 4) decoded += String.fromCharCode(Number.parseInt(value.slice(index, index + 4), 16));
470
- return decoded;
471
- }
472
- const agentProfilePermissionValueSchema = z.enum([
473
- "allow",
474
- "deny",
475
- "ask"
476
- ]);
477
- const agentProfilePermissionSchema = z.union([agentProfilePermissionValueSchema, ownPropertyRecordSchema(agentProfilePermissionValueSchema)]);
478
- const agentProfileResourceRefSchema = z.union([z.strictObject({
479
- kind: z.literal("inline"),
480
- name: z.string(),
481
- content: z.string()
482
- }), z.strictObject({
483
- kind: z.literal("github"),
484
- repository: z.string().optional(),
485
- path: z.string(),
486
- ref: z.string().optional(),
487
- name: z.string().optional()
488
- })]);
489
- const agentProfileFileMountSchema = z.strictObject({
490
- path: z.string(),
491
- resource: agentProfileResourceRefSchema,
492
- executable: z.boolean().optional()
493
- });
494
- const agentProfileResourcesSchema = z.strictObject({
495
- files: z.array(agentProfileFileMountSchema).optional(),
496
- tools: z.array(agentProfileResourceRefSchema).optional(),
497
- skills: z.array(agentProfileResourceRefSchema).optional(),
498
- agents: z.array(agentProfileResourceRefSchema).optional(),
499
- commands: z.array(agentProfileResourceRefSchema).optional(),
500
- instructions: z.union([z.string(), agentProfileResourceRefSchema]).optional(),
501
- failOnError: z.boolean().optional()
502
- });
503
- const reasoningEffortSchema = z.enum(REASONING_EFFORTS);
504
- /**
505
- * Enforce the token ceilings that live together: each single ceiling must not
506
- * exceed the total. It fails loud on a violation and never clamps a value.
507
- * `reasoningEffort` is a separate quality dial and is not a bound here.
508
- */
509
- function enforceModelTokenBounds(hints, context) {
510
- const { maxVisibleOutputTokens, maxReasoningTokens, maxTotalOutputTokens } = hints;
511
- if (maxTotalOutputTokens === void 0) return;
512
- if (maxVisibleOutputTokens !== void 0 && maxVisibleOutputTokens > maxTotalOutputTokens) context.addIssue({
513
- code: "custom",
514
- path: ["maxVisibleOutputTokens"],
515
- message: "maxVisibleOutputTokens must not exceed maxTotalOutputTokens"
516
- });
517
- if (maxReasoningTokens !== void 0 && maxReasoningTokens > maxTotalOutputTokens) context.addIssue({
518
- code: "custom",
519
- path: ["maxReasoningTokens"],
520
- message: "maxReasoningTokens must not exceed maxTotalOutputTokens"
521
- });
522
- }
523
- const agentProfileModelHintsSchema = z.strictObject({
524
- default: z.string().optional(),
525
- small: z.string().optional(),
526
- provider: z.string().optional(),
527
- reasoningEffort: reasoningEffortSchema.optional(),
528
- maxVisibleOutputTokens: z.number().int().positive().optional(),
529
- maxReasoningTokens: z.number().int().positive().optional(),
530
- maxTotalOutputTokens: z.number().int().positive().optional(),
531
- metadata: ownPropertyRecordSchema(z.unknown()).optional()
532
- }).superRefine(enforceModelTokenBounds);
533
- /** Ordered account selection policy, without credentials or ambient model defaults. */
534
- const agentProfileSeatSchema = z.strictObject({
535
- harness: harnessTypeSchema,
536
- provider: z.string().regex(/^[a-z][a-z0-9-]*$/),
537
- model: z.string().min(1).refine((value) => value.trim() === value, "model must be canonical"),
538
- selector: z.union([z.strictObject({ kind: z.literal("all-eligible") }), z.strictObject({
539
- kind: z.literal("seat"),
540
- id: z.string().min(1).refine((value) => value.trim() === value, "seat id must be canonical")
541
- })]),
542
- tools: ownPropertyRecordSchema(z.boolean()).optional(),
543
- permissions: ownPropertyRecordSchema(agentProfilePermissionSchema).optional()
544
- });
545
- /**
546
- * Replacement and addition are separate, independently optional fields, and the
547
- * pair is admitted on purpose: the effective prompt is `systemPrompt` followed
548
- * by `appendSystemPrompt`. No cross-field refinement rejects the combination,
549
- * because {@link mergeAgentProfiles} can produce it from two valid profiles.
550
- */
551
- const agentProfilePromptSchema = z.strictObject({
552
- systemPrompt: z.string().optional(),
553
- appendSystemPrompt: z.string().optional(),
554
- instructions: z.array(z.string()).optional()
555
- });
556
- const controlCharacterPattern = /[\u0000-\u001f\u007f]/;
557
- const secretCapableNamePattern = /(?:^|[_-])(?:api[_-]?key|access[_-]?key|private[_-]?key|token|secret|password|credentials?|authorization|cookie|database[_-]?url|dsn|pat)(?:[_-]|$)/i;
558
- /** Return true when a public config name denotes credential material. */
559
- function isCredentialBearingProfileConfigName(name) {
560
- return secretCapableNamePattern.test(name);
561
- }
562
- const publicProfileConfigStringSchema = z.string().refine((value) => isWellFormedUnicode(value) && !controlCharacterPattern.test(value) && !looksLikeCredential(value), "public profile config cannot carry credential-like material");
563
- const secretReferenceKeySchema = z.string().min(1).max(500).refine((value) => value.trim().length > 0 && isWellFormedUnicode(value) && !controlCharacterPattern.test(value) && !looksLikeCredential(value), "secret reference key must be a public non-credential identity");
564
- const agentProfilePublicConfigValueSchema = z.strictObject({
565
- kind: z.literal("public"),
566
- value: publicProfileConfigStringSchema
567
- });
568
- const agentProfileSecretRefSchema = z.strictObject({
569
- kind: z.literal("secret-ref"),
570
- key: secretReferenceKeySchema,
571
- format: z.enum(["raw", "bearer"]).optional()
572
- });
573
- const agentProfileConfigValueSchema = z.discriminatedUnion("kind", [agentProfilePublicConfigValueSchema, agentProfileSecretRefSchema]);
574
- function profileConfigRecordSchema(keySchema) {
575
- return ownPropertyRecordSchema(agentProfileConfigValueSchema).superRefine((record, context) => {
576
- for (const [name, value] of Object.entries(record)) {
577
- if (!keySchema.safeParse(name).success) context.addIssue({
578
- code: "custom",
579
- path: [name],
580
- message: "profile config key is invalid for this field"
581
- });
582
- if (value.kind === "public" && isCredentialBearingProfileConfigName(name)) context.addIssue({
583
- code: "custom",
584
- path: [name],
585
- message: "credential-bearing config names require a secret-ref"
586
- });
587
- }
588
- });
589
- }
590
- const agentProfileEnvironmentSchema = profileConfigRecordSchema(environmentNameSchema);
591
- const agentProfileHeaderSchema = profileConfigRecordSchema(headerNameSchema);
592
- const agentSubagentProfileSchema = z.strictObject({
593
- description: z.string().optional(),
594
- prompt: z.string().optional(),
595
- model: z.string().optional(),
596
- tools: ownPropertyRecordSchema(z.boolean()).optional(),
597
- permissions: ownPropertyRecordSchema(agentProfilePermissionSchema).optional(),
598
- maxSteps: z.number().optional(),
599
- metadata: ownPropertyRecordSchema(z.unknown()).optional()
600
- });
601
- const agentProfileHookCommandSchema = z.strictObject({
602
- command: z.string(),
603
- timeoutMs: z.number().positive().optional(),
604
- blocking: z.boolean().optional(),
605
- matcher: z.string().optional(),
606
- env: agentProfileEnvironmentSchema.optional()
607
- });
608
- const agentProfileModeSchema = z.strictObject({
609
- description: z.string().optional(),
610
- model: z.string().optional(),
611
- prompt: z.string().optional(),
612
- tools: ownPropertyRecordSchema(z.boolean()).optional(),
613
- permissions: ownPropertyRecordSchema(agentProfilePermissionSchema).optional(),
614
- metadata: ownPropertyRecordSchema(z.unknown()).optional()
615
- });
616
- const agentProfileConfidentialSchema = z.strictObject({
617
- tee: z.string().optional(),
618
- attestationNonce: z.string().optional(),
619
- sealed: z.boolean().optional(),
620
- attestationRefresh: z.boolean().optional()
621
- });
622
- const nonBlankMcpValueSchema = z.string().refine((value) => value.trim().length > 0, "value cannot be blank");
623
- const remoteMcpUrlSchema = nonBlankMcpValueSchema.refine((value) => {
624
- try {
625
- const url = new URL(value);
626
- return url.protocol === "http:" || url.protocol === "https:";
627
- } catch {
628
- return false;
629
- }
630
- }, "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");
631
- const agentProfileLocalMcpServerSchema = z.strictObject({
632
- transport: z.literal("stdio").optional(),
633
- command: nonBlankMcpValueSchema.refine(isSafeExecutable, "local MCP command must be a canonical public executable"),
634
- args: z.array(agentProfileConfigValueSchema).optional(),
635
- env: agentProfileEnvironmentSchema.optional(),
636
- cwd: z.string().refine((value) => isSafeRelativePath(value, true), "local MCP cwd must be a canonical workspace-relative path").optional(),
637
- url: z.undefined().optional(),
638
- headers: z.undefined().optional(),
639
- enabled: z.literal(true).optional(),
640
- metadata: ownPropertyRecordSchema(z.unknown()).optional()
641
- });
642
- const agentProfileRemoteMcpServerSchema = z.strictObject({
643
- transport: z.enum(["sse", "http"]).optional(),
644
- command: z.undefined().optional(),
645
- args: z.undefined().optional(),
646
- env: z.undefined().optional(),
647
- cwd: z.undefined().optional(),
648
- url: remoteMcpUrlSchema,
649
- headers: agentProfileHeaderSchema.optional(),
650
- enabled: z.literal(true).optional(),
651
- metadata: ownPropertyRecordSchema(z.unknown()).optional()
652
- });
653
- const agentProfileDisabledMcpServerSchema = z.strictObject({
654
- enabled: z.literal(false),
655
- transport: z.undefined().optional(),
656
- command: z.undefined().optional(),
657
- args: z.undefined().optional(),
658
- env: z.undefined().optional(),
659
- cwd: z.undefined().optional(),
660
- url: z.undefined().optional(),
661
- headers: z.undefined().optional(),
662
- metadata: ownPropertyRecordSchema(z.unknown()).optional()
663
- });
664
- const agentProfileMcpServerSchema = z.union([
665
- agentProfileLocalMcpServerSchema,
666
- agentProfileRemoteMcpServerSchema,
667
- agentProfileDisabledMcpServerSchema
668
- ]);
669
- const agentProfileConnectionSchema = z.strictObject({
670
- connectionId: z.string().min(1),
671
- capabilities: z.array(z.string().min(1)).min(1),
672
- alias: z.string().min(1).optional()
673
- });
674
- const removeListSchema = z.union([z.literal(true), z.array(z.string().min(1))]);
675
- const agentProfilePromptRemovalSchema = z.strictObject({
676
- systemPrompt: z.literal(true).optional(),
677
- appendSystemPrompt: z.literal(true).optional(),
678
- instructions: removeListSchema.optional()
679
- });
680
- const agentProfileResourceRemovalSchema = z.strictObject({
681
- files: removeListSchema.optional(),
682
- tools: removeListSchema.optional(),
683
- skills: removeListSchema.optional(),
684
- agents: removeListSchema.optional(),
685
- commands: removeListSchema.optional(),
686
- instructions: z.literal(true).optional(),
687
- failOnError: z.literal(true).optional()
688
- });
689
- const agentProfileDiffRemovalSchema = z.strictObject({
690
- identity: z.literal(true).optional(),
691
- tags: removeListSchema.optional(),
692
- prompt: z.union([z.literal(true), agentProfilePromptRemovalSchema]).optional(),
693
- model: removeListSchema.optional(),
694
- harness: z.literal(true).optional(),
695
- seats: z.literal(true).optional(),
696
- permissions: removeListSchema.optional(),
697
- tools: removeListSchema.optional(),
698
- mcp: removeListSchema.optional(),
699
- connections: removeListSchema.optional(),
700
- subagents: removeListSchema.optional(),
701
- resources: z.union([z.literal(true), agentProfileResourceRemovalSchema]).optional(),
702
- hooks: removeListSchema.optional(),
703
- modes: removeListSchema.optional(),
704
- confidential: z.literal(true).optional(),
705
- metadata: removeListSchema.optional(),
706
- extensions: removeListSchema.optional()
707
- });
708
- 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");
709
- const agentTrainingTaskSchema = z.strictObject({
710
- benchmark: trainingIdentitySchema,
711
- task: trainingIdentitySchema,
712
- contentDigest: sha256DigestSchema
713
- });
714
- /** The same order is used by dataset ingestion, receipt admission and holdout checks. */
715
- function agentTrainingTaskKey(task) {
716
- return JSON.stringify([
717
- task.benchmark,
718
- task.task,
719
- task.contentDigest
720
- ]);
721
- }
722
- const agentTrainingDatasetIdentitySchema = z.strictObject({
723
- digest: sha256DigestSchema,
724
- taskSetDigest: sha256DigestSchema,
725
- tasks: z.array(agentTrainingTaskSchema).min(1).max(1e4)
726
- }).superRefine((dataset, context) => {
727
- const keys = dataset.tasks.map(agentTrainingTaskKey);
728
- if (keys.some((key, index) => index > 0 && key <= keys[index - 1])) context.addIssue({
729
- code: "custom",
730
- path: ["tasks"],
731
- message: "training tasks must be sorted and unique"
732
- });
733
- if (canonicalCandidateDigest(dataset.tasks) !== dataset.taskSetDigest) context.addIssue({
734
- code: "custom",
735
- path: ["taskSetDigest"],
736
- message: "training task inventory digest mismatch"
737
- });
738
- });
739
- const agentTrainingParametersSchema = ownPropertyRecordSchema(z.union([
740
- z.string().max(2048).pipe(publicProfileConfigStringSchema),
741
- z.number().finite(),
742
- z.boolean(),
743
- z.null()
744
- ])).superRefine((parameters, context) => {
745
- if (Object.keys(parameters).length > 100) context.addIssue({
746
- code: "custom",
747
- message: "at most 100 public training parameters are allowed"
748
- });
749
- for (const name of Object.keys(parameters)) if (!trainingIdentitySchema.safeParse(name).success || isCredentialBearingProfileConfigName(name)) context.addIssue({
750
- code: "custom",
751
- path: [name],
752
- message: "training parameter name must be public and non-credential"
753
- });
754
- });
755
- const agentTrainingReceiptSchema = z.strictObject({
756
- version: z.literal(1),
757
- dataset: agentTrainingDatasetIdentitySchema,
758
- parentProfileDigest: sha256DigestSchema,
759
- parentReceiptDigest: sha256DigestSchema.nullable(),
760
- executionRef: sha256DigestSchema,
761
- trainer: z.strictObject({
762
- mode: z.enum(["command", "managed"]),
763
- id: trainingIdentitySchema,
764
- revision: sha256DigestSchema,
765
- parameters: agentTrainingParametersSchema
766
- }),
767
- checkpoint: z.strictObject({
768
- artifactDigest: sha256DigestSchema,
769
- artifactBytes: z.number().int().positive().max(Number.MAX_SAFE_INTEGER),
770
- routerModelId: trainingIdentitySchema,
771
- servingDigest: sha256DigestSchema
772
- })
773
- }).superRefine((receipt, context) => {
774
- if (receipt.checkpoint.routerModelId !== trainedModelIdForArtifact(receipt.checkpoint.artifactDigest)) context.addIssue({
775
- code: "custom",
776
- path: ["checkpoint", "routerModelId"],
777
- message: "trained Router model must be artifact-addressed"
778
- });
779
- });
780
- const agentProfileTrainingSchema = z.strictObject({
781
- receipt: agentTrainingReceiptSchema,
782
- ancestors: z.array(agentTrainingReceiptSchema).max(8)
783
- }).superRefine((training, context) => {
784
- const chain = [training.receipt, ...training.ancestors];
785
- const digests = chain.map(canonicalCandidateDigest);
786
- if (new Set(digests).size !== digests.length) context.addIssue({
787
- code: "custom",
788
- message: "training receipt ancestry must not repeat"
789
- });
790
- for (let index = 0; index < chain.length; index++) if (chain[index].parentReceiptDigest !== (digests[index + 1] ?? null)) context.addIssue({
791
- code: "custom",
792
- message: "training receipt ancestry is incomplete or has been altered"
793
- });
794
- });
795
- const agentProfileMetadataSchema = ownPropertyRecordSchema(z.unknown()).superRefine((metadata, context) => {
796
- if (!Object.hasOwn(metadata, "training")) return;
797
- const result = agentProfileTrainingSchema.safeParse(metadata.training);
798
- if (!result.success) for (const issue of result.error.issues) context.addIssue({
799
- code: "custom",
800
- path: ["training", ...issue.path],
801
- message: issue.message
802
- });
803
- });
804
- /**
805
- * The complete provider-neutral agent profile schema — the runtime validator for
806
- * the canonical {@link AgentProfile} TS contract. Kept structurally in lock-step
807
- * with that interface by the compile-time guard at the bottom of this file.
808
- */
809
- const agentProfileSchema = z.strictObject({
810
- name: z.string().optional(),
811
- description: z.string().optional(),
812
- version: z.string().optional(),
813
- tags: z.array(z.string()).optional(),
814
- prompt: agentProfilePromptSchema.optional(),
815
- model: agentProfileModelHintsSchema.optional(),
816
- harness: harnessTypeSchema.optional(),
817
- seats: z.array(agentProfileSeatSchema).nonempty().optional(),
818
- permissions: ownPropertyRecordSchema(agentProfilePermissionSchema).optional(),
819
- tools: ownPropertyRecordSchema(z.boolean()).optional(),
820
- mcp: ownPropertyRecordSchema(agentProfileMcpServerSchema).optional(),
821
- connections: z.array(agentProfileConnectionSchema).optional(),
822
- subagents: ownPropertyRecordSchema(agentSubagentProfileSchema).optional(),
823
- resources: agentProfileResourcesSchema.optional(),
824
- hooks: ownPropertyRecordSchema(z.array(agentProfileHookCommandSchema)).optional(),
825
- modes: ownPropertyRecordSchema(agentProfileModeSchema).optional(),
826
- confidential: agentProfileConfidentialSchema.optional(),
827
- metadata: agentProfileMetadataSchema.optional(),
828
- extensions: ownPropertyRecordSchema(z.union([ownPropertyRecordSchema(z.unknown()), z.undefined()])).optional()
829
- }).superRefine((profile, context) => {
830
- validateNestedRecordKeys(profile, context, [], /* @__PURE__ */ new Set());
831
- if (profile.seats?.length) {
832
- const first = profile.seats[0];
833
- if (first.harness !== profile.harness || first.provider !== profile.model?.provider || first.model !== profile.model?.default) context.addIssue({
834
- code: "custom",
835
- path: ["seats", 0],
836
- message: "first seat must match profile harness, model.provider, and model.default"
837
- });
838
- if (first.tools !== void 0 && canonicalAgentProfileJson(first.tools) !== canonicalAgentProfileJson(profile.tools)) context.addIssue({
839
- code: "custom",
840
- path: [
841
- "seats",
842
- 0,
843
- "tools"
844
- ],
845
- message: "first seat tools must match profile tools"
846
- });
847
- if (first.permissions !== void 0 && canonicalAgentProfileJson(first.permissions) !== canonicalAgentProfileJson(profile.permissions)) context.addIssue({
848
- code: "custom",
849
- path: [
850
- "seats",
851
- 0,
852
- "permissions"
853
- ],
854
- message: "first seat permissions must match profile permissions"
855
- });
856
- for (const [index, seat] of profile.seats.entries()) {
857
- if (resolveModelProvider(seat.model) !== seat.provider) context.addIssue({
858
- code: "custom",
859
- path: [
860
- "seats",
861
- index,
862
- "provider"
863
- ],
864
- message: "seat provider must match the model provider"
865
- });
866
- if (!harnessHonorsModel(seat.harness)) context.addIssue({
867
- code: "custom",
868
- path: [
869
- "seats",
870
- index,
871
- "harness"
872
- ],
873
- message: "seat harness does not honor an exact model choice"
874
- });
875
- const support = harnessModelSupport(seat.harness, seat.model, { reasoningEffort: profile.model?.reasoningEffort });
876
- if (!support.supported) context.addIssue({
877
- code: "custom",
878
- path: [
879
- "seats",
880
- index,
881
- "model"
882
- ],
883
- message: support.message
884
- });
885
- const effort = profile.model?.reasoningEffort;
886
- if (effort !== void 0 && (!harnessHonorsEffort(seat.harness) || !harnessReasoningEfforts(seat.harness).includes(effort))) context.addIssue({
887
- code: "custom",
888
- path: [
889
- "seats",
890
- index,
891
- "harness"
892
- ],
893
- message: "seat harness cannot honor profile reasoning effort"
894
- });
895
- const prompt = harnessSystemPromptIntents(seat.harness);
896
- if (profile.prompt?.systemPrompt !== void 0 && !prompt.replace) context.addIssue({
897
- code: "custom",
898
- path: [
899
- "seats",
900
- index,
901
- "harness"
902
- ],
903
- message: "seat harness cannot replace the system prompt"
904
- });
905
- if (profile.prompt?.appendSystemPrompt !== void 0 && !prompt.append) context.addIssue({
906
- code: "custom",
907
- path: [
908
- "seats",
909
- index,
910
- "harness"
911
- ],
912
- message: "seat harness cannot append the system prompt"
913
- });
914
- }
915
- }
916
- const training = agentProfileTrainingSchema.safeParse(profile.metadata?.training);
917
- if (profile.model?.default?.startsWith("tangle-trained/") && !training.success) context.addIssue({
918
- code: "custom",
919
- path: ["metadata", "training"],
920
- message: "trained model requires a checkpoint receipt"
921
- });
922
- if ([
923
- profile.model?.small,
924
- ...Object.values(profile.subagents ?? {}).map((agent) => agent.model),
925
- ...Object.values(profile.modes ?? {}).map((mode) => mode.model)
926
- ].some((model) => model?.startsWith("tangle-trained/") && (!training.success || model !== training.data.receipt.checkpoint.routerModelId))) context.addIssue({
927
- code: "custom",
928
- message: "trained auxiliary models require the same receipted checkpoint"
929
- });
930
- if (training.success && profile.model?.default !== training.data.receipt.checkpoint.routerModelId) context.addIssue({
931
- code: "custom",
932
- path: ["model", "default"],
933
- message: "trained profile model must equal the receipt's Router model"
934
- });
935
- });
936
- const encodedRecordKeyPattern = "^u(?:[0-9a-f]{4})*$";
937
- function isEncodedRecordKeyPropertyNames(value) {
938
- if (value === null || typeof value !== "object" || Array.isArray(value)) return false;
939
- const propertyNames = value;
940
- return propertyNames.type === "string" && propertyNames.pattern === encodedRecordKeyPattern;
941
- }
942
- function removeModelInputSchemaArtifacts(value) {
943
- if (Array.isArray(value)) return value.map(removeModelInputSchemaArtifacts);
944
- if (value === null || typeof value !== "object") return value;
945
- const result = {};
946
- for (const [key, entry] of Object.entries(value)) {
947
- if (key === "$schema") continue;
948
- if (key === "propertyNames" && isEncodedRecordKeyPropertyNames(entry)) continue;
949
- result[key] = removeModelInputSchemaArtifacts(entry);
950
- }
951
- return result;
952
- }
953
- /**
954
- * Model-facing JSON Schema for an authored {@link AgentProfile}.
955
- *
956
- * This is generated from {@link agentProfileSchema}'s input contract rather
957
- * than restating the profile shape. Zod sees encoded record keys at its
958
- * preprocessing boundary, so the generated `propertyNames` constraints for
959
- * that internal encoding are removed before exposing the schema to callers.
960
- * The root dialect declaration is also omitted because tool APIs embed this
961
- * value as a subschema rather than serving it as a standalone document.
962
- * Runtime admission remains the canonical Zod validator above.
963
- */
964
- const agentProfileJsonSchema = removeModelInputSchemaArtifacts(z.toJSONSchema(agentProfileSchema, {
965
- target: "draft-2020-12",
966
- io: "input",
967
- unrepresentable: "any"
968
- }));
969
- function validateNestedRecordKeys(value, context, path, seen) {
970
- if (value === null || typeof value !== "object" || seen.has(value)) return;
971
- seen.add(value);
972
- for (const [key, entry] of Object.entries(value)) {
973
- if (!isWellFormedUnicode(key)) context.addIssue({
974
- code: "custom",
975
- path: [...path, key],
976
- message: "record keys must contain valid Unicode"
977
- });
978
- validateNestedRecordKeys(entry, context, [...path, key], seen);
979
- }
980
- }
981
- z.strictObject({
982
- kind: z.literal("agent-profile-diff"),
983
- id: z.string().min(1).optional(),
984
- title: z.string().min(1).optional(),
985
- description: z.string().optional(),
986
- rationale: z.string().optional(),
987
- source: z.strictObject({
988
- kind: z.enum([
989
- "trace",
990
- "frontier-author",
991
- "human",
992
- "optimizer",
993
- "compound"
994
- ]),
995
- artifacts: z.array(z.string().min(1)).optional(),
996
- notes: z.array(z.string()).optional()
997
- }).optional(),
998
- set: agentProfileSchema.optional(),
999
- remove: agentProfileDiffRemovalSchema.optional(),
1000
- metadata: ownPropertyRecordSchema(z.unknown()).optional()
1001
- });
1002
- z.strictObject({
1003
- id: z.string().min(1),
1004
- definition: agentProfileSchema,
1005
- recommendedSize: z.enum(SANDBOX_SIZE_PRESET_NAMES).optional()
1006
- });
1007
- //#endregion
1008
- //#region ../../../packages/runtime-contracts/dist/harness-warm-transport.js
1009
- /** Persistent Kimi wire process and shared create/resume prewarm gates. */
1010
- const AGENT_INTERNAL_KIMI_WARM_SERVER_ENV_VAR = "AGENT_INTERNAL_KIMI_WARM_SERVER";
1011
- //#endregion
1012
- //#region ../../../packages/cli-agent-registry/dist/native-session-contracts-B8cbOI1r.mjs
1013
- /** The CLI version infra/nix ships for each registered harness. */
1014
- const HARNESS_CLI_VERSIONS = {
1015
- "claude-code": "2.1.311",
1016
- codex: "0.164.0",
1017
- opencode: "1.19.4",
1018
- pi: "1.4.0",
1019
- "kimi-code": "1.49.0",
1020
- "factory-droids": "0.249.0",
1021
- amp: "0.0.1793044831-ga1b1a0",
1022
- prime: "0.10.1",
1023
- hermes: "0.22.4",
1024
- forge: "2.14.0",
1025
- openclaw: "2026.10.7",
1026
- acp: "claude-agent-acp 0.97.0; codex-acp 0.16.0; gemini-cli 0.65.0"
1027
- };
1028
- const CLAUDE_PROJECTS = {
1029
- root: ".claude/projects",
1030
- files: ["*/{id}.jsonl", "*/{id}/subagents/**/*.jsonl"],
1031
- write: "jsonl-append",
1032
- shared: false,
1033
- format: "claude-code.projects-jsonl"
1034
- };
1035
- const CODEX_ROLLOUTS = {
1036
- root: ".codex/sessions",
1037
- files: ["*/*/*/rollout-*-{id}.jsonl"],
1038
- write: "jsonl-append",
1039
- shared: false,
1040
- format: "codex.rollout-jsonl"
1041
- };
1042
- /**
1043
- * Rollouts codex moved out of `sessions/` when a thread was archived: the same
1044
- * transcript, flat under `archived_sessions/`. Without it an archived
1045
- * session is no store's, so no copy, capture or export carries it.
1046
- */
1047
- const CODEX_ARCHIVED_ROLLOUTS = {
1048
- root: ".codex/archived_sessions",
1049
- files: ["rollout-*-{id}.jsonl"],
1050
- write: "jsonl-append",
1051
- shared: false,
1052
- format: "codex.rollout-jsonl"
1053
- };
1054
- const GEMINI_CHATS = {
1055
- root: ".gemini/tmp",
1056
- files: ["*/chats/session-*{id}*.json"],
1057
- write: "json-rewrite",
1058
- shared: false,
1059
- format: "gemini.chat-json"
1060
- };
1061
- const KIMI_SESSIONS = {
1062
- root: ".kimi/sessions",
1063
- files: ["*/{id}/**", "*/{id}.jsonl"],
1064
- write: "jsonl-append",
1065
- shared: false,
1066
- format: "kimi.session-dir"
1067
- };
1068
- const HERMES_STATE = {
1069
- root: ".hermes",
1070
- files: [
1071
- "state.db",
1072
- "state.db-wal",
1073
- "state.db-shm"
1074
- ],
1075
- write: "sqlite-wal",
1076
- shared: true,
1077
- format: "hermes.state-sqlite"
1078
- };
1079
- var acp_default = {
1080
- session: {
1081
- kind: "native",
1082
- processProbe: {
1083
- versionCommand: `set -eu
1084
- separator=''
1085
- for entry in claude-agent-acp:claude-agent-acp codex-acp:codex-acp gemini-cli:gemini; do
1086
- package=\${entry%%:*}
1087
- binary=\${entry#*:}
1088
- executable=$(readlink -f "$(command -v "$binary")")
1089
- case "$executable" in /nix/store/*-"$package"-*/bin/"$binary") ;; *) exit 1 ;; esac
1090
- store=\${executable#/nix/store/}
1091
- derivation=\${store%%/*}
1092
- version=\${derivation#*-"$package"-}
1093
- test -n "$version"
1094
- printf '%s%s %s' "$separator" "$package" "$version"
1095
- separator='; '
1096
- done
1097
- printf '\\n'`,
1098
- kill: ["-f", "[h]ermes.* acp( |$)"]
1099
- },
1100
- contract: {
1101
- version: 1,
1102
- stores: [
1103
- CLAUDE_PROJECTS,
1104
- CODEX_ROLLOUTS,
1105
- GEMINI_CHATS,
1106
- KIMI_SESSIONS,
1107
- HERMES_STATE
1108
- ],
1109
- identity: {
1110
- kind: "api-created",
1111
- call: "acp session/new"
1112
- },
1113
- resume: { kind: "api" },
1114
- forbiddenArgs: [],
1115
- storeEnv: {},
1116
- evidence: {
1117
- servedModel: "session-record",
1118
- usage: "per-response",
1119
- endingError: "none"
1120
- },
1121
- cliVersion: HARNESS_CLI_VERSIONS.acp
1122
- },
1123
- defect: {
1124
- issue: "#10096",
1125
- reason: "contract is declared per sub-agent; gemini needs a mock dialect"
1126
- }
1127
- },
1128
- config: {
1129
- kind: "model",
1130
- providerRequiresModel: true,
1131
- keySources: [
1132
- "managed",
1133
- "api-key",
1134
- "api-key-env",
1135
- "cli-auth"
1136
- ],
1137
- baseUrl: "caller-or-managed",
1138
- modelWire: "openai-compat",
1139
- envVars: {
1140
- apiKey: "OPENCODE_MODEL_API_KEY",
1141
- model: "TANGLE_ROUTER_MODEL",
1142
- baseUrl: "TANGLE_ROUTER_BASE_URL",
1143
- authFiles: "ACP_AUTH_FILES_JSON"
1144
- }
1145
- },
1146
- lifecycle: {
1147
- runtime: void 0,
1148
- coldCreate: { kind: "required" },
1149
- warmClaim: { kind: "required" },
1150
- parkResume: { kind: "required" },
1151
- branchChild: { kind: "required" },
1152
- killResume: { kind: "required" }
1153
- }
1154
- };
1155
- var amp_default = {
1156
- session: {
1157
- kind: "native",
1158
- processProbe: {
1159
- versionCommand: "amp --version",
1160
- kill: ["-x", "amp"]
1161
- },
1162
- contract: {
1163
- version: 1,
1164
- stores: [{
1165
- root: ".local/share/amp/threads",
1166
- files: ["{id}.json"],
1167
- write: "json-rewrite",
1168
- shared: false,
1169
- format: "amp.thread-json"
1170
- }],
1171
- identity: {
1172
- kind: "first-event",
1173
- event: "thread",
1174
- deadlineMs: 6e4
1175
- },
1176
- resume: {
1177
- kind: "args",
1178
- args: [
1179
- "threads",
1180
- "continue",
1181
- "{id}"
1182
- ]
1183
- },
1184
- forbiddenArgs: [],
1185
- storeEnv: { XDG_DATA_HOME: ".local/share" },
1186
- evidence: {
1187
- servedModel: "session-record",
1188
- usage: "per-response",
1189
- endingError: "none"
1190
- },
1191
- cliVersion: HARNESS_CLI_VERSIONS.amp
1192
- },
1193
- defect: {
1194
- issue: "#10096",
1195
- reason: "threads live on ampcode.com; neither a local copy nor a mock-routable model is proven"
1196
- }
1197
- },
1198
- config: {
1199
- kind: "model",
1200
- providerRequiresModel: true,
1201
- keySources: [
1202
- "api-key",
1203
- "api-key-env",
1204
- "cli-auth"
1205
- ],
1206
- baseUrl: "vendor-only",
1207
- modelWire: "openai-compat",
1208
- envVars: {
1209
- apiKey: "AMP_API_KEY",
1210
- model: "AMP_MODEL_NAME",
1211
- authMode: "AMP_AUTH_MODE",
1212
- authFiles: "AMP_AUTH_FILES_JSON"
1213
- }
1214
- },
1215
- lifecycle: {
1216
- runtime: void 0,
1217
- coldCreate: { kind: "required" },
1218
- warmClaim: { kind: "required" },
1219
- parkResume: { kind: "required" },
1220
- branchChild: { kind: "required" },
1221
- killResume: { kind: "required" }
1222
- }
1223
- };
1224
- var claude_code_default = {
1225
- session: {
1226
- kind: "native",
1227
- processProbe: {
1228
- versionCommand: "claude --version",
1229
- kill: ["-x", "claude"]
1230
- },
1231
- contract: {
1232
- version: 1,
1233
- stores: [CLAUDE_PROJECTS],
1234
- identity: {
1235
- kind: "pre-minted",
1236
- args: ["--session-id", "{id}"]
1237
- },
1238
- resume: {
1239
- kind: "args",
1240
- args: ["--resume", "{id}"]
1241
- },
1242
- forbiddenArgs: ["--no-session-persistence", "--fork-session"],
1243
- storeEnv: { CLAUDE_CONFIG_DIR: ".claude" },
1244
- evidence: {
1245
- servedModel: "provider-response",
1246
- usage: "per-response",
1247
- endingError: "session-record"
1248
- },
1249
- cliVersion: HARNESS_CLI_VERSIONS["claude-code"]
1250
- },
1251
- defect: null
1252
- },
1253
- config: {
1254
- kind: "model",
1255
- providerRequiresModel: true,
1256
- assertions: [
1257
- "managed-full-ladder",
1258
- "operator-model-first",
1259
- "named-model-exact"
1260
- ],
1261
- keySources: [
1262
- "managed",
1263
- "api-key",
1264
- "api-key-env",
1265
- "cli-auth"
1266
- ],
1267
- baseUrl: "caller-or-managed",
1268
- modelWire: "anthropic-messages",
1269
- envVars: {
1270
- apiKey: "ANTHROPIC_API_KEY",
1271
- model: "CLAUDE_CODE_MODEL_NAME",
1272
- authMode: "CLAUDE_CODE_AUTH_MODE",
1273
- authFiles: "CLAUDE_CODE_AUTH_FILES_JSON",
1274
- oauthToken: "CLAUDE_CODE_OAUTH_TOKEN",
1275
- baseUrl: "ANTHROPIC_BASE_URL"
1276
- }
1277
- },
1278
- lifecycle: {
1279
- runtime: {},
1280
- coldCreate: { kind: "required" },
1281
- warmClaim: { kind: "required" },
1282
- parkResume: { kind: "required" },
1283
- branchChild: { kind: "required" },
1284
- killResume: { kind: "required" }
1285
- }
1286
- };
1287
- var cli_base_default = {
1288
- session: {
1289
- kind: "no-agent",
1290
- reason: "This backend runs no agent process"
1291
- },
1292
- config: {
1293
- kind: "no-agent",
1294
- envVars: {},
1295
- reason: "This backend accepts no model or provider"
1296
- },
1297
- lifecycle: {
1298
- runtime: void 0,
1299
- coldCreate: {
1300
- kind: "unsupported",
1301
- reason: "This backend runs no agent turn"
1302
- },
1303
- warmClaim: {
1304
- kind: "unsupported",
1305
- reason: "This backend runs no agent turn"
1306
- },
1307
- parkResume: {
1308
- kind: "unsupported",
1309
- reason: "This backend runs no agent turn"
1310
- },
1311
- branchChild: {
1312
- kind: "unsupported",
1313
- reason: "This backend runs no agent turn"
1314
- },
1315
- killResume: {
1316
- kind: "unsupported",
1317
- reason: "The backend exposes no resumable native session"
1318
- }
1319
- }
1320
- };
1321
- var codex_default = {
1322
- session: {
1323
- kind: "native",
1324
- processProbe: {
1325
- versionCommand: "codex --version",
1326
- kill: ["-f", "bin/[c]odex( |$)"]
1327
- },
1328
- contract: {
1329
- version: 1,
1330
- stores: [CODEX_ROLLOUTS, CODEX_ARCHIVED_ROLLOUTS],
1331
- identity: {
1332
- kind: "first-event",
1333
- event: "thread.started",
1334
- deadlineMs: 3e4
1335
- },
1336
- resume: {
1337
- kind: "args",
1338
- args: [
1339
- "exec",
1340
- "resume",
1341
- "{id}"
1342
- ]
1343
- },
1344
- forbiddenArgs: ["--ephemeral"],
1345
- storeEnv: { CODEX_HOME: ".codex" },
1346
- evidence: {
1347
- servedModel: "turn-context",
1348
- usage: "cumulative",
1349
- endingError: "session-record"
1350
- },
1351
- cliVersion: HARNESS_CLI_VERSIONS.codex
1352
- },
1353
- defect: null
1354
- },
1355
- config: {
1356
- kind: "model",
1357
- providerRequiresModel: true,
1358
- assertions: [
1359
- "managed-full-ladder",
1360
- "operator-model-first",
1361
- "named-model-exact",
1362
- "responses-config-model-id"
1363
- ],
1364
- keySources: [
1365
- "managed",
1366
- "api-key",
1367
- "api-key-env",
1368
- "cli-auth"
1369
- ],
1370
- baseUrl: "caller-or-managed",
1371
- modelWire: "openai-responses",
1372
- envVars: {
1373
- apiKey: "OPENAI_API_KEY",
1374
- model: "CODEX_MODEL_NAME",
1375
- authMode: "CODEX_AUTH_MODE",
1376
- authFiles: "CODEX_AUTH_FILES_JSON",
1377
- baseUrl: "OPENAI_BASE_URL"
1378
- }
1379
- },
1380
- lifecycle: {
1381
- runtime: void 0,
1382
- coldCreate: { kind: "required" },
1383
- warmClaim: { kind: "required" },
1384
- parkResume: { kind: "required" },
1385
- branchChild: { kind: "required" },
1386
- killResume: { kind: "required" }
1387
- }
1388
- };
1389
- var cursor_default = {
1390
- session: {
1391
- kind: "unsupported",
1392
- defect: {
1393
- issue: "#10096",
1394
- reason: "runs the Cursor SDK in process; the cloud runtime stores the session remotely and model calls cannot be mocked"
1395
- }
1396
- },
1397
- config: {
1398
- kind: "model",
1399
- providerRequiresModel: true,
1400
- keySources: ["api-key", "api-key-env"],
1401
- baseUrl: "vendor-only",
1402
- modelWire: "openai-compat",
1403
- envVars: {
1404
- apiKey: "CURSOR_API_KEY",
1405
- model: "CURSOR_MODEL_NAME"
1406
- }
1407
- },
1408
- lifecycle: {
1409
- runtime: void 0,
1410
- coldCreate: { kind: "required" },
1411
- warmClaim: { kind: "required" },
1412
- parkResume: { kind: "required" },
1413
- branchChild: { kind: "required" },
1414
- killResume: {
1415
- kind: "unsupported",
1416
- reason: "The backend exposes no resumable native session"
1417
- }
1418
- }
1419
- };
1420
- var factory_droids_default = {
1421
- session: {
1422
- kind: "native",
1423
- processProbe: {
1424
- versionCommand: "droid --version",
1425
- kill: ["-x", "droid"]
1426
- },
1427
- contract: {
1428
- version: 1,
1429
- stores: [{
1430
- root: ".factory/sessions",
1431
- files: ["*/{id}.jsonl"],
1432
- write: "jsonl-append",
1433
- shared: false,
1434
- format: "factory.session-jsonl"
1435
- }, {
1436
- root: ".factory/sessions",
1437
- files: ["*/{id}.settings.json"],
1438
- write: "json-rewrite",
1439
- shared: false,
1440
- format: "factory.session-jsonl"
1441
- }],
1442
- identity: {
1443
- kind: "first-event",
1444
- event: "session_id",
1445
- deadlineMs: 6e4
1446
- },
1447
- resume: {
1448
- kind: "args",
1449
- args: ["--session-id", "{id}"]
1450
- },
1451
- forbiddenArgs: [],
1452
- storeEnv: {},
1453
- evidence: {
1454
- servedModel: "turn-context",
1455
- usage: "session-total",
1456
- endingError: "none"
1457
- },
1458
- cliVersion: HARNESS_CLI_VERSIONS["factory-droids"]
1459
- },
1460
- defect: {
1461
- issue: "#10096",
1462
- reason: "droid 0.232.0 resumes with --session-id only after it fetches the session from api.factory.ai, and the reader reads no usage, model or ending error from the session; the other checks pass (2026-10-05)"
1463
- }
1464
- },
1465
- config: {
1466
- kind: "model",
1467
- providerRequiresModel: true,
1468
- keySources: [
1469
- "managed",
1470
- "api-key",
1471
- "api-key-env"
1472
- ],
1473
- baseUrl: "caller-or-managed",
1474
- modelWire: "openai-compat",
1475
- envVars: {
1476
- apiKey: "FACTORY_API_KEY",
1477
- model: "FACTORY_DROIDS_MODEL_NAME"
1478
- }
1479
- },
1480
- lifecycle: {
1481
- runtime: void 0,
1482
- coldCreate: { kind: "required" },
1483
- warmClaim: { kind: "required" },
1484
- parkResume: { kind: "required" },
1485
- branchChild: { kind: "required" },
1486
- killResume: { kind: "required" }
1487
- }
1488
- };
1489
- var forge_default = {
1490
- session: {
1491
- kind: "native",
1492
- processProbe: {
1493
- versionCommand: "forgecode --version",
1494
- kill: ["-x", "forgecode"]
1495
- },
1496
- contract: {
1497
- version: 1,
1498
- stores: [{
1499
- root: ".forge",
1500
- files: [
1501
- ".forge.db",
1502
- ".forge.db-wal",
1503
- ".forge.db-shm"
1504
- ],
1505
- write: "sqlite-wal",
1506
- shared: true,
1507
- format: "forge.sqlite"
1508
- }],
1509
- identity: {
1510
- kind: "first-event",
1511
- event: "conversation",
1512
- deadlineMs: 6e4
1513
- },
1514
- resume: {
1515
- kind: "args",
1516
- args: ["--conversation-id", "{id}"]
1517
- },
1518
- forbiddenArgs: [],
1519
- storeEnv: {},
1520
- evidence: {
1521
- servedModel: "session-record",
1522
- usage: "per-response",
1523
- endingError: "none"
1524
- },
1525
- cliVersion: HARNESS_CLI_VERSIONS.forge
1526
- },
1527
- defect: {
1528
- issue: "#10096",
1529
- reason: "needs a SQLite-consistent capture and a .forge.db reader"
1530
- }
1531
- },
1532
- config: {
1533
- kind: "model",
1534
- providerRequiresModel: true,
1535
- keySources: [
1536
- "managed",
1537
- "api-key",
1538
- "api-key-env",
1539
- "cli-auth"
1540
- ],
1541
- baseUrl: "caller-or-managed",
1542
- modelWire: "openai-compat",
1543
- envVars: {
1544
- apiKey: "FORGE_API_KEY",
1545
- model: "FORGE_MODEL_ID",
1546
- authMode: "FORGE_AUTH_MODE",
1547
- authFiles: "FORGE_AUTH_FILES_JSON",
1548
- extras: {
1549
- FORGE_SESSION__PROVIDER_ID: { parser: "string" },
1550
- FORGE_SESSION__MODEL_ID: { parser: "string" },
1551
- FORGE_AGENT_ID: { parser: "string" }
1552
- }
1553
- }
1554
- },
1555
- lifecycle: {
1556
- runtime: void 0,
1557
- coldCreate: { kind: "required" },
1558
- warmClaim: { kind: "required" },
1559
- parkResume: { kind: "required" },
1560
- branchChild: { kind: "required" },
1561
- killResume: { kind: "required" }
1562
- }
1563
- };
1564
- var hermes_default = {
1565
- session: {
1566
- kind: "native",
1567
- processProbe: {
1568
- versionCommand: "hermes --version",
1569
- kill: ["-f", "(^|/)[h]ermes( |$)"]
1570
- },
1571
- contract: {
1572
- version: 1,
1573
- stores: [HERMES_STATE],
1574
- identity: {
1575
- kind: "first-event",
1576
- event: "session_id",
1577
- deadlineMs: 6e4
1578
- },
1579
- resume: {
1580
- kind: "args",
1581
- args: ["--resume", "{id}"]
1582
- },
1583
- forbiddenArgs: [],
1584
- storeEnv: { HERMES_HOME: ".hermes" },
1585
- evidence: {
1586
- servedModel: "session-record",
1587
- usage: "session-total",
1588
- endingError: "none"
1589
- },
1590
- cliVersion: HARNESS_CLI_VERSIONS.hermes
1591
- },
1592
- defect: {
1593
- issue: "#10096",
1594
- reason: "HERMES_HOME lives under the workspace, and the session id arrives on stderr after exit"
1595
- }
1596
- },
1597
- config: {
1598
- kind: "model",
1599
- providerRequiresModel: true,
1600
- keySources: [
1601
- "managed",
1602
- "api-key",
1603
- "api-key-env",
1604
- "cli-auth"
1605
- ],
1606
- baseUrl: "caller-or-managed",
1607
- modelWire: "openai-compat",
1608
- envVars: {
1609
- apiKey: "HERMES_API_KEY",
1610
- model: "HERMES_MODEL_NAME",
1611
- authMode: "HERMES_AUTH_MODE",
1612
- authFiles: "HERMES_AUTH_FILES_JSON",
1613
- baseUrl: "HERMES_BASE_URL",
1614
- extras: { HERMES_INFERENCE_PROVIDER: { parser: "string" } }
1615
- }
1616
- },
1617
- lifecycle: {
1618
- runtime: void 0,
1619
- coldCreate: { kind: "required" },
1620
- warmClaim: { kind: "required" },
1621
- parkResume: { kind: "required" },
1622
- branchChild: { kind: "required" },
1623
- killResume: { kind: "required" }
1624
- }
1625
- };
1626
- var kimi_code_default = {
1627
- session: {
1628
- kind: "native",
1629
- processProbe: {
1630
- versionCommand: "kimi --version",
1631
- kill: ["-f", "^[K]imi Code"]
1632
- },
1633
- contract: {
1634
- version: 1,
1635
- stores: [KIMI_SESSIONS],
1636
- identity: {
1637
- kind: "pre-minted",
1638
- args: ["--session", "{id}"]
1639
- },
1640
- resume: {
1641
- kind: "args",
1642
- args: ["--session", "{id}"]
1643
- },
1644
- forbiddenArgs: [],
1645
- storeEnv: {},
1646
- evidence: {
1647
- servedModel: "session-record",
1648
- usage: "per-response",
1649
- endingError: "none"
1650
- },
1651
- cliVersion: HARNESS_CLI_VERSIONS["kimi-code"]
1652
- },
1653
- defect: {
1654
- issue: "#10096",
1655
- reason: "kimi-cli 1.49.0 records no model id, served or requested, in its session files, and the reader reads the ending HTTP 500 as aborted; the other checks pass (2026-10-05)"
1656
- }
1657
- },
1658
- config: {
1659
- kind: "model",
1660
- providerRequiresModel: true,
1661
- assertions: ["moonshot-provider-lock"],
1662
- keySources: [
1663
- "managed",
1664
- "api-key",
1665
- "api-key-env",
1666
- "cli-auth"
1667
- ],
1668
- baseUrl: "caller-or-managed",
1669
- modelWire: "openai-compat",
1670
- envVars: {
1671
- apiKey: "MOONSHOT_API_KEY",
1672
- model: "KIMI_CODE_MODEL_NAME",
1673
- authMode: "KIMI_CODE_AUTH_MODE",
1674
- authFiles: "KIMI_CODE_AUTH_FILES_JSON",
1675
- extras: { OPENAI_BASE_URL: { parser: "string" } }
1676
- }
1677
- },
1678
- lifecycle: {
1679
- runtime: { warmRetention: {
1680
- envVar: AGENT_INTERNAL_KIMI_WARM_SERVER_ENV_VAR,
1681
- enabledByDefault: false
1682
- } },
1683
- coldCreate: { kind: "required" },
1684
- warmClaim: { kind: "required" },
1685
- parkResume: { kind: "required" },
1686
- branchChild: { kind: "required" },
1687
- killResume: { kind: "required" }
1688
- }
1689
- };
1690
- var nanoclaw_default = {
1691
- session: {
1692
- kind: "unsupported",
1693
- defect: {
1694
- issue: "#10096",
1695
- reason: "runs chat.ts against a NanoClaw daemon over a Unix socket: no session id, no resume, and the store belongs to the daemon"
1696
- }
1697
- },
1698
- config: {
1699
- kind: "model",
1700
- providerRequiresModel: true,
1701
- keySources: [
1702
- "managed",
1703
- "api-key",
1704
- "api-key-env"
1705
- ],
1706
- baseUrl: "caller-or-managed",
1707
- modelWire: "openai-compat",
1708
- envVars: {
1709
- apiKey: "OPENCODE_MODEL_API_KEY",
1710
- model: "TANGLE_ROUTER_MODEL",
1711
- authMode: "NANOCLAW_AUTH_MODE",
1712
- baseUrl: "TANGLE_ROUTER_BASE_URL",
1713
- extras: {
1714
- NANOCLAW_PROJECT_ROOT: { parser: "string" },
1715
- NANOCLAW_NATIVE_CREDENTIALS: { parser: "string" },
1716
- OPENCODE_MODEL_PROVIDER: {
1717
- parser: "string",
1718
- role: "provider"
1719
- }
1720
- }
1721
- }
1722
- },
1723
- lifecycle: {
1724
- runtime: void 0,
1725
- coldCreate: { kind: "required" },
1726
- warmClaim: { kind: "required" },
1727
- parkResume: { kind: "required" },
1728
- branchChild: { kind: "required" },
1729
- killResume: {
1730
- kind: "unsupported",
1731
- reason: "The backend exposes no resumable native session"
1732
- }
1733
- }
1734
- };
1735
- var openclaw_default = {
1736
- session: {
1737
- kind: "native",
1738
- processProbe: {
1739
- versionCommand: "openclaw --version",
1740
- kill: ["-f", "[o]penclaw(\\.mjs)?( |$)"]
1741
- },
1742
- contract: {
1743
- version: 1,
1744
- stores: [{
1745
- root: ".openclaw/agents",
1746
- files: ["**/{id}.jsonl"],
1747
- write: "jsonl-append",
1748
- shared: false,
1749
- format: "openclaw.session-jsonl"
1750
- }],
1751
- identity: {
1752
- kind: "first-event",
1753
- event: "session",
1754
- deadlineMs: 6e4
1755
- },
1756
- resume: {
1757
- kind: "args",
1758
- args: ["--session-id", "{id}"]
1759
- },
1760
- forbiddenArgs: [],
1761
- storeEnv: {},
1762
- evidence: {
1763
- servedModel: "session-record",
1764
- usage: "per-response",
1765
- endingError: "none"
1766
- },
1767
- cliVersion: HARNESS_CLI_VERSIONS.openclaw
1768
- },
1769
- defect: {
1770
- issue: "#10096",
1771
- reason: "config is pinned outside the runtime HOME; store layout unverified"
1772
- }
1773
- },
1774
- config: {
1775
- kind: "model",
1776
- providerRequiresModel: true,
1777
- keySources: [
1778
- "managed",
1779
- "api-key",
1780
- "api-key-env",
1781
- "cli-auth"
1782
- ],
1783
- baseUrl: "caller-or-managed",
1784
- modelWire: "openai-compat",
1785
- envVars: {
1786
- apiKey: "OPENCODE_MODEL_API_KEY",
1787
- model: "TANGLE_ROUTER_MODEL",
1788
- baseUrl: "TANGLE_ROUTER_BASE_URL",
1789
- authMode: "OPENCLAW_AUTH_MODE",
1790
- authFiles: "OPENCLAW_AUTH_FILES_JSON"
1791
- }
1792
- },
1793
- lifecycle: {
1794
- runtime: void 0,
1795
- coldCreate: { kind: "required" },
1796
- warmClaim: { kind: "required" },
1797
- parkResume: { kind: "required" },
1798
- branchChild: { kind: "required" },
1799
- killResume: { kind: "required" }
1800
- }
1801
- };
1802
- const HARNESSES = {
1803
- "claude-code": claude_code_default,
1804
- codex: codex_default,
1805
- opencode: {
1806
- session: {
1807
- kind: "native",
1808
- processProbe: {
1809
- versionCommand: "opencode --version",
1810
- kill: ["-x", "opencode"]
1811
- },
1812
- contract: {
1813
- version: 1,
1814
- stores: [{
1815
- root: ".local/share/opencode",
1816
- files: [
1817
- "opencode.db",
1818
- "opencode.db-wal",
1819
- "opencode.db-shm"
1820
- ],
1821
- write: "sqlite-wal",
1822
- shared: true,
1823
- format: "opencode.sqlite"
1824
- }],
1825
- identity: {
1826
- kind: "first-event",
1827
- event: "sessionID",
1828
- deadlineMs: 3e5
1829
- },
1830
- resume: {
1831
- kind: "args",
1832
- args: ["--session", "{id}"]
1833
- },
1834
- forbiddenArgs: [],
1835
- storeEnv: { XDG_DATA_HOME: ".local/share" },
1836
- evidence: {
1837
- servedModel: "turn-context",
1838
- usage: "per-response",
1839
- endingError: "session-record"
1840
- },
1841
- cliVersion: HARNESS_CLI_VERSIONS.opencode
1842
- },
1843
- defect: null
1844
- },
1845
- config: {
1846
- kind: "model",
1847
- providerRequiresModel: true,
1848
- keySources: [
1849
- "managed",
1850
- "api-key",
1851
- "api-key-env"
1852
- ],
1853
- baseUrl: "caller-or-managed",
1854
- modelWire: "openai-compat",
1855
- envVars: {
1856
- apiKey: "OPENCODE_MODEL_API_KEY",
1857
- model: "OPENCODE_MODEL_NAME",
1858
- baseUrl: "OPENCODE_MODEL_BASE_URL",
1859
- extras: {
1860
- OPENCODE_MODEL_PROVIDER: {
1861
- parser: "string",
1862
- role: "provider"
1863
- },
1864
- OPENCODE_MODEL_MODE: {
1865
- parser: "string",
1866
- role: "mode"
1867
- }
1868
- }
1869
- }
1870
- },
1871
- lifecycle: {
1872
- runtime: {
1873
- redactsHostEnv: true,
1874
- supportsToolDisabledTurns: true
1875
- },
1876
- coldCreate: { kind: "required" },
1877
- warmClaim: { kind: "required" },
1878
- parkResume: { kind: "required" },
1879
- branchChild: { kind: "required" },
1880
- killResume: { kind: "required" }
1881
- }
1882
- },
1883
- pi: {
1884
- session: {
1885
- kind: "native",
1886
- processProbe: {
1887
- versionCommand: "pi --version",
1888
- kill: ["-x", "pi"]
1889
- },
1890
- contract: {
1891
- version: 1,
1892
- stores: [{
1893
- root: ".pi/agent/sessions",
1894
- files: ["**/*_{id}.jsonl"],
1895
- write: "jsonl-append",
1896
- shared: false,
1897
- format: "pi.session-jsonl"
1898
- }],
1899
- identity: {
1900
- kind: "pre-minted",
1901
- args: ["--session-id", "{id}"]
1902
- },
1903
- resume: {
1904
- kind: "args",
1905
- args: ["--session", "{id}"]
1906
- },
1907
- forbiddenArgs: [
1908
- "--no-session",
1909
- "--fork",
1910
- "--continue"
1911
- ],
1912
- storeEnv: {
1913
- PI_CODING_AGENT_DIR: ".pi/agent",
1914
- PI_CODING_AGENT_SESSION_DIR: ".pi/agent/sessions",
1915
- "--session-dir": ".pi/agent/sessions"
1916
- },
1917
- evidence: {
1918
- servedModel: "session-record",
1919
- usage: "per-response",
1920
- endingError: "session-record"
1921
- },
1922
- cliVersion: HARNESS_CLI_VERSIONS.pi
1923
- },
1924
- defect: null
1925
- },
1926
- config: {
1927
- kind: "model",
1928
- providerRequiresModel: true,
1929
- keySources: [
1930
- "managed",
1931
- "api-key",
1932
- "api-key-env",
1933
- "cli-auth"
1934
- ],
1935
- baseUrl: "caller-or-managed",
1936
- modelWire: "openai-compat",
1937
- envVars: {
1938
- apiKey: "OPENCODE_MODEL_API_KEY",
1939
- model: "TANGLE_ROUTER_MODEL",
1940
- baseUrl: "TANGLE_ROUTER_BASE_URL"
1941
- }
1942
- },
1943
- lifecycle: {
1944
- runtime: {},
1945
- coldCreate: { kind: "required" },
1946
- warmClaim: { kind: "required" },
1947
- parkResume: { kind: "required" },
1948
- branchChild: { kind: "required" },
1949
- killResume: { kind: "required" }
1950
- }
1951
- },
1952
- "kimi-code": kimi_code_default,
1953
- "factory-droids": factory_droids_default,
1954
- amp: amp_default,
1955
- prime: {
1956
- session: {
1957
- kind: "native",
1958
- processProbe: {
1959
- versionCommand: "prime-agent --version",
1960
- kill: ["-f", "[p]rime-agent"]
1961
- },
1962
- contract: {
1963
- version: 1,
1964
- stores: [{
1965
- root: ".prime-provider/prime-agent-dirs",
1966
- files: ["**/*_{id}.jsonl"],
1967
- write: "jsonl-append",
1968
- shared: false,
1969
- format: "prime.session-jsonl"
1970
- }],
1971
- identity: {
1972
- kind: "api-created",
1973
- call: "acp session/new"
1974
- },
1975
- resume: { kind: "api" },
1976
- forbiddenArgs: ["--no-session"],
1977
- storeEnv: {},
1978
- evidence: {
1979
- servedModel: "session-record",
1980
- usage: "per-response",
1981
- endingError: "session-record"
1982
- },
1983
- cliVersion: HARNESS_CLI_VERSIONS.prime
1984
- },
1985
- defect: {
1986
- issue: "#10096",
1987
- reason: "no conformance receipt for the runtime-HOME agent dir yet"
1988
- }
1989
- },
1990
- config: {
1991
- kind: "model",
1992
- providerRequiresModel: true,
1993
- keySources: [
1994
- "managed",
1995
- "api-key",
1996
- "api-key-env"
1997
- ],
1998
- baseUrl: "caller-or-managed",
1999
- modelWire: "openai-compat",
2000
- envVars: {
2001
- apiKey: "OPENCODE_MODEL_API_KEY",
2002
- model: "TANGLE_ROUTER_MODEL",
2003
- baseUrl: "TANGLE_ROUTER_BASE_URL"
2004
- }
2005
- },
2006
- lifecycle: {
2007
- runtime: void 0,
2008
- coldCreate: { kind: "required" },
2009
- warmClaim: { kind: "required" },
2010
- parkResume: { kind: "required" },
2011
- branchChild: { kind: "required" },
2012
- killResume: { kind: "required" }
2013
- }
2014
- },
2015
- hermes: hermes_default,
2016
- forge: forge_default,
2017
- openclaw: openclaw_default,
2018
- nanoclaw: nanoclaw_default,
2019
- acp: acp_default,
2020
- cursor: cursor_default,
2021
- "cli-base": cli_base_default
2022
- };
2023
- /**
2024
- * The native session projection of the per-harness declarations in harness-contracts/. Each entry is
2025
- * proven by a conformance receipt (tests/harness/receipts) for
2026
- * its pinned CLI version, or is listed in HARNESS_CONFORMANCE_PENDING.
2027
- *
2028
- * CLI versions are the pins in infra/nix (agent-clis.json and flake.nix),
2029
- * generated into harness-cli-versions.ts by the bump. The registry test
2030
- * tests/harness-session-contract.test.ts fails when a pin, a contract or an
2031
- * adapter's source moves without a new receipt.
2032
- */
2033
- const NATIVE_SESSION_CONTRACTS = {
2034
- "claude-code": HARNESSES["claude-code"].session.contract,
2035
- codex: HARNESSES["codex"].session.contract,
2036
- opencode: HARNESSES["opencode"].session.contract,
2037
- pi: HARNESSES["pi"].session.contract,
2038
- "kimi-code": HARNESSES["kimi-code"].session.contract,
2039
- "factory-droids": HARNESSES["factory-droids"].session.contract,
2040
- amp: HARNESSES["amp"].session.contract,
2041
- prime: HARNESSES["prime"].session.contract,
2042
- hermes: HARNESSES["hermes"].session.contract,
2043
- forge: HARNESSES["forge"].session.contract,
2044
- openclaw: HARNESSES["openclaw"].session.contract,
2045
- acp: HARNESSES["acp"].session.contract
2046
- };
2047
- HARNESSES["kimi-code"].session.defect.reason, HARNESSES["factory-droids"].session.defect.reason, HARNESSES["amp"].session.defect.reason, HARNESSES["prime"].session.defect.reason, HARNESSES["hermes"].session.defect.reason, HARNESSES["forge"].session.defect.reason, HARNESSES["openclaw"].session.defect.reason, HARNESSES["acp"].session.defect.reason;
2048
- HARNESSES["nanoclaw"].session.defect.reason, HARNESSES["cursor"].session.defect.reason;
2049
- //#endregion
2050
- //#region ../../../packages/cli-agent-registry/dist/specs-BXZvq1L9.mjs
2051
- z.globalRegistry.add(agentProfileSchema, {
2052
- id: "AgentProfile",
2053
- ...agentProfileJsonSchema
2054
- });
2055
- const CLI_AGENT_SPECS = [
2056
- {
2057
- name: BACKEND_TYPE.OPENCODE,
2058
- nativeSession: NATIVE_SESSION_CONTRACTS.opencode,
2059
- messageStorageDir: ".opencode",
2060
- cliDirLayout: {
2061
- sessionData: ["snapshot/**"],
2062
- configAllow: ["bin/**"]
2063
- },
2064
- displayName: "OpenCode Agent",
2065
- description: "OpenCode CLI coding agent with native sessions, profiles, tools, and MCP.",
2066
- envVars: HARNESSES["opencode"].config.envVars,
2067
- capabilities: {
2068
- streaming: true,
2069
- toolUse: true,
2070
- reasoning: true,
2071
- multimodal: true,
2072
- contextWindow: 2e5,
2073
- mcp: true,
2074
- runtimeAttachments: { mcp: true },
2075
- sessions: true,
2076
- configurable: true,
2077
- interactions: [
2078
- "permission",
2079
- "question",
2080
- "plan"
2081
- ],
2082
- imageInput: true
2083
- },
2084
- hostPassthroughEnvVars: [
2085
- "OPENCODE_MODEL_MODE",
2086
- "OPENCODE_CODEX_PLUGIN_VERSION",
2087
- "OPENCODE_EXPERIMENTAL_NATIVE_LLM"
2088
- ],
2089
- interactiveSeededPrompt: true,
2090
- builtinTools: [
2091
- {
2092
- id: "apply_patch",
2093
- name: "Apply Patch",
2094
- description: "Apply a unified-diff patch to files"
2095
- },
2096
- {
2097
- id: "bash",
2098
- name: "Bash",
2099
- description: "Execute bash commands"
2100
- },
2101
- {
2102
- id: "codesearch",
2103
- name: "Code Search",
2104
- description: "Search code across the workspace"
2105
- },
2106
- {
2107
- id: "edit",
2108
- name: "Edit",
2109
- description: "Edit a file with string replacement"
2110
- },
2111
- {
2112
- id: "glob",
2113
- name: "Glob",
2114
- description: "Find files by glob pattern"
2115
- },
2116
- {
2117
- id: "grep",
2118
- name: "Grep",
2119
- description: "Search file contents using regular expressions"
2120
- },
2121
- {
2122
- id: "question",
2123
- name: "Question",
2124
- description: "Ask the user a question and wait for the answer"
2125
- },
2126
- {
2127
- id: "read",
2128
- name: "Read",
2129
- description: "Read file contents"
2130
- },
2131
- {
2132
- id: "skill",
2133
- name: "Skill",
2134
- description: "Invoke an installed skill"
2135
- },
2136
- {
2137
- id: "task",
2138
- name: "Task",
2139
- description: "Delegate a task to a subagent"
2140
- },
2141
- {
2142
- id: "todowrite",
2143
- name: "Todo Write",
2144
- description: "Maintain the turn's todo list"
2145
- },
2146
- {
2147
- id: "webfetch",
2148
- name: "Webfetch",
2149
- description: "Fetch and read web content"
2150
- },
2151
- {
2152
- id: "websearch",
2153
- name: "Websearch",
2154
- description: "Search the web"
2155
- },
2156
- {
2157
- id: "write",
2158
- name: "Write",
2159
- description: "Write content to a file"
2160
- }
2161
- ],
2162
- runtime: HARNESSES["opencode"].lifecycle.runtime,
2163
- cliAuthHome: { kind: "inherit-home" },
2164
- hasCliAuth: false
2165
- },
2166
- {
2167
- name: BACKEND_TYPE.CLAUDE_CODE,
2168
- nativeSession: NATIVE_SESSION_CONTRACTS["claude-code"],
2169
- runtime: HARNESSES["claude-code"].lifecycle.runtime,
2170
- messageStorageDir: ".claude-code",
2171
- cliDirLayout: {
2172
- sessionData: [
2173
- "plans/**",
2174
- "file-history/**",
2175
- "debug/**",
2176
- "projects/*/*/subagents/**/*.meta.json",
2177
- "projects/*/*/tool-results/**"
2178
- ],
2179
- configAllow: [
2180
- ".last-cleanup",
2181
- "policy-limits.json*",
2182
- "remote-settings.json",
2183
- "skills/**"
2184
- ],
2185
- credential: [
2186
- "backups/**",
2187
- "session-env/**",
2188
- "shell-snapshots/**",
2189
- "sessions/**"
2190
- ]
2191
- },
2192
- displayName: "Claude Code",
2193
- description: "Anthropic Claude Code CLI-based agent backend.",
2194
- envVars: HARNESSES["claude-code"].config.envVars,
2195
- modelWire: HARNESSES["claude-code"].config.modelWire,
2196
- capabilities: {
2197
- streaming: true,
2198
- toolUse: true,
2199
- reasoning: true,
2200
- multimodal: true,
2201
- contextWindow: 2e5,
2202
- mcp: true,
2203
- runtimeAttachments: { mcp: true },
2204
- sessions: true,
2205
- configurable: true,
2206
- interactions: [
2207
- "permission",
2208
- "question",
2209
- "plan"
2210
- ],
2211
- imageInput: true
2212
- },
2213
- securityCapabilities: [
2214
- "SYS_PTRACE",
2215
- "SETUID",
2216
- "SETGID",
2217
- "DAC_OVERRIDE",
2218
- "CHOWN",
2219
- "FOWNER"
2220
- ],
2221
- interactiveSeededPrompt: true,
2222
- cliAuthHome: {
2223
- kind: "agent-home",
2224
- uid: 1e3,
2225
- home: "/home/agent"
2226
- },
2227
- hasCliAuth: true,
2228
- byoOAuth: true
2229
- },
2230
- {
2231
- name: BACKEND_TYPE.KIMI_CODE,
2232
- nativeSession: NATIVE_SESSION_CONTRACTS["kimi-code"],
2233
- runtime: HARNESSES["kimi-code"].lifecycle.runtime,
2234
- messageStorageDir: ".kimi-code",
2235
- displayName: "Kimi Code",
2236
- description: "Moonshot AI Kimi Code CLI — headless non-interactive mode via `kimi --print --output-format stream-json --prompt ...`. Defaults to OAuth (Kimi Code subscription) with credentials materialized from the host-managed ~/.kimi/credentials/kimi-code.json; falls back to MOONSHOT_API_KEY when an apiKey is supplied.",
2237
- envVars: HARNESSES["kimi-code"].config.envVars,
2238
- capabilities: {
2239
- streaming: true,
2240
- toolUse: true,
2241
- reasoning: true,
2242
- multimodal: true,
2243
- contextWindow: 262144,
2244
- mcp: false,
2245
- runtimeAttachments: { mcp: true },
2246
- sessions: true,
2247
- configurable: true,
2248
- interactions: [],
2249
- imageInput: false
2250
- },
2251
- cliAuthHome: { kind: "inherit-home" },
2252
- hasCliAuth: true
2253
- },
2254
- {
2255
- name: BACKEND_TYPE.CODEX,
2256
- nativeSession: NATIVE_SESSION_CONTRACTS.codex,
2257
- messageStorageDir: ".codex",
2258
- cliDirLayout: { sessionData: [
2259
- "logs_*.sqlite*",
2260
- "goals_*.sqlite*",
2261
- "memories_*.sqlite*"
2262
- ] },
2263
- displayName: "Codex",
2264
- description: "OpenAI Codex CLI-based agent backend.",
2265
- envVars: HARNESSES["codex"].config.envVars,
2266
- modelWire: HARNESSES["codex"].config.modelWire,
2267
- capabilities: {
2268
- streaming: true,
2269
- toolUse: true,
2270
- reasoning: false,
2271
- multimodal: true,
2272
- contextWindow: 128e3,
2273
- mcp: false,
2274
- sessions: true,
2275
- configurable: false,
2276
- runtimeAttachments: { mcp: true },
2277
- interactions: [
2278
- "permission",
2279
- "question",
2280
- "plan"
2281
- ],
2282
- imageInput: true
2283
- },
2284
- interactiveSeededPrompt: true,
2285
- cliAuthHome: { kind: "inherit-home" },
2286
- hasCliAuth: true,
2287
- byoOAuth: true
2288
- },
2289
- {
2290
- name: BACKEND_TYPE.AMP,
2291
- nativeSession: NATIVE_SESSION_CONTRACTS.amp,
2292
- messageStorageDir: ".amp-sessions",
2293
- displayName: "AMP (Sourcegraph)",
2294
- description: "Sourcegraph AMP CLI-based agent backend.",
2295
- callerCredentialOnly: true,
2296
- envVars: HARNESSES["amp"].config.envVars,
2297
- capabilities: {
2298
- streaming: true,
2299
- toolUse: true,
2300
- reasoning: false,
2301
- multimodal: false,
2302
- contextWindow: 128e3,
2303
- mcp: false,
2304
- sessions: true,
2305
- configurable: false,
2306
- interactions: [],
2307
- imageInput: false
2308
- },
2309
- cliAuthHome: { kind: "inherit-home" },
2310
- hasCliAuth: true
2311
- },
2312
- {
2313
- name: BACKEND_TYPE.FACTORY_DROIDS,
2314
- nativeSession: NATIVE_SESSION_CONTRACTS["factory-droids"],
2315
- messageStorageDir: ".factory-droids",
2316
- displayName: "Factory Droids",
2317
- description: "Factory Droids CLI-based agent backend. A managed box runs its Tangle Router model as a droid custom model; a caller's FACTORY_API_KEY runs on the caller's Factory account.",
2318
- envVars: HARNESSES["factory-droids"].config.envVars,
2319
- capabilities: {
2320
- streaming: true,
2321
- toolUse: true,
2322
- reasoning: false,
2323
- multimodal: false,
2324
- contextWindow: 128e3,
2325
- mcp: false,
2326
- sessions: true,
2327
- configurable: false,
2328
- interactions: ["question"],
2329
- imageInput: false
2330
- },
2331
- cliAuthHome: { kind: "inherit-home" },
2332
- hasCliAuth: true
2333
- },
2334
- {
2335
- name: BACKEND_TYPE.PI,
2336
- nativeSession: NATIVE_SESSION_CONTRACTS.pi,
2337
- runtime: HARNESSES["pi"].lifecycle.runtime,
2338
- messageStorageDir: ".pi/agent",
2339
- displayName: "Pi",
2340
- description: "Pi CLI backend. Managed OpenAI-compatible model tuples use one private runtime HOME models.json and the shared Pi model schema.",
2341
- envVars: HARNESSES["pi"].config.envVars,
2342
- capabilities: {
2343
- streaming: true,
2344
- toolUse: true,
2345
- reasoning: true,
2346
- multimodal: false,
2347
- contextWindow: 128e3,
2348
- mcp: true,
2349
- sessions: true,
2350
- configurable: true,
2351
- interactions: ["permission"],
2352
- runtimeAttachments: { mcp: true },
2353
- imageInput: false
2354
- },
2355
- interactiveSeededPrompt: true,
2356
- cliAuthHome: { kind: "inherit-home" },
2357
- hasCliAuth: true
2358
- },
2359
- {
2360
- name: BACKEND_TYPE.PRIME,
2361
- nativeSession: NATIVE_SESSION_CONTRACTS.prime,
2362
- messageStorageDir: ".prime-provider",
2363
- displayName: "Prime Agent (PrimeIntellect)",
2364
- description: "PrimeIntellect-ai/prime-agent — IPython-first coding agent (pi hard fork, fork line 0.7.x) driven over its native ACP mode. Model tuple travels via backend.model into a per-session materialized models.json, never env; the adapter pins PRIME_AGENT_CODING_AGENT_DIR to an isolated per-session agent dir (fail-closed harness-state isolation).",
2365
- envVars: HARNESSES["prime"].config.envVars,
2366
- hostPassthroughEnvVars: ["PRIME_AGENT_INSTALL_UV", "PRIME_AGENT_KERNEL_PYTHON"],
2367
- capabilities: {
2368
- streaming: true,
2369
- toolUse: true,
2370
- reasoning: true,
2371
- multimodal: true,
2372
- contextWindow: 128e3,
2373
- mcp: false,
2374
- sessions: true,
2375
- configurable: true,
2376
- interactions: [],
2377
- imageInput: true
2378
- },
2379
- cliAuthHome: { kind: "inherit-home" },
2380
- hasCliAuth: false
2381
- },
2382
- {
2383
- name: BACKEND_TYPE.HERMES,
2384
- nativeSession: NATIVE_SESSION_CONTRACTS.hermes,
2385
- messageStorageDir: ".hermes-agent",
2386
- cliDirLayout: {
2387
- sessionData: ["cache/spillover/**", "cache/delegation/**"],
2388
- configAllow: ["config.yaml"]
2389
- },
2390
- displayName: "Hermes Agent (Nous Research)",
2391
- description: "Open-source self-improving CLI agent. Persistent memory and skills live in $HERMES_HOME (pinned to the per-session workspace mount, not the read-only in-box $HOME) across same-tenant snapshot resumes — the learning loop is the differentiator. Provider-pluggable; defaults to OpenRouter via Tangle Router.",
2392
- envVars: HARNESSES["hermes"].config.envVars,
2393
- capabilities: {
2394
- streaming: false,
2395
- toolUse: true,
2396
- reasoning: false,
2397
- multimodal: false,
2398
- contextWindow: 2e5,
2399
- mcp: true,
2400
- sessions: true,
2401
- configurable: true,
2402
- interactions: [],
2403
- imageInput: true
2404
- },
2405
- cliAuthHome: { kind: "inherit-home" },
2406
- hasCliAuth: true
2407
- },
2408
- {
2409
- name: BACKEND_TYPE.FORGE,
2410
- nativeSession: NATIVE_SESSION_CONTRACTS.forge,
2411
- messageStorageDir: ".forge-agent",
2412
- displayName: "Forge (forgecode.dev)",
2413
- description: "Rust-built multi-provider coding agent from tailcallhq/forgecode. Speaks anthropic/openai/openrouter/gemini/deepseek/kimi + local providers (ollama, lm_studio, llama_cpp). Credentials live in ~/.forge/.credentials.json, materialized via the standard authFiles pipeline — no interactive `forge provider login` required.",
2414
- envVars: HARNESSES["forge"].config.envVars,
2415
- capabilities: {
2416
- streaming: false,
2417
- toolUse: true,
2418
- reasoning: true,
2419
- multimodal: false,
2420
- contextWindow: 2e5,
2421
- mcp: true,
2422
- sessions: true,
2423
- configurable: true,
2424
- interactions: [],
2425
- imageInput: false
2426
- },
2427
- cliAuthHome: { kind: "inherit-home" },
2428
- hasCliAuth: true
2429
- },
2430
- {
2431
- name: BACKEND_TYPE.OPENCLAW,
2432
- nativeSession: NATIVE_SESSION_CONTRACTS.openclaw,
2433
- messageStorageDir: ".openclaw-agent",
2434
- cliDirLayout: { configAllow: ["openclaw.json"] },
2435
- displayName: "OpenClaw (Orchestrator)",
2436
- description: "Orchestrator-tier CLI agent that dispatches to underlying coding-agent CLIs (claude-cli, codex-cli, gemini-cli) via its built-in cliBackends plugin model. Use this when you want one entry point that intelligently routes tasks to the right coding harness.",
2437
- envVars: HARNESSES["openclaw"].config.envVars,
2438
- capabilities: {
2439
- streaming: false,
2440
- toolUse: true,
2441
- reasoning: true,
2442
- multimodal: true,
2443
- contextWindow: 2e5,
2444
- mcp: true,
2445
- sessions: true,
2446
- configurable: true,
2447
- interactions: [],
2448
- imageInput: false
2449
- },
2450
- cliAuthHome: { kind: "inherit-home" },
2451
- hasCliAuth: true
2452
- },
2453
- {
2454
- name: BACKEND_TYPE.NANOCLAW,
2455
- nativeSession: null,
2456
- messageStorageDir: ".nanoclaw-agent",
2457
- displayName: "NanoClaw",
2458
- description: "NanoClaw local socket bridge. Requires a running NanoClaw install and uses its `pnpm run chat` CLI channel; the adapter does not manage NanoClaw's Docker/service lifecycle.",
2459
- envVars: HARNESSES["nanoclaw"].config.envVars,
2460
- capabilities: {
2461
- streaming: false,
2462
- toolUse: true,
2463
- reasoning: true,
2464
- multimodal: false,
2465
- contextWindow: 2e5,
2466
- mcp: false,
2467
- sessions: true,
2468
- configurable: true,
2469
- interactions: [],
2470
- imageInput: false
2471
- },
2472
- cliAuthHome: { kind: "inherit-home" },
2473
- hasCliAuth: false
2474
- },
2475
- {
2476
- name: BACKEND_TYPE.ACP,
2477
- nativeSession: NATIVE_SESSION_CONTRACTS.acp,
2478
- messageStorageDir: ".acp-agent",
2479
- displayName: "ACP Bridge (multi-agent)",
2480
- description: "Generic Agent Client Protocol bridge — fronts any ACP-compliant agent binary (claude-agent-acp, codex-acp, gemini, openclaw acp, hermes acp). Pick the backing agent via config.subAgent; hermes runs on the box's Router model when none is named. One TypeScript adapter, many supported coding harnesses.",
2481
- envVars: HARNESSES["acp"].config.envVars,
2482
- capabilities: {
2483
- streaming: true,
2484
- toolUse: true,
2485
- reasoning: true,
2486
- multimodal: false,
2487
- contextWindow: 2e5,
2488
- mcp: false,
2489
- sessions: true,
2490
- configurable: true,
2491
- interactions: ["permission"],
2492
- imageInput: false
2493
- },
2494
- cliAuthHome: { kind: "inherit-home" },
2495
- hasCliAuth: true
2496
- },
2497
- {
2498
- name: BACKEND_TYPE.CURSOR,
2499
- nativeSession: null,
2500
- messageStorageDir: ".cursor-sdk-sessions",
2501
- displayName: "Cursor Agent SDK",
2502
- description: "Cursor Agent SDK backend. Runs Cursor's local agent against the sandbox workspace via @cursor/sdk, using CURSOR_API_KEY or backend.model.apiKey for authentication.",
2503
- callerCredentialOnly: true,
2504
- egressHosts: ["api2.cursor.sh", "api.cursor.com"],
2505
- envVars: HARNESSES["cursor"].config.envVars,
2506
- capabilities: {
2507
- streaming: true,
2508
- toolUse: true,
2509
- reasoning: true,
2510
- multimodal: true,
2511
- contextWindow: 2e5,
2512
- mcp: true,
2513
- sessions: true,
2514
- configurable: true,
2515
- interactions: [],
2516
- imageInput: true
2517
- },
2518
- cliAuthHome: { kind: "inherit-home" },
2519
- hasCliAuth: false
2520
- },
2521
- {
2522
- name: BACKEND_TYPE.CLI_BASE,
2523
- nativeSession: null,
2524
- displayName: "CLI Base (no agent)",
2525
- description: "Bare sandbox without an AI agent backend. Use when you want the workspace, tools, and SSH access but no LLM dispatch.",
2526
- envVars: HARNESSES["cli-base"].config.envVars,
2527
- capabilities: {
2528
- streaming: false,
2529
- toolUse: false,
2530
- reasoning: false,
2531
- multimodal: false,
2532
- contextWindow: 0,
2533
- mcp: false,
2534
- sessions: false,
2535
- configurable: false,
2536
- interactions: [],
2537
- imageInput: false
2538
- },
2539
- cliAuthHome: { kind: "inherit-home" },
2540
- hasCliAuth: false
2541
- }
2542
- ];
2543
- function getSpec(name) {
2544
- return CLI_AGENT_SPECS.find((spec) => spec.name === name);
2545
- }
2546
- //#endregion
2547
- //#region ../../../packages/cli-agent-registry/dist/cli-auth-bundle.mjs
2548
- const DEFAULT_MODE = 384;
2549
- const AUTH_BUNDLE_PATHS = Object.freeze({
2550
- codex: ".codex/auth.json",
2551
- "claude-code": ".claude/.credentials.json"
2552
- });
2553
- /** Convert a native credential JSON bundle without reading host credentials. */
2554
- function materializeCliAuthBundle(backendType, rawBundle) {
2555
- if (backendType !== "codex" && backendType !== "claude-code") throw new Error("CLI auth bundle is not supported for the selected backend");
2556
- if (typeof rawBundle !== "string") throw new Error("CLI auth bundle must be a JSON object");
2557
- let value;
2558
- try {
2559
- value = JSON.parse(rawBundle);
2560
- } catch {
2561
- throw new Error("CLI auth bundle must be a JSON object");
2562
- }
2563
- if (!value || typeof value !== "object" || Array.isArray(value)) throw new Error("CLI auth bundle must be a JSON object");
2564
- return [{
2565
- path: AUTH_BUNDLE_PATHS[backendType],
2566
- content: rawBundle,
2567
- mode: DEFAULT_MODE
2568
- }];
2569
- }
2570
- const cliAuthReferenceSchema = z.object({
2571
- account: z.string().regex(/^[A-Za-z0-9][A-Za-z0-9@._+-]{0,127}$/),
2572
- secretEnv: z.string().regex(/^[A-Za-z_][A-Za-z0-9_]{0,63}$/),
2573
- format: z.enum([
2574
- "token",
2575
- "bundle",
2576
- "files"
2577
- ])
2578
- }).strict();
2579
- z.array(z.object({
2580
- path: z.string().min(1).max(4096).refine((value) => !value.startsWith("/") && !/^[A-Za-z]:/.test(value) && !/[\\\0]/.test(value) && value.split("/").every((part) => part !== "" && part !== "." && part !== "..")),
2581
- content: z.string().max(1024 * 1024),
2582
- mode: z.number().int().min(0).max(448).refine((mode) => (mode & 63) === 0).optional()
2583
- }).strict()).min(1).max(128);
2584
- function assertCliAuthReferenceSupported(backendType, model) {
2585
- if (model.cliAuth === void 0) return void 0;
2586
- const parsedReference = cliAuthReferenceSchema.safeParse(model.cliAuth);
2587
- if (!parsedReference.success) throw new Error("Invalid native authentication reference");
2588
- const reference = parsedReference.data;
2589
- if (model.authMode === "api-key" || model.apiKey !== void 0 || model.apiKeyEnv !== void 0 || model.baseUrl !== void 0 || model.authFiles !== void 0) throw new Error("cliAuth cannot be combined with API credentials, baseUrl, or inline authFiles");
2590
- const spec = getSpec(backendType);
2591
- if (!spec?.hasCliAuth) throw new Error(`Native CLI authentication is unsupported by ${backendType}`);
2592
- if (reference.format === "token" && !spec.envVars.oauthToken) throw new Error(`Native subscription tokens are unsupported by ${backendType}`);
2593
- if (reference.format === "bundle" && backendType !== "codex" && backendType !== "claude-code") throw new Error(`Native credential bundles are unsupported by ${backendType}`);
2594
- return reference;
2595
- }
2596
- //#endregion
2597
- export { agentProfileSchema as a, materializeCliAuthBundle as i, assertCliAuthReferenceSupported as n, cliAuthReferenceSchema as r, AUTH_BUNDLE_PATHS as t };