@tangle-network/cli-agent-registry 0.0.0-stage → 0.14.0

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.
@@ -0,0 +1,415 @@
1
+ import { t as HarnessSessionContract } from "./session-contract-BC75JdnA.mjs";
2
+ import { SdkProviderAdapter, WellKnownInteractionKind, agentProfileSchema } from "@tangle-network/agent-interface";
3
+ import { HarnessModelSupport, HarnessModelSupportOptions } from "@tangle-network/agent-interface/harness-capabilities";
4
+
5
+ //#region src/cli-dir-layout.d.ts
6
+ /**
7
+ * How a parked export reads a CLI's own directory (`.codex`, `.claude`, …)
8
+ * beyond the session stores its contract declares. Globs are relative to that
9
+ * directory, in the session-contract glob syntax (`*`, `**`).
10
+ *
11
+ * - `sessionData`: what holds a user's session, to be exported as a
12
+ * transcript is. Until the export carries it, it is missing, and the box is
13
+ * held.
14
+ * - `configAllow`: the CLI's own configuration and caches, withheld and named.
15
+ *
16
+ * - `credential`: what this CLI keeps in its directory that carries secrets
17
+ * but no shared credential name says so (a directory of shell environment
18
+ * snapshots, messaging keys): named, never sent, never missing. The names
19
+ * every CLI shares are runtime-contracts credential-paths.ts
20
+ * (`isNativeStoreCredentialPath`, `NATIVE_STORE_CREDENTIAL_NAMES`), checked
21
+ * first; a spec lists here only what its own pinned version writes.
22
+ *
23
+ * Anything else in the directory is undeclared: missing, so a layout a CLI
24
+ * version adds holds the box until it is classified here.
25
+ */
26
+ interface CliDirLayout {
27
+ sessionData: readonly string[];
28
+ configAllow: readonly string[];
29
+ credential: readonly string[];
30
+ }
31
+ /** What every CLI's directory is read with; a spec adds its own entries. */
32
+ declare const DEFAULT_CLI_DIR_LAYOUT: CliDirLayout;
33
+ /** A spec's additions to the default layout. */
34
+ type CliDirLayoutAdditions = Partial<CliDirLayout>;
35
+ /** The default layout with a spec's additions. */
36
+ declare function mergeCliDirLayout(additions: CliDirLayoutAdditions | undefined): CliDirLayout;
37
+ //#endregion
38
+ //#region src/synthetic-router-model.d.mts
39
+ declare const SYNTHETIC_ROUTER_MODEL: "tangle/canary-echo";
40
+ //#endregion
41
+ //#region src/spec.d.ts
42
+ /**
43
+ * Capability descriptor surfaced via GET /backends.
44
+ * Mirrors `apps/orchestrator/src/routes/backends.ts` schema so the registry
45
+ * is the single source of truth for both the orchestrator UI surface and
46
+ * sidecar adapter selection.
47
+ */
48
+ interface HarnessSpecCapabilities {
49
+ streaming: boolean;
50
+ toolUse: boolean;
51
+ reasoning: boolean;
52
+ multimodal: boolean;
53
+ contextWindow: number;
54
+ mcp: boolean;
55
+ /** Runtime bindings lowered by the profile materializer, independently of dynamic MCP mutation. */
56
+ runtimeAttachments?: {
57
+ mcp: true;
58
+ };
59
+ sessions: boolean;
60
+ configurable: boolean;
61
+ /**
62
+ * Interaction kinds this harness is *capable* of originating
63
+ * (permission/question/plan). Static "can it, if asked" — NOT whether a
64
+ * given session enabled them (that's the per-session adapter
65
+ * getCapabilities() + toggle config). Empty = never asks the user.
66
+ */
67
+ interactions: WellKnownInteractionKind[];
68
+ /**
69
+ * Whether the harness forwards image input parts to the model natively
70
+ * (an argv flag or a stdin content block carrying the image itself)
71
+ * rather than a `[Image: <ref>]` text-marker reference. Distinct from
72
+ * `multimodal`, which is static "can the model reason over images, if
73
+ * asked" — `imageInput` is about the delivery mechanism this harness
74
+ * actually uses, not the model's capability.
75
+ *
76
+ * Like `interactions`, this is static "can it, if asked" — a specific
77
+ * config may still degrade: codex delivers natively on the exec path but
78
+ * marker-only on interactive (permission/question/plan) turns until the
79
+ * app-server protocol carries image elements (#3586). Per-config truth is
80
+ * the runtime adapter's getCapabilities().
81
+ */
82
+ imageInput: boolean;
83
+ }
84
+ type CliAgentEnvExtraParser = "string" | "int" | "json";
85
+ /**
86
+ * Model-tuple role an extra env var carries, for specs whose provider/mode
87
+ * ride the extras channel rather than a first-class {@link CliAgentEnvVars}
88
+ * field (opencode's OPENCODE_MODEL_PROVIDER / OPENCODE_MODEL_MODE). Lets
89
+ * spec-driven consumers (label codec, backend metadata) resolve the tuple
90
+ * without naming any backend's env vars. A spec that declares a `provider`
91
+ * role is authoritative for its provider value; specs without one leave
92
+ * provider resolution to the consumer (e.g. the router model slug's
93
+ * `provider/` prefix).
94
+ */
95
+ type CliAgentEnvExtraRole = "provider" | "mode";
96
+ interface CliAgentEnvExtra {
97
+ parser: CliAgentEnvExtraParser;
98
+ required?: boolean;
99
+ role?: CliAgentEnvExtraRole;
100
+ }
101
+ /**
102
+ * Env var name declared with `role` in this spec's extras, or undefined when
103
+ * the spec declares none. At most one extra may carry a given role (enforced
104
+ * by a registry test); the first declaration wins.
105
+ */
106
+ declare function cliAgentEnvRoleName(spec: CliAgentSpec, role: CliAgentEnvExtraRole): string | undefined;
107
+ interface CliAgentEnvVars {
108
+ apiKey?: string;
109
+ model?: string;
110
+ authMode?: string;
111
+ authFiles?: string;
112
+ /** Native subscription token; never delivered through a warm claim. */
113
+ oauthToken?: string;
114
+ baseUrl?: string;
115
+ /** Provider-specific extras keyed by env var name. */
116
+ extras?: Record<string, CliAgentEnvExtra>;
117
+ }
118
+ /**
119
+ * `inherit-home` means the spawned CLI reads $HOME from the sidecar process.
120
+ * `agent-home` means the adapter demotes to a fixed uid and forces $HOME to
121
+ * a fixed path (claude-code: uid=1000, /home/agent) when the sidecar runs as
122
+ * root. This is the only branch with a non-default home resolution.
123
+ */
124
+ type CliAuthHome = {
125
+ kind: "inherit-home";
126
+ } | {
127
+ kind: "agent-home";
128
+ uid: number;
129
+ home: string;
130
+ };
131
+ /**
132
+ * The wire protocol a harness speaks to the Tangle router.
133
+ *
134
+ * `openai-compat` (`/v1/chat/completions`) routes any provider's model — the
135
+ * router resolves a provider-prefixed slug verbatim. The other two are
136
+ * provider-native wires: the router passes that provider's own models through
137
+ * natively and translates every other model to chat completions (text, images
138
+ * and function tools, streamed or not; hosted tools such as web search are
139
+ * dropped), so each carries any router-served model. Measured 2026-10-15 with
140
+ * `zai/glm-5.3` on claude-code 2.1.300 (`/v1/messages`) and codex 0.162.1
141
+ * (`/v1/responses`): a plain turn and a tool turn completed on both.
142
+ */
143
+ type CliAgentModelWire = "openai-compat" | "openai-responses" | "anthropic-messages";
144
+ /** The wire a harness speaks; harnesses that declare none ride openai-compat. */
145
+ declare function harnessModelWire(spec: CliAgentSpec): CliAgentModelWire;
146
+ /**
147
+ * The model id a harness and model check reads: a `provider/model` slug as
148
+ * given, a bare id qualified by its tuple's vendor provider, and a bare id
149
+ * alone when the tuple names only the Router transport (agent-interface then
150
+ * resolves its provider from the id's family).
151
+ */
152
+ declare function canonicalModelSlug(model: string | {
153
+ provider?: string;
154
+ model?: string;
155
+ } | undefined): string | undefined;
156
+ /**
157
+ * Whether a harness can run a model, read from the one capability table in
158
+ * `@tangle-network/agent-interface`: vendor locks (kimi-code runs Moonshot
159
+ * models) and pairs measured to fail on production. A refused pair is refused
160
+ * where it is chosen (create, run, an authored workflow action) with the
161
+ * returned message, rather than provisioning a box whose first model call
162
+ * fails. An absent model is the harness's own default and is always supported.
163
+ */
164
+ declare function harnessModelSupportFor(harness: string, model: string | {
165
+ provider?: string;
166
+ model?: string;
167
+ } | undefined, options?: HarnessModelSupportOptions): HarnessModelSupport;
168
+ /**
169
+ * Env var names carrying this harness's claim-deliverable model tuple — the
170
+ * names a warm-claim rebind may deliver to a live sidecar: the model /
171
+ * base-URL / auth-mode roles plus declared extras. Deliberately EXCLUDES the
172
+ * credential-bearing roles: `apiKey` (a BYO key outside egress proxy-swap
173
+ * coverage would put a raw secret in the rebind body — the caller adds the
174
+ * name back only when its transport guarantees a dummy value) and `authFiles`
175
+ * (auth-file payloads are credential content and never ride a rebind).
176
+ */
177
+ declare function cliAgentClaimEnvVarNames(spec: CliAgentSpec): string[];
178
+ /**
179
+ * Sidecar lifecycle contract for a harness's adapter, declared as spec data
180
+ * so the backend manager, prewarm triggers, and execution guards key on
181
+ * capabilities instead of forking on a harness name. Omitted (or a field
182
+ * omitted) means the CLI default: a per-model-config adapter process with no
183
+ * shared server, no idle retention, no concurrency cap, and no prewarm.
184
+ */
185
+ interface CliAgentRuntimeSpec {
186
+ /**
187
+ * The adapter fronts one long-lived provider server per workspace and the
188
+ * model is a per-request override. Instance identity is therefore
189
+ * `type + workspace (+ profile/hub tools)`, never the model tuple, and
190
+ * config matching compares credentials + server address instead of the
191
+ * full model config. Non-server-based harnesses key every distinct model
192
+ * tuple to its own adapter instance — collapsing them would bleed one
193
+ * session's model config into another session's process.
194
+ */
195
+ serverBased?: boolean;
196
+ /**
197
+ * Keep an idle instance (refCount 0) alive for the next acquisition — the
198
+ * prewarm-then-claim first-token path depends on this. `envVar` names the
199
+ * deployed kill switch: unset means retain; "0"/"false"/"no"/"off"
200
+ * disables retention.
201
+ */
202
+ warmRetention?: {
203
+ envVar: string; /** Retained when `envVar` is unset. Defaults to true. */
204
+ enabledByDefault?: boolean;
205
+ };
206
+ /**
207
+ * Cap concurrent instances of this harness. The cap is read from `envVar`
208
+ * at acquisition time; unset means unlimited.
209
+ */
210
+ concurrencyLimit?: {
211
+ envVar: string;
212
+ };
213
+ /**
214
+ * Prewarm an instance from environment defaults at boot and after
215
+ * claim-time env injection so the first session skips the server spawn
216
+ * (~1.6s on the first-token path). Requires `serverBased`: prewarming a
217
+ * per-model CLI adapter would mint an instance keyed by a model tuple the
218
+ * claimed session may never match.
219
+ */
220
+ prewarmable?: boolean;
221
+ /**
222
+ * The adapter guarantees a tool-disabled visible-output continuation turn
223
+ * (`input.disableTools`). Execution fails loudly for harnesses without it.
224
+ */
225
+ supportsToolDisabledTurns?: boolean;
226
+ /**
227
+ * The adapter accepts a host-env redaction hook and the sidecar MUST wire
228
+ * its sanitizer into the adapter constructor so the agent process only
229
+ * inherits sandbox-public vars, never internal platform secrets. The
230
+ * binding fails closed if this declaration ever drifts off.
231
+ */
232
+ redactsHostEnv?: boolean;
233
+ }
234
+ /**
235
+ * A tool the harness ships built in, surfaced verbatim on the sidecar's
236
+ * tool-introspection routes. Declared as spec data so those routes serve
237
+ * whatever the registry says instead of forking on a harness name; a spec
238
+ * that declares none reports tool introspection as unsupported.
239
+ */
240
+ interface CliAgentBuiltinTool {
241
+ id: string;
242
+ name: string;
243
+ description: string;
244
+ }
245
+ interface CliAgentSpec {
246
+ name: string;
247
+ displayName: string;
248
+ description: string;
249
+ /** Durable message-store directory; omit when history requires a backend. */
250
+ messageStorageDir?: string;
251
+ /**
252
+ * What a parked export reads in this CLI's own directory beyond its session
253
+ * stores, added to DEFAULT_CLI_DIR_LAYOUT (cli-dir-layout.ts).
254
+ */
255
+ cliDirLayout?: CliDirLayoutAdditions;
256
+ envVars: CliAgentEnvVars;
257
+ runtime?: CliAgentRuntimeSpec;
258
+ /** Built-in tool inventory; omit when the harness declares none. */
259
+ builtinTools?: readonly CliAgentBuiltinTool[];
260
+ /**
261
+ * Operator-level tuning env names forwarded verbatim from a HOST process
262
+ * (orchestrator system env, host-agent process env) into every container —
263
+ * server log routing, retry/limit knobs, mock switches. NOT part of the
264
+ * claim-deliverable model tuple and never a credential channel: these names
265
+ * are excluded from the kernel-cmdline and rebind unions, and a secret-like
266
+ * name here would still be caught by the allowlist builders' secret-suffix
267
+ * guard. Omit for harnesses with no host-side tuning surface.
268
+ */
269
+ hostPassthroughEnvVars?: readonly string[];
270
+ /**
271
+ * Router wire this harness speaks. Omit for `openai-compat`, which every
272
+ * harness rides unless its CLI talks a provider-native protocol. Which models
273
+ * a harness can run is answered by {@link harnessModelSupportFor}; the model a
274
+ * managed session defaults to is `managedModelChain(name).chain[0]`.
275
+ */
276
+ modelWire?: CliAgentModelWire;
277
+ /**
278
+ * Hosts the vendor CLI must reach, allowed through egress only for a box
279
+ * running this harness. Declared beside {@link callerCredentialOnly} because
280
+ * a vendor-served harness cannot work without its vendor's API.
281
+ */
282
+ egressHosts?: readonly string[];
283
+ /**
284
+ * Whether this harness's native TUI can be launched PRE-SEEDED with an opening
285
+ * prompt (a launch arg the CLI submits once it is ready to read input).
286
+ *
287
+ * A caller that drives a TUI on the user's behalf — a workflow interactive run
288
+ * — always seeds one, so a harness without this can start a terminal but never
289
+ * receives the task. Declared here so the surface offering interactive runs and
290
+ * the sidecar that launches them cannot drift onto different sets; the actual
291
+ * argv shape stays with the launcher (`INTERACTIVE_INITIAL_PROMPT_ARGS`).
292
+ */
293
+ interactiveSeededPrompt?: boolean;
294
+ capabilities: HarnessSpecCapabilities;
295
+ /**
296
+ * The harness session contract (session-contract.ts): where the native
297
+ * session is stored, how its id is known, and which flags would disable
298
+ * it. Null only for a spec that runs no harness (`sessions: false`) or a
299
+ * harness listed in HARNESS_SESSION_UNSUPPORTED.
300
+ */
301
+ nativeSession: HarnessSessionContract | null;
302
+ /** Linux container caps. Defaults to ['SYS_PTRACE'] when omitted. */
303
+ securityCapabilities?: string[];
304
+ cliAuthHome: CliAuthHome;
305
+ hasCliAuth: boolean;
306
+ /**
307
+ * The harness completes a session on a caller-supplied OAuth bundle
308
+ * (`model.authFiles`) with no managed router key: its adapter scrubs the
309
+ * router pin under `authMode: "oauth"` and the CLI reaches the vendor's own
310
+ * subscription backend. A create for such a harness with auth files mints
311
+ * no router key.
312
+ */
313
+ byoOAuth?: boolean;
314
+ /**
315
+ * The Tangle Router cannot serve this harness: its CLI calls the vendor's own
316
+ * hosted service (amp: ampcode.com, cursor: api2.cursor.sh) and accepts no
317
+ * custom model endpoint. It runs only on the caller's credential (a key, a
318
+ * key reference, CLI auth, or login files through its `envVars.authFiles`
319
+ * channel), so it has no managed model chain: a create mints no Router key
320
+ * for it, is refused when it carries none, and its box gets no Router default
321
+ * model. The public backend catalog reports the flag. Every other harness
322
+ * starts on the Router when the caller brings no credential of its own.
323
+ */
324
+ callerCredentialOnly?: boolean;
325
+ }
326
+ type AdapterFactory = (logger: ProviderLogger) => SdkProviderAdapter;
327
+ /** Bounded provider startup spans, timed by the operation's owner. */
328
+ type ProviderPhase = "profile_materialize" | "session_prepare" | "native_resume" | "native_session_new" | "history_replay" | "native_session_bind" | "config_build" | "config_write" | "session_turn_wait" | "session_view_bind" | "mcp_proxy_lease" | "native_home_wait" | "dependency_prep" | "cli_spawn" | "cli_boot" | "cli_initialize" | "cli_authenticate" | "server_listening" | "session_open" | "mcp_ready_wait" | "prompt_dispatch" | "cli_ready_wait" | "warm_server_hit" | "warm_server_miss";
329
+ type ProviderLogger = {
330
+ info: (msg: string, meta?: Record<string, unknown>) => void;
331
+ warn: (msg: string, meta?: Record<string, unknown>) => void;
332
+ error: (msg: string, meta?: Record<string, unknown>) => void;
333
+ debug: (msg: string, meta?: Record<string, unknown>) => void; /** Report one startup span; the host records it with the turn's phases. */
334
+ observePhase?: (phase: ProviderPhase, durationMs: number, scope?: "turn" | "prewarm") => void;
335
+ };
336
+ //#endregion
337
+ //#region src/specs.d.ts
338
+ /**
339
+ * Env var naming a sandbox's selected backend. Stamped into every create env
340
+ * by the orchestrator (`buildSidecarContainerConfig`); read by the sidecar's
341
+ * backend resolution (`resolveConfiguredBackend`) and by the host-agent's
342
+ * warm-claim env selection to pick which spec's env vars the rebind delivers.
343
+ */
344
+ declare const AGENT_BACKEND_ENV_VAR = "AGENT_BACKEND";
345
+ /**
346
+ * The managed-router model-key channel every backend shares: the box-side
347
+ * value is always the salted proxy dummy (`proxy-model-token.<salt>`), which
348
+ * the per-sandbox egress proxy swaps for the real budget-scoped key at the
349
+ * network boundary. The opencode-derived NAME is pinned naming debt: FC
350
+ * shared-snapshot salt recovery, resume re-key, and the egress proxy swap map
351
+ * all key on this literal, so renaming it bricks managed-model auth
352
+ * fleet-wide. Kept equal to the opencode spec's own apiKey declaration
353
+ * (enforced by a registry test).
354
+ */
355
+ declare const MANAGED_MODEL_KEY_ENV_VAR = "OPENCODE_MODEL_API_KEY";
356
+ /**
357
+ * Caller-owned auth by reference: the NAME of the box env var (a stored
358
+ * secret) that holds the provider's key. The orchestrator sets it only when it
359
+ * injected no managed key; the sidecar composes the named provider on that
360
+ * credential. A variable name, never a secret, so it may ride every channel a
361
+ * create's env takes to the guest — the kernel cmdline and a warm-claim rebind.
362
+ */
363
+ declare const MANAGED_MODEL_KEY_NAME_ENV_VAR = "OPENCODE_MODEL_API_KEY_ENV";
364
+ /**
365
+ * Env var names declared across ALL registered harness specs, grouped by
366
+ * their `CliAgentEnvVars` role. The ONE derivation every allowlist that must
367
+ * track "what env names can a backend legitimately use" builds from — the
368
+ * FC kernel-cmdline whitelist, the egress secret handling, the sidecar
369
+ * terminal scrub, the SSH env forward, and the rebind union below. Deriving
370
+ * from roles (not one flat set) lets each consumer apply its own security
371
+ * policy per role: apiKey and oauthToken names are secret channels.
372
+ * Native subscription tokens stay out of warm-claim delivery.
373
+ */
374
+ declare function cliAgentEnvVarNamesByRole(): {
375
+ apiKey: ReadonlySet<string>;
376
+ oauthToken: ReadonlySet<string>;
377
+ model: ReadonlySet<string>;
378
+ baseUrl: ReadonlySet<string>;
379
+ authMode: ReadonlySet<string>;
380
+ authFiles: ReadonlySet<string>;
381
+ extras: ReadonlySet<string>;
382
+ };
383
+ /**
384
+ * Union of every spec's `hostPassthroughEnvVars` — the operator tuning names
385
+ * a host process (orchestrator system env, host-agent process env) may
386
+ * forward into containers. Request/caller env always keeps precedence at the
387
+ * host-agent boundary; the orchestrator system-env channel stays
388
+ * operator-authoritative. Replaces the old `OPENCODE_*` prefix forward,
389
+ * which leaked ANY stray host var with that prefix (model tuple and key
390
+ * included) into every tenant.
391
+ */
392
+ declare function cliAgentHostPassthroughEnvVarNames(): ReadonlySet<string>;
393
+ /**
394
+ * Union of every env var name a warm-claim rebind may deliver, across all
395
+ * registered harnesses. The ONE source both sides of the rebind derive from:
396
+ * the host-agent selects its delivery from it and the sidecar rebind route
397
+ * carves it out of the loader-control rejection, so the two can never drift
398
+ * into "host delivers a name the sidecar 400s" — which silently cold-paths
399
+ * every warm claim of that backend. Includes each spec's apiKey name because
400
+ * acceptance is a superset of delivery: the HOST decides which key names are
401
+ * safe to send (egress proxy-swap-covered only), while the sidecar must not
402
+ * reject a name a valid host may deliver.
403
+ */
404
+ declare function claimDeliverableEnvVarNames(): ReadonlySet<string>;
405
+ declare const CLI_AGENT_SPECS: readonly CliAgentSpec[];
406
+ declare function getSpec(name: string): CliAgentSpec | undefined;
407
+ /**
408
+ * The directory, relative to a session's storage path, where a backend's
409
+ * message log lives: the one value adapters, the sidecar and the parked
410
+ * export read. Throws for a backend whose spec names none.
411
+ */
412
+ declare function messageStorageDirOf(name: string): string;
413
+ //#endregion
414
+ export { CliDirLayout as A, ProviderPhase as C, harnessModelSupportFor as D, cliAgentEnvRoleName as E, DEFAULT_CLI_DIR_LAYOUT as M, mergeCliDirLayout as N, harnessModelWire as O, ProviderLogger as S, cliAgentClaimEnvVarNames as T, CliAgentModelWire as _, agentProfileSchema as a, CliAuthHome as b, cliAgentHostPassthroughEnvVarNames as c, AdapterFactory as d, CliAgentBuiltinTool as f, CliAgentEnvVars as g, CliAgentEnvExtraRole as h, MANAGED_MODEL_KEY_NAME_ENV_VAR as i, CliDirLayoutAdditions as j, SYNTHETIC_ROUTER_MODEL as k, getSpec as l, CliAgentEnvExtraParser as m, CLI_AGENT_SPECS as n, claimDeliverableEnvVarNames as o, CliAgentEnvExtra as p, MANAGED_MODEL_KEY_ENV_VAR as r, cliAgentEnvVarNamesByRole as s, AGENT_BACKEND_ENV_VAR as t, messageStorageDirOf as u, CliAgentRuntimeSpec as v, canonicalModelSlug as w, HarnessSpecCapabilities as x, CliAgentSpec as y };
415
+ //# sourceMappingURL=specs-BSELpX1h.d.mts.map