Pure helpers for ZCode's app-server stdio protocol.
ZCode Protocol v1 is NDJSON over stdio. Messages are JSON-RPC-shaped but
omit the jsonrpc field — the envelope is {id?, method?, params?, result?, error?}. IDs may be strings or integers.
This module owns only wire-shape construction and parsing. Translation
between ACP and ZCode message semantics lives in ZCode.Mapper.
Summary
Functions
Returns the ZCode executable path.
Returns the ZCode command line used by app-server sessions.
Builds a ZCode error response.
Builds a ZCode notification (no id).
Builds a ZCode request message.
Builds a ZCode success response.
Environment required for ZCode app-server.
Encodes one ZCode message as an NDJSON line.
Extracts the model reference from a ZCode session/snapshot.
Converts ZCode permission options into ACP permission options.
Converts an ACP permission outcome back into a ZCode permission response
(Nv shape: decision/reason/modifiedInput/permissionUpdates).
Maps a ZCode interaction/requestPermission request into an ACP tool call
suitable for session/request_permission.
Converts ACP prompt blocks into ZCode session/send content.
Extracts the session ID from a ZCode session snapshot.
Maps a ZCode turn.completed resultType to an ACP stopReason.
Builds the workspace descriptor required by the ZCode Protocol.
Functions
Returns the ZCode executable path.
Returns the ZCode command line used by app-server sessions.
Builds a ZCode error response.
Builds a ZCode notification (no id).
Builds a ZCode request message.
Builds a ZCode success response.
Environment required for ZCode app-server.
Encodes one ZCode message as an NDJSON line.
Extracts the model reference from a ZCode session/snapshot.
Converts ZCode permission options into ACP permission options.
ZCode options carry a pre-resolved response field (the decision that
selecting each option produces). We map the ZCode decision vocabulary
(allow/deny/escalate/modify) to ACP permission option kinds.
Converts an ACP permission outcome back into a ZCode permission response
(Nv shape: decision/reason/modifiedInput/permissionUpdates).
The ACP client responds with {outcome: "selected", optionId: ...} or
{outcome: "cancelled"}. We find the matching ZCode option's pre-resolved
response and return it, falling back to a deny.
Maps a ZCode interaction/requestPermission request into an ACP tool call
suitable for session/request_permission.
Converts ACP prompt blocks into ZCode session/send content.
ZCode's session/send accepts a content string. In v1 we support
text-only prompts. Image/embedded-context support is a follow-up.
Extracts the session ID from a ZCode session snapshot.
Maps a ZCode turn.completed resultType to an ACP stopReason.
ZCode result types: success, cancelled, error_max_turns, error_max_budget, error_during_execution, error_max_tool_calls.
Builds the workspace descriptor required by the ZCode Protocol.