@standardagents/spec 0.21.0 → 0.22.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.
package/dist/index.d.ts CHANGED
@@ -191,6 +191,70 @@ declare function defineEffect<State = ThreadState, Args extends ToolArgs = ToolA
191
191
  */
192
192
  declare function defineEffect<State = ThreadState>(description: string, handler: Effect<State, null>): EffectDefinition<State, null>;
193
193
 
194
+ /**
195
+ * Agent Skills — instance-global skill store types.
196
+ *
197
+ * Skills follow the Agent Skills standard (https://agentskills.io): a folder
198
+ * whose root SKILL.md opens with YAML frontmatter carrying a required `name`
199
+ * (lowercase kebab, ≤64 chars) and `description` (≤1024 chars), optionally
200
+ * accompanied by scripts, references, and assets.
201
+ *
202
+ * Runtimes store skills server-side as a GLOBAL, instance-wide library:
203
+ * installed once, visible to every thread, nothing persisted on a client
204
+ * machine. Progressive disclosure is the contract — agents see only each
205
+ * skill's name + description until a skill is judged applicable, at which
206
+ * point they load its SKILL.md body (and, when needed, read or execute its
207
+ * bundled files).
208
+ */
209
+ /** Registry view of an installed skill (metadata only — no file contents). */
210
+ interface SkillMetadata {
211
+ /** Kebab-case identifier from SKILL.md frontmatter. */
212
+ name: string;
213
+ /** What the skill does and when to use it (from frontmatter). */
214
+ description: string;
215
+ /** Optional version string from frontmatter. */
216
+ version?: string;
217
+ /** Disabled skills stay installed but are hidden from agents. */
218
+ enabled: boolean;
219
+ /** Relative paths of the skill's files (always includes SKILL.md). */
220
+ files: string[];
221
+ /** Unix seconds of the last install/update. */
222
+ updatedAt?: number;
223
+ }
224
+ /** A file being installed into a skill (relative path + full text). */
225
+ interface SkillFileInput {
226
+ path: string;
227
+ content: string;
228
+ }
229
+ /**
230
+ * ThreadState surface for the global skill library. All operations hit the
231
+ * instance-wide store — there is no per-thread skill state beyond what a
232
+ * thread chooses to keep in its own key-value store.
233
+ */
234
+ interface SkillsNamespace {
235
+ /** Installed skills (enabled only, unless includeDisabled). */
236
+ list(options?: {
237
+ includeDisabled?: boolean;
238
+ }): Promise<SkillMetadata[]>;
239
+ /** A skill's metadata plus its SKILL.md source (null when not installed). */
240
+ get(name: string): Promise<{
241
+ metadata: SkillMetadata;
242
+ skillMd: string;
243
+ } | null>;
244
+ /** Read one bundled file's text (null when the skill or file is missing). */
245
+ readFile(name: string, path: string): Promise<string | null>;
246
+ /**
247
+ * Install (or replace) a skill from its file set. The file set must include
248
+ * a root SKILL.md with valid frontmatter; the skill's identity comes from
249
+ * that frontmatter, never from a caller-supplied name.
250
+ */
251
+ install(files: SkillFileInput[]): Promise<SkillMetadata>;
252
+ /** Enable/disable an installed skill. Returns false when not installed. */
253
+ setEnabled(name: string, enabled: boolean): Promise<boolean>;
254
+ /** Uninstall a skill entirely. Returns false when not installed. */
255
+ remove(name: string): Promise<boolean>;
256
+ }
257
+
194
258
  /**
195
259
  * Thread state types for Standard Agents.
196
260
  *
@@ -207,6 +271,21 @@ declare function defineEffect<State = ThreadState>(description: string, handler:
207
271
  * This represents the core identity of a thread, separate from its
208
272
  * operational state. Thread metadata is immutable after creation.
209
273
  */
274
+ /**
275
+ * The profile of the user a thread belongs to, as exposed by
276
+ * {@link ThreadState.user}. Identity fields only — never credentials.
277
+ */
278
+ interface ThreadUser {
279
+ id: string;
280
+ username: string;
281
+ /** 'admin' | 'user' | 'api' in the reference runtime. */
282
+ role: string;
283
+ /** Explicit permission grants (runtime-defined strings), if any. */
284
+ permissions?: string[] | null;
285
+ email?: string | null;
286
+ display_name?: string | null;
287
+ avatar_url?: string | null;
288
+ }
210
289
  interface ThreadMetadata {
211
290
  /** Unique identifier for the thread */
212
291
  id: string;
@@ -380,6 +459,51 @@ interface MessageUpdates {
380
459
  /** Updated metadata (merged with existing) */
381
460
  metadata?: Record<string, unknown>;
382
461
  }
462
+ /**
463
+ * A streamed fragment of an assistant message's *visible content*.
464
+ *
465
+ * Always broadcast (no opt-in). Clients accumulate `chunk`s by `message_id` to
466
+ * render the answer as it generates; the authoritative final content still
467
+ * arrives separately as a persisted message.
468
+ */
469
+ interface ThreadMessageChunkEvent {
470
+ type: 'message_chunk';
471
+ /** The assistant message these fragments belong to. */
472
+ message_id: string;
473
+ /** Message depth: 0 = top-level thread, 1+ = subagent. */
474
+ depth: number;
475
+ /** The next fragment of visible content. */
476
+ chunk: string;
477
+ }
478
+ /**
479
+ * A streamed fragment of a model's *internal reasoning* (chain-of-thought).
480
+ *
481
+ * OPT-IN. Unlike content, reasoning is private by default: it is only sent to
482
+ * sockets that explicitly subscribe by connecting with the
483
+ * {@link THREAD_STREAM_REASONING_PARAM} query parameter set to a truthy value
484
+ * (e.g. `?reasoning=1`). Standard SDK consumers therefore never receive it
485
+ * unless they opt in.
486
+ *
487
+ * Reasoning is ephemeral *display* output: it is streamed for live presentation
488
+ * only and is NOT persisted as part of the assistant message content, so it
489
+ * cannot be replayed from message history — a client that wants it must be
490
+ * subscribed while the turn runs.
491
+ */
492
+ interface ThreadReasoningChunkEvent {
493
+ type: 'reasoning_chunk';
494
+ /** The assistant message this reasoning accompanies. */
495
+ message_id: string;
496
+ /** Message depth: 0 = top-level thread, 1+ = subagent. */
497
+ depth: number;
498
+ /** The next fragment of internal reasoning. */
499
+ chunk: string;
500
+ }
501
+ /**
502
+ * Query-parameter name a client sets (truthy) on the thread stream WebSocket to
503
+ * opt into receiving {@link ThreadReasoningChunkEvent}s. Absent/falsey means the
504
+ * server never emits reasoning to that socket.
505
+ */
506
+ declare const THREAD_STREAM_REASONING_PARAM = "reasoning";
383
507
  /**
384
508
  * Storage location identifier.
385
509
  *
@@ -844,6 +968,41 @@ interface StopSessionOptions {
844
968
  * });
845
969
  * ```
846
970
  */
971
+ /**
972
+ * A request forwarded from a server-side tool to a connected client (CLI) for
973
+ * local execution. Used by "forwarded" tools where the agent loop runs remotely
974
+ * but the actual operation (read a file, run a command) must happen on the
975
+ * user's own machine.
976
+ */
977
+ interface ClientToolRequest {
978
+ /** Logical operation name the client knows how to perform (e.g. `read_file`). */
979
+ tool: string;
980
+ /** Arguments for the operation. */
981
+ args?: Record<string, unknown>;
982
+ /**
983
+ * Human-readable description of what this call will do, shown to the user when
984
+ * the client needs to ask for permission. Presence signals the operation may
985
+ * carry side effects.
986
+ */
987
+ requestPermission?: string;
988
+ /** Risk level 1 (safe) – 5 (dangerous). Clients slide auto-accept on this. */
989
+ risk?: number;
990
+ /** Milliseconds to wait for the client before failing the call. */
991
+ timeoutMs?: number;
992
+ }
993
+ /**
994
+ * The result a connected client returns for a {@link ClientToolRequest}.
995
+ */
996
+ interface ClientToolResponse {
997
+ /** Whether the client successfully performed the operation. */
998
+ ok: boolean;
999
+ /** Text result (e.g. file contents, command output). */
1000
+ result?: string;
1001
+ /** Error message when `ok` is false (including a user denial). */
1002
+ error?: string;
1003
+ /** Optional structured payload the tool can inspect. */
1004
+ data?: unknown;
1005
+ }
847
1006
  interface ThreadState {
848
1007
  /** Unique thread identifier */
849
1008
  readonly threadId: string;
@@ -1206,6 +1365,51 @@ interface ThreadState {
1206
1365
  * to delete the key
1207
1366
  */
1208
1367
  setValue(key: string, value: unknown): Promise<void>;
1368
+ /**
1369
+ * The profile of the user this thread belongs to, or `null` when the thread
1370
+ * has no associated user (e.g. unauthenticated local development).
1371
+ *
1372
+ * Lets tools and hooks personalize or gate behavior per user — e.g. an
1373
+ * entitlement hook enforcing a per-user concurrency limit, or a tool
1374
+ * addressing the user by name. Never includes credentials.
1375
+ *
1376
+ * @example
1377
+ * ```typescript
1378
+ * const user = await state.user();
1379
+ * if (user?.email) await notifyBillingService(user.email);
1380
+ * ```
1381
+ */
1382
+ user(): Promise<ThreadUser | null>;
1383
+ /**
1384
+ * The instance-global Agent Skills library (https://agentskills.io format).
1385
+ *
1386
+ * Skills are installed once and visible to every thread; their files live
1387
+ * server-side (never on a client machine). Agents should follow progressive
1388
+ * disclosure: browse metadata via `skills.list()`, and load a skill's
1389
+ * SKILL.md body with `skills.get()` only when it is applicable to the task.
1390
+ *
1391
+ * @example
1392
+ * ```typescript
1393
+ * const available = await state.skills.list();
1394
+ * const skill = await state.skills.get('pdf-processing');
1395
+ * const script = await state.skills.readFile('pdf-processing', 'scripts/extract.py');
1396
+ * ```
1397
+ */
1398
+ skills: SkillsNamespace;
1399
+ /**
1400
+ * Forward a tool operation to the connected client (e.g. the coding CLI) and
1401
+ * await its result. The agent loop runs remotely, but operations like reading
1402
+ * a file or running a shell command must execute on the user's own machine;
1403
+ * `callClient` bridges that gap over the thread's `bridge` WebSocket.
1404
+ *
1405
+ * Resolves with `{ ok: false, error }` (rather than throwing) when no client
1406
+ * is connected, the request times out, or the user denies permission, so
1407
+ * forwarded tools can surface a normal tool error to the model.
1408
+ *
1409
+ * @param request - The operation, args, and optional permission/risk metadata
1410
+ * @returns The client's response
1411
+ */
1412
+ callClient(request: ClientToolRequest): Promise<ClientToolResponse>;
1209
1413
  /**
1210
1414
  * Write a file to the thread's file system.
1211
1415
  *
@@ -1774,6 +1978,38 @@ interface DefineToolOptions<State = ThreadState, Args extends ToolArgs | null =
1774
1978
  * ```
1775
1979
  */
1776
1980
  uses?: Uses;
1981
+ /**
1982
+ * The name of an argument whose value is a short, human-readable description
1983
+ * of what this tool call is doing — for example `"fixing index.html"`.
1984
+ *
1985
+ * When set, the `tool_call_started` hook and the `tool_call_started` thread
1986
+ * event wait until **just this argument** has finished streaming from the
1987
+ * model — not the whole tool call — and include its value as `progress`. This
1988
+ * lets a UI show what a tool is about to do before a large argument (such as
1989
+ * a file's `content`) finishes generating.
1990
+ *
1991
+ * When unset, `tool_call_started` fires as soon as the tool call appears in
1992
+ * the model stream (its name is known, arguments may still be incomplete).
1993
+ *
1994
+ * Declare the named argument early in the `args` schema and keep it short so
1995
+ * it completes quickly. If the model never emits it, `tool_call_started`
1996
+ * still fires once the tool call finishes, with `progress` undefined.
1997
+ *
1998
+ * @example
1999
+ * ```typescript
2000
+ * defineTool({
2001
+ * description: 'Write a file to the workspace',
2002
+ * progressArgument: 'description',
2003
+ * args: z.object({
2004
+ * description: z.string().describe('e.g. "writing index.html"'),
2005
+ * path: z.string(),
2006
+ * content: z.string(),
2007
+ * }),
2008
+ * execute: async (state, args) => { ... },
2009
+ * });
2010
+ * ```
2011
+ */
2012
+ progressArgument?: string;
1777
2013
  }
1778
2014
  /**
1779
2015
  * Tool definition object returned by defineTool().
@@ -1825,6 +2061,12 @@ interface ToolDefinition<State = ThreadState, Args extends ToolArgs | null = nul
1825
2061
  * - Qualified names (e.g., 'other_pkg:agent'): Cross-package entry point
1826
2062
  */
1827
2063
  uses?: Uses;
2064
+ /**
2065
+ * The name of an argument carrying a short, human-readable description of what
2066
+ * this tool call is doing (e.g. `"fixing index.html"`). Controls when the
2067
+ * `tool_call_started` hook/event fires — see {@link DefineToolOptions.progressArgument}.
2068
+ */
2069
+ progressArgument?: string;
1828
2070
  }
1829
2071
  /**
1830
2072
  * Defines a tool that agents can call during execution.
@@ -1939,6 +2181,12 @@ interface ProviderModelInfo {
1939
2181
  iconId?: string;
1940
2182
  /** Optional slug for additional lookups (e.g., OpenRouter endpoint queries) */
1941
2183
  slug?: string;
2184
+ /** Optional cost per 1M input tokens, in USD */
2185
+ inputPrice?: number;
2186
+ /** Optional cost per 1M output tokens, in USD */
2187
+ outputPrice?: number;
2188
+ /** Optional cost per 1M cached input tokens, in USD */
2189
+ cachedPrice?: number;
1942
2190
  /**
1943
2191
  * Optional capability hints surfaced from the provider's listing
1944
2192
  * payload. Populated when the provider can derive support flags
@@ -2478,6 +2726,117 @@ interface ProviderFactoryConfig {
2478
2726
  apiKey: string;
2479
2727
  baseUrl?: string;
2480
2728
  timeout?: number;
2729
+ [key: string]: unknown;
2730
+ }
2731
+ /**
2732
+ * Declarative connection-level config slot exposed by a provider factory.
2733
+ *
2734
+ * Slots describe values used to construct a provider client, such as
2735
+ * credentials, API endpoints, account IDs, regions, and timeouts. They are
2736
+ * different from `providerOptions`, which are per-model or per-request knobs.
2737
+ */
2738
+ interface ProviderConfigSlot<T = unknown> {
2739
+ /** Value type, used by UIs for validation and secret handling */
2740
+ type: VariableType | 'url' | 'number' | 'boolean';
2741
+ /** Whether this value is required to construct the provider */
2742
+ required?: boolean;
2743
+ /** Default literal value when no override/source provides one */
2744
+ default?: T;
2745
+ /** Conventional environment variable used by the built-in/default provider */
2746
+ defaultEnv?: string;
2747
+ /** Whether sub-providers may override this slot */
2748
+ overridable?: boolean;
2749
+ /** Human-readable description for setup UIs and docs */
2750
+ description?: string;
2751
+ }
2752
+ /**
2753
+ * Named collection of provider client config slots.
2754
+ */
2755
+ type ProviderConfigSlots = Record<string, ProviderConfigSlot>;
2756
+ /**
2757
+ * Value source used by `defineProvider()` sub-providers to fill base-provider
2758
+ * config slots.
2759
+ */
2760
+ type ProviderConfigValueSource<T = unknown> = {
2761
+ type: 'const';
2762
+ value: T;
2763
+ } | {
2764
+ type: 'env';
2765
+ name: string;
2766
+ valueType?: VariableType | 'url' | 'number' | 'boolean';
2767
+ required?: boolean;
2768
+ default?: T;
2769
+ description?: string;
2770
+ };
2771
+ /**
2772
+ * Convenience helper for constant provider config values.
2773
+ */
2774
+ declare function providerValue<T>(value: T): ProviderConfigValueSource<T>;
2775
+ /**
2776
+ * Convenience helper for provider config values resolved from environment.
2777
+ */
2778
+ declare function providerEnv<T = string>(name: string, options?: Omit<Extract<ProviderConfigValueSource<T>, {
2779
+ type: 'env';
2780
+ }>, 'type' | 'name'>): ProviderConfigValueSource<T>;
2781
+ /**
2782
+ * Backward-compatible alias with wording that reads naturally in provider
2783
+ * definition files.
2784
+ */
2785
+ declare const providerConst: typeof providerValue;
2786
+ interface ProviderOverrideContext {
2787
+ /** Name of the defined provider being executed */
2788
+ providerName: string;
2789
+ /** The resolved connection config passed to the base provider */
2790
+ config: ProviderFactoryConfig;
2791
+ /** Base provider instance before overrides are applied */
2792
+ baseProvider: ProviderInstance;
2793
+ }
2794
+ type MaybePromise<T> = T | Promise<T>;
2795
+ type ProviderOverride<Context, Result> = (context: ProviderOverrideContext & Context, next: () => MaybePromise<Result>) => MaybePromise<Result>;
2796
+ type ProviderSyncOverride<Context, Result> = (context: ProviderOverrideContext & Context, next: () => Result) => Result;
2797
+ /**
2798
+ * Overrideable provider methods. Each override can replace the base behavior
2799
+ * or call `next()` to compose with the base provider.
2800
+ */
2801
+ interface ProviderMethodOverrides {
2802
+ generate?: ProviderOverride<{
2803
+ request: ProviderRequest;
2804
+ }, ProviderResponse>;
2805
+ stream?: ProviderOverride<{
2806
+ request: ProviderRequest;
2807
+ }, AsyncIterable<ProviderStreamChunk>>;
2808
+ supportsModel?: ProviderSyncOverride<{
2809
+ modelId: string;
2810
+ }, boolean>;
2811
+ getModels?: ProviderOverride<{
2812
+ filter?: string;
2813
+ }, ProviderModelInfo[]>;
2814
+ getModelsPage?: ProviderOverride<{
2815
+ query?: ProviderModelsQuery;
2816
+ }, ProviderModelsPage>;
2817
+ getModelCapabilities?: ProviderOverride<{
2818
+ modelId: string;
2819
+ }, ModelCapabilities | null>;
2820
+ getTools?: ProviderOverride<{
2821
+ modelId?: string;
2822
+ }, Record<string, ToolDefinition<unknown, ToolArgs | null, ToolTenvs | null>>>;
2823
+ getIcon?: ProviderSyncOverride<{
2824
+ modelId?: string;
2825
+ }, string | undefined>;
2826
+ inspectRequest?: ProviderOverride<{
2827
+ request: ProviderRequest;
2828
+ }, InspectedRequest>;
2829
+ getResponseMetadata?: ProviderOverride<{
2830
+ summary: ResponseSummary;
2831
+ signal?: AbortSignal;
2832
+ }, Record<string, unknown> | null>;
2833
+ }
2834
+ interface ProviderDefinition<N extends string = string, Base extends ProviderFactoryWithOptions<ZodTypeAny> = ProviderFactoryWithOptions<ZodTypeAny>> {
2835
+ name: N;
2836
+ label?: string;
2837
+ baseProvider: Base;
2838
+ config?: Partial<Record<keyof ProviderFactoryConfig | string, ProviderConfigValueSource>>;
2839
+ overrides?: ProviderMethodOverrides;
2481
2840
  }
2482
2841
  /**
2483
2842
  * Provider factory with optional typed providerOptions schema.
@@ -2502,6 +2861,10 @@ interface ProviderFactoryWithOptions<TOptions extends ZodTypeAny = ZodTypeAny> {
2502
2861
  (config: ProviderFactoryConfig): ProviderInstance;
2503
2862
  /** Zod schema for provider-specific options */
2504
2863
  providerOptions?: TOptions;
2864
+ /** Connection-level config slots accepted by this provider factory */
2865
+ configSlots?: ProviderConfigSlots;
2866
+ /** Metadata attached to factories created with defineProvider() */
2867
+ providerDefinition?: ProviderDefinition<string, ProviderFactoryWithOptions<TOptions>>;
2505
2868
  }
2506
2869
  /**
2507
2870
  * Factory function that creates provider instances.
@@ -2518,6 +2881,11 @@ interface ProviderFactoryWithOptions<TOptions extends ZodTypeAny = ZodTypeAny> {
2518
2881
  * ```
2519
2882
  */
2520
2883
  type ProviderFactory = ProviderFactoryWithOptions<ZodTypeAny>;
2884
+ /**
2885
+ * Define a named sub-provider that uses a base provider implementation with
2886
+ * custom connection config sources and optional method overrides.
2887
+ */
2888
+ declare function defineProvider<const N extends string, Base extends ProviderFactoryWithOptions<ZodTypeAny>>(definition: ProviderDefinition<N, Base>): ProviderFactoryWithOptions<Base extends ProviderFactoryWithOptions<infer S> ? S : ZodTypeAny>;
2521
2889
  /**
2522
2890
  * Extract providerOptions type from a provider factory.
2523
2891
  *
@@ -3128,6 +3496,29 @@ interface SubagentToolConfig<T extends string = StandardAgentSpec.Callables> {
3128
3496
  */
3129
3497
  parentCommunication?: 'implicit' | 'explicit';
3130
3498
  };
3499
+ /**
3500
+ * How this subagent reports completion back to its parent. Applies to
3501
+ * non-resumable subagents; resumable subagents may instead set
3502
+ * `resumable.parentCommunication`, which takes precedence when present.
3503
+ *
3504
+ * - `implicit` (default): the child's completion is auto-queued to the parent,
3505
+ * which triggers a parent turn.
3506
+ * - `explicit`: the runtime does NOT auto-queue the child's completion, so the
3507
+ * parent is not woken. Use for background subagents that deliver their result
3508
+ * another way (e.g. writing to the parent's thread KV) and should be "picked
3509
+ * up" on the parent's next natural turn rather than forcing one.
3510
+ */
3511
+ parentCommunication?: 'implicit' | 'explicit';
3512
+ /**
3513
+ * Hide this subagent tool from the LLM's tool list while keeping the
3514
+ * relationship declared, so runtime code (hooks calling
3515
+ * `state.invokeTool()` / `queueTool()`) can still spawn it. Use for
3516
+ * infrastructure subagents the model must never call itself (e.g. a
3517
+ * background context-compaction agent).
3518
+ *
3519
+ * @default false
3520
+ */
3521
+ hidden?: boolean;
3131
3522
  }
3132
3523
  /**
3133
3524
  * Reasoning configuration for models that support extended thinking.
@@ -3730,6 +4121,55 @@ interface HookSignatures<State = ThreadState, Msg = HookMessage, ToolCall = Hook
3730
4121
  * ```
3731
4122
  */
3732
4123
  after_tool_call_failure: (state: State, toolCall: ToolCall, toolResult: ToolResult) => Promise<ToolResult | null>;
4124
+ /**
4125
+ * Called when a tool call STARTS — before the tool executes, while the model
4126
+ * may still be generating the rest of the call. Fires exactly once per tool
4127
+ * call. Observational: the return value is ignored.
4128
+ *
4129
+ * Timing depends on whether the tool declares a `progressArgument`:
4130
+ * - **With** `progressArgument`: fires as soon as *just that argument* has
4131
+ * finished streaming (not the whole call), passing its value as `progress`.
4132
+ * This lets a UI show "fixing index.html" before a large `content` argument
4133
+ * finishes generating.
4134
+ * - **Without** `progressArgument`: fires as soon as the tool call appears in
4135
+ * the stream — its name is known but `toolCall.function.arguments` may be an
4136
+ * incomplete JSON fragment (or empty), and `progress` is undefined.
4137
+ *
4138
+ * Conforming runtimes also broadcast a `tool_call_started` thread event to
4139
+ * connected clients with `{ id, name, progress }` at the same moment.
4140
+ *
4141
+ * @param state - Thread state
4142
+ * @param toolCall - The starting tool call; `function.arguments` may be incomplete
4143
+ * @param progress - The declared progress-argument value, when available
4144
+ *
4145
+ * @example
4146
+ * ```typescript
4147
+ * defineHook({
4148
+ * hook: 'tool_call_started',
4149
+ * id: 'log_tool_start',
4150
+ * execute: async (state, toolCall, progress) => {
4151
+ * console.log(`▸ ${toolCall.function.name}${progress ? `: ${progress}` : ''}`);
4152
+ * },
4153
+ * });
4154
+ * ```
4155
+ */
4156
+ tool_call_started: (state: State, toolCall: ToolCall, progress?: string) => Promise<void>;
4157
+ /**
4158
+ * Called when a tool call is DONE — after it has executed, with its result,
4159
+ * regardless of success or failure. Fires once per tool call. Observational:
4160
+ * the return value is ignored.
4161
+ *
4162
+ * This complements `after_tool_call_success` / `after_tool_call_failure`,
4163
+ * which can additionally *modify* the stored result; `tool_call_done` is a
4164
+ * single unified observation point that always fires. Conforming runtimes
4165
+ * also broadcast a `tool_call_done` thread event to connected clients with
4166
+ * `{ id, name, status }` at the same moment.
4167
+ *
4168
+ * @param state - Thread state
4169
+ * @param toolCall - The completed tool call
4170
+ * @param toolResult - The tool's result (`status` is `'success'` or `'error'`)
4171
+ */
4172
+ tool_call_done: (state: State, toolCall: ToolCall, toolResult: ToolResult) => Promise<void>;
3733
4173
  }
3734
4174
  /**
3735
4175
  * Valid hook names.
@@ -4621,4 +5061,4 @@ interface PackedExports {
4621
5061
  __meta: PackedMeta;
4622
5062
  }
4623
5063
 
4624
- export { type AgentDefinition, type AgentType, type AttachmentRef, type CodeExecution, type CodeExecutionError, type CodeExecutionLog, type CodeExecutionOptions, type CodeExecutionResult, type CodeExecutionStatus, type ContentPart, type Controller, type ControllerContext, type ControllerReturn, type DefineToolOptions, type DefinitionLoader, type Effect, type EffectDefinition, type EmptyUsesState, type EnvValueType, type ExecutionState, type FileChunk, type FilePart, type FileRecord, type FileStats, type FileStorage, type FindResult, type GetMessagesOptions, type GlobalNamespaceContext, type GrepResult, type HookContext, type HookDefinition, type HookDefinitionOptions, type HookDefinitionResult, type HookMessage, type HookName, type HookSignatures, type HookToolCall, type HookToolResult, type ImageContent, type ImagePart, type ImageUrlPart, type InferProviderOptions, type InjectMessageInput, type InspectedRequest, type LLMMessage, type LLMProviderInterface, type MarkedThreadEndpoint, type Message, type MessageUpdates, type MessagesResult, type ModelCapabilities, type ModelDefinition, type ModelProvider, type NamespaceContext, type PackageSignature, type PackedExports, type PackedMeta, type PackedMetadata, type PackedNamespaceContext, type PromptContent, type PromptDefinition, type PromptEnvPart, type PromptIncludePart, type PromptInput, type PromptPart, type PromptTextPart, type PromptToolConfig, type ProviderAssistantMessage, type ProviderAttachment, ProviderError, type ProviderErrorCode, type ProviderExecutedToolResult, type ProviderFactory, type ProviderFactoryConfig, type ProviderFactoryWithOptions, type ProviderFinishReason, type ProviderGeneratedImage, type ProviderInstance, type ProviderMessage, type ProviderMessageContent, type ProviderModelInfo, type ProviderModelsPage, type ProviderModelsQuery, type ProviderReasoningDetail, type ProviderRequest, type ProviderResponse, type ProviderStreamChunk, type ProviderSystemMessage, type ProviderTool, type ProviderToolCallPart, type ProviderToolMessage, type ProviderToolResultContent, type ProviderUsage, type ProviderUserMessage, type ProviderWebSearchResult, type QueueMessageInput, type ReadFileStreamOptions, type ReaddirResult, type ReasoningConfig, type ResolveUsesState, type ResponseSummary, type ScheduledEffect, type SessionToolBinding, type SessionToolConfig, type SetEnvOptions, type SideConfig, type StopSessionOptions, type StructuredPrompt, type SubagentRegistryEntry, type SubagentToolConfig, type SubpromptConfig, THREAD_ENDPOINT_SYMBOL, type TenvRawShape, type TextContent, type TextPart, type ThreadEndpointHandler, type ThreadEndpointRouteParams, type ThreadMetadata, type ThreadState, type Tool, type ToolArgs, type ToolArgsNode, type ToolArgsRawShape, type ToolAttachment, type ToolConfig, type ToolContent, type ToolDefinition, type ToolResult, type ToolTenvs, type ToolVariables, type UsesAwareExecute, type UsesConstrainedState, type VariableDefinition, type VariableType, type VirtualModuleLoader, type VirtualModuleRegistry, type WriteFileOptions, belongsToPackage, defineAgent, defineController, defineEffect, defineHook, defineModel, definePrompt, defineThreadEndpoint, defineTool, isPacked, isThreadEndpoint, isVisibleInNamespace, mapReasoningLevel, validateToolName };
5064
+ export { type AgentDefinition, type AgentType, type AttachmentRef, type ClientToolRequest, type ClientToolResponse, type CodeExecution, type CodeExecutionError, type CodeExecutionLog, type CodeExecutionOptions, type CodeExecutionResult, type CodeExecutionStatus, type ContentPart, type Controller, type ControllerContext, type ControllerReturn, type DefineToolOptions, type DefinitionLoader, type Effect, type EffectDefinition, type EmptyUsesState, type EnvValueType, type ExecutionState, type FileChunk, type FilePart, type FileRecord, type FileStats, type FileStorage, type FindResult, type GetMessagesOptions, type GlobalNamespaceContext, type GrepResult, type HookContext, type HookDefinition, type HookDefinitionOptions, type HookDefinitionResult, type HookMessage, type HookName, type HookSignatures, type HookToolCall, type HookToolResult, type ImageContent, type ImagePart, type ImageUrlPart, type InferProviderOptions, type InjectMessageInput, type InspectedRequest, type LLMMessage, type LLMProviderInterface, type MarkedThreadEndpoint, type Message, type MessageUpdates, type MessagesResult, type ModelCapabilities, type ModelDefinition, type ModelProvider, type NamespaceContext, type PackageSignature, type PackedExports, type PackedMeta, type PackedMetadata, type PackedNamespaceContext, type PromptContent, type PromptDefinition, type PromptEnvPart, type PromptIncludePart, type PromptInput, type PromptPart, type PromptTextPart, type PromptToolConfig, type ProviderAssistantMessage, type ProviderAttachment, type ProviderConfigSlot, type ProviderConfigSlots, type ProviderConfigValueSource, type ProviderDefinition, ProviderError, type ProviderErrorCode, type ProviderExecutedToolResult, type ProviderFactory, type ProviderFactoryConfig, type ProviderFactoryWithOptions, type ProviderFinishReason, type ProviderGeneratedImage, type ProviderInstance, type ProviderMessage, type ProviderMessageContent, type ProviderMethodOverrides, type ProviderModelInfo, type ProviderModelsPage, type ProviderModelsQuery, type ProviderOverride, type ProviderOverrideContext, type ProviderReasoningDetail, type ProviderRequest, type ProviderResponse, type ProviderStreamChunk, type ProviderSyncOverride, type ProviderSystemMessage, type ProviderTool, type ProviderToolCallPart, type ProviderToolMessage, type ProviderToolResultContent, type ProviderUsage, type ProviderUserMessage, type ProviderWebSearchResult, type QueueMessageInput, type ReadFileStreamOptions, type ReaddirResult, type ReasoningConfig, type ResolveUsesState, type ResponseSummary, type ScheduledEffect, type SessionToolBinding, type SessionToolConfig, type SetEnvOptions, type SideConfig, type SkillFileInput, type SkillMetadata, type SkillsNamespace, type StopSessionOptions, type StructuredPrompt, type SubagentRegistryEntry, type SubagentToolConfig, type SubpromptConfig, THREAD_ENDPOINT_SYMBOL, THREAD_STREAM_REASONING_PARAM, type TenvRawShape, type TextContent, type TextPart, type ThreadEndpointHandler, type ThreadEndpointRouteParams, type ThreadMessageChunkEvent, type ThreadMetadata, type ThreadReasoningChunkEvent, type ThreadState, type ThreadUser, type Tool, type ToolArgs, type ToolArgsNode, type ToolArgsRawShape, type ToolAttachment, type ToolConfig, type ToolContent, type ToolDefinition, type ToolResult, type ToolTenvs, type ToolVariables, type UsesAwareExecute, type UsesConstrainedState, type VariableDefinition, type VariableType, type VirtualModuleLoader, type VirtualModuleRegistry, type WriteFileOptions, belongsToPackage, defineAgent, defineController, defineEffect, defineHook, defineModel, definePrompt, defineProvider, defineThreadEndpoint, defineTool, isPacked, isThreadEndpoint, isVisibleInNamespace, mapReasoningLevel, providerConst, providerEnv, providerValue, validateToolName };