@b3os/mcp 0.2.0 → 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
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,147 @@ 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
|
+
},
|
|
126
280
|
];
|
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,28 @@ 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
|
+
},
|
|
42
79
|
{
|
|
43
80
|
name: "routine_validate",
|
|
44
81
|
group: "routines",
|
|
@@ -2,6 +2,8 @@
|
|
|
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 sandboxes toolset.
|
|
4
4
|
|
|
5
|
+
import { WAIT_S } from "../core.mjs";
|
|
6
|
+
|
|
5
7
|
/** @type {import("../../scripts/gen-table.mjs").ToolSource[]} */
|
|
6
8
|
export const TOOLS = [
|
|
7
9
|
{
|
|
@@ -147,6 +149,60 @@ export const TOOLS = [
|
|
|
147
149
|
body: { count: {}, metadata: { collapse: true, description: "Up to 16 string key-value pairs for the copies." } },
|
|
148
150
|
hints: { readOnlyHint: false, destructiveHint: false, openWorldHint: false },
|
|
149
151
|
},
|
|
152
|
+
{
|
|
153
|
+
name: "sandbox_swarm",
|
|
154
|
+
group: "sandboxes",
|
|
155
|
+
title: "Run a swarm",
|
|
156
|
+
description:
|
|
157
|
+
"Fork one checkpoint (a forkable sandbox, running or paused, or a snapshot) into up to 32 children, run a " +
|
|
158
|
+
"command in each (one per child in children, or count copies of defaults; B3OS_SWARM_INDEX tells them apart) " +
|
|
159
|
+
"and return every child's exit code, output and timing. Waits up to wait_s seconds; if it is still running, " +
|
|
160
|
+
"call again with job_id.",
|
|
161
|
+
op: "sandboxesCreateSwarm",
|
|
162
|
+
query: { wait: { from: "wait_s" } },
|
|
163
|
+
body: {
|
|
164
|
+
from: {
|
|
165
|
+
required: false,
|
|
166
|
+
collapse: true,
|
|
167
|
+
description: "The checkpoint: {sandbox: sbx_…} (created with forkable: true) or {snapshot: snap_…}.",
|
|
168
|
+
},
|
|
169
|
+
children: {
|
|
170
|
+
collapse: true,
|
|
171
|
+
description: "One object per child: {cmd, env, cwd, stdin, timeout_ms}; cmd is a shell line or an argv.",
|
|
172
|
+
},
|
|
173
|
+
count: {},
|
|
174
|
+
defaults: {
|
|
175
|
+
collapse: true,
|
|
176
|
+
description: "The child spec every child starts from ({cmd, env, cwd, timeout_ms}).",
|
|
177
|
+
},
|
|
178
|
+
stop_when: {},
|
|
179
|
+
keep: {},
|
|
180
|
+
},
|
|
181
|
+
args: {
|
|
182
|
+
job_id: { type: "string", description: "A swm_… id from an earlier call: keep waiting or read the results." },
|
|
183
|
+
wait_s: WAIT_S,
|
|
184
|
+
},
|
|
185
|
+
continueWith: { arg: "job_id", op: "sandboxesGetSwarm" },
|
|
186
|
+
hints: { readOnlyHint: false, destructiveHint: false, openWorldHint: true },
|
|
187
|
+
example: {
|
|
188
|
+
from: { sandbox: "sbx_01m5t68q1b590rj801nbzsqzkk" },
|
|
189
|
+
count: 3,
|
|
190
|
+
defaults: { cmd: "pytest -k shard_$B3OS_SWARM_INDEX" },
|
|
191
|
+
stop_when: "all",
|
|
192
|
+
wait_s: 30,
|
|
193
|
+
},
|
|
194
|
+
},
|
|
195
|
+
{
|
|
196
|
+
name: "sandbox_cancel_swarm",
|
|
197
|
+
group: "sandboxes",
|
|
198
|
+
title: "Cancel a swarm",
|
|
199
|
+
description:
|
|
200
|
+
"Stop a running swarm: its children's commands are killed and the children deleted unless its keep keeps them.",
|
|
201
|
+
op: "sandboxesCancelSwarm",
|
|
202
|
+
path: { swarm_id: {} },
|
|
203
|
+
hints: { readOnlyHint: false, destructiveHint: true, idempotentHint: true, openWorldHint: false },
|
|
204
|
+
example: { swarm_id: "swm_01m5t9k2hz4qv8e3c7rn0d6xja" },
|
|
205
|
+
},
|
|
150
206
|
{
|
|
151
207
|
name: "sandbox_snapshot",
|
|
152
208
|
group: "sandboxes",
|
|
@@ -225,6 +281,19 @@ export const TOOLS = [
|
|
|
225
281
|
body: { ttl_s: {} },
|
|
226
282
|
hints: { readOnlyHint: false, destructiveHint: false, openWorldHint: false },
|
|
227
283
|
},
|
|
284
|
+
{
|
|
285
|
+
name: "sandbox_port_host",
|
|
286
|
+
group: "sandboxes",
|
|
287
|
+
title: "Give a port its own host",
|
|
288
|
+
description:
|
|
289
|
+
"Give a port inside the sandbox its own host, https://<port>-sbx-<id>.b3os.io, where the app runs at / and " +
|
|
290
|
+
"keeps its cookies, so sign-in works. Returns the host and a link that opens it (shared by link only; the " +
|
|
291
|
+
"link is a secret). Prefer it to sandbox_port_url for web apps; rotate: true ends every earlier link.",
|
|
292
|
+
op: "platformCreatePortHost",
|
|
293
|
+
path: { sandbox_id: {}, port: {} },
|
|
294
|
+
body: { ttl_s: {}, rotate: {}, cookies: {} },
|
|
295
|
+
hints: { readOnlyHint: false, destructiveHint: false, openWorldHint: false },
|
|
296
|
+
},
|
|
228
297
|
{
|
|
229
298
|
name: "sandbox_logs",
|
|
230
299
|
group: "sandboxes",
|
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
|