@operator-labs/sdk 0.1.0 → 0.1.1
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 +10 -40
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -26,15 +26,12 @@ const status = await op.health();
|
|
|
26
26
|
console.log(status.planName, status.email);
|
|
27
27
|
|
|
28
28
|
// 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?");
|
|
29
|
+
const { chatId, text } = await op.chat.send("List my instances");
|
|
37
30
|
console.log(text);
|
|
31
|
+
|
|
32
|
+
// Continue the conversation
|
|
33
|
+
const followUp = await op.chat.send("Restart the first one", { chatId });
|
|
34
|
+
console.log(followUp.text);
|
|
38
35
|
```
|
|
39
36
|
|
|
40
37
|
## Configuration
|
|
@@ -72,27 +69,13 @@ const chats = await op.chat.list();
|
|
|
72
69
|
// Get a chat with messages
|
|
73
70
|
const detail = await op.chat.get("chat-uuid");
|
|
74
71
|
|
|
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");
|
|
72
|
+
// Send a message and get the full response
|
|
73
|
+
const { chatId, text } = await op.chat.send("Create a new instance called my-agent");
|
|
74
|
+
console.log(text);
|
|
93
75
|
|
|
94
76
|
// Continue a conversation
|
|
95
|
-
const
|
|
77
|
+
const followUp = await op.chat.send("Now check its logs", { chatId });
|
|
78
|
+
console.log(followUp.text);
|
|
96
79
|
|
|
97
80
|
// Update title / delete
|
|
98
81
|
await op.chat.updateTitle("chat-uuid", "Deployment Chat");
|
|
@@ -193,19 +176,6 @@ try {
|
|
|
193
176
|
}
|
|
194
177
|
```
|
|
195
178
|
|
|
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
179
|
## Requirements
|
|
210
180
|
|
|
211
181
|
- Node.js 18+ (uses native `fetch`)
|
package/package.json
CHANGED