@b3os/mcp 0.2.1 → 0.2.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 +26 -4
- package/dist/handlers/_common.d.ts +14 -0
- package/dist/handlers/_common.js +27 -0
- package/dist/handlers/_common.js.map +1 -1
- package/dist/handlers/actions.d.ts +12 -1
- package/dist/handlers/actions.js +51 -2
- package/dist/handlers/actions.js.map +1 -1
- package/dist/handlers/agents.d.ts +2 -0
- package/dist/handlers/agents.js +41 -0
- package/dist/handlers/agents.js.map +1 -0
- package/dist/handlers/platform.d.ts +32 -0
- package/dist/handlers/platform.js +663 -0
- package/dist/handlers/platform.js.map +1 -0
- package/dist/handlers/render.d.ts +13 -0
- package/dist/handlers/render.js +145 -18
- package/dist/handlers/render.js.map +1 -1
- package/dist/handlers/routines.d.ts +8 -2
- package/dist/handlers/routines.js +154 -15
- package/dist/handlers/routines.js.map +1 -1
- package/dist/server.js +1 -1
- package/dist/table.gen.js +3312 -42
- package/dist/table.gen.js.map +1 -1
- package/dist/table.js +4 -0
- package/dist/table.js.map +1 -1
- package/dist/tools.js +3 -0
- package/dist/tools.js.map +1 -1
- package/package.json +2 -2
- package/src/handlers/_common.ts +37 -0
- package/src/handlers/actions.ts +50 -2
- package/src/handlers/agents.ts +50 -0
- package/src/handlers/platform.ts +711 -0
- package/src/handlers/render.ts +147 -16
- package/src/handlers/routines.ts +164 -14
- package/src/server.ts +1 -1
- package/src/table.gen.ts +3367 -36
- package/src/table.ts +4 -0
- package/src/tools.ts +3 -0
- package/table/core.mjs +13 -2
- package/table/node-toolsets.json +668 -0
- package/table/requests.json +771 -0
- package/table/table.json +3315 -45
- package/table/tools/agents.mjs +230 -0
- package/table/tools/listeners.mjs +124 -0
- package/table/tools/platform.mjs +136 -3
- package/table/tools/render.mjs +157 -3
- package/table/tools/routines.mjs +37 -0
- package/table/tools/sandboxes.mjs +69 -0
- package/table/tools.mjs +3 -1
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
// Agents (Actors) tools of the MCP tool table (owner: agents, B3-7151). table/tools.mjs composes every product's TOOLS
|
|
2
|
+
// with core.mjs; the field options are described there. All are in the opt-in `agents` toolset, in tools/list order.
|
|
3
|
+
// Every operation is behind the `agents.actors` flag, so these tools are listed only to an organization with it on
|
|
4
|
+
// (src/table.ts selectTools).
|
|
5
|
+
|
|
6
|
+
import { WAIT_S } from "../core.mjs";
|
|
7
|
+
|
|
8
|
+
const AGENT = { description: "The agent's name, or its agt_ id." };
|
|
9
|
+
const KEY = { description: "The instance key: 1 to 128 of A-Z a-z 0-9 . _ : - (a user, a thread, a repository)." };
|
|
10
|
+
|
|
11
|
+
/** @type {import("../../scripts/gen-table.mjs").ToolSource[]} */
|
|
12
|
+
export const TOOLS = [
|
|
13
|
+
{
|
|
14
|
+
name: "agent_send",
|
|
15
|
+
group: "agents",
|
|
16
|
+
title: "Send a message to an agent instance",
|
|
17
|
+
description:
|
|
18
|
+
"Send one message to the agent's instance for key and wait up to wait_s seconds for the turn. The instance is " +
|
|
19
|
+
"made on its first message and woken from any sleep tier (woke_from says which); it runs one turn at a time " +
|
|
20
|
+
"and queues the rest. payload holds your own fields; the harness gets them as message. If the turn is still " +
|
|
21
|
+
"running, call again with job_id.",
|
|
22
|
+
op: "agentsSendMessage",
|
|
23
|
+
path: { agent: { ...AGENT, required: false }, key: { ...KEY, required: false } },
|
|
24
|
+
query: { wait: { from: "wait_s" } },
|
|
25
|
+
body: {
|
|
26
|
+
type: {},
|
|
27
|
+
conversation: {},
|
|
28
|
+
subject: {},
|
|
29
|
+
metadata: { collapse: true },
|
|
30
|
+
create: {},
|
|
31
|
+
},
|
|
32
|
+
args: {
|
|
33
|
+
payload: {
|
|
34
|
+
type: "object",
|
|
35
|
+
description: "The message's own fields (any JSON object), sent beside type, conversation and subject.",
|
|
36
|
+
},
|
|
37
|
+
job_id: { type: "string", description: "A ses_ id from an earlier call: keep waiting for that turn." },
|
|
38
|
+
wait_s: WAIT_S,
|
|
39
|
+
},
|
|
40
|
+
continueWith: { arg: "job_id", op: "agentsGetSession" },
|
|
41
|
+
example: { agent: "support", key: "user-42", payload: { text: "Where is my order?" }, wait_s: 30 },
|
|
42
|
+
hints: { readOnlyHint: false, destructiveHint: false, openWorldHint: true },
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
name: "agent_create",
|
|
46
|
+
group: "agents",
|
|
47
|
+
title: "Create an agent",
|
|
48
|
+
description:
|
|
49
|
+
"Create an agent: the definition each of its instances starts from (a template and size, the harness command " +
|
|
50
|
+
"and the port it answers messages on, env, vault secrets, its API grant, egress, sleep and turn settings). " +
|
|
51
|
+
"Nothing starts until the first message to a key.",
|
|
52
|
+
op: "agentsCreateAgent",
|
|
53
|
+
body: {
|
|
54
|
+
name: {},
|
|
55
|
+
source: {},
|
|
56
|
+
entry: {},
|
|
57
|
+
env: {},
|
|
58
|
+
secrets: {},
|
|
59
|
+
api: {},
|
|
60
|
+
egress: { collapse: true },
|
|
61
|
+
sleep: {},
|
|
62
|
+
turns: {},
|
|
63
|
+
metadata: { collapse: true },
|
|
64
|
+
},
|
|
65
|
+
example: {
|
|
66
|
+
name: "support",
|
|
67
|
+
entry: { command: ["node", "harness.js"], port: 8080, path: "/messages" },
|
|
68
|
+
},
|
|
69
|
+
hints: { readOnlyHint: false, destructiveHint: false, openWorldHint: false },
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
name: "agent_list",
|
|
73
|
+
group: "agents",
|
|
74
|
+
title: "List agents",
|
|
75
|
+
description: "List the project's agents, newest first, with each one's revision and instance count.",
|
|
76
|
+
op: "agentsListAgents",
|
|
77
|
+
query: { limit: { default: 20 }, cursor: {} },
|
|
78
|
+
defaults: { limit: 20 },
|
|
79
|
+
why: { limit: "twenty agents first (an agent's context is expensive); the cursor or a larger limit reads more" },
|
|
80
|
+
example: { limit: 5 },
|
|
81
|
+
hints: { readOnlyHint: true, openWorldHint: false },
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
name: "agent_get",
|
|
85
|
+
group: "agents",
|
|
86
|
+
title: "Get an agent",
|
|
87
|
+
description: "Read an agent's definition by name or agt_ id: its source, entry, sleep and turn settings, revision.",
|
|
88
|
+
op: "agentsGetAgent",
|
|
89
|
+
path: { agent: AGENT },
|
|
90
|
+
example: { agent: "support" },
|
|
91
|
+
hints: { readOnlyHint: true, openWorldHint: false },
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
name: "agent_update",
|
|
95
|
+
group: "agents",
|
|
96
|
+
title: "Update an agent",
|
|
97
|
+
description:
|
|
98
|
+
"Change an agent's definition (a new revision). upgrade says when instances take it: new_instances (the " +
|
|
99
|
+
"default) or on_wake.",
|
|
100
|
+
op: "agentsUpdateAgent",
|
|
101
|
+
path: { agent: AGENT },
|
|
102
|
+
body: {
|
|
103
|
+
source: {},
|
|
104
|
+
entry: {},
|
|
105
|
+
env: {},
|
|
106
|
+
secrets: {},
|
|
107
|
+
api: {},
|
|
108
|
+
egress: { collapse: true },
|
|
109
|
+
sleep: {},
|
|
110
|
+
turns: {},
|
|
111
|
+
upgrade: {},
|
|
112
|
+
metadata: { collapse: true },
|
|
113
|
+
},
|
|
114
|
+
example: { agent: "support", sleep: { ram_after_s: 60 } },
|
|
115
|
+
hints: { readOnlyHint: false, destructiveHint: false, openWorldHint: false },
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
name: "agent_delete",
|
|
119
|
+
group: "agents",
|
|
120
|
+
title: "Delete an agent",
|
|
121
|
+
description: "Delete an agent and every instance of it, with their microVMs, snapshots and disks.",
|
|
122
|
+
op: "agentsDeleteAgent",
|
|
123
|
+
path: { agent: AGENT },
|
|
124
|
+
example: { agent: "support" },
|
|
125
|
+
hints: { readOnlyHint: false, destructiveHint: true, idempotentHint: true, openWorldHint: false },
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
name: "agent_list_instances",
|
|
129
|
+
group: "agents",
|
|
130
|
+
title: "List an agent's instances",
|
|
131
|
+
description:
|
|
132
|
+
"List an agent's instances: each key with its status (running, paused, hibernated, dormant, failed), its " +
|
|
133
|
+
"resident memory and the bytes it holds on the node's disk.",
|
|
134
|
+
op: "agentsListInstances",
|
|
135
|
+
path: { agent: AGENT },
|
|
136
|
+
query: { status: {}, limit: { default: 20 }, cursor: {} },
|
|
137
|
+
defaults: { limit: 20 },
|
|
138
|
+
why: { limit: "twenty instances first; the cursor or a larger limit reads more" },
|
|
139
|
+
example: { agent: "support", status: "hibernated" },
|
|
140
|
+
hints: { readOnlyHint: true, openWorldHint: false },
|
|
141
|
+
},
|
|
142
|
+
{
|
|
143
|
+
name: "agent_get_instance",
|
|
144
|
+
group: "agents",
|
|
145
|
+
title: "Get an agent instance",
|
|
146
|
+
description:
|
|
147
|
+
"Read one instance by its key: status, sandbox id, resident memory, storage, last message, snapshot time.",
|
|
148
|
+
op: "agentsGetInstance",
|
|
149
|
+
path: { agent: AGENT, key: KEY },
|
|
150
|
+
example: { agent: "support", key: "user-42" },
|
|
151
|
+
hints: { readOnlyHint: true, openWorldHint: false },
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
name: "agent_instance_events",
|
|
155
|
+
group: "agents",
|
|
156
|
+
title: "Read an instance's lifecycle events",
|
|
157
|
+
description:
|
|
158
|
+
"An instance's lifecycle events, newest first: created, paused, hibernated, dormant, woke (and from which " +
|
|
159
|
+
"tier), recovered, failed, with their reasons.",
|
|
160
|
+
op: "agentsListInstanceEvents",
|
|
161
|
+
path: { agent: AGENT, key: KEY },
|
|
162
|
+
query: { limit: { default: 20 }, cursor: {} },
|
|
163
|
+
defaults: { limit: 20 },
|
|
164
|
+
why: { limit: "the last twenty events first; the cursor or a larger limit reads more" },
|
|
165
|
+
example: { agent: "support", key: "user-42", limit: 10 },
|
|
166
|
+
hints: { readOnlyHint: true, openWorldHint: false },
|
|
167
|
+
},
|
|
168
|
+
{
|
|
169
|
+
name: "agent_sleep",
|
|
170
|
+
group: "agents",
|
|
171
|
+
title: "Put an agent instance to sleep",
|
|
172
|
+
description:
|
|
173
|
+
"Send an instance to a sleep tier now instead of waiting for its timers: ram pauses it in memory, snapshot " +
|
|
174
|
+
"writes its memory to the node's disk and frees it. A turn in progress finishes first.",
|
|
175
|
+
op: "agentsSleepInstance",
|
|
176
|
+
path: { agent: AGENT, key: KEY },
|
|
177
|
+
body: { tier: {} },
|
|
178
|
+
example: { agent: "support", key: "user-42", tier: "snapshot" },
|
|
179
|
+
hints: { readOnlyHint: false, destructiveHint: false, idempotentHint: true, openWorldHint: false },
|
|
180
|
+
},
|
|
181
|
+
{
|
|
182
|
+
name: "agent_delete_instance",
|
|
183
|
+
group: "agents",
|
|
184
|
+
title: "Delete an agent instance",
|
|
185
|
+
description: "Delete one instance: its microVM, its memory snapshot and its disk. Its key starts fresh next time.",
|
|
186
|
+
op: "agentsDeleteInstance",
|
|
187
|
+
path: { agent: AGENT, key: KEY },
|
|
188
|
+
example: { agent: "support", key: "user-42" },
|
|
189
|
+
hints: { readOnlyHint: false, destructiveHint: true, idempotentHint: true, openWorldHint: false },
|
|
190
|
+
},
|
|
191
|
+
{
|
|
192
|
+
name: "agent_list_sessions",
|
|
193
|
+
group: "agents",
|
|
194
|
+
title: "List an agent's sessions",
|
|
195
|
+
description:
|
|
196
|
+
"List an agent's sessions (one per turn), newest first, optionally for one key, conversation or status: each " +
|
|
197
|
+
"with its status, woke_from and timing.",
|
|
198
|
+
op: "agentsListSessions",
|
|
199
|
+
path: { agent: AGENT },
|
|
200
|
+
query: { key: {}, conversation: {}, status: {}, limit: { default: 10 }, cursor: {} },
|
|
201
|
+
defaults: { limit: 10 },
|
|
202
|
+
why: { limit: "ten sessions first (an agent's context is expensive); the cursor or a larger limit reads more" },
|
|
203
|
+
example: { agent: "support", key: "user-42", status: "failed" },
|
|
204
|
+
hints: { readOnlyHint: true, openWorldHint: false },
|
|
205
|
+
},
|
|
206
|
+
{
|
|
207
|
+
name: "agent_get_session",
|
|
208
|
+
group: "agents",
|
|
209
|
+
title: "Get an agent session",
|
|
210
|
+
description:
|
|
211
|
+
"Read a session (one turn) by its ses_ id: status, phase, woke_from, the harness's result or the error, and " +
|
|
212
|
+
"the timing of its queue, wake, delivery and harness.",
|
|
213
|
+
op: "agentsGetSession",
|
|
214
|
+
path: { session_id: {} },
|
|
215
|
+
example: { session_id: "ses_01m87xh9pe1a47cey653pxk3zs" },
|
|
216
|
+
hints: { readOnlyHint: true, openWorldHint: false },
|
|
217
|
+
},
|
|
218
|
+
{
|
|
219
|
+
name: "agent_cancel_session",
|
|
220
|
+
group: "agents",
|
|
221
|
+
title: "Cancel an agent session",
|
|
222
|
+
description:
|
|
223
|
+
"Cancel a queued or running turn. A queued message is never delivered; a delivered one has its request into " +
|
|
224
|
+
"the harness closed.",
|
|
225
|
+
op: "agentsCancelSession",
|
|
226
|
+
path: { session_id: {} },
|
|
227
|
+
example: { session_id: "ses_01m87xh9pe1a47cey653pxk3zs" },
|
|
228
|
+
hints: { readOnlyHint: false, destructiveHint: true, openWorldHint: false },
|
|
229
|
+
},
|
|
230
|
+
];
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
// Listeners tools of the MCP tool table (owner: listeners, B3-7152). table/tools.mjs composes every product's TOOLS
|
|
2
|
+
// with core.mjs; the field options are described there. None is a core tool: they are the opt-in `listeners`
|
|
3
|
+
// toolset, and every one is gated by `listeners.api` (src/table.ts selectTools lists a flagged operation's tool only
|
|
4
|
+
// to an organization with its flag on), so they stay unlisted while the product is dark.
|
|
5
|
+
|
|
6
|
+
/** @type {import("../../scripts/gen-table.mjs").ToolSource[]} */
|
|
7
|
+
export const TOOLS = [
|
|
8
|
+
{
|
|
9
|
+
name: "listener_create",
|
|
10
|
+
group: "listeners",
|
|
11
|
+
title: "Create a listener",
|
|
12
|
+
description:
|
|
13
|
+
"Hold a source open for this project and hand each kept event to a sink: a source (http_poll, sse, websocket, " +
|
|
14
|
+
"webhook, pack or push), a CEL and optional model filter, and a routine or webhook sink, with a ttl and a daily " +
|
|
15
|
+
"budget. Nothing of yours runs between events. A webhook source's answer names its hook_url.",
|
|
16
|
+
op: "listenersCreateListener",
|
|
17
|
+
body: {
|
|
18
|
+
name: {},
|
|
19
|
+
source: { collapse: true, description: "{type: http_poll|sse|websocket|webhook|pack|push, ...} (see the docs)." },
|
|
20
|
+
dedupe: { collapse: true, description: "{key: CEL over event, window_s}; default the source's own event id." },
|
|
21
|
+
filter: { collapse: true, description: "{cel: 'event.payload.total > 10', model: {prompt, on_error}}." },
|
|
22
|
+
sink: { collapse: true, description: "{type: routine, routine} or {type: webhook, url}; optional batch." },
|
|
23
|
+
redact: {},
|
|
24
|
+
ttl_s: {},
|
|
25
|
+
budget: { collapse: true, description: "{events_per_day, model_tokens_per_day}." },
|
|
26
|
+
},
|
|
27
|
+
example: {
|
|
28
|
+
name: "big-orders",
|
|
29
|
+
source: { type: "push" },
|
|
30
|
+
filter: { cel: "event.payload.total > 1000" },
|
|
31
|
+
sink: { type: "webhook", url: "https://hooks.example.com/b3os" },
|
|
32
|
+
ttl_s: 86400,
|
|
33
|
+
},
|
|
34
|
+
hints: { readOnlyHint: false, openWorldHint: true },
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
name: "listener_list",
|
|
38
|
+
group: "listeners",
|
|
39
|
+
title: "List listeners",
|
|
40
|
+
description: "List this project's listeners, newest first, with each one's status and what it kept.",
|
|
41
|
+
op: "listenersListListeners",
|
|
42
|
+
query: { status: {}, limit: { default: 20 }, cursor: {} },
|
|
43
|
+
example: { status: "active", limit: 10 },
|
|
44
|
+
hints: { readOnlyHint: true, openWorldHint: false },
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
name: "listener_get",
|
|
48
|
+
group: "listeners",
|
|
49
|
+
title: "Get a listener",
|
|
50
|
+
description:
|
|
51
|
+
"One listener: its definition, status (and why it failed, when it did), its source's cursor, the budget it has " +
|
|
52
|
+
"used today and its stats.",
|
|
53
|
+
op: "listenersGetListener",
|
|
54
|
+
path: { listener_id: {} },
|
|
55
|
+
example: { listener_id: "lsn_01m5t8b2c4d6e8f0g2h4j6k8m0" },
|
|
56
|
+
hints: { readOnlyHint: true, openWorldHint: false },
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
name: "listener_update",
|
|
60
|
+
group: "listeners",
|
|
61
|
+
title: "Update a listener",
|
|
62
|
+
description:
|
|
63
|
+
"Pause or resume a listener, or change its filter, sink, budget, lifetime or redact list. The source is fixed.",
|
|
64
|
+
op: "listenersUpdateListener",
|
|
65
|
+
path: { listener_id: {} },
|
|
66
|
+
body: {
|
|
67
|
+
paused: {},
|
|
68
|
+
ttl_s: {},
|
|
69
|
+
filter: { collapse: true, description: "{cel, model}." },
|
|
70
|
+
budget: { collapse: true, description: "{events_per_day, model_tokens_per_day}." },
|
|
71
|
+
},
|
|
72
|
+
example: { listener_id: "lsn_01m5t8b2c4d6e8f0g2h4j6k8m0", paused: true },
|
|
73
|
+
hints: { readOnlyHint: false, idempotentHint: true, openWorldHint: false },
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
name: "listener_delete",
|
|
77
|
+
group: "listeners",
|
|
78
|
+
title: "Delete a listener",
|
|
79
|
+
description: "Delete a listener: its source closes and its hooks go; its history stays until its retention ends.",
|
|
80
|
+
op: "listenersDeleteListener",
|
|
81
|
+
path: { listener_id: {} },
|
|
82
|
+
example: { listener_id: "lsn_01m5t8b2c4d6e8f0g2h4j6k8m0" },
|
|
83
|
+
hints: { readOnlyHint: false, destructiveHint: true, idempotentHint: true, openWorldHint: false },
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
name: "listener_events",
|
|
87
|
+
group: "listeners",
|
|
88
|
+
title: "List a listener's events",
|
|
89
|
+
description:
|
|
90
|
+
"A listener's history, newest first: each event's payload, why the filter kept or dropped it, and its delivery " +
|
|
91
|
+
"(delivered, filtered, failed, pending, skipped), with gap records where the source could not resume.",
|
|
92
|
+
op: "listenersListEvents",
|
|
93
|
+
path: { listener_id: {} },
|
|
94
|
+
query: { status: {}, limit: { default: 20 }, cursor: {} },
|
|
95
|
+
example: { listener_id: "lsn_01m5t8b2c4d6e8f0g2h4j6k8m0", status: "failed" },
|
|
96
|
+
hints: { readOnlyHint: true, openWorldHint: false },
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
name: "listener_push",
|
|
100
|
+
group: "listeners",
|
|
101
|
+
title: "Send events to a listener",
|
|
102
|
+
description:
|
|
103
|
+
"Send up to 100 events to a push listener; each goes through its dedupe, filter and sink. Answers once they " +
|
|
104
|
+
"are in the listener's log.",
|
|
105
|
+
op: "listenersIngestEvents",
|
|
106
|
+
path: { listener_id: {} },
|
|
107
|
+
body: { events: {} },
|
|
108
|
+
example: { listener_id: "lsn_01m5t8b2c4d6e8f0g2h4j6k8m0", events: [{ payload: { order: 7, total: 1200 } }] },
|
|
109
|
+
hints: { readOnlyHint: false, openWorldHint: false },
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
name: "listener_test",
|
|
113
|
+
group: "listeners",
|
|
114
|
+
title: "Test a listener",
|
|
115
|
+
description:
|
|
116
|
+
"Run a sample event through a listener's dedupe and filter and say whether it would be kept; deliver: true " +
|
|
117
|
+
"also keeps it and hands it to the sink.",
|
|
118
|
+
op: "listenersTestListener",
|
|
119
|
+
path: { listener_id: {} },
|
|
120
|
+
body: { payload: {}, deliver: {} },
|
|
121
|
+
example: { listener_id: "lsn_01m5t8b2c4d6e8f0g2h4j6k8m0", payload: { total: 50 } },
|
|
122
|
+
hints: { readOnlyHint: false, openWorldHint: false },
|
|
123
|
+
},
|
|
124
|
+
];
|
package/table/tools/platform.mjs
CHANGED
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
// Platform tools of the MCP tool table (owner: platform-dx, plan 1.2). table/tools.mjs composes every
|
|
2
2
|
// product's TOOLS with core.mjs; the field options are described there. Keep the entries in tools/list order:
|
|
3
3
|
// core tools follow CORE in core.mjs, the rest of this list keeps its order within the platform toolset.
|
|
4
|
+
//
|
|
5
|
+
// The read tools for traces, the request log and kept model calls (B3-6853, observability.md 8.5) answer in a few
|
|
6
|
+
// lines per record, the fields a person looks at first in the console first, and say how to read more (a cursor, a
|
|
7
|
+
// larger limit, from_span, max_chars). Their handlers are src/handlers/platform.ts. Only
|
|
8
|
+
// llm_calls_get_prompt_and_answer returns a prompt or an answer, and only to a key that holds platform:content:read.
|
|
9
|
+
|
|
10
|
+
/** Ten records first: each is a line or two of an agent's context; the cursor or a larger limit reads more. */
|
|
11
|
+
const SMALL_LIMIT = "ten lines first (an agent's context is expensive); the cursor or a larger limit reads more";
|
|
4
12
|
|
|
5
13
|
/** @type {import("../../scripts/gen-table.mjs").ToolSource[]} */
|
|
6
14
|
export const TOOLS = [
|
|
@@ -26,16 +34,19 @@ export const TOOLS = [
|
|
|
26
34
|
group: "platform",
|
|
27
35
|
title: "List API requests",
|
|
28
36
|
description:
|
|
29
|
-
"List the API requests the node served for this project in the last 7 days, newest first
|
|
30
|
-
"product, operation, status, key, connection kind,
|
|
37
|
+
"List the API requests the node served for this project in the last 7 days, newest first, one line each " +
|
|
38
|
+
"with its status, duration and error; filter by product, operation, status, key, source, connection kind, " +
|
|
39
|
+
"sandbox, trace or time.",
|
|
31
40
|
op: "platformListRequests",
|
|
32
41
|
query: {
|
|
33
42
|
product: {},
|
|
34
43
|
operation_id: {},
|
|
35
44
|
status: {},
|
|
36
45
|
key_id: {},
|
|
46
|
+
source: {},
|
|
37
47
|
connection: {},
|
|
38
48
|
sandbox_id: {},
|
|
49
|
+
trace_id: {},
|
|
39
50
|
since: {},
|
|
40
51
|
limit: {},
|
|
41
52
|
cursor: {},
|
|
@@ -48,12 +59,134 @@ export const TOOLS = [
|
|
|
48
59
|
group: "platform",
|
|
49
60
|
title: "Get an API request",
|
|
50
61
|
description:
|
|
51
|
-
"Get one request by its ID (a response's x-request-id)
|
|
62
|
+
"Get one request by its ID (a response's x-request-id): its timing phase breakdown (node and edge), its " +
|
|
63
|
+
"error if it failed, and the usage it was charged.",
|
|
52
64
|
op: "platformGetRequest",
|
|
53
65
|
path: { request_id: {} },
|
|
66
|
+
uses: ["platformListUsageRecords"],
|
|
54
67
|
example: { request_id: "req_01m5t68q1b590rj801nbzsqzkk" },
|
|
55
68
|
hints: { readOnlyHint: true, openWorldHint: false },
|
|
56
69
|
},
|
|
70
|
+
{
|
|
71
|
+
name: "traces_list",
|
|
72
|
+
group: "platform",
|
|
73
|
+
title: "List traces",
|
|
74
|
+
description:
|
|
75
|
+
"List recent traces from the request log, newest first: each is the calls that shared one trace id (one " +
|
|
76
|
+
"turn of an agent), with its start, duration, calls by kind and its first error.",
|
|
77
|
+
op: "platformListRequests",
|
|
78
|
+
query: {
|
|
79
|
+
since: { description: "Only requests from this time on (RFC 3339); the log keeps 7 days." },
|
|
80
|
+
sandbox_id: {},
|
|
81
|
+
source: {},
|
|
82
|
+
},
|
|
83
|
+
args: {
|
|
84
|
+
status: {
|
|
85
|
+
type: "string",
|
|
86
|
+
enum: ["ok", "error"],
|
|
87
|
+
description: "Only traces where no call failed (ok), or where at least one did (error).",
|
|
88
|
+
},
|
|
89
|
+
app: {
|
|
90
|
+
type: "string",
|
|
91
|
+
pattern: "^[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?$",
|
|
92
|
+
description: "Only traces of this application's services (its b3os.yaml name); also needs sandboxes:read.",
|
|
93
|
+
},
|
|
94
|
+
single_calls: {
|
|
95
|
+
type: "boolean",
|
|
96
|
+
default: false,
|
|
97
|
+
description: "Also list traces of one call and its retries (a call made outside a turn has its own).",
|
|
98
|
+
},
|
|
99
|
+
limit: { type: "integer", minimum: 1, maximum: 50, default: 10, description: "Traces to list." },
|
|
100
|
+
},
|
|
101
|
+
uses: ["sandboxesListSandboxes"],
|
|
102
|
+
example: { status: "error", limit: 5 },
|
|
103
|
+
hints: { readOnlyHint: true, openWorldHint: false },
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
name: "traces_get",
|
|
107
|
+
group: "platform",
|
|
108
|
+
title: "Get a trace",
|
|
109
|
+
description:
|
|
110
|
+
"Read one trace as a waterfall: its calls in start order, each with its kind, start offset, duration, " +
|
|
111
|
+
"status, the operation or model it called, its tokens and usage, and the error of a failed call.",
|
|
112
|
+
op: "platformGetTrace",
|
|
113
|
+
path: { trace_id: { description: "The trace's 32-hex id: a request's trace_id, or one traces_list gave." } },
|
|
114
|
+
args: {
|
|
115
|
+
max_spans: {
|
|
116
|
+
type: "integer",
|
|
117
|
+
minimum: 1,
|
|
118
|
+
maximum: 300,
|
|
119
|
+
default: 25,
|
|
120
|
+
description: "Spans to show; the answer counts the rest and says how to read them.",
|
|
121
|
+
},
|
|
122
|
+
from_span: {
|
|
123
|
+
type: "integer",
|
|
124
|
+
minimum: 1,
|
|
125
|
+
maximum: 300,
|
|
126
|
+
default: 1,
|
|
127
|
+
description: "The first span to show, by its number in an earlier answer.",
|
|
128
|
+
},
|
|
129
|
+
},
|
|
130
|
+
uses: ["platformListLlmCalls"],
|
|
131
|
+
example: { trace_id: "4bf92f3577b34da6a3ce929d0e0e4736" },
|
|
132
|
+
hints: { readOnlyHint: true, openWorldHint: false },
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
name: "llm_calls_list",
|
|
136
|
+
group: "platform",
|
|
137
|
+
title: "List kept model calls",
|
|
138
|
+
description:
|
|
139
|
+
"List the model calls prompt logging kept in the last 7 days, newest first: model, tokens, timing, finish " +
|
|
140
|
+
"reason and the tools the model chose, never the prompt; filter by trace, model, sandbox or time.",
|
|
141
|
+
op: "platformListLlmCalls",
|
|
142
|
+
query: { trace_id: {}, model: {}, sandbox_id: {}, since: {}, limit: { default: 10 }, cursor: {} },
|
|
143
|
+
defaults: { limit: 10 },
|
|
144
|
+
why: { limit: SMALL_LIMIT },
|
|
145
|
+
example: { model: "b3os/qwen3.5-9b", limit: 5 },
|
|
146
|
+
hints: { readOnlyHint: true, openWorldHint: false },
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
name: "llm_calls_get",
|
|
150
|
+
group: "platform",
|
|
151
|
+
title: "Get a kept model call",
|
|
152
|
+
description:
|
|
153
|
+
"Get one kept model call's metadata by its request ID: model, sampling settings, tools offered and chosen, " +
|
|
154
|
+
"tokens, timing and what of its content was kept; never the prompt or the answer.",
|
|
155
|
+
op: "platformGetLlmCall",
|
|
156
|
+
path: { request_id: {} },
|
|
157
|
+
example: { request_id: "req_01m5t6d8ksbzrfxhqhzge06mqn" },
|
|
158
|
+
hints: { readOnlyHint: true, openWorldHint: false },
|
|
159
|
+
},
|
|
160
|
+
{
|
|
161
|
+
name: "llm_calls_get_prompt_and_answer",
|
|
162
|
+
group: "platform",
|
|
163
|
+
title: "Read a model call's prompt and answer",
|
|
164
|
+
description:
|
|
165
|
+
"Read a kept model call's prompt and answer: the messages and tools as the caller sent them, and the text, " +
|
|
166
|
+
"reasoning and tool calls the model gave. Sensitive: needs platform:content:read, which no wildcard " +
|
|
167
|
+
"grants; known key shapes read [redacted:<kind>]. Long strings are cut in the middle and the answer stops " +
|
|
168
|
+
"at max_chars; it says how to read more.",
|
|
169
|
+
op: "platformGetLlmCallContent",
|
|
170
|
+
path: { request_id: {} },
|
|
171
|
+
args: {
|
|
172
|
+
max_chars: {
|
|
173
|
+
type: "integer",
|
|
174
|
+
minimum: 1000,
|
|
175
|
+
maximum: 100000,
|
|
176
|
+
default: 12000,
|
|
177
|
+
description: "Characters of text to return at most.",
|
|
178
|
+
},
|
|
179
|
+
max_field_chars: {
|
|
180
|
+
type: "integer",
|
|
181
|
+
minimum: 200,
|
|
182
|
+
maximum: 100000,
|
|
183
|
+
default: 2000,
|
|
184
|
+
description: "A message, the answer or a tool call's arguments longer than this is cut in the middle.",
|
|
185
|
+
},
|
|
186
|
+
},
|
|
187
|
+
example: { request_id: "req_01m5t6d8ksbzrfxhqhzge06mqn", max_chars: 4000 },
|
|
188
|
+
hints: { readOnlyHint: true, openWorldHint: false },
|
|
189
|
+
},
|
|
57
190
|
{
|
|
58
191
|
name: "webhooks_list_deliveries",
|
|
59
192
|
group: "platform",
|