@octavus/docs 2.21.0 → 3.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/content/01-getting-started/01-introduction.md +15 -15
- package/content/01-getting-started/02-quickstart.md +2 -2
- package/content/02-server-sdk/01-overview.md +11 -7
- package/content/02-server-sdk/02-sessions.md +8 -8
- package/content/02-server-sdk/03-tools.md +11 -11
- package/content/02-server-sdk/04-streaming.md +1 -1
- package/content/02-server-sdk/05-cli.md +15 -15
- package/content/02-server-sdk/06-workers.md +10 -10
- package/content/02-server-sdk/07-debugging.md +7 -7
- package/content/02-server-sdk/08-computer.md +26 -8
- package/content/03-client-sdk/01-overview.md +11 -11
- package/content/03-client-sdk/03-streaming.md +3 -3
- package/content/03-client-sdk/04-execution-blocks.md +1 -1
- package/content/03-client-sdk/05-socket-transport.md +5 -5
- package/content/03-client-sdk/06-http-transport.md +5 -5
- package/content/03-client-sdk/07-structured-output.md +3 -3
- package/content/03-client-sdk/08-file-uploads.md +2 -2
- package/content/03-client-sdk/09-error-handling.md +3 -3
- package/content/03-client-sdk/10-client-tools.md +3 -3
- package/content/04-protocol/01-overview.md +18 -18
- package/content/04-protocol/02-input-resources.md +1 -1
- package/content/04-protocol/03-triggers.md +1 -1
- package/content/04-protocol/04-tools.md +6 -6
- package/content/04-protocol/05-skills.md +5 -5
- package/content/04-protocol/06-handlers.md +3 -0
- package/content/04-protocol/07-agent-config.md +66 -11
- package/content/04-protocol/09-skills-advanced.md +18 -18
- package/content/04-protocol/10-types.md +22 -22
- package/content/04-protocol/11-workers.md +31 -30
- package/content/04-protocol/12-references.md +10 -10
- package/content/04-protocol/13-mcp-servers.md +63 -6
- package/content/05-api-reference/02-sessions.md +2 -2
- package/content/06-examples/02-nextjs-chat.md +3 -3
- package/content/06-examples/03-socket-chat.md +3 -3
- package/dist/chunk-PD34BHI2.js +1523 -0
- package/dist/chunk-PD34BHI2.js.map +1 -0
- package/dist/content.js +1 -1
- package/dist/docs.json +39 -48
- package/dist/index.js +1 -1
- package/dist/search-index.json +1 -1
- package/dist/search.js +1 -1
- package/dist/search.js.map +1 -1
- package/dist/sections.json +39 -56
- package/package.json +1 -1
- package/content/07-migration/01-v1-to-v2.md +0 -366
- package/content/07-migration/_meta.md +0 -4
- package/dist/chunk-4XCEGHY7.js +0 -1549
- package/dist/chunk-4XCEGHY7.js.map +0 -1
- package/dist/chunk-BVJLZYTT.js +0 -1549
- package/dist/chunk-BVJLZYTT.js.map +0 -1
- package/dist/chunk-O5XHIDDC.js +0 -1549
- package/dist/chunk-O5XHIDDC.js.map +0 -1
- package/dist/chunk-PKBPANXP.js +0 -1549
- package/dist/chunk-PKBPANXP.js.map +0 -1
- package/dist/chunk-Q2SRPPSB.js +0 -1549
- package/dist/chunk-Q2SRPPSB.js.map +0 -1
- package/dist/chunk-WYHGKCEV.js +0 -1549
- package/dist/chunk-WYHGKCEV.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,366 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: Migrating from v1 to v2
|
|
3
|
-
description: Complete guide for upgrading from Octavus SDK v1.x to v2.0.
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
# Migrating from v1 to v2
|
|
7
|
-
|
|
8
|
-
This guide covers all breaking changes and new features in Octavus SDK v2.0.0.
|
|
9
|
-
|
|
10
|
-
## Overview
|
|
11
|
-
|
|
12
|
-
Version 2.0.0 introduces **client-side tool execution**, allowing tools to run in the browser with support for both automatic execution and interactive user input. This required changes to the transport layer and streaming protocol.
|
|
13
|
-
|
|
14
|
-
## Breaking Changes
|
|
15
|
-
|
|
16
|
-
### HTTP Transport Configuration
|
|
17
|
-
|
|
18
|
-
The `triggerRequest` option has been renamed to `request` and the function signature changed to support both trigger and continuation requests.
|
|
19
|
-
|
|
20
|
-
**Before (v1):**
|
|
21
|
-
|
|
22
|
-
```typescript
|
|
23
|
-
import { createHttpTransport } from '@octavus/client-sdk';
|
|
24
|
-
|
|
25
|
-
const transport = createHttpTransport({
|
|
26
|
-
triggerRequest: (triggerName, input, options) =>
|
|
27
|
-
fetch('/api/trigger', {
|
|
28
|
-
method: 'POST',
|
|
29
|
-
headers: { 'Content-Type': 'application/json' },
|
|
30
|
-
body: JSON.stringify({ sessionId, triggerName, input }),
|
|
31
|
-
signal: options?.signal,
|
|
32
|
-
}),
|
|
33
|
-
});
|
|
34
|
-
```
|
|
35
|
-
|
|
36
|
-
**After (v2):**
|
|
37
|
-
|
|
38
|
-
```typescript
|
|
39
|
-
import { createHttpTransport } from '@octavus/client-sdk';
|
|
40
|
-
|
|
41
|
-
const transport = createHttpTransport({
|
|
42
|
-
request: (payload, options) =>
|
|
43
|
-
fetch('/api/trigger', {
|
|
44
|
-
method: 'POST',
|
|
45
|
-
headers: { 'Content-Type': 'application/json' },
|
|
46
|
-
body: JSON.stringify({ sessionId, ...payload }),
|
|
47
|
-
signal: options?.signal,
|
|
48
|
-
}),
|
|
49
|
-
});
|
|
50
|
-
```
|
|
51
|
-
|
|
52
|
-
The `payload` parameter is a discriminated union with `type: 'trigger' | 'continue'`:
|
|
53
|
-
|
|
54
|
-
- **Trigger request:** `{ type: 'trigger', triggerName: string, input?: Record<string, unknown> }`
|
|
55
|
-
- **Continue request:** `{ type: 'continue', executionId: string, toolResults: ToolResult[] }`
|
|
56
|
-
|
|
57
|
-
### Server SDK Route Handler
|
|
58
|
-
|
|
59
|
-
Server-side route handlers should use the new `execute()` method which handles both triggers and continuations via the request type.
|
|
60
|
-
|
|
61
|
-
**Before (v1):**
|
|
62
|
-
|
|
63
|
-
```typescript
|
|
64
|
-
// app/api/trigger/route.ts
|
|
65
|
-
import { AgentSession, toSSEStream } from '@octavus/server-sdk';
|
|
66
|
-
|
|
67
|
-
export async function POST(request: Request) {
|
|
68
|
-
const { sessionId, triggerName, input } = await request.json();
|
|
69
|
-
|
|
70
|
-
const session = new AgentSession({
|
|
71
|
-
sessionId,
|
|
72
|
-
agentId: 'your-agent-id',
|
|
73
|
-
apiKey: process.env.OCTAVUS_API_KEY!,
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
const events = session.trigger(triggerName, input, { signal: request.signal });
|
|
77
|
-
return new Response(toSSEStream(events), {
|
|
78
|
-
headers: { 'Content-Type': 'text/event-stream' },
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
```
|
|
82
|
-
|
|
83
|
-
**After (v2):**
|
|
84
|
-
|
|
85
|
-
```typescript
|
|
86
|
-
// app/api/trigger/route.ts
|
|
87
|
-
import { AgentSession, toSSEStream, type SessionRequest } from '@octavus/server-sdk';
|
|
88
|
-
|
|
89
|
-
export async function POST(request: Request) {
|
|
90
|
-
const body = (await request.json()) as { sessionId: string } & SessionRequest;
|
|
91
|
-
const { sessionId, ...sessionRequest } = body;
|
|
92
|
-
|
|
93
|
-
const session = new AgentSession({
|
|
94
|
-
sessionId,
|
|
95
|
-
agentId: 'your-agent-id',
|
|
96
|
-
apiKey: process.env.OCTAVUS_API_KEY!,
|
|
97
|
-
});
|
|
98
|
-
|
|
99
|
-
const events = session.execute(sessionRequest, { signal: request.signal });
|
|
100
|
-
return new Response(toSSEStream(events), {
|
|
101
|
-
headers: { 'Content-Type': 'text/event-stream' },
|
|
102
|
-
});
|
|
103
|
-
}
|
|
104
|
-
```
|
|
105
|
-
|
|
106
|
-
The `SessionRequest` type is a discriminated union:
|
|
107
|
-
|
|
108
|
-
- **Trigger:** `{ type: 'trigger', triggerName: string, input?: Record<string, unknown> }`
|
|
109
|
-
- **Continue:** `{ type: 'continue', executionId: string, toolResults: ToolResult[] }`
|
|
110
|
-
|
|
111
|
-
### Export Changes
|
|
112
|
-
|
|
113
|
-
The SDKs no longer use star exports (`export * from '@octavus/core'`). Instead, they use explicit type exports and value exports. This improves tree-shaking but may require import adjustments.
|
|
114
|
-
|
|
115
|
-
**If you were importing schemas:**
|
|
116
|
-
|
|
117
|
-
Some Zod schemas are no longer re-exported from `@octavus/server-sdk`. If you need validation schemas, import them directly from `@octavus/core`:
|
|
118
|
-
|
|
119
|
-
```typescript
|
|
120
|
-
// Before (v1) - some schemas were re-exported
|
|
121
|
-
import { fileUploadRequestSchema } from '@octavus/server-sdk';
|
|
122
|
-
|
|
123
|
-
// After (v2) - import from core if needed
|
|
124
|
-
import { fileReferenceSchema } from '@octavus/core';
|
|
125
|
-
```
|
|
126
|
-
|
|
127
|
-
**Type imports remain the same:**
|
|
128
|
-
|
|
129
|
-
```typescript
|
|
130
|
-
// Types are still available
|
|
131
|
-
import type { StreamEvent, UIMessage, FileReference } from '@octavus/client-sdk';
|
|
132
|
-
```
|
|
133
|
-
|
|
134
|
-
### Custom Transport Interface
|
|
135
|
-
|
|
136
|
-
Custom transport implementations must now implement the `continueWithToolResults()` method:
|
|
137
|
-
|
|
138
|
-
```typescript
|
|
139
|
-
interface Transport {
|
|
140
|
-
trigger(triggerName: string, input?: Record<string, unknown>): AsyncIterable<StreamEvent>;
|
|
141
|
-
continueWithToolResults(executionId: string, results: ToolResult[]): AsyncIterable<StreamEvent>;
|
|
142
|
-
stop(): void;
|
|
143
|
-
}
|
|
144
|
-
```
|
|
145
|
-
|
|
146
|
-
### New ChatStatus Value
|
|
147
|
-
|
|
148
|
-
The `ChatStatus` type now includes `'awaiting-input'`:
|
|
149
|
-
|
|
150
|
-
```typescript
|
|
151
|
-
// v1
|
|
152
|
-
type ChatStatus = 'idle' | 'streaming' | 'error';
|
|
153
|
-
|
|
154
|
-
// v2
|
|
155
|
-
type ChatStatus = 'idle' | 'streaming' | 'error' | 'awaiting-input';
|
|
156
|
-
```
|
|
157
|
-
|
|
158
|
-
Update any status checks that assume only three values.
|
|
159
|
-
|
|
160
|
-
### Stream Event Changes
|
|
161
|
-
|
|
162
|
-
Two stream events have been modified:
|
|
163
|
-
|
|
164
|
-
**StartEvent and FinishEvent now include executionId:**
|
|
165
|
-
|
|
166
|
-
```typescript
|
|
167
|
-
interface StartEvent {
|
|
168
|
-
type: 'start';
|
|
169
|
-
messageId?: string;
|
|
170
|
-
executionId?: string; // New in v2
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
interface FinishEvent {
|
|
174
|
-
type: 'finish';
|
|
175
|
-
finishReason: FinishReason;
|
|
176
|
-
executionId?: string; // New in v2
|
|
177
|
-
}
|
|
178
|
-
```
|
|
179
|
-
|
|
180
|
-
**New FinishReason:**
|
|
181
|
-
|
|
182
|
-
```typescript
|
|
183
|
-
// Added 'client-tool-calls' to FinishReason
|
|
184
|
-
type FinishReason =
|
|
185
|
-
| 'stop'
|
|
186
|
-
| 'tool-calls'
|
|
187
|
-
| 'client-tool-calls' // New in v2
|
|
188
|
-
| 'length'
|
|
189
|
-
| 'content-filter'
|
|
190
|
-
| 'error'
|
|
191
|
-
| 'other';
|
|
192
|
-
```
|
|
193
|
-
|
|
194
|
-
**New ClientToolRequestEvent:**
|
|
195
|
-
|
|
196
|
-
```typescript
|
|
197
|
-
interface ClientToolRequestEvent {
|
|
198
|
-
type: 'client-tool-request';
|
|
199
|
-
executionId: string;
|
|
200
|
-
toolCalls: PendingToolCall[];
|
|
201
|
-
serverToolResults?: ToolResult[];
|
|
202
|
-
}
|
|
203
|
-
```
|
|
204
|
-
|
|
205
|
-
## New Features
|
|
206
|
-
|
|
207
|
-
### Client-Side Tools
|
|
208
|
-
|
|
209
|
-
v2 introduces client-side tool execution, allowing tools to run in the browser. This is useful for:
|
|
210
|
-
|
|
211
|
-
- Accessing browser APIs (geolocation, clipboard, etc.)
|
|
212
|
-
- Interactive tools requiring user input (confirmations, forms, selections)
|
|
213
|
-
- Tools that need access to client-side state
|
|
214
|
-
|
|
215
|
-
See the [Client Tools guide](/docs/client-sdk/client-tools) for full documentation.
|
|
216
|
-
|
|
217
|
-
#### Automatic Client Tools
|
|
218
|
-
|
|
219
|
-
Tools that execute automatically without user interaction:
|
|
220
|
-
|
|
221
|
-
```typescript
|
|
222
|
-
import { useOctavusChat, createHttpTransport } from '@octavus/react';
|
|
223
|
-
|
|
224
|
-
function Chat() {
|
|
225
|
-
const { messages, send, status } = useOctavusChat({
|
|
226
|
-
transport: createHttpTransport({
|
|
227
|
-
request: (payload, options) =>
|
|
228
|
-
fetch('/api/trigger', {
|
|
229
|
-
method: 'POST',
|
|
230
|
-
headers: { 'Content-Type': 'application/json' },
|
|
231
|
-
body: JSON.stringify({ sessionId, ...payload }),
|
|
232
|
-
signal: options?.signal,
|
|
233
|
-
}),
|
|
234
|
-
}),
|
|
235
|
-
clientTools: {
|
|
236
|
-
'get-browser-location': async (args, ctx) => {
|
|
237
|
-
const pos = await new Promise((resolve, reject) => {
|
|
238
|
-
navigator.geolocation.getCurrentPosition(resolve, reject);
|
|
239
|
-
});
|
|
240
|
-
return { lat: pos.coords.latitude, lng: pos.coords.longitude };
|
|
241
|
-
},
|
|
242
|
-
'get-clipboard': async () => {
|
|
243
|
-
return await navigator.clipboard.readText();
|
|
244
|
-
},
|
|
245
|
-
},
|
|
246
|
-
});
|
|
247
|
-
|
|
248
|
-
// ... rest of component
|
|
249
|
-
}
|
|
250
|
-
```
|
|
251
|
-
|
|
252
|
-
#### Interactive Client Tools
|
|
253
|
-
|
|
254
|
-
Tools that require user interaction before completing:
|
|
255
|
-
|
|
256
|
-
```typescript
|
|
257
|
-
import { useOctavusChat, createHttpTransport } from '@octavus/react';
|
|
258
|
-
|
|
259
|
-
function Chat() {
|
|
260
|
-
const { messages, send, status, pendingClientTools } = useOctavusChat({
|
|
261
|
-
transport: createHttpTransport({
|
|
262
|
-
request: (payload, options) =>
|
|
263
|
-
fetch('/api/trigger', {
|
|
264
|
-
method: 'POST',
|
|
265
|
-
headers: { 'Content-Type': 'application/json' },
|
|
266
|
-
body: JSON.stringify({ sessionId, ...payload }),
|
|
267
|
-
signal: options?.signal,
|
|
268
|
-
}),
|
|
269
|
-
}),
|
|
270
|
-
clientTools: {
|
|
271
|
-
'request-confirmation': 'interactive',
|
|
272
|
-
'select-option': 'interactive',
|
|
273
|
-
},
|
|
274
|
-
});
|
|
275
|
-
|
|
276
|
-
// Render UI for pending interactive tools
|
|
277
|
-
const confirmationTools = pendingClientTools['request-confirmation'] ?? [];
|
|
278
|
-
|
|
279
|
-
return (
|
|
280
|
-
<div>
|
|
281
|
-
{/* Chat messages */}
|
|
282
|
-
|
|
283
|
-
{/* Interactive tool UI */}
|
|
284
|
-
{confirmationTools.map((tool) => (
|
|
285
|
-
<ConfirmationModal
|
|
286
|
-
key={tool.toolCallId}
|
|
287
|
-
message={tool.args.message as string}
|
|
288
|
-
onConfirm={() => tool.submit({ confirmed: true })}
|
|
289
|
-
onCancel={() => tool.cancel('User declined')}
|
|
290
|
-
/>
|
|
291
|
-
))}
|
|
292
|
-
</div>
|
|
293
|
-
);
|
|
294
|
-
}
|
|
295
|
-
```
|
|
296
|
-
|
|
297
|
-
### New Types for Client Tools
|
|
298
|
-
|
|
299
|
-
```typescript
|
|
300
|
-
// Context provided to automatic tool handlers
|
|
301
|
-
interface ClientToolContext {
|
|
302
|
-
toolCallId: string;
|
|
303
|
-
toolName: string;
|
|
304
|
-
signal: AbortSignal;
|
|
305
|
-
}
|
|
306
|
-
|
|
307
|
-
// Handler types
|
|
308
|
-
type ClientToolHandler =
|
|
309
|
-
| ((args: Record<string, unknown>, ctx: ClientToolContext) => Promise<unknown>)
|
|
310
|
-
| 'interactive';
|
|
311
|
-
|
|
312
|
-
// Interactive tool with bound submit/cancel methods
|
|
313
|
-
interface InteractiveTool {
|
|
314
|
-
toolCallId: string;
|
|
315
|
-
toolName: string;
|
|
316
|
-
args: Record<string, unknown>;
|
|
317
|
-
submit: (result: unknown) => void;
|
|
318
|
-
cancel: (reason?: string) => void;
|
|
319
|
-
}
|
|
320
|
-
```
|
|
321
|
-
|
|
322
|
-
### pendingClientTools Property
|
|
323
|
-
|
|
324
|
-
Both `OctavusChat` and `useOctavusChat` now expose `pendingClientTools`:
|
|
325
|
-
|
|
326
|
-
```typescript
|
|
327
|
-
// Record keyed by tool name, with array of pending tools
|
|
328
|
-
const pendingClientTools: Record<string, InteractiveTool[]>;
|
|
329
|
-
```
|
|
330
|
-
|
|
331
|
-
This allows multiple simultaneous calls to the same tool (e.g., batch confirmations).
|
|
332
|
-
|
|
333
|
-
## Migration Checklist
|
|
334
|
-
|
|
335
|
-
Use this checklist to ensure you've addressed all breaking changes:
|
|
336
|
-
|
|
337
|
-
- [ ] Update all Octavus packages to v2.0.0
|
|
338
|
-
- [ ] Update HTTP transport from `triggerRequest` to `request` with new signature
|
|
339
|
-
- [ ] Update server route handlers to use `execute()` with `SessionRequest` type
|
|
340
|
-
- [ ] Update any status checks to handle `'awaiting-input'`
|
|
341
|
-
- [ ] Update custom transport implementations to include `continueWithToolResults()`
|
|
342
|
-
- [ ] Review any direct schema imports and update if needed
|
|
343
|
-
- [ ] (Optional) Add client-side tools for browser-based functionality
|
|
344
|
-
|
|
345
|
-
## Package Versions
|
|
346
|
-
|
|
347
|
-
All packages should be updated together to ensure compatibility:
|
|
348
|
-
|
|
349
|
-
```json
|
|
350
|
-
{
|
|
351
|
-
"dependencies": {
|
|
352
|
-
"@octavus/core": "^2.0.0",
|
|
353
|
-
"@octavus/client-sdk": "^2.0.0",
|
|
354
|
-
"@octavus/server-sdk": "^2.0.0",
|
|
355
|
-
"@octavus/react": "^2.0.0"
|
|
356
|
-
}
|
|
357
|
-
}
|
|
358
|
-
```
|
|
359
|
-
|
|
360
|
-
## Need Help?
|
|
361
|
-
|
|
362
|
-
If you encounter issues during migration:
|
|
363
|
-
|
|
364
|
-
- Check the [Client Tools documentation](/docs/client-sdk/client-tools) for the new features
|
|
365
|
-
- Review the [HTTP Transport](/docs/client-sdk/http-transport) and [Server SDK Sessions](/docs/server-sdk/sessions) docs for updated APIs
|
|
366
|
-
- [Open an issue](https://github.com/octavus-ai/agent-sdk/issues) on GitHub if you find a bug
|