@octavus/docs 0.0.7 → 0.0.8
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/02-quickstart.md +4 -3
- package/content/02-server-sdk/01-overview.md +11 -5
- package/content/02-server-sdk/02-sessions.md +6 -3
- package/content/02-server-sdk/03-tools.md +4 -2
- package/content/02-server-sdk/04-streaming.md +12 -4
- package/content/03-client-sdk/01-overview.md +11 -5
- package/content/03-client-sdk/05-socket-transport.md +263 -153
- package/content/03-client-sdk/06-http-transport.md +280 -0
- package/content/04-protocol/03-triggers.md +10 -2
- package/content/05-api-reference/01-overview.md +3 -17
- package/content/06-examples/01-overview.md +27 -0
- package/content/06-examples/02-nextjs-chat.md +343 -0
- package/content/06-examples/03-socket-chat.md +392 -0
- package/content/06-examples/_meta.md +5 -0
- package/dist/chunk-5M7DS4DF.js +519 -0
- package/dist/chunk-5M7DS4DF.js.map +1 -0
- package/dist/chunk-H6JGSSAJ.js +519 -0
- package/dist/chunk-H6JGSSAJ.js.map +1 -0
- package/dist/chunk-JZRABTHU.js +519 -0
- package/dist/chunk-JZRABTHU.js.map +1 -0
- package/dist/chunk-OL5QDJ42.js +483 -0
- package/dist/chunk-OL5QDJ42.js.map +1 -0
- package/dist/chunk-PMOVVTHO.js +519 -0
- package/dist/chunk-PMOVVTHO.js.map +1 -0
- package/dist/chunk-R5MTVABN.js +439 -0
- package/dist/chunk-R5MTVABN.js.map +1 -0
- package/dist/chunk-RJ4H4YVA.js +519 -0
- package/dist/chunk-RJ4H4YVA.js.map +1 -0
- package/dist/chunk-S5U4IWCR.js +439 -0
- package/dist/chunk-S5U4IWCR.js.map +1 -0
- package/dist/chunk-UCJE36LL.js +519 -0
- package/dist/chunk-UCJE36LL.js.map +1 -0
- package/dist/chunk-WW7TRC7S.js +519 -0
- package/dist/chunk-WW7TRC7S.js.map +1 -0
- package/dist/content.js +1 -1
- package/dist/docs.json +46 -10
- 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 +54 -10
- package/package.json +1 -1
|
@@ -72,6 +72,7 @@ Create an endpoint that handles triggers and streams responses:
|
|
|
72
72
|
|
|
73
73
|
```typescript
|
|
74
74
|
// app/api/trigger/route.ts
|
|
75
|
+
import { toSSEStream } from '@octavus/server-sdk';
|
|
75
76
|
import { octavus } from '@/lib/octavus';
|
|
76
77
|
|
|
77
78
|
export async function POST(request: Request) {
|
|
@@ -100,11 +101,11 @@ export async function POST(request: Request) {
|
|
|
100
101
|
},
|
|
101
102
|
});
|
|
102
103
|
|
|
103
|
-
// Trigger the action and
|
|
104
|
-
const
|
|
104
|
+
// Trigger the action and convert to SSE stream
|
|
105
|
+
const events = session.trigger(triggerName, input);
|
|
105
106
|
|
|
106
107
|
// Return as streaming response
|
|
107
|
-
return new Response(
|
|
108
|
+
return new Response(toSSEStream(events), {
|
|
108
109
|
headers: {
|
|
109
110
|
'Content-Type': 'text/event-stream',
|
|
110
111
|
'Cache-Control': 'no-cache',
|
|
@@ -63,12 +63,15 @@ const session = client.agentSessions.attach(sessionId, {
|
|
|
63
63
|
All responses stream in real-time:
|
|
64
64
|
|
|
65
65
|
```typescript
|
|
66
|
-
|
|
66
|
+
import { toSSEStream } from '@octavus/server-sdk';
|
|
67
|
+
|
|
68
|
+
// trigger() returns an async generator of events
|
|
69
|
+
const events = session.trigger('user-message', {
|
|
67
70
|
USER_MESSAGE: 'Hello!',
|
|
68
71
|
});
|
|
69
72
|
|
|
70
|
-
//
|
|
71
|
-
return new Response(
|
|
73
|
+
// Convert to SSE stream for HTTP responses
|
|
74
|
+
return new Response(toSSEStream(events), {
|
|
72
75
|
headers: { 'Content-Type': 'text/event-stream' },
|
|
73
76
|
});
|
|
74
77
|
```
|
|
@@ -138,15 +141,18 @@ Handles triggering and streaming for a specific session.
|
|
|
138
141
|
|
|
139
142
|
```typescript
|
|
140
143
|
class AgentSession {
|
|
141
|
-
// Trigger an action and stream
|
|
144
|
+
// Trigger an action and stream parsed events
|
|
142
145
|
trigger(
|
|
143
146
|
triggerName: string,
|
|
144
147
|
input?: Record<string, unknown>
|
|
145
|
-
):
|
|
148
|
+
): AsyncGenerator<StreamEvent>;
|
|
146
149
|
|
|
147
150
|
// Get the session ID
|
|
148
151
|
getSessionId(): string;
|
|
149
152
|
}
|
|
153
|
+
|
|
154
|
+
// Helper to convert events to SSE stream
|
|
155
|
+
function toSSEStream(events: AsyncIterable<StreamEvent>): ReadableStream<Uint8Array>;
|
|
150
156
|
```
|
|
151
157
|
|
|
152
158
|
## Next Steps
|
|
@@ -95,12 +95,15 @@ const session = client.agentSessions.attach(sessionId, {
|
|
|
95
95
|
Once attached, trigger actions on the session:
|
|
96
96
|
|
|
97
97
|
```typescript
|
|
98
|
-
|
|
98
|
+
import { toSSEStream } from '@octavus/server-sdk';
|
|
99
|
+
|
|
100
|
+
// trigger() returns an async generator of events
|
|
101
|
+
const events = session.trigger('user-message', {
|
|
99
102
|
USER_MESSAGE: 'How do I reset my password?',
|
|
100
103
|
});
|
|
101
104
|
|
|
102
|
-
//
|
|
103
|
-
return new Response(
|
|
105
|
+
// Convert to SSE stream for HTTP responses
|
|
106
|
+
return new Response(toSSEStream(events), {
|
|
104
107
|
headers: { 'Content-Type': 'text/event-stream' },
|
|
105
108
|
});
|
|
106
109
|
```
|
|
@@ -168,6 +168,8 @@ sequenceDiagram
|
|
|
168
168
|
For request-specific data (auth, headers), create handlers dynamically:
|
|
169
169
|
|
|
170
170
|
```typescript
|
|
171
|
+
import { toSSEStream } from '@octavus/server-sdk';
|
|
172
|
+
|
|
171
173
|
// In your API route
|
|
172
174
|
export async function POST(request: Request) {
|
|
173
175
|
const authToken = request.headers.get('Authorization');
|
|
@@ -190,8 +192,8 @@ export async function POST(request: Request) {
|
|
|
190
192
|
},
|
|
191
193
|
});
|
|
192
194
|
|
|
193
|
-
const
|
|
194
|
-
return new Response(
|
|
195
|
+
const events = session.trigger(triggerName, input);
|
|
196
|
+
return new Response(toSSEStream(events));
|
|
195
197
|
}
|
|
196
198
|
```
|
|
197
199
|
|
|
@@ -9,21 +9,29 @@ All Octavus responses stream in real-time using Server-Sent Events (SSE). This e
|
|
|
9
9
|
|
|
10
10
|
## Stream Response
|
|
11
11
|
|
|
12
|
-
When you trigger an action, you get
|
|
12
|
+
When you trigger an action, you get an async generator of parsed events:
|
|
13
13
|
|
|
14
14
|
```typescript
|
|
15
|
-
|
|
15
|
+
import { toSSEStream } from '@octavus/server-sdk';
|
|
16
|
+
|
|
17
|
+
// trigger() returns an async generator of StreamEvent
|
|
18
|
+
const events = session.trigger('user-message', {
|
|
16
19
|
USER_MESSAGE: 'Hello!'
|
|
17
20
|
});
|
|
18
21
|
|
|
19
|
-
//
|
|
20
|
-
return new Response(
|
|
22
|
+
// For HTTP endpoints, convert to SSE stream
|
|
23
|
+
return new Response(toSSEStream(events), {
|
|
21
24
|
headers: {
|
|
22
25
|
'Content-Type': 'text/event-stream',
|
|
23
26
|
'Cache-Control': 'no-cache',
|
|
24
27
|
'Connection': 'keep-alive',
|
|
25
28
|
},
|
|
26
29
|
});
|
|
30
|
+
|
|
31
|
+
// For sockets, iterate events directly
|
|
32
|
+
for await (const event of events) {
|
|
33
|
+
conn.write(JSON.stringify(event));
|
|
34
|
+
}
|
|
27
35
|
```
|
|
28
36
|
|
|
29
37
|
## Event Types
|
|
@@ -36,10 +36,14 @@ npm install @octavus/client-sdk
|
|
|
36
36
|
|
|
37
37
|
The Client SDK uses a **transport abstraction** to handle communication with your backend. This gives you flexibility in how events are delivered:
|
|
38
38
|
|
|
39
|
-
| Transport | Use Case |
|
|
40
|
-
|
|
41
|
-
| `createHttpTransport` | HTTP/SSE (Next.js, Express, etc.) |
|
|
42
|
-
| `createSocketTransport` | WebSocket, SockJS, or other socket protocols |
|
|
39
|
+
| Transport | Use Case | Docs |
|
|
40
|
+
|-----------|----------|------|
|
|
41
|
+
| `createHttpTransport` | HTTP/SSE (Next.js, Express, etc.) | [HTTP Transport](/docs/client-sdk/http-transport) |
|
|
42
|
+
| `createSocketTransport` | WebSocket, SockJS, or other socket protocols | [Socket Transport](/docs/client-sdk/socket-transport) |
|
|
43
|
+
|
|
44
|
+
When the transport changes (e.g., when `sessionId` changes), the `useOctavusChat` hook automatically reinitializes with the new transport.
|
|
45
|
+
|
|
46
|
+
> **Recommendation**: Use HTTP transport unless you specifically need WebSocket features (custom real-time events, Meteor/Phoenix, etc.).
|
|
43
47
|
|
|
44
48
|
## React Usage
|
|
45
49
|
|
|
@@ -294,7 +298,9 @@ class OctavusChat {
|
|
|
294
298
|
|
|
295
299
|
## Next Steps
|
|
296
300
|
|
|
301
|
+
- [HTTP Transport](/docs/client-sdk/http-transport) — HTTP/SSE integration (recommended)
|
|
302
|
+
- [Socket Transport](/docs/client-sdk/socket-transport) — WebSocket and SockJS integration
|
|
297
303
|
- [Messages](/docs/client-sdk/messages) — Working with message state
|
|
298
304
|
- [Streaming](/docs/client-sdk/streaming) — Building streaming UIs
|
|
299
305
|
- [Operations](/docs/client-sdk/execution-blocks) — Showing agent progress
|
|
300
|
-
- [
|
|
306
|
+
- [Examples](/docs/examples/overview) — Complete working examples
|