@cloudflare/think 0.7.3 → 0.8.1

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/think.d.ts CHANGED
@@ -1,1165 +1,67 @@
1
+ import { h as WorkspaceLike } from "./workspace-BZXdZcuw.js";
1
2
  import {
2
- i as ExtensionManifest,
3
- t as ExtensionManager
4
- } from "./manager-DCbSiSWT.js";
5
- import { WorkspaceLike } from "./tools/workspace.js";
6
- import {
7
- LanguageModel,
8
- ModelMessage,
9
- PrepareStepFunction,
10
- PrepareStepFunction as PrepareStepFunction$1,
11
- PrepareStepResult,
12
- PrepareStepResult as PrepareStepResult$1,
13
- StepResult,
14
- StopCondition,
15
- StopCondition as StopCondition$1,
16
- StreamTextOnChunkCallback,
17
- StreamTextOnStepFinishCallback,
18
- TextStreamPart,
19
- ToolSet,
20
- TypedToolCall,
21
- TypedToolCall as TypedToolCall$1,
22
- TypedToolResult,
23
- UIMessage,
24
- streamText
25
- } from "ai";
26
- import {
27
- Agent,
28
- FiberContext,
29
- FiberRecoveryContext,
30
- FiberRecoveryContext as FiberRecoveryContext$1
31
- } from "agents";
32
- import {
33
- ChatRecoveryContext,
34
- ChatRecoveryContext as ChatRecoveryContext$1,
35
- ChatRecoveryOptions,
36
- ChatRecoveryOptions as ChatRecoveryOptions$1,
37
- ChatResponseResult,
38
- ChatResponseResult as ChatResponseResult$1,
39
- ClientToolSchema,
40
- MessageConcurrency,
41
- MessageConcurrency as MessageConcurrency$1,
42
- ResumableStream,
43
- SaveMessagesOptions,
44
- SaveMessagesOptions as SaveMessagesOptions$1,
45
- SaveMessagesResult,
46
- SaveMessagesResult as SaveMessagesResult$1
47
- } from "agents/chat";
48
- import {
49
- Session,
50
- Session as Session$1
51
- } from "agents/experimental/memory/session";
52
- import { Workspace } from "@cloudflare/shell";
53
-
54
- //#region src/think.d.ts
55
- type ChatRecoveryRetryData = {
56
- targetUserId?: string;
57
- originalRequestId?: string;
58
- lastBody?: Record<string, unknown> | null;
59
- lastClientTools?: ClientToolSchema[] | null;
60
- recoveredRequestId?: string;
61
- };
62
- type ChatRecoveryContinueData = {
63
- targetAssistantId?: string;
64
- originalRequestId?: string;
65
- lastBody?: Record<string, unknown> | null;
66
- lastClientTools?: ClientToolSchema[] | null;
67
- recoveredRequestId?: string;
68
- };
69
- /**
70
- * Callback interface for streaming chat events from a Think sub-agent.
71
- *
72
- * Designed to work across the sub-agent RPC boundary — implement as
73
- * an RpcTarget in the parent agent and pass to `chat()`.
74
- */
75
- interface ChatStartEvent {
76
- requestId: string;
77
- }
78
- interface StreamCallback {
79
- onStart?(event: ChatStartEvent): void | Promise<void>;
80
- onEvent(json: string): void | Promise<void>;
81
- onDone(): void | Promise<void>;
82
- onError?(error: string): void | Promise<void>;
83
- }
84
- /**
85
- * Minimal interface for the result of the inference loop.
86
- * The AI SDK's `streamText()` result satisfies this interface.
87
- */
88
- interface StreamableResult {
89
- toUIMessageStream(options?: {
90
- sendReasoning?: boolean;
91
- }): AsyncIterable<unknown>;
92
- }
93
- /**
94
- * Options for a chat turn (sub-agent RPC entry point).
95
- */
96
- interface ChatOptions {
97
- signal?: AbortSignal;
98
- }
99
- type AgentToolChildRunStatus =
100
- | "starting"
101
- | "running"
102
- | "completed"
103
- | "error"
104
- | "aborted";
105
- type AgentToolRunInspection<Output = unknown> = {
106
- runId: string;
107
- status: AgentToolChildRunStatus;
108
- requestId?: string;
109
- streamId?: string;
110
- output?: Output;
111
- summary?: string;
112
- error?: string;
113
- startedAt: number;
114
- completedAt?: number;
115
- };
116
- type AgentToolStoredChunk = {
117
- sequence: number;
118
- body: string;
119
- };
120
- type ThinkSubmissionStatus =
121
- | "pending"
122
- | "running"
123
- | "completed"
124
- | "aborted"
125
- | "skipped"
126
- | "error";
127
- type SubmitMessagesOptions = {
128
- submissionId?: string;
129
- idempotencyKey?: string;
130
- metadata?: Record<string, unknown>;
131
- };
132
- type ThinkSubmissionInspection = {
133
- submissionId: string;
134
- idempotencyKey?: string;
135
- requestId?: string;
136
- status: ThinkSubmissionStatus;
137
- error?: string;
138
- metadata?: Record<string, unknown>;
139
- createdAt: number;
140
- startedAt?: number;
141
- completedAt?: number;
142
- };
143
- type SubmitMessagesResult = ThinkSubmissionInspection & {
144
- accepted: boolean;
145
- };
146
- type ListSubmissionsOptions = {
147
- status?: ThinkSubmissionStatus | ThinkSubmissionStatus[];
148
- limit?: number;
149
- };
150
- type DeleteSubmissionsOptions = {
151
- status?: ThinkSubmissionStatus | ThinkSubmissionStatus[];
152
- completedBefore?: Date;
153
- limit?: number;
154
- };
155
- /**
156
- * A chat turn request. Built automatically by each entry path
157
- * (WebSocket, chat(), saveMessages, auto-continuation) and passed
158
- * to Think's inference loop.
159
- */
160
- interface TurnInput {
161
- signal?: AbortSignal;
162
- /** Client-provided tool schemas for dynamic tool registration. */
163
- clientTools?: ClientToolSchema[];
164
- /** Custom body fields from the client request. */
165
- body?: Record<string, unknown>;
166
- /** Whether this is a continuation turn (auto-continue after tool result, recovery). */
167
- continuation: boolean;
168
- }
169
- /**
170
- * Context passed to the `beforeTurn` hook.
171
- * Contains everything Think assembled — the hook can inspect and override.
172
- */
173
- interface TurnContext {
174
- /** Assembled system prompt (from context blocks or getSystemPrompt fallback). */
175
- system: string;
176
- /** Assembled model messages (truncated, pruned). */
177
- messages: ModelMessage[];
178
- /** Merged tool set (workspace + getTools + session + MCP + client + caller). */
179
- tools: ToolSet;
180
- /** The language model from getModel(). */
181
- model: LanguageModel;
182
- /** Whether this is a continuation turn. */
183
- continuation: boolean;
184
- /** Custom body fields from the client request. */
185
- body?: Record<string, unknown>;
186
- }
187
- /**
188
- * Configuration returned by the `beforeTurn` hook to override defaults.
189
- * All fields are optional — return only what you want to change.
190
- */
191
- interface TurnConfig {
192
- /** Override the model for this turn (e.g. cheap model for continuations). */
193
- model?: LanguageModel;
194
- /** Override the assembled system prompt. */
195
- system?: string;
196
- /** Override the assembled messages. */
197
- messages?: ModelMessage[];
198
- /** Extra tools to merge (additive — spread on top of existing tools). */
199
- tools?: ToolSet;
200
- /** Limit which tools the model can call (AI SDK activeTools). */
201
- activeTools?: string[];
202
- /** Force a specific tool call (AI SDK toolChoice). */
203
- toolChoice?: Parameters<typeof streamText>[0]["toolChoice"];
204
- /** Override maxSteps for this turn. */
205
- maxSteps?: number;
206
- /**
207
- * Additional AI SDK stop conditions for ending the turn early.
208
- * Think always keeps its `maxSteps` stop condition as a safety bound.
209
- */
210
- stopWhen?: StopCondition$1<ToolSet> | Array<StopCondition$1<ToolSet>>;
211
- /**
212
- * Controls whether reasoning chunks are included in the UI message stream
213
- * for this turn. Defaults to the instance-level `sendReasoning` setting.
214
- */
215
- sendReasoning?: boolean;
216
- /** Maximum number of tokens to generate for this turn. */
217
- maxOutputTokens?: Parameters<typeof streamText>[0]["maxOutputTokens"];
218
- /** Temperature setting for this turn. */
219
- temperature?: Parameters<typeof streamText>[0]["temperature"];
220
- /** Nucleus sampling setting for this turn. */
221
- topP?: Parameters<typeof streamText>[0]["topP"];
222
- /** Top-K sampling setting for this turn. */
223
- topK?: Parameters<typeof streamText>[0]["topK"];
224
- /** Presence penalty setting for this turn. */
225
- presencePenalty?: Parameters<typeof streamText>[0]["presencePenalty"];
226
- /** Frequency penalty setting for this turn. */
227
- frequencyPenalty?: Parameters<typeof streamText>[0]["frequencyPenalty"];
228
- /** Stop sequences for this turn. */
229
- stopSequences?: Parameters<typeof streamText>[0]["stopSequences"];
230
- /** Seed for deterministic sampling when supported by the model. */
231
- seed?: Parameters<typeof streamText>[0]["seed"];
232
- /** Maximum number of retries for this turn. Set to 0 to disable retries. */
233
- maxRetries?: Parameters<typeof streamText>[0]["maxRetries"];
234
- /** Timeout configuration for this turn. */
235
- timeout?: Parameters<typeof streamText>[0]["timeout"];
236
- /** Additional HTTP headers for provider requests on this turn. */
237
- headers?: Parameters<typeof streamText>[0]["headers"];
238
- /** Provider-specific options (AI SDK providerOptions). */
239
- providerOptions?: Record<string, unknown>;
240
- /** Optional AI SDK telemetry configuration for this turn. */
241
- experimental_telemetry?: Parameters<
242
- typeof streamText
243
- >[0]["experimental_telemetry"];
244
- /**
245
- * Optional structured-output specification (AI SDK `output`).
246
- * Forwarded to `streamText` so the model's final response is parsed
247
- * against the supplied schema. Use the AI SDK's `Output.object({ schema })`
248
- * / `Output.text()` helpers. Combine with `activeTools: []` on the
249
- * terminal turn if your provider strips tools when structured output
250
- * is active (e.g. workers-ai-provider).
251
- */
252
- output?: Parameters<typeof streamText>[0]["output"];
253
- }
254
- /**
255
- * Context passed to the `beforeStep` hook before each AI SDK step in
256
- * the agentic loop. Backed by the AI SDK's `PrepareStepFunction<TOOLS>`
257
- * parameter — exposes the previous `steps`, the zero-based `stepNumber`,
258
- * the currently selected `model`, the `messages` about to be sent, and
259
- * `experimental_context`.
260
- *
261
- * Pass an explicit `TOOLS` generic for typed previous tool calls / results.
262
- *
263
- * Limitations (AI SDK boundary, not Think):
264
- * - No `abortSignal` is exposed in the context. If you do remote work
265
- * inside `beforeStep`, it cannot be cancelled by turn-level abort.
266
- * - `experimental_context` is typed `unknown`; users must narrow it.
267
- * - `output` cannot be overridden per-step — set it at the turn level
268
- * via `TurnConfig.output` (returned from `beforeTurn`).
269
- */
270
- type PrepareStepContext<TOOLS extends ToolSet = ToolSet> = Parameters<
271
- PrepareStepFunction$1<TOOLS>
272
- >[0];
273
- /**
274
- * Configuration returned by `beforeStep` to override defaults for the
275
- * current AI SDK step. This is the AI SDK's `PrepareStepResult<TOOLS>` —
276
- * return only the fields you want to override (`model`, `toolChoice`,
277
- * `activeTools`, `system`, `messages`, `experimental_context`,
278
- * `providerOptions`).
279
- */
280
- type StepConfig<TOOLS extends ToolSet = ToolSet> = PrepareStepResult$1<TOOLS>;
281
- /**
282
- * Context passed to the `beforeToolCall` hook **before** the tool's
283
- * `execute` function runs.
284
- *
285
- * Backed by the AI SDK's `OnToolCallStartEvent` (the parameter of
286
- * `experimental_onToolCallStart`). The full `TypedToolCall<TOOLS>`
287
- * fields (`toolName`, `toolCallId`, `input`, `providerMetadata`, the
288
- * dynamic/invalid/error discriminators) are spread at the top level for
289
- * convenience, with the per-call event extras attached:
290
- *
291
- * - `stepNumber` — index of the current step
292
- * - `messages` — conversation messages visible at tool execution time
293
- * - `abortSignal` — signal that aborts if the turn is cancelled
294
- *
295
- * Pass an explicit `TOOLS` generic for full input typing:
296
- *
297
- * ```ts
298
- * import type { ToolCallContext } from "@cloudflare/think";
299
- * import type { tools } from "./my-tools";
300
- *
301
- * beforeToolCall(ctx: ToolCallContext<typeof tools>) {
302
- * if (ctx.toolName === "search") {
303
- * ctx.input.query; // typed
304
- * }
305
- * }
306
- * ```
307
- */
308
- type ToolCallContext<TOOLS extends ToolSet = ToolSet> =
309
- TypedToolCall$1<TOOLS> & {
310
- /** Zero-based index of the current step where this tool call occurs. */ readonly stepNumber:
311
- | number
312
- | undefined /** The conversation messages available at tool execution time. */;
313
- readonly messages: ReadonlyArray<ModelMessage> /** Signal for cancelling the operation. */;
314
- readonly abortSignal: AbortSignal | undefined;
315
- };
316
- /**
317
- * Decision returned by `beforeToolCall` to control tool execution.
318
- * Return void/undefined to allow execution with original input.
319
- *
320
- * Discriminated union — each action has a clear, non-overlapping meaning:
321
- * - `allow` — execute the tool (optionally with modified input)
322
- * - `block` — don't execute; return `reason` as the tool result so the model can adjust
323
- * - `substitute` — don't execute; return `output` as the tool result (afterToolCall still fires)
324
- */
325
- type ToolCallDecision =
326
- | {
327
- action: "allow" /** Modified input — tool executes with this instead of the original. */;
328
- input?: Record<string, unknown>;
329
- }
330
- | {
331
- action: "block" /** Returned as the tool result so the model can adjust. */;
332
- reason?: string;
333
- }
334
- | {
335
- action: "substitute" /** The substitute tool output — model sees this instead of real execution. */;
336
- output: unknown /** Optional input attribution for the afterToolCall log. */;
337
- input?: Record<string, unknown>;
338
- };
339
- /**
340
- * Context passed to the `afterToolCall` hook after a tool executes.
341
- *
342
- * Backed by the AI SDK's `OnToolCallFinishEvent` (the parameter of
343
- * `experimental_onToolCallFinish`). The full `TypedToolCall<TOOLS>`
344
- * fields (`toolName`, `toolCallId`, `input`, …) are spread at the top
345
- * level, plus the per-call event extras:
346
- *
347
- * - `stepNumber` — index of the current step
348
- * - `messages` — conversation messages visible at tool execution time
349
- * - `durationMs` — wall-clock execution time in milliseconds
350
- * - `success`/`output`/`error` — discriminated outcome:
351
- * - on success: `success: true`, `output: unknown`
352
- * - on failure: `success: false`, `error: unknown`
353
- *
354
- * Pass an explicit `TOOLS` generic for full input typing:
355
- *
356
- * ```ts
357
- * import type { ToolCallResultContext } from "@cloudflare/think";
358
- * import type { tools } from "./my-tools";
359
- *
360
- * afterToolCall(ctx: ToolCallResultContext<typeof tools>) {
361
- * if (ctx.success) {
362
- * console.log(`${ctx.toolName} took ${ctx.durationMs}ms`, ctx.output);
363
- * } else {
364
- * console.error(`${ctx.toolName} failed:`, ctx.error);
365
- * }
366
- * }
367
- * ```
368
- */
369
- type ToolCallResultContext<TOOLS extends ToolSet = ToolSet> =
370
- TypedToolCall$1<TOOLS> & {
371
- readonly stepNumber: number | undefined;
372
- readonly messages: ReadonlyArray<ModelMessage> /** Wall-clock execution time in milliseconds. */;
373
- readonly durationMs: number;
374
- } & (
375
- | {
376
- readonly success: true;
377
- readonly output: unknown;
378
- readonly error?: never;
379
- }
380
- | {
381
- readonly success: false;
382
- readonly output?: never;
383
- readonly error: unknown;
384
- }
385
- );
386
- /**
387
- * Context passed to the `onStepFinish` hook after each step completes.
388
- *
389
- * This is the AI SDK's `StepResult<TOOLS>` (= `OnStepFinishEvent<TOOLS>`) —
390
- * the full step record including `text`, `reasoning`, `toolCalls`,
391
- * `toolResults`, `files`, `sources`, `usage` (with `cachedInputTokens`,
392
- * `reasoningTokens`, `totalTokens`), `finishReason`, `warnings`, `request`,
393
- * `response`, and `providerMetadata` (where provider-specific cache
394
- * accounting like `cacheCreationInputTokens` lives).
395
- *
396
- * Pass an explicit `TOOLS` generic for typed `toolCalls`/`toolResults`.
397
- */
398
- type StepContext<TOOLS extends ToolSet = ToolSet> = Parameters<
399
- StreamTextOnStepFinishCallback<TOOLS>
400
- >[0];
401
- /**
402
- * Context passed to the `onChunk` hook for each streaming chunk.
403
- *
404
- * This is the AI SDK's `StreamTextOnChunkCallback` event — `{ chunk }`
405
- * where `chunk` is a discriminated union of `TextStreamPart` variants
406
- * (text-delta, reasoning-delta, source, tool-call, tool-input-start,
407
- * tool-input-delta, tool-result, raw).
408
- */
409
- type ChunkContext<TOOLS extends ToolSet = ToolSet> = Parameters<
410
- StreamTextOnChunkCallback<TOOLS>
411
- >[0];
412
- /**
413
- * @internal Re-export of the chunk variant union for consumers that need
414
- * to narrow on `chunk.type` without importing `TextStreamPart` directly.
415
- */
416
- type ChunkPart<TOOLS extends ToolSet = ToolSet> = ChunkContext<TOOLS>["chunk"];
417
- /**
418
- * Configuration for a sandboxed extension, returned by getExtensions().
419
- */
420
- interface ExtensionConfig {
421
- /** Extension manifest (name, version, permissions, contributions). */
422
- manifest: ExtensionManifest;
423
- /** JavaScript source code defining the extension's tools. */
424
- source: string;
425
- }
426
- /**
427
- * An opinionated chat agent base class.
428
- *
429
- * @experimental The API surface may change before stabilizing.
430
- */
431
- declare class Think<
432
- Env extends Cloudflare.Env = Cloudflare.Env,
433
- State = unknown,
434
- Props extends Record<string, unknown> = Record<string, unknown>
435
- > extends Agent<Env, State, Props> {
436
- #private;
437
- private static readonly CONFIG_KEYS;
438
- /**
439
- * Wait for MCP server connections to be ready before the inference
440
- * loop. MCP tools are auto-merged into the tool set.
441
- *
442
- * Set to `true` for a default 10s timeout, or `{ timeout: ms }`
443
- * for a custom timeout. Defaults to `false` (no waiting).
444
- */
445
- waitForMcpConnections:
446
- | boolean
447
- | {
448
- timeout: number;
449
- };
450
- /**
451
- * Controls how overlapping user submit requests behave while another
452
- * chat turn is already active or queued.
453
- *
454
- * @default "queue"
455
- */
456
- messageConcurrency: MessageConcurrency$1;
457
- /**
458
- * When true, chat turns are wrapped in `runFiber` for durable execution.
459
- * Enables `onChatRecovery` hook and `this.stash()` during streaming.
460
- */
461
- chatRecovery: boolean;
462
- static readonly CHAT_FIBER_NAME = "__cf_internal_chat_turn";
463
- /**
464
- * The conversation session — messages, context, compaction, search.
465
- *
466
- * Direct message writes are observed and mirrored into Think's live cache.
467
- * Prefer the history helpers below when writing UI messages from subclasses;
468
- * they sanitize content and enforce row-size limits before delegating here.
469
- */
470
- session: Session$1;
471
- /** Cached messages — kept in sync with session storage. */
472
- private _cachedMessages;
473
- /**
474
- * WorkerLoader binding for sandboxed extensions.
475
- * Set this to enable `getExtensions()` and dynamic extension loading.
476
- */
477
- extensionLoader?: WorkerLoader;
478
- /**
479
- * Extension manager — created automatically when `extensionLoader` is set.
480
- * Use for dynamic `load()` / `unload()` at runtime.
481
- */
482
- extensionManager?: ExtensionManager;
483
- /**
484
- * Workspace filesystem available in `getTools()` and lifecycle hooks.
485
- * Defaults to a full `Workspace` backed by the DO's SQLite storage.
486
- *
487
- * Typed as `WorkspaceLike` rather than `Workspace` so subclasses can
488
- * replace it with anything that satisfies the interface — e.g. a proxy
489
- * that forwards to a shared workspace owned by a parent DO. Override as
490
- * a class field to skip the default init entirely:
491
- *
492
- * ```typescript
493
- * // Default init with R2 spillover for large files.
494
- * override workspace = new Workspace({
495
- * sql: this.ctx.storage.sql,
496
- * r2: this.env.R2,
497
- * name: () => this.name
498
- * });
499
- *
500
- * // Or a custom WorkspaceLike — e.g. a parent-owned shared workspace.
501
- * override workspace: WorkspaceLike = new SharedWorkspace(this);
502
- * ```
503
- */
504
- workspace: WorkspaceLike;
505
- constructor(ctx: DurableObjectState, env: Env);
506
- /**
507
- * Conversation history as Think's live in-memory view.
508
- *
509
- * Storage remains the durable source of truth, but runtime logic should read
510
- * through this cache so in-flight turns, tool updates, and recovery state all
511
- * observe the same message list. Use `_syncMessages()` only at safe
512
- * boundaries where a full storage reread cannot drop in-flight state.
513
- */
514
- get messages(): UIMessage[];
515
- /** Read the durable message path from session storage. */
516
- private _readMessagesFromStorage;
517
- /** Replace the live cache with a durable storage snapshot. */
518
- private _replaceCachedMessages;
519
- /** Refresh the live cache from durable storage at a safe boundary. */
520
- private _syncMessages;
521
- /** Patch or append one message in the live cache after a durable write. */
522
- private _upsertCachedMessage;
523
- /** Patch a message that is already present in the live cache. */
524
- private _patchCachedMessage;
525
- private _appendMessageToHistory;
526
- private _updateMessageInHistory;
527
- private _upsertMessageInHistory;
528
- private _clearHistory;
529
- /** Append a message while keeping Think's live message cache coherent. */
530
- protected appendMessageToHistory(
531
- message: UIMessage,
532
- parentId?: string | null
533
- ): Promise<UIMessage>;
534
- /** Update a message while keeping Think's live message cache coherent. */
535
- protected updateMessageInHistory(message: UIMessage): Promise<UIMessage>;
536
- /** Refresh Think's live message cache from the durable session path. */
537
- protected syncMessagesFromStorage(): Promise<UIMessage[]>;
538
- private _aborts;
539
- private _turnQueue;
540
- protected _resumableStream: ResumableStream;
541
- private _pendingResumeConnections;
542
- private _lastClientTools;
543
- private _lastBody;
544
- private _continuation;
545
- private _continuationTimer;
546
- private _insideResponseHook;
547
- private _insideInferenceLoop;
548
- private _pendingInteractionPromise;
549
- private _submitConcurrency;
550
- private static MESSAGE_DEBOUNCE_MS;
551
- private _agentToolForwarders;
552
- private _agentToolClosers;
553
- private _agentToolAbortControllers;
554
- private _agentToolLastErrors;
555
- private _agentToolPreTurnAssistantIds;
556
- private _agentToolLiveSequences;
557
- private _submissionTableEnsured;
558
- private _drainingSubmissions;
559
- private _submissionAbortControllers;
560
- private _programmaticStreamErrors;
561
- protected static submissionRecoveryStaleMs: number;
562
- broadcast(
563
- msg: string | ArrayBuffer | ArrayBufferView,
564
- without?: string[]
565
- ): void;
566
- /**
567
- * Persist an arbitrary JSON-serializable configuration object for this
568
- * agent instance. Stored in the Think-private `think_config` table —
569
- * survives
570
- * restarts and hibernation. Pass the config shape as a method generic
571
- * for typed call sites:
572
- *
573
- * ```ts
574
- * this.configure<MyConfig>({ modelTier: "fast" });
575
- * ```
576
- *
577
- * Prefer `state` / `setState` from `Agent` when you want the value
578
- * broadcast to connected clients. Use `configure` for private
579
- * per-instance config that should stay server-side.
580
- */
581
- configure<T = Record<string, unknown>>(config: T): void;
582
- /**
583
- * Read the persisted configuration, or null if never configured.
584
- * Pass the config shape as a method generic for a typed result:
585
- *
586
- * ```ts
587
- * const cfg = this.getConfig<MyConfig>();
588
- * ```
589
- */
590
- getConfig<T = Record<string, unknown>>(): T | null;
591
- protected _migrateLegacyConfigToThinkTable(): void;
592
- private _ensureConfigTable;
593
- private _configSet;
594
- private _configGet;
595
- private _configDelete;
596
- /**
597
- * Return the language model to use for inference.
598
- * Must be overridden by subclasses.
599
- */
600
- getModel(): LanguageModel;
601
- /**
602
- * Return the system prompt for the assistant.
603
- * Used as fallback when no context blocks are configured via `configureSession`.
604
- */
605
- getSystemPrompt(): string;
606
- /** Return the tools available to the assistant. */
607
- getTools(): ToolSet;
608
- private _runChatRecoveryFiber;
609
- private _systemPromptForTurn;
610
- private _buildThinkCapabilityBlock;
611
- /** Maximum number of tool-call steps per turn. Override via property or per-turn via TurnConfig. */
612
- maxSteps: number;
613
- /**
614
- * Whether reasoning chunks are sent to chat clients by default. Override
615
- * per turn by returning `sendReasoning` from `beforeTurn`.
616
- */
617
- sendReasoning: boolean;
618
- /**
619
- * Configure the session. Called once during `onStart`.
620
- * Override to add context blocks, compaction, search, skills.
621
- *
622
- * @example
623
- * ```typescript
624
- * configureSession(session: Session) {
625
- * return session
626
- * .withContext("memory", { description: "Learned facts", maxTokens: 2000 })
627
- * .withCachedPrompt();
628
- * }
629
- * ```
630
- */
631
- configureSession(session: Session$1): Session$1 | Promise<Session$1>;
632
- /**
633
- * Return sandboxed extension configurations. Defines load order,
634
- * which determines hook execution order.
635
- * Requires `extensionLoader` to be set.
636
- */
637
- getExtensions(): ExtensionConfig[];
638
- /**
639
- * Called before `streamText` — inspect the assembled context and
640
- * return overrides. Think assembles tools, system prompt, and messages
641
- * internally; this hook sees the result and can override any part.
642
- *
643
- * Return `void` to accept all defaults.
644
- *
645
- * @example Switch model for continuations
646
- * ```typescript
647
- * beforeTurn(ctx: TurnContext) {
648
- * if (ctx.continuation) return { model: this.cheapModel };
649
- * }
650
- * ```
651
- *
652
- * @example Restrict active tools
653
- * ```typescript
654
- * beforeTurn(ctx: TurnContext) {
655
- * return { activeTools: ["read", "write"] };
656
- * }
657
- * ```
658
- */
659
- beforeTurn(_ctx: TurnContext): TurnConfig | void | Promise<TurnConfig | void>;
660
- /**
661
- * Called before each AI SDK step in the agentic loop. Backed by
662
- * `streamText({ prepareStep })`.
663
- *
664
- * Return `void` to accept the current step defaults, or return a
665
- * `StepConfig` to override the model, tool choice, active tools,
666
- * system prompt, messages, experimental context, or provider options
667
- * for this step. Use `beforeTurn` for turn-wide assembly and
668
- * `beforeStep` when the decision depends on the step number or
669
- * previous step results.
670
- *
671
- * @example Force search on the first step
672
- * ```typescript
673
- * beforeStep(ctx: PrepareStepContext) {
674
- * if (ctx.stepNumber === 0) {
675
- * return {
676
- * activeTools: ["search"],
677
- * toolChoice: { type: "tool", toolName: "search" }
678
- * };
679
- * }
680
- * }
681
- * ```
682
- *
683
- * @example Switch to a cheaper model after tool results land
684
- * ```typescript
685
- * beforeStep(ctx: PrepareStepContext) {
686
- * // assumes a `fastSummaryModel` field on your Think subclass
687
- * if (ctx.steps.some((s) => s.toolResults.length > 0)) {
688
- * return { model: this.fastSummaryModel };
689
- * }
690
- * }
691
- * ```
692
- */
693
- beforeStep(
694
- _ctx: PrepareStepContext
695
- ): StepConfig | void | Promise<StepConfig | void>;
696
- /**
697
- * Called **before** the tool's `execute` function runs. Think wraps
698
- * every tool's `execute` so it can consult this hook and act on the
699
- * returned `ToolCallDecision`:
700
- *
701
- * - `void` (or `{ action: "allow" }` with no `input`) — run the
702
- * original `execute` with the original input.
703
- * - `{ action: "allow", input }` — run the original `execute` with
704
- * the substituted input.
705
- * - `{ action: "block", reason }` — skip `execute`; the model sees
706
- * `reason` as the tool's output.
707
- * - `{ action: "substitute", output }` — skip `execute`; the model
708
- * sees `output` as the tool's output.
709
- *
710
- * Only fires for server-side tools (tools with `execute`). Client
711
- * tools are handled on the client — Think can't intercept them.
712
- *
713
- * `afterToolCall` always fires after this hook (or after the original
714
- * `execute` when `allow`). For `block`/`substitute`, the substituted
715
- * value flows through `afterToolCall` as `success: true, output: ...`.
716
- *
717
- * @example Log tool calls
718
- * ```typescript
719
- * beforeToolCall(ctx: ToolCallContext) {
720
- * console.log(`Tool called: ${ctx.toolName}`, ctx.input);
721
- * }
722
- * ```
723
- *
724
- * @example Block a tool the model shouldn't be calling here
725
- * ```typescript
726
- * beforeToolCall(ctx: ToolCallContext): ToolCallDecision | void {
727
- * if (ctx.toolName === "delete" && this.isReadOnlyMode) {
728
- * return { action: "block", reason: "delete is disabled in read-only mode" };
729
- * }
730
- * }
731
- * ```
732
- *
733
- * @example Substitute a cached result
734
- * ```typescript
735
- * async beforeToolCall(ctx: ToolCallContext): Promise<ToolCallDecision | void> {
736
- * if (ctx.toolName === "weather") {
737
- * const cached = await this.cache.get(JSON.stringify(ctx.input));
738
- * if (cached) return { action: "substitute", output: cached };
739
- * }
740
- * }
741
- * ```
742
- */
743
- beforeToolCall(
744
- _ctx: ToolCallContext
745
- ): ToolCallDecision | void | Promise<ToolCallDecision | void>;
746
- /**
747
- * Called **after** a tool's outcome is known — for real executions, for
748
- * `block` (carries the `reason` as `output`), and for `substitute`
749
- * (carries the substituted `output`). Backed by the AI SDK's
750
- * `experimental_onToolCallFinish`, so `durationMs` and the discriminated
751
- * `success`/`output`/`error` outcome reflect what the model actually
752
- * sees: a thrown error from the original `execute` becomes
753
- * `success: false, error: ...`; everything else (including blocked /
754
- * substituted calls) is `success: true, output: ...`.
755
- *
756
- * Override for logging, metrics, or result inspection.
757
- *
758
- * @example
759
- * ```typescript
760
- * afterToolCall(ctx: ToolCallResultContext) {
761
- * if (ctx.success) {
762
- * console.log(`${ctx.toolName} ok in ${ctx.durationMs}ms`);
763
- * } else {
764
- * console.error(`${ctx.toolName} failed:`, ctx.error);
765
- * }
766
- * }
767
- * ```
768
- */
769
- afterToolCall(_ctx: ToolCallResultContext): void | Promise<void>;
770
- /**
771
- * Called after each step completes (initial, continue, tool-result).
772
- * Override for step-level logging or analytics.
773
- */
774
- onStepFinish(_ctx: StepContext): void | Promise<void>;
775
- /**
776
- * Called for each streaming chunk. High-frequency — fires per token.
777
- * Override for streaming analytics, progress indicators, or token counting.
778
- * Observational only (void return).
779
- */
780
- onChunk(_ctx: ChunkContext): void | Promise<void>;
781
- /**
782
- * Called after a chat turn completes and the assistant message has been
783
- * persisted. The turn lock is released before this hook runs, so it is
784
- * safe to call other methods from inside.
785
- *
786
- * Fires for all turn completion paths: WebSocket chat requests,
787
- * sub-agent RPC, and auto-continuation.
788
- *
789
- * Override for logging, chaining, analytics, usage tracking.
790
- */
791
- onChatResponse(_result: ChatResponseResult$1): void | Promise<void>;
792
- /**
793
- * Handle an error that occurred during a chat turn.
794
- * Override to customize error handling (e.g. logging, metrics).
795
- */
796
- onChatError(error: unknown): unknown;
797
- private _initializeExtensions;
798
- /**
799
- * The single convergence point for all chat turn entry paths.
800
- * Merges tools, assembles context, fires lifecycle hooks, wraps tools
801
- * for interception, and calls streamText.
802
- */
803
- private _runInferenceLoop;
804
- /** @internal Test seam — override in test agents to wrap the stream (e.g. error injection). */
805
- protected _transformInferenceResult(
806
- result: StreamableResult
807
- ): StreamableResult;
808
- /** Default hook timeout in milliseconds. */
809
- hookTimeout: number;
810
- /**
811
- * Pipeline beforeTurn through sandboxed extensions in load order.
812
- * Each extension sees the accumulated state from prior extensions
813
- * (snapshot is rebuilt after each extension's modifications).
814
- * Results are merged with last-write-wins for scalar fields.
815
- * Extensions that don't subscribe to beforeTurn are skipped.
816
- */
817
- private _pipelineExtensionBeforeTurn;
818
- /**
819
- * Dispatch an observation hook to all extensions that subscribe to it.
820
- *
821
- * Used by `_pipelineExtensionToolCallStart`, `_pipelineExtensionToolCallFinish`,
822
- * `_pipelineExtensionStepFinish`, and `_pipelineExtensionChunk`. Unlike
823
- * `beforeTurn`, these hooks are observation-only — extensions can't
824
- * influence the turn — so we ignore return values, log errors, and
825
- * apply a per-extension timeout.
826
- *
827
- * `onChunk` is high-frequency (per token) — extensions that subscribe
828
- * to it pay an RPC cost per chunk and should be used sparingly.
829
- */
830
- private _dispatchExtensionObservation;
831
- /**
832
- * Wrap each tool's `execute` function so the agent's `beforeToolCall`
833
- * hook is consulted before the tool runs. The hook can return a
834
- * `ToolCallDecision` to:
835
- *
836
- * - `allow` (default if `void` is returned) — run the original
837
- * `execute`, optionally with a substituted `input`.
838
- * - `block` — skip `execute` and return `reason` (or a default string)
839
- * as the tool result. The model sees this as the tool's output.
840
- * - `substitute` — skip `execute` and return `output` directly. The
841
- * model sees this as the tool's output.
842
- *
843
- * The wrapped `execute` also dispatches the `beforeToolCall`
844
- * observation snapshot to subscribed extensions. `afterToolCall` is
845
- * still wired through the AI SDK's `experimental_onToolCallFinish`
846
- * callback so we get accurate `durationMs` and proper success/error
847
- * discrimination — `block` and `substitute` outcomes show up as
848
- * `success: true` with the substituted output; uncaught throws from
849
- * the original `execute` show up as `success: false` with the error.
850
- *
851
- * Tools without an `execute` (output-schema-only tools, client tools
852
- * routed via `needsApproval`) are left untouched.
853
- *
854
- * **Streaming tools (AsyncIterable):** the AI SDK supports tools whose
855
- * `execute` returns `AsyncIterable<output>` to emit preliminary
856
- * results before a final value. This works whether the iterator is
857
- * returned directly (sync function, `async function*`) or wrapped in
858
- * a Promise (`async function execute(...) { return makeIter(); }`).
859
- * Because the wrapper must `await beforeToolCall` first, preliminary
860
- * chunks are collapsed — only the *final* yielded value reaches the
861
- * model. If you need true preliminary streaming, override
862
- * `getTools()` to provide such tools and avoid using `beforeToolCall`
863
- * for them (or accept the collapse).
864
- */
865
- private _wrapToolsWithDecision;
866
- private _pipelineExtensionToolCallStart;
867
- private _pipelineExtensionToolCallFinish;
868
- private _pipelineExtensionStepFinish;
869
- private _pipelineExtensionChunk;
870
- _hostReadFile(path: string): Promise<string | null>;
871
- _hostWriteFile(path: string, content: string): Promise<void>;
872
- _hostDeleteFile(path: string): Promise<boolean>;
873
- _hostListFiles(dir: string): Promise<
874
- Array<{
875
- name: string;
876
- type: string;
877
- size: number;
878
- path: string;
879
- }>
880
- >;
881
- _hostGetContext(label: string): Promise<string | null>;
882
- _hostSetContext(label: string, content: string): Promise<void>;
883
- _hostGetMessages(limit?: number): Promise<
884
- Array<{
885
- id: string;
886
- role: string;
887
- content: string;
888
- }>
889
- >;
890
- _hostSendMessage(content: string): Promise<void>;
891
- _hostGetSessionInfo(): Promise<{
892
- messageCount: number;
893
- }>;
894
- /**
895
- * Run a chat turn: persist the user message, run the agentic loop,
896
- * stream UIMessageChunk events via callback, and persist the
897
- * assistant's response.
898
- *
899
- * @param userMessage The user's message (string or UIMessage)
900
- * @param callback Streaming callback (typically an RpcTarget from the parent)
901
- * @param options Optional chat options (e.g. AbortSignal)
902
- */
903
- chat(
904
- userMessage: string | UIMessage,
905
- callback: StreamCallback,
906
- options?: ChatOptions
907
- ): Promise<void>;
908
- /** Get the conversation history as UIMessage[]. */
909
- getMessages(): Promise<UIMessage[]>;
910
- /** Clear all messages from storage. */
911
- clearMessages(): Promise<void>;
912
- private _ensureAgentToolChildRunTable;
913
- private _addAgentToolChildRunColumnIfMissing;
914
- private _readAgentToolChildRun;
915
- private _inspectionFromChildRow;
916
- protected formatAgentToolInput(input: unknown): UIMessage;
917
- protected getAgentToolOutput(_runId: string): unknown;
918
- protected getAgentToolSummary(runId: string, output: unknown): string;
919
- startAgentToolRun(
920
- input: unknown,
921
- options: {
922
- runId: string;
923
- }
924
- ): Promise<AgentToolRunInspection>;
925
- cancelAgentToolRun(runId: string, reason?: unknown): Promise<void>;
926
- inspectAgentToolRun(runId: string): Promise<AgentToolRunInspection | null>;
927
- getAgentToolChunks(
928
- runId: string,
929
- options?: {
930
- afterSequence?: number;
931
- }
932
- ): Promise<AgentToolStoredChunk[]>;
933
- tailAgentToolRun(
934
- runId: string,
935
- options?: {
936
- afterSequence?: number;
937
- }
938
- ): Promise<ReadableStream<AgentToolStoredChunk>>;
939
- private static _stringifyAgentToolOutput;
940
- private static _parseAgentToolOutput;
941
- private _getAgentToolFinalText;
942
- private _ensureSubmissionTable;
943
- private _readSubmission;
944
- private _readSubmissionByIdempotencyKey;
945
- private _normalizeStatusFilter;
946
- private _listSubmissionRows;
947
- private _listSubmissionRowsByStatus;
948
- private _inspectionFromSubmissionRow;
949
- private _parseJsonObject;
950
- private _parseSubmissionMessages;
951
- private _serializeSubmissionMessages;
952
- private _serializeMetadata;
953
- private _emitSubmissionStatus;
954
- protected onSubmissionStatus(
955
- _submission: ThinkSubmissionInspection
956
- ): void | Promise<void>;
957
- inspectSubmission(
958
- submissionId: string
959
- ): Promise<ThinkSubmissionInspection | null>;
960
- listSubmissions(
961
- options?: ListSubmissionsOptions
962
- ): Promise<ThinkSubmissionInspection[]>;
963
- deleteSubmission(submissionId: string): Promise<boolean>;
964
- deleteSubmissions(options?: DeleteSubmissionsOptions): Promise<number>;
965
- private _listTerminalSubmissionRowsForDelete;
966
- private _isTerminalSubmissionStatus;
967
- cancelSubmission(submissionId: string, reason?: unknown): Promise<void>;
968
- submitMessages(
969
- messages: UIMessage[],
970
- options?: SubmitMessagesOptions
971
- ): Promise<SubmitMessagesResult>;
972
- private _scheduleSubmissionDrain;
973
- private _startSubmissionDrain;
974
- _drainThinkSubmissions(): Promise<void>;
975
- private _drainSubmissions;
976
- private _runSubmission;
977
- private _getSubmissionFinalStatus;
978
- private _markPendingSubmissionsSkipped;
979
- private _emitSkippedSubmissions;
980
- private _recoverSubmissionsOnStart;
981
- private _getSubmissionMessagesAppliedState;
982
- private _hasRecoverableChatTurn;
983
- private _hasFreshRecoverableSubmissionEvidence;
984
- private _hasScheduledRecoveredContinuation;
985
- /**
986
- * Inject messages and trigger a model turn — without a WebSocket request.
987
- *
988
- * Use for scheduled responses, webhook-triggered turns, proactive agents,
989
- * or chaining from `onChatResponse`.
990
- *
991
- * Accepts static messages or a callback that derives messages from the
992
- * current state (useful when multiple calls queue up — the callback runs
993
- * with the latest messages when the turn actually starts).
994
- *
995
- * Pass `options.signal` to cancel the turn from outside without knowing
996
- * the internally-generated request id. The signal is linked to the
997
- * registry's controller for this turn — when it aborts, the inference
998
- * loop's signal aborts and the result reports `status: "aborted"`.
999
- * Pre-aborted signals short-circuit before any model work runs. See
1000
- * {@link SaveMessagesOptions} for the integration point.
1001
- *
1002
- * @example Scheduled follow-up
1003
- * ```typescript
1004
- * async onScheduled() {
1005
- * await this.saveMessages([{
1006
- * id: crypto.randomUUID(),
1007
- * role: "user",
1008
- * parts: [{ type: "text", text: "Time for your daily summary." }]
1009
- * }]);
1010
- * }
1011
- * ```
1012
- *
1013
- * @example Function form
1014
- * ```typescript
1015
- * await this.saveMessages((current) => [
1016
- * ...current,
1017
- * { id: crypto.randomUUID(), role: "user", parts: [{ type: "text", text: "Continue." }] }
1018
- * ]);
1019
- * ```
1020
- *
1021
- * @example External cancellation (helper-as-sub-agent)
1022
- * ```typescript
1023
- * // Inside a parent agent's tool execute — forward the AI SDK's
1024
- * // abortSignal so a parent stop / tab close cancels the helper.
1025
- * await helper.saveMessages([userMsg], { signal: abortSignal });
1026
- * ```
1027
- */
1028
- saveMessages(
1029
- messages:
1030
- | UIMessage[]
1031
- | ((currentMessages: UIMessage[]) => UIMessage[] | Promise<UIMessage[]>),
1032
- options?: SaveMessagesOptions$1
1033
- ): Promise<SaveMessagesResult$1>;
1034
- private _runProgrammaticMessagesTurn;
1035
- /**
1036
- * Run a new LLM call following the last assistant message.
1037
- *
1038
- * The model sees the full conversation (including the last assistant
1039
- * response) and generates a new response. The new response is persisted
1040
- * as a separate assistant message. Building block for chat recovery
1041
- * (Phase 4), "generate more" buttons, and self-correction.
1042
- *
1043
- * Note: this creates a new message, not an append to the existing one.
1044
- * True continuation-as-append (chunk rewriting) is planned for Phase 4.
1045
- *
1046
- * Returns early with `status: "skipped"` if there is no assistant message
1047
- * to continue from.
1048
- *
1049
- * Pass `options.signal` to cancel the continuation from outside —
1050
- * matches the {@link saveMessages} contract.
1051
- */
1052
- protected continueLastTurn(
1053
- body?: Record<string, unknown>,
1054
- options?: SaveMessagesOptions$1
1055
- ): Promise<SaveMessagesResult$1>;
1056
- private _retryLastUserTurn;
1057
- private _setupProtocolHandlers;
1058
- private _handleProtocolEvent;
1059
- private _handleStreamResumeRequest;
1060
- private _handleStreamResumeAck;
1061
- private _handleChatRequest;
1062
- /**
1063
- * Abort the active turn, invalidate queued turns, and reset
1064
- * concurrency/continuation state. Call this when intercepting
1065
- * clear events or implementing custom reset logic.
1066
- *
1067
- * Does NOT clear messages, streams, or persisted state —
1068
- * only turn execution state.
1069
- */
1070
- protected resetTurnState(): void;
1071
- /**
1072
- * Abort a single in-flight chat turn by request id.
1073
- *
1074
- * Equivalent to the cancel path that fires when a client sends a
1075
- * `chat-request-cancel` WebSocket message — the inference loop's
1076
- * signal aborts, partial chunks already streamed are still
1077
- * persisted, and the turn's `ChatResponseResult` reports
1078
- * `status: "aborted"`.
1079
- *
1080
- * No-op if no controller exists for `requestId` (the turn already
1081
- * completed, was never started, or used a different id).
1082
- *
1083
- * `chat()` callers can read the request id from
1084
- * {@link StreamCallback.onStart} and later pass it here from another
1085
- * RPC call.
1086
- *
1087
- * Prefer {@link SaveMessagesOptions.signal} when driving a turn
1088
- * programmatically — it threads the abort intent in from the start
1089
- * without requiring the caller to know the id.
1090
- */
1091
- cancelChat(requestId: string, reason?: string): void;
1092
- /** Abort every in-flight chat turn on this agent. */
1093
- cancelAllChats(): void;
1094
- protected abortRequest(requestId: string, reason?: unknown): void;
1095
- /**
1096
- * Abort every in-flight chat turn on this agent.
1097
- *
1098
- * Aborts all controllers in the registry and clears it. Used by
1099
- * subclasses that drive single-purpose turns (e.g. a sub-agent
1100
- * helper that runs one turn at a time over RPC) and want a coarse
1101
- * "cancel whatever is running" handle without tracking request ids.
1102
- *
1103
- * Does NOT reset queued turns, continuation timers, or submit
1104
- * concurrency state — use {@link resetTurnState} for the full
1105
- * teardown that runs on `chat-clear`.
1106
- */
1107
- protected abortAllRequests(): void;
1108
- private _handleClear;
1109
- private _streamResultToRpcCallback;
1110
- private _shouldFlushRpcStreamChunk;
1111
- private _streamResult;
1112
- private _persistAssistantMessage;
1113
- /**
1114
- * Persist an incoming message after reconciliation. For assistant
1115
- * messages, also resolve their ID against any server-side row that
1116
- * already owns the same `toolCallId` so we update the existing row
1117
- * instead of inserting an orphan duplicate.
1118
- */
1119
- private _persistIncomingMessage;
1120
- private _persistClientTools;
1121
- private _restoreClientTools;
1122
- private _persistBody;
1123
- private _restoreBody;
1124
- private _applyToolResult;
1125
- private _applyToolApproval;
1126
- private _applyToolUpdateToMessages;
1127
- protected hasPendingInteraction(): boolean;
1128
- protected waitUntilStable(options?: { timeout?: number }): Promise<boolean>;
1129
- private _awaitWithDeadline;
1130
- private _messageHasPendingInteraction;
1131
- protected _handleInternalFiberRecovery(
1132
- ctx: FiberRecoveryContext$1
1133
- ): Promise<boolean>;
1134
- private _recoverablePreStreamUserId;
1135
- _chatRecoveryRetry(data?: ChatRecoveryRetryData): Promise<void>;
1136
- private _hasRunningSubmission;
1137
- private _readRunningSubmissionByRequestId;
1138
- private _markRecoveredSubmissionInterrupted;
1139
- private _completeRecoveredSubmission;
1140
- protected onChatRecovery(
1141
- _ctx: ChatRecoveryContext$1
1142
- ): Promise<ChatRecoveryOptions$1 | void>;
1143
- _chatRecoveryContinue(data?: ChatRecoveryContinueData): Promise<void>;
1144
- private _applyRecoveredRequestContext;
1145
- private _getPartialStreamText;
1146
- private _getSubmitConcurrencyDecision;
1147
- private _completeSkippedRequest;
1148
- private _rollbackDroppedSubmit;
1149
- private _scheduleAutoContinuation;
1150
- private _fireAutoContinuation;
1151
- private _activateDeferredContinuation;
1152
- private _fireResponseHook;
1153
- private _notifyStreamResuming;
1154
- private _persistOrphanedStream;
1155
- private _broadcastChat;
1156
- private _broadcast;
1157
- private _broadcastMessages;
1158
- }
1159
- //#endregion
3
+ $t as defineScheduledTasks,
4
+ At as StreamableResult,
5
+ Bt as ThinkSubmissionInspection,
6
+ Ct as SkillRunContext,
7
+ Dt as StepResult,
8
+ Et as StepContext,
9
+ Ft as ThinkIntervalSchedule,
10
+ Gt as ToolCallDecision,
11
+ Ht as ThinkTime,
12
+ It as ThinkScheduledTask,
13
+ Jt as TurnContext,
14
+ Kt as ToolCallResultContext,
15
+ Lt as ThinkScheduledTaskContext,
16
+ Mt as SubmitMessagesResult,
17
+ Nt as TextStreamPart,
18
+ Ot as StopCondition,
19
+ Pt as Think,
20
+ Qt as Workspace,
21
+ Rt as ThinkScheduledTaskSchedule,
22
+ St as Session,
23
+ Tt as StepConfig,
24
+ Ut as ThinkWallClockSchedule,
25
+ Vt as ThinkSubmissionStatus,
26
+ Wt as ToolCallContext,
27
+ Xt as TypedToolCall,
28
+ Yt as TurnInput,
29
+ Zt as TypedToolResult,
30
+ _t as PrepareStepFunction,
31
+ at as ChatRecoveryOptions,
32
+ bt as SaveMessagesOptions,
33
+ ct as ChunkContext,
34
+ dt as ExtensionConfig,
35
+ en as skills,
36
+ et as ChatErrorContext,
37
+ ft as FiberContext,
38
+ gt as PrepareStepContext,
39
+ ht as MessageConcurrency,
40
+ it as ChatRecoveryExhaustedContext,
41
+ jt as SubmitMessagesOptions,
42
+ kt as StreamCallback,
43
+ lt as ChunkPart,
44
+ mt as ListSubmissionsOptions,
45
+ nt as ChatRecoveryConfig,
46
+ ot as ChatResponseResult,
47
+ pt as FiberRecoveryContext,
48
+ qt as TurnConfig,
49
+ rt as ChatRecoveryContext,
50
+ st as ChatStartEvent,
51
+ tt as ChatOptions,
52
+ ut as DeleteSubmissionsOptions,
53
+ vt as PrepareStepResult,
54
+ wt as SkillSource,
55
+ xt as SaveMessagesResult,
56
+ yt as ResolvedChatRecoveryConfig,
57
+ zt as ThinkScheduledTasks
58
+ } from "./index-DpPdyY46.js";
1160
59
  export {
60
+ ChatErrorContext,
1161
61
  ChatOptions,
62
+ type ChatRecoveryConfig,
1162
63
  type ChatRecoveryContext,
64
+ type ChatRecoveryExhaustedContext,
1163
65
  type ChatRecoveryOptions,
1164
66
  type ChatResponseResult,
1165
67
  ChatStartEvent,
@@ -1174,9 +76,12 @@ export {
1174
76
  PrepareStepContext,
1175
77
  type PrepareStepFunction,
1176
78
  type PrepareStepResult,
79
+ type ResolvedChatRecoveryConfig,
1177
80
  type SaveMessagesOptions,
1178
81
  type SaveMessagesResult,
1179
82
  Session,
83
+ type SkillRunContext,
84
+ type SkillSource,
1180
85
  StepConfig,
1181
86
  StepContext,
1182
87
  type StepResult,
@@ -1187,8 +92,15 @@ export {
1187
92
  SubmitMessagesResult,
1188
93
  type TextStreamPart,
1189
94
  Think,
95
+ ThinkIntervalSchedule,
96
+ ThinkScheduledTask,
97
+ ThinkScheduledTaskContext,
98
+ ThinkScheduledTaskSchedule,
99
+ ThinkScheduledTasks,
1190
100
  ThinkSubmissionInspection,
1191
101
  ThinkSubmissionStatus,
102
+ ThinkTime,
103
+ ThinkWallClockSchedule,
1192
104
  ToolCallContext,
1193
105
  ToolCallDecision,
1194
106
  ToolCallResultContext,
@@ -1198,6 +110,7 @@ export {
1198
110
  type TypedToolCall,
1199
111
  type TypedToolResult,
1200
112
  Workspace,
1201
- type WorkspaceLike
113
+ type WorkspaceLike,
114
+ defineScheduledTasks,
115
+ skills
1202
116
  };
1203
- //# sourceMappingURL=think.d.ts.map