@actagent/acpx 2026.6.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json ADDED
@@ -0,0 +1,50 @@
1
+ {
2
+ "name": "@actagent/acpx",
3
+ "version": "2026.6.2",
4
+ "description": "ACTAgent ACP runtime backend with plugin-owned session and transport management.",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "https://github.com/actagent/actagent"
8
+ },
9
+ "type": "module",
10
+ "dependencies": {
11
+ "@agentclientprotocol/claude-agent-acp": "0.39.0",
12
+ "@zed-industries/codex-acp": "0.15.0",
13
+ "acpx": "0.10.0",
14
+ "zod": "4.4.3"
15
+ },
16
+ "devDependencies": {
17
+ "@actagent/plugin-sdk": "workspace:*"
18
+ },
19
+ "actagent": {
20
+ "extensions": [
21
+ "./index.ts"
22
+ ],
23
+ "install": {
24
+ "npmSpec": "@actagent/acpx",
25
+ "defaultChoice": "npm",
26
+ "minHostVersion": ">=2026.4.25"
27
+ },
28
+ "compat": {
29
+ "pluginApi": ">=2026.6.2"
30
+ },
31
+ "build": {
32
+ "actagentVersion": "2026.6.2",
33
+ "staticAssets": [
34
+ {
35
+ "source": "./src/runtime-internals/mcp-proxy.mjs",
36
+ "output": "mcp-proxy.mjs"
37
+ },
38
+ {
39
+ "source": "./src/runtime-internals/mcp-command-line.mjs",
40
+ "output": "mcp-command-line.mjs"
41
+ }
42
+ ]
43
+ },
44
+ "release": {
45
+ "publishToACTAgentHub": true,
46
+ "publishToNpm": true,
47
+ "bundleRuntimeDependencies": false
48
+ }
49
+ }
50
+ }
@@ -0,0 +1,168 @@
1
+ // ACPX tests cover register plugin behavior.
2
+ import { afterEach, describe, expect, it, vi } from "vitest";
3
+
4
+ const { runtimeRegistry } = vi.hoisted(() => ({
5
+ runtimeRegistry: new Map<string, { runtime: unknown }>(),
6
+ }));
7
+
8
+ const { realRuntime, realServiceStartMock, realServiceStopMock, createRealServiceMock } =
9
+ vi.hoisted(() => {
10
+ const runtime = {
11
+ async ensureSession(input: { sessionKey: string }) {
12
+ return {
13
+ backend: "acpx",
14
+ runtimeSessionName: input.sessionKey,
15
+ sessionKey: input.sessionKey,
16
+ };
17
+ },
18
+ async *runTurn() {},
19
+ async cancel() {},
20
+ async close() {},
21
+ isHealthy: vi.fn(() => true),
22
+ probeAvailability: vi.fn(async () => {}),
23
+ };
24
+ const start = vi.fn(async () => {
25
+ runtimeRegistry.set("acpx", { runtime });
26
+ });
27
+ const stop = vi.fn(async () => {
28
+ runtimeRegistry.delete("acpx");
29
+ });
30
+ return {
31
+ realRuntime: runtime,
32
+ realServiceStartMock: start,
33
+ realServiceStopMock: stop,
34
+ createRealServiceMock: vi.fn(() => ({ id: "real-acpx-runtime", start, stop })),
35
+ };
36
+ });
37
+
38
+ vi.mock("actagent/plugin-sdk/acp-runtime-backend", () => ({
39
+ getAcpRuntimeBackend: (id: string) => runtimeRegistry.get(id),
40
+ registerAcpRuntimeBackend: (entry: { id: string; runtime: unknown }) => {
41
+ runtimeRegistry.set(entry.id, entry);
42
+ },
43
+ unregisterAcpRuntimeBackend: (id: string) => {
44
+ runtimeRegistry.delete(id);
45
+ },
46
+ }));
47
+
48
+ vi.mock("./src/service.js", () => ({
49
+ createAcpxRuntimeService: createRealServiceMock,
50
+ }));
51
+
52
+ import { createAcpxRuntimeService } from "./register.runtime.js";
53
+
54
+ const previousSkipRuntime = process.env.ACTAGENT_SKIP_ACPX_RUNTIME;
55
+
56
+ function restoreEnv(): void {
57
+ if (previousSkipRuntime === undefined) {
58
+ delete process.env.ACTAGENT_SKIP_ACPX_RUNTIME;
59
+ } else {
60
+ process.env.ACTAGENT_SKIP_ACPX_RUNTIME = previousSkipRuntime;
61
+ }
62
+ }
63
+
64
+ function createServiceContext() {
65
+ return {
66
+ workspaceDir: "/tmp/actagent-acpx-register-test",
67
+ stateDir: "/tmp/actagent-acpx-register-test/state",
68
+ config: {},
69
+ logger: {
70
+ info: vi.fn(),
71
+ warn: vi.fn(),
72
+ error: vi.fn(),
73
+ debug: vi.fn(),
74
+ },
75
+ };
76
+ }
77
+
78
+ describe("acpx register runtime service", () => {
79
+ afterEach(() => {
80
+ runtimeRegistry.clear();
81
+ realServiceStartMock.mockClear();
82
+ realServiceStopMock.mockClear();
83
+ createRealServiceMock.mockClear();
84
+ restoreEnv();
85
+ });
86
+
87
+ it("registers the acpx backend at startup and starts the real service on first use", async () => {
88
+ delete process.env.ACTAGENT_SKIP_ACPX_RUNTIME;
89
+ const ctx = createServiceContext();
90
+ const service = createAcpxRuntimeService({
91
+ pluginConfig: { timeoutSeconds: 10 },
92
+ });
93
+
94
+ await service.start(ctx as never);
95
+
96
+ const deferredRuntime = runtimeRegistry.get("acpx")?.runtime as {
97
+ ensureSession(input: { sessionKey: string; agent: string; mode: string }): Promise<unknown>;
98
+ startTurn(input: {
99
+ handle: { sessionKey: string; backend: string; runtimeSessionName: string };
100
+ text: string;
101
+ mode: string;
102
+ requestId: string;
103
+ }): {
104
+ events: AsyncIterable<unknown>;
105
+ result: Promise<unknown>;
106
+ };
107
+ };
108
+ expect(deferredRuntime).toBeTruthy();
109
+ expect(createRealServiceMock).not.toHaveBeenCalled();
110
+ expect(realServiceStartMock).not.toHaveBeenCalled();
111
+
112
+ await expect(
113
+ deferredRuntime.ensureSession({
114
+ sessionKey: "agent:codex:acp:test",
115
+ agent: "codex",
116
+ mode: "oneshot",
117
+ }),
118
+ ).resolves.toEqual({
119
+ backend: "acpx",
120
+ runtimeSessionName: "agent:codex:acp:test",
121
+ sessionKey: "agent:codex:acp:test",
122
+ });
123
+
124
+ expect(createRealServiceMock).toHaveBeenCalledWith({
125
+ pluginConfig: { timeoutSeconds: 10 },
126
+ });
127
+ expect(realServiceStartMock).toHaveBeenCalledWith(ctx);
128
+ expect(runtimeRegistry.get("acpx")?.runtime).toBe(realRuntime);
129
+ expect(ctx.logger.info).toHaveBeenCalledWith("embedded acpx runtime backend registered lazily");
130
+
131
+ const turn = deferredRuntime.startTurn({
132
+ handle: {
133
+ sessionKey: "agent:codex:acp:test",
134
+ backend: "acpx",
135
+ runtimeSessionName: "agent:codex:acp:test",
136
+ },
137
+ text: "hello",
138
+ mode: "prompt",
139
+ requestId: "turn-1",
140
+ });
141
+ await expect(turn.result).resolves.toEqual({
142
+ status: "failed",
143
+ error: {
144
+ code: "ACP_TURN_FAILED",
145
+ message: "ACP turn ended without a terminal done event.",
146
+ },
147
+ });
148
+
149
+ await service.stop?.(ctx as never);
150
+
151
+ expect(realServiceStopMock).toHaveBeenCalledWith(ctx);
152
+ expect(runtimeRegistry.get("acpx")).toBeUndefined();
153
+ });
154
+
155
+ it("keeps the explicit runtime skip env as the only outer startup skip", async () => {
156
+ process.env.ACTAGENT_SKIP_ACPX_RUNTIME = "1";
157
+ const ctx = createServiceContext();
158
+ const service = createAcpxRuntimeService();
159
+
160
+ await service.start(ctx as never);
161
+
162
+ expect(createRealServiceMock).not.toHaveBeenCalled();
163
+ expect(runtimeRegistry.get("acpx")).toBeUndefined();
164
+ expect(ctx.logger.info).toHaveBeenCalledWith(
165
+ "skipping embedded acpx runtime backend (ACTAGENT_SKIP_ACPX_RUNTIME=1)",
166
+ );
167
+ });
168
+ });
@@ -0,0 +1,108 @@
1
+ /**
2
+ * Lazy ACPX runtime service registration. The plugin exposes an ACP backend
3
+ * immediately, then imports the heavier service only when a session needs it.
4
+ */
5
+ import {
6
+ getAcpRuntimeBackend,
7
+ registerAcpRuntimeBackend,
8
+ unregisterAcpRuntimeBackend,
9
+ type AcpRuntime,
10
+ } from "actagent/plugin-sdk/acp-runtime-backend";
11
+ import type { ACTAgentPluginService, ACTAgentPluginServiceContext } from "actagent/plugin-sdk/core";
12
+ import { createLazyAcpRuntimeProxy } from "./src/runtime-proxy.js";
13
+
14
+ const ACPX_BACKEND_ID = "acpx";
15
+
16
+ type RealAcpxServiceModule = typeof import("./src/service.js");
17
+ type CreateAcpxRuntimeServiceParams = NonNullable<
18
+ Parameters<RealAcpxServiceModule["createAcpxRuntimeService"]>[0]
19
+ >;
20
+
21
+ type DeferredServiceState = {
22
+ ctx: ACTAgentPluginServiceContext | null;
23
+ params: CreateAcpxRuntimeServiceParams;
24
+ realRuntime: AcpRuntime | null;
25
+ realService: ACTAgentPluginService | null;
26
+ startPromise: Promise<AcpRuntime> | null;
27
+ };
28
+
29
+ let serviceModulePromise: Promise<RealAcpxServiceModule> | null = null;
30
+
31
+ function loadServiceModule(): Promise<RealAcpxServiceModule> {
32
+ serviceModulePromise ??= import("./src/service.js");
33
+ return serviceModulePromise;
34
+ }
35
+
36
+ async function startRealService(state: DeferredServiceState): Promise<AcpRuntime> {
37
+ if (state.realRuntime) {
38
+ return state.realRuntime;
39
+ }
40
+ if (!state.ctx) {
41
+ throw new Error("ACPX runtime service is not started");
42
+ }
43
+ state.startPromise ??= (async () => {
44
+ const { createAcpxRuntimeService: createAcpxRuntimeServiceLocal } = await loadServiceModule();
45
+ const service = createAcpxRuntimeServiceLocal(state.params);
46
+ state.realService = service;
47
+ await service.start(state.ctx as ACTAgentPluginServiceContext);
48
+ const backend = getAcpRuntimeBackend(ACPX_BACKEND_ID);
49
+ if (!backend?.runtime) {
50
+ throw new Error("ACPX runtime service did not register an ACP backend");
51
+ }
52
+ state.realRuntime = backend.runtime;
53
+ return state.realRuntime;
54
+ })();
55
+ try {
56
+ return await state.startPromise;
57
+ } catch (error) {
58
+ state.startPromise = null;
59
+ state.realService = null;
60
+ throw error;
61
+ }
62
+ }
63
+
64
+ function createDeferredRuntime(state: DeferredServiceState): AcpRuntime {
65
+ const resolveRuntime = () => startRealService(state);
66
+ return createLazyAcpRuntimeProxy(resolveRuntime);
67
+ }
68
+
69
+ /** Creates the plugin service that registers ACPX as an ACP runtime backend. */
70
+ export function createAcpxRuntimeService(
71
+ params: CreateAcpxRuntimeServiceParams = {},
72
+ ): ACTAgentPluginService {
73
+ const state: DeferredServiceState = {
74
+ ctx: null,
75
+ params,
76
+ realRuntime: null,
77
+ realService: null,
78
+ startPromise: null,
79
+ };
80
+
81
+ return {
82
+ id: "acpx-runtime",
83
+ async start(ctx) {
84
+ if (process.env.ACTAGENT_SKIP_ACPX_RUNTIME === "1") {
85
+ ctx.logger.info("skipping embedded acpx runtime backend (ACTAGENT_SKIP_ACPX_RUNTIME=1)");
86
+ return;
87
+ }
88
+
89
+ state.ctx = ctx;
90
+ registerAcpRuntimeBackend({
91
+ id: ACPX_BACKEND_ID,
92
+ runtime: createDeferredRuntime(state),
93
+ });
94
+ ctx.logger.info("embedded acpx runtime backend registered lazily");
95
+ },
96
+ async stop(ctx) {
97
+ if (state.realService) {
98
+ await state.realService.stop?.(ctx);
99
+ } else {
100
+ unregisterAcpRuntimeBackend(ACPX_BACKEND_ID);
101
+ }
102
+ state.ctx = null;
103
+ state.realRuntime = null;
104
+ state.realService = null;
105
+ state.startPromise = null;
106
+ },
107
+ };
108
+ }
package/runtime-api.ts ADDED
@@ -0,0 +1,53 @@
1
+ /**
2
+ * Public runtime API barrel for ACPX. Core and plugin consumers import these
3
+ * SDK-facing ACP runtime contracts instead of reaching into ACPX internals.
4
+ */
5
+ export type { AcpRuntimeErrorCode } from "actagent/plugin-sdk/acp-runtime-backend";
6
+ export {
7
+ AcpRuntimeError,
8
+ getAcpRuntimeBackend,
9
+ tryDispatchAcpReplyHook,
10
+ registerAcpRuntimeBackend,
11
+ unregisterAcpRuntimeBackend,
12
+ } from "actagent/plugin-sdk/acp-runtime-backend";
13
+ export type {
14
+ AcpRuntime,
15
+ AcpRuntimeCapabilities,
16
+ AcpRuntimeDoctorReport,
17
+ AcpRuntimeEnsureInput,
18
+ AcpRuntimeEvent,
19
+ AcpRuntimeHandle,
20
+ AcpRuntimeStatus,
21
+ AcpRuntimeTurn,
22
+ AcpRuntimeTurnAttachment,
23
+ AcpRuntimeTurnInput,
24
+ AcpRuntimeTurnResult,
25
+ AcpRuntimeTurnResultError,
26
+ AcpSessionUpdateTag,
27
+ } from "actagent/plugin-sdk/acp-runtime-backend";
28
+ export type {
29
+ ACTAgentPluginApi,
30
+ ACTAgentPluginConfigSchema,
31
+ ACTAgentPluginService,
32
+ ACTAgentPluginServiceContext,
33
+ PluginLogger,
34
+ } from "actagent/plugin-sdk/core";
35
+ export type {
36
+ PluginHookReplyDispatchContext,
37
+ PluginHookReplyDispatchEvent,
38
+ PluginHookReplyDispatchResult,
39
+ } from "actagent/plugin-sdk/core";
40
+ export type {
41
+ WindowsSpawnProgram,
42
+ WindowsSpawnProgramCandidate,
43
+ WindowsSpawnResolution,
44
+ } from "actagent/plugin-sdk/windows-spawn";
45
+ export {
46
+ applyWindowsSpawnProgramPolicy,
47
+ materializeWindowsSpawnProgram,
48
+ resolveWindowsSpawnProgramCandidate,
49
+ } from "actagent/plugin-sdk/windows-spawn";
50
+ export {
51
+ listKnownProviderAuthEnvVarNames,
52
+ omitEnvKeysCaseInsensitive,
53
+ } from "actagent/plugin-sdk/provider-env-vars";
package/setup-api.ts ADDED
@@ -0,0 +1,22 @@
1
+ /**
2
+ * ACPX setup plugin entry. It auto-enables setup when ACP config already points
3
+ * at the embedded ACPX runtime backend.
4
+ */
5
+ import { definePluginEntry } from "actagent/plugin-sdk/plugin-entry";
6
+ import { normalizeLowercaseStringOrEmpty } from "actagent/plugin-sdk/string-coerce-runtime";
7
+
8
+ export default definePluginEntry({
9
+ id: "acpx",
10
+ name: "ACPX Setup",
11
+ description: "Lightweight ACPX setup hooks",
12
+ register(api) {
13
+ api.registerAutoEnableProbe(({ config }) => {
14
+ const backendRaw = normalizeLowercaseStringOrEmpty(config.acp?.backend);
15
+ const configured =
16
+ config.acp?.enabled === true ||
17
+ config.acp?.dispatch?.enabled === true ||
18
+ backendRaw === "acpx";
19
+ return configured && (!backendRaw || backendRaw === "acpx") ? "ACP runtime configured" : null;
20
+ });
21
+ },
22
+ });
@@ -0,0 +1,245 @@
1
+ ---
2
+ name: acp-router
3
+ description: Route plain-language requests for Claude Code, Cursor, Copilot, ACTAgent ACP, OpenCode, Gemini CLI, Qwen, Kiro, Kimi, iFlow, Factory Droid, Kilocode, or explicit ACP harness work into either ACTAgent ACP runtime sessions or direct acpx-driven sessions ("telephone game" flow). For coding-agent thread requests, read this skill first, then use only `sessions_spawn` for thread creation. Codex chat binding defaults to the native Codex app-server plugin unless ACP is explicit or background spawn needs ACP.
4
+ user-invocable: false
5
+ ---
6
+
7
+ # ACP Harness Router
8
+
9
+ When user intent is "run this in Claude Code/Cursor/Copilot/ACTAgent/OpenCode/Gemini/Qwen/Kiro/Kimi/iFlow/Droid/Kilocode (ACP harness)", do not use subagent runtime or PTY scraping. Route through ACP-aware flows.
10
+
11
+ Codex is special: plain chat/conversation binding and control should use the native Codex app-server plugin (`/codex bind`, `/codex threads`, `/codex resume`) instead of the default ACP path. Use ACP for Codex only when the user explicitly names ACP/`/acp`/acpx, or when spawning background child sessions through `sessions_spawn` where a native Codex runtime spawn is not available yet.
12
+
13
+ ## Intent detection
14
+
15
+ Trigger this skill when the user asks ACTAgent to:
16
+
17
+ - run something in Claude Code / Cursor / Copilot / ACTAgent / OpenCode / Gemini / Qwen / Kiro / Kimi / iFlow / Droid / Kilocode
18
+ - run Codex explicitly through ACP, `/acp`, or acpx
19
+ - continue existing harness work
20
+ - relay instructions to an external coding harness
21
+ - keep an external harness conversation in a thread-like conversation
22
+
23
+ Mandatory preflight for coding-agent thread requests:
24
+
25
+ - Before creating any thread for ACP harness work, read this skill first in the same turn.
26
+ - After reading, follow `ACTAgent ACP runtime path` below; do not use `message(action="thread-create")` for ACP harness thread spawn.
27
+
28
+ ## Mode selection
29
+
30
+ Choose one of these paths:
31
+
32
+ 1. ACTAgent ACP runtime path (default): use `sessions_spawn` / ACP runtime tools.
33
+ 2. Direct `acpx` path (telephone game): use `acpx` CLI through `exec` to drive the harness session directly.
34
+
35
+ Use direct `acpx` when one of these is true:
36
+
37
+ - user explicitly asks for direct `acpx` driving
38
+ - ACP runtime/plugin path is unavailable or unhealthy
39
+ - the task is "just relay prompts to harness" and no ACTAgent ACP lifecycle features are needed
40
+
41
+ Do not use:
42
+
43
+ - `subagents` runtime for harness control
44
+ - `/acp` command delegation as a requirement for the user
45
+ - PTY scraping of supported ACP harness CLIs when `acpx` is available
46
+
47
+ ## AgentId mapping
48
+
49
+ Use these defaults when user names a harness directly:
50
+
51
+ - "actagent" -> `agentId: "actagent"`
52
+ - "claude" or "claude code" -> `agentId: "claude"`
53
+ - "codex" -> `agentId: "codex"` only for explicit ACP/acpx requests or background ACP runtime spawn
54
+ - "copilot" or "github copilot" -> `agentId: "copilot"`
55
+ - "cursor" or "cursor cli" -> `agentId: "cursor"`
56
+ - "droid" or "factory droid" -> `agentId: "droid"`
57
+ - "opencode" -> `agentId: "opencode"`
58
+ - "gemini" or "gemini cli" -> `agentId: "gemini"`
59
+ - "iflow" -> `agentId: "iflow"`
60
+ - "kilocode" -> `agentId: "kilocode"`
61
+ - "kimi" or "kimi cli" -> `agentId: "kimi"`
62
+ - "kiro" or "kiro cli" -> `agentId: "kiro"`
63
+ - "qwen" or "qwen code" -> `agentId: "qwen"`
64
+
65
+ These defaults match current acpx built-in aliases.
66
+
67
+ If policy rejects the chosen id, report the policy error clearly and ask for the allowed ACP agent id.
68
+
69
+ ## ACTAgent ACP runtime path
70
+
71
+ Required behavior:
72
+
73
+ 1. For ACP harness thread spawn requests, read this skill first in the same turn before calling tools.
74
+ 2. Use `sessions_spawn` with:
75
+ - `runtime: "acp"`
76
+ - `thread: true`
77
+ - `mode: "session"` (unless user explicitly wants one-shot)
78
+ 3. For ACP harness thread creation, do not use `message` with `action=thread-create`; `sessions_spawn` is the only thread-create path.
79
+ 4. Put requested work in `task` so the ACP session gets it immediately.
80
+ 5. Set `agentId` explicitly unless ACP default agent is known.
81
+ 6. Do not ask user to run slash commands or CLI when this path works directly.
82
+
83
+ Example:
84
+
85
+ User: "spawn a test codex ACP session in thread and tell it to say hi"
86
+
87
+ Call:
88
+
89
+ ```json
90
+ {
91
+ "task": "Say hi.",
92
+ "runtime": "acp",
93
+ "agentId": "codex",
94
+ "thread": true,
95
+ "mode": "session"
96
+ }
97
+ ```
98
+
99
+ ## Thread spawn recovery policy
100
+
101
+ When the user asks to start a coding harness in a thread, treat that as an ACP runtime request and try to satisfy it end-to-end.
102
+
103
+ Required behavior when ACP backend is unavailable:
104
+
105
+ 1. Do not immediately ask the user to pick an alternate path.
106
+ 2. First attempt automatic local repair:
107
+ - ensure plugin-local pinned acpx is installed in the ACPX plugin package
108
+ - verify `${ACPX_CMD} --version`
109
+ 3. After reinstall/repair, restart the gateway and explicitly offer to run that restart for the user.
110
+ 4. Retry ACP thread spawn once after repair.
111
+ 5. Only if repair+retry fails, report the concrete error and then offer fallback options.
112
+
113
+ When offering fallback, keep ACP first:
114
+
115
+ - Option 1: retry ACP spawn after showing exact failing step
116
+ - Option 2: direct acpx telephone-game flow
117
+
118
+ Do not default to subagent runtime for these requests.
119
+
120
+ ## ACPX install and version policy (direct acpx path)
121
+
122
+ For this repo, direct `acpx` calls must follow the same pinned policy as the `@actagent/acpx` extension package.
123
+
124
+ 1. Prefer plugin-local binary, not global PATH:
125
+ - `${ACPX_PLUGIN_ROOT}/node_modules/.bin/acpx`
126
+ 2. Resolve pinned version from extension dependency:
127
+ - `node -e "console.log(require(process.env.ACPX_PLUGIN_ROOT + '/package.json').dependencies.acpx)"`
128
+ 3. If binary is missing or version mismatched, install plugin-local pinned version:
129
+ - `cd "$ACPX_PLUGIN_ROOT" && npm install --omit=dev --no-save acpx@<pinnedVersion>`
130
+ 4. Verify before use:
131
+ - `${ACPX_PLUGIN_ROOT}/node_modules/.bin/acpx --version`
132
+ 5. If install/repair changed ACPX artifacts, restart the gateway and offer to run the restart.
133
+ 6. Do not run `npm install -g acpx` unless the user explicitly asks for global install.
134
+
135
+ Set and reuse:
136
+
137
+ ```bash
138
+ ACPX_PLUGIN_ROOT="<bundled-acpx-plugin-root>"
139
+ ACPX_CMD="$ACPX_PLUGIN_ROOT/node_modules/.bin/acpx"
140
+ ```
141
+
142
+ ## Direct acpx path ("telephone game")
143
+
144
+ Use this path to drive harness sessions without `/acp` or subagent runtime.
145
+
146
+ ### Rules
147
+
148
+ 1. Use `exec` commands that call `${ACPX_CMD}`.
149
+ 2. Reuse a stable session name per conversation so follow-up prompts stay in the same harness context.
150
+ 3. Prefer `--format quiet` for clean assistant text to relay back to user.
151
+ 4. Use `exec` (one-shot) only when the user wants one-shot behavior.
152
+ 5. Keep working directory explicit (`--cwd`) when task scope depends on repo context.
153
+
154
+ ### Session naming
155
+
156
+ Use a deterministic name, for example:
157
+
158
+ - `oc-<harness>-<conversationId>`
159
+
160
+ Where `conversationId` is thread id when available, otherwise channel/conversation id.
161
+
162
+ ### Command templates
163
+
164
+ Persistent session (create if missing, then prompt):
165
+
166
+ ```bash
167
+ ${ACPX_CMD} codex sessions show oc-codex-<conversationId> \
168
+ || ${ACPX_CMD} codex sessions new --name oc-codex-<conversationId>
169
+
170
+ ${ACPX_CMD} codex -s oc-codex-<conversationId> --cwd <workspacePath> --format quiet "<prompt>"
171
+ ```
172
+
173
+ One-shot:
174
+
175
+ ```bash
176
+ ${ACPX_CMD} codex exec --cwd <workspacePath> --format quiet "<prompt>"
177
+ ```
178
+
179
+ Cancel in-flight turn:
180
+
181
+ ```bash
182
+ ${ACPX_CMD} codex cancel -s oc-codex-<conversationId>
183
+ ```
184
+
185
+ Close session:
186
+
187
+ ```bash
188
+ ${ACPX_CMD} codex sessions close oc-codex-<conversationId>
189
+ ```
190
+
191
+ ### Harness aliases in acpx
192
+
193
+ - `claude`
194
+ - `codex`
195
+ - `copilot`
196
+ - `cursor`
197
+ - `droid`
198
+ - `gemini`
199
+ - `iflow`
200
+ - `kilocode`
201
+ - `kimi`
202
+ - `kiro`
203
+ - `actagent`
204
+ - `opencode`
205
+ - `qwen`
206
+
207
+ ### Built-in adapter commands in acpx
208
+
209
+ Defaults are:
210
+
211
+ - `actagent -> actagent acp`
212
+ - `claude -> bundled @agentclientprotocol/claude-agent-acp@0.32.0`
213
+ - `codex -> bundled @zed-industries/codex-acp@0.13.0 through ACTAgent's isolated CODEX_HOME wrapper`
214
+ - `copilot -> copilot --acp --stdio`
215
+ - `cursor -> cursor-agent acp`
216
+ - `droid -> droid exec --output-format acp`
217
+ - `gemini -> gemini --acp`
218
+ - `iflow -> iflow --experimental-acp`
219
+ - `kilocode -> npx -y @kilocode/cli acp`
220
+ - `kimi -> kimi acp`
221
+ - `kiro -> kiro-cli acp`
222
+ - `opencode -> npx -y opencode-ai acp`
223
+ - `qwen -> qwen --acp`
224
+
225
+ If `~/.acpx/config.json` overrides `agents`, those overrides replace defaults.
226
+ If your local Cursor install still exposes ACP as `agent acp`, set that as the `cursor` agent override explicitly.
227
+
228
+ ### Failure handling
229
+
230
+ - `acpx: command not found`:
231
+ - for thread-spawn ACP requests, install plugin-local pinned acpx in the ACPX plugin package immediately
232
+ - restart gateway after install and offer to run the restart automatically
233
+ - then retry once
234
+ - do not ask for install permission first unless policy explicitly requires it
235
+ - do not install global `acpx` unless explicitly requested
236
+ - adapter command missing (for example `claude-agent-acp` not found):
237
+ - for thread-spawn ACP requests, first restore built-in defaults by removing broken `~/.acpx/config.json` agent overrides
238
+ - then retry once before offering fallback
239
+ - if user wants binary-based overrides, install exactly the configured adapter binary
240
+ - `NO_SESSION`: run `${ACPX_CMD} <agent> sessions new --name <sessionName>` then retry prompt.
241
+ - queue busy: either wait for completion (default) or use `--no-wait` when async behavior is explicitly desired.
242
+
243
+ ### Output relay
244
+
245
+ When relaying to user, return the final assistant text output from `acpx` command result. Avoid relaying raw local tool noise unless user asked for verbose logs.