@operator-labs/sdk 0.1.0 → 0.1.2
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 +11 -50
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -8,12 +8,6 @@ TypeScript SDK for the Operator platform. Manage agents, chat, instances, automa
|
|
|
8
8
|
npm install @operator-labs/sdk
|
|
9
9
|
```
|
|
10
10
|
|
|
11
|
-
Or link locally during development:
|
|
12
|
-
|
|
13
|
-
```bash
|
|
14
|
-
cd sdk && npm link
|
|
15
|
-
```
|
|
16
|
-
|
|
17
11
|
## Quick Start
|
|
18
12
|
|
|
19
13
|
```ts
|
|
@@ -26,28 +20,22 @@ const status = await op.health();
|
|
|
26
20
|
console.log(status.planName, status.email);
|
|
27
21
|
|
|
28
22
|
// Send a message to the AI fleet manager
|
|
29
|
-
const
|
|
30
|
-
for await (const event of stream) {
|
|
31
|
-
if (event.type === "text-delta") process.stdout.write(event.text);
|
|
32
|
-
}
|
|
33
|
-
console.log();
|
|
34
|
-
|
|
35
|
-
// Or collect the full response
|
|
36
|
-
const { text } = await op.chat.sendAndWait("What's my current plan?");
|
|
23
|
+
const { chatId, text } = await op.chat.send("List my instances");
|
|
37
24
|
console.log(text);
|
|
25
|
+
|
|
26
|
+
// Continue the conversation
|
|
27
|
+
const followUp = await op.chat.send("Restart the first one", { chatId });
|
|
28
|
+
console.log(followUp.text);
|
|
38
29
|
```
|
|
39
30
|
|
|
40
31
|
## Configuration
|
|
41
32
|
|
|
42
33
|
```ts
|
|
43
34
|
const op = new Operator({
|
|
44
|
-
apiKey: "ck_live_...",
|
|
45
|
-
baseUrl: "https://www.operator.io", // Optional — defaults to production
|
|
35
|
+
apiKey: "ck_live_...", // Required — Chat API key from the dashboard
|
|
46
36
|
});
|
|
47
37
|
```
|
|
48
38
|
|
|
49
|
-
For local development, set `baseUrl` to `http://localhost:3000`.
|
|
50
|
-
|
|
51
39
|
## Getting an API Key
|
|
52
40
|
|
|
53
41
|
1. Go to **Settings > API Keys** in the Operator dashboard
|
|
@@ -72,27 +60,13 @@ const chats = await op.chat.list();
|
|
|
72
60
|
// Get a chat with messages
|
|
73
61
|
const detail = await op.chat.get("chat-uuid");
|
|
74
62
|
|
|
75
|
-
// Send a
|
|
76
|
-
const
|
|
77
|
-
|
|
78
|
-
switch (event.type) {
|
|
79
|
-
case "text-delta":
|
|
80
|
-
process.stdout.write(event.text);
|
|
81
|
-
break;
|
|
82
|
-
case "tool-call":
|
|
83
|
-
console.log(`Tool: ${event.toolName}`, event.args);
|
|
84
|
-
break;
|
|
85
|
-
case "tool-result":
|
|
86
|
-
console.log(`Result: ${event.toolName}`, event.result);
|
|
87
|
-
break;
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
// Send and wait for full response
|
|
92
|
-
const { chatId, text } = await op.chat.sendAndWait("Restart instance abc");
|
|
63
|
+
// Send a message and get the full response
|
|
64
|
+
const { chatId, text } = await op.chat.send("Create a new instance called my-agent");
|
|
65
|
+
console.log(text);
|
|
93
66
|
|
|
94
67
|
// Continue a conversation
|
|
95
|
-
const
|
|
68
|
+
const followUp = await op.chat.send("Now check its logs", { chatId });
|
|
69
|
+
console.log(followUp.text);
|
|
96
70
|
|
|
97
71
|
// Update title / delete
|
|
98
72
|
await op.chat.updateTitle("chat-uuid", "Deployment Chat");
|
|
@@ -193,19 +167,6 @@ try {
|
|
|
193
167
|
}
|
|
194
168
|
```
|
|
195
169
|
|
|
196
|
-
## Stream Events
|
|
197
|
-
|
|
198
|
-
When using `op.chat.send()`, the returned `ChatStream` yields these event types:
|
|
199
|
-
|
|
200
|
-
| Type | Fields | Description |
|
|
201
|
-
|------|--------|-------------|
|
|
202
|
-
| `text-delta` | `text` | Incremental text from the AI |
|
|
203
|
-
| `tool-call` | `toolName`, `args` | AI is calling a tool |
|
|
204
|
-
| `tool-result` | `toolName`, `result` | Tool execution result |
|
|
205
|
-
| `step-finish` | | A processing step completed |
|
|
206
|
-
| `finish` | `messages` | Stream finished |
|
|
207
|
-
| `error` | `error` | Error occurred |
|
|
208
|
-
|
|
209
170
|
## Requirements
|
|
210
171
|
|
|
211
172
|
- Node.js 18+ (uses native `fetch`)
|
package/package.json
CHANGED