@theokit/agents 15.1.0 → 16.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/client/http-transport.ts","../src/client/last-user-text.ts","../src/client/in-process-transport.ts","../src/client/channel-transport.ts","../src/client/agent-client.ts","../src/client/agent-handle.ts"],"mappings":";;;;;;;;;;;AAsEA,SAASA,qBAAAA;AACP,MAAIC;AACJ,SAAO;IACLC,KAAK,6BAAMD,OAAN;IACLE,KAAK,wBAACC,SAAAA;AACJH,cAAQG;IACV,GAFK;EAGP;AACF;AARSJ;AAWT,SAASK,SAASC,SAAqD;AACrE,MAAIA,YAAYC,OAAW,QAAO,CAAC;AACnC,MAAID,mBAAmBE,QAAS,QAAOC,OAAOC,YAAYJ,QAAQK,QAAO,CAAA;AACzE,SAAOL;AACT;AAJSD;AAuBF,IAAMO,gBAAN,MAAMA;EAnGb,OAmGaA;;;EACF;EACA;EACA;;EAEA;EAET,YAAYC,SAA+B;AACzC,SAAK,OAAOA,QAAQC;AACpB,SAAK,WAAWD,QAAQP,WAAW,CAAC;AAIpC,SAAK,SAASO,QAAQE,SAASC,WAAWD,MAAME,KAAKD,UAAAA;AACrD,SAAK,UAAUH,QAAQK,cAAclB,mBAAAA;EACvC;;EAGA,kBAAe;AACb,YAAQ,OAAO,KAAK,aAAa,aAAa,KAAK,SAAQ,IAAK,KAAK,aAAa,CAAC;EACrF;EAEA,MAAMmB,aACJN,SACyC;AACzC,UAAM,EAAEO,UAAUC,aAAaf,SAASgB,MAAMC,OAAM,IAAKV;AAKzD,UAAMW,QAAQ,OAAOF,SAAS,WAAWA,OAAOf;AAChD,UAAMkB,WAAW,MAAM,KAAK,OAAO,KAAK,MAAM;MAC5CC,QAAQ;MACRpB,SAASqB,oBAAoBC,sBAAsB,KAAK,gBAAe,GAAIvB,SAASC,OAAAA,CAAAA;;;;;MAKpFgB,MAAMO,KAAKC,UAAU;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AO,CAAA,GAA1C;EACX;AACF;AARgBN;AAWT,SAASQ,cAAcC,OAAc;AAC1C,SACE,OAAOA,UAAU,YACjBA,UAAU,QACV,OAAQA,MAA6BR,SAAS,YAC9C,OAAQQ,MAAqCC,iBAAiB;AAElE;AAPgBF;","names":["inMemoryRunIdStore","runId","get","set","next","toRecord","headers","undefined","Headers","Object","fromEntries","entries","HttpTransport","options","api","fetch","globalThis","bind","runIdStore","sendMessages","messages","abortSignal","body","chatId","extra","response","method","agentRequestHeaders","AGENT_ACTION_HEADERS","JSON","stringify","id","signal","ok","Error","status","statusText","responseToChunkStream","reconnectToStream","approve","approvalId","decision","extractLastUserText","messages","i","length","message","role","text","parts","filter","part","type","map","join","TheokitAgentError","generatorToStream","gen","ReadableStream","pull","controller","result","next","done","close","enqueue","value","err","error","cancel","return","undefined","ApprovalAbortedError","TheokitAgentError","name","approvalId","reason","code","isRetryable","InProcessTransport","Map","options","run","turn","signal","req","Promise","resolve","reject","aborted","has","Error","set","id","entry","delete","pending","size","sendMessages","messages","abortSignal","metadata","currentTurn","addEventListener","once","generator","message","extractLastUserText","awaitApproval","context","reconnectToStream","approve","decision","get","ChannelTransport","options","source","sendMessages","messages","abortSignal","metadata","message","extractLastUserText","closed","teardown","undefined","detachAbort","stream","ReadableStream","start","controller","finish","settle","context","onLine","line","parsed","JSON","parse","type","enqueue","onClose","close","onError","err","error","onAbort","aborted","addEventListener","removeEventListener","cancel","Promise","resolve","reconnectToStream","approve","approvalId","decision","Error","TheokitAgentError","AgentStreamInterruptedError","TheokitAgentError","name","chunksReceived","String","isRetryable","code","NO_PENDING_APPROVALS","derivePendingApprovals","messages","pending","message","part","parts","state","approval","id","push","approvalId","toolCallId","toolName","undefined","input","question","timeoutMs","inputToText","JSON","stringify","buildUserMessage","crypto","randomUUID","role","type","text","AgentClient","Set","thread","status","error","pendingApprovals","transport","contextResolver","options","emitIntervalMs","chatId","subscribe","listener","add","delete","getSnapshot","clearTimeout","tail","concat","setTimeout","next","idx","findIndex","existing","open","controller","aborted","signal","stream","length","outcome","consumeChunkStream","stamped","terminated","err","Error","send","abort","AbortController","userMsg","context","sendMessages","trigger","messageId","abortSignal","body","headers","metadata","reconnect","reconnectToStream","reset","approve","decision","agentHandle","path","inProcess","run","InProcessTransport","channel","source","ChannelTransport","isAgentHandle","value","sendMessages"]}
@@ -2,7 +2,8 @@ import {
2
2
  AgentClient,
3
3
  HttpTransport,
4
4
  isAgentHandle
5
- } from "./chunk-7PNUTDBQ.js";
5
+ } from "./chunk-KXE52FP2.js";
6
+ import "./chunk-FBCT4B2L.js";
6
7
  import {
7
8
  __name
8
9
  } from "./chunk-Z4QWC7IK.js";
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/client/use-agent.ts"],"mappings":";;;;;;;;;;AACA,SAASA,SAASC,QAAQC,4BAA4B;AA+F/C,SAASC,SACdC,SACAC,UAA2B,CAAC,GAAC;AAI7B,QAAMC,aAAaC,OAAOF,OAAAA;AAC1BC,aAAWE,UAAUH;AAIrB,MAAII;AACJ,MAAI,OAAOL,YAAY,SAAUK,OAAML;WAC9BM,cAAcN,OAAAA,EAAUK,OAAML,QAAQO;AAE/C,QAAMC,kBAAkBH,OAAOL;AAE/B,QAAMS,SAASC;IACb,MACE,IAAIC;MACFN,QAAQO,SACJ,IAAIC,cAAc;QAChBR;QACAS,SAAS,6BAAMZ,WAAWE,QAAQU,SAAzB;QACTC,OAAOb,WAAWE,QAAQW;MAC5B,CAAA,IACCf;;MAEL,MAAA;AACE,cAAMgB,MAAMd,WAAWE,QAAQa;AAC/B,eAAO,OAAOD,QAAQ,aAAaA,IAAAA,IAAQA;MAC7C;IAAA;;;IAIJ;MAACR;;EAAgB;AAGnB,QAAMU,QAAQC,qBAAqBV,OAAOW,WAAWX,OAAOY,aAAaZ,OAAOY,WAAW;AAE3F,SAAO;IACLC,UAAUJ,MAAMI;IAChBC,QAAQL,MAAMK;IACdC,QAAQN,MAAMM;IACdC,OAAOP,MAAMO;IACbC,kBAAkBR,MAAMQ;IACxBC,MAAMlB,OAAOkB;IACbC,OAAOnB,OAAOmB;IACdC,OAAOpB,OAAOoB;IACdC,SAASrB,OAAOqB;IAChBC,WAAWtB,OAAOsB;EACpB;AACF;AApDgBhC;","names":["useMemo","useRef","useSyncExternalStore","useAgent","binding","options","optionsRef","useRef","current","api","isAgentHandle","path","bindingIdentity","client","useMemo","AgentClient","undefined","HttpTransport","headers","fetch","ctx","context","state","useSyncExternalStore","subscribe","getSnapshot","messages","thread","status","error","pendingApprovals","send","abort","reset","approve","reconnect"]}
1
+ {"version":3,"sources":["../src/client/use-agent.ts"],"mappings":";;;;;;;;;;;AACA,SAASA,SAASC,QAAQC,4BAA4B;AA+F/C,SAASC,SACdC,SACAC,UAA2B,CAAC,GAAC;AAI7B,QAAMC,aAAaC,OAAOF,OAAAA;AAC1BC,aAAWE,UAAUH;AAIrB,MAAII;AACJ,MAAI,OAAOL,YAAY,SAAUK,OAAML;WAC9BM,cAAcN,OAAAA,EAAUK,OAAML,QAAQO;AAE/C,QAAMC,kBAAkBH,OAAOL;AAE/B,QAAMS,SAASC;IACb,MACE,IAAIC;MACFN,QAAQO,SACJ,IAAIC,cAAc;QAChBR;QACAS,SAAS,6BAAMZ,WAAWE,QAAQU,SAAzB;QACTC,OAAOb,WAAWE,QAAQW;MAC5B,CAAA,IACCf;;MAEL,MAAA;AACE,cAAMgB,MAAMd,WAAWE,QAAQa;AAC/B,eAAO,OAAOD,QAAQ,aAAaA,IAAAA,IAAQA;MAC7C;IAAA;;;IAIJ;MAACR;;EAAgB;AAGnB,QAAMU,QAAQC,qBAAqBV,OAAOW,WAAWX,OAAOY,aAAaZ,OAAOY,WAAW;AAE3F,SAAO;IACLC,UAAUJ,MAAMI;IAChBC,QAAQL,MAAMK;IACdC,QAAQN,MAAMM;IACdC,OAAOP,MAAMO;IACbC,kBAAkBR,MAAMQ;IACxBC,MAAMlB,OAAOkB;IACbC,OAAOnB,OAAOmB;IACdC,OAAOpB,OAAOoB;IACdC,SAASrB,OAAOqB;IAChBC,WAAWtB,OAAOsB;EACpB;AACF;AApDgBhC;","names":["useMemo","useRef","useSyncExternalStore","useAgent","binding","options","optionsRef","useRef","current","api","isAgentHandle","path","bindingIdentity","client","useMemo","AgentClient","undefined","HttpTransport","headers","fetch","ctx","context","state","useSyncExternalStore","subscribe","getSnapshot","messages","thread","status","error","pendingApprovals","send","abort","reset","approve","reconnect"]}
package/dist/client.d.ts CHANGED
@@ -110,14 +110,18 @@ type UIMessageChunk = WireChunk;
110
110
  *
111
111
  * `onMessage` is invoked on every reconstruction step with the latest snapshot of the assistant
112
112
  * message, so a caller (the `useAgent` hook) can render streaming updates.
113
+ *
114
+ * Because this path parses the bytes itself, its outcome also carries `framesDropped`: how many
115
+ * frames the wire parser could not read and discarded. A turn that said nothing and a turn whose
116
+ * frames were all unreadable both reconstruct to no text; that count is what tells them apart.
113
117
  */
114
118
  declare function consumeUIMessageStream(response: Response, onMessage: (message: UIMessage) => void): Promise<ChunkStreamOutcome>;
115
119
  /**
116
120
  * A UIMessageStream SSE `Response` → `ReadableStream<UIMessageChunk>`. This is precisely what a
117
121
  * `ChatTransport.sendMessages` returns, so `HttpTransport` builds on it directly. A body-less
118
- * response yields an empty stream.
122
+ * response yields an empty stream. `onWarn` hears each frame the wire parser discards.
119
123
  */
120
- declare function responseToChunkStream(response: Response): Promise<ReadableStream<UIMessageChunk>>;
124
+ declare function responseToChunkStream(response: Response, onWarn?: (message: string) => void): Promise<ReadableStream<UIMessageChunk>>;
121
125
  /**
122
126
  * How a chunk stream ENDED — theokit#384.
123
127
  *
@@ -159,6 +163,12 @@ interface ChunkStreamOutcome {
159
163
  * (`n > 0`), which are different failures with different first suspects.
160
164
  */
161
165
  readonly chunksReceived: number;
166
+ /**
167
+ * How many frames the wire parser discarded as unreadable (invalid JSON, an unknown variant).
168
+ * Present only when this module parsed the bytes ({@link consumeUIMessageStream}); a caller
169
+ * handing in an already-parsed chunk stream has no frames to count.
170
+ */
171
+ readonly framesDropped?: number;
162
172
  }
163
173
  /**
164
174
  * Read a `ReadableStream<UIMessageChunk>` into reconstructed assistant messages. Shared by
package/dist/client.js CHANGED
@@ -6,12 +6,14 @@ import {
6
6
  HttpTransport,
7
7
  InProcessTransport,
8
8
  agentHandle,
9
+ extractLastUserText,
10
+ isAgentHandle
11
+ } from "./chunk-KXE52FP2.js";
12
+ import {
9
13
  consumeChunkStream,
10
14
  consumeUIMessageStream,
11
- extractLastUserText,
12
- isAgentHandle,
13
15
  responseToChunkStream
14
- } from "./chunk-7PNUTDBQ.js";
16
+ } from "./chunk-FBCT4B2L.js";
15
17
  import "./chunk-Z4QWC7IK.js";
16
18
  export {
17
19
  AgentClient,
@@ -1,9 +1,9 @@
1
1
  import { PluginsSettings, ProviderRoutingSettings, AgentDefinition, BudgetTracker, CustomTool } from '@theokit/sdk';
2
2
  import { RetryOptions } from '@theokit/sdk/retry';
3
- import { C as CompiledAgentOptions, a as CompiledTool } from './agent-compiler-DMQcLHIs.js';
3
+ import { C as CompiledAgentOptions, a as CompiledTool } from './agent-compiler-BMpuJFAI.js';
4
4
  import { TheokitAgentError } from '@theokit/sdk/errors';
5
5
  import { z } from 'zod';
6
- import { b as MainLoopMeta } from './types-CxI2x6mU.js';
6
+ import { b as MainLoopMeta } from './types-DdltPCj2.js';
7
7
  import { WireChunk } from '@theokit/presenter/wire';
8
8
  import { H as HookHandlers } from './hook-handlers-Cw2FsnE5.js';
9
9
 
@@ -159,7 +159,13 @@ interface DoneEvent {
159
159
  cacheWriteTokens?: number;
160
160
  };
161
161
  durationMs: number;
162
- /** Total cost in USD for this agent run (EC-2: added for budget tracking). */
162
+ /**
163
+ * Total cost in USD for this agent run, as the SDK priced it (`CostBreakdown.amountUsd`).
164
+ *
165
+ * Absent when the run's price is not known (the SDK has no pricing data for the model); 0 means
166
+ * the SDK priced the run at zero, for example a subscription-included route. A consumer summing
167
+ * runs must not read an absent cost as 0 (usetheokit/theokit#969).
168
+ */
163
169
  cost?: number;
164
170
  /**
165
171
  * theokit#379 — why the run stopped, when it did NOT stop because the agent was done.
@@ -428,7 +434,17 @@ interface DelegationResult {
428
434
  input: unknown;
429
435
  output: string;
430
436
  }[];
437
+ /**
438
+ * USD the run's priced rounds cost. A round the SDK could not price adds nothing here, so read it
439
+ * with {@link costUnknown}: when that is set, this is the known spend and not the run's cost.
440
+ */
431
441
  cost: number;
442
+ /**
443
+ * Present, and `true`, when at least one round reported no finite cost (B-409): the run cost
444
+ * {@link cost} plus an amount nobody knows. Absent on a run whose every round was priced. A
445
+ * consumer summing runs must not read such a `cost` as the run's price (#969).
446
+ */
447
+ costUnknown?: true;
432
448
  tokens: number;
433
449
  /** V4-N: split token usage accumulated across rounds (`tokens` stays as the total). Absent for the single-shot path. */
434
450
  tokensInput?: number;
@@ -445,6 +461,24 @@ interface DelegationResult {
445
461
  */
446
462
  finishReason?: LoopFinishReason;
447
463
  }
464
+ /**
465
+ * Why a run stopped BEFORE a round rather than after one. Without it the error reports an
466
+ * overspend (`$actual > $limit`), which is only true once the spend passed the limit; a refusal
467
+ * stops while the spend is still under it, so it needs wording that does not claim otherwise.
468
+ */
469
+ type BudgetRefusal =
470
+ /** The next round's projected cost (the last completed round's), which would pass the limit. */
471
+ {
472
+ readonly projectedRoundCost: number;
473
+ }
474
+ /** The last round's cost is not known, so the limit cannot be enforced for the next one. */
475
+ | {
476
+ readonly costUnknown: true;
477
+ }
478
+ /** The limit is 0 or below, so no round fits: the run stops before its first one. */
479
+ | {
480
+ readonly nothingToSpend: true;
481
+ };
448
482
  /**
449
483
  * DELEGATION budget exceeded — the dollar cost of a delegated agent.
450
484
  *
@@ -475,7 +509,22 @@ declare class DelegationBudgetExceededError extends TheokitAgentError {
475
509
  readonly actualCost: number;
476
510
  readonly budgetLimit: number;
477
511
  readonly name = "DelegationBudgetExceededError";
478
- constructor(agentName: string, actualCost: number, budgetLimit: number);
512
+ /** The cost the refused round was projected at; absent when the spend already passed the limit. */
513
+ readonly projectedRoundCost: number | undefined;
514
+ constructor(agentName: string, actualCost: number, budgetLimit: number, refusal?: BudgetRefusal);
515
+ }
516
+ /**
517
+ * A run with a USD ceiling stopped because the cost of its last round is not known (B-409).
518
+ *
519
+ * A model with no price reports no cost, and reading that as $0 would let the run keep spending
520
+ * against a limit it can no longer check, so the run stops instead (fail closed). `actualCost` is
521
+ * the spend that IS known. A subclass so it can be caught on its own while every existing
522
+ * `instanceof DelegationBudgetExceededError` and the `DELEGATION_BUDGET_EXCEEDED` code still match;
523
+ * `name` is inherited because the parent declares it as a string literal, which a subclass cannot
524
+ * override with another.
525
+ */
526
+ declare class DelegationBudgetCostUnknownError extends DelegationBudgetExceededError {
527
+ constructor(agentName: string, knownSpend: number, budgetLimit: number);
479
528
  }
480
529
  /**
481
530
  * @deprecated Use {@link DelegationBudgetExceededError}. The alias is kept for one major so anyone
@@ -616,9 +665,15 @@ interface DelegateOptions {
616
665
  * unlike the budget errors — is marked retryable, because a hang is often transient.
617
666
  */
618
667
  readonly timeoutMs?: number;
619
- /** Max USD for this sub-agent call. */
668
+ /**
669
+ * Max USD for this sub-agent call. `NaN` is refused with `DelegationError`; 0 or below stops the
670
+ * call before any round with `DelegationBudgetExceededError`; `Infinity` is no ceiling.
671
+ */
620
672
  budget?: number;
621
- /** Parent's remaining budget (for clamping). */
673
+ /**
674
+ * Parent's remaining budget (for clamping), read on the same terms as `budget`: a parent that
675
+ * has spent its ceiling (0 or below) ends the call as budget exceeded before any round.
676
+ */
622
677
  parentBudgetRemaining?: number;
623
678
  /** Parent's tools (for sharing — sub-agent inherits these). */
624
679
  parentTools?: CompiledTool[];
@@ -806,4 +861,4 @@ declare function delegateWithScoring(subAgent: DelegationTarget, message: string
806
861
  feedbackTemplate?: (message: string, feedback: string) => string;
807
862
  }): Promise<ScoredDelegation>;
808
863
 
809
- export { noopReflectionStrategy as $, type AgentStopReason as A, type BackgroundDelegation as B, type CheckpointSavedEvent as C, type DelegationTarget as D, type ErrorEvent as E, type FileEditEvent as F, type ThinkingEvent as G, type ToolCallEvent as H, type IterationEvent as I, type ToolResultEvent as J, delegate as K, type LoopStrategy as L, delegateBackground as M, delegateWithScoring as N, isApprovalRequired as O, type PartialToolCallEvent as P, isDone as Q, type ReflectionStrategy as R, type StreamEvent as S, type TextDeltaEvent as T, isError as U, isPartialToolCall as V, isTextDelta as W, isToolCall as X, isToolResult as Y, ladderReflectionStrategy as Z, loopStrategyConfigSchema as _, type DelegateOptions as a, presentUIMessageStream as a0, reflectionStrategyConfigSchema as a1, resolveLoopStrategy as a2, streamAgentResponse as a3, type MaskError as a4, type RoundStreamFactory as b, type DelegationResult as c, type AgentStreamEvent as d, type AgentTurnMetadata as e, type ApprovalRequiredEvent as f, type ArtifactChunkEvent as g, type ArtifactStartEvent as h, BudgetExceededError as i, DEFAULT_MAX_ITERATIONS as j, type DelegateFn as k, DelegationBudgetExceededError as l, DelegationError as m, type DelegationPort as n, type DoneEvent as o, type LoopFinishReason as p, type LoopOutcome as q, type LoopStrategyConfig as r, type ReflectionContext as s, type ReflectionResult as t, type ReflectionStrategyConfig as u, type RunStartedEvent as v, type ScoreVerdict as w, type ScoredDelegation as x, type Scorer as y, type StateUpdateEvent as z };
864
+ export { loopStrategyConfigSchema as $, type AgentStopReason as A, type BackgroundDelegation as B, type CheckpointSavedEvent as C, type DelegationTarget as D, type ErrorEvent as E, type FileEditEvent as F, type StateUpdateEvent as G, type ThinkingEvent as H, type IterationEvent as I, type ToolCallEvent as J, type ToolResultEvent as K, type LoopStrategy as L, delegate as M, delegateBackground as N, delegateWithScoring as O, type PartialToolCallEvent as P, isApprovalRequired as Q, type ReflectionStrategy as R, type StreamEvent as S, type TextDeltaEvent as T, isDone as U, isError as V, isPartialToolCall as W, isTextDelta as X, isToolCall as Y, isToolResult as Z, ladderReflectionStrategy as _, type DelegateOptions as a, noopReflectionStrategy as a0, presentUIMessageStream as a1, reflectionStrategyConfigSchema as a2, resolveLoopStrategy as a3, streamAgentResponse as a4, type MaskError as a5, type RoundStreamFactory as b, type DelegationResult as c, type AgentStreamEvent as d, type AgentTurnMetadata as e, type ApprovalRequiredEvent as f, type ArtifactChunkEvent as g, type ArtifactStartEvent as h, BudgetExceededError as i, DEFAULT_MAX_ITERATIONS as j, type DelegateFn as k, DelegationBudgetCostUnknownError as l, DelegationBudgetExceededError as m, DelegationError as n, type DelegationPort as o, type DoneEvent as p, type LoopFinishReason as q, type LoopOutcome as r, type LoopStrategyConfig as s, type ReflectionContext as t, type ReflectionResult as u, type ReflectionStrategyConfig as v, type RunStartedEvent as w, type ScoreVerdict as x, type ScoredDelegation as y, type Scorer as z };
package/dist/index.d.ts CHANGED
@@ -1,18 +1,18 @@
1
1
  import { PluginsSettings, Plugin, ProviderRoutingSettings, AgentDefinition, BudgetTracker, CustomTool, GoalLoopAgent, GoalOptions, runGoalLoop, GoalEvent, GoalResult, InlineSkill, Agent as Agent$1, ListAgentsOptions, ListResult, SDKAgentInfo } from '@theokit/sdk';
2
2
  export { BudgetTracker, CustomTool, DiagnosticsSink, GenerateObjectError, GoalEvent, GoalLoopAgent, GoalOptions, GoalResult, InlineSkill, JudgeCredentialError, JudgeResult, LayerOrderError, McpAuthConfig, McpHttpServerConfig, McpOAuthConfig, McpServerConfig, McpStdioServerConfig, Plugin, PluginsSettings, Provider, ProviderRoutingSettings, RunEvent, SDKAgent, SessionRecord, SessionStore, Squad, StreamObjectError, Tool, ToolError, ToolResultContentBlock, TrustLevel, TrustPosture, TrustPostureInput, TrustSource, UngatedCapabilityError, Verdict, WiredEntity, applySecurityFloor, auditEnvReachability, foldLayers, recordWiring, resolveTrustPosture, setDiagnosticsSink, verifyLayerOrdering } from '@theokit/sdk';
3
- import { b as MainLoopMeta, R as ReasoningEffort, T as ToolOptions, A as ApprovalOptions, H as HumanInTheLoopOptions } from './types-CxI2x6mU.js';
4
- export { c as AgentOptions, B as BudgetOptions, d as MainLoopOptions, M as McpServersMap, e as PolicyHandler, f as TimeoutAction, g as ToolboxOptions } from './types-CxI2x6mU.js';
5
- import { C as ContextWindowOptions, S as SkillsOptions, A as AgentManifestEntry, H as HitlDecision, s as streamAgentUIMessages, a as ApprovalPosture, b as AgentModule } from './bridge-entry-CDFRjtbb.js';
6
- export { c as APPROVAL_MODES, d as AfterToolCallContext, e as AgentBuilder, f as AgentDefinitionError, g as AgentExecutionContext, h as AgentManifest, i as AgentManifestSource, j as AgentManifestTool, k as AgentRoute, l as AgentRouteContext, m as AgentRunInfo, n as AgentsPluginOptions, o as ApiErrorContext, p as ApiErrorDecision, q as ApiErrorPolicy, r as ApprovalMode, t as ApprovalRequest, B as BeforeToolCallContext, u as CompiledContextWindow, v as ContextualTool, D as DefinitionOrThunk, w as DelegationTimeoutError, E as EphemeralAgent, L as LLMCallContext, M as McpApprovalSpec, x as McpFileError, y as McpRegistryConfig, z as McpRequestContext, F as McpSelection, P as PermissionsPluginOptions, G as ProcessInputContext, R as RuntimeOverrides, I as SdkAgentHandle, J as SdkMessage, K as SdkSendOptions, N as SdkTurnHandle, O as Segment, Q as ShouldAutoApproveOptions, T as ToolCallVeto, U as ToolHooks, V as ToolHooksPlugin, W as WRITE_SCOPED_TOOLS, X as agentsPlugin, Y as applyPosture, Z as buildModelSelection, _ as compileAgentModule, $ as compileContextWindow, a0 as compileLoadedAgentModule, a1 as compileProjectContext, a2 as compileSkills, a3 as createAgentExecutionContext, a4 as createApiErrorHandler, a5 as createPermissionsPlugin, a6 as createSdkAgentStream, a7 as createThinkTagExtractor, a8 as createToolHooksPlugin, a9 as extractThinkTagStream, aa as generateAgentManifest, ab as generateAgentRoutes, ac as isAgentContext, ad as loadMcpJson, ae as loadPersonalMcpServers, af as mcpRegistry, ag as mcpToolApprovals, ah as projectContextMetadataOnlyKnobs, ai as reasoningEffortOf, aj as resolveMcpServers, ak as runWithApiErrorHandling, al as shouldAutoApprove, am as toAgentFactory, an as translateSdkEvent, ao as withClockCap, ap as withEphemeralAgent } from './bridge-entry-CDFRjtbb.js';
3
+ import { b as MainLoopMeta, B as BudgetOptions, R as ReasoningEffort, T as ToolOptions, A as ApprovalOptions, H as HumanInTheLoopOptions } from './types-DdltPCj2.js';
4
+ export { c as AgentOptions, d as MainLoopOptions, M as McpServersMap, e as PolicyHandler, f as TimeoutAction, g as ToolboxOptions } from './types-DdltPCj2.js';
5
+ import { C as ContextWindowOptions, S as SkillsOptions, A as AgentManifestEntry, H as HitlDecision, s as streamAgentUIMessages, a as ApprovalPosture, b as AgentModule } from './bridge-entry-BxJWDpQP.js';
6
+ export { c as APPROVAL_MODES, d as AfterToolCallContext, e as AgentBuilder, f as AgentDefinitionError, g as AgentExecutionContext, h as AgentManifest, i as AgentManifestSource, j as AgentManifestTool, k as AgentRoute, l as AgentRouteContext, m as AgentRunInfo, n as AgentsPluginOptions, o as ApiErrorContext, p as ApiErrorDecision, q as ApiErrorPolicy, r as ApprovalMode, t as ApprovalRequest, B as BeforeToolCallContext, u as CompiledContextWindow, v as ContextualTool, D as DefinitionOrThunk, w as DelegationTimeoutError, E as EphemeralAgent, L as LLMCallContext, M as McpApprovalSpec, x as McpFileError, y as McpRegistryConfig, z as McpRequestContext, F as McpSelection, P as PermissionsPluginOptions, G as ProcessInputContext, R as RuntimeOverrides, I as SdkAgentHandle, J as SdkMessage, K as SdkSendOptions, N as SdkTurnHandle, O as Segment, Q as ShouldAutoApproveOptions, T as ToolCallVeto, U as ToolHooks, V as ToolHooksPlugin, W as WRITE_SCOPED_TOOLS, X as agentsPlugin, Y as applyPosture, Z as buildModelSelection, _ as compileAgentModule, $ as compileContextWindow, a0 as compileLoadedAgentModule, a1 as compileProjectContext, a2 as compileSkills, a3 as createAgentExecutionContext, a4 as createApiErrorHandler, a5 as createPermissionsPlugin, a6 as createSdkAgentStream, a7 as createThinkTagExtractor, a8 as createToolHooksPlugin, a9 as extractThinkTagStream, aa as generateAgentManifest, ab as generateAgentRoutes, ac as isAgentContext, ad as loadMcpJson, ae as loadPersonalMcpServers, af as mcpRegistry, ag as mcpToolApprovals, ah as projectContextMetadataOnlyKnobs, ai as reasoningEffortOf, aj as resolveMcpServers, ak as runWithApiErrorHandling, al as shouldAutoApprove, am as toAgentFactory, an as translateSdkEvent, ao as withClockCap, ap as withEphemeralAgent } from './bridge-entry-BxJWDpQP.js';
7
7
  import { TheokitAgentError } from '@theokit/sdk/errors';
8
8
  export * from '@theokit/sdk/errors';
9
9
  export { ConfigurationError, BudgetExceededError as WindowBudgetExceededError } from '@theokit/sdk/errors';
10
- import { G as Guardrail, C as CompiledAgentOptions, a as CompiledTool } from './agent-compiler-DMQcLHIs.js';
11
- export { b as AGENT_BRAND, A as AgentDefinition, c as CompatImportUnsupportedError, d as CostBudgetExceededError, D as DefineAgentConfig, e as GuardrailAction, f as GuardrailError, g as GuardrailPhase, h as GuardrailResult, i as GuardrailViolationError, H as HookApprovalGate, j as HookApprovalRequest, k as HookGateUnsupportedError, I as InferAgentInput, l as InferAgentToolNames, M as MalformedGuardrailResultError, S as SkillsRequestContext, m as SkillsSelection, T as ToolWalkResult, n as ToolboxWalkResult, U as UnreadableTextPayloadError, o as compileAgentDefinition, p as compileTools, q as isAgentDefinition, r as resolveEnabledSkills } from './agent-compiler-DMQcLHIs.js';
10
+ import { G as Guardrail, C as CompiledAgentOptions, a as CompiledTool } from './agent-compiler-BMpuJFAI.js';
11
+ export { b as AGENT_BRAND, A as AgentDefinition, c as CompatImportUnsupportedError, d as CostBudgetExceededError, D as DefineAgentConfig, e as GuardrailAction, f as GuardrailError, g as GuardrailPhase, h as GuardrailResult, i as GuardrailViolationError, H as HookApprovalGate, j as HookApprovalRequest, k as HookGateUnsupportedError, I as InferAgentInput, l as InferAgentToolNames, M as MalformedGuardrailResultError, S as SkillsRequestContext, m as SkillsSelection, T as ToolWalkResult, n as ToolboxWalkResult, U as UnreadableTextPayloadError, o as compileAgentDefinition, p as compileTools, q as isAgentDefinition, r as resolveEnabledSkills } from './agent-compiler-BMpuJFAI.js';
12
12
  import { S as SettingSourcesSelection } from './setting-sources-gate-BJJiKq33.js';
13
13
  export { C as CompatSurface, a as GatedCompatSource, G as GatedSettingSource, P as ProjectSettingsGrant, R as ResolvedCompatSource, b as SettingSourceCapability, U as UntrustedSettingSourceError, r as resolveCompatSources, c as resolveSettingSources } from './setting-sources-gate-BJJiKq33.js';
14
- import { L as LoopStrategy, R as ReflectionStrategy, b as RoundStreamFactory, S as StreamEvent, c as DelegationResult } from './delegation-scoring-CSe_C-iX.js';
15
- export { A as AgentStopReason, d as AgentStreamEvent, e as AgentTurnMetadata, f as ApprovalRequiredEvent, g as ArtifactChunkEvent, h as ArtifactStartEvent, B as BackgroundDelegation, i as BudgetExceededError, C as CheckpointSavedEvent, j as DEFAULT_MAX_ITERATIONS, k as DelegateFn, a as DelegateOptions, l as DelegationBudgetExceededError, m as DelegationError, n as DelegationPort, D as DelegationTarget, o as DoneEvent, E as ErrorEvent, F as FileEditEvent, I as IterationEvent, p as LoopFinishReason, q as LoopOutcome, r as LoopStrategyConfig, P as PartialToolCallEvent, s as ReflectionContext, t as ReflectionResult, u as ReflectionStrategyConfig, v as RunStartedEvent, w as ScoreVerdict, x as ScoredDelegation, y as Scorer, z as StateUpdateEvent, T as TextDeltaEvent, G as ThinkingEvent, H as ToolCallEvent, J as ToolResultEvent, K as delegate, M as delegateBackground, N as delegateWithScoring, O as isApprovalRequired, Q as isDone, U as isError, V as isPartialToolCall, W as isTextDelta, X as isToolCall, Y as isToolResult, Z as ladderReflectionStrategy, _ as loopStrategyConfigSchema, $ as noopReflectionStrategy, a0 as presentUIMessageStream, a1 as reflectionStrategyConfigSchema, a2 as resolveLoopStrategy, a3 as streamAgentResponse } from './delegation-scoring-CSe_C-iX.js';
14
+ import { L as LoopStrategy, R as ReflectionStrategy, b as RoundStreamFactory, S as StreamEvent, c as DelegationResult } from './delegation-scoring-CURe4oSL.js';
15
+ export { A as AgentStopReason, d as AgentStreamEvent, e as AgentTurnMetadata, f as ApprovalRequiredEvent, g as ArtifactChunkEvent, h as ArtifactStartEvent, B as BackgroundDelegation, i as BudgetExceededError, C as CheckpointSavedEvent, j as DEFAULT_MAX_ITERATIONS, k as DelegateFn, a as DelegateOptions, l as DelegationBudgetCostUnknownError, m as DelegationBudgetExceededError, n as DelegationError, o as DelegationPort, D as DelegationTarget, p as DoneEvent, E as ErrorEvent, F as FileEditEvent, I as IterationEvent, q as LoopFinishReason, r as LoopOutcome, s as LoopStrategyConfig, P as PartialToolCallEvent, t as ReflectionContext, u as ReflectionResult, v as ReflectionStrategyConfig, w as RunStartedEvent, x as ScoreVerdict, y as ScoredDelegation, z as Scorer, G as StateUpdateEvent, T as TextDeltaEvent, H as ThinkingEvent, J as ToolCallEvent, K as ToolResultEvent, M as delegate, N as delegateBackground, O as delegateWithScoring, Q as isApprovalRequired, U as isDone, V as isError, W as isPartialToolCall, X as isTextDelta, Y as isToolCall, Z as isToolResult, _ as ladderReflectionStrategy, $ as loopStrategyConfigSchema, a0 as noopReflectionStrategy, a1 as presentUIMessageStream, a2 as reflectionStrategyConfigSchema, a3 as resolveLoopStrategy, a4 as streamAgentResponse } from './delegation-scoring-CURe4oSL.js';
16
16
  import { RetryOptions } from '@theokit/sdk/retry';
17
17
  export * from '@theokit/sdk/retry';
18
18
  export { RetryOptions } from '@theokit/sdk/retry';
@@ -319,8 +319,16 @@ interface AgentRunnerRunOptions {
319
319
  readonly apiKey: string | CredentialResolver;
320
320
  /** Session id override (default: a fresh isolated id). */
321
321
  readonly sessionId?: string;
322
- /** Cumulative USD budget across rounds. */
323
- readonly budget?: number;
322
+ /**
323
+ * The run's USD ceiling across rounds: a number, or `{ maxCostUsd }`. The first round always
324
+ * runs, because no earlier round exists to project its cost from; when that round alone passes
325
+ * the ceiling, the run then stops with `DelegationBudgetExceededError`. Every later round is
326
+ * projected at the last round's cost, and the run stops before a round the ceiling cannot cover.
327
+ * `window`, and a ceiling (either spelling) that is `NaN` or not a number, are refused at the
328
+ * call with a `DelegationError`; a ceiling of 0 or below throws `DelegationBudgetExceededError`
329
+ * at the call, before any round; `Infinity` is no ceiling.
330
+ */
331
+ readonly budget?: number | BudgetOptions;
324
332
  /** Cancellation — aborts stop the reflective loop from re-entering. */
325
333
  readonly signal?: AbortSignal;
326
334
  /**
@@ -1377,45 +1385,6 @@ declare function buildMcpToolDescriptors(entry: AgentManifestEntry): McpToolDesc
1377
1385
  /** Build the MCP `initialize` server-info block for an agent. */
1378
1386
  declare function mcpServerInfo(entry: AgentManifestEntry): McpServerInfo;
1379
1387
 
1380
- /**
1381
- * M15 (theokit-ai-first) — A2A client: call a remote A2A agent as a tool (ADR-0040 § D2).
1382
- *
1383
- * `createA2ATool` returns a `CustomTool` whose handler POSTs the input message to a remote agent's
1384
- * HTTP endpoint and returns its text response — cross-network delegation. Uses `fetch` (Web
1385
- * Standards, G8). The target is a remote AGENT endpoint, not an LLM provider, so the G2 grep guard
1386
- * (`openrouter.ai|api.openai.com|api.anthropic.com`) is unaffected. `fetchImpl` is injectable for tests.
1387
- */
1388
-
1389
- /** How to authenticate to the remote agent. */
1390
- interface A2AAuth {
1391
- /** Bearer token → `Authorization: Bearer <token>`. */
1392
- bearer?: string;
1393
- /** API-key header pair → `<name>: <value>` (e.g. `x-api-key`). */
1394
- apiKey?: {
1395
- header: string;
1396
- value: string;
1397
- };
1398
- }
1399
- interface A2AToolConfig {
1400
- /** Remote agent endpoint URL (POST target). */
1401
- url: string;
1402
- /** Tool name the model calls. */
1403
- name: string;
1404
- /** Tool description surfaced to the model. */
1405
- description: string;
1406
- /** Static headers merged into every request. */
1407
- headers?: Record<string, string>;
1408
- /** Auth applied to every request. */
1409
- auth?: A2AAuth;
1410
- /** Injected fetch (defaults to the global). Narrowed to the call shape this client uses. */
1411
- fetchImpl?: (url: string, init: RequestInit) => Promise<Response>;
1412
- }
1413
- /**
1414
- * Create a tool that delegates to a remote A2A agent. The remote is expected to answer a
1415
- * `{ message }` POST with a JSON body carrying a `response` (or `text`) string.
1416
- */
1417
- declare function createA2ATool(config: A2AToolConfig): CustomTool;
1418
-
1419
1388
  /**
1420
1389
  * M11 (theokit-ai-first) — {resource, thread} conversation scoping (ADR-0040 § D2, home concern).
1421
1390
  *
@@ -1463,27 +1432,68 @@ declare class AcpMessageDecoder {
1463
1432
  push(chunk: string): unknown[];
1464
1433
  }
1465
1434
 
1435
+ /**
1436
+ * M17 (theokit-ai-first) — ACP client: JSON-RPC over the stdio framing.
1437
+ *
1438
+ * Drives a coding agent (Claude Code, Amp, Codex) over an INJECTED {@link AcpTransport}. The
1439
+ * subprocess spawn is a Node API and lives in the adapter layer (G8); this client is transport-
1440
+ * agnostic and testable. It correlates responses to requests by `id`, dispatches server→client
1441
+ * requests (e.g. `session/request_permission`) to a registered handler, replying with its decision,
1442
+ * and delivers notifications (a `method` with no `id`, e.g. `session/update`) to their handler.
1443
+ */
1444
+
1466
1445
  /** The stdio channel to the coding-agent subprocess (abstracted for testability + G8). */
1467
1446
  interface AcpTransport {
1468
1447
  /** Write one already-encoded (newline-terminated) line to the agent's stdin. */
1469
1448
  send(line: string): void;
1470
1449
  /** Subscribe to raw lines/chunks from the agent's stdout. */
1471
1450
  subscribe(onData: (chunk: string) => void): void;
1451
+ /**
1452
+ * Report a channel that closed on its own (the process exited or failed). Optional: a transport
1453
+ * that has it lets the client reject the requests no reply will ever answer.
1454
+ */
1455
+ onClose?(listener: (cause: Error) => void): void;
1456
+ }
1457
+ /**
1458
+ * The agent wrote a stdout line that does not decode to a JSON-RPC message: it is not JSON, it is
1459
+ * JSON but not an object (`null`, a number, a string, an array), or it is an object that is not a
1460
+ * response, a request or a notification. `line` is the line, trimmed. Code `ACP_PROTOCOL_ERROR`.
1461
+ */
1462
+ declare class AcpProtocolError extends TheokitAgentError {
1463
+ readonly line: string;
1464
+ readonly name = "AcpProtocolError";
1465
+ constructor(line: string, options?: {
1466
+ cause?: unknown;
1467
+ });
1468
+ }
1469
+ /** The transport closed; `cause` is what the transport reported. Code `ACP_CONNECTION_CLOSED`. */
1470
+ declare class AcpConnectionClosedError extends TheokitAgentError {
1471
+ readonly name = "AcpConnectionClosedError";
1472
+ constructor(cause: Error);
1472
1473
  }
1473
1474
  /** Return a value or a Promise — `unknown` already includes `Promise<unknown>`; `await` handles both. */
1474
1475
  type ServerRequestHandler = (params: unknown) => unknown;
1476
+ /** Called with a notification's `params`; nothing is sent back. A returned promise is watched. */
1477
+ type NotificationHandler = (params: unknown) => void | Promise<void>;
1475
1478
  declare class AcpClient {
1476
1479
  private readonly transport;
1477
1480
  private nextId;
1478
1481
  private readonly pending;
1479
1482
  private readonly handlers;
1480
- private readonly decoder;
1483
+ private readonly notificationHandlers;
1484
+ private buffer;
1485
+ private closed;
1481
1486
  constructor(transport: AcpTransport);
1482
1487
  /** Send a JSON-RPC request and resolve with its `result` (or reject on `error`). */
1483
1488
  request(method: string, params: unknown): Promise<unknown>;
1484
1489
  /** Register a handler for a server→client request method (e.g. `session/request_permission`). */
1485
1490
  onRequest(method: string, handler: ServerRequestHandler): void;
1491
+ /** Register a notification handler; one that throws or rejects is reported. */
1492
+ onNotification(method: string, handler: NotificationHandler): void;
1493
+ private receive;
1494
+ private fail;
1486
1495
  private dispatch;
1496
+ private notify;
1487
1497
  private handleServerRequest;
1488
1498
  }
1489
1499
 
@@ -1664,4 +1674,4 @@ type AgentWithNarrowedList = Omit<typeof Agent$1, 'list'> & {
1664
1674
  type AgentWithNarrowedListAlias = AgentWithNarrowedList;
1665
1675
  declare const Agent: AgentWithNarrowedList;
1666
1676
 
1667
- export { type A2AAuth, type A2ACapabilities, type A2ASkill, type A2AToolConfig, AcpClient, AcpMessageDecoder, type AcpTransport, Agent, type AgentCard, type AgentConfig, AgentConfigCapability, AgentManifestEntry, AgentModule, AgentRunner, AgentRunnerBuilder, type AgentRunnerRunOptions, type AgentShape, type AgentWithNarrowedListAlias, ApprovalOptions, ApprovalPosture, type BuildAgentCardOptions, CanUseToolCapability, type Capability, CapabilityConflictError, CapabilityPreset, CapabilityRegistry, CheckpointCapability, type CompactionCallOptions, type CompactionStrategyConfig, CompiledAgentOptions, type CompiledAgentOptionsDraft, CompiledTool, ContextWindowCapability, ContextWindowOptions, type CostGuardOptions, DEFAULT_HANDLER_TIMEOUT_MS, DEFAULT_KEEP_TOKENS, DelegationResult, FieldCapability, type FinalizedDraft, GoalRunner, type GoalRunnerDeps, Guardrail, GuardrailsCapability, HitlDecision, HookApprovalCapability, HumanInTheLoopCapability, HumanInTheLoopOptions, type InProcessApprovalRequest, InProcessApprovalRequiredError, type InProcessAwaitApproval, type ListOptionsWithoutPaginationAlias, LoopStrategy, MCP_PROTOCOL_VERSION, MainLoopCapability, MainLoopMeta, type McpJsonSchema, type McpServerInfo, McpServersCapability, type McpToolDescriptor, MemoryCapability, ModelCapability, type NamedTool, type OutputModerationOptions, type PiiOptions, PluginsCapability, type PreCompactionHandler, PreCompactionHandlerError, type PreCompactionOptions, ProjectContextCapability, type PromptInjectionOptions, type ProvenanceEntry, ReasoningEffort, ReflectionStrategy, RoundStreamFactory, RunContextCapability, SessionStoreCapability, SettingSourcesCapability, SettingSourcesSelection, SkillsCapability, SkillsOptions, SkillsOptionsCapability, SkillsResolverCapability, type StreamAgentTurnDeps, type StreamAgentTurnInProcessInput, StreamEvent, SubAgentsCapability, SubagentsCapability, type Summarize, TelemetryCapability, type ToolComNome, type ToolDeclaration, ToolOptions, ToolboxCapability, type ToolboxSource, ToolsCapability, Toolset, ToolsetError, type TranscriptCompactionStrategy, UnknownCapabilityError, applyCapabilities, buildAgentCard, buildMcpToolDescriptors, compactionStrategyConfigSchema, costGuard, createA2ATool, createDraft, declareAgentShape, deriveConversationId, encodeAcpMessage, estimateTokens, formatGoalEvent, listSubagentNames, mcpServerInfo, moderateOutputStream, outputModeration, parseConversationId, piiDetector, promptInjectionDetector, resolveCompactionStrategy, resolveDecomposition, runInputGuards, runOutputGuards, setOnce, streamAgentTurnInProcess, streamAgentUIMessages, textPayloadExtractor, tokenBudgetCompactionStrategy, unicodeNormalizer, wellKnownCardPath, withPreCompaction };
1677
+ export { type A2ACapabilities, type A2ASkill, AcpClient, AcpConnectionClosedError, AcpMessageDecoder, AcpProtocolError, type AcpTransport, Agent, type AgentCard, type AgentConfig, AgentConfigCapability, AgentManifestEntry, AgentModule, AgentRunner, AgentRunnerBuilder, type AgentRunnerRunOptions, type AgentShape, type AgentWithNarrowedListAlias, ApprovalOptions, ApprovalPosture, BudgetOptions, type BuildAgentCardOptions, CanUseToolCapability, type Capability, CapabilityConflictError, CapabilityPreset, CapabilityRegistry, CheckpointCapability, type CompactionCallOptions, type CompactionStrategyConfig, CompiledAgentOptions, type CompiledAgentOptionsDraft, CompiledTool, ContextWindowCapability, ContextWindowOptions, type CostGuardOptions, DEFAULT_HANDLER_TIMEOUT_MS, DEFAULT_KEEP_TOKENS, DelegationResult, FieldCapability, type FinalizedDraft, GoalRunner, type GoalRunnerDeps, Guardrail, GuardrailsCapability, HitlDecision, HookApprovalCapability, HumanInTheLoopCapability, HumanInTheLoopOptions, type InProcessApprovalRequest, InProcessApprovalRequiredError, type InProcessAwaitApproval, type ListOptionsWithoutPaginationAlias, LoopStrategy, MCP_PROTOCOL_VERSION, MainLoopCapability, MainLoopMeta, type McpJsonSchema, type McpServerInfo, McpServersCapability, type McpToolDescriptor, MemoryCapability, ModelCapability, type NamedTool, type OutputModerationOptions, type PiiOptions, PluginsCapability, type PreCompactionHandler, PreCompactionHandlerError, type PreCompactionOptions, ProjectContextCapability, type PromptInjectionOptions, type ProvenanceEntry, ReasoningEffort, ReflectionStrategy, RoundStreamFactory, RunContextCapability, SessionStoreCapability, SettingSourcesCapability, SettingSourcesSelection, SkillsCapability, SkillsOptions, SkillsOptionsCapability, SkillsResolverCapability, type StreamAgentTurnDeps, type StreamAgentTurnInProcessInput, StreamEvent, SubAgentsCapability, SubagentsCapability, type Summarize, TelemetryCapability, type ToolComNome, type ToolDeclaration, ToolOptions, ToolboxCapability, type ToolboxSource, ToolsCapability, Toolset, ToolsetError, type TranscriptCompactionStrategy, UnknownCapabilityError, applyCapabilities, buildAgentCard, buildMcpToolDescriptors, compactionStrategyConfigSchema, costGuard, createDraft, declareAgentShape, deriveConversationId, encodeAcpMessage, estimateTokens, formatGoalEvent, listSubagentNames, mcpServerInfo, moderateOutputStream, outputModeration, parseConversationId, piiDetector, promptInjectionDetector, resolveCompactionStrategy, resolveDecomposition, runInputGuards, runOutputGuards, setOnce, streamAgentTurnInProcess, streamAgentUIMessages, textPayloadExtractor, tokenBudgetCompactionStrategy, unicodeNormalizer, wellKnownCardPath, withPreCompaction };