Register the dashboard's own tools with document.modelContext so an in-page agent can read tasks, events, and daemon health, and recover a stuck task: list_tasks, get_task, recent_events and daemon_health (read-only), plus retry_task, stop_task and cancel_task (consequential). The human review gate (approve/reject) and the destructive verbs (abandon/archive) are deliberately not exposed. Every tool calls the same ui/src/lib/api.ts client the interface calls, so the agent and the UI exercise one set of endpoints, one CSRF header and one error shape. Registration is framework-agnostic (lib/webmcp.ts machinery, lib/webmcp-tools.ts list, lib/archie-webmcp.ts the api binding) and no-ops when document.modelContext is absent, which it is outside the WebMCP origin trial. Tools returning agent, operator or inbound content carry untrustedContentHint; only the recovery actions carry consequentialHint. Verified in system Chrome 152 with --enable-features=WebMCP: seven tools listed with schemas and annotations, all four read-only tools executed against the live dashboard, and the flagless run mounts the dashboard with no exception.
12 lines
577 B
TypeScript
12 lines
577 B
TypeScript
// Binds the dashboard's WebMCP tool list to the dashboard's own HTTP client.
|
|
//
|
|
// Nothing here reaches into a component: the tools call the same `api` methods
|
|
// the UI calls, so the agent and the interface exercise one set of endpoints,
|
|
// one CSRF header, and one error shape.
|
|
import { api } from "./api";
|
|
import { createWebMcpRegistrar } from "./webmcp";
|
|
import { archieWebMcpTools } from "./webmcp-tools";
|
|
|
|
/** Registers the dashboard's tools, replacing any earlier registration. */
|
|
export const registerArchieWebMcpTools = createWebMcpRegistrar(archieWebMcpTools(api));
|