Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/lot-10f-tool-family-docs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@agentproto/runtime": patch
"@agentproto/cli": patch
---

Document the remaining file, browser, panel, daemon status and introspection tools as family docs (fs, browser, panels, daemon-status, introspection). Every daemon tool now has a family doc, so `tool_help` and `agentproto help` drop the unreachable "known tool without a doc" answer.
8 changes: 0 additions & 8 deletions packages/cli/src/__tests__/help.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,6 @@ describe("runHelp", () => {
expect(list.length).toBeLessThanOrEqual(10)
})

it("says a real tool has no doc yet, exit 0, no suggestions", async () => {
const { out, err, code } = await capture(["host_load"])
expect(code).toBe(0)
expect(err).toBe("")
expect(out).toContain("has no help doc yet")
expect(out).not.toContain("Close names")
})

it("--topic selects a section of the family doc", async () => {
const { out, code } = await capture(["desktop_conversation_create", "--topic", "Examples"])
expect(code).toBe(0)
Expand Down
6 changes: 2 additions & 4 deletions packages/cli/src/commands/help.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import {
extractHelpSection,
getToolFamilyHelp,
getToolHelp,
isKnownDaemonTool,
unknownToolHelpMessage,
} from "@agentproto/runtime"

Expand Down Expand Up @@ -55,9 +54,8 @@ export async function runHelp(argv: readonly string[]): Promise<number> {
process.stdout.write((section ?? family) + "\n")
return 0
}
const known = isKnownDaemonTool(name)
;(known ? process.stdout : process.stderr).write(`agentproto help: ${unknownToolHelpMessage(name)}\n`)
return known ? 0 : 1
process.stderr.write(`agentproto help: ${unknownToolHelpMessage(name)}\n`)
return 1
}

if (!topic) {
Expand Down
11 changes: 0 additions & 11 deletions packages/runtime/src/__tests__/tool-help.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,17 +106,6 @@ describe("tool_help MCP tool", () => {
await close()
})

it("says a real tool has no doc yet, without suggestions or an error", async () => {
const { client, close } = await buildHarness()
const result = await client.callTool({ name: "tool_help", arguments: { name: "host_load" } })
expect(result.isError).toBeFalsy()
const text = textOf(result)
expect(text).toContain("`host_load` has no help doc yet")
expect(text).toContain("tools/list")
expect(text).not.toContain("Close names")
await close()
})

it("does not crash on Object.prototype names and honors topic on the family doc", async () => {
expect(getToolFamilyHelp("constructor")).toBeUndefined()
expect(getToolFamilyHelp("__proto__")).toBeUndefined()
Expand Down
256 changes: 256 additions & 0 deletions packages/runtime/src/tool-docs/browser.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,256 @@
import { defineToolFamilyDoc } from "./types.js"

/**
* Sources: `browser-tools.ts` (registration, schemas, `builtin` modes),
* `browser-proxy.ts` (field mapping, refused and dropped fields, `notes`),
* `page-text.ts` (extraction, blocked detection).
*/
export const browserToolDoc = defineToolFamilyDoc({
family: "browser",
title: "Web pages and the browser relay",
summary:
"Read a public page over plain HTTP, or drive a real browser tab (navigate, read, click, fill, scroll, screenshot, record) through the external browser server.",
whenToUse: [
"Read a public web page as clean text: start with `fetch_page`, which needs no browser.",
"Handle a page that is anti-bot gated, needs JavaScript or needs clicks and typing: use a browser tab.",
"Capture a screenshot or a short recording of a page.",
],
workflow: [
"Call `fetch_page` with the URL. When `blocked` is true or the text is empty because the page needs JavaScript, switch to a browser tab.",
"Call `browser_navigate` to open the URL in this session's own tab, then `browser_extract_text` to read it.",
"Use `browser_get_dom` to find a CSS selector, then `browser_click`, `browser_fill`, `browser_press_key` or `browser_scroll` to interact.",
"Call `browser_screenshot` to see the page, or `browser_screencast_start`, `browser_screencast_frame` and `browser_screencast_stop` to record it.",
],
cliCommands: [],
seeAlso: ["browser-instances", "ap-import-mcp"],
tools: {
fetch_page: {
effect: "external",
examples: [
{
label: "Read a public page",
args: { url: "https://example.com/docs" },
outcome: "Returns `{ title, text, url, blocked: false }` with `text` as markdown without boilerplate.",
},
{
label: "Allow a slow server more time",
args: { url: "https://example.com/report", timeoutMs: 30000 },
outcome: "Same result, with the request aborted after 30 seconds instead of 15.",
},
],
returns: "`title`, `text`, `url` (after redirects) and `blocked`.",
pitfalls: [
"`blocked: true` (HTTP 403, 429 or 503, or a known challenge page) returns only `url`, `blocked` and `status`, with no text: retry with a browser tab, not with the same fetch.",
"Any other non-2xx status is a tool error; `timeoutMs` defaults to 15000 and is capped at 60000.",
"It does not run JavaScript: a page that renders its content client-side comes back nearly empty.",
"It is the only tool of the family still registered when `defaults.browser.builtin` is `off`.",
],
},
browser_navigate: {
effect: "external",
examples: [
{
label: "Open a page in this session's tab",
args: { url: "https://example.com/login" },
outcome: "Opens the tab on first use, loads the URL and returns the browser server's answer, with a `deprecated` marker.",
},
{
label: "Target an owned tab on a named instance",
args: { url: "https://example.com/dashboard", tabId: "<tab-id>", instance: "<instance-id>" },
outcome: "Navigates that tab instead of the default one.",
},
],
returns: "The browser server's result, plus `deprecated` and, when a field was dropped, `notes`.",
pitfalls: [
"Every `browser_*` tool is a deprecated relay: it forwards to the server named by `defaults.browser.proxyImport` (default `bureau`) and answers an error when that import is missing; prefer calling that server's own tool.",
"A session only touches tabs it owns; the tab is opened on first use, so there is no separate open-tab call.",
"`sessionId` is accepted and ignored (reported in `notes`): the server identifies the calling session itself.",
"A server-side error such as `browser:not_owner` or `browser:awaiting_consent` is returned unchanged; consent needs a person to act in the browser.",
],
},
browser_extract_text: {
effect: "external",
examples: [
{
label: "Read the current tab as clean text",
args: {},
outcome: "Returns `{ title, text, url }` with `text` as markdown, built from the tab's DOM with boilerplate removed.",
},
],
returns: "`title`, `text` (markdown) and `url`.",
pitfalls: ["Call `browser_navigate` first: with no loaded page there is nothing to read."],
},
browser_get_dom: {
effect: "external",
examples: [
{
label: "Get the raw markup to find a selector",
args: {},
outcome: "Returns the tab's serialized DOM (outerHTML).",
},
],
returns: "The raw DOM text.",
pitfalls: ["The result can be very large: prefer `browser_extract_text` unless you need exact markup."],
},
browser_click: {
effect: "external",
examples: [
{
label: "Click a button",
args: { selector: "button[type=submit]" },
outcome: "Left-clicks the element once.",
},
{
label: "Double-click with the right button",
args: { selector: "#row-1", button: "right", clickCount: 2 },
outcome: "Sends two clicks with the right mouse button.",
},
],
returns: "The browser server's result.",
pitfalls: ["`clickCount` is 1 to 3; use `browser_get_dom` first when you do not know a selector."],
},
browser_fill: {
effect: "external",
examples: [
{
label: "Fill a field",
args: { selector: "input[name=email]", value: "user@example.com" },
outcome: "Clears the field, then types the value.",
},
{
label: "Append to existing text",
args: { selector: "textarea#notes", value: " more text", clear: false },
outcome: "Types after the current content.",
},
],
returns: "The browser server's result.",
pitfalls: ["`selector` must designate an input or textarea element; an error from the browser server is returned unchanged."],
},
browser_evaluate: {
effect: "external",
examples: [
{
label: "Read a value from the page",
args: { expression: "document.title" },
outcome: "Returns the serialized result of the expression.",
},
{
label: "Await a request and cap the output",
args: { expression: "fetch('/api/items').then(r => r.json())", awaitPromise: true, maxResultBytes: 20000 },
outcome: "Waits for the promise and truncates the serialized result at 20000 bytes.",
},
],
returns: "The expression's value as the browser server serializes it.",
pitfalls: [
"`awaitPromise` and `returnByValue` both default to true.",
"The expression runs with the page's own privileges and cookies: treat page content as untrusted and do not run text taken from it.",
],
},
browser_scroll: {
effect: "external",
examples: [
{
label: "Scroll an element into view",
args: { selector: "#comments" },
outcome: "Centers the element in the viewport.",
},
{
label: "Scroll the window down by 800 px",
args: { y: 800 },
outcome: "Scrolls relative to the current position.",
},
],
returns: "The browser server's result.",
pitfalls: [
"`x` and `y` are deltas in CSS pixels, not absolute positions, and are ignored when `selector` is set.",
"The daemon runs a fixed script through the server's evaluate tool; your selector is passed as data, never as code.",
],
},
browser_press_key: {
effect: "external",
examples: [
{
label: "Press Enter",
args: { key: "Enter" },
outcome: "Sends the key to whatever has focus.",
},
{
label: "Select all",
args: { key: "a", modifiers: ["Control"] },
outcome: "Presses the key while holding Control.",
},
],
returns: "The browser server's result.",
pitfalls: [
"`selector` and `count` exist in the schema but are refused with an error and nothing is sent: click the element first, and call again to repeat.",
"`key` is a name such as Enter, Tab, Escape, Backspace, Delete, an arrow, Home, End, PageUp, PageDown, Space, or one printable character.",
],
},
browser_screenshot: {
effect: "external",
examples: [
{
label: "Screenshot the current tab",
args: {},
outcome: "Returns the image as base64 with its format.",
},
],
returns: "The base64 image and its format.",
pitfalls: ["This relay exposes only `tabId` and `instance`: format, quality and full-page options of the server are not reachable here."],
},
browser_list_tabs: {
effect: "read",
examples: [
{
label: "List this session's tabs",
args: {},
outcome: "Returns the tabs the session owns, with the ids to pass as `tabId`.",
},
],
returns: "The owned tabs and their `tabId` values.",
},
browser_screencast_start: {
effect: "external",
examples: [
{
label: "Record an owned tab at 5 frames per second",
args: { tabId: "<tab-id>", fps: 5, format: "jpeg" },
outcome: "Starts recording; the call then needs `browser_screencast_stop` to finish.",
},
],
returns: "The browser server's result, with `notes` naming any dropped field.",
pitfalls: [
"`tabId` is required by the server although the schema marks it optional: get it from `browser_list_tabs`.",
"`quality`, `everyNthFrame`, `maxWidth` and `maxHeight` are dropped and listed in `notes`; only `fps` (default 3, clamped to 1 to 10) and `format` take effect.",
],
},
browser_screencast_frame: {
effect: "read",
examples: [
{
label: "Grab the latest frame",
args: { tabId: "<tab-id>" },
outcome: "Returns the most recent recorded frame.",
},
],
returns: "One frame as the browser server returns it.",
pitfalls: ["A recording must be running on that tab, started with `browser_screencast_start`."],
},
browser_screencast_stop: {
effect: "external",
examples: [
{
label: "Stop and encode",
args: { tabId: "<tab-id>" },
outcome: "Ends the recording and encodes the frames into a video (`encode` defaults to true).",
},
{
label: "Stop and keep raw frames",
args: { tabId: "<tab-id>", encode: false },
outcome: "Ends the recording without encoding.",
},
],
returns: "The browser server's result for the recording.",
},
},
})
Loading
Loading