Skip to content

ACP host hooks — permission, updates, cancel, stream

JavaScript · package toolnexus · SPEC §8

Opt-in hooks on an ACP model source: choose the permission option, watch every session/update, cancel a turn, and stream through an in-process client.

The JS ACP client (loadACP → ACPClient, js/src/acp.ts) ships without these hooks. Today it:

  • answers every session/request_permission with the first allow-kind option as soon as it arrives (permissionTimeoutMs only bounds a broken agent);
  • returns only agent_message_chunk text as the reply — thoughts, tool calls and plans are not surfaced;
  • has no per-turn cancel and does not stream through createInProcessClient.

To gate an ACP agent’s actions today, set the agent’s own mode with ACPOptions.mode (for example a read-only or plan mode the agent supports) and keep side-effecting work in toolnexus tools, where beforeTool gates them. The Go port has the hooks (ACPOptions.OnPermission, OnUpdate, ACPClient.GenerateCtx, GenerateStream) — see the Go page. Tracked in openspec/changes/add-go-host-asks task 2.6d.

  • createClient — The unified client: system prompt, skills injection, parallel and chained tool calls, retries, memory.
  • Client.run — Send a prompt, let the loop call tools until the model stops, get a RunResult.
  • Client.stream — The streaming loop: text deltas, tool-call events, and suspension events as they happen.
  • Hooks — Intercept before/after model calls and tool calls: audit, redact, veto, or rewrite.