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-1.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@agentproto/runtime": patch
---

Document the sandbox, tunnels, remote, llm-endpoint and decision tool families (32 tools leave the legacy undocumented list).
170 changes: 170 additions & 0 deletions packages/runtime/src/tool-docs/decision.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
import { defineToolFamilyDoc } from "./types.js"

/**
* Sources: `decision-tools.ts` (`decision_decide`), `decision-workflow-tools.ts`
* (the seven stage tools), `workflows/decision-route/` (the shipped workflow and
* its example DECISION.md).
*/
export const decisionToolDoc = defineToolFamilyDoc({
family: "decision",
title: "Decision router: closed-set choices from a DECISION.md policy",
summary:
"Resolve one closed choice from a policy plus evidence (rules, one classifier call, conservative default), or run it as the staged review-routing workflow.",
whenToUse: [
"Pick one of a few declared choices from evidence, with rules that a classifier cannot downgrade.",
"Route a code change to the right review binding (light, standard or deep) with a recorded trace.",
],
workflow: [
"One decision: `decision_decide` with the policy text and an evidence object. It never mutates anything.",
"Staged routing: run the `decision-route` workflow, or call the stages in order, each fed with the previous result: `decision_collect_evidence`, `decision_stage_rules`, `decision_stage_classify`, `decision_stage_escalate`, `decision_select_review`, `decision_run_review`, `decision_validate_verdict`.",
"Read `approved` only from `decision_validate_verdict`; every other state (shadow, timeout, provider-unavailable, incomplete) is not an approval.",
],
cliCommands: [],
seeAlso: ["review", "workflows"],
tools: {
decision_decide: {
effect: "read",
examples: [
{
label: "Decide from a policy and evidence",
args: {
policy: "---\nschema: 1\nname: review-router\nversion: 1\nchoices: [light, standard, deep]\ndefault: deep\n...\n---\n",
evidence: { changeTypes: ["docs-only"], riskCategories: [] },
},
outcome: "Returns `{ choice, source, matchedRules, status, ... }`. Here a docs-only rule would settle it with zero model calls.",
},
],
returns: "`choice`, `source` (rule, rule-floor, classifier, escalation or default), `status` (`decided` or `fallback`), `matchedRules`, `probabilities`, `confidence`, hashes.",
pitfalls: [
"A malformed policy comes back as `{ ok: false, errors }`, not as a tool error; a failed classification gives `status: \"fallback\"` with the policy's default.",
"`fallback` is a safe answer, not a trusted one, and is never cached.",
"Paths, code and messages are removed from the evidence before the classifier unless the policy's evidence section allows them. No harness escalation runs here.",
"The classifier needs a Jev API key; without one the call degrades to the default.",
],
},
decision_collect_evidence: {
effect: "read",
examples: [
{
label: "Evidence for a git range",
args: { cwd: "/path/to/repo", policyPath: "DECISION.md", base: "origin/main", head: "HEAD" },
outcome: "Returns `{ ok, policy, evidence, range, complete, withheld, notes, trace }`: counts, change types and risk categories, never code.",
},
{
label: "Consumer-built evidence",
args: { cwd: "/path/to/repo", policy: "<DECISION.md text>", supplied: { changeTypes: ["docs-only"] } },
outcome: "Same export policy applied to the evidence you supply.",
},
],
returns: "`evidence` and `policy` to pass to the next stages; `complete: false` means classifier scores will not be trusted.",
pitfalls: [
"Pass `policy` or `policyPath`; neither is `{ ok: false }`. Stage failures are data, never MCP errors.",
"Paths appear only if the policy's evidence section allows them; secrets are scrubbed.",
],
},
decision_stage_rules: {
effect: "read",
examples: [
{
label: "Apply the rules, no model call",
args: { policy: "<DECISION.md text>", evidence: { riskCategories: ["security"] } },
outcome: "Returns `{ ok, settled, decision, trace }`; `settled: true` when a rule decided.",
},
],
returns: "`settled`, `decision`; pass `decision` along as `rules`.",
},
decision_stage_classify: {
effect: "external",
examples: [
{
label: "Classify an unresolved case",
args: { policy: "<DECISION.md text>", evidence: { changeTypes: ["code"] }, rules: { ok: true, settled: false } },
outcome: "Returns `{ ok, settled, decision, trace }`; skipped (no model call) when the rules settled it, the policy disables the classifier or the profile disables Jev.",
},
],
returns: "`settled`, `decision`; pass the whole result along as `classify`.",
pitfalls: [
"One call, no retries. Low confidence is not a human request: it flows to escalation.",
"It sends the bounded evidence to the Jev API when the profile allows it.",
],
},
decision_stage_escalate: {
effect: "external",
examples: [
{
label: "Escalate a still-unresolved case under the free profile",
args: {
policy: "<DECISION.md text>",
profile: "local-free",
evidence: { changeTypes: ["code"] },
classify: { ok: true, settled: false },
rules: { ok: true, settled: false },
},
outcome: "Returns `{ ok, settled, decision, escalation, trace }`; no session is spawned when already settled.",
},
],
returns: "`settled`, `decision`, `escalation` (status, wait, `toolControls`).",
pitfalls: [
"At most one harness session, spawned read-only with no MCP servers. The harness's own built-in tools stay available: `toolControls` reports what is configured versus enforced.",
"The profile validates the adapter and model before any spawn; an unknown identity fails closed, and placement (a sandbox) grants no entitlement.",
"If the escalation session asks for human input, nobody answers it here: the result is `wait: \"human-input-required\"` and the policy default applies, so there is no human gate to wait on.",
"`profile` is `local-free` (default) or `remote-sonnet`; `profileOptions` narrows targets and budgets but cannot change the entitlement. `profileOptions.escalation.adapter` is a deprecated alias of `harness`.",
],
},
decision_select_review: {
effect: "read",
examples: [
{
label: "Map the choice to a review binding",
args: { policy: "<DECISION.md text>", escalate: { ok: true, settled: true }, cwd: "/path/to/repo" },
outcome: "Returns `{ ok, ready, state, choice, binding, targets, trace }`.",
},
],
returns: "`binding` and `targets`; pass the whole result along as `select`.",
pitfalls: [
"Default bindings: skip and light map to `light`, standard to `local`, deep to `deep`; `freeBindings` overrides under a free-only profile (deep becomes `deep-free`).",
"Every reviewer, fallback and recovery preset of the binding is preflighted against the profile; one non-entitled target refuses the whole selection and nothing is substituted.",
],
},
decision_run_review: {
effect: "external",
examples: [
{
label: "Shadow run (default): report only",
args: { policy: "<DECISION.md text>", select: { ok: true, ready: true, binding: "local" }, cwd: "/path/to/repo" },
outcome: "Returns `{ ok, mode: \"shadow\", ... }` saying which binding would run; no review lane is spawned.",
},
{
label: "Enforce",
args: { policy: "<DECISION.md text>", select: { ok: true, ready: true, binding: "local" }, cwd: "/path/to/repo", mode: "enforce" },
outcome: "Starts the review with a profile deadline and returns `review` ({ runId, status, verdict, lanes, durationMs }).",
},
],
returns: "`state`, `review.verdict`; pass the whole result along as `review`.",
pitfalls: [
"Only `mode: \"enforce\"` starts anything; the review is cancelled on the deadline or on abort.",
"`nocache: true` skips a cached review result.",
],
},
decision_validate_verdict: {
effect: "read",
examples: [
{
label: "Fold everything into one report",
args: {
policy: "<DECISION.md text>",
escalate: { ok: true, settled: true },
select: { ok: true, binding: "local" },
review: { ok: true, mode: "enforce", state: "done" },
},
outcome: "Returns `{ ok, approved, state, reason, verdict, choice, binding, violations, trace }`.",
},
],
returns: "`approved` and `state`.",
pitfalls: [
"`approved` is true only for a real passing verdict from lanes that stayed inside the profile. completed, provider-unavailable, human-input-required, incomplete, timeout, cancelled, refused, failed and shadow are separate states, never approvals.",
"A blocking finding stops the flow: no other model is asked to approve it.",
],
},
},
})
10 changes: 10 additions & 0 deletions packages/runtime/src/tool-docs/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ import { mcpAppsToolDoc } from "./mcp-apps.js"
import { mcpImportToolDoc } from "./mcp-import.js"
import { skillImportToolDoc } from "./skill-import.js"
import { toolAuthoringToolDoc } from "./tool-authoring.js"
import { decisionToolDoc } from "./decision.js"
import { llmEndpointToolDoc } from "./llm-endpoint.js"
import { remoteToolDoc } from "./remote.js"
import { sandboxToolDoc } from "./sandbox.js"
import { tunnelsToolDoc } from "./tunnels.js"
import type { ToolFamilyDoc } from "./types.js"
import { worktreeToolDoc } from "./worktree.js"

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

export const TOOL_FAMILY_DOCS: readonly ToolFamilyDoc[] = [
tunnelsToolDoc,
sandboxToolDoc,
remoteToolDoc,
llmEndpointToolDoc,
decisionToolDoc,
authProfileToolDoc,
catalogToolDoc,
harnessToolDoc,
Expand Down
32 changes: 0 additions & 32 deletions packages/runtime/src/tool-docs/legacy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,6 @@ export const LEGACY_UNDOCUMENTED_TOOLS: readonly DaemonToolName[] = [
"conversation_locate",
"conversation_read",
"daemon_health",
"decision_collect_evidence",
"decision_decide",
"decision_run_review",
"decision_select_review",
"decision_stage_classify",
"decision_stage_escalate",
"decision_stage_rules",
"decision_validate_verdict",
"directory_create",
"directory_list",
"fetch_page",
Expand All @@ -58,23 +50,8 @@ export const LEGACY_UNDOCUMENTED_TOOLS: readonly DaemonToolName[] = [
"inbound_watcher_start",
"inbound_watcher_stop",
"live_session",
"llm_endpoint_list_links",
"llm_endpoint_set_upstream_link",
"llm_endpoint_start",
"llm_endpoint_status",
"llm_endpoint_stop",
"reach_send",
"remote_disable",
"remote_enable",
"remote_status",
"role_list",
"sandbox_attach",
"sandbox_checkpoint_gc",
"sandbox_checkpoint_gc_status",
"sandbox_egress_health",
"sandbox_exec",
"sandbox_gc",
"sandbox_list",
"self_inspect",
"telegram_bot_set_webhook",
"telegram_bot_token_set",
Expand All @@ -84,15 +61,6 @@ export const LEGACY_UNDOCUMENTED_TOOLS: readonly DaemonToolName[] = [
"transcript_read",
"transcript_search",
"transmit_message",
"tunnel_add_hostname",
"tunnel_create",
"tunnel_delete",
"tunnel_list",
"tunnel_login",
"tunnel_remove_hostname",
"tunnel_revoke",
"tunnel_status",
"tunnel_stop",
"usage_rollup",
"workspace_brain_ingest",
"workspace_brain_query",
Expand Down
105 changes: 105 additions & 0 deletions packages/runtime/src/tool-docs/llm-endpoint.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
import { defineToolFamilyDoc } from "./types.js"

/**
* Sources: `llm-endpoint-tools.ts` (every tool), `llm-endpoint-links-store.ts`
* (canonical upstreams).
*/
export const llmEndpointToolDoc = defineToolFamilyDoc({
family: "llm-endpoint",
title: "LLM endpoint: the local inference proxy sidecar",
summary:
"Start, stop and inspect the inference-endpoint proxy the daemon supervises, and link each of its upstreams to an auth profile.",
whenToUse: [
"Run the OpenAI-compatible proxy on this machine without starting it by hand.",
"Make an upstream authenticate from a named auth profile instead of a bare environment key.",
],
workflow: [
"`llm_endpoint_status` to see whether it runs and is healthy.",
"`llm_endpoint_list_links` shows each upstream, its linked profile and the eligible profiles; `llm_endpoint_set_upstream_link` links one.",
"`llm_endpoint_start` (after `llm_endpoint_stop` when links changed), because links are read only when the proxy is spawned.",
],
cliCommands: [],
seeAlso: ["agentproto-llm-endpoint"],
tools: {
llm_endpoint_start: {
effect: "external",
examples: [
{
label: "Start on the default port",
args: {},
outcome: "Spawns the proxy (port 18090 unless `LLM_ENDPOINT_PORT` is set) and returns `{ pid, port, baseUrl, status, startedAt }` once ready.",
},
{
label: "Start behind an access token",
args: { port: 18091, accessTokens: "<token>" },
outcome: "The proxy requires that bearer token on inbound requests.",
},
],
returns: "`baseUrl` and `port` to point clients at, `pid`, `status`.",
pitfalls: [
"Idempotent: when the proxy is already running and healthy, the existing descriptor is returned and nothing is respawned, so new `port`, `accessTokens` or `env` are not applied. Stop first.",
"Without `accessTokens` the proxy is open; it also carries the stored provider keys, so bind it only where that is acceptable.",
"Explicit `env` wins over the injected provider keys and the port default.",
],
},
llm_endpoint_stop: {
effect: "write",
examples: [
{ label: "Stop the proxy", args: {}, outcome: "Returns `{ ok }` after SIGTERM to the child; idempotent when it is not running." },
],
returns: "`ok`.",
},
llm_endpoint_status: {
effect: "read",
examples: [
{
label: "Probe it",
args: {},
outcome: "Returns `{ running, pid, port, baseUrl, healthy, startedAt }`; `healthy` comes from a live `GET /v1/models`.",
},
],
returns: "`running`, `healthy`, `baseUrl`.",
},
llm_endpoint_list_links: {
effect: "read",
examples: [
{
label: "Links and eligible profiles",
args: {},
outcome: "Returns `{ links, upstreams }`: `links` maps provider to profile id; each upstream row has `provider`, `linkedProfile` and `eligible` ({ id, label, method, endpoint }).",
},
{
label: "Paged, full profile metadata",
args: { full: true, limit: 5 },
outcome: "Pages the rows with the whole non-secret profile metadata. Never a secret.",
},
],
returns: "Upstream names to pass as `provider` and eligible profile ids to pass as `profileId`.",
pitfalls: [
"It reports the persisted link; a running proxy may lag until restarted.",
"A profile is eligible when its endpoint equals the upstream, it is not disabled, and its method fits (`oauth-bearer` only for `anthropic`).",
],
},
llm_endpoint_set_upstream_link: {
effect: "write",
examples: [
{
label: "Link an upstream to an auth profile",
args: { provider: "anthropic", profileId: "team-primary" },
outcome: "Persists the link and returns `{ ok: true, applied: false, restartRequired }`.",
},
{
label: "Clear the link",
args: { provider: "anthropic", profileId: null },
outcome: "Reverts that upstream to its environment key; `cleared` says whether a link existed.",
},
],
returns: "`restartRequired` (true when the proxy is running), `applied` (always false).",
pitfalls: [
"It never restarts the proxy: the link is injected as an environment variable only at spawn.",
"The profile id is not checked for existence; a dangling link gives a 401 at request time.",
"`provider` must be a canonical upstream, and an account slot ref is refused: pass a real profile id from `auth_profile_list`.",
],
},
},
})
Loading
Loading