@octavus/docs 0.0.8 → 1.0.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/README.md +127 -0
- package/content/01-getting-started/01-introduction.md +3 -3
- package/content/01-getting-started/02-quickstart.md +40 -17
- package/content/02-server-sdk/01-overview.md +54 -11
- package/content/02-server-sdk/02-sessions.md +166 -15
- package/content/02-server-sdk/03-tools.md +21 -21
- package/content/02-server-sdk/04-streaming.md +50 -20
- package/content/02-server-sdk/05-cli.md +247 -0
- package/content/03-client-sdk/01-overview.md +65 -35
- package/content/03-client-sdk/02-messages.md +116 -8
- package/content/03-client-sdk/03-streaming.md +36 -17
- package/content/03-client-sdk/04-execution-blocks.md +8 -12
- package/content/03-client-sdk/05-socket-transport.md +161 -45
- package/content/03-client-sdk/06-http-transport.md +48 -24
- package/content/03-client-sdk/07-structured-output.md +412 -0
- package/content/03-client-sdk/08-file-uploads.md +473 -0
- package/content/03-client-sdk/09-error-handling.md +274 -0
- package/content/04-protocol/01-overview.md +25 -14
- package/content/04-protocol/02-input-resources.md +35 -35
- package/content/04-protocol/03-triggers.md +9 -11
- package/content/04-protocol/04-tools.md +72 -29
- package/content/04-protocol/05-skills.md +304 -0
- package/content/04-protocol/06-handlers.md +304 -0
- package/content/04-protocol/07-agent-config.md +334 -0
- package/content/04-protocol/08-provider-options.md +294 -0
- package/content/04-protocol/09-skills-advanced.md +439 -0
- package/content/04-protocol/10-types.md +719 -0
- package/content/05-api-reference/01-overview.md +20 -21
- package/content/05-api-reference/02-sessions.md +192 -37
- package/content/05-api-reference/03-agents.md +25 -37
- package/content/06-examples/01-overview.md +6 -4
- package/content/06-examples/02-nextjs-chat.md +28 -18
- package/content/06-examples/03-socket-chat.md +53 -30
- package/content/06-examples/_meta.md +0 -1
- package/dist/chunk-WJ2W3DUC.js +663 -0
- package/dist/chunk-WJ2W3DUC.js.map +1 -0
- package/dist/content.js +1 -1
- package/dist/docs.json +106 -34
- 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 +106 -34
- package/package.json +12 -2
- package/content/04-protocol/05-handlers.md +0 -251
- package/content/04-protocol/06-agent-config.md +0 -209
- package/dist/chunk-232K4EME.js +0 -439
- package/dist/chunk-232K4EME.js.map +0 -1
- package/dist/chunk-2JDZLMS3.js +0 -439
- package/dist/chunk-2JDZLMS3.js.map +0 -1
- package/dist/chunk-2YMRODFE.js +0 -421
- package/dist/chunk-2YMRODFE.js.map +0 -1
- package/dist/chunk-2ZBPX5QB.js +0 -421
- package/dist/chunk-2ZBPX5QB.js.map +0 -1
- package/dist/chunk-3PIIST4D.js +0 -421
- package/dist/chunk-3PIIST4D.js.map +0 -1
- package/dist/chunk-42JETGDO.js +0 -421
- package/dist/chunk-42JETGDO.js.map +0 -1
- package/dist/chunk-4WWUKU4V.js +0 -421
- package/dist/chunk-4WWUKU4V.js.map +0 -1
- package/dist/chunk-5M7DS4DF.js +0 -519
- package/dist/chunk-5M7DS4DF.js.map +0 -1
- package/dist/chunk-6JQ3OMGF.js +0 -421
- package/dist/chunk-6JQ3OMGF.js.map +0 -1
- package/dist/chunk-7AOWCJHW.js +0 -421
- package/dist/chunk-7AOWCJHW.js.map +0 -1
- package/dist/chunk-7AS4ST73.js +0 -421
- package/dist/chunk-7AS4ST73.js.map +0 -1
- package/dist/chunk-7F5WOCIL.js +0 -421
- package/dist/chunk-7F5WOCIL.js.map +0 -1
- package/dist/chunk-7FPUAWSX.js +0 -421
- package/dist/chunk-7FPUAWSX.js.map +0 -1
- package/dist/chunk-APASMJBS.js +0 -421
- package/dist/chunk-APASMJBS.js.map +0 -1
- package/dist/chunk-BCEV3WV2.js +0 -421
- package/dist/chunk-BCEV3WV2.js.map +0 -1
- package/dist/chunk-CHGY4G27.js +0 -421
- package/dist/chunk-CHGY4G27.js.map +0 -1
- package/dist/chunk-CI7JDWKU.js +0 -421
- package/dist/chunk-CI7JDWKU.js.map +0 -1
- package/dist/chunk-CVFWWRL7.js +0 -421
- package/dist/chunk-CVFWWRL7.js.map +0 -1
- package/dist/chunk-EPDM2NIJ.js +0 -421
- package/dist/chunk-EPDM2NIJ.js.map +0 -1
- package/dist/chunk-ESGSYVGK.js +0 -421
- package/dist/chunk-ESGSYVGK.js.map +0 -1
- package/dist/chunk-GDCTM2SV.js +0 -421
- package/dist/chunk-GDCTM2SV.js.map +0 -1
- package/dist/chunk-GJ6FMIPD.js +0 -421
- package/dist/chunk-GJ6FMIPD.js.map +0 -1
- package/dist/chunk-H6JGSSAJ.js +0 -519
- package/dist/chunk-H6JGSSAJ.js.map +0 -1
- package/dist/chunk-IKQHGGUZ.js +0 -421
- package/dist/chunk-IKQHGGUZ.js.map +0 -1
- package/dist/chunk-IUKE3XDN.js +0 -421
- package/dist/chunk-IUKE3XDN.js.map +0 -1
- package/dist/chunk-J26MLMLN.js +0 -421
- package/dist/chunk-J26MLMLN.js.map +0 -1
- package/dist/chunk-J7BMB3ZW.js +0 -421
- package/dist/chunk-J7BMB3ZW.js.map +0 -1
- package/dist/chunk-JCBQRD5N.js +0 -421
- package/dist/chunk-JCBQRD5N.js.map +0 -1
- package/dist/chunk-JOB6YWEF.js +0 -421
- package/dist/chunk-JOB6YWEF.js.map +0 -1
- package/dist/chunk-JZRABTHU.js +0 -519
- package/dist/chunk-JZRABTHU.js.map +0 -1
- package/dist/chunk-K3GFQUMC.js +0 -421
- package/dist/chunk-K3GFQUMC.js.map +0 -1
- package/dist/chunk-LWYMRXBF.js +0 -421
- package/dist/chunk-LWYMRXBF.js.map +0 -1
- package/dist/chunk-M2R2NDPR.js +0 -421
- package/dist/chunk-M2R2NDPR.js.map +0 -1
- package/dist/chunk-MA3P7WCA.js +0 -421
- package/dist/chunk-MA3P7WCA.js.map +0 -1
- package/dist/chunk-MDMRCS4W.mjs +0 -421
- package/dist/chunk-MDMRCS4W.mjs.map +0 -1
- package/dist/chunk-MJXTA2R6.js +0 -421
- package/dist/chunk-MJXTA2R6.js.map +0 -1
- package/dist/chunk-NFVJQNDP.js +0 -421
- package/dist/chunk-NFVJQNDP.js.map +0 -1
- package/dist/chunk-O5TLYMQP.js +0 -421
- package/dist/chunk-O5TLYMQP.js.map +0 -1
- package/dist/chunk-OECAPVSX.js +0 -439
- package/dist/chunk-OECAPVSX.js.map +0 -1
- package/dist/chunk-OL5QDJ42.js +0 -483
- package/dist/chunk-OL5QDJ42.js.map +0 -1
- package/dist/chunk-PMOVVTHO.js +0 -519
- package/dist/chunk-PMOVVTHO.js.map +0 -1
- package/dist/chunk-QCHDPR2D.js +0 -421
- package/dist/chunk-QCHDPR2D.js.map +0 -1
- package/dist/chunk-R5MTVABN.js +0 -439
- package/dist/chunk-R5MTVABN.js.map +0 -1
- package/dist/chunk-RJ4H4YVA.js +0 -519
- package/dist/chunk-RJ4H4YVA.js.map +0 -1
- package/dist/chunk-S5U4IWCR.js +0 -439
- package/dist/chunk-S5U4IWCR.js.map +0 -1
- package/dist/chunk-SCKIOGKI.js +0 -421
- package/dist/chunk-SCKIOGKI.js.map +0 -1
- package/dist/chunk-TGJSIJYP.js +0 -421
- package/dist/chunk-TGJSIJYP.js.map +0 -1
- package/dist/chunk-TQZRBMU7.js +0 -421
- package/dist/chunk-TQZRBMU7.js.map +0 -1
- package/dist/chunk-TRL4RSEO.js +0 -421
- package/dist/chunk-TRL4RSEO.js.map +0 -1
- package/dist/chunk-TWUMRHQ7.js +0 -421
- package/dist/chunk-TWUMRHQ7.js.map +0 -1
- package/dist/chunk-UCJE36LL.js +0 -519
- package/dist/chunk-UCJE36LL.js.map +0 -1
- package/dist/chunk-VCASA6KL.js +0 -421
- package/dist/chunk-VCASA6KL.js.map +0 -1
- package/dist/chunk-VWPQ6ORV.js +0 -421
- package/dist/chunk-VWPQ6ORV.js.map +0 -1
- package/dist/chunk-WPXKIHLT.js +0 -421
- package/dist/chunk-WPXKIHLT.js.map +0 -1
- package/dist/chunk-WUNFFJ32.js +0 -421
- package/dist/chunk-WUNFFJ32.js.map +0 -1
- package/dist/chunk-WW7TRC7S.js +0 -519
- package/dist/chunk-WW7TRC7S.js.map +0 -1
- package/dist/chunk-XVSMRXBJ.js +0 -421
- package/dist/chunk-XVSMRXBJ.js.map +0 -1
- package/dist/chunk-YPPXXV3I.js +0 -421
- package/dist/chunk-YPPXXV3I.js.map +0 -1
- package/dist/chunk-ZKZVV4OQ.js +0 -421
- package/dist/chunk-ZKZVV4OQ.js.map +0 -1
- package/dist/chunk-ZOFEX73I.js +0 -421
- package/dist/chunk-ZOFEX73I.js.map +0 -1
- package/dist/content.mjs +0 -17
- package/dist/content.mjs.map +0 -1
- package/dist/index.mjs +0 -11
- package/dist/index.mjs.map +0 -1
- package/dist/search.mjs +0 -30
- package/dist/search.mjs.map +0 -1
- package/dist/types-BltYGlWI.d.ts +0 -36
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Error Handling
|
|
3
|
+
description: Handling errors in streaming responses with structured error types.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Error Handling
|
|
7
|
+
|
|
8
|
+
Octavus provides structured error handling across all transports. Errors are categorized by type and source, enabling you to build appropriate UI responses and monitoring.
|
|
9
|
+
|
|
10
|
+
## Error Types
|
|
11
|
+
|
|
12
|
+
The `onError` callback receives an `OctavusError` with structured information:
|
|
13
|
+
|
|
14
|
+
```typescript
|
|
15
|
+
import { useOctavusChat, type OctavusError } from '@octavus/react';
|
|
16
|
+
|
|
17
|
+
const { error, status } = useOctavusChat({
|
|
18
|
+
transport,
|
|
19
|
+
onError: (err: OctavusError) => {
|
|
20
|
+
console.error('Chat error:', {
|
|
21
|
+
type: err.errorType, // Error classification
|
|
22
|
+
message: err.message, // Human-readable message
|
|
23
|
+
source: err.source, // Where the error originated
|
|
24
|
+
retryable: err.retryable, // Can be retried
|
|
25
|
+
retryAfter: err.retryAfter, // Seconds to wait (rate limits)
|
|
26
|
+
code: err.code, // Machine-readable code
|
|
27
|
+
provider: err.provider, // Provider details (if applicable)
|
|
28
|
+
});
|
|
29
|
+
},
|
|
30
|
+
});
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Error Classification
|
|
34
|
+
|
|
35
|
+
### Error Types
|
|
36
|
+
|
|
37
|
+
| Type | Description | Typical Response |
|
|
38
|
+
| ---------------------- | --------------------- | ------------------- |
|
|
39
|
+
| `rate_limit_error` | Too many requests | Show retry timer |
|
|
40
|
+
| `quota_exceeded_error` | Usage quota exceeded | Show upgrade prompt |
|
|
41
|
+
| `authentication_error` | Invalid API key | Check configuration |
|
|
42
|
+
| `permission_error` | No access to resource | Check permissions |
|
|
43
|
+
| `validation_error` | Invalid request | Fix request data |
|
|
44
|
+
| `provider_error` | LLM provider issue | Retry or show error |
|
|
45
|
+
| `provider_overloaded` | Provider at capacity | Retry with backoff |
|
|
46
|
+
| `provider_timeout` | Provider timed out | Retry |
|
|
47
|
+
| `tool_error` | Tool execution failed | Show tool error |
|
|
48
|
+
| `internal_error` | Platform error | Show generic error |
|
|
49
|
+
|
|
50
|
+
### Error Sources
|
|
51
|
+
|
|
52
|
+
| Source | Description |
|
|
53
|
+
| ---------- | -------------------------------------------- |
|
|
54
|
+
| `platform` | Octavus platform error |
|
|
55
|
+
| `provider` | LLM provider error (OpenAI, Anthropic, etc.) |
|
|
56
|
+
| `tool` | Tool execution error |
|
|
57
|
+
| `client` | Client-side error (network, parsing) |
|
|
58
|
+
|
|
59
|
+
## Type Guards
|
|
60
|
+
|
|
61
|
+
Use type guards to handle specific error types:
|
|
62
|
+
|
|
63
|
+
```typescript
|
|
64
|
+
import {
|
|
65
|
+
useOctavusChat,
|
|
66
|
+
isRateLimitError,
|
|
67
|
+
isAuthenticationError,
|
|
68
|
+
isProviderError,
|
|
69
|
+
isToolError,
|
|
70
|
+
isRetryableError,
|
|
71
|
+
} from '@octavus/react';
|
|
72
|
+
|
|
73
|
+
const { error } = useOctavusChat({
|
|
74
|
+
transport,
|
|
75
|
+
onError: (err) => {
|
|
76
|
+
if (isRateLimitError(err)) {
|
|
77
|
+
// Show countdown timer
|
|
78
|
+
showRetryTimer(err.retryAfter ?? 60);
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
if (isAuthenticationError(err)) {
|
|
83
|
+
// Configuration issue - shouldn't happen in production
|
|
84
|
+
reportConfigError(err);
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
if (isProviderError(err)) {
|
|
89
|
+
// LLM service issue
|
|
90
|
+
showProviderError(err.provider?.name ?? 'AI service');
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
if (isToolError(err)) {
|
|
95
|
+
// Tool failed - already shown inline
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
if (isRetryableError(err)) {
|
|
100
|
+
// Generic retryable error
|
|
101
|
+
showRetryButton();
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// Non-retryable error
|
|
106
|
+
showGenericError(err.message);
|
|
107
|
+
},
|
|
108
|
+
});
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
## Provider Error Details
|
|
112
|
+
|
|
113
|
+
When errors come from LLM providers, additional details are available:
|
|
114
|
+
|
|
115
|
+
```typescript
|
|
116
|
+
if (isProviderError(error) && error.provider) {
|
|
117
|
+
console.log({
|
|
118
|
+
name: error.provider.name, // 'anthropic', 'openai', 'google'
|
|
119
|
+
model: error.provider.model, // Model that caused the error
|
|
120
|
+
statusCode: error.provider.statusCode, // HTTP status code
|
|
121
|
+
errorType: error.provider.errorType, // Provider's error type
|
|
122
|
+
requestId: error.provider.requestId, // For support tickets
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
## Building Error UI
|
|
128
|
+
|
|
129
|
+
```tsx
|
|
130
|
+
import {
|
|
131
|
+
useOctavusChat,
|
|
132
|
+
isRateLimitError,
|
|
133
|
+
isAuthenticationError,
|
|
134
|
+
isProviderError,
|
|
135
|
+
} from '@octavus/react';
|
|
136
|
+
|
|
137
|
+
function Chat() {
|
|
138
|
+
const { error, status } = useOctavusChat({ transport });
|
|
139
|
+
|
|
140
|
+
return (
|
|
141
|
+
<div>
|
|
142
|
+
{/* Error display */}
|
|
143
|
+
{error && (
|
|
144
|
+
<div className="bg-red-50 border border-red-200 rounded-lg p-4">
|
|
145
|
+
<div className="font-medium text-red-800">{getErrorTitle(error)}</div>
|
|
146
|
+
<p className="text-red-600 text-sm mt-1">{error.message}</p>
|
|
147
|
+
{isRateLimitError(error) && error.retryAfter && (
|
|
148
|
+
<p className="text-red-500 text-sm mt-2">
|
|
149
|
+
Please try again in {error.retryAfter} seconds
|
|
150
|
+
</p>
|
|
151
|
+
)}
|
|
152
|
+
{error.retryable && <button className="mt-3 text-red-700 underline">Try again</button>}
|
|
153
|
+
</div>
|
|
154
|
+
)}
|
|
155
|
+
</div>
|
|
156
|
+
);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
function getErrorTitle(error: OctavusError): string {
|
|
160
|
+
if (isRateLimitError(error)) return 'Service is busy';
|
|
161
|
+
if (isAuthenticationError(error)) return 'Configuration error';
|
|
162
|
+
if (isProviderError(error)) return 'AI service unavailable';
|
|
163
|
+
return 'Something went wrong';
|
|
164
|
+
}
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
## Monitoring & Logging
|
|
168
|
+
|
|
169
|
+
Log errors for monitoring and debugging:
|
|
170
|
+
|
|
171
|
+
```typescript
|
|
172
|
+
useOctavusChat({
|
|
173
|
+
transport,
|
|
174
|
+
onError: (err) => {
|
|
175
|
+
// Send to your monitoring service
|
|
176
|
+
analytics.track('octavus_error', {
|
|
177
|
+
errorType: err.errorType,
|
|
178
|
+
source: err.source,
|
|
179
|
+
retryable: err.retryable,
|
|
180
|
+
code: err.code,
|
|
181
|
+
provider: err.provider?.name,
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
// Log for debugging
|
|
185
|
+
console.error('[Octavus]', {
|
|
186
|
+
type: err.errorType,
|
|
187
|
+
message: err.message,
|
|
188
|
+
source: err.source,
|
|
189
|
+
provider: err.provider,
|
|
190
|
+
});
|
|
191
|
+
},
|
|
192
|
+
});
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
## Error State
|
|
196
|
+
|
|
197
|
+
The hook exposes error state directly:
|
|
198
|
+
|
|
199
|
+
```typescript
|
|
200
|
+
const { error, status } = useOctavusChat({ transport });
|
|
201
|
+
|
|
202
|
+
// status is 'error' when an error occurred
|
|
203
|
+
// error contains the OctavusError object
|
|
204
|
+
|
|
205
|
+
// Clear error by sending a new message
|
|
206
|
+
await send('user-message', { USER_MESSAGE: 'Try again' });
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
## Rate Limit Handling
|
|
210
|
+
|
|
211
|
+
Rate limits include retry information:
|
|
212
|
+
|
|
213
|
+
```typescript
|
|
214
|
+
if (isRateLimitError(error)) {
|
|
215
|
+
const waitTime = error.retryAfter ?? 60; // Default to 60 seconds
|
|
216
|
+
|
|
217
|
+
// Show countdown
|
|
218
|
+
setCountdown(waitTime);
|
|
219
|
+
const timer = setInterval(() => {
|
|
220
|
+
setCountdown((c) => {
|
|
221
|
+
if (c <= 1) {
|
|
222
|
+
clearInterval(timer);
|
|
223
|
+
return 0;
|
|
224
|
+
}
|
|
225
|
+
return c - 1;
|
|
226
|
+
});
|
|
227
|
+
}, 1000);
|
|
228
|
+
}
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
## Error Event Structure
|
|
232
|
+
|
|
233
|
+
For custom transports or direct event handling, errors follow this structure:
|
|
234
|
+
|
|
235
|
+
```typescript
|
|
236
|
+
interface ErrorEvent {
|
|
237
|
+
type: 'error';
|
|
238
|
+
errorType: ErrorType;
|
|
239
|
+
message: string;
|
|
240
|
+
source: ErrorSource;
|
|
241
|
+
retryable: boolean;
|
|
242
|
+
retryAfter?: number;
|
|
243
|
+
code?: string;
|
|
244
|
+
provider?: {
|
|
245
|
+
name: string;
|
|
246
|
+
model?: string;
|
|
247
|
+
statusCode?: number;
|
|
248
|
+
errorType?: string;
|
|
249
|
+
requestId?: string;
|
|
250
|
+
};
|
|
251
|
+
tool?: {
|
|
252
|
+
name: string;
|
|
253
|
+
callId?: string;
|
|
254
|
+
};
|
|
255
|
+
}
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
## Tool Errors
|
|
259
|
+
|
|
260
|
+
Tool errors are handled differently—they appear inline on the tool call:
|
|
261
|
+
|
|
262
|
+
```tsx
|
|
263
|
+
function ToolCallPart({ part }: { part: UIToolCallPart }) {
|
|
264
|
+
return (
|
|
265
|
+
<div>
|
|
266
|
+
<span>{part.toolName}</span>
|
|
267
|
+
|
|
268
|
+
{part.status === 'error' && <div className="text-red-500 text-sm mt-1">{part.error}</div>}
|
|
269
|
+
</div>
|
|
270
|
+
);
|
|
271
|
+
}
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
Tool errors don't trigger `onError`—they're captured on the tool call part itself.
|
|
@@ -29,7 +29,7 @@ input:
|
|
|
29
29
|
resources:
|
|
30
30
|
CONVERSATION_SUMMARY:
|
|
31
31
|
description: Summary for handoff
|
|
32
|
-
default:
|
|
32
|
+
default: ''
|
|
33
33
|
|
|
34
34
|
# How the agent can be invoked
|
|
35
35
|
triggers:
|
|
@@ -53,25 +53,33 @@ tools:
|
|
|
53
53
|
parameters:
|
|
54
54
|
userId: { type: string }
|
|
55
55
|
|
|
56
|
+
# Octavus skills (provider-agnostic code execution)
|
|
57
|
+
skills:
|
|
58
|
+
qr-code:
|
|
59
|
+
display: description
|
|
60
|
+
description: Generating QR codes
|
|
61
|
+
|
|
56
62
|
# Agent configuration (model, tools, etc.)
|
|
57
63
|
agent:
|
|
58
64
|
model: anthropic/claude-sonnet-4-5
|
|
59
|
-
system: system
|
|
65
|
+
system: system # References prompts/system.md
|
|
60
66
|
tools: [get-user-account]
|
|
61
|
-
|
|
62
|
-
|
|
67
|
+
skills: [qr-code] # Enable skills
|
|
68
|
+
imageModel: google/gemini-2.5-flash-image # Enable image generation
|
|
69
|
+
agentic: true # Allow multiple tool calls
|
|
70
|
+
thinking: medium # Extended reasoning
|
|
63
71
|
|
|
64
72
|
# What happens when triggers fire
|
|
65
73
|
handlers:
|
|
66
74
|
user-message:
|
|
67
75
|
Add user message:
|
|
68
|
-
|
|
76
|
+
block: add-message
|
|
69
77
|
role: user
|
|
70
78
|
prompt: user-message
|
|
71
79
|
input: [USER_MESSAGE]
|
|
72
|
-
|
|
80
|
+
|
|
73
81
|
Respond to user:
|
|
74
|
-
|
|
82
|
+
block: next-message
|
|
75
83
|
```
|
|
76
84
|
|
|
77
85
|
## File Structure
|
|
@@ -99,12 +107,12 @@ my-agent/
|
|
|
99
107
|
}
|
|
100
108
|
```
|
|
101
109
|
|
|
102
|
-
| Field
|
|
103
|
-
|
|
104
|
-
| `slug`
|
|
105
|
-
| `name`
|
|
106
|
-
| `description` | No
|
|
107
|
-
| `format`
|
|
110
|
+
| Field | Required | Description |
|
|
111
|
+
| ------------- | -------- | ----------------------------------------------- |
|
|
112
|
+
| `slug` | Yes | URL-safe identifier (lowercase, digits, dashes) |
|
|
113
|
+
| `name` | Yes | Human-readable name |
|
|
114
|
+
| `description` | No | Brief description |
|
|
115
|
+
| `format` | Yes | `interactive` (chat) or `worker` (background) |
|
|
108
116
|
|
|
109
117
|
## Naming Conventions
|
|
110
118
|
|
|
@@ -120,6 +128,7 @@ Reference variables with `{{VARIABLE_NAME}}`:
|
|
|
120
128
|
|
|
121
129
|
```markdown
|
|
122
130
|
<!-- prompts/system.md -->
|
|
131
|
+
|
|
123
132
|
You are a support agent for {{COMPANY_NAME}}.
|
|
124
133
|
|
|
125
134
|
Help users with their {{PRODUCT_NAME}} questions.
|
|
@@ -136,6 +145,8 @@ Variables are replaced with their values at runtime. If a variable is not provid
|
|
|
136
145
|
- [Input & Resources](/docs/protocol/input-resources) — Defining agent inputs
|
|
137
146
|
- [Triggers](/docs/protocol/triggers) — How agents are invoked
|
|
138
147
|
- [Tools](/docs/protocol/tools) — External capabilities
|
|
148
|
+
- [Skills](/docs/protocol/skills) — Code execution and knowledge packages
|
|
139
149
|
- [Handlers](/docs/protocol/handlers) — Execution blocks
|
|
140
150
|
- [Agent Config](/docs/protocol/agent-config) — Model and settings
|
|
141
|
-
|
|
151
|
+
- [Provider Options](/docs/protocol/provider-options) — Provider-specific features
|
|
152
|
+
- [Types](/docs/protocol/types) — Custom type definitions
|
|
@@ -34,17 +34,17 @@ input:
|
|
|
34
34
|
type: string
|
|
35
35
|
description: Current user's ID
|
|
36
36
|
optional: true
|
|
37
|
-
default:
|
|
37
|
+
default: ''
|
|
38
38
|
```
|
|
39
39
|
|
|
40
40
|
### Input Definition
|
|
41
41
|
|
|
42
|
-
| Field
|
|
43
|
-
|
|
44
|
-
| `type`
|
|
45
|
-
| `description` | No
|
|
46
|
-
| `optional`
|
|
47
|
-
| `default`
|
|
42
|
+
| Field | Required | Description |
|
|
43
|
+
| ------------- | -------- | -------------------------------------------------------------------------------------------------------- |
|
|
44
|
+
| `type` | Yes | Data type: `string`, `number`, `integer`, `boolean`, `unknown`, or a [custom type](/docs/protocol/types) |
|
|
45
|
+
| `description` | No | Describes what this input is for |
|
|
46
|
+
| `optional` | No | If true, consumer doesn't have to provide it |
|
|
47
|
+
| `default` | No | Default value if not provided (defaults to `"NONE"`) |
|
|
48
48
|
|
|
49
49
|
### Using Inputs
|
|
50
50
|
|
|
@@ -70,6 +70,7 @@ You are a support agent for {{COMPANY_NAME}}.
|
|
|
70
70
|
## Resources
|
|
71
71
|
|
|
72
72
|
Resources are persistent state that:
|
|
73
|
+
|
|
73
74
|
- Survive across triggers
|
|
74
75
|
- Can be read and written by the agent
|
|
75
76
|
- Are synced to the consumer's application
|
|
@@ -80,7 +81,7 @@ resources:
|
|
|
80
81
|
CONVERSATION_SUMMARY:
|
|
81
82
|
type: string
|
|
82
83
|
description: Running summary of the conversation
|
|
83
|
-
default:
|
|
84
|
+
default: ''
|
|
84
85
|
|
|
85
86
|
# Resource with unknown type (for complex data)
|
|
86
87
|
USER_CONTEXT:
|
|
@@ -100,12 +101,12 @@ resources:
|
|
|
100
101
|
|
|
101
102
|
### Resource Definition
|
|
102
103
|
|
|
103
|
-
| Field
|
|
104
|
-
|
|
105
|
-
| `type`
|
|
106
|
-
| `description` | No
|
|
107
|
-
| `default`
|
|
108
|
-
| `readonly`
|
|
104
|
+
| Field | Required | Description |
|
|
105
|
+
| ------------- | -------- | -------------------------------------------------------------------------------------------------------- |
|
|
106
|
+
| `type` | Yes | Data type: `string`, `number`, `integer`, `boolean`, `unknown`, or a [custom type](/docs/protocol/types) |
|
|
107
|
+
| `description` | No | Describes the resource purpose |
|
|
108
|
+
| `default` | No | Initial value |
|
|
109
|
+
| `readonly` | No | If true, agent cannot write to it |
|
|
109
110
|
|
|
110
111
|
### Writing Resources
|
|
111
112
|
|
|
@@ -115,11 +116,11 @@ Use the `set-resource` block in handlers:
|
|
|
115
116
|
handlers:
|
|
116
117
|
request-human:
|
|
117
118
|
# ... generate summary ...
|
|
118
|
-
|
|
119
|
+
|
|
119
120
|
Save summary:
|
|
120
|
-
|
|
121
|
+
block: set-resource
|
|
121
122
|
resource: CONVERSATION_SUMMARY
|
|
122
|
-
value: SUMMARY
|
|
123
|
+
value: SUMMARY # Variable containing the value
|
|
123
124
|
```
|
|
124
125
|
|
|
125
126
|
### Resource Events
|
|
@@ -155,11 +156,11 @@ variables:
|
|
|
155
156
|
|
|
156
157
|
### Variable Definition
|
|
157
158
|
|
|
158
|
-
| Field
|
|
159
|
-
|
|
160
|
-
| `type`
|
|
161
|
-
| `description` | No
|
|
162
|
-
| `default`
|
|
159
|
+
| Field | Required | Description |
|
|
160
|
+
| ------------- | -------- | -------------------------------------------------------------------------------------------------------- |
|
|
161
|
+
| `type` | Yes | Data type: `string`, `number`, `integer`, `boolean`, `unknown`, or a [custom type](/docs/protocol/types) |
|
|
162
|
+
| `description` | No | Describes what this variable stores |
|
|
163
|
+
| `default` | No | Initial value |
|
|
163
164
|
|
|
164
165
|
### Using Variables
|
|
165
166
|
|
|
@@ -169,27 +170,26 @@ Set variables as output from blocks:
|
|
|
169
170
|
handlers:
|
|
170
171
|
request-human:
|
|
171
172
|
Serialize conversation:
|
|
172
|
-
|
|
173
|
+
block: serialize-thread
|
|
173
174
|
format: markdown
|
|
174
|
-
output: CONVERSATION_TEXT
|
|
175
|
-
|
|
175
|
+
output: CONVERSATION_TEXT # Stores result in variable
|
|
176
|
+
|
|
176
177
|
Generate summary:
|
|
177
|
-
|
|
178
|
-
output: SUMMARY
|
|
179
|
-
|
|
178
|
+
block: next-message
|
|
179
|
+
output: SUMMARY # LLM output stored in variable
|
|
180
|
+
|
|
180
181
|
Create ticket:
|
|
181
|
-
|
|
182
|
+
block: tool-call
|
|
182
183
|
tool: create-support-ticket
|
|
183
184
|
input:
|
|
184
|
-
summary: SUMMARY
|
|
185
|
+
summary: SUMMARY # Use variable as input
|
|
185
186
|
output: TICKET
|
|
186
187
|
```
|
|
187
188
|
|
|
188
189
|
## Scoping
|
|
189
190
|
|
|
190
|
-
| Type
|
|
191
|
-
|
|
192
|
-
| `input`
|
|
191
|
+
| Type | Scope | Persistence | Synced to Consumer |
|
|
192
|
+
| ----------- | ------- | ------------------------ | ------------------- |
|
|
193
|
+
| `input` | Session | Immutable | Yes (at creation) |
|
|
193
194
|
| `resources` | Session | Persists across triggers | Yes (via callbacks) |
|
|
194
|
-
| `variables` | Session | Persists across triggers | No (internal only)
|
|
195
|
-
|
|
195
|
+
| `variables` | Session | Persists across triggers | No (internal only) |
|
|
@@ -69,12 +69,14 @@ triggers:
|
|
|
69
69
|
description: Optional description
|
|
70
70
|
input:
|
|
71
71
|
VARIABLE_NAME:
|
|
72
|
-
type: string | number | boolean | unknown
|
|
72
|
+
type: string | number | integer | boolean | unknown | CustomType
|
|
73
73
|
description: What this input is for
|
|
74
|
-
optional: true | false
|
|
75
|
-
default: value
|
|
74
|
+
optional: true | false # defaults to false
|
|
75
|
+
default: value # default if optional and not provided
|
|
76
76
|
```
|
|
77
77
|
|
|
78
|
+
> **Tip**: You can use [custom types](/docs/protocol/types) for complex trigger inputs.
|
|
79
|
+
|
|
78
80
|
## Invoking Triggers
|
|
79
81
|
|
|
80
82
|
### From Client SDK
|
|
@@ -100,11 +102,7 @@ function Chat({ sessionId }: { sessionId: string }) {
|
|
|
100
102
|
const { send } = useOctavusChat({ transport });
|
|
101
103
|
|
|
102
104
|
// User message trigger with UI message
|
|
103
|
-
await send(
|
|
104
|
-
'user-message',
|
|
105
|
-
{ USER_MESSAGE: text },
|
|
106
|
-
{ userMessage: { content: text } },
|
|
107
|
-
);
|
|
105
|
+
await send('user-message', { USER_MESSAGE: text }, { userMessage: { content: text } });
|
|
108
106
|
|
|
109
107
|
// User action trigger (no input, no UI message)
|
|
110
108
|
await send('request-human');
|
|
@@ -149,18 +147,18 @@ handlers:
|
|
|
149
147
|
user-message:
|
|
150
148
|
# Blocks executed when user-message is triggered
|
|
151
149
|
Add user message:
|
|
152
|
-
|
|
150
|
+
block: add-message
|
|
153
151
|
role: user
|
|
154
152
|
prompt: user-message
|
|
155
153
|
input: [USER_MESSAGE]
|
|
156
154
|
|
|
157
155
|
Respond:
|
|
158
|
-
|
|
156
|
+
block: next-message
|
|
159
157
|
|
|
160
158
|
request-human:
|
|
161
159
|
# Blocks executed when request-human is triggered
|
|
162
160
|
Summarize:
|
|
163
|
-
|
|
161
|
+
block: serialize-thread
|
|
164
162
|
# ...
|
|
165
163
|
```
|
|
166
164
|
|