@tangle-network/agent-interface 5.4.0 → 5.6.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.
@@ -1816,6 +1816,10 @@ export declare function createAgentEnvironmentWithIdempotency<T extends object>(
1816
1816
  /** Reconstruct an existing environment; never allocates a replacement. */
1817
1817
  export interface AgentEnvironmentGetOptions {
1818
1818
  signal?: AbortSignal;
1819
+ /** Side-effect-free custody discovery on a qualified provider. Never resumes, installs or
1820
+ * rebinds; the returned snapshot cannot execute. Unsupported providers must reject this mode.
1821
+ * Expired installed custody may be returned as metadata, never as dispatch authority. */
1822
+ readOnly?: true;
1819
1823
  /** Explicit custody attachment through the existing egress lifecycle. Omission reads current
1820
1824
  * custody; [] revokes custom bindings. A get never allocates a replacement environment. */
1821
1825
  proxySecrets?: readonly ProxySecretBinding[];
@@ -1827,7 +1831,7 @@ export interface AgentEnvironmentGetOptions {
1827
1831
  * Authorize the first turn of an accepted portable transfer. The provider looks up the exact
1828
1832
  * durable operation and returns its dispatch-capable environment with contextTransferReceipt.
1829
1833
  * A missing, uncertain, conflicting or unsupported receipt refuses attachment. The request's
1830
- * exact profile, workspace and resources remain authoritative; ordinary get remains read-only.
1834
+ * exact profile, workspace and resources remain authoritative; use readOnly for discovery without reconnect side effects.
1831
1835
  */
1832
1836
  contextTransfer?: ContextTransferRequest;
1833
1837
  }
@@ -2323,6 +2327,11 @@ export declare const AgentEnvironmentGetOptionsSchema: z.ZodObject<{
2323
2327
  }, z.core.$strict>>;
2324
2328
  }, z.core.$strict>>;
2325
2329
  }, z.core.$strict>;
2330
+ /** Explicit opt-in for providers implementing side-effect-free, non-executable discovery. */
2331
+ export declare const AgentEnvironmentReadOnlyGetOptionsSchema: z.ZodObject<{
2332
+ signal: z.ZodOptional<z.ZodCustom<AbortSignal, AbortSignal>>;
2333
+ readOnly: z.ZodLiteral<true>;
2334
+ }, z.core.$strict>;
2326
2335
  export interface AgentEnvironmentProvider {
2327
2336
  readonly name: string;
2328
2337
  readonly exactProcess?: AgentExactProcessProvider;
@@ -526,8 +526,11 @@ export async function createAgentEnvironmentWithIdempotency(records, input, crea
526
526
  throw error;
527
527
  }
528
528
  }
529
+ // Keep the existing parser strict: published providers that import it must not silently
530
+ // accept readOnly and then perform their ordinary reconnect side effects.
531
+ const environmentGetSignalSchema = z.custom().optional();
529
532
  export const AgentEnvironmentGetOptionsSchema = z.strictObject({
530
- signal: z.custom().optional(),
533
+ signal: environmentGetSignalSchema,
531
534
  proxySecrets: ProxySecretsSchema.optional(),
532
535
  proxySecretParents: ProxySecretParentsSchema.optional(),
533
536
  ...ProxySecretUpdateControlsSchema.shape,
@@ -545,3 +548,8 @@ export const AgentEnvironmentGetOptionsSchema = z.strictObject({
545
548
  ctx.addIssue({ code: "custom", path: ["proxySecrets"], message: "proxy update controls require an explicit proxySecrets selection" });
546
549
  }
547
550
  });
551
+ /** Explicit opt-in for providers implementing side-effect-free, non-executable discovery. */
552
+ export const AgentEnvironmentReadOnlyGetOptionsSchema = z.strictObject({
553
+ signal: environmentGetSignalSchema,
554
+ readOnly: z.literal(true),
555
+ });
@@ -7,7 +7,7 @@ import type { HarnessType } from "./harness.js";
7
7
  * 3. system-prompt intents (whether a harness can replace its own prompt, add to it, or neither).
8
8
  *
9
9
  * All are facets of the same question — "what can this (harness, model) pair actually do" — and
10
- * apply to BOTH harness-backed systems (vendor-locked CLIs like claude-code/codex/kimi) AND
10
+ * apply to BOTH harness-backed systems (CLIs that speak a vendor wire, like claude-code, codex and kimi-code) AND
11
11
  * router-backed systems (opencode, cli-base: any model the router serves). Lifted here so the
12
12
  * cli-bridge backends, the sandbox UI pickers, and the router all read one truth instead of each
13
13
  * hand-rolling a divergent copy.
@@ -91,7 +91,7 @@ export declare function harnessModelSupport(harness: HarnessType, modelId: strin
91
91
  * Whether a harness can run a model; {@link harnessModelSupport} gives the reason when it cannot.
92
92
  */
93
93
  export declare function harnessSupportsModel(harness: HarnessType, modelId: string, options?: HarnessModelSupportOptions): boolean;
94
- /** The harness to adopt for a model whose provider is vendor-locked (`anthropic` → `claude-code`,
94
+ /** The harness a vendor's model adopts when the caller names none (`anthropic` → `claude-code`,
95
95
  * `openai` → `codex`, `moonshot` → `kimi-code`); `null` when any router-backed harness will do. */
96
96
  export declare function preferredHarnessForModel(modelId: string): HarnessType | null;
97
97
  /**
@@ -104,8 +104,7 @@ export declare function preferredHarnessForModel(modelId: string): HarnessType |
104
104
  export declare function snapModelToHarness(harness: HarnessType, modelId: string, candidateIds: readonly string[]): string;
105
105
  /**
106
106
  * Keep the harness when it can run `modelId`; otherwise return the model's native harness
107
- * (anthropic → claude-code, openai → codex, moonshot → kimi-code), falling back to the router-backed
108
- * `opencode` for everything else.
107
+ * ({@link vendorHarness}), falling back to the router-backed `opencode` for everything else.
109
108
  */
110
109
  export declare function snapHarnessToModel(harness: HarnessType, modelId: string): HarnessType;
111
110
  /** The reasoning efforts a harness can express, independent of model — its explicit override set, or
@@ -6,7 +6,7 @@ import { REASONING_EFFORTS, } from "./agent-profile.js";
6
6
  * 3. system-prompt intents (whether a harness can replace its own prompt, add to it, or neither).
7
7
  *
8
8
  * All are facets of the same question — "what can this (harness, model) pair actually do" — and
9
- * apply to BOTH harness-backed systems (vendor-locked CLIs like claude-code/codex/kimi) AND
9
+ * apply to BOTH harness-backed systems (CLIs that speak a vendor wire, like claude-code, codex and kimi-code) AND
10
10
  * router-backed systems (opencode, cli-base: any model the router serves). Lifted here so the
11
11
  * cli-bridge backends, the sandbox UI pickers, and the router all read one truth instead of each
12
12
  * hand-rolling a divergent copy.
@@ -20,19 +20,36 @@ import { REASONING_EFFORTS, } from "./agent-profile.js";
20
20
  export const reasoningLadder = REASONING_EFFORTS;
21
21
  // ── Harness ↔ model compatibility ────────────────────────────────────────────
22
22
  /**
23
- * Provider prefixes a harness is vendor-locked to (canonical-id prefix, e.g. `anthropic`, `openai`).
24
- * A harness with no entry is router-backed: it runs any model, except the measured exclusions in
23
+ * Provider prefixes a harness is vendor-locked to (canonical-id prefix, e.g. `moonshot`). A harness
24
+ * with no entry is router-backed: it runs any model, except the measured exclusions in
25
25
  * {@link harnessModelExclusions}.
26
26
  *
27
+ * `claude-code` and `codex` are deliberately absent. Their CLIs speak a vendor wire (Anthropic
28
+ * Messages, OpenAI Responses), but the Tangle Router passes only that vendor's own models through
29
+ * natively and translates every other model on those wires to chat completions (text, images and
30
+ * function tools, streamed or not; hosted tools are dropped), so both run any router-served model.
31
+ * A caller's own vendor key or login still serves that vendor's models alone, which this table does
32
+ * not see. Which harness a vendor's model adopts when the caller names none is
33
+ * {@link vendorHarness}, a separate fact.
34
+ *
27
35
  * `nanoclaw` is deliberately absent despite the "claw" name: its runner routes every provider through
28
36
  * the Tangle router (canonical model id straight to the gateway), so it is router-backed like
29
37
  * `opencode` — not Anthropic-locked.
30
38
  */
31
39
  const harnessProviderLock = {
32
- "claude-code": ["anthropic"],
33
- codex: ["openai"],
34
40
  "kimi-code": ["moonshot"],
35
41
  };
42
+ /**
43
+ * The harness that natively speaks a vendor's models. A model of that vendor adopts it when the
44
+ * caller names no harness ({@link preferredHarnessForModel}), and a locked harness handed such a
45
+ * model switches to it ({@link snapHarnessToModel}). It is not a restriction: `claude-code` and
46
+ * `codex` also run other providers' models through the router.
47
+ */
48
+ const vendorHarness = {
49
+ anthropic: "claude-code",
50
+ openai: "codex",
51
+ moonshot: "kimi-code",
52
+ };
36
53
  /** Provider prefix of a canonical model id (`anthropic/claude-…` → `anthropic`), or null. */
37
54
  export function modelProvider(modelId) {
38
55
  const slash = modelId.indexOf("/");
@@ -169,17 +186,11 @@ export function harnessModelSupport(harness, modelId, options = {}) {
169
186
  export function harnessSupportsModel(harness, modelId, options) {
170
187
  return harnessModelSupport(harness, modelId, options).supported;
171
188
  }
172
- /** The harness to adopt for a model whose provider is vendor-locked (`anthropic` → `claude-code`,
189
+ /** The harness a vendor's model adopts when the caller names none (`anthropic` → `claude-code`,
173
190
  * `openai` → `codex`, `moonshot` → `kimi-code`); `null` when any router-backed harness will do. */
174
191
  export function preferredHarnessForModel(modelId) {
175
192
  const provider = resolveModelProvider(modelId);
176
- if (!provider)
177
- return null;
178
- for (const [harness, providers] of Object.entries(harnessProviderLock)) {
179
- if (providers?.includes(provider))
180
- return harness;
181
- }
182
- return null;
193
+ return provider ? (vendorHarness[provider] ?? null) : null;
183
194
  }
184
195
  // ── Harness ↔ model snapping (catalog-aware) ─────────────────────────────────
185
196
  /**
@@ -188,12 +199,6 @@ export function preferredHarnessForModel(modelId) {
188
199
  * harness never snaps (it runs the model as-is).
189
200
  */
190
201
  const harnessPreferredModelPatterns = {
191
- "claude-code": [
192
- /^anthropic\/claude-opus-[\d.-]+$/,
193
- /^anthropic\/claude-sonnet-[\d.-]+$/,
194
- /^anthropic\//,
195
- ],
196
- codex: [/^openai\/gpt-\d+(\.\d+)?$/, /^openai\/gpt/, /^openai\//],
197
202
  "kimi-code": [/^moonshot\//],
198
203
  };
199
204
  const numericDesc = new Intl.Collator(undefined, {
@@ -222,8 +227,7 @@ export function snapModelToHarness(harness, modelId, candidateIds) {
222
227
  }
223
228
  /**
224
229
  * Keep the harness when it can run `modelId`; otherwise return the model's native harness
225
- * (anthropic → claude-code, openai → codex, moonshot → kimi-code), falling back to the router-backed
226
- * `opencode` for everything else.
230
+ * ({@link vendorHarness}), falling back to the router-backed `opencode` for everything else.
227
231
  */
228
232
  export function snapHarnessToModel(harness, modelId) {
229
233
  if (harnessSupportsModel(harness, modelId))
package/dist/index.d.ts CHANGED
@@ -9,7 +9,7 @@ export * from "./host-services.js";
9
9
  export * from "./mcp.js";
10
10
  export * from "./provider-adapter.js";
11
11
  export type * from "./environment-provider.js";
12
- export { AgentEnvironmentCapabilitiesSchema, AgentRuntimeAttachmentsSchema, AgentNativeContextContinuationAdmissionSchema, AgentNativeContextContinuationResultSchema, AgentTurnInputSchema, AgentTurnResultSchema, agentEnvironmentCreateInputDigest, agentNativeContextContinuationAdmissionMatchesRequest, agentNativeContextContinuationResultMatchesRequest, AccountUsageSchema, AgentEnvironmentObservationSchema, AgentEnvironmentStatusSchema, ComputeBillingSchema, EnvironmentLifecycleSchema, ModelUsageSchema, ObservationProvenanceSchema, PlacementDescriptorSchema, ProviderIdentitySchema, ResourceProfileSchema, ResourceUseSampleSchema, SafeEndpointSchema, agentEnvironmentObservationIdentityMatches, observationContainsCredential, observationOf, AgentInteractiveSessionAttachSchema, AgentInteractiveSessionControlClaimAcknowledgementSchema, AgentInteractiveSessionControlClaimRequestSchema, AgentInteractiveSessionControlClaimSchema, AgentInteractiveSessionPromptAcknowledgementSchema, AgentInteractiveSessionPromptCommandSchema, AgentInteractiveSessionRefSchema, AgentInteractiveSessionStartSchema, AgentInteractiveSessionStopAcknowledgementSchema, AgentInteractiveSessionStopCommandSchema, AgentInteractiveSessionStatusSchema, agentInteractiveSessionControlClaimAcknowledgementMatchesRequest, agentInteractiveSessionControlClaimRequestDigest, agentInteractiveSessionControlClaimMatchesRef, agentInteractiveSessionControlClaimIsNewer, agentInteractiveSessionPromptAcknowledgementMatchesCommand, agentInteractiveSessionPromptRequestDigest, agentInteractiveSessionStopAcknowledgementMatchesCommand, agentInteractiveSessionStopRequestDigest, agentInteractiveSessionRefMatchesStart, agentInteractiveSessionRunRef, agentInteractiveSessionStatusMatchesRef, exactAgentInteractiveSessionStart, createAgentEnvironmentWithIdempotency, canonicalWorkspaceCwd, MAX_WORKSPACE_CWD_LENGTH, workspaceCwdSchema, workspaceCwdPathForBase, WorkspaceRequestSchema, ResourceRequestSchema, TerminalAttachRequestSchema, TerminalAttachResultSchema, TerminalDetachAckSchema, TerminalInputSchema, TerminalOutputEventSchema, TerminalReplayWindowSchema, TerminalResizeSchema, TerminalSessionRefSchema, terminalAttachResultMatchesRequest, terminalSessionUsable, } from "./environment-provider.js";
12
+ export { AgentEnvironmentCapabilitiesSchema, AgentEnvironmentReadOnlyGetOptionsSchema, AgentRuntimeAttachmentsSchema, AgentNativeContextContinuationAdmissionSchema, AgentNativeContextContinuationResultSchema, AgentTurnInputSchema, AgentTurnResultSchema, agentEnvironmentCreateInputDigest, agentNativeContextContinuationAdmissionMatchesRequest, agentNativeContextContinuationResultMatchesRequest, AccountUsageSchema, AgentEnvironmentObservationSchema, AgentEnvironmentStatusSchema, ComputeBillingSchema, EnvironmentLifecycleSchema, ModelUsageSchema, ObservationProvenanceSchema, PlacementDescriptorSchema, ProviderIdentitySchema, ResourceProfileSchema, ResourceUseSampleSchema, SafeEndpointSchema, agentEnvironmentObservationIdentityMatches, observationContainsCredential, observationOf, AgentInteractiveSessionAttachSchema, AgentInteractiveSessionControlClaimAcknowledgementSchema, AgentInteractiveSessionControlClaimRequestSchema, AgentInteractiveSessionControlClaimSchema, AgentInteractiveSessionPromptAcknowledgementSchema, AgentInteractiveSessionPromptCommandSchema, AgentInteractiveSessionRefSchema, AgentInteractiveSessionStartSchema, AgentInteractiveSessionStopAcknowledgementSchema, AgentInteractiveSessionStopCommandSchema, AgentInteractiveSessionStatusSchema, agentInteractiveSessionControlClaimAcknowledgementMatchesRequest, agentInteractiveSessionControlClaimRequestDigest, agentInteractiveSessionControlClaimMatchesRef, agentInteractiveSessionControlClaimIsNewer, agentInteractiveSessionPromptAcknowledgementMatchesCommand, agentInteractiveSessionPromptRequestDigest, agentInteractiveSessionStopAcknowledgementMatchesCommand, agentInteractiveSessionStopRequestDigest, agentInteractiveSessionRefMatchesStart, agentInteractiveSessionRunRef, agentInteractiveSessionStatusMatchesRef, exactAgentInteractiveSessionStart, createAgentEnvironmentWithIdempotency, canonicalWorkspaceCwd, MAX_WORKSPACE_CWD_LENGTH, workspaceCwdSchema, workspaceCwdPathForBase, WorkspaceRequestSchema, ResourceRequestSchema, TerminalAttachRequestSchema, TerminalAttachResultSchema, TerminalDetachAckSchema, TerminalInputSchema, TerminalOutputEventSchema, TerminalReplayWindowSchema, TerminalResizeSchema, TerminalSessionRefSchema, terminalAttachResultMatchesRequest, terminalSessionUsable, } from "./environment-provider.js";
13
13
  export * from "./plan.js";
14
14
  export * from "./runtime-control.js";
15
15
  export * from "./portable-context.js";
package/dist/index.js CHANGED
@@ -8,7 +8,7 @@ export * from "./provider-config.js";
8
8
  export * from "./host-services.js";
9
9
  export * from "./mcp.js";
10
10
  export * from "./provider-adapter.js";
11
- export { AgentEnvironmentCapabilitiesSchema, AgentRuntimeAttachmentsSchema, AgentNativeContextContinuationAdmissionSchema, AgentNativeContextContinuationResultSchema, AgentTurnInputSchema, AgentTurnResultSchema, agentEnvironmentCreateInputDigest, agentNativeContextContinuationAdmissionMatchesRequest, agentNativeContextContinuationResultMatchesRequest, AccountUsageSchema, AgentEnvironmentObservationSchema, AgentEnvironmentStatusSchema, ComputeBillingSchema, EnvironmentLifecycleSchema, ModelUsageSchema, ObservationProvenanceSchema, PlacementDescriptorSchema, ProviderIdentitySchema, ResourceProfileSchema, ResourceUseSampleSchema, SafeEndpointSchema, agentEnvironmentObservationIdentityMatches, observationContainsCredential, observationOf, AgentInteractiveSessionAttachSchema, AgentInteractiveSessionControlClaimAcknowledgementSchema, AgentInteractiveSessionControlClaimRequestSchema, AgentInteractiveSessionControlClaimSchema, AgentInteractiveSessionPromptAcknowledgementSchema, AgentInteractiveSessionPromptCommandSchema, AgentInteractiveSessionRefSchema, AgentInteractiveSessionStartSchema, AgentInteractiveSessionStopAcknowledgementSchema, AgentInteractiveSessionStopCommandSchema, AgentInteractiveSessionStatusSchema, agentInteractiveSessionControlClaimAcknowledgementMatchesRequest, agentInteractiveSessionControlClaimRequestDigest, agentInteractiveSessionControlClaimMatchesRef, agentInteractiveSessionControlClaimIsNewer, agentInteractiveSessionPromptAcknowledgementMatchesCommand, agentInteractiveSessionPromptRequestDigest, agentInteractiveSessionStopAcknowledgementMatchesCommand, agentInteractiveSessionStopRequestDigest, agentInteractiveSessionRefMatchesStart, agentInteractiveSessionRunRef, agentInteractiveSessionStatusMatchesRef, exactAgentInteractiveSessionStart, createAgentEnvironmentWithIdempotency, canonicalWorkspaceCwd, MAX_WORKSPACE_CWD_LENGTH, workspaceCwdSchema, workspaceCwdPathForBase, WorkspaceRequestSchema, ResourceRequestSchema, TerminalAttachRequestSchema, TerminalAttachResultSchema, TerminalDetachAckSchema, TerminalInputSchema, TerminalOutputEventSchema, TerminalReplayWindowSchema, TerminalResizeSchema, TerminalSessionRefSchema, terminalAttachResultMatchesRequest, terminalSessionUsable, } from "./environment-provider.js";
11
+ export { AgentEnvironmentCapabilitiesSchema, AgentEnvironmentReadOnlyGetOptionsSchema, AgentRuntimeAttachmentsSchema, AgentNativeContextContinuationAdmissionSchema, AgentNativeContextContinuationResultSchema, AgentTurnInputSchema, AgentTurnResultSchema, agentEnvironmentCreateInputDigest, agentNativeContextContinuationAdmissionMatchesRequest, agentNativeContextContinuationResultMatchesRequest, AccountUsageSchema, AgentEnvironmentObservationSchema, AgentEnvironmentStatusSchema, ComputeBillingSchema, EnvironmentLifecycleSchema, ModelUsageSchema, ObservationProvenanceSchema, PlacementDescriptorSchema, ProviderIdentitySchema, ResourceProfileSchema, ResourceUseSampleSchema, SafeEndpointSchema, agentEnvironmentObservationIdentityMatches, observationContainsCredential, observationOf, AgentInteractiveSessionAttachSchema, AgentInteractiveSessionControlClaimAcknowledgementSchema, AgentInteractiveSessionControlClaimRequestSchema, AgentInteractiveSessionControlClaimSchema, AgentInteractiveSessionPromptAcknowledgementSchema, AgentInteractiveSessionPromptCommandSchema, AgentInteractiveSessionRefSchema, AgentInteractiveSessionStartSchema, AgentInteractiveSessionStopAcknowledgementSchema, AgentInteractiveSessionStopCommandSchema, AgentInteractiveSessionStatusSchema, agentInteractiveSessionControlClaimAcknowledgementMatchesRequest, agentInteractiveSessionControlClaimRequestDigest, agentInteractiveSessionControlClaimMatchesRef, agentInteractiveSessionControlClaimIsNewer, agentInteractiveSessionPromptAcknowledgementMatchesCommand, agentInteractiveSessionPromptRequestDigest, agentInteractiveSessionStopAcknowledgementMatchesCommand, agentInteractiveSessionStopRequestDigest, agentInteractiveSessionRefMatchesStart, agentInteractiveSessionRunRef, agentInteractiveSessionStatusMatchesRef, exactAgentInteractiveSessionStart, createAgentEnvironmentWithIdempotency, canonicalWorkspaceCwd, MAX_WORKSPACE_CWD_LENGTH, workspaceCwdSchema, workspaceCwdPathForBase, WorkspaceRequestSchema, ResourceRequestSchema, TerminalAttachRequestSchema, TerminalAttachResultSchema, TerminalDetachAckSchema, TerminalInputSchema, TerminalOutputEventSchema, TerminalReplayWindowSchema, TerminalResizeSchema, TerminalSessionRefSchema, terminalAttachResultMatchesRequest, terminalSessionUsable, } from "./environment-provider.js";
12
12
  export * from "./plan.js";
13
13
  export * from "./runtime-control.js";
14
14
  export * from "./portable-context.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tangle-network/agent-interface",
3
- "version": "5.4.0",
3
+ "version": "5.6.0",
4
4
  "type": "module",
5
5
  "sideEffects": false,
6
6
  "license": "MIT",