@octavus/core 0.1.0 → 0.2.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
@@ -21,6 +21,16 @@ declare class ConflictError extends AppError {
21
21
  * Format: timestamp-random (e.g., "1702345678901-abc123def")
22
22
  */
23
23
  declare function generateId(): string;
24
+ /**
25
+ * Check if an error is an abort error.
26
+ *
27
+ * This handles the various ways abort errors can manifest across different
28
+ * environments (browsers, Node.js, Next.js, etc.).
29
+ *
30
+ * @param error - The error to check
31
+ * @returns True if the error is an abort error
32
+ */
33
+ declare function isAbortError(error: unknown): error is Error;
24
34
 
25
35
  /**
26
36
  * Default thread name when none is specified.
@@ -48,510 +58,30 @@ declare function isOtherThread(part: {
48
58
  }): boolean;
49
59
 
50
60
  /**
51
- * Stream event types for Octavus agent communication.
61
+ * Zod schemas for stream events.
52
62
  *
53
- * Events are organized into two categories:
63
+ * Schemas are organized into two categories:
54
64
  * - Standard Events (====): Aligned with Vercel AI SDK for interoperability
55
65
  * - Octavus Events (----): Octavus-specific protocol events
56
66
  */
67
+
68
+ declare const toolResultSchema: z.ZodObject<{
69
+ toolCallId: z.ZodString;
70
+ toolName: z.ZodOptional<z.ZodString>;
71
+ result: z.ZodOptional<z.ZodUnknown>;
72
+ error: z.ZodOptional<z.ZodString>;
73
+ outputVariable: z.ZodOptional<z.ZodString>;
74
+ blockIndex: z.ZodOptional<z.ZodNumber>;
75
+ }, z.core.$strip>;
57
76
  /**
58
- * Display mode - controls execution indicator visibility (NOT final message visibility).
59
- * - hidden: Block runs silently
60
- * - name: Shows block/tool name
61
- * - description: Shows description
62
- * - stream: Shows live streaming content
63
- */
64
- type DisplayMode = 'hidden' | 'name' | 'description' | 'stream';
65
- type ToolHandler = (args: Record<string, unknown>) => Promise<unknown>;
66
- type ToolHandlers = Record<string, ToolHandler>;
67
- type ResourceUpdateHandler = (name: string, value: unknown) => Promise<void> | void;
68
- type MessageRole = 'user' | 'assistant' | 'system';
69
- type ToolCallStatus = 'pending' | 'streaming' | 'available' | 'error';
70
- interface ToolCallInfo {
71
- id: string;
72
- name: string;
73
- description?: string;
74
- arguments: Record<string, unknown>;
75
- status: ToolCallStatus;
76
- result?: unknown;
77
- error?: string;
78
- }
79
- /** Signals the start of a response message */
80
- interface StartEvent {
81
- type: 'start';
82
- messageId?: string;
83
- }
84
- /** Signals completion of streaming */
85
- interface FinishEvent {
86
- type: 'finish';
87
- finishReason: FinishReason;
88
- }
89
- /** Error during streaming */
90
- interface ErrorEvent {
91
- type: 'error';
92
- errorText: string;
93
- }
94
- type FinishReason = 'stop' | 'tool-calls' | 'length' | 'content-filter' | 'error' | 'other';
95
- /**
96
- * Start of text generation for a specific text part.
97
- *
98
- * If `responseType` is set, the text content is JSON matching a custom type.
99
- * The client SDK should parse the text as a structured object instead of
100
- * displaying it as plain text.
101
- */
102
- interface TextStartEvent {
103
- type: 'text-start';
104
- id: string;
105
- /**
106
- * If specified, the text content is JSON matching this type name.
107
- * Client SDK should parse as object, not display as text.
108
- */
109
- responseType?: string;
110
- }
111
- /** Incremental text content */
112
- interface TextDeltaEvent {
113
- type: 'text-delta';
114
- id: string;
115
- delta: string;
116
- }
117
- /** End of text generation for a specific text part */
118
- interface TextEndEvent {
119
- type: 'text-end';
120
- id: string;
121
- }
122
- /** Start of reasoning/thinking generation */
123
- interface ReasoningStartEvent {
124
- type: 'reasoning-start';
125
- id: string;
126
- }
127
- /** Incremental reasoning content */
128
- interface ReasoningDeltaEvent {
129
- type: 'reasoning-delta';
130
- id: string;
131
- delta: string;
132
- }
133
- /** End of reasoning generation */
134
- interface ReasoningEndEvent {
135
- type: 'reasoning-end';
136
- id: string;
137
- }
138
- /** Tool call initiated - input streaming will follow */
139
- interface ToolInputStartEvent {
140
- type: 'tool-input-start';
141
- toolCallId: string;
142
- toolName: string;
143
- /** Human-readable title/description for the tool call */
144
- title?: string;
145
- }
146
- /** Incremental tool input/arguments */
147
- interface ToolInputDeltaEvent {
148
- type: 'tool-input-delta';
149
- toolCallId: string;
150
- inputTextDelta: string;
151
- }
152
- /** Tool input streaming has ended */
153
- interface ToolInputEndEvent {
154
- type: 'tool-input-end';
155
- toolCallId: string;
156
- }
157
- /** Tool input is complete and available */
158
- interface ToolInputAvailableEvent {
159
- type: 'tool-input-available';
160
- toolCallId: string;
161
- toolName: string;
162
- input: unknown;
163
- }
164
- /** Tool output/result is available */
165
- interface ToolOutputAvailableEvent {
166
- type: 'tool-output-available';
167
- toolCallId: string;
168
- output: unknown;
169
- }
170
- /** Tool execution resulted in error */
171
- interface ToolOutputErrorEvent {
172
- type: 'tool-output-error';
173
- toolCallId: string;
174
- errorText: string;
175
- }
176
- /** Base source event fields */
177
- interface BaseSourceEvent {
178
- type: 'source';
179
- /** The ID of the source */
180
- id: string;
181
- }
182
- /** URL source from web search or similar tools */
183
- interface SourceUrlEvent extends BaseSourceEvent {
184
- sourceType: 'url';
185
- /** The URL of the source */
186
- url: string;
187
- /** The title of the source */
188
- title?: string;
189
- }
190
- /** Document source from file processing */
191
- interface SourceDocumentEvent extends BaseSourceEvent {
192
- sourceType: 'document';
193
- /** IANA media type of the document (e.g., 'application/pdf') */
194
- mediaType: string;
195
- /** The title of the document */
196
- title: string;
197
- /** Optional filename of the document */
198
- filename?: string;
199
- }
200
- /** Source event - union of all source types */
201
- type SourceEvent = SourceUrlEvent | SourceDocumentEvent;
202
- /** Protocol block execution started */
203
- interface BlockStartEvent {
204
- type: 'block-start';
205
- blockId: string;
206
- blockName: string;
207
- blockType: string;
208
- display: DisplayMode;
209
- description?: string;
210
- /** Whether output goes to main chat (false for independent blocks) */
211
- outputToChat?: boolean;
212
- /** Thread name (undefined or 'main' for main thread) */
213
- thread?: string;
214
- }
215
- /** Protocol block execution completed */
216
- interface BlockEndEvent {
217
- type: 'block-end';
218
- blockId: string;
219
- summary?: string;
220
- }
221
- /** Resource value updated */
222
- interface ResourceUpdateEvent {
223
- type: 'resource-update';
224
- name: string;
225
- value: unknown;
226
- }
227
- /** Pending tool call that needs external execution (continuation pattern) */
228
- interface PendingToolCall {
229
- toolCallId: string;
230
- toolName: string;
231
- args: Record<string, unknown>;
232
- /** 'llm' for LLM-initiated, 'block' for protocol block */
233
- source?: 'llm' | 'block';
234
- /** For block-based tools: variable name to store result in */
235
- outputVariable?: string;
236
- /** For block-based tools: block index to resume from after execution */
237
- blockIndex?: number;
238
- }
239
- /**
240
- * When this event is received, the stream will close.
241
- * Consumer should execute the tools and POST a new trigger request with toolResults.
242
- */
243
- interface ToolRequestEvent {
244
- type: 'tool-request';
245
- toolCalls: PendingToolCall[];
246
- }
247
- /** Result from tool execution (consumer's response to tool-request) */
248
- interface ToolResult {
249
- toolCallId: string;
250
- toolName?: string;
251
- result?: unknown;
252
- error?: string;
253
- outputVariable?: string;
254
- blockIndex?: number;
255
- }
256
- /**
257
- * A file generated during execution (aligned with Vercel AI SDK FilePart).
258
- * Used for skill outputs, image generation, code execution artifacts, etc.
259
- */
260
- interface GeneratedFile {
261
- /** Unique file ID */
262
- id: string;
263
- /** MIME type (e.g., 'image/png', 'application/pdf') - aligned with Vercel AI SDK */
264
- mediaType: string;
265
- /** URL for download/display (presigned S3 URL or data URL) */
266
- url: string;
267
- /** Original filename (optional, for display/download) */
268
- filename?: string;
269
- /** Size in bytes (optional, for display) */
270
- size?: number;
271
- }
272
- /**
273
- * File generated and available for download/display.
274
- * Emitted when a tool or skill produces a file output.
275
- */
276
- interface FileAvailableEvent {
277
- type: 'file-available';
278
- /** Unique file ID */
279
- id: string;
280
- /** MIME type (aligned with Vercel AI SDK) */
281
- mediaType: string;
282
- /** URL for download/display */
283
- url: string;
284
- /** Original filename */
285
- filename?: string;
286
- /** Size in bytes */
287
- size?: number;
288
- /** Tool call that generated this file */
289
- toolCallId?: string;
290
- }
291
- type StreamEvent = StartEvent | FinishEvent | ErrorEvent | TextStartEvent | TextDeltaEvent | TextEndEvent | ReasoningStartEvent | ReasoningDeltaEvent | ReasoningEndEvent | ToolInputStartEvent | ToolInputDeltaEvent | ToolInputEndEvent | ToolInputAvailableEvent | ToolOutputAvailableEvent | ToolOutputErrorEvent | SourceEvent | BlockStartEvent | BlockEndEvent | ResourceUpdateEvent | ToolRequestEvent | FileAvailableEvent;
292
- /**
293
- * Type of content in a message part (internal)
77
+ * Schema for file references used in trigger input and user messages.
294
78
  */
295
- type MessagePartType = 'text' | 'reasoning' | 'tool-call' | 'source' | 'file' | 'object';
296
- /**
297
- * Source info for URL sources (from web search, etc.)
298
- */
299
- interface SourceUrlInfo {
300
- sourceType: 'url';
301
- id: string;
302
- url: string;
303
- title?: string;
304
- }
305
- /**
306
- * Source info for document sources (from file processing)
307
- */
308
- interface SourceDocumentInfo {
309
- sourceType: 'document';
310
- id: string;
311
- mediaType: string;
312
- title: string;
313
- filename?: string;
314
- }
315
- /**
316
- * Source info - union of all source types (internal)
317
- */
318
- type SourceInfo = SourceUrlInfo | SourceDocumentInfo;
319
- /**
320
- * File info for generated files (from skill execution, code execution, etc.)
321
- */
322
- interface FileInfo {
323
- id: string;
324
- mediaType: string;
325
- url: string;
326
- filename?: string;
327
- size?: number;
328
- toolCallId?: string;
329
- }
330
- /**
331
- * Object info for structured output (internal storage)
332
- */
333
- interface ObjectInfo {
334
- id: string;
335
- /** Type name from the protocol */
336
- typeName: string;
337
- /** The structured object value */
338
- value: unknown;
339
- }
340
- /**
341
- * A single part of a message, stored in order for proper display (internal)
342
- */
343
- interface MessagePart {
344
- type: MessagePartType;
345
- /** Whether shown in chat UI (false = LLM sees it, user doesn't) */
346
- visible: boolean;
347
- /** Content for text/reasoning parts */
348
- content?: string;
349
- /** Tool call info for tool-call parts */
350
- toolCall?: ToolCallInfo;
351
- /** Source info for source parts (from web search, etc.) */
352
- source?: SourceInfo;
353
- /** File info for file parts (from skill execution, etc.) */
354
- file?: FileInfo;
355
- /** Object info for object parts (structured output) */
356
- object?: ObjectInfo;
357
- /** Thread name for non-main-thread content (e.g., "summary") */
358
- thread?: string;
359
- }
360
- /**
361
- * Internal chat message - stored in session state, used by LLM
362
- */
363
- interface ChatMessage {
364
- id: string;
365
- role: MessageRole;
366
- /** Ordered parts for display - preserves reasoning/tool/text order */
367
- parts: MessagePart[];
368
- createdAt: string;
369
- /**
370
- * Whether shown in chat UI (false = LLM sees it, user doesn't).
371
- * Use for internal directives. Different from `display` which controls execution indicator.
372
- * @default true
373
- */
374
- visible?: boolean;
375
- content: string;
376
- toolCalls?: ToolCallInfo[];
377
- reasoning?: string;
378
- /** Required by Anthropic to verify reasoning blocks */
379
- reasoningSignature?: string;
380
- }
381
- /**
382
- * Status of a UI message
383
- */
384
- type UIMessageStatus = 'streaming' | 'done';
385
- /**
386
- * Status of a UI message part
387
- */
388
- type UIPartStatus = 'streaming' | 'done';
389
- /**
390
- * Text content in a UI message
391
- */
392
- interface UITextPart {
393
- type: 'text';
394
- text: string;
395
- status: UIPartStatus;
396
- /** Thread name (undefined or 'main' for main thread) */
397
- thread?: string;
398
- }
399
- /**
400
- * Reasoning/thinking content in a UI message
401
- */
402
- interface UIReasoningPart {
403
- type: 'reasoning';
404
- text: string;
405
- status: UIPartStatus;
406
- /** Thread name (undefined or 'main' for main thread) */
407
- thread?: string;
408
- }
409
- /**
410
- * Tool call status for UI
411
- */
412
- type UIToolCallStatus = 'pending' | 'running' | 'done' | 'error';
413
- /**
414
- * Tool call in a UI message
415
- */
416
- interface UIToolCallPart {
417
- type: 'tool-call';
418
- toolCallId: string;
419
- toolName: string;
420
- /** Human-readable display name (from protocol description) */
421
- displayName?: string;
422
- args: Record<string, unknown>;
423
- result?: unknown;
424
- error?: string;
425
- status: UIToolCallStatus;
426
- /** Thread name (undefined or 'main' for main thread) */
427
- thread?: string;
428
- }
429
- /**
430
- * Operation status for UI
431
- */
432
- type UIOperationStatus = 'running' | 'done';
433
- /**
434
- * Internal operation in a UI message (e.g., set-resource, serialize-thread)
435
- * These are Octavus-specific operations, not LLM tool calls
436
- */
437
- interface UIOperationPart {
438
- type: 'operation';
439
- operationId: string;
440
- /** Human-readable name (from block name/description) */
441
- name: string;
442
- /** Type of operation (e.g., 'set-resource', 'serialize-thread') */
443
- operationType: string;
444
- status: UIOperationStatus;
445
- /** Thread name (undefined or 'main' for main thread) */
446
- thread?: string;
447
- }
448
- /** Base UI source part fields */
449
- interface BaseUISourcePart {
450
- type: 'source';
451
- /** The ID of the source */
452
- id: string;
453
- /** Thread name (undefined or 'main' for main thread) */
454
- thread?: string;
455
- }
456
- /**
457
- * URL source part (from web search results)
458
- */
459
- interface UISourceUrlPart extends BaseUISourcePart {
460
- sourceType: 'url';
461
- url: string;
462
- title?: string;
463
- }
464
- /**
465
- * Document source part (from file processing)
466
- */
467
- interface UISourceDocumentPart extends BaseUISourcePart {
468
- sourceType: 'document';
469
- mediaType: string;
470
- title: string;
471
- filename?: string;
472
- }
473
- /**
474
- * Source part - union of all source types
475
- */
476
- type UISourcePart = UISourceUrlPart | UISourceDocumentPart;
477
- /**
478
- * File attachment part (aligned with Vercel AI SDK FilePart).
479
- * Generated by skill execution, image generation, code execution, etc.
480
- */
481
- interface UIFilePart {
482
- type: 'file';
483
- /** Unique file ID */
484
- id: string;
485
- /** MIME type for rendering (aligned with Vercel AI SDK) */
486
- mediaType: string;
487
- /** URL for download/display (presigned URL or data URL) */
488
- url: string;
489
- /** Original filename (for display/download) */
490
- filename?: string;
491
- /** Size in bytes */
492
- size?: number;
493
- /** Tool call that generated this file */
494
- toolCallId?: string;
495
- /** Thread name (undefined or 'main' for main thread) */
496
- thread?: string;
497
- }
498
- /**
499
- * Status of a UI object part
500
- */
501
- type UIObjectStatus = 'streaming' | 'done' | 'error';
502
- /**
503
- * Structured object part in a UI message.
504
- * Used when the agent response is a typed object (structured output).
505
- * Client applications can render custom UI based on the typeName.
506
- */
507
- interface UIObjectPart {
508
- type: 'object';
509
- /** Unique part ID */
510
- id: string;
511
- /** The type name from the protocol (e.g., "ChatResponse") */
512
- typeName: string;
513
- /** Partial object while streaming (may have missing/incomplete fields) */
514
- partial?: unknown;
515
- /** Final validated object when done */
516
- object?: unknown;
517
- /** Current status */
518
- status: UIObjectStatus;
519
- /** Error message if status is 'error' */
520
- error?: string;
521
- /** Thread name (undefined or 'main' for main thread) */
522
- thread?: string;
523
- }
524
- /**
525
- * Union of all UI message part types
526
- */
527
- type UIMessagePart = UITextPart | UIReasoningPart | UIToolCallPart | UIOperationPart | UISourcePart | UIFilePart | UIObjectPart;
528
- /**
529
- * UI Message - the client-facing message format
530
- * All complexity is handled by the SDK, this is what consumers render
531
- */
532
- interface UIMessage {
533
- id: string;
534
- role: 'user' | 'assistant';
535
- parts: UIMessagePart[];
536
- status: UIMessageStatus;
537
- createdAt: Date;
538
- }
539
-
540
- /**
541
- * Zod schemas for stream events.
542
- *
543
- * Schemas are organized into two categories:
544
- * - Standard Events (====): Aligned with Vercel AI SDK for interoperability
545
- * - Octavus Events (----): Octavus-specific protocol events
546
- */
547
-
548
- declare const toolResultSchema: z.ZodObject<{
549
- toolCallId: z.ZodString;
550
- toolName: z.ZodOptional<z.ZodString>;
551
- result: z.ZodOptional<z.ZodUnknown>;
552
- error: z.ZodOptional<z.ZodString>;
553
- outputVariable: z.ZodOptional<z.ZodString>;
554
- blockIndex: z.ZodOptional<z.ZodNumber>;
79
+ declare const fileReferenceSchema: z.ZodObject<{
80
+ id: z.ZodString;
81
+ mediaType: z.ZodString;
82
+ url: z.ZodString;
83
+ filename: z.ZodOptional<z.ZodString>;
84
+ size: z.ZodOptional<z.ZodNumber>;
555
85
  }, z.core.$strip>;
556
86
  declare const chatMessageSchema: z.ZodObject<{
557
87
  id: z.ZodString;
@@ -563,11 +93,11 @@ declare const chatMessageSchema: z.ZodObject<{
563
93
  parts: z.ZodArray<z.ZodObject<{
564
94
  type: z.ZodEnum<{
565
95
  object: "object";
96
+ file: "file";
566
97
  source: "source";
567
98
  text: "text";
568
99
  reasoning: "reasoning";
569
100
  "tool-call": "tool-call";
570
- file: "file";
571
101
  }>;
572
102
  visible: z.ZodBoolean;
573
103
  content: z.ZodOptional<z.ZodString>;
@@ -807,239 +337,754 @@ declare function safeParseStreamEvent(data: unknown): z.ZodSafeParseResult<{
807
337
  sourceType: "url";
808
338
  id: string;
809
339
  url: string;
810
- title?: string | undefined;
811
- } | {
812
- type: "source";
813
- sourceType: "document";
340
+ title?: string | undefined;
341
+ } | {
342
+ type: "source";
343
+ sourceType: "document";
344
+ id: string;
345
+ mediaType: string;
346
+ title: string;
347
+ filename?: string | undefined;
348
+ } | {
349
+ type: "start";
350
+ messageId?: string | undefined;
351
+ } | {
352
+ type: "finish";
353
+ finishReason: "error" | "stop" | "tool-calls" | "length" | "content-filter" | "other";
354
+ } | {
355
+ type: "error";
356
+ errorText: string;
357
+ } | {
358
+ type: "text-start";
359
+ id: string;
360
+ responseType?: string | undefined;
361
+ } | {
362
+ type: "text-delta";
363
+ id: string;
364
+ delta: string;
365
+ } | {
366
+ type: "text-end";
367
+ id: string;
368
+ } | {
369
+ type: "reasoning-start";
370
+ id: string;
371
+ } | {
372
+ type: "reasoning-delta";
373
+ id: string;
374
+ delta: string;
375
+ } | {
376
+ type: "reasoning-end";
377
+ id: string;
378
+ } | {
379
+ type: "tool-input-start";
380
+ toolCallId: string;
381
+ toolName: string;
382
+ title?: string | undefined;
383
+ } | {
384
+ type: "tool-input-delta";
385
+ toolCallId: string;
386
+ inputTextDelta: string;
387
+ } | {
388
+ type: "tool-input-end";
389
+ toolCallId: string;
390
+ } | {
391
+ type: "tool-input-available";
392
+ toolCallId: string;
393
+ toolName: string;
394
+ input: unknown;
395
+ } | {
396
+ type: "tool-output-available";
397
+ toolCallId: string;
398
+ output: unknown;
399
+ } | {
400
+ type: "tool-output-error";
401
+ toolCallId: string;
402
+ errorText: string;
403
+ } | {
404
+ type: "block-start";
405
+ blockId: string;
406
+ blockName: string;
407
+ blockType: string;
408
+ display: "hidden" | "name" | "description" | "stream";
409
+ description?: string | undefined;
410
+ outputToChat?: boolean | undefined;
411
+ thread?: string | undefined;
412
+ } | {
413
+ type: "block-end";
414
+ blockId: string;
415
+ summary?: string | undefined;
416
+ } | {
417
+ type: "resource-update";
418
+ name: string;
419
+ value: unknown;
420
+ } | {
421
+ type: "tool-request";
422
+ toolCalls: {
423
+ toolCallId: string;
424
+ toolName: string;
425
+ args: Record<string, unknown>;
426
+ source?: "llm" | "block" | undefined;
427
+ outputVariable?: string | undefined;
428
+ blockIndex?: number | undefined;
429
+ }[];
430
+ } | {
431
+ type: "file-available";
432
+ id: string;
433
+ mediaType: string;
434
+ url: string;
435
+ filename?: string | undefined;
436
+ size?: number | undefined;
437
+ toolCallId?: string | undefined;
438
+ }>;
439
+ declare function safeParseUIMessage(data: unknown): z.ZodSafeParseResult<{
440
+ id: string;
441
+ role: "user" | "assistant";
442
+ parts: ({
443
+ type: "source";
444
+ sourceType: "url";
445
+ id: string;
446
+ url: string;
447
+ title?: string | undefined;
448
+ thread?: string | undefined;
449
+ } | {
450
+ type: "source";
451
+ sourceType: "document";
452
+ id: string;
453
+ mediaType: string;
454
+ title: string;
455
+ filename?: string | undefined;
456
+ thread?: string | undefined;
457
+ } | {
458
+ type: "text";
459
+ text: string;
460
+ status: "streaming" | "done";
461
+ thread?: string | undefined;
462
+ } | {
463
+ type: "reasoning";
464
+ text: string;
465
+ status: "streaming" | "done";
466
+ thread?: string | undefined;
467
+ } | {
468
+ type: "tool-call";
469
+ toolCallId: string;
470
+ toolName: string;
471
+ args: Record<string, unknown>;
472
+ status: "pending" | "error" | "done" | "running";
473
+ displayName?: string | undefined;
474
+ result?: unknown;
475
+ error?: string | undefined;
476
+ thread?: string | undefined;
477
+ } | {
478
+ type: "operation";
479
+ operationId: string;
480
+ name: string;
481
+ operationType: string;
482
+ status: "done" | "running";
483
+ thread?: string | undefined;
484
+ } | {
485
+ type: "file";
486
+ id: string;
487
+ mediaType: string;
488
+ url: string;
489
+ filename?: string | undefined;
490
+ size?: number | undefined;
491
+ toolCallId?: string | undefined;
492
+ thread?: string | undefined;
493
+ } | {
494
+ type: "object";
495
+ id: string;
496
+ typeName: string;
497
+ status: "streaming" | "error" | "done";
498
+ partial?: unknown;
499
+ object?: unknown;
500
+ error?: string | undefined;
501
+ thread?: string | undefined;
502
+ })[];
503
+ status: "streaming" | "done";
504
+ createdAt: Date;
505
+ }>;
506
+ declare function safeParseUIMessages(data: unknown): z.ZodSafeParseResult<{
507
+ id: string;
508
+ role: "user" | "assistant";
509
+ parts: ({
510
+ type: "source";
511
+ sourceType: "url";
512
+ id: string;
513
+ url: string;
514
+ title?: string | undefined;
515
+ thread?: string | undefined;
516
+ } | {
517
+ type: "source";
518
+ sourceType: "document";
519
+ id: string;
520
+ mediaType: string;
521
+ title: string;
522
+ filename?: string | undefined;
523
+ thread?: string | undefined;
524
+ } | {
525
+ type: "text";
526
+ text: string;
527
+ status: "streaming" | "done";
528
+ thread?: string | undefined;
529
+ } | {
530
+ type: "reasoning";
531
+ text: string;
532
+ status: "streaming" | "done";
533
+ thread?: string | undefined;
534
+ } | {
535
+ type: "tool-call";
536
+ toolCallId: string;
537
+ toolName: string;
538
+ args: Record<string, unknown>;
539
+ status: "pending" | "error" | "done" | "running";
540
+ displayName?: string | undefined;
541
+ result?: unknown;
542
+ error?: string | undefined;
543
+ thread?: string | undefined;
544
+ } | {
545
+ type: "operation";
546
+ operationId: string;
547
+ name: string;
548
+ operationType: string;
549
+ status: "done" | "running";
550
+ thread?: string | undefined;
551
+ } | {
552
+ type: "file";
553
+ id: string;
554
+ mediaType: string;
555
+ url: string;
556
+ filename?: string | undefined;
557
+ size?: number | undefined;
558
+ toolCallId?: string | undefined;
559
+ thread?: string | undefined;
560
+ } | {
561
+ type: "object";
562
+ id: string;
563
+ typeName: string;
564
+ status: "streaming" | "error" | "done";
565
+ partial?: unknown;
566
+ object?: unknown;
567
+ error?: string | undefined;
568
+ thread?: string | undefined;
569
+ })[];
570
+ status: "streaming" | "done";
571
+ createdAt: Date;
572
+ }[]>;
573
+ /**
574
+ * Type guard to check if a value is a FileReference object.
575
+ */
576
+ declare function isFileReference(value: unknown): value is z.infer<typeof fileReferenceSchema>;
577
+ /**
578
+ * Type guard to check if a value is an array of FileReference objects.
579
+ */
580
+ declare function isFileReferenceArray(value: unknown): value is z.infer<typeof fileReferenceSchema>[];
581
+
582
+ /**
583
+ * Stream event types for Octavus agent communication.
584
+ *
585
+ * Events are organized into two categories:
586
+ * - Standard Events (====): Aligned with Vercel AI SDK for interoperability
587
+ * - Octavus Events (----): Octavus-specific protocol events
588
+ */
589
+ /**
590
+ * Display mode - controls execution indicator visibility (NOT final message visibility).
591
+ * - hidden: Block runs silently
592
+ * - name: Shows block/tool name
593
+ * - description: Shows description
594
+ * - stream: Shows live streaming content
595
+ */
596
+ type DisplayMode = 'hidden' | 'name' | 'description' | 'stream';
597
+ type ToolHandler = (args: Record<string, unknown>) => Promise<unknown>;
598
+ type ToolHandlers = Record<string, ToolHandler>;
599
+ /**
600
+ * Reference to an uploaded file.
601
+ * Used in trigger input and user messages for file attachments.
602
+ * Compatible with UIFilePart structure for rendering.
603
+ */
604
+ interface FileReference {
605
+ /** Unique file ID (platform-generated) */
606
+ id: string;
607
+ /** IANA media type (e.g., 'image/png', 'application/pdf') */
608
+ mediaType: string;
609
+ /** Presigned download URL (S3) */
610
+ url: string;
611
+ /** Original filename */
612
+ filename?: string;
613
+ /** File size in bytes */
614
+ size?: number;
615
+ }
616
+ type ResourceUpdateHandler = (name: string, value: unknown) => Promise<void> | void;
617
+ type MessageRole = 'user' | 'assistant' | 'system';
618
+ type ToolCallStatus = 'pending' | 'streaming' | 'available' | 'error';
619
+ interface ToolCallInfo {
620
+ id: string;
621
+ name: string;
622
+ description?: string;
623
+ arguments: Record<string, unknown>;
624
+ status: ToolCallStatus;
625
+ result?: unknown;
626
+ error?: string;
627
+ }
628
+ /** Signals the start of a response message */
629
+ interface StartEvent {
630
+ type: 'start';
631
+ messageId?: string;
632
+ }
633
+ /** Signals completion of streaming */
634
+ interface FinishEvent {
635
+ type: 'finish';
636
+ finishReason: FinishReason;
637
+ }
638
+ /** Error during streaming */
639
+ interface ErrorEvent {
640
+ type: 'error';
641
+ errorText: string;
642
+ }
643
+ type FinishReason = 'stop' | 'tool-calls' | 'length' | 'content-filter' | 'error' | 'other';
644
+ /**
645
+ * Start of text generation for a specific text part.
646
+ *
647
+ * If `responseType` is set, the text content is JSON matching a custom type.
648
+ * The client SDK should parse the text as a structured object instead of
649
+ * displaying it as plain text.
650
+ */
651
+ interface TextStartEvent {
652
+ type: 'text-start';
653
+ id: string;
654
+ /**
655
+ * If specified, the text content is JSON matching this type name.
656
+ * Client SDK should parse as object, not display as text.
657
+ */
658
+ responseType?: string;
659
+ }
660
+ /** Incremental text content */
661
+ interface TextDeltaEvent {
662
+ type: 'text-delta';
663
+ id: string;
664
+ delta: string;
665
+ }
666
+ /** End of text generation for a specific text part */
667
+ interface TextEndEvent {
668
+ type: 'text-end';
669
+ id: string;
670
+ }
671
+ /** Start of reasoning/thinking generation */
672
+ interface ReasoningStartEvent {
673
+ type: 'reasoning-start';
674
+ id: string;
675
+ }
676
+ /** Incremental reasoning content */
677
+ interface ReasoningDeltaEvent {
678
+ type: 'reasoning-delta';
679
+ id: string;
680
+ delta: string;
681
+ }
682
+ /** End of reasoning generation */
683
+ interface ReasoningEndEvent {
684
+ type: 'reasoning-end';
685
+ id: string;
686
+ }
687
+ /** Tool call initiated - input streaming will follow */
688
+ interface ToolInputStartEvent {
689
+ type: 'tool-input-start';
690
+ toolCallId: string;
691
+ toolName: string;
692
+ /** Human-readable title/description for the tool call */
693
+ title?: string;
694
+ }
695
+ /** Incremental tool input/arguments */
696
+ interface ToolInputDeltaEvent {
697
+ type: 'tool-input-delta';
698
+ toolCallId: string;
699
+ inputTextDelta: string;
700
+ }
701
+ /** Tool input streaming has ended */
702
+ interface ToolInputEndEvent {
703
+ type: 'tool-input-end';
704
+ toolCallId: string;
705
+ }
706
+ /** Tool input is complete and available */
707
+ interface ToolInputAvailableEvent {
708
+ type: 'tool-input-available';
709
+ toolCallId: string;
710
+ toolName: string;
711
+ input: unknown;
712
+ }
713
+ /** Tool output/result is available */
714
+ interface ToolOutputAvailableEvent {
715
+ type: 'tool-output-available';
716
+ toolCallId: string;
717
+ output: unknown;
718
+ }
719
+ /** Tool execution resulted in error */
720
+ interface ToolOutputErrorEvent {
721
+ type: 'tool-output-error';
722
+ toolCallId: string;
723
+ errorText: string;
724
+ }
725
+ /** Base source event fields */
726
+ interface BaseSourceEvent {
727
+ type: 'source';
728
+ /** The ID of the source */
729
+ id: string;
730
+ }
731
+ /** URL source from web search or similar tools */
732
+ interface SourceUrlEvent extends BaseSourceEvent {
733
+ sourceType: 'url';
734
+ /** The URL of the source */
735
+ url: string;
736
+ /** The title of the source */
737
+ title?: string;
738
+ }
739
+ /** Document source from file processing */
740
+ interface SourceDocumentEvent extends BaseSourceEvent {
741
+ sourceType: 'document';
742
+ /** IANA media type of the document (e.g., 'application/pdf') */
743
+ mediaType: string;
744
+ /** The title of the document */
745
+ title: string;
746
+ /** Optional filename of the document */
747
+ filename?: string;
748
+ }
749
+ /** Source event - union of all source types */
750
+ type SourceEvent = SourceUrlEvent | SourceDocumentEvent;
751
+ /** Protocol block execution started */
752
+ interface BlockStartEvent {
753
+ type: 'block-start';
754
+ blockId: string;
755
+ blockName: string;
756
+ blockType: string;
757
+ display: DisplayMode;
758
+ description?: string;
759
+ /** Whether output goes to main chat (false for independent blocks) */
760
+ outputToChat?: boolean;
761
+ /** Thread name (undefined or 'main' for main thread) */
762
+ thread?: string;
763
+ }
764
+ /** Protocol block execution completed */
765
+ interface BlockEndEvent {
766
+ type: 'block-end';
767
+ blockId: string;
768
+ summary?: string;
769
+ }
770
+ /** Resource value updated */
771
+ interface ResourceUpdateEvent {
772
+ type: 'resource-update';
773
+ name: string;
774
+ value: unknown;
775
+ }
776
+ /** Pending tool call that needs external execution (continuation pattern) */
777
+ interface PendingToolCall {
778
+ toolCallId: string;
779
+ toolName: string;
780
+ args: Record<string, unknown>;
781
+ /** 'llm' for LLM-initiated, 'block' for protocol block */
782
+ source?: 'llm' | 'block';
783
+ /** For block-based tools: variable name to store result in */
784
+ outputVariable?: string;
785
+ /** For block-based tools: block index to resume from after execution */
786
+ blockIndex?: number;
787
+ }
788
+ /**
789
+ * When this event is received, the stream will close.
790
+ * Consumer should execute the tools and POST a new trigger request with toolResults.
791
+ */
792
+ interface ToolRequestEvent {
793
+ type: 'tool-request';
794
+ toolCalls: PendingToolCall[];
795
+ }
796
+ /** Result from tool execution (consumer's response to tool-request) */
797
+ interface ToolResult {
798
+ toolCallId: string;
799
+ toolName?: string;
800
+ result?: unknown;
801
+ error?: string;
802
+ outputVariable?: string;
803
+ blockIndex?: number;
804
+ }
805
+ /**
806
+ * A file generated during execution (aligned with Vercel AI SDK FilePart).
807
+ * Used for skill outputs, image generation, code execution artifacts, etc.
808
+ */
809
+ interface GeneratedFile {
810
+ /** Unique file ID */
811
+ id: string;
812
+ /** MIME type (e.g., 'image/png', 'application/pdf') - aligned with Vercel AI SDK */
813
+ mediaType: string;
814
+ /** URL for download/display (presigned S3 URL or data URL) */
815
+ url: string;
816
+ /** Original filename (optional, for display/download) */
817
+ filename?: string;
818
+ /** Size in bytes (optional, for display) */
819
+ size?: number;
820
+ }
821
+ /**
822
+ * File generated and available for download/display.
823
+ * Emitted when a tool or skill produces a file output.
824
+ */
825
+ interface FileAvailableEvent {
826
+ type: 'file-available';
827
+ /** Unique file ID */
814
828
  id: string;
829
+ /** MIME type (aligned with Vercel AI SDK) */
815
830
  mediaType: string;
816
- title: string;
817
- filename?: string | undefined;
818
- } | {
819
- type: "start";
820
- messageId?: string | undefined;
821
- } | {
822
- type: "finish";
823
- finishReason: "error" | "stop" | "tool-calls" | "length" | "content-filter" | "other";
824
- } | {
825
- type: "error";
826
- errorText: string;
827
- } | {
828
- type: "text-start";
829
- id: string;
830
- responseType?: string | undefined;
831
- } | {
832
- type: "text-delta";
831
+ /** URL for download/display */
832
+ url: string;
833
+ /** Original filename */
834
+ filename?: string;
835
+ /** Size in bytes */
836
+ size?: number;
837
+ /** Tool call that generated this file */
838
+ toolCallId?: string;
839
+ }
840
+ type StreamEvent = StartEvent | FinishEvent | ErrorEvent | TextStartEvent | TextDeltaEvent | TextEndEvent | ReasoningStartEvent | ReasoningDeltaEvent | ReasoningEndEvent | ToolInputStartEvent | ToolInputDeltaEvent | ToolInputEndEvent | ToolInputAvailableEvent | ToolOutputAvailableEvent | ToolOutputErrorEvent | SourceEvent | BlockStartEvent | BlockEndEvent | ResourceUpdateEvent | ToolRequestEvent | FileAvailableEvent;
841
+ /**
842
+ * Type of content in a message part (internal)
843
+ */
844
+ type MessagePartType = 'text' | 'reasoning' | 'tool-call' | 'source' | 'file' | 'object';
845
+ /**
846
+ * Source info for URL sources (from web search, etc.)
847
+ */
848
+ interface SourceUrlInfo {
849
+ sourceType: 'url';
833
850
  id: string;
834
- delta: string;
835
- } | {
836
- type: "text-end";
851
+ url: string;
852
+ title?: string;
853
+ }
854
+ /**
855
+ * Source info for document sources (from file processing)
856
+ */
857
+ interface SourceDocumentInfo {
858
+ sourceType: 'document';
837
859
  id: string;
838
- } | {
839
- type: "reasoning-start";
860
+ mediaType: string;
861
+ title: string;
862
+ filename?: string;
863
+ }
864
+ /**
865
+ * Source info - union of all source types (internal)
866
+ */
867
+ type SourceInfo = SourceUrlInfo | SourceDocumentInfo;
868
+ /**
869
+ * File info for generated files (from skill execution, code execution, etc.)
870
+ */
871
+ interface FileInfo {
840
872
  id: string;
841
- } | {
842
- type: "reasoning-delta";
873
+ mediaType: string;
874
+ url: string;
875
+ filename?: string;
876
+ size?: number;
877
+ toolCallId?: string;
878
+ }
879
+ /**
880
+ * Object info for structured output (internal storage)
881
+ */
882
+ interface ObjectInfo {
843
883
  id: string;
844
- delta: string;
845
- } | {
846
- type: "reasoning-end";
884
+ /** Type name from the protocol */
885
+ typeName: string;
886
+ /** The structured object value */
887
+ value: unknown;
888
+ }
889
+ /**
890
+ * A single part of a message, stored in order for proper display (internal)
891
+ */
892
+ interface MessagePart {
893
+ type: MessagePartType;
894
+ /** Whether shown in chat UI (false = LLM sees it, user doesn't) */
895
+ visible: boolean;
896
+ /** Content for text/reasoning parts */
897
+ content?: string;
898
+ /** Tool call info for tool-call parts */
899
+ toolCall?: ToolCallInfo;
900
+ /** Source info for source parts (from web search, etc.) */
901
+ source?: SourceInfo;
902
+ /** File info for file parts (from skill execution, etc.) */
903
+ file?: FileInfo;
904
+ /** Object info for object parts (structured output) */
905
+ object?: ObjectInfo;
906
+ /** Thread name for non-main-thread content (e.g., "summary") */
907
+ thread?: string;
908
+ }
909
+ /**
910
+ * Internal chat message - stored in session state, used by LLM
911
+ */
912
+ interface ChatMessage {
847
913
  id: string;
848
- } | {
849
- type: "tool-input-start";
850
- toolCallId: string;
851
- toolName: string;
852
- title?: string | undefined;
853
- } | {
854
- type: "tool-input-delta";
855
- toolCallId: string;
856
- inputTextDelta: string;
857
- } | {
858
- type: "tool-input-end";
859
- toolCallId: string;
860
- } | {
861
- type: "tool-input-available";
914
+ role: MessageRole;
915
+ /** Ordered parts for display - preserves reasoning/tool/text order */
916
+ parts: MessagePart[];
917
+ createdAt: string;
918
+ /**
919
+ * Whether shown in chat UI (false = LLM sees it, user doesn't).
920
+ * Use for internal directives. Different from `display` which controls execution indicator.
921
+ * @default true
922
+ */
923
+ visible?: boolean;
924
+ content: string;
925
+ toolCalls?: ToolCallInfo[];
926
+ reasoning?: string;
927
+ /** Required by Anthropic to verify reasoning blocks */
928
+ reasoningSignature?: string;
929
+ }
930
+ /**
931
+ * Status of a UI message
932
+ */
933
+ type UIMessageStatus = 'streaming' | 'done';
934
+ /**
935
+ * Status of a UI message part
936
+ */
937
+ type UIPartStatus = 'streaming' | 'done';
938
+ /**
939
+ * Text content in a UI message
940
+ */
941
+ interface UITextPart {
942
+ type: 'text';
943
+ text: string;
944
+ status: UIPartStatus;
945
+ /** Thread name (undefined or 'main' for main thread) */
946
+ thread?: string;
947
+ }
948
+ /**
949
+ * Reasoning/thinking content in a UI message
950
+ */
951
+ interface UIReasoningPart {
952
+ type: 'reasoning';
953
+ text: string;
954
+ status: UIPartStatus;
955
+ /** Thread name (undefined or 'main' for main thread) */
956
+ thread?: string;
957
+ }
958
+ /**
959
+ * Tool call status for UI
960
+ */
961
+ type UIToolCallStatus = 'pending' | 'running' | 'done' | 'error' | 'cancelled';
962
+ /**
963
+ * Tool call in a UI message
964
+ */
965
+ interface UIToolCallPart {
966
+ type: 'tool-call';
862
967
  toolCallId: string;
863
968
  toolName: string;
864
- input: unknown;
865
- } | {
866
- type: "tool-output-available";
867
- toolCallId: string;
868
- output: unknown;
869
- } | {
870
- type: "tool-output-error";
871
- toolCallId: string;
872
- errorText: string;
873
- } | {
874
- type: "block-start";
875
- blockId: string;
876
- blockName: string;
877
- blockType: string;
878
- display: "hidden" | "name" | "description" | "stream";
879
- description?: string | undefined;
880
- outputToChat?: boolean | undefined;
881
- thread?: string | undefined;
882
- } | {
883
- type: "block-end";
884
- blockId: string;
885
- summary?: string | undefined;
886
- } | {
887
- type: "resource-update";
969
+ /** Human-readable display name (from protocol description) */
970
+ displayName?: string;
971
+ args: Record<string, unknown>;
972
+ result?: unknown;
973
+ error?: string;
974
+ status: UIToolCallStatus;
975
+ /** Thread name (undefined or 'main' for main thread) */
976
+ thread?: string;
977
+ }
978
+ /**
979
+ * Operation status for UI
980
+ */
981
+ type UIOperationStatus = 'running' | 'done' | 'cancelled';
982
+ /**
983
+ * Internal operation in a UI message (e.g., set-resource, serialize-thread)
984
+ * These are Octavus-specific operations, not LLM tool calls
985
+ */
986
+ interface UIOperationPart {
987
+ type: 'operation';
988
+ operationId: string;
989
+ /** Human-readable name (from block name/description) */
888
990
  name: string;
889
- value: unknown;
890
- } | {
891
- type: "tool-request";
892
- toolCalls: {
893
- toolCallId: string;
894
- toolName: string;
895
- args: Record<string, unknown>;
896
- source?: "llm" | "block" | undefined;
897
- outputVariable?: string | undefined;
898
- blockIndex?: number | undefined;
899
- }[];
900
- } | {
901
- type: "file-available";
991
+ /** Type of operation (e.g., 'set-resource', 'serialize-thread') */
992
+ operationType: string;
993
+ status: UIOperationStatus;
994
+ /** Thread name (undefined or 'main' for main thread) */
995
+ thread?: string;
996
+ }
997
+ /** Base UI source part fields */
998
+ interface BaseUISourcePart {
999
+ type: 'source';
1000
+ /** The ID of the source */
1001
+ id: string;
1002
+ /** Thread name (undefined or 'main' for main thread) */
1003
+ thread?: string;
1004
+ }
1005
+ /**
1006
+ * URL source part (from web search results)
1007
+ */
1008
+ interface UISourceUrlPart extends BaseUISourcePart {
1009
+ sourceType: 'url';
1010
+ url: string;
1011
+ title?: string;
1012
+ }
1013
+ /**
1014
+ * Document source part (from file processing)
1015
+ */
1016
+ interface UISourceDocumentPart extends BaseUISourcePart {
1017
+ sourceType: 'document';
1018
+ mediaType: string;
1019
+ title: string;
1020
+ filename?: string;
1021
+ }
1022
+ /**
1023
+ * Source part - union of all source types
1024
+ */
1025
+ type UISourcePart = UISourceUrlPart | UISourceDocumentPart;
1026
+ /**
1027
+ * File attachment part (aligned with Vercel AI SDK FilePart).
1028
+ * Generated by skill execution, image generation, code execution, etc.
1029
+ */
1030
+ interface UIFilePart {
1031
+ type: 'file';
1032
+ /** Unique file ID */
902
1033
  id: string;
1034
+ /** MIME type for rendering (aligned with Vercel AI SDK) */
903
1035
  mediaType: string;
1036
+ /** URL for download/display (presigned URL or data URL) */
904
1037
  url: string;
905
- filename?: string | undefined;
906
- size?: number | undefined;
907
- toolCallId?: string | undefined;
908
- }>;
909
- declare function safeParseUIMessage(data: unknown): z.ZodSafeParseResult<{
1038
+ /** Original filename (for display/download) */
1039
+ filename?: string;
1040
+ /** Size in bytes */
1041
+ size?: number;
1042
+ /** Tool call that generated this file */
1043
+ toolCallId?: string;
1044
+ /** Thread name (undefined or 'main' for main thread) */
1045
+ thread?: string;
1046
+ }
1047
+ /**
1048
+ * Status of a UI object part
1049
+ */
1050
+ type UIObjectStatus = 'streaming' | 'done' | 'error';
1051
+ /**
1052
+ * Structured object part in a UI message.
1053
+ * Used when the agent response is a typed object (structured output).
1054
+ * Client applications can render custom UI based on the typeName.
1055
+ */
1056
+ interface UIObjectPart {
1057
+ type: 'object';
1058
+ /** Unique part ID */
910
1059
  id: string;
911
- role: "user" | "assistant";
912
- parts: ({
913
- type: "source";
914
- sourceType: "url";
915
- id: string;
916
- url: string;
917
- title?: string | undefined;
918
- thread?: string | undefined;
919
- } | {
920
- type: "source";
921
- sourceType: "document";
922
- id: string;
923
- mediaType: string;
924
- title: string;
925
- filename?: string | undefined;
926
- thread?: string | undefined;
927
- } | {
928
- type: "text";
929
- text: string;
930
- status: "streaming" | "done";
931
- thread?: string | undefined;
932
- } | {
933
- type: "reasoning";
934
- text: string;
935
- status: "streaming" | "done";
936
- thread?: string | undefined;
937
- } | {
938
- type: "tool-call";
939
- toolCallId: string;
940
- toolName: string;
941
- args: Record<string, unknown>;
942
- status: "pending" | "error" | "done" | "running";
943
- displayName?: string | undefined;
944
- result?: unknown;
945
- error?: string | undefined;
946
- thread?: string | undefined;
947
- } | {
948
- type: "operation";
949
- operationId: string;
950
- name: string;
951
- operationType: string;
952
- status: "done" | "running";
953
- thread?: string | undefined;
954
- } | {
955
- type: "file";
956
- id: string;
957
- mediaType: string;
958
- url: string;
959
- filename?: string | undefined;
960
- size?: number | undefined;
961
- toolCallId?: string | undefined;
962
- thread?: string | undefined;
963
- } | {
964
- type: "object";
965
- id: string;
966
- typeName: string;
967
- status: "streaming" | "error" | "done";
968
- partial?: unknown;
969
- object?: unknown;
970
- error?: string | undefined;
971
- thread?: string | undefined;
972
- })[];
973
- status: "streaming" | "done";
974
- createdAt: Date;
975
- }>;
976
- declare function safeParseUIMessages(data: unknown): z.ZodSafeParseResult<{
1060
+ /** The type name from the protocol (e.g., "ChatResponse") */
1061
+ typeName: string;
1062
+ /** Partial object while streaming (may have missing/incomplete fields) */
1063
+ partial?: unknown;
1064
+ /** Final validated object when done */
1065
+ object?: unknown;
1066
+ /** Current status */
1067
+ status: UIObjectStatus;
1068
+ /** Error message if status is 'error' */
1069
+ error?: string;
1070
+ /** Thread name (undefined or 'main' for main thread) */
1071
+ thread?: string;
1072
+ }
1073
+ /**
1074
+ * Union of all UI message part types
1075
+ */
1076
+ type UIMessagePart = UITextPart | UIReasoningPart | UIToolCallPart | UIOperationPart | UISourcePart | UIFilePart | UIObjectPart;
1077
+ /**
1078
+ * UI Message - the client-facing message format
1079
+ * All complexity is handled by the SDK, this is what consumers render
1080
+ */
1081
+ interface UIMessage {
977
1082
  id: string;
978
- role: "user" | "assistant";
979
- parts: ({
980
- type: "source";
981
- sourceType: "url";
982
- id: string;
983
- url: string;
984
- title?: string | undefined;
985
- thread?: string | undefined;
986
- } | {
987
- type: "source";
988
- sourceType: "document";
989
- id: string;
990
- mediaType: string;
991
- title: string;
992
- filename?: string | undefined;
993
- thread?: string | undefined;
994
- } | {
995
- type: "text";
996
- text: string;
997
- status: "streaming" | "done";
998
- thread?: string | undefined;
999
- } | {
1000
- type: "reasoning";
1001
- text: string;
1002
- status: "streaming" | "done";
1003
- thread?: string | undefined;
1004
- } | {
1005
- type: "tool-call";
1006
- toolCallId: string;
1007
- toolName: string;
1008
- args: Record<string, unknown>;
1009
- status: "pending" | "error" | "done" | "running";
1010
- displayName?: string | undefined;
1011
- result?: unknown;
1012
- error?: string | undefined;
1013
- thread?: string | undefined;
1014
- } | {
1015
- type: "operation";
1016
- operationId: string;
1017
- name: string;
1018
- operationType: string;
1019
- status: "done" | "running";
1020
- thread?: string | undefined;
1021
- } | {
1022
- type: "file";
1023
- id: string;
1024
- mediaType: string;
1025
- url: string;
1026
- filename?: string | undefined;
1027
- size?: number | undefined;
1028
- toolCallId?: string | undefined;
1029
- thread?: string | undefined;
1030
- } | {
1031
- type: "object";
1032
- id: string;
1033
- typeName: string;
1034
- status: "streaming" | "error" | "done";
1035
- partial?: unknown;
1036
- object?: unknown;
1037
- error?: string | undefined;
1038
- thread?: string | undefined;
1039
- })[];
1040
- status: "streaming" | "done";
1083
+ role: 'user' | 'assistant';
1084
+ parts: UIMessagePart[];
1085
+ status: UIMessageStatus;
1041
1086
  createdAt: Date;
1042
- }[]>;
1087
+ }
1043
1088
 
1044
1089
  /**
1045
1090
  * Octavus skill tool names
@@ -1086,4 +1131,4 @@ declare function isOctavusSkillTool(toolName: string): toolName is OctavusSkillT
1086
1131
  */
1087
1132
  declare function getSkillSlugFromToolCall(toolName: string, args: Record<string, unknown> | undefined): string | undefined;
1088
1133
 
1089
- export { AppError, type BlockEndEvent, type BlockStartEvent, type ChatMessage, ConflictError, type DisplayMode, type ErrorEvent, type FileAvailableEvent, type FileInfo, type FinishEvent, type FinishReason, type GeneratedFile, MAIN_THREAD, type MessagePart, type MessagePartType, type MessageRole, NotFoundError, OCTAVUS_SKILL_TOOLS, type ObjectInfo, type OctavusSkillToolName, type PendingToolCall, type ReasoningDeltaEvent, type ReasoningEndEvent, type ReasoningStartEvent, type ResourceUpdateEvent, type ResourceUpdateHandler, type SourceDocumentEvent, type SourceDocumentInfo, type SourceEvent, type SourceInfo, type SourceUrlEvent, type SourceUrlInfo, type StartEvent, type StreamEvent, type TextDeltaEvent, type TextEndEvent, type TextStartEvent, type ToolCallInfo, type ToolCallStatus, type ToolHandler, type ToolHandlers, type ToolInputAvailableEvent, type ToolInputDeltaEvent, type ToolInputEndEvent, type ToolInputStartEvent, type ToolOutputAvailableEvent, type ToolOutputErrorEvent, type ToolRequestEvent, type ToolResult, type UIFilePart, type UIMessage, type UIMessagePart, type UIMessageStatus, type UIObjectPart, type UIObjectStatus, type UIOperationPart, type UIOperationStatus, type UIPartStatus, type UIReasoningPart, type UISourceDocumentPart, type UISourcePart, type UISourceUrlPart, type UITextPart, type UIToolCallPart, type UIToolCallStatus, ValidationError, chatMessageSchema, generateId, getSkillSlugFromToolCall, isMainThread, isOctavusSkillTool, isOtherThread, resolveThread, safeParseStreamEvent, safeParseUIMessage, safeParseUIMessages, threadForPart, toolResultSchema, uiMessagePartSchema, uiMessageSchema };
1134
+ export { AppError, type BlockEndEvent, type BlockStartEvent, type ChatMessage, ConflictError, type DisplayMode, type ErrorEvent, type FileAvailableEvent, type FileInfo, type FileReference, type FinishEvent, type FinishReason, type GeneratedFile, MAIN_THREAD, type MessagePart, type MessagePartType, type MessageRole, NotFoundError, OCTAVUS_SKILL_TOOLS, type ObjectInfo, type OctavusSkillToolName, type PendingToolCall, type ReasoningDeltaEvent, type ReasoningEndEvent, type ReasoningStartEvent, type ResourceUpdateEvent, type ResourceUpdateHandler, type SourceDocumentEvent, type SourceDocumentInfo, type SourceEvent, type SourceInfo, type SourceUrlEvent, type SourceUrlInfo, type StartEvent, type StreamEvent, type TextDeltaEvent, type TextEndEvent, type TextStartEvent, type ToolCallInfo, type ToolCallStatus, type ToolHandler, type ToolHandlers, type ToolInputAvailableEvent, type ToolInputDeltaEvent, type ToolInputEndEvent, type ToolInputStartEvent, type ToolOutputAvailableEvent, type ToolOutputErrorEvent, type ToolRequestEvent, type ToolResult, type UIFilePart, type UIMessage, type UIMessagePart, type UIMessageStatus, type UIObjectPart, type UIObjectStatus, type UIOperationPart, type UIOperationStatus, type UIPartStatus, type UIReasoningPart, type UISourceDocumentPart, type UISourcePart, type UISourceUrlPart, type UITextPart, type UIToolCallPart, type UIToolCallStatus, ValidationError, chatMessageSchema, fileReferenceSchema, generateId, getSkillSlugFromToolCall, isAbortError, isFileReference, isFileReferenceArray, isMainThread, isOctavusSkillTool, isOtherThread, resolveThread, safeParseStreamEvent, safeParseUIMessage, safeParseUIMessages, threadForPart, toolResultSchema, uiMessagePartSchema, uiMessageSchema };