@tangle-network/sdk-provider-cli-base 0.13.210 → 0.13.212

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.
@@ -1,4 +1,4 @@
1
- import { Kt as CliProviderConfig, Ot as CliProviderAdapterBase, Wt as CliExecArgs, Xt as ExecutionState } from "../../index-gDCIpOnJ.mjs";
1
+ import { At as CliProviderAdapterBase, Jt as CliProviderConfig, Kt as CliExecArgs, Qt as ExecutionState } from "../../index-LwzOWUtG.mjs";
2
2
  import { StreamParserConfig } from "@tangle-network/sdk-cli-runner";
3
3
  import { McpConfig, ProviderConfig, StreamEvent } from "@tangle-network/agent-interface";
4
4
 
@@ -1,4 +1,4 @@
1
- import { Bt as textDeltaEvents, Ht as toolResultEvents, I as localMcpArgv, L as localMcpEnv, Lt as reasoningEvents, O as recordCliTokenUsage, Rt as sessionObservedEvents, S as jsonEventParser, Ut as toolStartEvents, k as CliProviderAdapterBase } from "../../src-B_4qa95r.mjs";
1
+ import { A as recordCliTokenUsage, Bt as sessionObservedEvents, Gt as toolStartEvents, Ht as textDeltaEvents, R as localMcpArgv, Wt as toolResultEvents, j as CliProviderAdapterBase, w as jsonEventParser, z as localMcpEnv, zt as reasoningEvents } from "../../src-OUp4Ymnt.mjs";
2
2
  //#region src/adapters/amp/types.ts
3
3
  /**
4
4
  * Type guard for AMP events.
@@ -1,4 +1,4 @@
1
- import { Dn as CliTurnSpawn, En as CliTurnProcess, Kt as CliProviderConfig, Ot as CliProviderAdapterBase, Wt as CliExecArgs, Xt as ExecutionState } from "../../index-gDCIpOnJ.mjs";
1
+ import { At as CliProviderAdapterBase, Jt as CliProviderConfig, Kt as CliExecArgs, On as CliTurnProcess, Qt as ExecutionState, kn as CliTurnSpawn } from "../../index-LwzOWUtG.mjs";
2
2
  import { StreamParserConfig } from "@tangle-network/sdk-cli-runner";
3
3
  import { StreamEvent } from "@tangle-network/agent-interface";
4
4
 
@@ -1,4 +1,4 @@
1
- import { C as plaintextResponseParser, Ht as toolResultEvents, O as recordCliTokenUsage, Rt as sessionObservedEvents, Ut as toolStartEvents, k as CliProviderAdapterBase } from "../../src-B_4qa95r.mjs";
1
+ import { A as recordCliTokenUsage, Bt as sessionObservedEvents, Gt as toolStartEvents, T as plaintextResponseParser, Wt as toolResultEvents, j as CliProviderAdapterBase } from "../../src-OUp4Ymnt.mjs";
2
2
  import { normalizeOpenAiCompatibleBaseUrl, resolveTangleRouterDefaults } from "@tangle-network/agent-interface";
3
3
  import { join } from "node:path";
4
4
  import { statSync } from "node:fs";
@@ -1,4 +1,4 @@
1
- import { Kt as CliProviderConfig, Ot as CliProviderAdapterBase, Wt as CliExecArgs, Xt as ExecutionState } from "../../index-gDCIpOnJ.mjs";
1
+ import { At as CliProviderAdapterBase, Jt as CliProviderConfig, Kt as CliExecArgs, Qt as ExecutionState } from "../../index-LwzOWUtG.mjs";
2
2
  import { StreamParserConfig } from "@tangle-network/sdk-cli-runner";
3
3
  import { AgentExecutionInput, AgentExecutionResult, BackendCapabilities, InteractionResponse, McpConfig, ProviderConfig, SdkHostServices, StreamEvent } from "@tangle-network/agent-interface";
4
4
 
@@ -1,4 +1,4 @@
1
- import { Bt as textDeltaEvents, F as isLocalMcpConfig, Ht as toolResultEvents, I as localMcpArgv, L as localMcpEnv, Lt as reasoningEvents, O as recordCliTokenUsage, R as enabledInteractionKinds, Rt as sessionObservedEvents, S as jsonEventParser, Ut as toolStartEvents, W as withTurnInteractions, g as McpInteractionSupport, k as CliProviderAdapterBase, zt as streamPartBase } from "../../src-B_4qa95r.mjs";
1
+ import { A as recordCliTokenUsage, B as enabledInteractionKinds, Bt as sessionObservedEvents, Gt as toolStartEvents, Ht as textDeltaEvents, K as withTurnInteractions, L as isLocalMcpConfig, R as localMcpArgv, Vt as streamPartBase, Wt as toolResultEvents, j as CliProviderAdapterBase, v as McpInteractionSupport, w as jsonEventParser, z as localMcpEnv, zt as reasoningEvents } from "../../src-OUp4Ymnt.mjs";
2
2
  import { createHash, randomUUID } from "node:crypto";
3
3
  import { InteractionKind } from "@tangle-network/agent-interface";
4
4
  import { mkdir, readFile, writeFile } from "node:fs/promises";
@@ -1,4 +1,4 @@
1
- import { Kt as CliProviderConfig, Ot as CliProviderAdapterBase, Wt as CliExecArgs, Xt as ExecutionState } from "../../index-gDCIpOnJ.mjs";
1
+ import { At as CliProviderAdapterBase, Jt as CliProviderConfig, Kt as CliExecArgs, Qt as ExecutionState } from "../../index-LwzOWUtG.mjs";
2
2
  import { StreamParserConfig } from "@tangle-network/sdk-cli-runner";
3
3
  import { StreamEvent } from "@tangle-network/agent-interface";
4
4
 
@@ -1,4 +1,4 @@
1
- import { Bt as textDeltaEvents, Ht as toolResultEvents, Lt as reasoningEvents, O as recordCliTokenUsage, Rt as sessionObservedEvents, S as jsonEventParser, Ut as toolStartEvents, _t as prependPromptSection, k as CliProviderAdapterBase } from "../../src-B_4qa95r.mjs";
1
+ import { A as recordCliTokenUsage, Bt as sessionObservedEvents, Gt as toolStartEvents, Ht as textDeltaEvents, Wt as toolResultEvents, j as CliProviderAdapterBase, w as jsonEventParser, yt as prependPromptSection, zt as reasoningEvents } from "../../src-OUp4Ymnt.mjs";
2
2
  import { isRecord } from "@tangle-network/agent-core";
3
3
  //#region src/adapters/grok/adapter.ts
4
4
  const DECLARE_MODEL = String.raw`d=$HOME/.grok; [ -z "$GROK_HOME" ] || d=$GROK_HOME
@@ -1,4 +1,4 @@
1
- import { Kt as CliProviderConfig, Ot as CliProviderAdapterBase, Wt as CliExecArgs, Xt as ExecutionState, n as HarnessId } from "../../index-gDCIpOnJ.mjs";
1
+ import { At as CliProviderAdapterBase, Jt as CliProviderConfig, Kt as CliExecArgs, Qt as ExecutionState, n as HarnessId } from "../../index-LwzOWUtG.mjs";
2
2
  import { i as PreparedAttachment } from "../../prompt-input-CD7okX8T.mjs";
3
3
  import { StreamParserConfig } from "@tangle-network/sdk-cli-runner";
4
4
  import { InputPart, McpConfig, StreamEvent } from "@tangle-network/agent-interface";
@@ -1,4 +1,4 @@
1
- import { Bt as textDeltaEvents, C as plaintextResponseParser, F as isLocalMcpConfig, Ht as toolResultEvents, I as localMcpArgv, It as finalTextEvent, L as localMcpEnv, O as recordCliTokenUsage, Rt as sessionObservedEvents, Ut as toolStartEvents, Vt as textSnapshotEvents, _t as prependPromptSection, ht as partitionImageAttachments, k as CliProviderAdapterBase } from "../../src-B_4qa95r.mjs";
1
+ import { A as recordCliTokenUsage, Bt as sessionObservedEvents, Gt as toolStartEvents, Ht as textDeltaEvents, L as isLocalMcpConfig, R as localMcpArgv, Rt as finalTextEvent, T as plaintextResponseParser, Ut as textSnapshotEvents, Wt as toolResultEvents, _t as partitionImageAttachments, j as CliProviderAdapterBase, yt as prependPromptSection, z as localMcpEnv } from "../../src-OUp4Ymnt.mjs";
2
2
  import { randomUUID } from "node:crypto";
3
3
  import { resolveTangleRouterDefaults } from "@tangle-network/agent-interface";
4
4
  import { writeFile } from "node:fs/promises";
@@ -1,4 +1,4 @@
1
- import { Kt as CliProviderConfig, Ot as CliProviderAdapterBase, Wt as CliExecArgs, Xt as ExecutionState, n as HarnessId } from "../../index-gDCIpOnJ.mjs";
1
+ import { At as CliProviderAdapterBase, Jt as CliProviderConfig, Kt as CliExecArgs, Qt as ExecutionState, n as HarnessId } from "../../index-LwzOWUtG.mjs";
2
2
  import { StreamParserConfig } from "@tangle-network/sdk-cli-runner";
3
3
  import { StreamEvent } from "@tangle-network/agent-interface";
4
4
 
@@ -1,4 +1,4 @@
1
- import { C as plaintextResponseParser, E as parseCliUsageLine, O as recordCliTokenUsage, Rt as sessionObservedEvents, _t as prependPromptSection, k as CliProviderAdapterBase } from "../../src-B_4qa95r.mjs";
1
+ import { A as recordCliTokenUsage, Bt as sessionObservedEvents, O as parseCliUsageLine, T as plaintextResponseParser, j as CliProviderAdapterBase, yt as prependPromptSection } from "../../src-OUp4Ymnt.mjs";
2
2
  import { normalizeOpenAiCompatibleBaseUrl, resolveTangleRouterDefaults } from "@tangle-network/agent-interface";
3
3
  import { join } from "node:path";
4
4
  //#region src/adapters/nanoclaw/adapter.ts
@@ -1,4 +1,4 @@
1
- import { Dn as CliTurnSpawn, En as CliTurnProcess, Kt as CliProviderConfig, Ot as CliProviderAdapterBase, Wt as CliExecArgs, Xt as ExecutionState } from "../../index-gDCIpOnJ.mjs";
1
+ import { At as CliProviderAdapterBase, Jt as CliProviderConfig, Kt as CliExecArgs, On as CliTurnProcess, Qt as ExecutionState, kn as CliTurnSpawn } from "../../index-LwzOWUtG.mjs";
2
2
  import { i as PreparedAttachment } from "../../prompt-input-CD7okX8T.mjs";
3
3
  import { StreamParserConfig } from "@tangle-network/sdk-cli-runner";
4
4
  import { InputPart, StreamEvent } from "@tangle-network/agent-interface";
@@ -1,4 +1,4 @@
1
- import { Bt as textDeltaEvents, Ht as toolResultEvents, O as recordCliTokenUsage, Rt as sessionObservedEvents, Ut as toolStartEvents, _t as prependPromptSection, k as CliProviderAdapterBase } from "../../src-B_4qa95r.mjs";
1
+ import { A as recordCliTokenUsage, Bt as sessionObservedEvents, Gt as toolStartEvents, Ht as textDeltaEvents, Wt as toolResultEvents, j as CliProviderAdapterBase, yt as prependPromptSection } from "../../src-OUp4Ymnt.mjs";
2
2
  import { qualifyModelId } from "@tangle-network/agent-profile-materialize";
3
3
  import { normalizeOpenAiCompatibleBaseUrl, resolveTangleRouterDefaults } from "@tangle-network/agent-interface";
4
4
  import { join, relative } from "node:path";
@@ -1,4 +1,4 @@
1
- import { Dn as CliTurnSpawn, En as CliTurnProcess, Gt as CliExecutionInput, Kt as CliProviderConfig, Ot as CliProviderAdapterBase, Wt as CliExecArgs, Xt as ExecutionState, c as WorkspacePlanApplication, n as HarnessId } from "../../index-gDCIpOnJ.mjs";
1
+ import { At as CliProviderAdapterBase, Jt as CliProviderConfig, Kt as CliExecArgs, On as CliTurnProcess, Qt as ExecutionState, c as WorkspacePlanApplication, kn as CliTurnSpawn, n as HarnessId, qt as CliExecutionInput } from "../../index-LwzOWUtG.mjs";
2
2
  import { StreamParserConfig } from "@tangle-network/sdk-cli-runner";
3
3
  import { CliAuthFile, ProviderConfig, StreamEvent } from "@tangle-network/agent-interface";
4
4
 
@@ -52,8 +52,8 @@ declare class OpenclawProviderAdapter extends CliProviderAdapterBase<OpenclawCon
52
52
  * Reads the limits of each model that has none yet from the Router's
53
53
  * catalog, with the key the turn's model calls carry. This runs before a
54
54
  * turn, so it must not hold or fail one: resolveRouterModelLimits bounds the
55
- * request, answers from a catalog it read within the last minute, and stops
56
- * asking an endpoint that failed for a minute.
55
+ * request, answers from the catalog the process already read, and does not
56
+ * repeat a failed read inside its stop.
57
57
  *
58
58
  * A model whose limits could not be read is declared without them, so until
59
59
  * a later turn's read succeeds OpenClaw takes it to hold 128000 tokens and
@@ -1,4 +1,4 @@
1
- import { Bt as textDeltaEvents, Ht as toolResultEvents, It as finalTextEvent, O as recordCliTokenUsage, Rt as sessionObservedEvents, Ut as toolStartEvents, Vt as textSnapshotEvents, _t as prependPromptSection, f as resolveRouterModelLimits, h as nativeEffortArgs, k as CliProviderAdapterBase } from "../../src-B_4qa95r.mjs";
1
+ import { A as recordCliTokenUsage, Bt as sessionObservedEvents, Gt as toolStartEvents, Ht as textDeltaEvents, Rt as finalTextEvent, Ut as textSnapshotEvents, Wt as toolResultEvents, _ as nativeEffortArgs, j as CliProviderAdapterBase, m as resolveRouterModelLimits, yt as prependPromptSection } from "../../src-OUp4Ymnt.mjs";
2
2
  import { randomUUID } from "node:crypto";
3
3
  import { resolveTangleRouterDefaults } from "@tangle-network/agent-interface";
4
4
  import { StringDecoder } from "node:string_decoder";
@@ -165,8 +165,8 @@ var OpenclawProviderAdapter = class extends CliProviderAdapterBase {
165
165
  * Reads the limits of each model that has none yet from the Router's
166
166
  * catalog, with the key the turn's model calls carry. This runs before a
167
167
  * turn, so it must not hold or fail one: resolveRouterModelLimits bounds the
168
- * request, answers from a catalog it read within the last minute, and stops
169
- * asking an endpoint that failed for a minute.
168
+ * request, answers from the catalog the process already read, and does not
169
+ * repeat a failed read inside its stop.
170
170
  *
171
171
  * A model whose limits could not be read is declared without them, so until
172
172
  * a later turn's read succeeds OpenClaw takes it to hold 128000 tokens and
@@ -1,4 +1,4 @@
1
- import { An as AcpProcessSpec, Dt as AcpProviderAdapterBase, Ft as AcpContentBlock, Pt as AcpBridgeConfig, Vt as AcpTurn, kn as AcpBridgeSpawn } from "../../index-gDCIpOnJ.mjs";
1
+ import { It as AcpBridgeConfig, Lt as AcpContentBlock, Mn as AcpProcessSpec, Ut as AcpTurn, jn as AcpBridgeSpawn, kt as AcpProviderAdapterBase } from "../../index-LwzOWUtG.mjs";
2
2
  import { i as PreparedAttachment } from "../../prompt-input-CD7okX8T.mjs";
3
3
  import { PRIME_AGENT_DIR_ENV_VAR, PRIME_AGENT_DIR_ENV_VARS, PRIME_HARNESS_STATE_ENV_DENYLIST, PRIME_KERNEL_DEAD_MARKERS, PRIME_KERNEL_ENV_PASSTHROUGH, PRIME_MCP_UNSUPPORTED_REASON, PrimeHarnessStateError, PrimeMaterializeOptions, PrimeProfileControls, PrimeProfileControls as PrimeProfileControls$1, PrimeProfileError, PrimeProfileSkill, PrimeProfileSubagent, assertPrimeModelAgreement, hasPrimeProfileMaterial, matchPrimeKernelDeadMarker, materializePrimeProfileControls, primeAgentDirEnv, primeProfileNeedsAgentDir, primeSubagentEntryId as subagentEntryId, primeThinkingLevel, prunePrimeProfileMaterial, readPrimeProfileControls } from "@tangle-network/agent-profile-materialize";
4
4
  import { RpcBridge } from "@tangle-network/sdk-cli-runner";
@@ -71,9 +71,11 @@ interface PrimeTurn extends AcpTurn<PrimeConfig> {
71
71
  * Kernel death closes the session with a typed failure.
72
72
  *
73
73
  * prime hosts one session per connection and has no `session/load`: a new
74
- * process opens a new ACP session and a new prime-agent session. It reads an
75
- * earlier session's file only when the caller's flags name one (`--continue`,
76
- * `--resume`), which prime-agent looks up in its session directory.
74
+ * process opens a new ACP session and a new prime-agent session, and a
75
+ * session's turn in a new process replays the durable transcript (see
76
+ * `resumableProviderSessionId` in the ACP base). prime-agent reads an earlier
77
+ * session's file only when the caller's flags name one (`--continue`,
78
+ * `--resume`), which it looks up in its session directory.
77
79
  */
78
80
  declare class PrimeProviderAdapter extends AcpProviderAdapterBase<PrimeConfig, PrimeTurn> {
79
81
  readonly provider = "prime";
@@ -1,4 +1,4 @@
1
- import { D as readCliTokenUsage, Yt as spawnAcpBridge, _t as prependPromptSection, w as AcpProviderAdapterBase } from "../../src-B_4qa95r.mjs";
1
+ import { E as AcpProviderAdapterBase, Zt as spawnAcpBridge, k as readCliTokenUsage, yt as prependPromptSection } from "../../src-OUp4Ymnt.mjs";
2
2
  import { PRIME_AGENT_DIR_ENV_VAR, PRIME_AGENT_DIR_ENV_VAR as PRIME_AGENT_DIR_ENV_VAR$1, PRIME_AGENT_DIR_ENV_VARS, PRIME_HARNESS_STATE_ENV_DENYLIST, PRIME_HARNESS_STATE_ENV_DENYLIST as PRIME_HARNESS_STATE_ENV_DENYLIST$1, PRIME_KERNEL_DEAD_MARKERS, PRIME_KERNEL_ENV_PASSTHROUGH, PRIME_KERNEL_ENV_PASSTHROUGH as PRIME_KERNEL_ENV_PASSTHROUGH$1, PRIME_MCP_UNSUPPORTED_REASON, PrimeHarnessStateError, PrimeProfileError, assertPrimeModelAgreement, assertPrimeModelAgreement as assertPrimeModelAgreement$1, buildPiModelsConfig, hasPrimeProfileMaterial, matchPrimeKernelDeadMarker, materializePrimeProfileControls, materializePrimeProfileControls as materializePrimeProfileControls$1, primeAgentDirEnv, primeAgentDirEnv as primeAgentDirEnv$1, primeHarnessStatePath, primeProfileNeedsAgentDir, primeSubagentEntryId as subagentEntryId, primeThinkingLevel, primeThinkingLevel as primeThinkingLevel$1, prunePrimeProfileMaterial, readPrimeProfileControls, readPrimeProfileControls as readPrimeProfileControls$1, writePrimeAgentFile } from "@tangle-network/agent-profile-materialize";
3
3
  import { isAbsolute, join, relative, sep } from "node:path";
4
4
  import { existsSync, lchownSync, lstatSync, mkdirSync } from "node:fs";
@@ -440,9 +440,11 @@ function __setPrimeBridgeFactoryForTesting(factory) {
440
440
  * Kernel death closes the session with a typed failure.
441
441
  *
442
442
  * prime hosts one session per connection and has no `session/load`: a new
443
- * process opens a new ACP session and a new prime-agent session. It reads an
444
- * earlier session's file only when the caller's flags name one (`--continue`,
445
- * `--resume`), which prime-agent looks up in its session directory.
443
+ * process opens a new ACP session and a new prime-agent session, and a
444
+ * session's turn in a new process replays the durable transcript (see
445
+ * `resumableProviderSessionId` in the ACP base). prime-agent reads an earlier
446
+ * session's file only when the caller's flags name one (`--continue`,
447
+ * `--resume`), which it looks up in its session directory.
446
448
  */
447
449
  var PrimeProviderAdapter = class extends AcpProviderAdapterBase {
448
450
  provider = "prime";
@@ -886,6 +886,15 @@ declare abstract class AcpProviderAdapterBase<TConfig extends AcpBridgeConfig, T
886
886
  protected takeTurnFailure(_sessionId: string): Error | undefined;
887
887
  protected onSessionEvicted(_sessionId: string): void;
888
888
  protected turnLogContext(_turn: TTurn): Record<string, unknown>;
889
+ /**
890
+ * An agent with no `session/load` holds a conversation only in its running
891
+ * process, and a new process opens an empty native session. Its stored id
892
+ * is therefore resumable only while this adapter holds that process. Once
893
+ * the process is gone (the sidecar restarted, the idle process was reaped,
894
+ * the turn needs another process configuration) the turn replays the
895
+ * durable transcript into the new session.
896
+ */
897
+ protected resumableProviderSessionId(session: PersistedSession): Promise<string | undefined>;
889
898
  execute(input: AgentExecutionInput, services: SdkHostServices, onEvent?: (event: StreamEvent) => void): Promise<AgentExecutionResult>;
890
899
  protected interruptStuckTurn(): void;
891
900
  protected acknowledgeLostTurn(_detail: string): Promise<boolean>;
@@ -893,6 +902,11 @@ declare abstract class AcpProviderAdapterBase<TConfig extends AcpBridgeConfig, T
893
902
  private checkProtocolVersion;
894
903
  private openNativeSession;
895
904
  private promptAcpSession;
905
+ /**
906
+ * The session's running process, when it was started for the process
907
+ * configuration the turn needs. One started for another is ended.
908
+ */
909
+ private heldAcpSession;
896
910
  private scheduleIdleReap;
897
911
  private cancelIdleReap;
898
912
  protected evictAcpSession(sessionId: string, reason: string): void;
@@ -1250,7 +1264,7 @@ type RouterModelLimitsResult = {
1250
1264
  status: "unavailable";
1251
1265
  reason: string;
1252
1266
  };
1253
- /** One catalog request at backend start; a slow gateway must not hold the turn. */
1267
+ /** How long one catalog request may take; a slow gateway must not hold the turn. */
1254
1268
  declare const ROUTER_MODEL_CATALOG_TIMEOUT_MS = 5000;
1255
1269
  interface ResolveRouterModelLimitsInput {
1256
1270
  /** OpenAI-compatible root, including `/v1`. */
@@ -1261,26 +1275,31 @@ interface ResolveRouterModelLimitsInput {
1261
1275
  catalogAlias?: string;
1262
1276
  /** The backend's model credential. Sent as a bearer token; a sandbox's egress proxy requires it. */
1263
1277
  apiKey?: string;
1264
- fetchImpl?: typeof fetch;
1265
- timeoutMs?: number;
1266
- /** Opt in to sharing a successful catalog for this credential and deployment revision. */
1278
+ /** A deployment revision. Callers naming different revisions keep separate catalogs; the rest share one. */
1267
1279
  cacheRevision?: string;
1268
1280
  }
1269
- interface CatalogEntry {
1270
- id?: unknown;
1271
- _provider?: unknown;
1272
- context_length?: unknown;
1273
- max_completion_tokens?: unknown;
1274
- max_completion_tokens_source?: unknown;
1275
- max_completion_tokens_verified?: unknown;
1276
- reasoning_effort_values?: unknown;
1277
- }
1281
+ /** The entry fields this module reads. A kept catalog holds these and nothing else of the list. */
1282
+ declare const CATALOG_FIELDS: readonly ["id", "_provider", "context_length", "max_completion_tokens", "max_completion_tokens_source", "max_completion_tokens_verified", "reasoning_effort_values"];
1283
+ type CatalogEntry = Partial<Record<(typeof CATALOG_FIELDS)[number], unknown>>;
1278
1284
  /**
1279
1285
  * The catalog names a model two ways: some ids are already provider-qualified, and the rest are
1280
1286
  * bare with the vendor in `_provider` (the Tangle Router lists `glm-5.3` with `_provider: "zai"`
1281
1287
  * while requests name `zai/glm-5.3`). An exact id wins so a qualified id is never shadowed.
1282
1288
  */
1283
1289
  declare function findRouterCatalogEntry(entries: readonly unknown[], model: string): CatalogEntry | undefined;
1290
+ /**
1291
+ * How long a process answers from the list it read. It is also the floor: no response header
1292
+ * shortens it and none lengthens it, because `cache-control` and `expires` are not read. The
1293
+ * production Router marks this list, about 63 KB gzipped, `no-store`, and a helper that obeys
1294
+ * the mark asks for the whole list on every call from every box; on 2026-11-24 a benchmark
1295
+ * starting many boxes made the Router's replicas miss health checks. One lifetime covers a box
1296
+ * start and the turns after it with one request, and it bounds how long a running box keeps a
1297
+ * limit the Router has since corrected. After it the list is asked for again, with the
1298
+ * validator the gateway gave, so an unchanged list costs a 304 and no body.
1299
+ */
1300
+ declare const ROUTER_MODEL_CATALOG_LIFETIME_MS: number;
1301
+ /** A failed read is not repeated for this long, so no turn waits on a failing catalog twice. */
1302
+ declare const ROUTER_MODEL_CATALOG_FAILURE_STOP_MS = 60000;
1284
1303
  /** The model's listed `reasoning_effort_values`, trimmed and lowercased, or why the catalog was unreadable. */
1285
1304
  declare function resolveRouterModelReasoningEfforts(input: ResolveRouterModelLimitsInput): Promise<string[] | string>;
1286
1305
  declare function resolveRouterModelLimits(input: ResolveRouterModelLimitsInput): Promise<RouterModelLimitsResult>;
@@ -1454,5 +1473,5 @@ declare function homeXdgEnv(home: string): {
1454
1473
  XDG_STATE_HOME: string;
1455
1474
  };
1456
1475
  //#endregion
1457
- export { AskUserBridge as $, PerTurnInteractionInput as $t, refuseSecretLaunch as A, AcpProcessSpec as An, createExecutionState as At, RepeatedToolFailureGuardOptions as B, AcpSessionUpdateParams as Bt, forgetSessionScopes as C, sharedSecretMcpRefused as Cn, failureAfterCleanup as Ct, assertSealedNativeHome as D, CliTurnSpawn as Dn, AcpProviderAdapterBase as Dt, SEALED_NATIVE_HOME_LAYOUT as E, CliTurnProcess as En, mapAcpSessionUpdate as Et, RouterModelLimitsResult as F, AcpContentBlock as Ft, accumulateCliTokenUsage as G, CliExecutionInput as Gt, trackReasoningBlock as H, acpContentText as Ht, findRouterCatalogEntry as I, AcpInitializeParams as It, recordCliTokenUsage as J, CliProviderOptions as Jt, parseCliUsageLine as K, CliProviderConfig as Kt, resolveRouterModelLimits as L, AcpInitializeResult as Lt, ROUTER_MODEL_CATALOG_TIMEOUT_MS as M, ACP_MIN_PROTOCOL_VERSION as Mt, ResolveRouterModelLimitsInput as N, ACP_PROTOCOL_VERSION as Nt, isTrustedStoreBinary as O, PreparedCliLaunch as On, CliProviderAdapterBase as Ot, RouterModelLimits as P, AcpBridgeConfig as Pt, McpInteractionSupport as Q, InteractionToggleKind as Qt, resolveRouterModelReasoningEfforts as R, AcpNewSessionResult as Rt, toolStartEvents as S, servableStdioServer as Sn, SessionRehydrationError as St, NATIVE_SESSION_CONTRACTS$1 as T, untilSettledOrAborted as Tn, wasNeverLaunched as Tt, kimiThinkingArgs as U, assertAcpTurnFinished as Ut, createRepeatedToolFailureGuard as V, AcpTurn as Vt, nativeEffortArgs as W, CliExecArgs as Wt, localMcpArgv as X, ExecutionState as Xt, isLocalMcpConfig as Y, EphemeralContextInput as Yt, localMcpEnv as Z, InteractionToggleConfig as Zt, sessionObservedEvents as _, joinQueue as _n, executionCorrelationHeaders as _t, PERMISSION_DECISION_TIMEOUT_MS as a, turnEndReason as an, RequestPlanBridge as at, textSnapshotEvents as b, secretSessionTurnQueue as bn, plaintextResponseParser as bt, WorkspacePlanApplication$1 as c, withTurnInteractions as cn, buildFileUrl as ct, endFailedTurn as d, SecretProfileMcpLease as dn, inferMediaType as dt, ToolCallState as en, DEFAULT_INTERACTION_MCP_SERVER_NAME as et, recordTurnInterruption as f, SecretProfileMcpServer as fn, trackFilePart as ft, reasoningEvents as g, isPlainRecord as gn, MANAGED_QUOTE_VERSION_HEADER as gt, finalTextEvent as h, isLoopbackEndpoint as hn, EXECUTION_TRACE_HEADER as ht, InteractionHttpBridge as i, readEphemeralContext as in, RequestPermissionBridge as it, resolveExecutableRealpath as j, spawnAcpBridge as jn, TurnObserver as jt, provenStoreBinary as k, AcpBridgeSpawn as kn, runtimeSecretsOverlay as kt, codexDeveloperInstructionArgs as l, SHARED_WORKSPACE_DIR_ENV as ln, deriveFilePart as lt, TerminalPlanSupportOptions as m, directStdioMcpServers as mn, EXECUTION_ID_HEADER as mt, HarnessId$1 as n, enabledInteractionKinds as nn, InteractionMcpServerConfig$1 as nt, SECRET_REFERENCE$1 as o, turnInteractionEnabled as on, brokerInteractionTools$1 as ot, TerminalPlanSupport as p, assertSealedNativeSearchPath as pn, EXECUTION_CORRELATION_HEADERS as pt, readCliTokenUsage as q, CliProviderLogger as qt, InteractionBroker$1 as r, interactionToggleEnabled as rn, PermissionPromptBridge as rt, SECRET_REFERENCE_PREFIX$1 as s, withEphemeralContext as sn, interactionMcpToolName as st, CODEX_DISABLED_FEATURE_ARGS as t, TurnEndReason as tn, InteractionMcpServer$1 as tt, homeXdgEnv as u, SecretProfileMcpCredentialProxy as un, deterministicFilePartId as ut, streamPartBase as v, requireRecord as vn, PlaintextResponse as vt, secretMcpScope as w, spawnUnderSecretMcpLease as wn, rejectNotLaunched as wt, toolResultEvents as x, servableMcpServer as xn, InvalidAttachmentError as xt, textDeltaEvents as y, resolveReferences as yn, jsonEventParser as yt, RepeatedToolFailure as z, AcpPromptResult as zt };
1458
- //# sourceMappingURL=index-gDCIpOnJ.d.mts.map
1476
+ export { localMcpEnv as $, InteractionToggleConfig as $t, refuseSecretLaunch as A, PreparedCliLaunch as An, CliProviderAdapterBase as At, resolveRouterModelReasoningEfforts as B, AcpNewSessionResult as Bt, forgetSessionScopes as C, servableMcpServer as Cn, InvalidAttachmentError as Ct, assertSealedNativeHome as D, untilSettledOrAborted as Dn, wasNeverLaunched as Dt, SEALED_NATIVE_HOME_LAYOUT as E, spawnUnderSecretMcpLease as En, rejectNotLaunched as Et, ResolveRouterModelLimitsInput as F, ACP_PROTOCOL_VERSION as Ft, kimiThinkingArgs as G, assertAcpTurnFinished as Gt, RepeatedToolFailureGuardOptions as H, AcpSessionUpdateParams as Ht, RouterModelLimits as I, AcpBridgeConfig as It, parseCliUsageLine as J, CliProviderConfig as Jt, nativeEffortArgs as K, CliExecArgs as Kt, RouterModelLimitsResult as L, AcpContentBlock as Lt, ROUTER_MODEL_CATALOG_FAILURE_STOP_MS as M, AcpProcessSpec as Mn, createExecutionState as Mt, ROUTER_MODEL_CATALOG_LIFETIME_MS as N, spawnAcpBridge as Nn, TurnObserver as Nt, isTrustedStoreBinary as O, CliTurnProcess as On, mapAcpSessionUpdate as Ot, ROUTER_MODEL_CATALOG_TIMEOUT_MS as P, ACP_MIN_PROTOCOL_VERSION as Pt, localMcpArgv as Q, ExecutionState as Qt, findRouterCatalogEntry as R, AcpInitializeParams as Rt, toolStartEvents as S, secretSessionTurnQueue as Sn, plaintextResponseParser as St, NATIVE_SESSION_CONTRACTS$1 as T, sharedSecretMcpRefused as Tn, failureAfterCleanup as Tt, createRepeatedToolFailureGuard as U, AcpTurn as Ut, RepeatedToolFailure as V, AcpPromptResult as Vt, trackReasoningBlock as W, acpContentText as Wt, recordCliTokenUsage as X, CliProviderOptions as Xt, readCliTokenUsage as Y, CliProviderLogger as Yt, isLocalMcpConfig as Z, EphemeralContextInput as Zt, sessionObservedEvents as _, isLoopbackEndpoint as _n, EXECUTION_TRACE_HEADER as _t, PERMISSION_DECISION_TIMEOUT_MS as a, interactionToggleEnabled as an, PermissionPromptBridge as at, textSnapshotEvents as b, requireRecord as bn, PlaintextResponse as bt, WorkspacePlanApplication$1 as c, turnInteractionEnabled as cn, brokerInteractionTools$1 as ct, endFailedTurn as d, SHARED_WORKSPACE_DIR_ENV as dn, deriveFilePart as dt, InteractionToggleKind as en, McpInteractionSupport as et, recordTurnInterruption as f, SecretProfileMcpCredentialProxy as fn, deterministicFilePartId as ft, reasoningEvents as g, directStdioMcpServers as gn, EXECUTION_ID_HEADER as gt, finalTextEvent as h, assertSealedNativeSearchPath as hn, EXECUTION_CORRELATION_HEADERS as ht, InteractionHttpBridge as i, enabledInteractionKinds as in, InteractionMcpServerConfig$1 as it, resolveExecutableRealpath as j, AcpBridgeSpawn as jn, runtimeSecretsOverlay as jt, provenStoreBinary as k, CliTurnSpawn as kn, AcpProviderAdapterBase as kt, codexDeveloperInstructionArgs as l, withEphemeralContext as ln, interactionMcpToolName as lt, TerminalPlanSupportOptions as m, SecretProfileMcpServer as mn, trackFilePart as mt, HarnessId$1 as n, ToolCallState as nn, DEFAULT_INTERACTION_MCP_SERVER_NAME as nt, SECRET_REFERENCE$1 as o, readEphemeralContext as on, RequestPermissionBridge as ot, TerminalPlanSupport as p, SecretProfileMcpLease as pn, inferMediaType as pt, accumulateCliTokenUsage as q, CliExecutionInput as qt, InteractionBroker$1 as r, TurnEndReason as rn, InteractionMcpServer$1 as rt, SECRET_REFERENCE_PREFIX$1 as s, turnEndReason as sn, RequestPlanBridge as st, CODEX_DISABLED_FEATURE_ARGS as t, PerTurnInteractionInput as tn, AskUserBridge as tt, homeXdgEnv as u, withTurnInteractions as un, buildFileUrl as ut, streamPartBase as v, isPlainRecord as vn, MANAGED_QUOTE_VERSION_HEADER as vt, secretMcpScope as w, servableStdioServer as wn, SessionRehydrationError as wt, toolResultEvents as x, resolveReferences as xn, jsonEventParser as xt, textDeltaEvents as y, joinQueue as yn, executionCorrelationHeaders as yt, resolveRouterModelLimits as z, AcpInitializeResult as zt };
1477
+ //# sourceMappingURL=index-LwzOWUtG.d.mts.map
package/dist/index.d.mts CHANGED
@@ -1,3 +1,3 @@
1
- import { $ as AskUserBridge, $t as PerTurnInteractionInput, A as refuseSecretLaunch, An as AcpProcessSpec, At as createExecutionState, B as RepeatedToolFailureGuardOptions, Bt as AcpSessionUpdateParams, C as forgetSessionScopes, Cn as sharedSecretMcpRefused, Ct as failureAfterCleanup, D as assertSealedNativeHome, Dn as CliTurnSpawn, Dt as AcpProviderAdapterBase, E as SEALED_NATIVE_HOME_LAYOUT, En as CliTurnProcess, Et as mapAcpSessionUpdate, F as RouterModelLimitsResult, Ft as AcpContentBlock, G as accumulateCliTokenUsage, Gt as CliExecutionInput, H as trackReasoningBlock, Ht as acpContentText, I as findRouterCatalogEntry, It as AcpInitializeParams, J as recordCliTokenUsage, Jt as CliProviderOptions, K as parseCliUsageLine, Kt as CliProviderConfig, L as resolveRouterModelLimits, Lt as AcpInitializeResult, M as ROUTER_MODEL_CATALOG_TIMEOUT_MS, Mt as ACP_MIN_PROTOCOL_VERSION, N as ResolveRouterModelLimitsInput, Nt as ACP_PROTOCOL_VERSION, O as isTrustedStoreBinary, On as PreparedCliLaunch, Ot as CliProviderAdapterBase, P as RouterModelLimits, Pt as AcpBridgeConfig, Q as McpInteractionSupport, Qt as InteractionToggleKind, R as resolveRouterModelReasoningEfforts, Rt as AcpNewSessionResult, S as toolStartEvents, Sn as servableStdioServer, St as SessionRehydrationError, T as NATIVE_SESSION_CONTRACTS, Tn as untilSettledOrAborted, Tt as wasNeverLaunched, U as kimiThinkingArgs, Ut as assertAcpTurnFinished, V as createRepeatedToolFailureGuard, Vt as AcpTurn, W as nativeEffortArgs, Wt as CliExecArgs, X as localMcpArgv, Xt as ExecutionState, Y as isLocalMcpConfig, Yt as EphemeralContextInput, Z as localMcpEnv, Zt as InteractionToggleConfig, _ as sessionObservedEvents, _n as joinQueue, _t as executionCorrelationHeaders, a as PERMISSION_DECISION_TIMEOUT_MS, an as turnEndReason, at as RequestPlanBridge, b as textSnapshotEvents, bn as secretSessionTurnQueue, bt as plaintextResponseParser, c as WorkspacePlanApplication, cn as withTurnInteractions, ct as buildFileUrl, d as endFailedTurn, dn as SecretProfileMcpLease, dt as inferMediaType, en as ToolCallState, et as DEFAULT_INTERACTION_MCP_SERVER_NAME, f as recordTurnInterruption, fn as SecretProfileMcpServer, ft as trackFilePart, g as reasoningEvents, gn as isPlainRecord, gt as MANAGED_QUOTE_VERSION_HEADER, h as finalTextEvent, hn as isLoopbackEndpoint, ht as EXECUTION_TRACE_HEADER, i as InteractionHttpBridge, in as readEphemeralContext, it as RequestPermissionBridge, j as resolveExecutableRealpath, jn as spawnAcpBridge, jt as TurnObserver, k as provenStoreBinary, kn as AcpBridgeSpawn, kt as runtimeSecretsOverlay, l as codexDeveloperInstructionArgs, ln as SHARED_WORKSPACE_DIR_ENV, lt as deriveFilePart, m as TerminalPlanSupportOptions, mn as directStdioMcpServers, mt as EXECUTION_ID_HEADER, n as HarnessId, nn as enabledInteractionKinds, nt as InteractionMcpServerConfig, o as SECRET_REFERENCE, on as turnInteractionEnabled, ot as brokerInteractionTools, p as TerminalPlanSupport, pn as assertSealedNativeSearchPath, pt as EXECUTION_CORRELATION_HEADERS, q as readCliTokenUsage, qt as CliProviderLogger, r as InteractionBroker, rn as interactionToggleEnabled, rt as PermissionPromptBridge, s as SECRET_REFERENCE_PREFIX, sn as withEphemeralContext, st as interactionMcpToolName, t as CODEX_DISABLED_FEATURE_ARGS, tn as TurnEndReason, tt as InteractionMcpServer, u as homeXdgEnv, un as SecretProfileMcpCredentialProxy, ut as deterministicFilePartId, v as streamPartBase, vn as requireRecord, vt as PlaintextResponse, w as secretMcpScope, wn as spawnUnderSecretMcpLease, wt as rejectNotLaunched, x as toolResultEvents, xn as servableMcpServer, xt as InvalidAttachmentError, y as textDeltaEvents, yn as resolveReferences, yt as jsonEventParser, z as RepeatedToolFailure, zt as AcpPromptResult } from "./index-gDCIpOnJ.mjs";
1
+ import { $ as localMcpEnv, $t as InteractionToggleConfig, A as refuseSecretLaunch, An as PreparedCliLaunch, At as CliProviderAdapterBase, B as resolveRouterModelReasoningEfforts, Bt as AcpNewSessionResult, C as forgetSessionScopes, Cn as servableMcpServer, Ct as InvalidAttachmentError, D as assertSealedNativeHome, Dn as untilSettledOrAborted, Dt as wasNeverLaunched, E as SEALED_NATIVE_HOME_LAYOUT, En as spawnUnderSecretMcpLease, Et as rejectNotLaunched, F as ResolveRouterModelLimitsInput, Ft as ACP_PROTOCOL_VERSION, G as kimiThinkingArgs, Gt as assertAcpTurnFinished, H as RepeatedToolFailureGuardOptions, Ht as AcpSessionUpdateParams, I as RouterModelLimits, It as AcpBridgeConfig, J as parseCliUsageLine, Jt as CliProviderConfig, K as nativeEffortArgs, Kt as CliExecArgs, L as RouterModelLimitsResult, Lt as AcpContentBlock, M as ROUTER_MODEL_CATALOG_FAILURE_STOP_MS, Mn as AcpProcessSpec, Mt as createExecutionState, N as ROUTER_MODEL_CATALOG_LIFETIME_MS, Nn as spawnAcpBridge, Nt as TurnObserver, O as isTrustedStoreBinary, On as CliTurnProcess, Ot as mapAcpSessionUpdate, P as ROUTER_MODEL_CATALOG_TIMEOUT_MS, Pt as ACP_MIN_PROTOCOL_VERSION, Q as localMcpArgv, Qt as ExecutionState, R as findRouterCatalogEntry, Rt as AcpInitializeParams, S as toolStartEvents, Sn as secretSessionTurnQueue, St as plaintextResponseParser, T as NATIVE_SESSION_CONTRACTS, Tn as sharedSecretMcpRefused, Tt as failureAfterCleanup, U as createRepeatedToolFailureGuard, Ut as AcpTurn, V as RepeatedToolFailure, Vt as AcpPromptResult, W as trackReasoningBlock, Wt as acpContentText, X as recordCliTokenUsage, Xt as CliProviderOptions, Y as readCliTokenUsage, Yt as CliProviderLogger, Z as isLocalMcpConfig, Zt as EphemeralContextInput, _ as sessionObservedEvents, _n as isLoopbackEndpoint, _t as EXECUTION_TRACE_HEADER, a as PERMISSION_DECISION_TIMEOUT_MS, an as interactionToggleEnabled, at as PermissionPromptBridge, b as textSnapshotEvents, bn as requireRecord, bt as PlaintextResponse, c as WorkspacePlanApplication, cn as turnInteractionEnabled, ct as brokerInteractionTools, d as endFailedTurn, dn as SHARED_WORKSPACE_DIR_ENV, dt as deriveFilePart, en as InteractionToggleKind, et as McpInteractionSupport, f as recordTurnInterruption, fn as SecretProfileMcpCredentialProxy, ft as deterministicFilePartId, g as reasoningEvents, gn as directStdioMcpServers, gt as EXECUTION_ID_HEADER, h as finalTextEvent, hn as assertSealedNativeSearchPath, ht as EXECUTION_CORRELATION_HEADERS, i as InteractionHttpBridge, in as enabledInteractionKinds, it as InteractionMcpServerConfig, j as resolveExecutableRealpath, jn as AcpBridgeSpawn, jt as runtimeSecretsOverlay, k as provenStoreBinary, kn as CliTurnSpawn, kt as AcpProviderAdapterBase, l as codexDeveloperInstructionArgs, ln as withEphemeralContext, lt as interactionMcpToolName, m as TerminalPlanSupportOptions, mn as SecretProfileMcpServer, mt as trackFilePart, n as HarnessId, nn as ToolCallState, nt as DEFAULT_INTERACTION_MCP_SERVER_NAME, o as SECRET_REFERENCE, on as readEphemeralContext, ot as RequestPermissionBridge, p as TerminalPlanSupport, pn as SecretProfileMcpLease, pt as inferMediaType, q as accumulateCliTokenUsage, qt as CliExecutionInput, r as InteractionBroker, rn as TurnEndReason, rt as InteractionMcpServer, s as SECRET_REFERENCE_PREFIX, sn as turnEndReason, st as RequestPlanBridge, t as CODEX_DISABLED_FEATURE_ARGS, tn as PerTurnInteractionInput, tt as AskUserBridge, u as homeXdgEnv, un as withTurnInteractions, ut as buildFileUrl, v as streamPartBase, vn as isPlainRecord, vt as MANAGED_QUOTE_VERSION_HEADER, w as secretMcpScope, wn as servableStdioServer, wt as SessionRehydrationError, x as toolResultEvents, xn as resolveReferences, xt as jsonEventParser, y as textDeltaEvents, yn as joinQueue, yt as executionCorrelationHeaders, z as resolveRouterModelLimits, zt as AcpInitializeResult } from "./index-LwzOWUtG.mjs";
2
2
  import { a as partitionImageAttachments, i as PreparedAttachment, n as MAX_TOTAL_INLINE_IMAGE_BYTES, o as preparePromptInputParts, r as PROMPT_SECTION_SEPARATOR, s as prependPromptSection, t as MAX_INLINE_IMAGE_BYTES } from "./prompt-input-CD7okX8T.mjs";
3
- export { ACP_MIN_PROTOCOL_VERSION, ACP_PROTOCOL_VERSION, AcpBridgeConfig, AcpBridgeSpawn, AcpContentBlock, AcpInitializeParams, AcpInitializeResult, AcpNewSessionResult, AcpProcessSpec, AcpPromptResult, AcpProviderAdapterBase, AcpSessionUpdateParams, AcpTurn, AskUserBridge, CODEX_DISABLED_FEATURE_ARGS, CliExecArgs, CliExecutionInput, CliProviderAdapterBase, CliProviderConfig, CliProviderLogger, CliProviderOptions, CliTurnProcess, CliTurnSpawn, DEFAULT_INTERACTION_MCP_SERVER_NAME, EXECUTION_CORRELATION_HEADERS, EXECUTION_ID_HEADER, EXECUTION_TRACE_HEADER, EphemeralContextInput, ExecutionState, HarnessId, InteractionBroker, InteractionHttpBridge, InteractionMcpServer, InteractionMcpServerConfig, InteractionToggleConfig, InteractionToggleKind, InvalidAttachmentError, MANAGED_QUOTE_VERSION_HEADER, MAX_INLINE_IMAGE_BYTES, MAX_TOTAL_INLINE_IMAGE_BYTES, McpInteractionSupport, NATIVE_SESSION_CONTRACTS, PERMISSION_DECISION_TIMEOUT_MS, PROMPT_SECTION_SEPARATOR, PerTurnInteractionInput, PermissionPromptBridge, PlaintextResponse, PreparedAttachment, PreparedCliLaunch, ROUTER_MODEL_CATALOG_TIMEOUT_MS, RepeatedToolFailure, RepeatedToolFailureGuardOptions, RequestPermissionBridge, RequestPlanBridge, ResolveRouterModelLimitsInput, RouterModelLimits, RouterModelLimitsResult, SEALED_NATIVE_HOME_LAYOUT, SECRET_REFERENCE, SECRET_REFERENCE_PREFIX, SHARED_WORKSPACE_DIR_ENV, SecretProfileMcpCredentialProxy, SecretProfileMcpLease, SecretProfileMcpServer, SessionRehydrationError, TerminalPlanSupport, TerminalPlanSupportOptions, ToolCallState, TurnEndReason, TurnObserver, WorkspacePlanApplication, accumulateCliTokenUsage, acpContentText, assertAcpTurnFinished, assertSealedNativeHome, assertSealedNativeSearchPath, brokerInteractionTools, buildFileUrl, codexDeveloperInstructionArgs, createExecutionState, createRepeatedToolFailureGuard, deriveFilePart, deterministicFilePartId, directStdioMcpServers, enabledInteractionKinds, endFailedTurn, executionCorrelationHeaders, failureAfterCleanup, finalTextEvent, findRouterCatalogEntry, forgetSessionScopes, homeXdgEnv, inferMediaType, interactionMcpToolName, interactionToggleEnabled, isLocalMcpConfig, isLoopbackEndpoint, isPlainRecord, isTrustedStoreBinary, joinQueue, jsonEventParser, kimiThinkingArgs, localMcpArgv, localMcpEnv, mapAcpSessionUpdate, nativeEffortArgs, parseCliUsageLine, partitionImageAttachments, plaintextResponseParser, preparePromptInputParts, prependPromptSection, provenStoreBinary, readCliTokenUsage, readEphemeralContext, reasoningEvents, recordCliTokenUsage, recordTurnInterruption, refuseSecretLaunch, rejectNotLaunched, requireRecord, resolveExecutableRealpath, resolveReferences, resolveRouterModelLimits, resolveRouterModelReasoningEfforts, runtimeSecretsOverlay, secretMcpScope, secretSessionTurnQueue, servableMcpServer, servableStdioServer, sessionObservedEvents, sharedSecretMcpRefused, spawnAcpBridge, spawnUnderSecretMcpLease, streamPartBase, textDeltaEvents, textSnapshotEvents, toolResultEvents, toolStartEvents, trackFilePart, trackReasoningBlock, turnEndReason, turnInteractionEnabled, untilSettledOrAborted, wasNeverLaunched, withEphemeralContext, withTurnInteractions };
3
+ export { ACP_MIN_PROTOCOL_VERSION, ACP_PROTOCOL_VERSION, AcpBridgeConfig, AcpBridgeSpawn, AcpContentBlock, AcpInitializeParams, AcpInitializeResult, AcpNewSessionResult, AcpProcessSpec, AcpPromptResult, AcpProviderAdapterBase, AcpSessionUpdateParams, AcpTurn, AskUserBridge, CODEX_DISABLED_FEATURE_ARGS, CliExecArgs, CliExecutionInput, CliProviderAdapterBase, CliProviderConfig, CliProviderLogger, CliProviderOptions, CliTurnProcess, CliTurnSpawn, DEFAULT_INTERACTION_MCP_SERVER_NAME, EXECUTION_CORRELATION_HEADERS, EXECUTION_ID_HEADER, EXECUTION_TRACE_HEADER, EphemeralContextInput, ExecutionState, HarnessId, InteractionBroker, InteractionHttpBridge, InteractionMcpServer, InteractionMcpServerConfig, InteractionToggleConfig, InteractionToggleKind, InvalidAttachmentError, MANAGED_QUOTE_VERSION_HEADER, MAX_INLINE_IMAGE_BYTES, MAX_TOTAL_INLINE_IMAGE_BYTES, McpInteractionSupport, NATIVE_SESSION_CONTRACTS, PERMISSION_DECISION_TIMEOUT_MS, PROMPT_SECTION_SEPARATOR, PerTurnInteractionInput, PermissionPromptBridge, PlaintextResponse, PreparedAttachment, PreparedCliLaunch, ROUTER_MODEL_CATALOG_FAILURE_STOP_MS, ROUTER_MODEL_CATALOG_LIFETIME_MS, ROUTER_MODEL_CATALOG_TIMEOUT_MS, RepeatedToolFailure, RepeatedToolFailureGuardOptions, RequestPermissionBridge, RequestPlanBridge, ResolveRouterModelLimitsInput, RouterModelLimits, RouterModelLimitsResult, SEALED_NATIVE_HOME_LAYOUT, SECRET_REFERENCE, SECRET_REFERENCE_PREFIX, SHARED_WORKSPACE_DIR_ENV, SecretProfileMcpCredentialProxy, SecretProfileMcpLease, SecretProfileMcpServer, SessionRehydrationError, TerminalPlanSupport, TerminalPlanSupportOptions, ToolCallState, TurnEndReason, TurnObserver, WorkspacePlanApplication, accumulateCliTokenUsage, acpContentText, assertAcpTurnFinished, assertSealedNativeHome, assertSealedNativeSearchPath, brokerInteractionTools, buildFileUrl, codexDeveloperInstructionArgs, createExecutionState, createRepeatedToolFailureGuard, deriveFilePart, deterministicFilePartId, directStdioMcpServers, enabledInteractionKinds, endFailedTurn, executionCorrelationHeaders, failureAfterCleanup, finalTextEvent, findRouterCatalogEntry, forgetSessionScopes, homeXdgEnv, inferMediaType, interactionMcpToolName, interactionToggleEnabled, isLocalMcpConfig, isLoopbackEndpoint, isPlainRecord, isTrustedStoreBinary, joinQueue, jsonEventParser, kimiThinkingArgs, localMcpArgv, localMcpEnv, mapAcpSessionUpdate, nativeEffortArgs, parseCliUsageLine, partitionImageAttachments, plaintextResponseParser, preparePromptInputParts, prependPromptSection, provenStoreBinary, readCliTokenUsage, readEphemeralContext, reasoningEvents, recordCliTokenUsage, recordTurnInterruption, refuseSecretLaunch, rejectNotLaunched, requireRecord, resolveExecutableRealpath, resolveReferences, resolveRouterModelLimits, resolveRouterModelReasoningEfforts, runtimeSecretsOverlay, secretMcpScope, secretSessionTurnQueue, servableMcpServer, servableStdioServer, sessionObservedEvents, sharedSecretMcpRefused, spawnAcpBridge, spawnUnderSecretMcpLease, streamPartBase, textDeltaEvents, textSnapshotEvents, toolResultEvents, toolStartEvents, trackFilePart, trackReasoningBlock, turnEndReason, turnInteractionEnabled, untilSettledOrAborted, wasNeverLaunched, withEphemeralContext, withTurnInteractions };
package/dist/index.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import { $ as secretSessionTurnQueue, A as TurnObserver, At as EXECUTION_ID_HEADER, B as readEphemeralContext, Bt as textDeltaEvents, C as plaintextResponseParser, Ct as InvalidAttachmentError, D as readCliTokenUsage, Dt as wasNeverLaunched, E as parseCliUsageLine, Et as rejectNotLaunched, F as isLocalMcpConfig, Ft as mapAcpSessionUpdate, G as SHARED_WORKSPACE_DIR_ENV, Gt as ACP_MIN_PROTOCOL_VERSION, H as turnInteractionEnabled, Ht as toolResultEvents, I as localMcpArgv, It as finalTextEvent, J as isLoopbackEndpoint, Jt as assertAcpTurnFinished, K as assertSealedNativeSearchPath, Kt as ACP_PROTOCOL_VERSION, L as localMcpEnv, Lt as reasoningEvents, M as endFailedTurn, Mt as MANAGED_QUOTE_VERSION_HEADER, N as recordTurnInterruption, Nt as executionCorrelationHeaders, O as recordCliTokenUsage, Ot as runtimeSecretsOverlay, P as createExecutionState, Pt as homeXdgEnv, Q as resolveReferences, R as enabledInteractionKinds, Rt as sessionObservedEvents, S as jsonEventParser, St as trackFilePart, T as accumulateCliTokenUsage, Tt as failureAfterCleanup, U as withEphemeralContext, Ut as toolStartEvents, V as turnEndReason, Vt as textSnapshotEvents, W as withTurnInteractions, Wt as trackReasoningBlock, X as joinQueue, Y as isPlainRecord, Yt as spawnAcpBridge, Z as requireRecord, _ as TerminalPlanSupport, _t as prependPromptSection, a as SECRET_REFERENCE, at as NATIVE_SESSION_CONTRACTS, b as brokerInteractionTools, bt as deterministicFilePartId, c as forgetSessionScopes, ct as isTrustedStoreBinary, d as findRouterCatalogEntry, dt as resolveExecutableRealpath, et as servableMcpServer, f as resolveRouterModelLimits, ft as MAX_INLINE_IMAGE_BYTES, g as McpInteractionSupport, gt as preparePromptInputParts, h as nativeEffortArgs, ht as partitionImageAttachments, i as PERMISSION_DECISION_TIMEOUT_MS, it as untilSettledOrAborted, j as createRepeatedToolFailureGuard, jt as EXECUTION_TRACE_HEADER, k as CliProviderAdapterBase, kt as EXECUTION_CORRELATION_HEADERS, l as secretMcpScope, lt as provenStoreBinary, m as kimiThinkingArgs, mt as PROMPT_SECTION_SEPARATOR, n as InteractionBroker, nt as sharedSecretMcpRefused, o as SECRET_REFERENCE_PREFIX, ot as SEALED_NATIVE_HOME_LAYOUT, p as resolveRouterModelReasoningEfforts, pt as MAX_TOTAL_INLINE_IMAGE_BYTES, q as directStdioMcpServers, qt as acpContentText, r as InteractionHttpBridge, rt as spawnUnderSecretMcpLease, s as codexDeveloperInstructionArgs, st as assertSealedNativeHome, t as CODEX_DISABLED_FEATURE_ARGS, tt as servableStdioServer, u as ROUTER_MODEL_CATALOG_TIMEOUT_MS, ut as refuseSecretLaunch, v as DEFAULT_INTERACTION_MCP_SERVER_NAME, vt as buildFileUrl, w as AcpProviderAdapterBase, wt as SessionRehydrationError, x as interactionMcpToolName, xt as inferMediaType, y as InteractionMcpServer, yt as deriveFilePart, z as interactionToggleEnabled, zt as streamPartBase } from "./src-B_4qa95r.mjs";
2
- export { ACP_MIN_PROTOCOL_VERSION, ACP_PROTOCOL_VERSION, AcpProviderAdapterBase, CODEX_DISABLED_FEATURE_ARGS, CliProviderAdapterBase, DEFAULT_INTERACTION_MCP_SERVER_NAME, EXECUTION_CORRELATION_HEADERS, EXECUTION_ID_HEADER, EXECUTION_TRACE_HEADER, InteractionBroker, InteractionHttpBridge, InteractionMcpServer, InvalidAttachmentError, MANAGED_QUOTE_VERSION_HEADER, MAX_INLINE_IMAGE_BYTES, MAX_TOTAL_INLINE_IMAGE_BYTES, McpInteractionSupport, NATIVE_SESSION_CONTRACTS, PERMISSION_DECISION_TIMEOUT_MS, PROMPT_SECTION_SEPARATOR, ROUTER_MODEL_CATALOG_TIMEOUT_MS, SEALED_NATIVE_HOME_LAYOUT, SECRET_REFERENCE, SECRET_REFERENCE_PREFIX, SHARED_WORKSPACE_DIR_ENV, SessionRehydrationError, TerminalPlanSupport, TurnObserver, accumulateCliTokenUsage, acpContentText, assertAcpTurnFinished, assertSealedNativeHome, assertSealedNativeSearchPath, brokerInteractionTools, buildFileUrl, codexDeveloperInstructionArgs, createExecutionState, createRepeatedToolFailureGuard, deriveFilePart, deterministicFilePartId, directStdioMcpServers, enabledInteractionKinds, endFailedTurn, executionCorrelationHeaders, failureAfterCleanup, finalTextEvent, findRouterCatalogEntry, forgetSessionScopes, homeXdgEnv, inferMediaType, interactionMcpToolName, interactionToggleEnabled, isLocalMcpConfig, isLoopbackEndpoint, isPlainRecord, isTrustedStoreBinary, joinQueue, jsonEventParser, kimiThinkingArgs, localMcpArgv, localMcpEnv, mapAcpSessionUpdate, nativeEffortArgs, parseCliUsageLine, partitionImageAttachments, plaintextResponseParser, preparePromptInputParts, prependPromptSection, provenStoreBinary, readCliTokenUsage, readEphemeralContext, reasoningEvents, recordCliTokenUsage, recordTurnInterruption, refuseSecretLaunch, rejectNotLaunched, requireRecord, resolveExecutableRealpath, resolveReferences, resolveRouterModelLimits, resolveRouterModelReasoningEfforts, runtimeSecretsOverlay, secretMcpScope, secretSessionTurnQueue, servableMcpServer, servableStdioServer, sessionObservedEvents, sharedSecretMcpRefused, spawnAcpBridge, spawnUnderSecretMcpLease, streamPartBase, textDeltaEvents, textSnapshotEvents, toolResultEvents, toolStartEvents, trackFilePart, trackReasoningBlock, turnEndReason, turnInteractionEnabled, untilSettledOrAborted, wasNeverLaunched, withEphemeralContext, withTurnInteractions };
1
+ import { $ as requireRecord, A as recordCliTokenUsage, At as runtimeSecretsOverlay, B as enabledInteractionKinds, Bt as sessionObservedEvents, C as interactionMcpToolName, Ct as inferMediaType, D as accumulateCliTokenUsage, Dt as failureAfterCleanup, E as AcpProviderAdapterBase, Et as SessionRehydrationError, F as recordTurnInterruption, Ft as executionCorrelationHeaders, G as withEphemeralContext, Gt as toolStartEvents, H as readEphemeralContext, Ht as textDeltaEvents, I as createExecutionState, It as homeXdgEnv, J as assertSealedNativeSearchPath, Jt as ACP_PROTOCOL_VERSION, K as withTurnInteractions, Kt as trackReasoningBlock, L as isLocalMcpConfig, Lt as mapAcpSessionUpdate, M as TurnObserver, Mt as EXECUTION_ID_HEADER, N as createRepeatedToolFailureGuard, Nt as EXECUTION_TRACE_HEADER, O as parseCliUsageLine, Ot as rejectNotLaunched, P as endFailedTurn, Pt as MANAGED_QUOTE_VERSION_HEADER, Q as joinQueue, R as localMcpArgv, Rt as finalTextEvent, S as brokerInteractionTools, St as deterministicFilePartId, T as plaintextResponseParser, Tt as InvalidAttachmentError, U as turnEndReason, Ut as textSnapshotEvents, V as interactionToggleEnabled, Vt as streamPartBase, W as turnInteractionEnabled, Wt as toolResultEvents, X as isLoopbackEndpoint, Xt as assertAcpTurnFinished, Y as directStdioMcpServers, Yt as acpContentText, Z as isPlainRecord, Zt as spawnAcpBridge, _ as nativeEffortArgs, _t as partitionImageAttachments, a as SECRET_REFERENCE, at as spawnUnderSecretMcpLease, b as DEFAULT_INTERACTION_MCP_SERVER_NAME, bt as buildFileUrl, c as forgetSessionScopes, ct as SEALED_NATIVE_HOME_LAYOUT, d as ROUTER_MODEL_CATALOG_LIFETIME_MS, dt as provenStoreBinary, et as resolveReferences, f as ROUTER_MODEL_CATALOG_TIMEOUT_MS, ft as refuseSecretLaunch, g as kimiThinkingArgs, gt as PROMPT_SECTION_SEPARATOR, h as resolveRouterModelReasoningEfforts, ht as MAX_TOTAL_INLINE_IMAGE_BYTES, i as PERMISSION_DECISION_TIMEOUT_MS, it as sharedSecretMcpRefused, j as CliProviderAdapterBase, jt as EXECUTION_CORRELATION_HEADERS, k as readCliTokenUsage, kt as wasNeverLaunched, l as secretMcpScope, lt as assertSealedNativeHome, m as resolveRouterModelLimits, mt as MAX_INLINE_IMAGE_BYTES, n as InteractionBroker, nt as servableMcpServer, o as SECRET_REFERENCE_PREFIX, ot as untilSettledOrAborted, p as findRouterCatalogEntry, pt as resolveExecutableRealpath, q as SHARED_WORKSPACE_DIR_ENV, qt as ACP_MIN_PROTOCOL_VERSION, r as InteractionHttpBridge, rt as servableStdioServer, s as codexDeveloperInstructionArgs, st as NATIVE_SESSION_CONTRACTS, t as CODEX_DISABLED_FEATURE_ARGS, tt as secretSessionTurnQueue, u as ROUTER_MODEL_CATALOG_FAILURE_STOP_MS, ut as isTrustedStoreBinary, v as McpInteractionSupport, vt as preparePromptInputParts, w as jsonEventParser, wt as trackFilePart, x as InteractionMcpServer, xt as deriveFilePart, y as TerminalPlanSupport, yt as prependPromptSection, z as localMcpEnv, zt as reasoningEvents } from "./src-OUp4Ymnt.mjs";
2
+ export { ACP_MIN_PROTOCOL_VERSION, ACP_PROTOCOL_VERSION, AcpProviderAdapterBase, CODEX_DISABLED_FEATURE_ARGS, CliProviderAdapterBase, DEFAULT_INTERACTION_MCP_SERVER_NAME, EXECUTION_CORRELATION_HEADERS, EXECUTION_ID_HEADER, EXECUTION_TRACE_HEADER, InteractionBroker, InteractionHttpBridge, InteractionMcpServer, InvalidAttachmentError, MANAGED_QUOTE_VERSION_HEADER, MAX_INLINE_IMAGE_BYTES, MAX_TOTAL_INLINE_IMAGE_BYTES, McpInteractionSupport, NATIVE_SESSION_CONTRACTS, PERMISSION_DECISION_TIMEOUT_MS, PROMPT_SECTION_SEPARATOR, ROUTER_MODEL_CATALOG_FAILURE_STOP_MS, ROUTER_MODEL_CATALOG_LIFETIME_MS, ROUTER_MODEL_CATALOG_TIMEOUT_MS, SEALED_NATIVE_HOME_LAYOUT, SECRET_REFERENCE, SECRET_REFERENCE_PREFIX, SHARED_WORKSPACE_DIR_ENV, SessionRehydrationError, TerminalPlanSupport, TurnObserver, accumulateCliTokenUsage, acpContentText, assertAcpTurnFinished, assertSealedNativeHome, assertSealedNativeSearchPath, brokerInteractionTools, buildFileUrl, codexDeveloperInstructionArgs, createExecutionState, createRepeatedToolFailureGuard, deriveFilePart, deterministicFilePartId, directStdioMcpServers, enabledInteractionKinds, endFailedTurn, executionCorrelationHeaders, failureAfterCleanup, finalTextEvent, findRouterCatalogEntry, forgetSessionScopes, homeXdgEnv, inferMediaType, interactionMcpToolName, interactionToggleEnabled, isLocalMcpConfig, isLoopbackEndpoint, isPlainRecord, isTrustedStoreBinary, joinQueue, jsonEventParser, kimiThinkingArgs, localMcpArgv, localMcpEnv, mapAcpSessionUpdate, nativeEffortArgs, parseCliUsageLine, partitionImageAttachments, plaintextResponseParser, preparePromptInputParts, prependPromptSection, provenStoreBinary, readCliTokenUsage, readEphemeralContext, reasoningEvents, recordCliTokenUsage, recordTurnInterruption, refuseSecretLaunch, rejectNotLaunched, requireRecord, resolveExecutableRealpath, resolveReferences, resolveRouterModelLimits, resolveRouterModelReasoningEfforts, runtimeSecretsOverlay, secretMcpScope, secretSessionTurnQueue, servableMcpServer, servableStdioServer, sessionObservedEvents, sharedSecretMcpRefused, spawnAcpBridge, spawnUnderSecretMcpLease, streamPartBase, textDeltaEvents, textSnapshotEvents, toolResultEvents, toolStartEvents, trackFilePart, trackReasoningBlock, turnEndReason, turnInteractionEnabled, untilSettledOrAborted, wasNeverLaunched, withEphemeralContext, withTurnInteractions };
@@ -4194,6 +4194,19 @@ var AcpProviderAdapterBase = class extends CliProviderAdapterBase {
4194
4194
  turnLogContext(_turn) {
4195
4195
  return {};
4196
4196
  }
4197
+ /**
4198
+ * An agent with no `session/load` holds a conversation only in its running
4199
+ * process, and a new process opens an empty native session. Its stored id
4200
+ * is therefore resumable only while this adapter holds that process. Once
4201
+ * the process is gone (the sidecar restarted, the idle process was reaped,
4202
+ * the turn needs another process configuration) the turn replays the
4203
+ * durable transcript into the new session.
4204
+ */
4205
+ async resumableProviderSessionId(session) {
4206
+ if (this.loadsNativeSessions) return super.resumableProviderSessionId(session);
4207
+ const held = this.acpSessions.get(session.id);
4208
+ return held && !held.bridge.closed ? held.acpSessionId : void 0;
4209
+ }
4197
4210
  async execute(input, services, onEvent) {
4198
4211
  this.ensureInitialized();
4199
4212
  const turn = this.resolveTurn(input);
@@ -4205,6 +4218,7 @@ var AcpProviderAdapterBase = class extends CliProviderAdapterBase {
4205
4218
  ...input,
4206
4219
  sessionId: input.interactionBinding?.sessionId
4207
4220
  };
4221
+ if (turnInput.sessionId) this.heldAcpSession(turnInput.sessionId, turn.processKey)?.idleTimer?.refresh();
4208
4222
  const opened = await this.openTurnSession(turnInput, recorder, onEvent);
4209
4223
  if (opened.cached) return opened.cached;
4210
4224
  const { sessionId, providerSessionId, providerMessageIds } = opened;
@@ -4220,7 +4234,7 @@ var AcpProviderAdapterBase = class extends CliProviderAdapterBase {
4220
4234
  try {
4221
4235
  entry = await this.acquireAcpSession({
4222
4236
  sessionId,
4223
- ...this.loadsNativeSessions && providerSessionId ? { providerSessionId } : {},
4237
+ ...providerSessionId ? { providerSessionId } : {},
4224
4238
  turn,
4225
4239
  workspaceRoot,
4226
4240
  onEvent
@@ -4321,15 +4335,12 @@ var AcpProviderAdapterBase = class extends CliProviderAdapterBase {
4321
4335
  }
4322
4336
  async acquireAcpSession(opts) {
4323
4337
  const { sessionId, turn, workspaceRoot, onEvent } = opts;
4324
- const existing = this.acpSessions.get(sessionId);
4325
- if (existing && !existing.bridge.closed) {
4326
- if (existing.processKey === turn.processKey) {
4327
- this.cancelIdleReap(existing);
4328
- return existing;
4329
- }
4330
- this.logger.warn(`${this.provider}: cached session was started for another process configuration — respawning`, { sessionId });
4331
- this.evictAcpSession(sessionId, "process-change");
4338
+ const existing = this.heldAcpSession(sessionId, turn.processKey);
4339
+ if (existing) {
4340
+ this.cancelIdleReap(existing);
4341
+ return existing;
4332
4342
  }
4343
+ if (opts.providerSessionId && !this.loadsNativeSessions) throw new Error(`${this.provider}: the agent process holding this conversation ended while the turn was being prepared`);
4333
4344
  const storedSessionId = opts.providerSessionId ? this.resumeSessionId() : void 0;
4334
4345
  const spec = await this.processSpec(turn, {
4335
4346
  sessionId,
@@ -4486,6 +4497,17 @@ var AcpProviderAdapterBase = class extends CliProviderAdapterBase {
4486
4497
  releaseLock();
4487
4498
  }
4488
4499
  }
4500
+ /**
4501
+ * The session's running process, when it was started for the process
4502
+ * configuration the turn needs. One started for another is ended.
4503
+ */
4504
+ heldAcpSession(sessionId, processKey) {
4505
+ const existing = this.acpSessions.get(sessionId);
4506
+ if (!existing || existing.bridge.closed) return void 0;
4507
+ if (existing.processKey === processKey) return existing;
4508
+ this.logger.warn(`${this.provider}: cached session was started for another process configuration — respawning`, { sessionId });
4509
+ this.evictAcpSession(sessionId, "process-change");
4510
+ }
4489
4511
  scheduleIdleReap(sessionId, bridgeIdleMs) {
4490
4512
  const entry = this.acpSessions.get(sessionId);
4491
4513
  if (!entry) return;
@@ -4854,8 +4876,18 @@ function kimiThinkingArgs(level, modelId) {
4854
4876
  }
4855
4877
  //#endregion
4856
4878
  //#region src/router-model-limits.ts
4857
- /** One catalog request at backend start; a slow gateway must not hold the turn. */
4879
+ /** How long one catalog request may take; a slow gateway must not hold the turn. */
4858
4880
  const ROUTER_MODEL_CATALOG_TIMEOUT_MS = 5e3;
4881
+ /** The entry fields this module reads. A kept catalog holds these and nothing else of the list. */
4882
+ const CATALOG_FIELDS = [
4883
+ "id",
4884
+ "_provider",
4885
+ "context_length",
4886
+ "max_completion_tokens",
4887
+ "max_completion_tokens_source",
4888
+ "max_completion_tokens_verified",
4889
+ "reasoning_effort_values"
4890
+ ];
4859
4891
  function isPositiveInteger(value) {
4860
4892
  return typeof value === "number" && Number.isSafeInteger(value) && value > 0;
4861
4893
  }
@@ -4870,102 +4902,132 @@ function findRouterCatalogEntry(entries, model) {
4870
4902
  if (exact) return exact;
4871
4903
  return candidates.find((entry) => typeof entry.id === "string" && typeof entry._provider === "string" && `${entry._provider}/${entry.id}` === model);
4872
4904
  }
4873
- /** An unreachable or failing (5xx) catalog stops reads at that endpoint for 60 s. */
4874
- const catalogFailures = /* @__PURE__ */ new Map();
4875
- const CATALOG_FRESHNESS_MS = 6e4;
4876
- const MAX_CACHED_CATALOGS = 32;
4905
+ /**
4906
+ * How long a process answers from the list it read. It is also the floor: no response header
4907
+ * shortens it and none lengthens it, because `cache-control` and `expires` are not read. The
4908
+ * production Router marks this list, about 63 KB gzipped, `no-store`, and a helper that obeys
4909
+ * the mark asks for the whole list on every call from every box; on 2026-11-24 a benchmark
4910
+ * starting many boxes made the Router's replicas miss health checks. One lifetime covers a box
4911
+ * start and the turns after it with one request, and it bounds how long a running box keeps a
4912
+ * limit the Router has since corrected. After it the list is asked for again, with the
4913
+ * validator the gateway gave, so an unchanged list costs a 304 and no body.
4914
+ */
4915
+ const ROUTER_MODEL_CATALOG_LIFETIME_MS = 60 * 6e4;
4916
+ /** A failed read is not repeated for this long, so no turn waits on a failing catalog twice. */
4917
+ const ROUTER_MODEL_CATALOG_FAILURE_STOP_MS = 6e4;
4918
+ /** A box reads with one or two credentials; the bound stops a caller that varies them from growing the map. */
4919
+ const MAX_KEPT_CATALOGS = 32;
4877
4920
  const catalogs = /* @__PURE__ */ new Map();
4921
+ /** An unreachable or failing (5xx) endpoint answers no credential, so its stop covers them all. */
4922
+ const endpointStops = /* @__PURE__ */ new Map();
4878
4923
  function digest(value) {
4879
4924
  return createHash("sha256").update(value).digest("hex");
4880
4925
  }
4881
- function catalogFailed(endpoint, reason) {
4882
- catalogFailures.set(endpoint, {
4883
- at: Date.now(),
4884
- reason
4926
+ function catalogUrl(baseUrl) {
4927
+ try {
4928
+ const url = new URL(baseUrl);
4929
+ url.pathname = `${url.pathname.replace(/\/+$/, "")}/models`;
4930
+ url.hash = "";
4931
+ return url.href;
4932
+ } catch {
4933
+ return `${baseUrl.replace(/\/+$/, "")}/models`;
4934
+ }
4935
+ }
4936
+ function keptEntries(data) {
4937
+ return data.filter((entry) => typeof entry === "object" && entry !== null).map((entry) => {
4938
+ const kept = {};
4939
+ for (const field of CATALOG_FIELDS) kept[field] = entry[field];
4940
+ return kept;
4885
4941
  });
4886
- return reason;
4887
- }
4888
- function catalogExpiry(headers) {
4889
- const control = headers.get("cache-control") ?? "";
4890
- if (/(?:^|,)\s*(?:no-cache|no-store)\s*(?:=|,|$)/i.test(control)) return 0;
4891
- const maxAge = /(?:^|,)\s*max-age\s*=\s*"?(\d+)"?\s*(?:,|$)/i.exec(control);
4892
- const date = Date.parse(headers.get("date") ?? "");
4893
- const expires = Date.parse(headers.get("expires") ?? "");
4894
- const now = Date.now();
4895
- const ageMs = Math.max(0, Number(headers.get("age")) || 0) * 1e3;
4896
- const lifetime = maxAge ? Number(maxAge[1]) * 1e3 : Number.isFinite(expires) ? expires - (Number.isFinite(date) ? date : now) : CATALOG_FRESHNESS_MS;
4897
- const currentAge = Math.max(ageMs, Number.isFinite(date) ? now - date : 0);
4898
- return now + Math.min(CATALOG_FRESHNESS_MS, lifetime) - currentAge;
4899
- }
4900
- async function fetchCatalog(input, url) {
4901
- const endpoint = digest(input.baseUrl);
4902
- const failed = catalogFailures.get(endpoint);
4903
- if (failed) {
4904
- if (Date.now() - failed.at < 6e4) return failed.reason;
4905
- catalogFailures.delete(endpoint);
4906
- }
4907
- const fetchImpl = input.fetchImpl ?? fetch;
4942
+ }
4943
+ /** One request, never retried: the list, or why there is none and whether the endpoint is at fault. */
4944
+ async function requestCatalog(url, apiKey, held) {
4908
4945
  try {
4909
- const apiKey = input.apiKey?.trim();
4910
- const response = await fetchImpl(url, {
4946
+ const response = await fetch(url, {
4911
4947
  headers: {
4912
4948
  accept: "application/json",
4913
- ...apiKey ? { authorization: `Bearer ${apiKey}` } : {}
4949
+ ...apiKey ? { authorization: `Bearer ${apiKey}` } : {},
4950
+ ...held?.etag ? { "if-none-match": held.etag } : {}
4914
4951
  },
4915
- signal: AbortSignal.timeout(input.timeoutMs ?? 5e3)
4952
+ signal: AbortSignal.timeout(ROUTER_MODEL_CATALOG_TIMEOUT_MS)
4916
4953
  });
4917
- const reason = `model catalog returned HTTP ${response.status}`;
4918
- if (!response.ok) return response.status < 500 ? reason : catalogFailed(endpoint, reason);
4954
+ if (response.status === 304 && held?.etag) return held;
4955
+ if (!response.ok) return {
4956
+ failed: `model catalog returned HTTP ${response.status}`,
4957
+ endpoint: response.status >= 500
4958
+ };
4919
4959
  const body = await response.json();
4920
- if (typeof body !== "object" || body === null || !("data" in body) || !Array.isArray(body.data)) return "model catalog has no data array";
4960
+ if (typeof body !== "object" || body === null || !("data" in body) || !Array.isArray(body.data)) return {
4961
+ failed: "model catalog has no data array",
4962
+ endpoint: false
4963
+ };
4964
+ const etag = response.headers.get("etag");
4921
4965
  return {
4922
- entries: body.data,
4923
- expiresAt: input.cacheRevision === void 0 ? 0 : catalogExpiry(response.headers)
4966
+ entries: keptEntries(body.data),
4967
+ ...etag ? { etag } : {}
4924
4968
  };
4925
4969
  } catch (error) {
4926
- return catalogFailed(endpoint, `model catalog request failed: ${error instanceof Error ? error.message : String(error)}`);
4970
+ return {
4971
+ failed: `model catalog request failed: ${error instanceof Error ? error.message : String(error)}`,
4972
+ endpoint: true
4973
+ };
4927
4974
  }
4928
4975
  }
4929
- async function readCatalog(input) {
4930
- const legacyUrl = `${input.baseUrl.replace(/\/+$/, "")}/models`;
4931
- if (input.cacheRevision === void 0) return fetchCatalog(input, legacyUrl);
4932
- let url;
4933
- try {
4934
- url = new URL(input.baseUrl);
4935
- } catch {
4936
- return fetchCatalog(input, legacyUrl);
4976
+ async function refreshCatalog(catalog, url, apiKey) {
4977
+ const answer = await requestCatalog(url, apiKey, catalog.list);
4978
+ const now = Date.now();
4979
+ if ("failed" in answer) {
4980
+ catalog.until = now + ROUTER_MODEL_CATALOG_FAILURE_STOP_MS;
4981
+ if (answer.endpoint) {
4982
+ for (const [stopped, { until }] of endpointStops) if (until <= now) endpointStops.delete(stopped);
4983
+ endpointStops.set(url, {
4984
+ until: catalog.until,
4985
+ reason: answer.failed
4986
+ });
4987
+ }
4988
+ return catalog.list?.entries ?? answer.failed;
4937
4989
  }
4938
- url.pathname = `${url.pathname.replace(/\/+$/, "")}/models`;
4939
- url.hash = "";
4990
+ endpointStops.delete(url);
4991
+ catalog.list = answer;
4992
+ catalog.until = now + ROUTER_MODEL_CATALOG_LIFETIME_MS;
4993
+ return answer.entries;
4994
+ }
4995
+ /**
4996
+ * The catalog for this endpoint, credential and revision. A process makes one request for it
4997
+ * per lifetime: callers that arrive while it is in flight wait on it, and later ones are
4998
+ * answered from the list it returned. A failure is remembered for its stop: a 4xx for the
4999
+ * credential it answered, an unreachable or failing endpoint for every credential.
5000
+ */
5001
+ function readCatalog(input) {
5002
+ const url = catalogUrl(input.baseUrl);
5003
+ const apiKey = input.apiKey?.trim() ?? "";
4940
5004
  const key = digest(JSON.stringify([
4941
- url.href,
4942
- digest(input.apiKey?.trim() ?? ""),
4943
- input.cacheRevision
5005
+ url,
5006
+ apiKey,
5007
+ input.cacheRevision ?? ""
4944
5008
  ]));
4945
- const existing = catalogs.get(key);
4946
- if (existing && existing.expiresAt > Date.now()) return existing.read;
5009
+ const now = Date.now();
5010
+ const kept = catalogs.get(key);
5011
+ if (kept && kept.until > now) return kept.read;
5012
+ const stopped = endpointStops.get(url);
5013
+ if (stopped && stopped.until > now) return Promise.resolve(kept?.list?.entries ?? stopped.reason);
5014
+ for (const [other, { until, list }] of catalogs) if (until <= now && !list) catalogs.delete(other);
4947
5015
  catalogs.delete(key);
4948
- if (catalogs.size >= MAX_CACHED_CATALOGS) {
5016
+ if (catalogs.size >= MAX_KEPT_CATALOGS) {
4949
5017
  const oldest = catalogs.keys().next();
4950
5018
  if (!oldest.done) catalogs.delete(oldest.value);
4951
5019
  }
4952
- const entry = {
4953
- read: fetchCatalog(input, url.href),
4954
- expiresAt: Number.POSITIVE_INFINITY
5020
+ const next = {
5021
+ until: Number.POSITIVE_INFINITY,
5022
+ list: kept?.list
4955
5023
  };
4956
- catalogs.set(key, entry);
4957
- try {
4958
- const result = await entry.read;
4959
- entry.expiresAt = typeof result === "string" ? 0 : result.expiresAt;
4960
- return result;
4961
- } finally {
4962
- if (catalogs.get(key) === entry && !(entry.expiresAt > Date.now() && Number.isFinite(entry.expiresAt))) catalogs.delete(key);
4963
- }
5024
+ const read = refreshCatalog(next, url, apiKey);
5025
+ catalogs.set(key, Object.assign(next, { read }));
5026
+ return read;
4964
5027
  }
4965
5028
  async function readRouterCatalogEntry(input) {
4966
- const catalog = await readCatalog(input);
4967
- if (typeof catalog === "string") return catalog;
4968
- const { entries } = catalog;
5029
+ const entries = await readCatalog(input);
5030
+ if (typeof entries === "string") return entries;
4969
5031
  return findRouterCatalogEntry(entries, input.model) ?? (input.catalogAlias ? findRouterCatalogEntry(entries, input.catalogAlias) : void 0) ?? `model catalog does not list ${input.model}`;
4970
5032
  }
4971
5033
  /** The model's listed `reasoning_effort_values`, trimmed and lowercased, or why the catalog was unreadable. */
@@ -5033,6 +5095,6 @@ async function forgetSessionScopes(target) {
5033
5095
  }
5034
5096
  }
5035
5097
  //#endregion
5036
- export { secretSessionTurnQueue as $, TurnObserver as A, EXECUTION_ID_HEADER as At, readEphemeralContext as B, textDeltaEvents as Bt, plaintextResponseParser as C, InvalidAttachmentError as Ct, readCliTokenUsage as D, wasNeverLaunched as Dt, parseCliUsageLine as E, rejectNotLaunched as Et, isLocalMcpConfig as F, mapAcpSessionUpdate as Ft, SHARED_WORKSPACE_DIR_ENV as G, ACP_MIN_PROTOCOL_VERSION as Gt, turnInteractionEnabled as H, toolResultEvents as Ht, localMcpArgv as I, finalTextEvent as It, isLoopbackEndpoint as J, assertAcpTurnFinished as Jt, assertSealedNativeSearchPath as K, ACP_PROTOCOL_VERSION as Kt, localMcpEnv as L, reasoningEvents as Lt, endFailedTurn as M, MANAGED_QUOTE_VERSION_HEADER as Mt, recordTurnInterruption as N, executionCorrelationHeaders as Nt, recordCliTokenUsage as O, runtimeSecretsOverlay as Ot, createExecutionState as P, homeXdgEnv as Pt, resolveReferences as Q, enabledInteractionKinds as R, sessionObservedEvents as Rt, jsonEventParser as S, trackFilePart as St, accumulateCliTokenUsage as T, failureAfterCleanup as Tt, withEphemeralContext as U, toolStartEvents as Ut, turnEndReason as V, textSnapshotEvents as Vt, withTurnInteractions as W, trackReasoningBlock as Wt, joinQueue as X, isPlainRecord as Y, spawnAcpBridge as Yt, requireRecord as Z, TerminalPlanSupport as _, prependPromptSection as _t, SECRET_REFERENCE$1 as a, NATIVE_SESSION_CONTRACTS$1 as at, brokerInteractionTools$1 as b, deterministicFilePartId as bt, forgetSessionScopes as c, isTrustedStoreBinary as ct, findRouterCatalogEntry as d, resolveExecutableRealpath as dt, servableMcpServer as et, resolveRouterModelLimits as f, MAX_INLINE_IMAGE_BYTES as ft, McpInteractionSupport as g, preparePromptInputParts as gt, nativeEffortArgs as h, partitionImageAttachments as ht, PERMISSION_DECISION_TIMEOUT_MS as i, untilSettledOrAborted as it, createRepeatedToolFailureGuard as j, EXECUTION_TRACE_HEADER as jt, CliProviderAdapterBase as k, EXECUTION_CORRELATION_HEADERS as kt, secretMcpScope as l, provenStoreBinary as lt, kimiThinkingArgs as m, PROMPT_SECTION_SEPARATOR as mt, InteractionBroker$1 as n, sharedSecretMcpRefused as nt, SECRET_REFERENCE_PREFIX$1 as o, SEALED_NATIVE_HOME_LAYOUT as ot, resolveRouterModelReasoningEfforts as p, MAX_TOTAL_INLINE_IMAGE_BYTES as pt, directStdioMcpServers as q, acpContentText as qt, InteractionHttpBridge as r, spawnUnderSecretMcpLease as rt, codexDeveloperInstructionArgs as s, assertSealedNativeHome as st, CODEX_DISABLED_FEATURE_ARGS as t, servableStdioServer as tt, ROUTER_MODEL_CATALOG_TIMEOUT_MS as u, refuseSecretLaunch as ut, DEFAULT_INTERACTION_MCP_SERVER_NAME as v, buildFileUrl as vt, AcpProviderAdapterBase as w, SessionRehydrationError as wt, interactionMcpToolName as x, inferMediaType as xt, InteractionMcpServer$1 as y, deriveFilePart as yt, interactionToggleEnabled as z, streamPartBase as zt };
5098
+ export { requireRecord as $, recordCliTokenUsage as A, runtimeSecretsOverlay as At, enabledInteractionKinds as B, sessionObservedEvents as Bt, interactionMcpToolName as C, inferMediaType as Ct, accumulateCliTokenUsage as D, failureAfterCleanup as Dt, AcpProviderAdapterBase as E, SessionRehydrationError as Et, recordTurnInterruption as F, executionCorrelationHeaders as Ft, withEphemeralContext as G, toolStartEvents as Gt, readEphemeralContext as H, textDeltaEvents as Ht, createExecutionState as I, homeXdgEnv as It, assertSealedNativeSearchPath as J, ACP_PROTOCOL_VERSION as Jt, withTurnInteractions as K, trackReasoningBlock as Kt, isLocalMcpConfig as L, mapAcpSessionUpdate as Lt, TurnObserver as M, EXECUTION_ID_HEADER as Mt, createRepeatedToolFailureGuard as N, EXECUTION_TRACE_HEADER as Nt, parseCliUsageLine as O, rejectNotLaunched as Ot, endFailedTurn as P, MANAGED_QUOTE_VERSION_HEADER as Pt, joinQueue as Q, localMcpArgv as R, finalTextEvent as Rt, brokerInteractionTools$1 as S, deterministicFilePartId as St, plaintextResponseParser as T, InvalidAttachmentError as Tt, turnEndReason as U, textSnapshotEvents as Ut, interactionToggleEnabled as V, streamPartBase as Vt, turnInteractionEnabled as W, toolResultEvents as Wt, isLoopbackEndpoint as X, assertAcpTurnFinished as Xt, directStdioMcpServers as Y, acpContentText as Yt, isPlainRecord as Z, spawnAcpBridge as Zt, nativeEffortArgs as _, partitionImageAttachments as _t, SECRET_REFERENCE$1 as a, spawnUnderSecretMcpLease as at, DEFAULT_INTERACTION_MCP_SERVER_NAME as b, buildFileUrl as bt, forgetSessionScopes as c, SEALED_NATIVE_HOME_LAYOUT as ct, ROUTER_MODEL_CATALOG_LIFETIME_MS as d, provenStoreBinary as dt, resolveReferences as et, ROUTER_MODEL_CATALOG_TIMEOUT_MS as f, refuseSecretLaunch as ft, kimiThinkingArgs as g, PROMPT_SECTION_SEPARATOR as gt, resolveRouterModelReasoningEfforts as h, MAX_TOTAL_INLINE_IMAGE_BYTES as ht, PERMISSION_DECISION_TIMEOUT_MS as i, sharedSecretMcpRefused as it, CliProviderAdapterBase as j, EXECUTION_CORRELATION_HEADERS as jt, readCliTokenUsage as k, wasNeverLaunched as kt, secretMcpScope as l, assertSealedNativeHome as lt, resolveRouterModelLimits as m, MAX_INLINE_IMAGE_BYTES as mt, InteractionBroker$1 as n, servableMcpServer as nt, SECRET_REFERENCE_PREFIX$1 as o, untilSettledOrAborted as ot, findRouterCatalogEntry as p, resolveExecutableRealpath as pt, SHARED_WORKSPACE_DIR_ENV as q, ACP_MIN_PROTOCOL_VERSION as qt, InteractionHttpBridge as r, servableStdioServer as rt, codexDeveloperInstructionArgs as s, NATIVE_SESSION_CONTRACTS$1 as st, CODEX_DISABLED_FEATURE_ARGS as t, secretSessionTurnQueue as tt, ROUTER_MODEL_CATALOG_FAILURE_STOP_MS as u, isTrustedStoreBinary as ut, McpInteractionSupport as v, preparePromptInputParts as vt, jsonEventParser as w, trackFilePart as wt, InteractionMcpServer$1 as x, deriveFilePart as xt, TerminalPlanSupport as y, prependPromptSection as yt, localMcpEnv as z, reasoningEvents as zt };
5037
5099
 
5038
- //# sourceMappingURL=src-B_4qa95r.mjs.map
5100
+ //# sourceMappingURL=src-OUp4Ymnt.mjs.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tangle-network/sdk-provider-cli-base",
3
- "version": "0.13.210",
3
+ "version": "0.13.212",
4
4
  "description": "Base adapter for CLI-based AI agent providers",
5
5
  "type": "module",
6
6
  "main": "./dist/index.mjs",
@@ -79,8 +79,8 @@
79
79
  "registry": "https://registry.npmjs.org"
80
80
  },
81
81
  "tangleRelease": {
82
- "sourceSha": "295d3b99ce919b7d33be93088eb2a28cd32e3ca5",
83
- "mergedAt": "2026-11-24T13:59:54-08:00"
82
+ "sourceSha": "2e94fd8706ebbdd10a59eeabd79f161139a0047e",
83
+ "mergedAt": "2026-11-24T14:48:55-08:00"
84
84
  },
85
85
  "scripts": {
86
86
  "build": "tsdown",