createCoworkTools (cowork-tools.ts)

pi-cowork · realtime-sync, shared-state, event-bus, collaboration, realtime

Creates coworking tools for real-time collaboration, managing shared state and events.

import { defineTool } from "@earendil-works/pi-coding-agent";
import type { ToolDefinition } from "@earendil-works/pi-coding-agent";
import type { TodoItem } from "../event-schema.js";

/**
 * Cowork-specific custom tools, layered on top of Pi Agent's built-in tools.
 *
 * - `ask_question`: pauses the agent until the user answers a clarifying question.
 *   Implemented by having execute() await a deferred promise resolved when the
 *   browser POSTs an answer to /api/sessions/:id/answers.
 * - `todo_write`: pushes the current task list to the UI (full replacement).
 *
 * The factory receives a `deps` object so the engine can wire the tools to the
 * session's WS event stream and answer resolver without the tools knowing about
 * HTTP or WebSockets.
 */
export interface CoworkToolDeps {
  /

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search 40K more like it.

Get a free API key