@octavus/core 0.0.12 → 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 +553 -493
- package/dist/index.js +36 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -23,510 +23,55 @@ declare class ConflictError extends AppError {
|
|
|
23
23
|
declare function generateId(): string;
|
|
24
24
|
|
|
25
25
|
/**
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
* Events are organized into two categories:
|
|
29
|
-
* - Standard Events (====): Aligned with Vercel AI SDK for interoperability
|
|
30
|
-
* - Octavus Events (----): Octavus-specific protocol events
|
|
31
|
-
*/
|
|
32
|
-
/**
|
|
33
|
-
* Display mode - controls execution indicator visibility (NOT final message visibility).
|
|
34
|
-
* - hidden: Block runs silently
|
|
35
|
-
* - name: Shows block/tool name
|
|
36
|
-
* - description: Shows description
|
|
37
|
-
* - stream: Shows live streaming content
|
|
26
|
+
* Default thread name when none is specified.
|
|
38
27
|
*/
|
|
39
|
-
|
|
40
|
-
type ToolHandler = (args: Record<string, unknown>) => Promise<unknown>;
|
|
41
|
-
type ToolHandlers = Record<string, ToolHandler>;
|
|
42
|
-
type ResourceUpdateHandler = (name: string, value: unknown) => Promise<void> | void;
|
|
43
|
-
type MessageRole = 'user' | 'assistant' | 'system';
|
|
44
|
-
type ToolCallStatus = 'pending' | 'streaming' | 'available' | 'error';
|
|
45
|
-
interface ToolCallInfo {
|
|
46
|
-
id: string;
|
|
47
|
-
name: string;
|
|
48
|
-
description?: string;
|
|
49
|
-
arguments: Record<string, unknown>;
|
|
50
|
-
status: ToolCallStatus;
|
|
51
|
-
result?: unknown;
|
|
52
|
-
error?: string;
|
|
53
|
-
}
|
|
54
|
-
/** Signals the start of a response message */
|
|
55
|
-
interface StartEvent {
|
|
56
|
-
type: 'start';
|
|
57
|
-
messageId?: string;
|
|
58
|
-
}
|
|
59
|
-
/** Signals completion of streaming */
|
|
60
|
-
interface FinishEvent {
|
|
61
|
-
type: 'finish';
|
|
62
|
-
finishReason: FinishReason;
|
|
63
|
-
}
|
|
64
|
-
/** Error during streaming */
|
|
65
|
-
interface ErrorEvent {
|
|
66
|
-
type: 'error';
|
|
67
|
-
errorText: string;
|
|
68
|
-
}
|
|
69
|
-
type FinishReason = 'stop' | 'tool-calls' | 'length' | 'content-filter' | 'error' | 'other';
|
|
28
|
+
declare const MAIN_THREAD: "main";
|
|
70
29
|
/**
|
|
71
|
-
*
|
|
72
|
-
*
|
|
73
|
-
* If `responseType` is set, the text content is JSON matching a custom type.
|
|
74
|
-
* The client SDK should parse the text as a structured object instead of
|
|
75
|
-
* displaying it as plain text.
|
|
30
|
+
* Resolve a thread name, defaulting to main thread.
|
|
76
31
|
*/
|
|
77
|
-
|
|
78
|
-
type: 'text-start';
|
|
79
|
-
id: string;
|
|
80
|
-
/**
|
|
81
|
-
* If specified, the text content is JSON matching this type name.
|
|
82
|
-
* Client SDK should parse as object, not display as text.
|
|
83
|
-
*/
|
|
84
|
-
responseType?: string;
|
|
85
|
-
}
|
|
86
|
-
/** Incremental text content */
|
|
87
|
-
interface TextDeltaEvent {
|
|
88
|
-
type: 'text-delta';
|
|
89
|
-
id: string;
|
|
90
|
-
delta: string;
|
|
91
|
-
}
|
|
92
|
-
/** End of text generation for a specific text part */
|
|
93
|
-
interface TextEndEvent {
|
|
94
|
-
type: 'text-end';
|
|
95
|
-
id: string;
|
|
96
|
-
}
|
|
97
|
-
/** Start of reasoning/thinking generation */
|
|
98
|
-
interface ReasoningStartEvent {
|
|
99
|
-
type: 'reasoning-start';
|
|
100
|
-
id: string;
|
|
101
|
-
}
|
|
102
|
-
/** Incremental reasoning content */
|
|
103
|
-
interface ReasoningDeltaEvent {
|
|
104
|
-
type: 'reasoning-delta';
|
|
105
|
-
id: string;
|
|
106
|
-
delta: string;
|
|
107
|
-
}
|
|
108
|
-
/** End of reasoning generation */
|
|
109
|
-
interface ReasoningEndEvent {
|
|
110
|
-
type: 'reasoning-end';
|
|
111
|
-
id: string;
|
|
112
|
-
}
|
|
113
|
-
/** Tool call initiated - input streaming will follow */
|
|
114
|
-
interface ToolInputStartEvent {
|
|
115
|
-
type: 'tool-input-start';
|
|
116
|
-
toolCallId: string;
|
|
117
|
-
toolName: string;
|
|
118
|
-
/** Human-readable title/description for the tool call */
|
|
119
|
-
title?: string;
|
|
120
|
-
}
|
|
121
|
-
/** Incremental tool input/arguments */
|
|
122
|
-
interface ToolInputDeltaEvent {
|
|
123
|
-
type: 'tool-input-delta';
|
|
124
|
-
toolCallId: string;
|
|
125
|
-
inputTextDelta: string;
|
|
126
|
-
}
|
|
127
|
-
/** Tool input streaming has ended */
|
|
128
|
-
interface ToolInputEndEvent {
|
|
129
|
-
type: 'tool-input-end';
|
|
130
|
-
toolCallId: string;
|
|
131
|
-
}
|
|
132
|
-
/** Tool input is complete and available */
|
|
133
|
-
interface ToolInputAvailableEvent {
|
|
134
|
-
type: 'tool-input-available';
|
|
135
|
-
toolCallId: string;
|
|
136
|
-
toolName: string;
|
|
137
|
-
input: unknown;
|
|
138
|
-
}
|
|
139
|
-
/** Tool output/result is available */
|
|
140
|
-
interface ToolOutputAvailableEvent {
|
|
141
|
-
type: 'tool-output-available';
|
|
142
|
-
toolCallId: string;
|
|
143
|
-
output: unknown;
|
|
144
|
-
}
|
|
145
|
-
/** Tool execution resulted in error */
|
|
146
|
-
interface ToolOutputErrorEvent {
|
|
147
|
-
type: 'tool-output-error';
|
|
148
|
-
toolCallId: string;
|
|
149
|
-
errorText: string;
|
|
150
|
-
}
|
|
151
|
-
/** Base source event fields */
|
|
152
|
-
interface BaseSourceEvent {
|
|
153
|
-
type: 'source';
|
|
154
|
-
/** The ID of the source */
|
|
155
|
-
id: string;
|
|
156
|
-
}
|
|
157
|
-
/** URL source from web search or similar tools */
|
|
158
|
-
interface SourceUrlEvent extends BaseSourceEvent {
|
|
159
|
-
sourceType: 'url';
|
|
160
|
-
/** The URL of the source */
|
|
161
|
-
url: string;
|
|
162
|
-
/** The title of the source */
|
|
163
|
-
title?: string;
|
|
164
|
-
}
|
|
165
|
-
/** Document source from file processing */
|
|
166
|
-
interface SourceDocumentEvent extends BaseSourceEvent {
|
|
167
|
-
sourceType: 'document';
|
|
168
|
-
/** IANA media type of the document (e.g., 'application/pdf') */
|
|
169
|
-
mediaType: string;
|
|
170
|
-
/** The title of the document */
|
|
171
|
-
title: string;
|
|
172
|
-
/** Optional filename of the document */
|
|
173
|
-
filename?: string;
|
|
174
|
-
}
|
|
175
|
-
/** Source event - union of all source types */
|
|
176
|
-
type SourceEvent = SourceUrlEvent | SourceDocumentEvent;
|
|
177
|
-
/** Protocol block execution started */
|
|
178
|
-
interface BlockStartEvent {
|
|
179
|
-
type: 'block-start';
|
|
180
|
-
blockId: string;
|
|
181
|
-
blockName: string;
|
|
182
|
-
blockType: string;
|
|
183
|
-
display: DisplayMode;
|
|
184
|
-
description?: string;
|
|
185
|
-
/** Whether output goes to main chat (false for independent blocks) */
|
|
186
|
-
outputToChat?: boolean;
|
|
187
|
-
/** Thread name (undefined or 'main' for main thread) */
|
|
188
|
-
thread?: string;
|
|
189
|
-
}
|
|
190
|
-
/** Protocol block execution completed */
|
|
191
|
-
interface BlockEndEvent {
|
|
192
|
-
type: 'block-end';
|
|
193
|
-
blockId: string;
|
|
194
|
-
summary?: string;
|
|
195
|
-
}
|
|
196
|
-
/** Resource value updated */
|
|
197
|
-
interface ResourceUpdateEvent {
|
|
198
|
-
type: 'resource-update';
|
|
199
|
-
name: string;
|
|
200
|
-
value: unknown;
|
|
201
|
-
}
|
|
202
|
-
/** Pending tool call that needs external execution (continuation pattern) */
|
|
203
|
-
interface PendingToolCall {
|
|
204
|
-
toolCallId: string;
|
|
205
|
-
toolName: string;
|
|
206
|
-
args: Record<string, unknown>;
|
|
207
|
-
/** 'llm' for LLM-initiated, 'block' for protocol block */
|
|
208
|
-
source?: 'llm' | 'block';
|
|
209
|
-
/** For block-based tools: variable name to store result in */
|
|
210
|
-
outputVariable?: string;
|
|
211
|
-
/** For block-based tools: block index to resume from after execution */
|
|
212
|
-
blockIndex?: number;
|
|
213
|
-
}
|
|
32
|
+
declare function resolveThread(thread: string | undefined): string;
|
|
214
33
|
/**
|
|
215
|
-
*
|
|
216
|
-
* Consumer should execute the tools and POST a new trigger request with toolResults.
|
|
34
|
+
* Check if a thread is the main thread.
|
|
217
35
|
*/
|
|
218
|
-
|
|
219
|
-
type: 'tool-request';
|
|
220
|
-
toolCalls: PendingToolCall[];
|
|
221
|
-
}
|
|
222
|
-
/** Result from tool execution (consumer's response to tool-request) */
|
|
223
|
-
interface ToolResult {
|
|
224
|
-
toolCallId: string;
|
|
225
|
-
toolName?: string;
|
|
226
|
-
result?: unknown;
|
|
227
|
-
error?: string;
|
|
228
|
-
outputVariable?: string;
|
|
229
|
-
blockIndex?: number;
|
|
230
|
-
}
|
|
36
|
+
declare function isMainThread(thread: string | undefined): boolean;
|
|
231
37
|
/**
|
|
232
|
-
*
|
|
233
|
-
*
|
|
38
|
+
* Normalize thread for storage in message parts.
|
|
39
|
+
* Main thread is stored as undefined to save space.
|
|
234
40
|
*/
|
|
235
|
-
|
|
236
|
-
/** Unique file ID */
|
|
237
|
-
id: string;
|
|
238
|
-
/** MIME type (e.g., 'image/png', 'application/pdf') - aligned with Vercel AI SDK */
|
|
239
|
-
mediaType: string;
|
|
240
|
-
/** URL for download/display (presigned S3 URL or data URL) */
|
|
241
|
-
url: string;
|
|
242
|
-
/** Original filename (optional, for display/download) */
|
|
243
|
-
filename?: string;
|
|
244
|
-
/** Size in bytes (optional, for display) */
|
|
245
|
-
size?: number;
|
|
246
|
-
}
|
|
41
|
+
declare function threadForPart(thread: string | undefined): string | undefined;
|
|
247
42
|
/**
|
|
248
|
-
*
|
|
249
|
-
*
|
|
43
|
+
* Check if a message part belongs to a non-main thread.
|
|
44
|
+
* Non-main thread content (e.g., "summary") is typically displayed differently.
|
|
250
45
|
*/
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
/** MIME type (aligned with Vercel AI SDK) */
|
|
256
|
-
mediaType: string;
|
|
257
|
-
/** URL for download/display */
|
|
258
|
-
url: string;
|
|
259
|
-
/** Original filename */
|
|
260
|
-
filename?: string;
|
|
261
|
-
/** Size in bytes */
|
|
262
|
-
size?: number;
|
|
263
|
-
/** Tool call that generated this file */
|
|
264
|
-
toolCallId?: string;
|
|
265
|
-
}
|
|
266
|
-
type StreamEvent = StartEvent | FinishEvent | ErrorEvent | TextStartEvent | TextDeltaEvent | TextEndEvent | ReasoningStartEvent | ReasoningDeltaEvent | ReasoningEndEvent | ToolInputStartEvent | ToolInputDeltaEvent | ToolInputEndEvent | ToolInputAvailableEvent | ToolOutputAvailableEvent | ToolOutputErrorEvent | SourceEvent | BlockStartEvent | BlockEndEvent | ResourceUpdateEvent | ToolRequestEvent | FileAvailableEvent;
|
|
46
|
+
declare function isOtherThread(part: {
|
|
47
|
+
thread?: string;
|
|
48
|
+
}): boolean;
|
|
49
|
+
|
|
267
50
|
/**
|
|
268
|
-
*
|
|
51
|
+
* Zod schemas for stream events.
|
|
52
|
+
*
|
|
53
|
+
* Schemas are organized into two categories:
|
|
54
|
+
* - Standard Events (====): Aligned with Vercel AI SDK for interoperability
|
|
55
|
+
* - Octavus Events (----): Octavus-specific protocol events
|
|
269
56
|
*/
|
|
270
|
-
|
|
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>;
|
|
271
66
|
/**
|
|
272
|
-
*
|
|
67
|
+
* Schema for file references used in trigger input and user messages.
|
|
273
68
|
*/
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
url:
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
/**
|
|
281
|
-
* Source info for document sources (from file processing)
|
|
282
|
-
*/
|
|
283
|
-
interface SourceDocumentInfo {
|
|
284
|
-
sourceType: 'document';
|
|
285
|
-
id: string;
|
|
286
|
-
mediaType: string;
|
|
287
|
-
title: string;
|
|
288
|
-
filename?: string;
|
|
289
|
-
}
|
|
290
|
-
/**
|
|
291
|
-
* Source info - union of all source types (internal)
|
|
292
|
-
*/
|
|
293
|
-
type SourceInfo = SourceUrlInfo | SourceDocumentInfo;
|
|
294
|
-
/**
|
|
295
|
-
* File info for generated files (from skill execution, code execution, etc.)
|
|
296
|
-
*/
|
|
297
|
-
interface FileInfo {
|
|
298
|
-
id: string;
|
|
299
|
-
mediaType: string;
|
|
300
|
-
url: string;
|
|
301
|
-
filename?: string;
|
|
302
|
-
size?: number;
|
|
303
|
-
toolCallId?: string;
|
|
304
|
-
}
|
|
305
|
-
/**
|
|
306
|
-
* Object info for structured output (internal storage)
|
|
307
|
-
*/
|
|
308
|
-
interface ObjectInfo {
|
|
309
|
-
id: string;
|
|
310
|
-
/** Type name from the protocol */
|
|
311
|
-
typeName: string;
|
|
312
|
-
/** The structured object value */
|
|
313
|
-
value: unknown;
|
|
314
|
-
}
|
|
315
|
-
/**
|
|
316
|
-
* A single part of a message, stored in order for proper display (internal)
|
|
317
|
-
*/
|
|
318
|
-
interface MessagePart {
|
|
319
|
-
type: MessagePartType;
|
|
320
|
-
/** Whether shown in chat UI (false = LLM sees it, user doesn't) */
|
|
321
|
-
visible: boolean;
|
|
322
|
-
/** Content for text/reasoning parts */
|
|
323
|
-
content?: string;
|
|
324
|
-
/** Tool call info for tool-call parts */
|
|
325
|
-
toolCall?: ToolCallInfo;
|
|
326
|
-
/** Source info for source parts (from web search, etc.) */
|
|
327
|
-
source?: SourceInfo;
|
|
328
|
-
/** File info for file parts (from skill execution, etc.) */
|
|
329
|
-
file?: FileInfo;
|
|
330
|
-
/** Object info for object parts (structured output) */
|
|
331
|
-
object?: ObjectInfo;
|
|
332
|
-
/** Thread name for non-main-thread content (e.g., "summary") */
|
|
333
|
-
thread?: string;
|
|
334
|
-
}
|
|
335
|
-
/**
|
|
336
|
-
* Internal chat message - stored in session state, used by LLM
|
|
337
|
-
*/
|
|
338
|
-
interface ChatMessage {
|
|
339
|
-
id: string;
|
|
340
|
-
role: MessageRole;
|
|
341
|
-
/** Ordered parts for display - preserves reasoning/tool/text order */
|
|
342
|
-
parts: MessagePart[];
|
|
343
|
-
createdAt: string;
|
|
344
|
-
/**
|
|
345
|
-
* Whether shown in chat UI (false = LLM sees it, user doesn't).
|
|
346
|
-
* Use for internal directives. Different from `display` which controls execution indicator.
|
|
347
|
-
* @default true
|
|
348
|
-
*/
|
|
349
|
-
visible?: boolean;
|
|
350
|
-
content: string;
|
|
351
|
-
toolCalls?: ToolCallInfo[];
|
|
352
|
-
reasoning?: string;
|
|
353
|
-
/** Required by Anthropic to verify reasoning blocks */
|
|
354
|
-
reasoningSignature?: string;
|
|
355
|
-
}
|
|
356
|
-
/**
|
|
357
|
-
* Status of a UI message
|
|
358
|
-
*/
|
|
359
|
-
type UIMessageStatus = 'streaming' | 'done';
|
|
360
|
-
/**
|
|
361
|
-
* Status of a UI message part
|
|
362
|
-
*/
|
|
363
|
-
type UIPartStatus = 'streaming' | 'done';
|
|
364
|
-
/**
|
|
365
|
-
* Text content in a UI message
|
|
366
|
-
*/
|
|
367
|
-
interface UITextPart {
|
|
368
|
-
type: 'text';
|
|
369
|
-
text: string;
|
|
370
|
-
status: UIPartStatus;
|
|
371
|
-
/** Thread name (undefined or 'main' for main thread) */
|
|
372
|
-
thread?: string;
|
|
373
|
-
}
|
|
374
|
-
/**
|
|
375
|
-
* Reasoning/thinking content in a UI message
|
|
376
|
-
*/
|
|
377
|
-
interface UIReasoningPart {
|
|
378
|
-
type: 'reasoning';
|
|
379
|
-
text: string;
|
|
380
|
-
status: UIPartStatus;
|
|
381
|
-
/** Thread name (undefined or 'main' for main thread) */
|
|
382
|
-
thread?: string;
|
|
383
|
-
}
|
|
384
|
-
/**
|
|
385
|
-
* Tool call status for UI
|
|
386
|
-
*/
|
|
387
|
-
type UIToolCallStatus = 'pending' | 'running' | 'done' | 'error';
|
|
388
|
-
/**
|
|
389
|
-
* Tool call in a UI message
|
|
390
|
-
*/
|
|
391
|
-
interface UIToolCallPart {
|
|
392
|
-
type: 'tool-call';
|
|
393
|
-
toolCallId: string;
|
|
394
|
-
toolName: string;
|
|
395
|
-
/** Human-readable display name (from protocol description) */
|
|
396
|
-
displayName?: string;
|
|
397
|
-
args: Record<string, unknown>;
|
|
398
|
-
result?: unknown;
|
|
399
|
-
error?: string;
|
|
400
|
-
status: UIToolCallStatus;
|
|
401
|
-
/** Thread name (undefined or 'main' for main thread) */
|
|
402
|
-
thread?: string;
|
|
403
|
-
}
|
|
404
|
-
/**
|
|
405
|
-
* Operation status for UI
|
|
406
|
-
*/
|
|
407
|
-
type UIOperationStatus = 'running' | 'done';
|
|
408
|
-
/**
|
|
409
|
-
* Internal operation in a UI message (e.g., set-resource, serialize-thread)
|
|
410
|
-
* These are Octavus-specific operations, not LLM tool calls
|
|
411
|
-
*/
|
|
412
|
-
interface UIOperationPart {
|
|
413
|
-
type: 'operation';
|
|
414
|
-
operationId: string;
|
|
415
|
-
/** Human-readable name (from block name/description) */
|
|
416
|
-
name: string;
|
|
417
|
-
/** Type of operation (e.g., 'set-resource', 'serialize-thread') */
|
|
418
|
-
operationType: string;
|
|
419
|
-
status: UIOperationStatus;
|
|
420
|
-
/** Thread name (undefined or 'main' for main thread) */
|
|
421
|
-
thread?: string;
|
|
422
|
-
}
|
|
423
|
-
/** Base UI source part fields */
|
|
424
|
-
interface BaseUISourcePart {
|
|
425
|
-
type: 'source';
|
|
426
|
-
/** The ID of the source */
|
|
427
|
-
id: string;
|
|
428
|
-
/** Thread name (undefined or 'main' for main thread) */
|
|
429
|
-
thread?: string;
|
|
430
|
-
}
|
|
431
|
-
/**
|
|
432
|
-
* URL source part (from web search results)
|
|
433
|
-
*/
|
|
434
|
-
interface UISourceUrlPart extends BaseUISourcePart {
|
|
435
|
-
sourceType: 'url';
|
|
436
|
-
url: string;
|
|
437
|
-
title?: string;
|
|
438
|
-
}
|
|
439
|
-
/**
|
|
440
|
-
* Document source part (from file processing)
|
|
441
|
-
*/
|
|
442
|
-
interface UISourceDocumentPart extends BaseUISourcePart {
|
|
443
|
-
sourceType: 'document';
|
|
444
|
-
mediaType: string;
|
|
445
|
-
title: string;
|
|
446
|
-
filename?: string;
|
|
447
|
-
}
|
|
448
|
-
/**
|
|
449
|
-
* Source part - union of all source types
|
|
450
|
-
*/
|
|
451
|
-
type UISourcePart = UISourceUrlPart | UISourceDocumentPart;
|
|
452
|
-
/**
|
|
453
|
-
* File attachment part (aligned with Vercel AI SDK FilePart).
|
|
454
|
-
* Generated by skill execution, image generation, code execution, etc.
|
|
455
|
-
*/
|
|
456
|
-
interface UIFilePart {
|
|
457
|
-
type: 'file';
|
|
458
|
-
/** Unique file ID */
|
|
459
|
-
id: string;
|
|
460
|
-
/** MIME type for rendering (aligned with Vercel AI SDK) */
|
|
461
|
-
mediaType: string;
|
|
462
|
-
/** URL for download/display (presigned URL or data URL) */
|
|
463
|
-
url: string;
|
|
464
|
-
/** Original filename (for display/download) */
|
|
465
|
-
filename?: string;
|
|
466
|
-
/** Size in bytes */
|
|
467
|
-
size?: number;
|
|
468
|
-
/** Tool call that generated this file */
|
|
469
|
-
toolCallId?: string;
|
|
470
|
-
/** Thread name (undefined or 'main' for main thread) */
|
|
471
|
-
thread?: string;
|
|
472
|
-
}
|
|
473
|
-
/**
|
|
474
|
-
* Status of a UI object part
|
|
475
|
-
*/
|
|
476
|
-
type UIObjectStatus = 'streaming' | 'done' | 'error';
|
|
477
|
-
/**
|
|
478
|
-
* Structured object part in a UI message.
|
|
479
|
-
* Used when the agent response is a typed object (structured output).
|
|
480
|
-
* Client applications can render custom UI based on the typeName.
|
|
481
|
-
*/
|
|
482
|
-
interface UIObjectPart {
|
|
483
|
-
type: 'object';
|
|
484
|
-
/** Unique part ID */
|
|
485
|
-
id: string;
|
|
486
|
-
/** The type name from the protocol (e.g., "ChatResponse") */
|
|
487
|
-
typeName: string;
|
|
488
|
-
/** Partial object while streaming (may have missing/incomplete fields) */
|
|
489
|
-
partial?: unknown;
|
|
490
|
-
/** Final validated object when done */
|
|
491
|
-
object?: unknown;
|
|
492
|
-
/** Current status */
|
|
493
|
-
status: UIObjectStatus;
|
|
494
|
-
/** Error message if status is 'error' */
|
|
495
|
-
error?: string;
|
|
496
|
-
/** Thread name (undefined or 'main' for main thread) */
|
|
497
|
-
thread?: string;
|
|
498
|
-
}
|
|
499
|
-
/**
|
|
500
|
-
* Union of all UI message part types
|
|
501
|
-
*/
|
|
502
|
-
type UIMessagePart = UITextPart | UIReasoningPart | UIToolCallPart | UIOperationPart | UISourcePart | UIFilePart | UIObjectPart;
|
|
503
|
-
/**
|
|
504
|
-
* UI Message - the client-facing message format
|
|
505
|
-
* All complexity is handled by the SDK, this is what consumers render
|
|
506
|
-
*/
|
|
507
|
-
interface UIMessage {
|
|
508
|
-
id: string;
|
|
509
|
-
role: 'user' | 'assistant';
|
|
510
|
-
parts: UIMessagePart[];
|
|
511
|
-
status: UIMessageStatus;
|
|
512
|
-
createdAt: Date;
|
|
513
|
-
}
|
|
514
|
-
|
|
515
|
-
/**
|
|
516
|
-
* Zod schemas for stream events.
|
|
517
|
-
*
|
|
518
|
-
* Schemas are organized into two categories:
|
|
519
|
-
* - Standard Events (====): Aligned with Vercel AI SDK for interoperability
|
|
520
|
-
* - Octavus Events (----): Octavus-specific protocol events
|
|
521
|
-
*/
|
|
522
|
-
|
|
523
|
-
declare const toolResultSchema: z.ZodObject<{
|
|
524
|
-
toolCallId: z.ZodString;
|
|
525
|
-
toolName: z.ZodOptional<z.ZodString>;
|
|
526
|
-
result: z.ZodOptional<z.ZodUnknown>;
|
|
527
|
-
error: z.ZodOptional<z.ZodString>;
|
|
528
|
-
outputVariable: z.ZodOptional<z.ZodString>;
|
|
529
|
-
blockIndex: z.ZodOptional<z.ZodNumber>;
|
|
69
|
+
declare const fileReferenceSchema: z.ZodObject<{
|
|
70
|
+
id: z.ZodString;
|
|
71
|
+
mediaType: z.ZodString;
|
|
72
|
+
url: z.ZodString;
|
|
73
|
+
filename: z.ZodOptional<z.ZodString>;
|
|
74
|
+
size: z.ZodOptional<z.ZodNumber>;
|
|
530
75
|
}, z.core.$strip>;
|
|
531
76
|
declare const chatMessageSchema: z.ZodObject<{
|
|
532
77
|
id: z.ZodString;
|
|
@@ -538,11 +83,11 @@ declare const chatMessageSchema: z.ZodObject<{
|
|
|
538
83
|
parts: z.ZodArray<z.ZodObject<{
|
|
539
84
|
type: z.ZodEnum<{
|
|
540
85
|
object: "object";
|
|
86
|
+
file: "file";
|
|
541
87
|
source: "source";
|
|
542
88
|
text: "text";
|
|
543
89
|
reasoning: "reasoning";
|
|
544
90
|
"tool-call": "tool-call";
|
|
545
|
-
file: "file";
|
|
546
91
|
}>;
|
|
547
92
|
visible: z.ZodBoolean;
|
|
548
93
|
content: z.ZodOptional<z.ZodString>;
|
|
@@ -1015,6 +560,521 @@ declare function safeParseUIMessages(data: unknown): z.ZodSafeParseResult<{
|
|
|
1015
560
|
status: "streaming" | "done";
|
|
1016
561
|
createdAt: Date;
|
|
1017
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 */
|
|
818
|
+
id: string;
|
|
819
|
+
/** MIME type (aligned with Vercel AI SDK) */
|
|
820
|
+
mediaType: string;
|
|
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';
|
|
840
|
+
id: string;
|
|
841
|
+
url: string;
|
|
842
|
+
title?: string;
|
|
843
|
+
}
|
|
844
|
+
/**
|
|
845
|
+
* Source info for document sources (from file processing)
|
|
846
|
+
*/
|
|
847
|
+
interface SourceDocumentInfo {
|
|
848
|
+
sourceType: 'document';
|
|
849
|
+
id: string;
|
|
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 {
|
|
862
|
+
id: string;
|
|
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 {
|
|
873
|
+
id: string;
|
|
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 {
|
|
903
|
+
id: string;
|
|
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';
|
|
957
|
+
toolCallId: string;
|
|
958
|
+
toolName: string;
|
|
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) */
|
|
980
|
+
name: string;
|
|
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 */
|
|
1023
|
+
id: string;
|
|
1024
|
+
/** MIME type for rendering (aligned with Vercel AI SDK) */
|
|
1025
|
+
mediaType: string;
|
|
1026
|
+
/** URL for download/display (presigned URL or data URL) */
|
|
1027
|
+
url: string;
|
|
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 */
|
|
1049
|
+
id: string;
|
|
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 {
|
|
1072
|
+
id: string;
|
|
1073
|
+
role: 'user' | 'assistant';
|
|
1074
|
+
parts: UIMessagePart[];
|
|
1075
|
+
status: UIMessageStatus;
|
|
1076
|
+
createdAt: Date;
|
|
1077
|
+
}
|
|
1018
1078
|
|
|
1019
1079
|
/**
|
|
1020
1080
|
* Octavus skill tool names
|
|
@@ -1061,4 +1121,4 @@ declare function isOctavusSkillTool(toolName: string): toolName is OctavusSkillT
|
|
|
1061
1121
|
*/
|
|
1062
1122
|
declare function getSkillSlugFromToolCall(toolName: string, args: Record<string, unknown> | undefined): string | undefined;
|
|
1063
1123
|
|
|
1064
|
-
export { AppError, type BlockEndEvent, type BlockStartEvent, type ChatMessage, ConflictError, type DisplayMode, type ErrorEvent, type FileAvailableEvent, type FileInfo, type FinishEvent, type FinishReason, type GeneratedFile, 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, isOctavusSkillTool, safeParseStreamEvent, safeParseUIMessage, safeParseUIMessages, 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 };
|
package/dist/index.js
CHANGED
|
@@ -32,6 +32,21 @@ function generateId() {
|
|
|
32
32
|
return `${Date.now()}-${Math.random().toString(36).substring(2, 9)}`;
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
+
// src/thread.ts
|
|
36
|
+
var MAIN_THREAD = "main";
|
|
37
|
+
function resolveThread(thread) {
|
|
38
|
+
return thread ?? MAIN_THREAD;
|
|
39
|
+
}
|
|
40
|
+
function isMainThread(thread) {
|
|
41
|
+
return thread === void 0 || thread === MAIN_THREAD;
|
|
42
|
+
}
|
|
43
|
+
function threadForPart(thread) {
|
|
44
|
+
return isMainThread(thread) ? void 0 : thread;
|
|
45
|
+
}
|
|
46
|
+
function isOtherThread(part) {
|
|
47
|
+
return !isMainThread(part.thread);
|
|
48
|
+
}
|
|
49
|
+
|
|
35
50
|
// src/stream/schemas.ts
|
|
36
51
|
import { z } from "zod";
|
|
37
52
|
var displayModeSchema = z.enum(["hidden", "name", "description", "stream"]);
|
|
@@ -183,6 +198,13 @@ var toolResultSchema = z.object({
|
|
|
183
198
|
outputVariable: z.string().optional(),
|
|
184
199
|
blockIndex: z.number().optional()
|
|
185
200
|
});
|
|
201
|
+
var fileReferenceSchema = z.object({
|
|
202
|
+
id: z.string(),
|
|
203
|
+
mediaType: z.string(),
|
|
204
|
+
url: z.string(),
|
|
205
|
+
filename: z.string().optional(),
|
|
206
|
+
size: z.number().optional()
|
|
207
|
+
});
|
|
186
208
|
var fileAvailableEventSchema = z.object({
|
|
187
209
|
type: z.literal("file-available"),
|
|
188
210
|
id: z.string(),
|
|
@@ -378,6 +400,12 @@ function safeParseUIMessage(data) {
|
|
|
378
400
|
function safeParseUIMessages(data) {
|
|
379
401
|
return z.array(uiMessageSchema).safeParse(data);
|
|
380
402
|
}
|
|
403
|
+
function isFileReference(value) {
|
|
404
|
+
return fileReferenceSchema.safeParse(value).success;
|
|
405
|
+
}
|
|
406
|
+
function isFileReferenceArray(value) {
|
|
407
|
+
return z.array(fileReferenceSchema).safeParse(value).success;
|
|
408
|
+
}
|
|
381
409
|
|
|
382
410
|
// src/skills.ts
|
|
383
411
|
var OCTAVUS_SKILL_TOOLS = {
|
|
@@ -403,16 +431,24 @@ function getSkillSlugFromToolCall(toolName, args) {
|
|
|
403
431
|
export {
|
|
404
432
|
AppError,
|
|
405
433
|
ConflictError,
|
|
434
|
+
MAIN_THREAD,
|
|
406
435
|
NotFoundError,
|
|
407
436
|
OCTAVUS_SKILL_TOOLS,
|
|
408
437
|
ValidationError,
|
|
409
438
|
chatMessageSchema,
|
|
439
|
+
fileReferenceSchema,
|
|
410
440
|
generateId,
|
|
411
441
|
getSkillSlugFromToolCall,
|
|
442
|
+
isFileReference,
|
|
443
|
+
isFileReferenceArray,
|
|
444
|
+
isMainThread,
|
|
412
445
|
isOctavusSkillTool,
|
|
446
|
+
isOtherThread,
|
|
447
|
+
resolveThread,
|
|
413
448
|
safeParseStreamEvent,
|
|
414
449
|
safeParseUIMessage,
|
|
415
450
|
safeParseUIMessages,
|
|
451
|
+
threadForPart,
|
|
416
452
|
toolResultSchema,
|
|
417
453
|
uiMessagePartSchema,
|
|
418
454
|
uiMessageSchema
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/errors.ts","../src/utils.ts","../src/stream/schemas.ts","../src/skills.ts"],"sourcesContent":["export class AppError extends Error {\n constructor(\n message: string,\n public code: string,\n public statusCode = 500,\n ) {\n super(message);\n this.name = 'AppError';\n }\n}\n\nexport class NotFoundError extends AppError {\n constructor(resource: string, id: string) {\n super(`${resource} not found: ${id}`, 'NOT_FOUND', 404);\n this.name = 'NotFoundError';\n }\n}\n\nexport class ValidationError extends AppError {\n constructor(\n message: string,\n public issues?: unknown[],\n ) {\n super(message, 'VALIDATION_ERROR', 400);\n this.name = 'ValidationError';\n }\n}\n\nexport class ConflictError extends AppError {\n constructor(resource: string, identifier: string) {\n super(`${resource} already exists: ${identifier}`, 'CONFLICT', 409);\n this.name = 'ConflictError';\n }\n}\n","/**\n * Generate a unique ID for messages, tool calls, etc.\n * Format: timestamp-random (e.g., \"1702345678901-abc123def\")\n */\nexport function generateId(): string {\n return `${Date.now()}-${Math.random().toString(36).substring(2, 9)}`;\n}\n","/**\n * Zod schemas for stream events.\n *\n * Schemas are organized into two categories:\n * - Standard Events (====): Aligned with Vercel AI SDK for interoperability\n * - Octavus Events (----): Octavus-specific protocol events\n */\n\nimport { z } from 'zod';\n\nexport const displayModeSchema = z.enum(['hidden', 'name', 'description', 'stream']);\nexport const messageRoleSchema = z.enum(['user', 'assistant', 'system']);\nexport const toolCallStatusSchema = z.enum(['pending', 'streaming', 'available', 'error']);\nexport const finishReasonSchema = z.enum([\n 'stop',\n 'tool-calls',\n 'length',\n 'content-filter',\n 'error',\n 'other',\n]);\n\nexport const toolCallInfoSchema = z.object({\n id: z.string(),\n name: z.string(),\n description: z.string().optional(),\n arguments: z.record(z.string(), z.unknown()),\n status: toolCallStatusSchema,\n result: z.unknown().optional(),\n error: z.string().optional(),\n});\n\n// =============================================================================\n// STANDARD EVENTS (aligned with Vercel AI SDK)\n// =============================================================================\n\n// ============================== Lifecycle ====================================\n\nexport const startEventSchema = z.object({\n type: z.literal('start'),\n messageId: z.string().optional(),\n});\n\nexport const finishEventSchema = z.object({\n type: z.literal('finish'),\n finishReason: finishReasonSchema,\n});\n\nexport const errorEventSchema = z.object({\n type: z.literal('error'),\n errorText: z.string(),\n});\n\n// ================================= Text ======================================\n\nexport const textStartEventSchema = z.object({\n type: z.literal('text-start'),\n id: z.string(),\n responseType: z.string().optional(),\n});\n\nexport const textDeltaEventSchema = z.object({\n type: z.literal('text-delta'),\n id: z.string(),\n delta: z.string(),\n});\n\nexport const textEndEventSchema = z.object({\n type: z.literal('text-end'),\n id: z.string(),\n});\n\n// =============================== Reasoning ===================================\n\nexport const reasoningStartEventSchema = z.object({\n type: z.literal('reasoning-start'),\n id: z.string(),\n});\n\nexport const reasoningDeltaEventSchema = z.object({\n type: z.literal('reasoning-delta'),\n id: z.string(),\n delta: z.string(),\n});\n\nexport const reasoningEndEventSchema = z.object({\n type: z.literal('reasoning-end'),\n id: z.string(),\n});\n\n// ================================= Tool ======================================\n\nexport const toolInputStartEventSchema = z.object({\n type: z.literal('tool-input-start'),\n toolCallId: z.string(),\n toolName: z.string(),\n title: z.string().optional(),\n});\n\nexport const toolInputDeltaEventSchema = z.object({\n type: z.literal('tool-input-delta'),\n toolCallId: z.string(),\n inputTextDelta: z.string(),\n});\n\nexport const toolInputEndEventSchema = z.object({\n type: z.literal('tool-input-end'),\n toolCallId: z.string(),\n});\n\nexport const toolInputAvailableEventSchema = z.object({\n type: z.literal('tool-input-available'),\n toolCallId: z.string(),\n toolName: z.string(),\n input: z.unknown(),\n});\n\nexport const toolOutputAvailableEventSchema = z.object({\n type: z.literal('tool-output-available'),\n toolCallId: z.string(),\n output: z.unknown(),\n});\n\nexport const toolOutputErrorEventSchema = z.object({\n type: z.literal('tool-output-error'),\n toolCallId: z.string(),\n errorText: z.string(),\n});\n\n// ================================ Source =====================================\n\nexport const sourceUrlEventSchema = z.object({\n type: z.literal('source'),\n sourceType: z.literal('url'),\n id: z.string(),\n url: z.string(),\n title: z.string().optional(),\n});\n\nexport const sourceDocumentEventSchema = z.object({\n type: z.literal('source'),\n sourceType: z.literal('document'),\n id: z.string(),\n mediaType: z.string(),\n title: z.string(),\n filename: z.string().optional(),\n});\n\nexport const sourceEventSchema = z.discriminatedUnion('sourceType', [\n sourceUrlEventSchema,\n sourceDocumentEventSchema,\n]);\n\n// =============================================================================\n// OCTAVUS EVENTS (protocol-specific)\n// =============================================================================\n\n// --------------------------------- Block -------------------------------------\n\nexport const blockStartEventSchema = z.object({\n type: z.literal('block-start'),\n blockId: z.string(),\n blockName: z.string(),\n blockType: z.string(),\n display: displayModeSchema,\n description: z.string().optional(),\n outputToChat: z.boolean().optional(),\n thread: z.string().optional(),\n});\n\nexport const blockEndEventSchema = z.object({\n type: z.literal('block-end'),\n blockId: z.string(),\n summary: z.string().optional(),\n});\n\nexport const resourceUpdateEventSchema = z.object({\n type: z.literal('resource-update'),\n name: z.string(),\n value: z.unknown(),\n});\n\nexport const pendingToolCallSchema = z.object({\n toolCallId: z.string(),\n toolName: z.string(),\n args: z.record(z.string(), z.unknown()),\n source: z.enum(['llm', 'block']).optional(),\n outputVariable: z.string().optional(),\n blockIndex: z.number().optional(),\n});\n\nexport const toolRequestEventSchema = z.object({\n type: z.literal('tool-request'),\n toolCalls: z.array(pendingToolCallSchema),\n});\n\nexport const toolResultSchema = z.object({\n toolCallId: z.string(),\n toolName: z.string().optional(),\n result: z.unknown().optional(),\n error: z.string().optional(),\n outputVariable: z.string().optional(),\n blockIndex: z.number().optional(),\n});\n\n// --------------------------------- File --------------------------------------\n\nexport const fileAvailableEventSchema = z.object({\n type: z.literal('file-available'),\n id: z.string(),\n mediaType: z.string(),\n url: z.string(),\n filename: z.string().optional(),\n size: z.number().optional(),\n toolCallId: z.string().optional(),\n});\n\n// =============================================================================\n// Union of all stream events\n// =============================================================================\n\n// Note: We use z.union here because source events share type: 'source' but\n// differ by sourceType. z.discriminatedUnion requires unique discriminator values.\nexport const streamEventSchema = z.union([\n // Standard events (Vercel AI SDK aligned)\n startEventSchema,\n finishEventSchema,\n errorEventSchema,\n textStartEventSchema,\n textDeltaEventSchema,\n textEndEventSchema,\n reasoningStartEventSchema,\n reasoningDeltaEventSchema,\n reasoningEndEventSchema,\n toolInputStartEventSchema,\n toolInputDeltaEventSchema,\n toolInputEndEventSchema,\n toolInputAvailableEventSchema,\n toolOutputAvailableEventSchema,\n toolOutputErrorEventSchema,\n sourceEventSchema,\n // Octavus events (protocol-specific)\n blockStartEventSchema,\n blockEndEventSchema,\n resourceUpdateEventSchema,\n toolRequestEventSchema,\n fileAvailableEventSchema,\n]);\n\n// =============================================================================\n// Internal Message Types (used by platform/runtime)\n// =============================================================================\n\nexport const messagePartTypeSchema = z.enum([\n 'text',\n 'reasoning',\n 'tool-call',\n 'source',\n 'file',\n 'object',\n]);\n\nexport const sourceUrlInfoSchema = z.object({\n sourceType: z.literal('url'),\n id: z.string(),\n url: z.string(),\n title: z.string().optional(),\n});\n\nexport const sourceDocumentInfoSchema = z.object({\n sourceType: z.literal('document'),\n id: z.string(),\n mediaType: z.string(),\n title: z.string(),\n filename: z.string().optional(),\n});\n\nexport const sourceInfoSchema = z.discriminatedUnion('sourceType', [\n sourceUrlInfoSchema,\n sourceDocumentInfoSchema,\n]);\n\nexport const fileInfoSchema = z.object({\n id: z.string(),\n mediaType: z.string(),\n url: z.string(),\n filename: z.string().optional(),\n size: z.number().optional(),\n toolCallId: z.string().optional(),\n});\n\nexport const objectInfoSchema = z.object({\n id: z.string(),\n typeName: z.string(),\n value: z.unknown(),\n});\n\nexport const messagePartSchema = z.object({\n type: messagePartTypeSchema,\n visible: z.boolean(),\n content: z.string().optional(),\n toolCall: toolCallInfoSchema.optional(),\n source: sourceInfoSchema.optional(),\n file: fileInfoSchema.optional(),\n object: objectInfoSchema.optional(),\n thread: z.string().optional(),\n});\n\nexport const chatMessageSchema = z.object({\n id: z.string(),\n role: messageRoleSchema,\n parts: z.array(messagePartSchema),\n createdAt: z.string(),\n visible: z.boolean().optional(),\n content: z.string(),\n toolCalls: z.array(toolCallInfoSchema).optional(),\n reasoning: z.string().optional(),\n reasoningSignature: z.string().optional(),\n});\n\n// =============================================================================\n// UI Message Types (used by SDKs and consumer apps)\n// =============================================================================\n\nexport const uiMessageStatusSchema = z.enum(['streaming', 'done']);\nexport const uiPartStatusSchema = z.enum(['streaming', 'done']);\nexport const uiToolCallStatusSchema = z.enum(['pending', 'running', 'done', 'error']);\n\nexport const uiTextPartSchema = z.object({\n type: z.literal('text'),\n text: z.string(),\n status: uiPartStatusSchema,\n thread: z.string().optional(),\n});\n\nexport const uiReasoningPartSchema = z.object({\n type: z.literal('reasoning'),\n text: z.string(),\n status: uiPartStatusSchema,\n thread: z.string().optional(),\n});\n\nexport const uiToolCallPartSchema = z.object({\n type: z.literal('tool-call'),\n toolCallId: z.string(),\n toolName: z.string(),\n displayName: z.string().optional(),\n args: z.record(z.string(), z.unknown()),\n result: z.unknown().optional(),\n error: z.string().optional(),\n status: uiToolCallStatusSchema,\n thread: z.string().optional(),\n});\n\nexport const uiOperationStatusSchema = z.enum(['running', 'done']);\n\nexport const uiOperationPartSchema = z.object({\n type: z.literal('operation'),\n operationId: z.string(),\n name: z.string(),\n operationType: z.string(),\n status: uiOperationStatusSchema,\n thread: z.string().optional(),\n});\n\nexport const uiSourceUrlPartSchema = z.object({\n type: z.literal('source'),\n sourceType: z.literal('url'),\n id: z.string(),\n url: z.string(),\n title: z.string().optional(),\n thread: z.string().optional(),\n});\n\nexport const uiSourceDocumentPartSchema = z.object({\n type: z.literal('source'),\n sourceType: z.literal('document'),\n id: z.string(),\n mediaType: z.string(),\n title: z.string(),\n filename: z.string().optional(),\n thread: z.string().optional(),\n});\n\nexport const uiSourcePartSchema = z.discriminatedUnion('sourceType', [\n uiSourceUrlPartSchema,\n uiSourceDocumentPartSchema,\n]);\n\nexport const uiFilePartSchema = z.object({\n type: z.literal('file'),\n id: z.string(),\n mediaType: z.string(),\n url: z.string(),\n filename: z.string().optional(),\n size: z.number().optional(),\n toolCallId: z.string().optional(),\n thread: z.string().optional(),\n});\n\nexport const uiObjectStatusSchema = z.enum(['streaming', 'done', 'error']);\n\nexport const uiObjectPartSchema = z.object({\n type: z.literal('object'),\n id: z.string(),\n typeName: z.string(),\n partial: z.unknown().optional(),\n object: z.unknown().optional(),\n status: uiObjectStatusSchema,\n error: z.string().optional(),\n thread: z.string().optional(),\n});\n\n// Note: We use z.union here because source parts share type: 'source' but\n// differ by sourceType. z.discriminatedUnion requires unique discriminator values.\nexport const uiMessagePartSchema = z.union([\n uiTextPartSchema,\n uiReasoningPartSchema,\n uiToolCallPartSchema,\n uiOperationPartSchema,\n uiSourcePartSchema,\n uiFilePartSchema,\n uiObjectPartSchema,\n]);\n\nexport const uiMessageSchema = z.object({\n id: z.string(),\n role: z.enum(['user', 'assistant']),\n parts: z.array(uiMessagePartSchema),\n status: uiMessageStatusSchema,\n createdAt: z.coerce.date(),\n});\n\nexport function safeParseStreamEvent(data: unknown) {\n return streamEventSchema.safeParse(data);\n}\n\nexport function safeParseUIMessage(data: unknown) {\n return uiMessageSchema.safeParse(data);\n}\n\nexport function safeParseUIMessages(data: unknown) {\n return z.array(uiMessageSchema).safeParse(data);\n}\n","/**\n * Octavus skill tool names\n *\n * These are internal tools executed in E2B sandboxes.\n * Use these constants to filter skill tool events from external tool call events.\n */\nexport const OCTAVUS_SKILL_TOOLS = {\n SKILL_READ: 'octavus_skill_read',\n SKILL_LIST: 'octavus_skill_list',\n SKILL_RUN: 'octavus_skill_run',\n CODE_RUN: 'octavus_code_run',\n FILE_WRITE: 'octavus_file_write',\n FILE_READ: 'octavus_file_read',\n} as const;\n\nexport type OctavusSkillToolName = (typeof OCTAVUS_SKILL_TOOLS)[keyof typeof OCTAVUS_SKILL_TOOLS];\n\n/**\n * Check if a tool name is an Octavus skill tool\n *\n * @example\n * ```typescript\n * if (isOctavusSkillTool(event.toolName)) {\n * // This is a skill tool, executed in E2B sandbox\n * const skillSlug = event.input?.skill;\n * } else {\n * // This is an external tool, executed on consumer's server\n * }\n * ```\n */\nexport function isOctavusSkillTool(toolName: string): toolName is OctavusSkillToolName {\n return Object.values(OCTAVUS_SKILL_TOOLS).includes(toolName as OctavusSkillToolName);\n}\n\n/**\n * Extract skill slug from skill tool arguments\n *\n * Most skill tools include a `skill` parameter with the skill slug.\n * Returns undefined if the tool is not a skill tool or if the skill slug is not present.\n *\n * @example\n * ```typescript\n * const slug = getSkillSlugFromToolCall(event.toolName, event.input);\n * if (slug) {\n * console.log(`Using skill: ${slug}`);\n * }\n * ```\n */\nexport function getSkillSlugFromToolCall(\n toolName: string,\n args: Record<string, unknown> | undefined,\n): string | undefined {\n if (!isOctavusSkillTool(toolName) || !args) {\n return undefined;\n }\n\n // Most skill tools have a 'skill' parameter\n if (typeof args.skill === 'string') {\n return args.skill;\n }\n\n return undefined;\n}\n"],"mappings":";AAAO,IAAM,WAAN,cAAuB,MAAM;AAAA,EAClC,YACE,SACO,MACA,aAAa,KACpB;AACA,UAAM,OAAO;AAHN;AACA;AAGP,SAAK,OAAO;AAAA,EACd;AACF;AAEO,IAAM,gBAAN,cAA4B,SAAS;AAAA,EAC1C,YAAY,UAAkB,IAAY;AACxC,UAAM,GAAG,QAAQ,eAAe,EAAE,IAAI,aAAa,GAAG;AACtD,SAAK,OAAO;AAAA,EACd;AACF;AAEO,IAAM,kBAAN,cAA8B,SAAS;AAAA,EAC5C,YACE,SACO,QACP;AACA,UAAM,SAAS,oBAAoB,GAAG;AAF/B;AAGP,SAAK,OAAO;AAAA,EACd;AACF;AAEO,IAAM,gBAAN,cAA4B,SAAS;AAAA,EAC1C,YAAY,UAAkB,YAAoB;AAChD,UAAM,GAAG,QAAQ,oBAAoB,UAAU,IAAI,YAAY,GAAG;AAClE,SAAK,OAAO;AAAA,EACd;AACF;;;AC7BO,SAAS,aAAqB;AACnC,SAAO,GAAG,KAAK,IAAI,CAAC,IAAI,KAAK,OAAO,EAAE,SAAS,EAAE,EAAE,UAAU,GAAG,CAAC,CAAC;AACpE;;;ACEA,SAAS,SAAS;AAEX,IAAM,oBAAoB,EAAE,KAAK,CAAC,UAAU,QAAQ,eAAe,QAAQ,CAAC;AAC5E,IAAM,oBAAoB,EAAE,KAAK,CAAC,QAAQ,aAAa,QAAQ,CAAC;AAChE,IAAM,uBAAuB,EAAE,KAAK,CAAC,WAAW,aAAa,aAAa,OAAO,CAAC;AAClF,IAAM,qBAAqB,EAAE,KAAK;AAAA,EACvC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CA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B,UAAoD;AACrF,SAAO,OAAO,OAAO,mBAAmB,EAAE,SAAS,QAAgC;AACrF;AAgBO,SAAS,yBACd,UACA,MACoB;AACpB,MAAI,CAAC,mBAAmB,QAAQ,KAAK,CAAC,MAAM;AAC1C,WAAO;AAAA,EACT;AAGA,MAAI,OAAO,KAAK,UAAU,UAAU;AAClC,WAAO,KAAK;AAAA,EACd;AAEA,SAAO;AACT;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/errors.ts","../src/utils.ts","../src/thread.ts","../src/stream/schemas.ts","../src/skills.ts"],"sourcesContent":["export class AppError extends Error {\n constructor(\n message: string,\n public code: string,\n public statusCode = 500,\n ) {\n super(message);\n this.name = 'AppError';\n }\n}\n\nexport class NotFoundError extends AppError {\n constructor(resource: string, id: string) {\n super(`${resource} not found: ${id}`, 'NOT_FOUND', 404);\n this.name = 'NotFoundError';\n }\n}\n\nexport class ValidationError extends AppError {\n constructor(\n message: string,\n public issues?: unknown[],\n ) {\n super(message, 'VALIDATION_ERROR', 400);\n this.name = 'ValidationError';\n }\n}\n\nexport class ConflictError extends AppError {\n constructor(resource: string, identifier: string) {\n super(`${resource} already exists: ${identifier}`, 'CONFLICT', 409);\n this.name = 'ConflictError';\n }\n}\n","/**\n * Generate a unique ID for messages, tool calls, etc.\n * Format: timestamp-random (e.g., \"1702345678901-abc123def\")\n */\nexport function generateId(): string {\n return `${Date.now()}-${Math.random().toString(36).substring(2, 9)}`;\n}\n","/**\n * Default thread name when none is specified.\n */\nexport const MAIN_THREAD = 'main' as const;\n\n/**\n * Resolve a thread name, defaulting to main thread.\n */\nexport function resolveThread(thread: string | undefined): string {\n return thread ?? MAIN_THREAD;\n}\n\n/**\n * Check if a thread is the main thread.\n */\nexport function isMainThread(thread: string | undefined): boolean {\n return thread === undefined || thread === MAIN_THREAD;\n}\n\n/**\n * Normalize thread for storage in message parts.\n * Main thread is stored as undefined to save space.\n */\nexport function threadForPart(thread: string | undefined): string | undefined {\n return isMainThread(thread) ? undefined : thread;\n}\n\n/**\n * Check if a message part belongs to a non-main thread.\n * Non-main thread content (e.g., \"summary\") is typically displayed differently.\n */\nexport function isOtherThread(part: { thread?: string }): boolean {\n return !isMainThread(part.thread);\n}\n","/**\n * Zod schemas for stream events.\n *\n * Schemas are organized into two categories:\n * - Standard Events (====): Aligned with Vercel AI SDK for interoperability\n * - Octavus Events (----): Octavus-specific protocol events\n */\n\nimport { z } from 'zod';\n\nexport const displayModeSchema = z.enum(['hidden', 'name', 'description', 'stream']);\nexport const messageRoleSchema = z.enum(['user', 'assistant', 'system']);\nexport const toolCallStatusSchema = z.enum(['pending', 'streaming', 'available', 'error']);\nexport const finishReasonSchema = z.enum([\n 'stop',\n 'tool-calls',\n 'length',\n 'content-filter',\n 'error',\n 'other',\n]);\n\nexport const toolCallInfoSchema = z.object({\n id: z.string(),\n name: z.string(),\n description: z.string().optional(),\n arguments: z.record(z.string(), z.unknown()),\n status: toolCallStatusSchema,\n result: z.unknown().optional(),\n error: z.string().optional(),\n});\n\n// =============================================================================\n// STANDARD EVENTS (aligned with Vercel AI SDK)\n// =============================================================================\n\n// ============================== Lifecycle ====================================\n\nexport const startEventSchema = z.object({\n type: z.literal('start'),\n messageId: z.string().optional(),\n});\n\nexport const finishEventSchema = z.object({\n type: z.literal('finish'),\n finishReason: finishReasonSchema,\n});\n\nexport const errorEventSchema = z.object({\n type: z.literal('error'),\n errorText: z.string(),\n});\n\n// ================================= Text ======================================\n\nexport const textStartEventSchema = z.object({\n type: z.literal('text-start'),\n id: z.string(),\n responseType: z.string().optional(),\n});\n\nexport const textDeltaEventSchema = z.object({\n type: z.literal('text-delta'),\n id: z.string(),\n delta: z.string(),\n});\n\nexport const textEndEventSchema = z.object({\n type: z.literal('text-end'),\n id: z.string(),\n});\n\n// =============================== Reasoning ===================================\n\nexport const reasoningStartEventSchema = z.object({\n type: z.literal('reasoning-start'),\n id: z.string(),\n});\n\nexport const reasoningDeltaEventSchema = z.object({\n type: z.literal('reasoning-delta'),\n id: z.string(),\n delta: z.string(),\n});\n\nexport const reasoningEndEventSchema = z.object({\n type: z.literal('reasoning-end'),\n id: z.string(),\n});\n\n// ================================= Tool ======================================\n\nexport const toolInputStartEventSchema = z.object({\n type: z.literal('tool-input-start'),\n toolCallId: z.string(),\n toolName: z.string(),\n title: z.string().optional(),\n});\n\nexport const toolInputDeltaEventSchema = z.object({\n type: z.literal('tool-input-delta'),\n toolCallId: z.string(),\n inputTextDelta: z.string(),\n});\n\nexport const toolInputEndEventSchema = z.object({\n type: z.literal('tool-input-end'),\n toolCallId: z.string(),\n});\n\nexport const toolInputAvailableEventSchema = z.object({\n type: z.literal('tool-input-available'),\n toolCallId: z.string(),\n toolName: z.string(),\n input: z.unknown(),\n});\n\nexport const toolOutputAvailableEventSchema = z.object({\n type: z.literal('tool-output-available'),\n toolCallId: z.string(),\n output: z.unknown(),\n});\n\nexport const toolOutputErrorEventSchema = z.object({\n type: z.literal('tool-output-error'),\n toolCallId: z.string(),\n errorText: z.string(),\n});\n\n// ================================ Source =====================================\n\nexport const sourceUrlEventSchema = z.object({\n type: z.literal('source'),\n sourceType: z.literal('url'),\n id: z.string(),\n url: z.string(),\n title: z.string().optional(),\n});\n\nexport const sourceDocumentEventSchema = z.object({\n type: z.literal('source'),\n sourceType: z.literal('document'),\n id: z.string(),\n mediaType: z.string(),\n title: z.string(),\n filename: z.string().optional(),\n});\n\nexport const sourceEventSchema = z.discriminatedUnion('sourceType', [\n sourceUrlEventSchema,\n sourceDocumentEventSchema,\n]);\n\n// =============================================================================\n// OCTAVUS EVENTS (protocol-specific)\n// =============================================================================\n\n// --------------------------------- Block -------------------------------------\n\nexport const blockStartEventSchema = z.object({\n type: z.literal('block-start'),\n blockId: z.string(),\n blockName: z.string(),\n blockType: z.string(),\n display: displayModeSchema,\n description: z.string().optional(),\n outputToChat: z.boolean().optional(),\n thread: z.string().optional(),\n});\n\nexport const blockEndEventSchema = z.object({\n type: z.literal('block-end'),\n blockId: z.string(),\n summary: z.string().optional(),\n});\n\nexport const resourceUpdateEventSchema = z.object({\n type: z.literal('resource-update'),\n name: z.string(),\n value: z.unknown(),\n});\n\nexport const pendingToolCallSchema = z.object({\n toolCallId: z.string(),\n toolName: z.string(),\n args: z.record(z.string(), z.unknown()),\n source: z.enum(['llm', 'block']).optional(),\n outputVariable: z.string().optional(),\n blockIndex: z.number().optional(),\n});\n\nexport const toolRequestEventSchema = z.object({\n type: z.literal('tool-request'),\n toolCalls: z.array(pendingToolCallSchema),\n});\n\nexport const toolResultSchema = z.object({\n toolCallId: z.string(),\n toolName: z.string().optional(),\n result: z.unknown().optional(),\n error: z.string().optional(),\n outputVariable: z.string().optional(),\n blockIndex: z.number().optional(),\n});\n\n// --------------------------------- File --------------------------------------\n\n/**\n * Schema for file references used in trigger input and user messages.\n */\nexport const fileReferenceSchema = z.object({\n id: z.string(),\n mediaType: z.string(),\n url: z.string(),\n filename: z.string().optional(),\n size: z.number().optional(),\n});\n\nexport const fileAvailableEventSchema = z.object({\n type: z.literal('file-available'),\n id: z.string(),\n mediaType: z.string(),\n url: z.string(),\n filename: z.string().optional(),\n size: z.number().optional(),\n toolCallId: z.string().optional(),\n});\n\n// =============================================================================\n// Union of all stream events\n// =============================================================================\n\n// Note: We use z.union here because source events share type: 'source' but\n// differ by sourceType. z.discriminatedUnion requires unique discriminator values.\nexport const streamEventSchema = z.union([\n // Standard events (Vercel AI SDK aligned)\n startEventSchema,\n finishEventSchema,\n errorEventSchema,\n textStartEventSchema,\n textDeltaEventSchema,\n textEndEventSchema,\n reasoningStartEventSchema,\n reasoningDeltaEventSchema,\n reasoningEndEventSchema,\n toolInputStartEventSchema,\n toolInputDeltaEventSchema,\n toolInputEndEventSchema,\n toolInputAvailableEventSchema,\n toolOutputAvailableEventSchema,\n toolOutputErrorEventSchema,\n sourceEventSchema,\n // Octavus events (protocol-specific)\n blockStartEventSchema,\n blockEndEventSchema,\n resourceUpdateEventSchema,\n toolRequestEventSchema,\n fileAvailableEventSchema,\n]);\n\n// =============================================================================\n// Internal Message Types (used by platform/runtime)\n// =============================================================================\n\nexport const messagePartTypeSchema = z.enum([\n 'text',\n 'reasoning',\n 'tool-call',\n 'source',\n 'file',\n 'object',\n]);\n\nexport const sourceUrlInfoSchema = z.object({\n sourceType: z.literal('url'),\n id: z.string(),\n url: z.string(),\n title: z.string().optional(),\n});\n\nexport const sourceDocumentInfoSchema = z.object({\n sourceType: z.literal('document'),\n id: z.string(),\n mediaType: z.string(),\n title: z.string(),\n filename: z.string().optional(),\n});\n\nexport const sourceInfoSchema = z.discriminatedUnion('sourceType', [\n sourceUrlInfoSchema,\n sourceDocumentInfoSchema,\n]);\n\nexport const fileInfoSchema = z.object({\n id: z.string(),\n mediaType: z.string(),\n url: z.string(),\n filename: z.string().optional(),\n size: z.number().optional(),\n toolCallId: z.string().optional(),\n});\n\nexport const objectInfoSchema = z.object({\n id: z.string(),\n typeName: z.string(),\n value: z.unknown(),\n});\n\nexport const messagePartSchema = z.object({\n type: messagePartTypeSchema,\n visible: z.boolean(),\n content: z.string().optional(),\n toolCall: toolCallInfoSchema.optional(),\n source: sourceInfoSchema.optional(),\n file: fileInfoSchema.optional(),\n object: objectInfoSchema.optional(),\n thread: z.string().optional(),\n});\n\nexport const chatMessageSchema = z.object({\n id: z.string(),\n role: messageRoleSchema,\n parts: z.array(messagePartSchema),\n createdAt: z.string(),\n visible: z.boolean().optional(),\n content: z.string(),\n toolCalls: z.array(toolCallInfoSchema).optional(),\n reasoning: z.string().optional(),\n reasoningSignature: z.string().optional(),\n});\n\n// =============================================================================\n// UI Message Types (used by SDKs and consumer apps)\n// =============================================================================\n\nexport const uiMessageStatusSchema = z.enum(['streaming', 'done']);\nexport const uiPartStatusSchema = z.enum(['streaming', 'done']);\nexport const uiToolCallStatusSchema = z.enum(['pending', 'running', 'done', 'error']);\n\nexport const uiTextPartSchema = z.object({\n type: z.literal('text'),\n text: z.string(),\n status: uiPartStatusSchema,\n thread: z.string().optional(),\n});\n\nexport const uiReasoningPartSchema = z.object({\n type: z.literal('reasoning'),\n text: z.string(),\n status: uiPartStatusSchema,\n thread: z.string().optional(),\n});\n\nexport const uiToolCallPartSchema = z.object({\n type: z.literal('tool-call'),\n toolCallId: z.string(),\n toolName: z.string(),\n displayName: z.string().optional(),\n args: z.record(z.string(), z.unknown()),\n result: z.unknown().optional(),\n error: z.string().optional(),\n status: uiToolCallStatusSchema,\n thread: z.string().optional(),\n});\n\nexport const uiOperationStatusSchema = z.enum(['running', 'done']);\n\nexport const uiOperationPartSchema = z.object({\n type: z.literal('operation'),\n operationId: z.string(),\n name: z.string(),\n operationType: z.string(),\n status: uiOperationStatusSchema,\n thread: z.string().optional(),\n});\n\nexport const uiSourceUrlPartSchema = z.object({\n type: z.literal('source'),\n sourceType: z.literal('url'),\n id: z.string(),\n url: z.string(),\n title: z.string().optional(),\n thread: z.string().optional(),\n});\n\nexport const uiSourceDocumentPartSchema = z.object({\n type: z.literal('source'),\n sourceType: z.literal('document'),\n id: z.string(),\n mediaType: z.string(),\n title: z.string(),\n filename: z.string().optional(),\n thread: z.string().optional(),\n});\n\nexport const uiSourcePartSchema = z.discriminatedUnion('sourceType', [\n uiSourceUrlPartSchema,\n uiSourceDocumentPartSchema,\n]);\n\nexport const uiFilePartSchema = z.object({\n type: z.literal('file'),\n id: z.string(),\n mediaType: z.string(),\n url: z.string(),\n filename: z.string().optional(),\n size: z.number().optional(),\n toolCallId: z.string().optional(),\n thread: z.string().optional(),\n});\n\nexport const uiObjectStatusSchema = z.enum(['streaming', 'done', 'error']);\n\nexport const uiObjectPartSchema = z.object({\n type: z.literal('object'),\n id: z.string(),\n typeName: z.string(),\n partial: z.unknown().optional(),\n object: z.unknown().optional(),\n status: uiObjectStatusSchema,\n error: z.string().optional(),\n thread: z.string().optional(),\n});\n\n// Note: We use z.union here because source parts share type: 'source' but\n// differ by sourceType. z.discriminatedUnion requires unique discriminator values.\nexport const uiMessagePartSchema = z.union([\n uiTextPartSchema,\n uiReasoningPartSchema,\n uiToolCallPartSchema,\n uiOperationPartSchema,\n uiSourcePartSchema,\n uiFilePartSchema,\n uiObjectPartSchema,\n]);\n\nexport const uiMessageSchema = z.object({\n id: z.string(),\n role: z.enum(['user', 'assistant']),\n parts: z.array(uiMessagePartSchema),\n status: uiMessageStatusSchema,\n createdAt: z.coerce.date(),\n});\n\nexport function safeParseStreamEvent(data: unknown) {\n return streamEventSchema.safeParse(data);\n}\n\nexport function safeParseUIMessage(data: unknown) {\n return uiMessageSchema.safeParse(data);\n}\n\nexport function safeParseUIMessages(data: unknown) {\n return z.array(uiMessageSchema).safeParse(data);\n}\n\n// =============================================================================\n// Type Guards\n// =============================================================================\n\n/**\n * Type guard to check if a value is a FileReference object.\n */\nexport function isFileReference(value: unknown): value is z.infer<typeof fileReferenceSchema> {\n return fileReferenceSchema.safeParse(value).success;\n}\n\n/**\n * Type guard to check if a value is an array of FileReference objects.\n */\nexport function isFileReferenceArray(\n value: unknown,\n): value is z.infer<typeof fileReferenceSchema>[] {\n return z.array(fileReferenceSchema).safeParse(value).success;\n}\n","/**\n * Octavus skill tool names\n *\n * These are internal tools executed in E2B sandboxes.\n * Use these constants to filter skill tool events from external tool call events.\n */\nexport const OCTAVUS_SKILL_TOOLS = {\n SKILL_READ: 'octavus_skill_read',\n SKILL_LIST: 'octavus_skill_list',\n SKILL_RUN: 'octavus_skill_run',\n CODE_RUN: 'octavus_code_run',\n FILE_WRITE: 'octavus_file_write',\n FILE_READ: 'octavus_file_read',\n} as const;\n\nexport type OctavusSkillToolName = (typeof OCTAVUS_SKILL_TOOLS)[keyof typeof OCTAVUS_SKILL_TOOLS];\n\n/**\n * Check if a tool name is an Octavus skill tool\n *\n * @example\n * ```typescript\n * if (isOctavusSkillTool(event.toolName)) {\n * // This is a skill tool, executed in E2B sandbox\n * const skillSlug = event.input?.skill;\n * } else {\n * // This is an external tool, executed on consumer's server\n * }\n * ```\n */\nexport function isOctavusSkillTool(toolName: string): toolName is OctavusSkillToolName {\n return Object.values(OCTAVUS_SKILL_TOOLS).includes(toolName as OctavusSkillToolName);\n}\n\n/**\n * Extract skill slug from skill tool arguments\n *\n * Most skill tools include a `skill` parameter with the skill slug.\n * Returns undefined if the tool is not a skill tool or if the skill slug is not present.\n *\n * @example\n * ```typescript\n * const slug = getSkillSlugFromToolCall(event.toolName, event.input);\n * if (slug) {\n * console.log(`Using skill: ${slug}`);\n * }\n * ```\n */\nexport function getSkillSlugFromToolCall(\n toolName: string,\n args: Record<string, unknown> | undefined,\n): string | undefined {\n if (!isOctavusSkillTool(toolName) || !args) {\n return undefined;\n }\n\n // Most skill tools have a 'skill' parameter\n if (typeof args.skill === 'string') {\n return args.skill;\n }\n\n return undefined;\n}\n"],"mappings":";AAAO,IAAM,WAAN,cAAuB,MAAM;AAAA,EAClC,YACE,SACO,MACA,aAAa,KACpB;AACA,UAAM,OAAO;AAHN;AACA;AAGP,SAAK,OAAO;AAAA,EACd;AACF;AAEO,IAAM,gBAAN,cAA4B,SAAS;AAAA,EAC1C,YAAY,UAAkB,IAAY;AACxC,UAAM,GAAG,QAAQ,eAAe,EAAE,IAAI,aAAa,GAAG;AACtD,SAAK,OAAO;AAAA,EACd;AACF;AAEO,IAAM,kBAAN,cAA8B,SAAS;AAAA,EAC5C,YACE,SACO,QACP;AACA,UAAM,SAAS,oBAAoB,GAAG;AAF/B;AAGP,SAAK,OAAO;AAAA,EACd;AACF;AAEO,IAAM,gBAAN,cAA4B,SAAS;AAAA,EAC1C,YAAY,UAAkB,YAAoB;AAChD,UAAM,GAAG,QAAQ,oBAAoB,UAAU,IAAI,YAAY,GAAG;AAClE,SAAK,OAAO;AAAA,EACd;AACF;;;AC7BO,SAAS,aAAqB;AACnC,SAAO,GAAG,KAAK,IAAI,CAAC,IAAI,KAAK,OAAO,EAAE,SAAS,EAAE,EAAE,UAAU,GAAG,CAAC,CAAC;AACpE;;;ACHO,IAAM,cAAc;AAKpB,SAAS,cAAc,QAAoC;AAChE,SAAO,UAAU;AACnB;AAKO,SAAS,aAAa,QAAqC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