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
5 changes: 5 additions & 0 deletions .changeset/tool-docs-10e-2.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@agentproto/runtime": patch
---

Document the channels, reach, conversation and workspace-brain tool families (19 tools leave the legacy undocumented list).
2 changes: 1 addition & 1 deletion packages/cli/src/__tests__/help.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ describe("runHelp", () => {
})

it("says a real tool has no doc yet, exit 0, no suggestions", async () => {
const { out, err, code } = await capture(["telegram_bot_token_status"])
const { out, err, code } = await capture(["host_load"])
expect(code).toBe(0)
expect(err).toBe("")
expect(out).toContain("has no help doc yet")
Expand Down
4 changes: 2 additions & 2 deletions packages/runtime/src/__tests__/tool-help.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,10 @@ describe("tool_help MCP tool", () => {

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: "telegram_bot_token_status" } })
const result = await client.callTool({ name: "tool_help", arguments: { name: "host_load" } })
expect(result.isError).toBeFalsy()
const text = textOf(result)
expect(text).toContain("`telegram_bot_token_status` has no help doc yet")
expect(text).toContain("`host_load` has no help doc yet")
expect(text).toContain("tools/list")
expect(text).not.toContain("Close names")
await close()
Expand Down
159 changes: 159 additions & 0 deletions packages/runtime/src/tool-docs/channels.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
import { defineToolFamilyDoc } from "./types.js"

/**
* Sources: `orchestration-tools.ts` (transmit_message, inbound_endpoint_*,
* inbound_watcher_*), `outbound-adapters.ts` (send result and blocked
* statuses), `telegram-bot-creds.ts` (telegram_*).
*/
export const channelsToolDoc = defineToolFamilyDoc({
family: "channels",
title: "Channels: outbound messages, inbound endpoints, watchers and Telegram bots",
summary:
"Send a message to an external contact through a provider, receive replies by webhook or by polling and route them to a session, and set up a Telegram bot.",
whenToUse: [
"Message an outside contact (Telegram, an agentpush channel) and have their replies come back to the same session.",
"Expose a signed `/inbound/<slug>` webhook that spawns or routes into sessions.",
"Poll an agentpush source and spawn one agent per contact.",
"Connect a Telegram bot and point its webhook at this daemon.",
],
workflow: [
"Telegram only: `telegram_bot_token_set`, check with `telegram_bot_token_status`, then `telegram_bot_set_webhook` with a public https URL (see `tunnels`).",
"Receiving: `inbound_endpoint_create` (webhook; keep the generated `secret`) or `inbound_watcher_start` (polling; keep the `watcherId`).",
"Sending: `transmit_message` with a `sessionId` binds the contact to that session, so their replies route into it. The `alias` must match the one the endpoint was created with.",
"Clean up with `inbound_endpoint_delete` and `inbound_watcher_stop`; `inbound_endpoint_list` and `inbound_watcher_list` show what is live.",
],
cliCommands: [],
seeAlso: ["tunnels", "messaging", "reach"],
tools: {
transmit_message: {
effect: "external",
examples: [
{
label: "Message a Telegram chat and bind it to this session",
args: { provider: "telegram", source: "<bot-source>", contact_ref: "<chat-id>", text: "Build finished, tests green.", sessionId: "<session-id>" },
outcome: "Returns `{ sent: true, bound: true, message_id }`; the chat's next replies route into the session.",
},
{
label: "Fire and forget through agentpush",
args: { alias: "agentpush", source: "<channel>", contact_ref: "<contact-ref>", text: "Reminder: standup at 10.", bind: false },
outcome: "Returns `{ sent: true, bound: false }`; nothing is bound.",
},
],
returns: "`sent`, `bound`, `message_id`; on failure `error`, and `blocked_reason` / `suggestion` when the provider refused the send.",
pitfalls: [
"Provider defaults to `agentpush`, which requires `alias`; telegram defaults the alias to `default`.",
"`text` or `attachments` is required, and `sessionId` is required unless `bind: false`.",
"A blocked send (opt-out, expired window, unapproved template) is an error result with `blocked_reason`, not `sent: true`.",
"It is a real message to a real person: there is no dry run. The tool exists only when an MCP proxy and a binding store are wired.",
],
},
inbound_endpoint_create: {
effect: "write",
examples: [
{
label: "Create a webhook endpoint and keep its generated secret",
args: { slug: "support-line", provider: "generic", alias: "agentpush", mode: "route-or-spawn" },
outcome: "Returns `{ slug, provider, alias, mode, enabled, has_secret, secret }`; `secret` appears only when it was generated now.",
},
],
returns: "`slug` (the path of `POST /inbound/<slug>`) and `secret` (once).",
pitfalls: [
"It creates or updates by `slug`; an update keeps the existing secret unless you pass one.",
"`alias` must match what `transmit_message` used, or replies will not find their binding.",
"Modes: `spawn` always starts a fresh agent, `route` only delivers to a bound session, `route-or-spawn` (default) does both.",
"The URL must be reachable from outside (see `tunnels`); the secret is shown once, so store it.",
],
},
inbound_endpoint_list: {
effect: "read",
examples: [
{ label: "Compact list", args: {}, outcome: "Returns `{ endpoints }` with slug, provider, alias, mode and enabled. No secret." },
{ label: "Full records", args: { full: true }, outcome: "Adds source, createdTs, lastSeenTs and `has_secret`." },
],
returns: "`endpoints[].slug`.",
},
inbound_endpoint_delete: {
effect: "write",
examples: [
{ label: "Remove an endpoint", args: { slug: "support-line" }, outcome: "Returns `{ deleted: true }`, or `false` when the slug did not exist." },
],
returns: "`deleted`.",
pitfalls: ["Bindings made by `transmit_message` stay; only the webhook stops accepting posts."],
},
inbound_watcher_start: {
effect: "write",
examples: [
{
label: "Poll a source and spawn an agent per contact",
args: {
alias: "agentpush",
source: "<channel-or-phone>",
harness: "claude-code",
promptTemplate: "{{count}} new message(s) from {{contact_ref}}: {{messages_json}}. Answer them.",
pollIntervalMs: 5000,
mode: "route-or-spawn",
},
outcome: "Returns the watcher descriptor with a `watcherId`.",
},
],
returns: "`watcherId` for `inbound_watcher_stop`.",
pitfalls: [
"Import the agentpush server first (`mcp_import`); `alias` names that import.",
"`pollIntervalMs` is 1000 to 60000 (default 5000). `harness` is required; `adapter` is a deprecated alias.",
"Each contact spawns an agent that replies through `mcpServersForChild`; without agentpush mounted there, the agent cannot answer.",
"`mode` defaults to `spawn`, unlike the endpoint default.",
],
},
inbound_watcher_stop: {
effect: "write",
examples: [
{ label: "Stop a watcher", args: { watcherId: "<watcher-id>" }, outcome: "Returns `{ ok: true, status: \"stopped\" }`; the cursor is kept so a new watcher resumes there." },
],
returns: "`ok`; an unknown id is an error result.",
},
inbound_watcher_list: {
effect: "read",
examples: [
{ label: "Watchers, running and stopped", args: {}, outcome: "Returns `{ watchers }` with watcherId, alias, source, adapter, status and spawned count." },
{ label: "With cursors", args: { full: true }, outcome: "Adds cursor, lastPollAt and lastFireAt." },
],
returns: "`watchers[].watcherId`.",
},
telegram_bot_token_set: {
effect: "write",
examples: [
{ label: "Store the primary bot token", args: { token: "<bot-token-from-botfather>" }, outcome: "Returns `{ ok, alias: \"default\", fingerprint, last4 }`. The token is never returned." },
{ label: "A second bot", args: { token: "<bot-token>", alias: "support-bot" }, outcome: "Stored under that alias." },
],
returns: "`alias`, `fingerprint`, `last4`.",
pitfalls: ["Stored in a 0600 file under the user's agentproto home; setting it again rotates it. The token passes through your context once: do not echo it."],
humanGate: {
when: "always",
action: "The person creates the bot with @BotFather in Telegram and gives you the token it prints. No tool can create a bot or fetch that token.",
},
},
telegram_bot_token_status: {
effect: "read",
examples: [
{ label: "Is a token stored?", args: {}, outcome: "Returns `{ alias, configured, fingerprint, last4 }`, or `configured: false`." },
],
returns: "`configured`; compare `fingerprint` and `last4` to confirm which token is loaded.",
},
telegram_bot_set_webhook: {
effect: "external",
examples: [
{
label: "Point the bot at a public https URL",
args: { url: "https://bot.example.com/inbound/telegram" },
outcome: "Calls Telegram's setWebhook with the stored token; returns `{ ok: true, alias, url, secret_token }`.",
},
],
returns: "`secret_token` (generated when omitted), the value Telegram echoes in a header on each delivery.",
pitfalls: [
"Without a stored token it fails with `telegram_token_not_configured`: run `telegram_bot_token_set` first.",
"The URL must be public https and should end at an `inbound_endpoint_create` slug; keep `secret_token` and use it as that endpoint's secret.",
"A Telegram refusal is an error result carrying `telegram_error`.",
],
},
},
})
93 changes: 93 additions & 0 deletions packages/runtime/src/tool-docs/conversation.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
import { defineToolFamilyDoc } from "./types.js"

/**
* Sources: `conversation-read.ts`, `conversation-export.ts`,
* `conversation-locate-tool.ts`, `session-tools.ts` (transcript_search,
* transcript_read: bounds and result shape), `docs/cli/verbs/conversation.md`.
*/
export const conversationToolDoc = defineToolFamilyDoc({
family: "conversation",
title: "Conversations and transcripts: read what a session said",
summary:
"Read a session's native conversation, find which session owns a transcript file, copy a transcript into another harness's store, and search or excerpt a session and its predecessors.",
whenToUse: [
"Recover what was said before a restart or a continue-fresh.",
"Find the session behind a transcript file, or the transcript behind a forgotten session.",
"Resume a daemon session's conversation in the native CLI of a harness.",
],
workflow: [
"To find a fact: `transcript_search` with a `query`, then `transcript_read` with a `since` cursor for context around it.",
"To read the whole native conversation: `conversation_read` (paged with `lastN` and `cursor`).",
"With only a session id or a file path: `conversation_locate` returns the owner and the native file.",
"To continue elsewhere: `conversation_export` writes a copy and returns the resume command.",
],
cliCommands: [
{
verb: "conversation",
command: "agentproto conversation locate sess_ab12cd34 --json",
note: "Same as `conversation_locate`; it also accepts a native transcript path.",
},
],
seeAlso: ["workspace-brain", "agent"],
tools: {
transcript_search: {
effect: "read",
examples: [
{
label: "Find a decision made before a restart",
args: { sessionId: "<session-id>", query: "retry budget", maxResults: 5 },
outcome: "Returns `{ sessionId, query, chain, hits, truncated }`: dated excerpts, one bounded snippet per hit, across the session and its predecessors.",
},
],
returns: "`hits[]` (excerpt with its session and date), `chain` (the lineage walked), `truncated`.",
pitfalls: [
"Case-insensitive substring match, not semantic. Defaults: 10 hits (max 50), 600 characters per excerpt (80 to 4000), 20000 characters in total (200 to 100000).",
"The chain follows `resumedFrom`, `continuedFrom` and `succeeds` links; a session with no such link searches only itself.",
"Give `sessionId`, `idOrName` or `slug`; none is an error.",
],
},
transcript_read: {
effect: "read",
examples: [
{ label: "The latest excerpts", args: { sessionId: "<session-id>", maxRecords: 10 }, outcome: "Returns `{ sessionId, chain, excerpts, truncated }`." },
{ label: "Only what matches, after a cursor", args: { sessionId: "<session-id>", query: "migration", since: 120 }, outcome: "Excerpts containing `migration` from records past sequence 120 of the target's own transcript." },
],
returns: "`excerpts[]` with sequence numbers to reuse as `since`.",
pitfalls: [
"Bounded: 10 excerpts by default (max 50), 600 characters each (80 to 4000), 20000 total. Never a whole transcript: use `conversation_read` for that.",
"`since` applies only to the target session's own file; predecessors are read from their start.",
],
},
conversation_read: {
effect: "read",
examples: [
{ label: "Last 20 messages as markdown", args: { sessionId: "<session-id>", lastN: 20 }, outcome: "Returns the rendered conversation with a `window` including `nextCursor`." },
{ label: "Page forward as JSON", args: { sessionId: "<session-id>", format: "json", cursor: 40 }, outcome: "Starts at message index 40." },
],
returns: "The rendered conversation and `window.nextCursor`; or `{ conversation: null, reason }`, or a candidate list.",
pitfalls: [
"A session with no underlying conversation (a bash or vim terminal) returns `conversation: null`: a normal outcome, not an error.",
"When discovery finds several candidate conversations it returns the list instead of guessing.",
"Read-only: it never spawns, resumes or writes.",
],
},
conversation_locate: {
effect: "read",
examples: [
{ label: "Session to transcript", args: { target: "sess_ab12cd34" }, outcome: "Returns `{ found: true, workspace, record, matchedBy: \"sessionId\" }`." },
{ label: "Transcript file to session", args: { target: "/path/to/native/conversation.jsonl" }, outcome: "Returns the owner session; `matchedSubagentPath` is set when the file was a subagent transcript." },
],
returns: "`found`, `record`, `workspace`, or `reason` when nothing matched.",
pitfalls: ["Not found is `{ found: false, reason }`, not an error. Useful after `session_gc` with `forget`, when the session is gone but its transcript is not."],
},
conversation_export: {
effect: "write",
examples: [
{ label: "Make a Claude Code resumable copy", args: { sessionId: "<session-id>", target: "claude-code" }, outcome: "Writes a copy into the native store and returns the conversation id, the written path and the `claude --resume <uuid>` command." },
{ label: "Scope it to another directory", args: { sessionId: "<session-id>", target: "claude-code", cwd: "/path/to/repo" }, outcome: "The copy lands under the project slug of that directory." },
],
returns: "Conversation id, written path, resume command.",
pitfalls: ["It writes a copy into the harness's own store under the user's home; the daemon session is never modified and nothing is resumed for you. Only `claude-code` is supported."],
},
},
})
8 changes: 8 additions & 0 deletions packages/runtime/src/tool-docs/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ import { llmEndpointToolDoc } from "./llm-endpoint.js"
import { remoteToolDoc } from "./remote.js"
import { sandboxToolDoc } from "./sandbox.js"
import { tunnelsToolDoc } from "./tunnels.js"
import { channelsToolDoc } from "./channels.js"
import { reachToolDoc } from "./reach.js"
import { conversationToolDoc } from "./conversation.js"
import { workspaceBrainToolDoc } from "./workspace-brain.js"
import type { ToolFamilyDoc } from "./types.js"
import { worktreeToolDoc } from "./worktree.js"

Expand All @@ -66,6 +70,10 @@ export type {
} from "./types.js"

export const TOOL_FAMILY_DOCS: readonly ToolFamilyDoc[] = [
workspaceBrainToolDoc,
conversationToolDoc,
reachToolDoc,
channelsToolDoc,
tunnelsToolDoc,
sandboxToolDoc,
remoteToolDoc,
Expand Down
19 changes: 0 additions & 19 deletions packages/runtime/src/tool-docs/legacy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,6 @@ export const LEGACY_UNDOCUMENTED_TOOLS: readonly DaemonToolName[] = [
"browser_screenshot",
"browser_scroll",
"capabilities_inventory",
"conversation_export",
"conversation_locate",
"conversation_read",
"daemon_health",
"directory_create",
"directory_list",
Expand All @@ -43,26 +40,10 @@ export const LEGACY_UNDOCUMENTED_TOOLS: readonly DaemonToolName[] = [
"file_read",
"file_write",
"host_load",
"inbound_endpoint_create",
"inbound_endpoint_delete",
"inbound_endpoint_list",
"inbound_watcher_list",
"inbound_watcher_start",
"inbound_watcher_stop",
"live_session",
"reach_send",
"role_list",
"self_inspect",
"telegram_bot_set_webhook",
"telegram_bot_token_set",
"telegram_bot_token_status",
"tool_calls_list",
"tool_help",
"transcript_read",
"transcript_search",
"transmit_message",
"usage_rollup",
"workspace_brain_ingest",
"workspace_brain_query",
"workspace_brain_status",
]
48 changes: 48 additions & 0 deletions packages/runtime/src/tool-docs/reach.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import { defineToolFamilyDoc } from "./types.js"

/**
* Sources: `reach/tools.ts` (the tool and its limits), `reach/tell.ts`
* (statuses, dedupe).
*/
export const reachToolDoc = defineToolFamilyDoc({
family: "reach",
title: "Reach: tell the owner something",
summary: "Send the owner a short, one-way notice on their phone or chat through the daemon's reach route.",
whenToUse: [
"A session has news the owner would want to know now, and no answer is needed.",
"A long job finished or hit a blocker the owner should see without opening the daemon.",
],
workflow: [
"Call `reach_send` with a short `summary` and a stable `dedupeKey`.",
"Read `status`: a delivered status means the route took it; `deduped` means the same key already went out in the last 24 hours; `undelivered` carries a `reason` (for example `no-route`).",
],
cliCommands: [],
seeAlso: ["messaging", "channels"],
tools: {
reach_send: {
effect: "external",
examples: [
{
label: "Tell the owner a job finished",
args: {
summary: "Nightly migration finished, 0 errors.",
dedupeKey: "nightly-migration-2026-12-01",
links: [{ url: "https://example.com/runs/42", label: "Run" }],
},
outcome: "Returns `{ status, adapterId?, attempts }` with one attempt per route entry tried.",
},
{
label: "A digest-grade notice via a chosen route entry",
args: { summary: "Three PRs are waiting for review.", dedupeKey: "review-queue-digest", urgency: "digest", via: "<route-entry-id>" },
outcome: "May be grouped with other digests; `via` is tried first and the rest of the route follows.",
},
],
returns: "`status`, `adapterId`, `attempts[]` (each with status and, on failure, `reason`).",
pitfalls: [
"A tell only: no question, no answer comes back. Use `approval_request` when you need a decision.",
"`summary` is 1 to 1000 characters, at most 3 `links`, https only; at most 20 tells per session per day.",
"Without a reach route configured, the answer is `reach_not_available` or `undelivered` with `no-route`.",
],
},
},
})
Loading
Loading