/** * GH-746: lets a short-lived CLI invocation (e.g. `sf setup-agents workflow * execute --background`, run via the chat's own Bash tool) reach the ALREADY * async delegation pipeline (`POST /api/v1/chat/delegate` → spawnDetached → * /spawn/events SSE → console notifications) instead of spawning and awaiting * a subagent inline in its own throwaway process — whose in-memory event bus * (spawn-session.ts's `eventListeners`) no SSE client can ever see. * * The bridge server already exports its own port/token on `process.env` * (server/index.ts) when it starts; the chat process inherits them via * buildSandboxEnv's process.env copy (chat-process-manager.ts), and a Bash * tool call inside that chat turn inherits them again — no new credential * storage needed. */ export type RunningBridge = { port: number; token: string; cwd: string; }; /** * Reads the bridge connection env vars this process inherited (if any) and * confirms a healthy bridge is actually listening on that port for THIS * workspace. Returns `null` if the vars are absent, the bridge isn't * reachable, or it's serving a different workspace (e.g. a second `serve` * running for an unrelated project on the same machine). */ export declare function discoverRunningBridge(cwd: string): Promise; export type DelegateViaBridgeInput = { bridge: RunningBridge; sessionId: string; taskId: string; runId: string; phase: string; goal: string; label?: string; }; export type DelegateViaBridgeResult = { ok: true; sessionId: string; status: string; } | { ok: false; error: string; }; export type BackgroundDispatchInput = { cwd: string; taskId: string; runId: string; phase: string; goal: string; label?: string; }; export type BackgroundDispatchResult = { dispatched: true; sessionId: string; } | { dispatched: false; error?: string; }; /** * Shared by `workflow execute` (GH-746) and `workflow run --autonomous` * (GH-748): discovers a running bridge for THIS chat session and workspace, * and dispatches `phase` through its existing async delegation route. * `dispatched: false` with no `error` means the prerequisites (chat session * id + a reachable bridge) simply aren't present — the expected, silent case * outside a chat session (CI, manual terminal) — vs. with an `error`, which * means the bridge WAS reachable but rejected the delegation for cause. */ export declare function tryDispatchPhaseInBackground(input: BackgroundDispatchInput): Promise; /** POSTs to the running bridge's existing `/api/v1/chat/delegate` route. */ export declare function delegateViaBridge(input: DelegateViaBridgeInput): Promise;