@b3os/mcp 0.2.1 → 0.2.3
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 +31 -6
- package/dist/handlers/_common.d.ts +27 -0
- package/dist/handlers/_common.js +39 -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 +675 -0
- package/dist/handlers/platform.js.map +1 -0
- package/dist/handlers/render.d.ts +13 -0
- package/dist/handlers/render.js +170 -18
- package/dist/handlers/render.js.map +1 -1
- package/dist/handlers/routines.d.ts +8 -2
- package/dist/handlers/routines.js +175 -15
- package/dist/handlers/routines.js.map +1 -1
- package/dist/handlers/sandboxes.js +232 -15
- package/dist/handlers/sandboxes.js.map +1 -1
- package/dist/handlers/vision.d.ts +1 -6
- package/dist/handlers/vision.js +1 -13
- package/dist/handlers/vision.js.map +1 -1
- package/dist/server.d.ts +4 -0
- package/dist/server.js +4 -1
- package/dist/server.js.map +1 -1
- package/dist/stdio.d.ts +8 -0
- package/dist/stdio.js +18 -1
- package/dist/stdio.js.map +1 -1
- package/dist/table.gen.js +4868 -701
- 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 +53 -0
- package/src/handlers/actions.ts +50 -2
- package/src/handlers/agents.ts +50 -0
- package/src/handlers/platform.ts +728 -0
- package/src/handlers/render.ts +173 -16
- package/src/handlers/routines.ts +186 -14
- package/src/handlers/sandboxes.ts +259 -11
- package/src/handlers/vision.ts +1 -11
- package/src/server.ts +7 -1
- package/src/stdio.ts +21 -1
- package/src/table.gen.ts +4952 -707
- 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 +1008 -10
- package/table/table.json +4869 -680
- package/table/tools/agents.mjs +232 -0
- package/table/tools/listeners.mjs +124 -0
- package/table/tools/platform.mjs +136 -3
- package/table/tools/render.mjs +196 -3
- package/table/tools/routines.mjs +55 -0
- package/table/tools/sandboxes.mjs +236 -1
- package/table/tools.mjs +3 -1
package/table/tools/render.mjs
CHANGED
|
@@ -62,13 +62,24 @@ export const TOOLS = [
|
|
|
62
62
|
group: "core",
|
|
63
63
|
title: "Render a product video",
|
|
64
64
|
description:
|
|
65
|
-
"Record a
|
|
66
|
-
"
|
|
67
|
-
"
|
|
65
|
+
"Record a product demo as MP4, GIF and a poster: beats of browser steps, or a goal the node plans them from, " +
|
|
66
|
+
"with optional narration. Waits up to wait_s seconds and returns the poster; if still rendering, call again " +
|
|
67
|
+
"with job_id.",
|
|
68
68
|
op: "renderCreateVideo",
|
|
69
69
|
query: { wait: { from: "wait_s" } },
|
|
70
70
|
body: {
|
|
71
71
|
source: { required: false },
|
|
72
|
+
goal: {
|
|
73
|
+
description:
|
|
74
|
+
"What the video should show, in a sentence, in place of beats: the node reads the start page, plans " +
|
|
75
|
+
"the beats with its model and checks them in a browser (needs vision:run and infer:run). The planned " +
|
|
76
|
+
"beats come back in goal.beats; send them as beats to record the same steps again.",
|
|
77
|
+
},
|
|
78
|
+
alias: {
|
|
79
|
+
description:
|
|
80
|
+
"Name this recording (a-z, 0-9, hyphens): the alias points at the newest video made with it and keeps " +
|
|
81
|
+
"it past the 7-day retention, and render_share {alias} shares whichever video that is.",
|
|
82
|
+
},
|
|
72
83
|
beats: {
|
|
73
84
|
required: false,
|
|
74
85
|
description:
|
|
@@ -123,4 +134,186 @@ export const TOOLS = [
|
|
|
123
134
|
continueWith: { arg: "job_id", op: "renderGetVideo" },
|
|
124
135
|
hints: { readOnlyHint: false, openWorldHint: true },
|
|
125
136
|
},
|
|
137
|
+
{
|
|
138
|
+
name: "render_inspect",
|
|
139
|
+
group: "render",
|
|
140
|
+
title: "Inspect a page frame by frame",
|
|
141
|
+
description:
|
|
142
|
+
"Load a page, run optional browser steps, and record every frame of a short window (or read the same window " +
|
|
143
|
+
"from a finished video with video_id). Returns what changed between frames as plain lines (layout shifts in " +
|
|
144
|
+
"px, flashes, cuts, changed regions, watched elements' boxes) and one contact-sheet image of timestamped " +
|
|
145
|
+
"frames with before/after crops. Use it to check that a load or a click does not jump, flash or leave a " +
|
|
146
|
+
"skeleton. Give url or video_id. Bills one render.inspection_s per second of window.",
|
|
147
|
+
op: "renderCreateInspection",
|
|
148
|
+
body: {
|
|
149
|
+
url: {},
|
|
150
|
+
video_id: {},
|
|
151
|
+
steps: {
|
|
152
|
+
description:
|
|
153
|
+
"Browser steps in order (url only): step 0 starts at 300 ms, each next one when the one before ends. " +
|
|
154
|
+
`Step kinds and their required fields: ${STEPS}; a target is {selector}, {text} or {role, name}.`,
|
|
155
|
+
},
|
|
156
|
+
watch: {
|
|
157
|
+
description:
|
|
158
|
+
"Elements whose box is read on every frame (url only; the answer's trace): each {selector} (CSS) or " +
|
|
159
|
+
"{text, exact?, nth?}, at most 8; role and name are not accepted here.",
|
|
160
|
+
},
|
|
161
|
+
duration_ms: {},
|
|
162
|
+
from_ms: {},
|
|
163
|
+
fps: {},
|
|
164
|
+
viewport: {},
|
|
165
|
+
theme: {},
|
|
166
|
+
interval_ms: {},
|
|
167
|
+
},
|
|
168
|
+
args: {
|
|
169
|
+
include_image: {
|
|
170
|
+
type: "boolean",
|
|
171
|
+
default: true,
|
|
172
|
+
description: "Return the contact sheet itself as well as its URL.",
|
|
173
|
+
},
|
|
174
|
+
},
|
|
175
|
+
example: {
|
|
176
|
+
url: "https://beta.b3os.org/demo/billing/",
|
|
177
|
+
steps: [{ kind: "click", target: { text: "Annual", exact: true } }],
|
|
178
|
+
duration_ms: 2000,
|
|
179
|
+
},
|
|
180
|
+
hints: { readOnlyHint: true, openWorldHint: true },
|
|
181
|
+
},
|
|
182
|
+
{
|
|
183
|
+
name: "render_get",
|
|
184
|
+
group: "render",
|
|
185
|
+
title: "Get a video",
|
|
186
|
+
description:
|
|
187
|
+
"A video's status and files: its artifacts with signed URLs, the alias it was made with and the one that keeps " +
|
|
188
|
+
"it, its share's URL, and the goal it was planned from. Returns the poster as an image once it succeeded. " +
|
|
189
|
+
"Never waits.",
|
|
190
|
+
op: "renderGetVideo",
|
|
191
|
+
path: { video_id: {} },
|
|
192
|
+
args: {
|
|
193
|
+
include_poster: {
|
|
194
|
+
type: "boolean",
|
|
195
|
+
default: true,
|
|
196
|
+
description: "Return the poster frame as an image once the video has succeeded.",
|
|
197
|
+
},
|
|
198
|
+
},
|
|
199
|
+
example: { video_id: "vid_01m5t68q1b590rj801nbzsqzkk" },
|
|
200
|
+
hints: { readOnlyHint: true, idempotentHint: true, openWorldHint: false },
|
|
201
|
+
},
|
|
202
|
+
{
|
|
203
|
+
name: "render_restyle",
|
|
204
|
+
group: "render",
|
|
205
|
+
title: "Restyle a video",
|
|
206
|
+
description:
|
|
207
|
+
"Render a finished video again in another look (background, frame, cursor, captions, output size) from its " +
|
|
208
|
+
"recording, without a browser: seconds, not a re-record. alias adds the new video to an alias (a restyle " +
|
|
209
|
+
"never inherits its source's). Waits up to wait_s seconds; call again with job_id to keep waiting.",
|
|
210
|
+
op: "renderRestyleVideo",
|
|
211
|
+
path: { video_id: { required: false, description: "The vid_… video to restyle (omit with job_id)." } },
|
|
212
|
+
query: { wait: { from: "wait_s" } },
|
|
213
|
+
body: {
|
|
214
|
+
style: {
|
|
215
|
+
collapse: true,
|
|
216
|
+
keys: ["background", "frame", "cursor", "captions", "click_effect"],
|
|
217
|
+
description: "Preset IDs from render_presets.",
|
|
218
|
+
},
|
|
219
|
+
captions: {},
|
|
220
|
+
output: {},
|
|
221
|
+
formats: {},
|
|
222
|
+
alias: {
|
|
223
|
+
description: "Add the restyled video to this alias; when it succeeds the alias (and its share) plays it.",
|
|
224
|
+
},
|
|
225
|
+
},
|
|
226
|
+
args: {
|
|
227
|
+
job_id: { type: "string", description: "A vid_… id from an earlier call." },
|
|
228
|
+
wait_s: WAIT_S,
|
|
229
|
+
include_poster: {
|
|
230
|
+
type: "boolean",
|
|
231
|
+
default: true,
|
|
232
|
+
description: "Return the poster frame as an image once the video has succeeded.",
|
|
233
|
+
},
|
|
234
|
+
},
|
|
235
|
+
continueWith: { arg: "job_id", op: "renderGetVideo" },
|
|
236
|
+
example: {
|
|
237
|
+
video_id: "vid_01m5t68q1b590rj801nbzsqzkk",
|
|
238
|
+
style: { background: "midnight", frame: "browser-dark" },
|
|
239
|
+
alias: "billing-tour",
|
|
240
|
+
wait_s: 10,
|
|
241
|
+
},
|
|
242
|
+
hints: { readOnlyHint: false, openWorldHint: false },
|
|
243
|
+
},
|
|
244
|
+
{
|
|
245
|
+
name: "render_presets",
|
|
246
|
+
group: "render",
|
|
247
|
+
title: "List render presets",
|
|
248
|
+
description:
|
|
249
|
+
"The style presets render takes (backgrounds, frames, cursors, captions, click effects), one line each as " +
|
|
250
|
+
"id (kind): name, for the style of render_screenshot, render_video and render_restyle.",
|
|
251
|
+
op: "renderListPresets",
|
|
252
|
+
query: { kind: {} },
|
|
253
|
+
example: { kind: "background" },
|
|
254
|
+
hints: { readOnlyHint: true, idempotentHint: true, openWorldHint: false },
|
|
255
|
+
},
|
|
256
|
+
{
|
|
257
|
+
name: "render_share",
|
|
258
|
+
group: "render",
|
|
259
|
+
title: "Share a video",
|
|
260
|
+
description:
|
|
261
|
+
"Publish a video, or an alias's newest video, at a public page on usercontent.b3os.org (Open Graph, oEmbed, " +
|
|
262
|
+
"its own iframe): returns the page URL, the embed HTML, the oEmbed URL and stable GIF and poster links. An " +
|
|
263
|
+
"alias share keeps playing the newest re-record with no change to the embed. stop: true stops the share; " +
|
|
264
|
+
"the page, its files and its oEmbed answer 404 within 60 seconds.",
|
|
265
|
+
op: "renderShareVideo",
|
|
266
|
+
path: { video_id: { required: false, description: "The vid_… video to share (or give alias)." } },
|
|
267
|
+
body: { title: {} },
|
|
268
|
+
args: {
|
|
269
|
+
alias: {
|
|
270
|
+
type: "string",
|
|
271
|
+
pattern: "^[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?$",
|
|
272
|
+
description: "Share this alias of the project instead of one video.",
|
|
273
|
+
},
|
|
274
|
+
stop: { type: "boolean", default: false, description: "Stop the share instead of making it." },
|
|
275
|
+
},
|
|
276
|
+
uses: ["renderUnshareVideo", "renderShareAlias", "renderUnshareAlias"],
|
|
277
|
+
example: { alias: "billing-tour", title: "Billing in 30 seconds" },
|
|
278
|
+
hints: { readOnlyHint: false, destructiveHint: true, idempotentHint: true, openWorldHint: false },
|
|
279
|
+
},
|
|
280
|
+
{
|
|
281
|
+
name: "render_screenshot_file",
|
|
282
|
+
group: "render",
|
|
283
|
+
title: "Save a screenshot to a file",
|
|
284
|
+
description:
|
|
285
|
+
"Take a screenshot as render_screenshot does, and save the image to a file on this machine (the local server " +
|
|
286
|
+
"only, inside its working folder). Answers with the path, the image's size and its signed URL, never the " +
|
|
287
|
+
"image itself.",
|
|
288
|
+
op: "renderCreateScreenshot",
|
|
289
|
+
body: {
|
|
290
|
+
url: {},
|
|
291
|
+
html: {},
|
|
292
|
+
viewport: {},
|
|
293
|
+
full_page: {},
|
|
294
|
+
target: {
|
|
295
|
+
collapse: true,
|
|
296
|
+
keys: ["selector", "text", "role", "name"],
|
|
297
|
+
description: "Capture only this element: {selector} (CSS), {text} (visible text) or {role, name}.",
|
|
298
|
+
},
|
|
299
|
+
wait_for_ms: {},
|
|
300
|
+
theme: {},
|
|
301
|
+
hide: {},
|
|
302
|
+
style: {
|
|
303
|
+
collapse: true,
|
|
304
|
+
keys: ["background", "frame"],
|
|
305
|
+
description:
|
|
306
|
+
"Leave style out for a plain capture. Any style object, even {}, adds the B3OS frame. Preset IDs from GET /v1/render/presets.",
|
|
307
|
+
},
|
|
308
|
+
format: {},
|
|
309
|
+
},
|
|
310
|
+
args: {
|
|
311
|
+
path: {
|
|
312
|
+
type: "string",
|
|
313
|
+
description: "The file to save the image to, inside the server's working folder (shot.png).",
|
|
314
|
+
},
|
|
315
|
+
},
|
|
316
|
+
example: { url: "https://example.com", path: "shot.png" },
|
|
317
|
+
hints: { readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: true },
|
|
318
|
+
},
|
|
126
319
|
];
|
package/table/tools/routines.mjs
CHANGED
|
@@ -27,6 +27,21 @@ export const TOOLS = [
|
|
|
27
27
|
continueWith: { arg: "job_id", op: "routinesGetRun" },
|
|
28
28
|
hints: { readOnlyHint: false, openWorldHint: true },
|
|
29
29
|
},
|
|
30
|
+
{
|
|
31
|
+
name: "routine_list_runs",
|
|
32
|
+
group: "routines",
|
|
33
|
+
title: "List a routine's runs",
|
|
34
|
+
description:
|
|
35
|
+
"List a routine's recent runs (by name or rtn_ id), newest first, one line each with its status, trigger, " +
|
|
36
|
+
"version, duration and outcome, and for a failed run the step it failed at with the error.",
|
|
37
|
+
op: "routinesListRuns",
|
|
38
|
+
path: { routine: {} },
|
|
39
|
+
query: { status: {}, limit: { default: 10 }, cursor: {} },
|
|
40
|
+
defaults: { limit: 10 },
|
|
41
|
+
why: { limit: "ten runs first (an agent's context is expensive); the cursor or a larger limit reads more" },
|
|
42
|
+
example: { routine: "nightly-digest", status: "failed", limit: 5 },
|
|
43
|
+
hints: { readOnlyHint: true, openWorldHint: false },
|
|
44
|
+
},
|
|
30
45
|
{
|
|
31
46
|
name: "routine_get_run",
|
|
32
47
|
group: "routines",
|
|
@@ -39,6 +54,46 @@ export const TOOLS = [
|
|
|
39
54
|
path: { run_id: {} },
|
|
40
55
|
hints: { readOnlyHint: true, openWorldHint: false },
|
|
41
56
|
},
|
|
57
|
+
{
|
|
58
|
+
name: "routine_run_events",
|
|
59
|
+
group: "routines",
|
|
60
|
+
title: "Read a run's events",
|
|
61
|
+
description:
|
|
62
|
+
"Read a finished run's event log: when each step started, retried, waited and ended, with errors, and the " +
|
|
63
|
+
"run.log lines of its core/log steps. A run still in progress answers with its steps so far.",
|
|
64
|
+
op: "routinesRunEvents",
|
|
65
|
+
path: { run_id: {} },
|
|
66
|
+
args: {
|
|
67
|
+
max_events: {
|
|
68
|
+
type: "integer",
|
|
69
|
+
minimum: 1,
|
|
70
|
+
maximum: 500,
|
|
71
|
+
default: 40,
|
|
72
|
+
description: "The last events to show; the answer counts the earlier ones.",
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
uses: ["routinesGetRun"],
|
|
76
|
+
example: { run_id: "run_01m5t68q1b590rj801nbzsqzkk", max_events: 20 },
|
|
77
|
+
hints: { readOnlyHint: true, openWorldHint: false },
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
name: "routine_publish",
|
|
81
|
+
group: "routines",
|
|
82
|
+
title: "Publish a routine",
|
|
83
|
+
description:
|
|
84
|
+
"Publish a routine definition by its name: the first publish creates it, each later one adds a version. Check " +
|
|
85
|
+
"it with routine_validate first. Returns the routine's id and version; run it with routine_run.",
|
|
86
|
+
op: "routinesPublishRoutine",
|
|
87
|
+
path: { routine: { required: false, description: "The routine's name (default: definition.name)." } },
|
|
88
|
+
args: {
|
|
89
|
+
definition: {
|
|
90
|
+
type: "object",
|
|
91
|
+
description: "The definition as JSON: name and steps, optionally inputs, triggers, vars, output, defaults.",
|
|
92
|
+
},
|
|
93
|
+
},
|
|
94
|
+
example: { definition: { name: "hello", steps: [{ id: "say", uses: "core/log@1", with: { message: "hi" } }] } },
|
|
95
|
+
hints: { readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: false },
|
|
96
|
+
},
|
|
42
97
|
{
|
|
43
98
|
name: "routine_validate",
|
|
44
99
|
group: "routines",
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
// Sandboxes tools of the MCP tool table (owner: sandboxes, 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
|
-
// core tools follow CORE in core.mjs, the rest of this list keeps its order within the sandboxes
|
|
3
|
+
// core tools follow CORE in core.mjs, the rest of this list keeps its order within the sandboxes and desktop toolsets.
|
|
4
|
+
|
|
5
|
+
import { WAIT_S } from "../core.mjs";
|
|
6
|
+
|
|
7
|
+
/** The feature flag the desktop toolset is listed behind (packages/spec/flags/sandboxes.yaml). */
|
|
8
|
+
const DESKTOP_FLAG = "sandboxes.desktop";
|
|
4
9
|
|
|
5
10
|
/** @type {import("../../scripts/gen-table.mjs").ToolSource[]} */
|
|
6
11
|
export const TOOLS = [
|
|
@@ -147,6 +152,60 @@ export const TOOLS = [
|
|
|
147
152
|
body: { count: {}, metadata: { collapse: true, description: "Up to 16 string key-value pairs for the copies." } },
|
|
148
153
|
hints: { readOnlyHint: false, destructiveHint: false, openWorldHint: false },
|
|
149
154
|
},
|
|
155
|
+
{
|
|
156
|
+
name: "sandbox_swarm",
|
|
157
|
+
group: "sandboxes",
|
|
158
|
+
title: "Run a swarm",
|
|
159
|
+
description:
|
|
160
|
+
"Fork one checkpoint (a forkable sandbox, running or paused, or a snapshot) into up to 32 children, run a " +
|
|
161
|
+
"command in each (one per child in children, or count copies of defaults; B3OS_SWARM_INDEX tells them apart) " +
|
|
162
|
+
"and return every child's exit code, output and timing. Waits up to wait_s seconds; if it is still running, " +
|
|
163
|
+
"call again with job_id.",
|
|
164
|
+
op: "sandboxesCreateSwarm",
|
|
165
|
+
query: { wait: { from: "wait_s" } },
|
|
166
|
+
body: {
|
|
167
|
+
from: {
|
|
168
|
+
required: false,
|
|
169
|
+
collapse: true,
|
|
170
|
+
description: "The checkpoint: {sandbox: sbx_…} (created with forkable: true) or {snapshot: snap_…}.",
|
|
171
|
+
},
|
|
172
|
+
children: {
|
|
173
|
+
collapse: true,
|
|
174
|
+
description: "One object per child: {cmd, env, cwd, stdin, timeout_ms}; cmd is a shell line or an argv.",
|
|
175
|
+
},
|
|
176
|
+
count: {},
|
|
177
|
+
defaults: {
|
|
178
|
+
collapse: true,
|
|
179
|
+
description: "The child spec every child starts from ({cmd, env, cwd, timeout_ms}).",
|
|
180
|
+
},
|
|
181
|
+
stop_when: {},
|
|
182
|
+
keep: {},
|
|
183
|
+
},
|
|
184
|
+
args: {
|
|
185
|
+
job_id: { type: "string", description: "A swm_… id from an earlier call: keep waiting or read the results." },
|
|
186
|
+
wait_s: WAIT_S,
|
|
187
|
+
},
|
|
188
|
+
continueWith: { arg: "job_id", op: "sandboxesGetSwarm" },
|
|
189
|
+
hints: { readOnlyHint: false, destructiveHint: false, openWorldHint: true },
|
|
190
|
+
example: {
|
|
191
|
+
from: { sandbox: "sbx_01m5t68q1b590rj801nbzsqzkk" },
|
|
192
|
+
count: 3,
|
|
193
|
+
defaults: { cmd: "pytest -k shard_$B3OS_SWARM_INDEX" },
|
|
194
|
+
stop_when: "all",
|
|
195
|
+
wait_s: 30,
|
|
196
|
+
},
|
|
197
|
+
},
|
|
198
|
+
{
|
|
199
|
+
name: "sandbox_cancel_swarm",
|
|
200
|
+
group: "sandboxes",
|
|
201
|
+
title: "Cancel a swarm",
|
|
202
|
+
description:
|
|
203
|
+
"Stop a running swarm: its children's commands are killed and the children deleted unless its keep keeps them.",
|
|
204
|
+
op: "sandboxesCancelSwarm",
|
|
205
|
+
path: { swarm_id: {} },
|
|
206
|
+
hints: { readOnlyHint: false, destructiveHint: true, idempotentHint: true, openWorldHint: false },
|
|
207
|
+
example: { swarm_id: "swm_01m5t9k2hz4qv8e3c7rn0d6xja" },
|
|
208
|
+
},
|
|
150
209
|
{
|
|
151
210
|
name: "sandbox_snapshot",
|
|
152
211
|
group: "sandboxes",
|
|
@@ -225,6 +284,19 @@ export const TOOLS = [
|
|
|
225
284
|
body: { ttl_s: {} },
|
|
226
285
|
hints: { readOnlyHint: false, destructiveHint: false, openWorldHint: false },
|
|
227
286
|
},
|
|
287
|
+
{
|
|
288
|
+
name: "sandbox_port_host",
|
|
289
|
+
group: "sandboxes",
|
|
290
|
+
title: "Give a port its own host",
|
|
291
|
+
description:
|
|
292
|
+
"Give a port inside the sandbox its own host, https://<port>-sbx-<id>.b3os.io, where the app runs at / and " +
|
|
293
|
+
"keeps its cookies, so sign-in works. Returns the host and a link that opens it (shared by link only; the " +
|
|
294
|
+
"link is a secret). Prefer it to sandbox_port_url for web apps; rotate: true ends every earlier link.",
|
|
295
|
+
op: "platformCreatePortHost",
|
|
296
|
+
path: { sandbox_id: {}, port: {} },
|
|
297
|
+
body: { ttl_s: {}, rotate: {}, cookies: {} },
|
|
298
|
+
hints: { readOnlyHint: false, destructiveHint: false, openWorldHint: false },
|
|
299
|
+
},
|
|
228
300
|
{
|
|
229
301
|
name: "sandbox_logs",
|
|
230
302
|
group: "sandboxes",
|
|
@@ -266,4 +338,167 @@ export const TOOLS = [
|
|
|
266
338
|
body: { signal: {} },
|
|
267
339
|
hints: { readOnlyHint: false, destructiveHint: true, idempotentHint: true, openWorldHint: false },
|
|
268
340
|
},
|
|
341
|
+
|
|
342
|
+
// The desktop toolset (B3-7326, research/desk-v0.md §2 and §7 item 3): desktops are sandboxes of the `desktop`
|
|
343
|
+
// template, driven through the computer-use operations. Every tool names the `sandboxes.desktop` flag, so the
|
|
344
|
+
// toolset is listed whole or not at all: desktop_create, desktop_list, desktop_delete and desktop_run call open
|
|
345
|
+
// operations, the other three operations behind that flag. Handlers: src/handlers/sandboxes.ts.
|
|
346
|
+
{
|
|
347
|
+
name: "desktop_create",
|
|
348
|
+
group: "desktop",
|
|
349
|
+
flag: DESKTOP_FLAG,
|
|
350
|
+
title: "Create a desktop",
|
|
351
|
+
description:
|
|
352
|
+
"Start a desktop: a sandbox of the desktop template, a Linux desktop with Chrome on a 1280x800 screen, for " +
|
|
353
|
+
"computer use. Returns its id. Look at it with desktop_screenshot, drive its mouse and keyboard with " +
|
|
354
|
+
"desktop_act, and run shell commands in it with desktop_run. It stops after timeout_s seconds, or pauses " +
|
|
355
|
+
"with on_idle: pause. Running and paused desktops count against your limits, so call desktop_delete on each " +
|
|
356
|
+
"desktop you created once the task is done; desktop_room says how many more fit. Logins, captchas and " +
|
|
357
|
+
"payments are for a person: stop and ask the user.",
|
|
358
|
+
op: "sandboxesCreateSandbox",
|
|
359
|
+
body: {
|
|
360
|
+
vcpu: {},
|
|
361
|
+
memory_mib: {},
|
|
362
|
+
timeout_s: {},
|
|
363
|
+
on_idle: {},
|
|
364
|
+
metadata: { collapse: true, description: "Up to 16 string key-value pairs for your own use." },
|
|
365
|
+
},
|
|
366
|
+
defaults: { template: "desktop" },
|
|
367
|
+
why: { template: "a desktop tool creates desktops; template is not an argument" },
|
|
368
|
+
hints: { readOnlyHint: false, destructiveHint: false, openWorldHint: false },
|
|
369
|
+
example: { timeout_s: 900, on_idle: "pause", metadata: { task: "checkout-test" } },
|
|
370
|
+
},
|
|
371
|
+
{
|
|
372
|
+
name: "desktop_list",
|
|
373
|
+
group: "desktop",
|
|
374
|
+
flag: DESKTOP_FLAG,
|
|
375
|
+
title: "List desktops",
|
|
376
|
+
description:
|
|
377
|
+
"List this project's desktops (sandboxes of the desktop template), newest first: each one's id, status, " +
|
|
378
|
+
"size and expiry. status filters them (running, paused, ...).",
|
|
379
|
+
op: "sandboxesListSandboxes",
|
|
380
|
+
query: { status: {} },
|
|
381
|
+
hints: { readOnlyHint: true, openWorldHint: false },
|
|
382
|
+
example: { status: "running" },
|
|
383
|
+
},
|
|
384
|
+
{
|
|
385
|
+
name: "desktop_delete",
|
|
386
|
+
group: "desktop",
|
|
387
|
+
flag: DESKTOP_FLAG,
|
|
388
|
+
title: "Delete a desktop",
|
|
389
|
+
description:
|
|
390
|
+
"Stop a desktop and destroy its memory and disk. Delete each desktop you created once the task is done: " +
|
|
391
|
+
"paused desktops still count against your limits.",
|
|
392
|
+
op: "sandboxesDeleteSandbox",
|
|
393
|
+
path: { sandbox_id: { description: "The desktop's sbx_… id, from desktop_create or desktop_list." } },
|
|
394
|
+
hints: { readOnlyHint: false, destructiveHint: true, idempotentHint: true, openWorldHint: false },
|
|
395
|
+
example: { sandbox_id: "sbx_01m5t68q1b590rj801nbzsqzkk" },
|
|
396
|
+
},
|
|
397
|
+
{
|
|
398
|
+
name: "desktop_room",
|
|
399
|
+
group: "desktop",
|
|
400
|
+
flag: DESKTOP_FLAG,
|
|
401
|
+
title: "Check room for desktops",
|
|
402
|
+
description:
|
|
403
|
+
"Say how many more desktops can be created now and which limit stops the next one (your organization's " +
|
|
404
|
+
"sandboxes, its desktops, or the node's memory), so you can plan a wave of desktop_create calls instead of " +
|
|
405
|
+
"meeting 429 or 503 answers. Paused desktops count. It is a reading, not a reservation.",
|
|
406
|
+
op: "sandboxesGetCapacity",
|
|
407
|
+
query: { vcpu: {}, memory_mib: {} },
|
|
408
|
+
defaults: { template: "desktop" },
|
|
409
|
+
hints: { readOnlyHint: true, openWorldHint: false },
|
|
410
|
+
example: { memory_mib: 2048 },
|
|
411
|
+
},
|
|
412
|
+
{
|
|
413
|
+
name: "desktop_screenshot",
|
|
414
|
+
group: "desktop",
|
|
415
|
+
flag: DESKTOP_FLAG,
|
|
416
|
+
title: "Take a desktop screenshot",
|
|
417
|
+
description:
|
|
418
|
+
"Take a screenshot of a desktop's whole 1280x800 screen and return it as an image (JPEG at quality 80 " +
|
|
419
|
+
"unless format or quality says otherwise). The x and y of desktop_act are pixels of this image from its top " +
|
|
420
|
+
"left. desktop_act already returns a screenshot after its actions; use this to look without acting.",
|
|
421
|
+
op: "sandboxesComputerScreenshot",
|
|
422
|
+
path: { sandbox_id: {} },
|
|
423
|
+
query: { format: {}, quality: {} },
|
|
424
|
+
hints: { readOnlyHint: true, openWorldHint: false },
|
|
425
|
+
example: { sandbox_id: "sbx_01m5t68q1b590rj801nbzsqzkk", format: "png" },
|
|
426
|
+
},
|
|
427
|
+
{
|
|
428
|
+
name: "desktop_act",
|
|
429
|
+
group: "desktop",
|
|
430
|
+
flag: DESKTOP_FLAG,
|
|
431
|
+
title: "Use a desktop's mouse and keyboard",
|
|
432
|
+
description:
|
|
433
|
+
"Send mouse and keyboard input to a desktop and see the result: runs 1 to 32 actions in order, waits for " +
|
|
434
|
+
"the screen to settle, and returns one line per action and a screenshot (JPEG 80; screenshot: false for " +
|
|
435
|
+
"none). The screen is 1280x800 and x, y are pixels from its top left. Each action is {action, ...}: click " +
|
|
436
|
+
"{x?, y?, button?, count? (2 double, 3 triple)}, move {x, y}, drag {path: [[x, y], ...]}, scroll {x?, y?, " +
|
|
437
|
+
'direction: up|down|left|right, amount?}, type {text}, key {keys: "ctrl+l", "Return"}, mouse_down and ' +
|
|
438
|
+
"mouse_up {x?, y?, button?}, key_down and key_up {key}, wait {ms}, cursor_position. An action without x " +
|
|
439
|
+
"and y acts at the pointer. A failed action stops the batch: the ones after it did not run. Look at the " +
|
|
440
|
+
"screenshot before you send an action again: a click, text or key that landed has run once already. " +
|
|
441
|
+
"Logins, captchas and payments are for a person: stop and ask the user to handle them; never try to solve " +
|
|
442
|
+
"or get around one.",
|
|
443
|
+
op: "sandboxesComputerAct",
|
|
444
|
+
path: { sandbox_id: {} },
|
|
445
|
+
body: {
|
|
446
|
+
actions: {
|
|
447
|
+
description:
|
|
448
|
+
"Run in order, 1 to 32; each is {action, ...}: click, move, drag, scroll, type, key, mouse_down, " +
|
|
449
|
+
"mouse_up, key_down, key_up, wait or cursor_position. Their waits add up to at most 30,000 ms.",
|
|
450
|
+
},
|
|
451
|
+
// The MCP defaults of research/desk-v0.md §2: a model acts on what it sees, so every call looks (the API's
|
|
452
|
+
// default is no screenshot and no settle). `false` turns either off; an object is sent as given.
|
|
453
|
+
screenshot: {
|
|
454
|
+
schema: {
|
|
455
|
+
type: ["object", "boolean"],
|
|
456
|
+
properties: {
|
|
457
|
+
format: { type: "string", enum: ["png", "jpeg"] },
|
|
458
|
+
quality: { type: "integer", minimum: 1, maximum: 100 },
|
|
459
|
+
},
|
|
460
|
+
default: { format: "jpeg", quality: 80 },
|
|
461
|
+
description: "The screenshot after the actions, {format, quality} (JPEG 80 when left out); false for none.",
|
|
462
|
+
},
|
|
463
|
+
},
|
|
464
|
+
settle: {
|
|
465
|
+
schema: {
|
|
466
|
+
type: ["object", "boolean"],
|
|
467
|
+
properties: {
|
|
468
|
+
quiet_ms: { type: "integer", minimum: 0, maximum: 1000 },
|
|
469
|
+
max_ms: { type: "integer", minimum: 0, maximum: 5000 },
|
|
470
|
+
},
|
|
471
|
+
default: { quiet_ms: 80, max_ms: 1000 },
|
|
472
|
+
description:
|
|
473
|
+
"Before the screenshot, wait until the screen has not changed for quiet_ms, at most max_ms (80 and " +
|
|
474
|
+
"1000 when left out); false for no wait.",
|
|
475
|
+
},
|
|
476
|
+
},
|
|
477
|
+
},
|
|
478
|
+
hints: { readOnlyHint: false, destructiveHint: true, openWorldHint: true },
|
|
479
|
+
example: {
|
|
480
|
+
sandbox_id: "sbx_01m5t68q1b590rj801nbzsqzkk",
|
|
481
|
+
actions: [
|
|
482
|
+
{ action: "click", x: 640, y: 60 },
|
|
483
|
+
{ action: "type", text: "docs.beta.b3os.org" },
|
|
484
|
+
{ action: "key", keys: "Return" },
|
|
485
|
+
],
|
|
486
|
+
},
|
|
487
|
+
},
|
|
488
|
+
{
|
|
489
|
+
name: "desktop_run",
|
|
490
|
+
group: "desktop",
|
|
491
|
+
flag: DESKTOP_FLAG,
|
|
492
|
+
title: "Run a command on a desktop",
|
|
493
|
+
description:
|
|
494
|
+
"Run a shell command (a string, run with /bin/sh -c) or an argv array in a desktop and return its exit " +
|
|
495
|
+
"code, stdout and stderr. DISPLAY is set, so a command reaches the screen (xdotool, a script that opens a " +
|
|
496
|
+
"window). A paused desktop is resumed first. background: true returns at once with the process.",
|
|
497
|
+
op: "sandboxesExec",
|
|
498
|
+
path: { sandbox_id: {} },
|
|
499
|
+
body: { cmd: {}, cwd: {}, env: {}, stdin: {}, timeout_ms: {}, background: {}, user: {} },
|
|
500
|
+
uses: ["sandboxesResumeSandbox"],
|
|
501
|
+
hints: { readOnlyHint: false, destructiveHint: true, openWorldHint: false },
|
|
502
|
+
example: { sandbox_id: "sbx_01m5t68q1b590rj801nbzsqzkk", cmd: "xdotool getmouselocation" },
|
|
503
|
+
},
|
|
269
504
|
];
|
package/table/tools.mjs
CHANGED
|
@@ -29,7 +29,9 @@
|
|
|
29
29
|
|
|
30
30
|
import { CORE, CORE_BUDGET, INSTRUCTIONS, MAX_DESCRIPTION_CHARS, PRODUCTS, RESULT_SIZE_CHARS } from "./core.mjs";
|
|
31
31
|
import { TOOLS as actions } from "./tools/actions.mjs";
|
|
32
|
+
import { TOOLS as agents } from "./tools/agents.mjs";
|
|
32
33
|
import { TOOLS as infer } from "./tools/infer.mjs";
|
|
34
|
+
import { TOOLS as listeners } from "./tools/listeners.mjs";
|
|
33
35
|
import { TOOLS as platform } from "./tools/platform.mjs";
|
|
34
36
|
import { TOOLS as render } from "./tools/render.mjs";
|
|
35
37
|
import { TOOLS as routines } from "./tools/routines.mjs";
|
|
@@ -39,7 +41,7 @@ import { TOOLS as vision } from "./tools/vision.mjs";
|
|
|
39
41
|
export { INSTRUCTIONS, MAX_DESCRIPTION_CHARS, RESULT_SIZE_CHARS };
|
|
40
42
|
|
|
41
43
|
/** @type {Record<string, import("../scripts/gen-table.mjs").ToolSource[]>} */
|
|
42
|
-
export const MODULES = { actions, infer, platform, render, routines, sandboxes, vision };
|
|
44
|
+
export const MODULES = { actions, agents, infer, listeners, platform, render, routines, sandboxes, vision };
|
|
43
45
|
|
|
44
46
|
/**
|
|
45
47
|
* Compose the table from the core list, the product order and the product modules. Every refusal names the file to
|