@b3os/mcp 0.2.2 → 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.
@@ -53,7 +53,9 @@ export const TOOLS = [
53
53
  body: {
54
54
  name: {},
55
55
  source: {},
56
- entry: {},
56
+ // The spec takes `entry` or `harness`; this tool makes entry agents, so it keeps `entry` required until the
57
+ // node serves harness agents (B3-7262).
58
+ entry: { required: true },
57
59
  env: {},
58
60
  secrets: {},
59
61
  api: {},
@@ -277,4 +277,43 @@ export const TOOLS = [
277
277
  example: { alias: "billing-tour", title: "Billing in 30 seconds" },
278
278
  hints: { readOnlyHint: false, destructiveHint: true, idempotentHint: true, openWorldHint: false },
279
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
+ },
280
319
  ];
@@ -76,6 +76,24 @@ export const TOOLS = [
76
76
  example: { run_id: "run_01m5t68q1b590rj801nbzsqzkk", max_events: 20 },
77
77
  hints: { readOnlyHint: true, openWorldHint: false },
78
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
+ },
79
97
  {
80
98
  name: "routine_validate",
81
99
  group: "routines",
@@ -1,9 +1,12 @@
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 toolset.
3
+ // core tools follow CORE in core.mjs, the rest of this list keeps its order within the sandboxes and desktop toolsets.
4
4
 
5
5
  import { WAIT_S } from "../core.mjs";
6
6
 
7
+ /** The feature flag the desktop toolset is listed behind (packages/spec/flags/sandboxes.yaml). */
8
+ const DESKTOP_FLAG = "sandboxes.desktop";
9
+
7
10
  /** @type {import("../../scripts/gen-table.mjs").ToolSource[]} */
8
11
  export const TOOLS = [
9
12
  {
@@ -335,4 +338,167 @@ export const TOOLS = [
335
338
  body: { signal: {} },
336
339
  hints: { readOnlyHint: false, destructiveHint: true, idempotentHint: true, openWorldHint: false },
337
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
+ },
338
504
  ];