@octavus/docs 4.2.0 → 5.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/02-server-sdk/02-sessions.md +35 -0
- package/content/03-client-sdk/02-messages.md +23 -0
- package/content/04-protocol/04-tools.md +21 -11
- package/content/04-protocol/05-skills.md +8 -7
- package/content/04-protocol/06-handlers.md +7 -6
- package/content/04-protocol/07-agent-config.md +26 -22
- package/content/04-protocol/08-provider-options.md +12 -10
- package/content/04-protocol/09-skills-advanced.md +1 -1
- package/content/04-protocol/11-workers.md +19 -16
- package/content/04-protocol/13-mcp-servers.md +2 -1
- package/content/04-protocol/14-context-management.md +68 -0
- package/content/04-protocol/15-fast-mode.md +77 -0
- package/content/07-workforce-agents/01-overview.md +60 -0
- package/content/07-workforce-agents/02-sdk.md +105 -0
- package/content/07-workforce-agents/03-api-reference.md +146 -0
- package/content/07-workforce-agents/_meta.md +4 -0
- package/dist/{chunk-DOHOCPKJ.js → chunk-RW7WOZKG.js} +129 -31
- package/dist/chunk-RW7WOZKG.js.map +1 -0
- package/dist/content.js +1 -1
- package/dist/docs.json +60 -15
- 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 +68 -15
- package/package.json +1 -1
- package/dist/chunk-DOHOCPKJ.js.map +0 -1
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Using the SDK
|
|
3
|
+
description: Drive a Workforce Agent with the @octavus/server-sdk workforce client.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Using the SDK
|
|
7
|
+
|
|
8
|
+
`@octavus/server-sdk` ships a `workforce` client for driving an agent with its per-agent key.
|
|
9
|
+
|
|
10
|
+
## Install
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
npm install @octavus/server-sdk@{{VERSION:@octavus/server-sdk}}
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## Set up the client
|
|
17
|
+
|
|
18
|
+
Construct `OctavusClient` with your agent's API key:
|
|
19
|
+
|
|
20
|
+
```ts
|
|
21
|
+
import { OctavusClient } from '@octavus/server-sdk';
|
|
22
|
+
|
|
23
|
+
const client = new OctavusClient({
|
|
24
|
+
baseUrl: 'https://octavus.ai',
|
|
25
|
+
apiKey: process.env.OCTAVUS_AGENT_KEY, // oct_agt_...
|
|
26
|
+
});
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Run a task and wait for the result
|
|
30
|
+
|
|
31
|
+
`run()` is the all-in-one method: it dispatches a message, polls until the run finishes, and returns the completed thread.
|
|
32
|
+
|
|
33
|
+
```ts
|
|
34
|
+
const thread = await client.workforce.run(agentId, 'Summarize the latest sales report');
|
|
35
|
+
|
|
36
|
+
console.log(thread.status); // 'completed' | 'failed' | 'cancelled'
|
|
37
|
+
console.log(thread.messages); // the full conversation, including the agent's reply
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
The agent's latest turn is at the end of `thread.messages`.
|
|
41
|
+
|
|
42
|
+
## Dispatch and poll manually
|
|
43
|
+
|
|
44
|
+
For more control, dispatch and read the thread yourself:
|
|
45
|
+
|
|
46
|
+
```ts
|
|
47
|
+
const { threadId } = await client.workforce.dispatch(agentId, 'Research our top 3 competitors');
|
|
48
|
+
|
|
49
|
+
const thread = await client.workforce.getThread(agentId, threadId);
|
|
50
|
+
if (thread.status === 'completed') {
|
|
51
|
+
// ...
|
|
52
|
+
}
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
`waitForCompletion()` does the polling loop for you until the thread is terminal:
|
|
56
|
+
|
|
57
|
+
```ts
|
|
58
|
+
const { threadId } = await client.workforce.dispatch(agentId, 'Draft the Q3 board update');
|
|
59
|
+
const thread = await client.workforce.waitForCompletion(agentId, threadId);
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## Follow up in the same thread
|
|
63
|
+
|
|
64
|
+
Continue a thread with another message. It runs after the current turn finishes.
|
|
65
|
+
|
|
66
|
+
```ts
|
|
67
|
+
await client.workforce.followUp(agentId, threadId, 'Now turn that into a slide deck');
|
|
68
|
+
const thread = await client.workforce.waitForCompletion(agentId, threadId);
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
## Options
|
|
72
|
+
|
|
73
|
+
`run()` and `waitForCompletion()` accept polling options. Full runs can take several minutes, so the defaults are generous.
|
|
74
|
+
|
|
75
|
+
| Option | Type | Default | Description |
|
|
76
|
+
| ---------------- | ----------- | -------- | --------------------------------------------- |
|
|
77
|
+
| `pollIntervalMs` | number | `3000` | Delay between status checks |
|
|
78
|
+
| `timeoutMs` | number | `900000` | Max time to wait before throwing (15 minutes) |
|
|
79
|
+
| `signal` | AbortSignal | - | Cancel the wait early |
|
|
80
|
+
|
|
81
|
+
`dispatch()`, `followUp()`, and `run()` also accept `files` (an array of `FileReference`) to attach hosted files to the message.
|
|
82
|
+
|
|
83
|
+
```ts
|
|
84
|
+
const thread = await client.workforce.run(agentId, 'Review this spec', {
|
|
85
|
+
timeoutMs: 30 * 60 * 1000, // 30 minutes
|
|
86
|
+
pollIntervalMs: 5000,
|
|
87
|
+
});
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
If the timeout elapses first, `waitForCompletion()` and `run()` throw. The run keeps going on the server, so you can read it later with `getThread()`.
|
|
91
|
+
|
|
92
|
+
## Result shape
|
|
93
|
+
|
|
94
|
+
`getThread()`, `waitForCompletion()`, and `run()` return a thread:
|
|
95
|
+
|
|
96
|
+
| Field | Type | Description |
|
|
97
|
+
| --------------- | -------------- | -------------------------------------------------------------------------------------------------------------- |
|
|
98
|
+
| `threadId` | string | The thread identifier |
|
|
99
|
+
| `status` | string | `idle`, `queued`, `pending`, `running`, `completed`, `failed`, or `cancelled` |
|
|
100
|
+
| `failureReason` | string \| null | Why the run failed, when `status` is `failed` |
|
|
101
|
+
| `messages` | UIMessage[] | The conversation - text, tool and skill steps, and files (see [UIMessage parts](/docs/api-reference/sessions)) |
|
|
102
|
+
|
|
103
|
+
Use `isTerminalThreadStatus(status)` to check whether a run has finished.
|
|
104
|
+
|
|
105
|
+
The same operations are available as plain HTTP - see the [API reference](/docs/workforce-agents/api-reference).
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: API Reference
|
|
3
|
+
description: REST endpoints for the Workforce Agents API.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Workforce Agents API
|
|
7
|
+
|
|
8
|
+
Drive a single agent over HTTP. Every request is authenticated with that agent's API key, sent as a bearer token:
|
|
9
|
+
|
|
10
|
+
```
|
|
11
|
+
Authorization: Bearer oct_agt_...
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
All endpoints are scoped to one agent through the `{agentId}` path segment - find the agent ID in the agent's page URL in the dashboard. A key only works for the agent it was created for.
|
|
15
|
+
|
|
16
|
+
## Start a thread
|
|
17
|
+
|
|
18
|
+
Dispatch a message to the agent. This starts a new thread and returns immediately.
|
|
19
|
+
|
|
20
|
+
```
|
|
21
|
+
POST /api/v1/workforce/agents/{agentId}/threads
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
### Request Body
|
|
25
|
+
|
|
26
|
+
```json
|
|
27
|
+
{
|
|
28
|
+
"message": "Summarize the latest sales report"
|
|
29
|
+
}
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
| Field | Type | Required | Description |
|
|
33
|
+
| --------- | --------------- | -------- | --------------------------------- |
|
|
34
|
+
| `message` | string | Yes | The task or message for the agent |
|
|
35
|
+
| `files` | FileReference[] | No | Hosted file attachments |
|
|
36
|
+
|
|
37
|
+
### Response
|
|
38
|
+
|
|
39
|
+
Returns `201`.
|
|
40
|
+
|
|
41
|
+
```json
|
|
42
|
+
{
|
|
43
|
+
"threadId": "cm5xyz123abc456def",
|
|
44
|
+
"status": "pending"
|
|
45
|
+
}
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
Poll the [Get a thread](#get-a-thread) endpoint until the status is terminal.
|
|
49
|
+
|
|
50
|
+
### Example
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
curl -X POST https://octavus.ai/api/v1/workforce/agents/AGENT_ID/threads \
|
|
54
|
+
-H "Authorization: Bearer oct_agt_..." \
|
|
55
|
+
-H "Content-Type: application/json" \
|
|
56
|
+
-d '{ "message": "Summarize the latest sales report" }'
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## Get a thread
|
|
60
|
+
|
|
61
|
+
Read a thread's status and messages. Poll this until the run finishes.
|
|
62
|
+
|
|
63
|
+
```
|
|
64
|
+
GET /api/v1/workforce/agents/{agentId}/threads/{threadId}
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### Response
|
|
68
|
+
|
|
69
|
+
```json
|
|
70
|
+
{
|
|
71
|
+
"threadId": "cm5xyz123abc456def",
|
|
72
|
+
"status": "completed",
|
|
73
|
+
"failureReason": null,
|
|
74
|
+
"messages": []
|
|
75
|
+
}
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
| Field | Type | Description |
|
|
79
|
+
| --------------- | -------------- | ----------------------------------------------------------------------------- |
|
|
80
|
+
| `threadId` | string | The thread identifier |
|
|
81
|
+
| `status` | string | `idle`, `queued`, `pending`, `running`, `completed`, `failed`, or `cancelled` |
|
|
82
|
+
| `failureReason` | string \| null | Why the run failed, when `status` is `failed` |
|
|
83
|
+
| `messages` | UIMessage[] | The conversation - see [UIMessage parts](/docs/api-reference/sessions) |
|
|
84
|
+
|
|
85
|
+
Keep polling while the status is `pending`, `queued`, or `running`. Stop when it is `completed`, `failed`, or `cancelled`.
|
|
86
|
+
|
|
87
|
+
### Example
|
|
88
|
+
|
|
89
|
+
```bash
|
|
90
|
+
curl https://octavus.ai/api/v1/workforce/agents/AGENT_ID/threads/THREAD_ID \
|
|
91
|
+
-H "Authorization: Bearer oct_agt_..."
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
## Follow up in a thread
|
|
95
|
+
|
|
96
|
+
Send another message into an existing thread. If the agent is still working the message runs after the current turn finishes; otherwise it starts immediately.
|
|
97
|
+
|
|
98
|
+
```
|
|
99
|
+
POST /api/v1/workforce/agents/{agentId}/threads/{threadId}/messages
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
### Request Body
|
|
103
|
+
|
|
104
|
+
```json
|
|
105
|
+
{
|
|
106
|
+
"message": "Now turn that into a slide deck"
|
|
107
|
+
}
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
| Field | Type | Required | Description |
|
|
111
|
+
| --------- | --------------- | -------- | ----------------------- |
|
|
112
|
+
| `message` | string | Yes | The follow-up message |
|
|
113
|
+
| `files` | FileReference[] | No | Hosted file attachments |
|
|
114
|
+
|
|
115
|
+
### Response
|
|
116
|
+
|
|
117
|
+
Returns `202`.
|
|
118
|
+
|
|
119
|
+
```json
|
|
120
|
+
{
|
|
121
|
+
"threadId": "cm5xyz123abc456def",
|
|
122
|
+
"status": "running"
|
|
123
|
+
}
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
Poll [Get a thread](#get-a-thread) for the new run's result.
|
|
127
|
+
|
|
128
|
+
### Example
|
|
129
|
+
|
|
130
|
+
```bash
|
|
131
|
+
curl -X POST https://octavus.ai/api/v1/workforce/agents/AGENT_ID/threads/THREAD_ID/messages \
|
|
132
|
+
-H "Authorization: Bearer oct_agt_..." \
|
|
133
|
+
-H "Content-Type: application/json" \
|
|
134
|
+
-d '{ "message": "Now turn that into a slide deck" }'
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
## Errors
|
|
138
|
+
|
|
139
|
+
Errors return `{ "error": string, "code": string }` with an HTTP status:
|
|
140
|
+
|
|
141
|
+
| Status | Meaning |
|
|
142
|
+
| ------ | ------------------------------------------------- |
|
|
143
|
+
| `401` | Missing or invalid API key |
|
|
144
|
+
| `402` | The agent is blocked by a usage or spending limit |
|
|
145
|
+
| `403` | The key is not authorized for this agent |
|
|
146
|
+
| `404` | The thread does not exist for this agent |
|