/** * Macro execution endpoint (workstream W5's backend slice): `GET /api/macros` * and `POST /api/macros/:id/run` from src/shared/types.ts. The SPA's action * rail already resolves and opens "open-url" macros client-side — it can't * carry the boot token through `window.open` anyway — so in practice this * only ever executes "inject" macros (routed to the session's pty, or to a * headless background task when the macro says `execution: "background"`) * but it handles every kind per the documented contract ("render-canvas" * is answered with a 400: the SPA re-reads the board itself). The integrator mounts this (with express.json()) alongside the * SessionManager, TaskManager, and WorkflowRegistry. */ import { type Router as ExpressRouter } from "express"; import { type MacroDef, type WorkflowInfo } from "../shared/types.js"; export interface MacrosRouterDeps { listMacros(): MacroDef[]; /** Look up a registered workflow by its path; null when not found. */ findWorkflow(workflowPath: string): WorkflowInfo | null; /** The session's project directory, or null when the session is unknown. */ getSessionCwd(harnessSessionId: string): string | null; /** The session's currently bound workflow path (PATCH /sessions/:id/workflow), * or null when unbound / the session is unknown. Explicit `workflowPath` on * the request always wins — this is only a fallback for when it's omitted. */ getBoundWorkflowPath(harnessSessionId: string): string | null; /** Injects resolved text into the session's pty (the SessionManager). */ injectInput(harnessSessionId: string, text: string, submit: boolean): Promise; /** Runs an "inject" macro marked `execution: "background"` as a headless * one-shot task (the TaskManager) instead of touching the session's pty. * `workflowPath` is the resolved workflow the macro was invoked against — * passed through to TaskManager so two sessions running the same macro * against the same workflow dedupe per-workflow rather than per-session. * May throw TaskNotSupportedError (session's harness has no headless * mode → 400) or TaskAlreadyRunningError (same macro already in flight * for this target → 409), or McpCredentialGenerationChangedError * (credentials changed while the task was preparing → 409). */ runBackgroundTask(harnessSessionId: string, macro: MacroDef, prompt: string, workflowPath: string | null): Promise; /** Opens a URL in the user's default browser (the `open` package). */ openUrl(url: string): Promise; } export declare function createMacrosRouter(deps: MacrosRouterDeps): ExpressRouter; //# sourceMappingURL=macros.d.ts.map