一键导入
ax-ipc
Use when modifying IPC protocol between host and agent — schemas, actions, length-prefix framing, or Zod validation in ipc-schemas.ts and ipc-server.ts
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Use when modifying IPC protocol between host and agent — schemas, actions, length-prefix framing, or Zod validation in ipc-schemas.ts and ipc-server.ts
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Use when modifying logging, error handling, or diagnostic messages — logger setup, transports, error diagnosis patterns in src/logger.ts and src/errors.ts
Use when modifying the trusted host process — server orchestration, message routing, IPC handler, request lifecycle, event streaming, file handling, plugin loading, or agent delegation in src/host/
Use when modifying the sandboxed agent process — runner, IPC client, local/IPC tools, tool catalog, prompt building, or identity loading in src/agent/
Use when modifying agent sandbox isolation -- Docker, Apple Container (macOS), or k8s providers in src/providers/sandbox/
AX project architecture and coding skills - use sub-skills for specific subsystems (agent, host, cli, providers, etc.)
Use this skill when the user asks for a capability the agent doesn't yet have — a new integration (Linear, GitHub, Notion, Slack, etc.), a new workflow, a new tool, or "can you check our team's X" where X is a service the agent has no existing connector for. Creates a proper AX skill under .ax/skills/<name>/ with the right frontmatter, credentials, and domain allowlist so the capability becomes permanent after admin approval. Use this skill whenever you'd otherwise be tempted to improvise with one-off scripts, `npm install`, or `execute_script` to reach an external service.
| name | ax-ipc |
| description | Use when modifying IPC protocol between host and agent — schemas, actions, length-prefix framing, or Zod validation in ipc-schemas.ts and ipc-server.ts |
AX host and agent processes communicate over Unix domain sockets using a length-prefixed JSON protocol. The host (src/host/ipc-server.ts) validates every inbound message against Zod strict schemas (src/ipc-schemas.ts) before dispatching to a handler. Long-running handlers send periodic heartbeat frames to keep the client alive.
In Kubernetes, HTTP-based IPC replaces Unix sockets: the agent uses HttpIPCClient (src/agent/http-ipc-client.ts) and the host receives requests via POST /internal/ipc route in server-k8s.ts, routing through the same handleIPC pipeline with identical schema validation.
UInt32 length prefix, followed by a UTF-8 JSON payload of exactly that length.{ "action": "<action_name>", ...fields }. The action field is validated first, then the full payload validated against the action-specific strict schema.{ _heartbeat: true, ts: number } frames every 15 seconds. Clients reset their timeout on each heartbeat.IPCEnvelopeSchema validates that action is in VALID_ACTIONS. Uses .passthrough() so extra fields survive to step 3.IPC_SCHEMAS[action]. Built with z.strictObject() via the ipcAction() helper. Rejects any field not explicitly declared.identity_write, user_write, or identity_propose.Shared validators: safeString(maxLen), scopeName, uuid, pathSegment.
Minimal IPC client interface defined in src/agent/runner.ts, implemented by both IPCClient (Unix socket) and HttpIPCClient (HTTP for k8s):
interface IIPCClient {
call(request: Record<string, unknown>, timeoutMs?: number): Promise<Record<string, unknown>>;
connect(): Promise<void>;
disconnect(): void;
setContext(ctx: { sessionId?: string; requestId?: string; userId?: string; sessionScope?: string; token?: string }): void;
}
This interface enables transport-agnostic IPC usage in runners and tools (e.g. compactHistory(), createLocalSandbox()) without coupling to a specific transport.
| Category | Action | Key Request Fields | Key Response Fields |
|---|---|---|---|
| LLM | llm_call | messages, model?, taskType?, tools?, temperature?, maxTokens? | chunks |
| Image | image_generate | prompt, model?, size?, quality? | (provider result) |
| Memory | memory_write | scope, content, tags?, tainted? | id |
| Memory | memory_query | scope, query?, limit?, tags? | results |
| Memory | memory_read | id | entry |
| Memory | memory_delete | id | ok |
| Memory | memory_list | scope, limit? | entries |
| Web | web_fetch | url, method?, headers?, timeoutMs? | (provider result) |
| Web | web_search | query, maxResults? | (provider result) |
| Browser | browser_launch | config? (headless, viewport) | (session info) |
| Browser | browser_navigate | session, url | ok |
| Browser | browser_snapshot | session | (snapshot data) |
| Browser | browser_click | session, ref | ok |
| Browser | browser_type | session, ref, text | ok |
| Browser | browser_screenshot | session | data (base64) |
| Browser | browser_close | session | ok |
| Skills | skill_search | query, limit? | (search results) |
| Credentials | credential_request | envName | ok, available |
| Workspace | workspace_release | staging_key | ok |
| Audit | audit_query | filter? (action, sessionId, since, until, limit) | entries |
| Delegation | agent_delegate | task, context?, runner?, model?, maxTokens?, timeoutSec? | response |
| Delegation | agent_collect | delegationId | response |
| Orchestration | agent_orch_status | agentId? | status |
| Orchestration | agent_orch_list | sessionId? | agents |
| Orchestration | agent_orch_tree | agentId? | tree |
| Orchestration | agent_orch_message | targetAgentId, content | ok |
| Orchestration | agent_orch_poll | (none) | messages |
| Orchestration | agent_orch_interrupt | agentId | ok |
| Orchestration | agent_orch_timeline | agentId?, since? | events |
| Identity | identity_read | file | content |
| Identity | identity_write | file (SOUL.md/IDENTITY.md), content, reason, origin | applied or queued |
| Identity | identity_propose | file, content, reason, origin | proposalId |
| User | user_write | userId, content, reason, origin | applied or queued |
| Governance | proposal_list | status? (pending/approved/rejected) | proposals |
| Governance | proposal_review | proposalId, decision, reason? | ok |
| Registry | agent_registry_list | status? (active/suspended/archived) | agents |
| Registry | agent_registry_get | agentId | agent |
| Scheduler | scheduler_add_cron | schedule, prompt, maxTokenBudget?, delivery? | jobId |
| Scheduler | scheduler_run_at | datetime, prompt, maxTokenBudget?, delivery? | jobId |
| Scheduler | scheduler_remove_cron | id | removed |
| Scheduler | scheduler_list_jobs | (none) | jobs |
| Skills | skill_propose | skill, content, reason? | proposalId, decision |
| Sandbox | sandbox_bash | command | (exec result) |
| Sandbox | sandbox_read_file | path | content |
| Sandbox | sandbox_write_file | path, content | ok |
| Sandbox | sandbox_edit_file | path, old_string, new_string | ok |
| Sandbox Audit | sandbox_approve | operation (bash/read/write/edit), command?, path?, content?, old_string?, new_string? | approved, reason? |
| Sandbox Audit | sandbox_result | operation (bash/read/write/edit), command?, path?, success?, output?, error?, exitCode? | ok |
| Plugin | plugin_list | (none) | plugins |
| Plugin | plugin_status | packageName | (status result) |
| Tool Dispatch | describe_tools | names (string[], empty = full directory) | tools (schemas) |
| Tool Dispatch | call_tool | tool (catalog name), args (incl. optional _select jq) | result or truncated envelope |
| Session | session_expiring | sessionId, remainingSec | ok |
All responses are wrapped: { "ok": true, ...fields } on success, { "ok": false, "error": "..." } on failure.
sandbox_approve and sandbox_result support the local sandbox execution model used when the agent runs inside a container (Docker, Apple Container, k8s). Instead of routing sandbox tool calls through IPC to the host for execution, the agent executes them locally via src/agent/local-sandbox.ts with a host audit gate:
sandbox_approve with the operation details -- host audits and returns {approved: true/false}.sandbox_result to report the outcome (best-effort, fire-and-forget).Messages support multiple block types:
text -- plain text content (up to 200 KB)tool_use -- agent requesting a tool invocationtool_result -- result from a tool callimage -- reference to stored image file via fileIdimage_data -- inline base64-encoded image data (transient, up to 20 MB encoded)src/ipc-schemas.ts, define via ipcAction('action_name', { ...fields }). Auto-registers in IPC_SCHEMAS.src/host/ipc-server.ts, add entry to handlers record via domain module (e.g., createLLMHandlers). Receives (req, ctx: IPCContext).src/agent/ipc-tools.ts (TypeBox params, for pi-session runner)src/agent/mcp-server.ts (Zod params, for claude-code runner)tests/sandbox-isolation.test.ts.{ _heartbeat: true, ts } and reset their timeoutclient.call(request, timeoutMs)image_generate, agent_delegate, llm_call (with thinking)Workspace operations are handled via IPC handlers (src/host/ipc-handlers/workspace.ts). In k8s, workspace file syncing uses symmetric HTTP endpoints on the host (pods have no GCS credentials) authenticated via Authorization: Bearer <ipcToken>.
Sandbox tools (sandbox_bash, sandbox_read_file, sandbox_write_file, sandbox_edit_file) route through IPC to host-side handlers in src/host/ipc-handlers/sandbox-tools.ts. All file paths are validated with safePath() for workspace containment. In container mode, these instead route to src/agent/local-sandbox.ts using the sandbox_approve/sandbox_result audit gate.
In Kubernetes deployments, IPC uses HTTP instead of Unix sockets. NATS is only for work dispatch:
src/agent/http-ipc-client.ts (HttpIPCClient) is a drop-in replacement for IPCClient. Selected automatically when AX_HOST_URL env var is set. POSTs JSON to ${hostUrl}/internal/ipc.POST /internal/ipc route in src/host/server-k8s.ts receives requests and routes through the existing handleIPC pipeline -- same schema validation, same handlers, same audit logging as Unix socket IPC.Authorization: Bearer <ipcToken>. The host validates the token to prevent unauthorized IPC requests.POST /internal/llm-proxy/* route in server-k8s.ts uses shared llm-proxy-core.ts for credential injection and Anthropic API forwarding.Removed: nats-ipc-client.ts, nats-bridge.ts (agent), nats-ipc-handler.ts, nats-llm-proxy.ts (host) have all been replaced by HTTP routes.
ipc-tools.ts (TypeBox) and mcp-server.ts (Zod) must stay in sync.identity_write, user_write, and identity_propose bypass the global taint check and handle taint internally.{ ok: true, ...result }. If a handler returns { ok: false }, the spread overwrites ok: true._sessionId in requests (stripped before schema validation)._heartbeat frames and only process actual responses.call() requests are in-flight on the same Unix socket connection. Each request is now matched to its response correctly.HttpIPCClient uses HTTP POST to /internal/ipc. NATS is only for work dispatch (queue groups). The old NATSIPCClient, nats-bridge.ts, nats-ipc-handler.ts, and nats-llm-proxy.ts have all been removed.