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