@scotthuang/agent-knock-knock 0.2.44 → 0.2.46

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.
Files changed (34) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/README.md +135 -244
  3. package/dist/src/cli.js +638 -729
  4. package/dist/src/cli.js.map +1 -1
  5. package/dist/src/codex-session-provider.d.ts +6 -32
  6. package/dist/src/codex-session-provider.js +2 -1
  7. package/dist/src/codex-session-provider.js.map +1 -1
  8. package/dist/src/codex-store-adapter.d.ts +3 -9
  9. package/dist/src/codex-store-adapter.js +5 -55
  10. package/dist/src/codex-store-adapter.js.map +1 -1
  11. package/dist/src/codex-terminal-agent-adapter.d.ts +34 -0
  12. package/dist/src/codex-terminal-agent-adapter.js +386 -0
  13. package/dist/src/codex-terminal-agent-adapter.js.map +1 -0
  14. package/dist/src/openclaw-plugin.js +54 -5
  15. package/dist/src/openclaw-plugin.js.map +1 -1
  16. package/dist/src/protocol.d.ts +1 -1
  17. package/dist/src/terminal-agent-adapter.d.ts +124 -0
  18. package/dist/src/terminal-agent-adapter.js +109 -0
  19. package/dist/src/terminal-agent-adapter.js.map +1 -0
  20. package/dist/src/terminal-agent-bridge.d.ts +97 -0
  21. package/dist/src/terminal-agent-bridge.js +362 -0
  22. package/dist/src/terminal-agent-bridge.js.map +1 -0
  23. package/dist/src/terminal-agent-registry.d.ts +7 -0
  24. package/dist/src/terminal-agent-registry.js +22 -0
  25. package/dist/src/terminal-agent-registry.js.map +1 -0
  26. package/dist/src/terminal-control-provider.d.ts +8 -6
  27. package/dist/src/terminal-control-provider.js +5 -5
  28. package/dist/src/terminal-control-provider.js.map +1 -1
  29. package/dist/src/terminal-process-source.d.ts +25 -0
  30. package/dist/src/terminal-process-source.js +77 -0
  31. package/dist/src/terminal-process-source.js.map +1 -0
  32. package/openclaw.plugin.json +4 -0
  33. package/package.json +1 -1
  34. package/templates/openclaw-skills/agent-knock-knock/SKILL.md +4 -4
package/CHANGELOG.md CHANGED
@@ -1,5 +1,26 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.2.46 - 2026-07-22
4
+
5
+ ### Added
6
+
7
+ - Add a registry-driven terminal-agent adapter layer, neutral process discovery, agent-aware terminal IDs, and a documented extension path while keeping legacy Codex IDs compatible.
8
+
9
+ ### Security
10
+
11
+ - Fail closed on missing capabilities and revalidate the full ordered approval-key action against a freshly captured prompt before sending terminal input.
12
+
13
+ ## 0.2.45 - 2026-07-20
14
+
15
+ ### Added
16
+
17
+ - Persist terminal callback delivery state and add bounded automatic retries plus `AKK retry-callback` / `agent_knock_knock_retry_callback` for idempotent manual recovery after delivery failures.
18
+
19
+ ### Fixed
20
+
21
+ - Require a request-hash-matched Codex rollout `task_complete` (or terminal-screen completion fallback) before closing terminal bridge tasks, preventing same-workspace assistant progress from another or unfinished turn from being reported as done.
22
+ - Keep terminal bridge tasks in `callback_pending` or `callback_failed` until their OpenClaw callback is actually delivered, and close them only after successful delivery.
23
+
3
24
  ## 0.2.44 - 2026-07-19
4
25
 
5
26
  ### Fixed
package/README.md CHANGED
@@ -2,151 +2,93 @@
2
2
 
3
3
  ![Agent Knock Knock cover: OpenClaw knocking on coding agents' door](docs/assets/agent-knock-knock-cover.jpg)
4
4
 
5
- Agent Knock Knock lets OpenClaw delegate work to local coding agents such as Codex, Claude Code, and Cursor, keep those delegations alive as reusable tasks, and route follow-up messages or results back through OpenClaw.
5
+ Agent Knock Knock (AKK) lets OpenClaw delegate work to local Codex, Claude Code, and Cursor agents, preserve each task for follow-ups, and route results back to chat—even on channels without threads. It can also discover and safely take over native Codex sessions.
6
6
 
7
- The name is literal: OpenClaw knocks on the door of another coding agent, hands it a task, waits for the callback, and can knock again later with follow-up instructions. AKK provides the persistent task layer that makes that workflow practical across chat channels.
8
-
9
- ## Why This Exists
10
-
11
- OpenClaw already has built-in session spawning, but persistent ACP sessions can depend on thread-bound channels such as Discord or Telegram. That model works well when the external channel can attach replies to a stable thread.
12
-
13
- Channels such as WeChat and many direct-message surfaces do not provide that same thread primitive. Without an external thread, OpenClaw needs another durable place to remember which coding agents are working, which task each agent owns, and where follow-up messages should go.
14
-
15
- Agent Knock Knock fills that gap. It keeps local task state outside the chat channel, uses ACPX / ACP to talk to coding agents, and gives OpenClaw tools to delegate, list, inspect, continue, cancel, and close work without relying on any external channel feature.
16
-
17
- BTW, it can also [take over a Codex task](#native-codex-takeover) you started in a terminal, so when you are away from your computer, OpenClaw can still pick it up and keep going.
18
-
19
- ## What It Provides
20
-
21
- - ACPX-backed delegation to Codex, Claude Code, and Cursor
22
- - Reusable task sessions for follow-up messages after the first result
23
- - Task listing, status inspection, follow-up send, cooperative cancellation, and local close
24
- - Structured callbacks back into OpenClaw through the plugin Gateway method
25
- - Conversation state stored in the user's home directory for recovery across OpenClaw turns
26
- - Runtime diagnostics logs with local timestamps, redaction, and retention cleanup
27
- - A short `AKK` routing convention for chat and `/akk` command surfaces
28
-
29
- See [ROADMAP.md](ROADMAP.md) for planned reliability work and future orchestration features.
30
-
31
- ## Architecture
32
-
33
- OpenClaw is the top-level orchestrator. Agent Knock Knock runs as the OpenClaw plugin bridge, uses ACPX / ACP to communicate with local coding agents, and keeps enough local task state for OpenClaw to manage many concurrent coding-agent sessions.
34
-
35
- ```mermaid
36
- flowchart LR
37
- user["User / chat surface"] --> openclaw["OpenClaw"]
38
- openclaw --> plugin["Agent Knock Knock<br/>OpenClaw plugin"]
39
- plugin --> state["Local task state<br/>~/.agent-knock-knock"]
40
- plugin --> acpx["ACPX / ACP"]
41
- plugin --> terminal["Terminal bridge<br/>tmux Codex"]
42
- acpx --> codex["Codex"]
43
- acpx --> claude["Claude Code"]
44
- acpx --> cursor["Cursor"]
45
- terminal --> codex
46
- codex --> plugin
47
- claude --> plugin
48
- cursor --> plugin
49
- plugin --> callback["OpenClaw callback"]
50
- callback --> openclaw
51
- ```
7
+ ## Install
52
8
 
53
- ## Prerequisites
9
+ Requirements:
54
10
 
55
11
  - Node.js 20+
56
12
  - OpenClaw installed and running
57
- - ACPX installed globally:
58
-
59
- ```bash
60
- npm install -g acpx
61
- acpx --version
62
- ```
63
-
64
- - At least one local coding agent:
65
- - Codex, if you want Codex delegation
66
- - Claude Code, if you want Claude delegation
67
- - Cursor, if you want Cursor delegation
68
-
69
- Agent Knock Knock does not manage Codex, Claude Code, or Cursor authentication. Make sure the agent you want to use is already installed and logged in before delegating tasks.
70
-
71
- ## Install
72
-
73
- Install Agent Knock Knock globally:
13
+ - [ACPX](https://github.com/openclaw/acpx) installed globally
14
+ - At least one authenticated coding agent: Codex, Claude Code, or Cursor
74
15
 
75
16
  ```bash
17
+ npm install -g acpx
76
18
  npm install -g @scotthuang/agent-knock-knock
77
19
  agent-knock-knock install-openclaw
78
20
  agent-knock-knock doctor
79
21
  ```
80
22
 
81
- `install-openclaw` installs or updates and enables the OpenClaw plugin from the npm package, installs the Agent Knock Knock skill template, and restarts the OpenClaw Gateway by default. The command is safe to rerun when the plugin is already installed. Use `--skill-only` to update only the skill template, or `--no-restart` if you want to restart the Gateway yourself.
23
+ `install-openclaw` installs or updates the plugin, enables it, installs the AKK skill template, and restarts the OpenClaw Gateway. It is safe to rerun. Use `--skill-only` to skip plugin installation; add `--no-restart` to skip the automatic Gateway restart.
82
24
 
83
- If you are developing from a local checkout, you can ask OpenClaw to install it for you:
25
+ If OpenClaw runs from a local checkout or another nonstandard location, pass its CLI explicitly:
84
26
 
85
- ```text
86
- Install this Agent Knock Knock project into my local OpenClaw:
87
- 1. Make sure Node.js 20+, OpenClaw, and at least one local coding agent such as Codex, Claude Code, or Cursor are installed.
88
- 2. Install ACPX globally if it is missing: npm install -g acpx.
89
- 3. Run npm install.
90
- 4. Run npm run build.
91
- 5. Link and enable the OpenClaw plugin from this repository.
92
- 6. Install the Agent Knock Knock skill template into ~/.openclaw/skills/agent-knock-knock/SKILL.md.
93
- 7. Restart the OpenClaw Gateway.
27
+ ```bash
28
+ agent-knock-knock install-openclaw --openclaw-bin /path/to/openclaw/openclaw.mjs
94
29
  ```
95
30
 
96
- Local development installation:
97
-
98
- Install the plugin into OpenClaw during local development:
31
+ For local AKK development:
99
32
 
100
33
  ```bash
101
34
  npm install
102
35
  npm run build
103
- openclaw plugins install --link .
104
- openclaw plugins enable agent-knock-knock
36
+ node dist/src/cli.js install-openclaw
105
37
  ```
106
38
 
107
- Install the OpenClaw skill template so OpenClaw learns when to route chat requests to AKK:
39
+ Rerun the build and installer after pulling or editing plugin sources. OpenClaw loads the compiled files from `dist/`.
108
40
 
109
- ```bash
110
- mkdir -p ~/.openclaw/skills/agent-knock-knock
111
- cp templates/openclaw-skills/agent-knock-knock/SKILL.md ~/.openclaw/skills/agent-knock-knock/SKILL.md
112
- ```
41
+ ## Quick Start
113
42
 
114
- Apply local project updates to OpenClaw:
43
+ Start a task from an OpenClaw chat, then use its conversation ID for follow-ups:
115
44
 
116
- ```bash
117
- npm install
118
- npm run build
119
- openclaw plugins install --link .
120
- openclaw plugins enable agent-knock-knock
121
- openclaw gateway restart
45
+ ```text
46
+ AKK Codex: inspect this repository and summarize it
47
+ AKK status <conversation-id>
48
+ AKK send <conversation-id>: run the tests and fix any failures
49
+ AKK list
122
50
  ```
123
51
 
124
- Run this after pulling new code or editing TypeScript/plugin files. The OpenClaw plugin loads compiled files from `dist/`, so source changes do not take effect until `npm run build` has run and the Gateway has reloaded the linked plugin. If the skill template changes, copy `templates/openclaw-skills/agent-knock-knock/SKILL.md` to `~/.openclaw/skills/agent-knock-knock/SKILL.md` again.
52
+ If no agent is named, AKK uses the configured `defaultAgent`, falling back to Codex.
53
+
54
+ ## Why AKK
55
+
56
+ OpenClaw can spawn agents directly, but persistent sessions may depend on channel threads. WeChat and many direct-message surfaces do not provide that primitive. AKK keeps task state outside the chat channel so OpenClaw can recover, inspect, and continue coding-agent work from any supported surface.
57
+
58
+ OpenClaw remains the orchestrator. AKK provides the plugin bridge, ACPX/ACP transport, durable task state, tmux terminal control, and structured callbacks.
59
+
60
+ ```mermaid
61
+ flowchart LR
62
+ user["User / chat surface"] --> openclaw["OpenClaw"]
63
+ openclaw --> plugin["AKK plugin"]
64
+ plugin --> state["Task state<br/>~/.agent-knock-knock"]
65
+ plugin --> acpx["ACPX/ACP"]
66
+ plugin --> terminal["tmux terminal bridge"]
67
+ acpx --> codex["Codex"]
68
+ acpx --> claude["Claude Code"]
69
+ acpx --> cursor["Cursor"]
70
+ terminal --> codex
71
+ codex --> plugin
72
+ claude --> plugin
73
+ cursor --> plugin
74
+ plugin --> callback["OpenClaw callback"]
75
+ callback --> openclaw
76
+ ```
125
77
 
126
- ## OpenClaw Plugin
78
+ See [ROADMAP.md](ROADMAP.md) for planned reliability and orchestration work.
127
79
 
128
- Use `AKK` or `akk` in OpenClaw chat to delegate coding work. If no agent is named, AKK uses the plugin `defaultAgent`; if that is unset, it falls back to Codex. Explicit agent names override the default.
80
+ ## Usage
129
81
 
130
- Useful chat-style prompts:
82
+ Use conversational `AKK` prompts on any chat surface. Explicit agent names override the configured default:
131
83
 
132
84
  ```text
133
- akk: fix the failing tests in this project
134
- AKK Codex: review the current branch and propose a small fix
135
85
  AKK Claude: review the latest commit
136
86
  AKK Cursor: fix the flaky UI test
137
- akk list
138
- akk status <conversation-id>
139
- akk describe <conversation-id>
140
- akk send <conversation-id>: continue with the smaller implementation
141
- akk cancel <conversation-id>
142
- akk renew <conversation-id> --minutes 180
143
- akk recover <conversation-id>
144
- akk close <conversation-id>
145
- AKK terminal takeover Codex <native-session-id>
146
- AKK approve <conversation-id>
87
+ AKK describe <conversation-id>
88
+ AKK recover <conversation-id>
147
89
  ```
148
90
 
149
- Surfaces that support OpenClaw native commands can use the same workflow through `/akk`:
91
+ Surfaces with native commands also support:
150
92
 
151
93
  ```text
152
94
  /akk <task>
@@ -155,31 +97,18 @@ Surfaces that support OpenClaw native commands can use the same workflow through
155
97
  /akk cursor <task>
156
98
  /akk list
157
99
  /akk status <conversation-id>
100
+ /akk describe <conversation-id>
158
101
  /akk send <conversation-id> <message>
159
102
  /akk cancel <conversation-id>
160
103
  /akk renew <conversation-id> [minutes]
104
+ /akk retry-callback <conversation-id>
105
+ /akk recover <conversation-id>
161
106
  /akk close <conversation-id> [reason]
162
107
  ```
163
108
 
164
- Optional default-agent config:
109
+ ## Configuration
165
110
 
166
- ```json5
167
- {
168
- plugins: {
169
- entries: {
170
- "agent-knock-knock": {
171
- config: {
172
- defaultAgent: "codex", // "codex", "claude", or "cursor"
173
- agentTimeoutMinutes: 60, // terminal inactivity timeout
174
- agentHardTimeoutMinutes: 720 // terminal task lifetime ceiling
175
- }
176
- }
177
- }
178
- }
179
- }
180
- ```
181
-
182
- Optional deterministic auto-approval policy for terminal-controlled Codex sessions:
111
+ Configure AKK under `plugins.entries.agent-knock-knock.config` in `~/.openclaw/openclaw.json`:
183
112
 
184
113
  ```json5
185
114
  {
@@ -187,21 +116,8 @@ Optional deterministic auto-approval policy for terminal-controlled Codex sessio
187
116
  entries: {
188
117
  "agent-knock-knock": {
189
118
  config: {
190
- autoApprove: {
191
- enabled: true,
192
- rules: [
193
- {
194
- id: "project-read-status",
195
- agents: ["codex"],
196
- workspaces: ["/Users/scott/project"],
197
- commands: [
198
- ["pwd"],
199
- ["git", "status"],
200
- ["git", "diff", "--stat"]
201
- ]
202
- }
203
- ]
204
- }
119
+ defaultAgent: "codex",
120
+ workspace: "/Users/scott/project"
205
121
  }
206
122
  }
207
123
  }
@@ -209,118 +125,115 @@ Optional deterministic auto-approval policy for terminal-controlled Codex sessio
209
125
  }
210
126
  ```
211
127
 
212
- Auto-approval is disabled by default. Rules use exact argument-vector matching and apply only to Codex `run command` prompts in the configured workspace. Shell composition, command substitution, glob expansion, environment assignments, unparseable commands, and paths outside the workspace always fall back to user approval. The OpenClaw plugin reads this trusted configuration inside the Gateway; it is not exposed as model-controlled tool input. AKK rechecks the visible prompt fingerprint immediately before sending the approval key and records the matched rule and policy fingerprint in the conversation event log.
128
+ | Option | Default | Purpose |
129
+ | --- | --- | --- |
130
+ | `defaultAgent` | `codex` | Agent used when a request does not name one. |
131
+ | `workspace` | OpenClaw process directory | Working directory for delegated tasks. |
132
+ | `storeDir` | `~/.agent-knock-knock/conversations` | Conversation state location. |
133
+ | `openclawBin` | Auto-detected | OpenClaw CLI used for callback delivery. |
134
+ | `codexAllProxy`, `cursorAllProxy`, `allProxy` | Unset | Per-agent or shared `ALL_PROXY` for ACPX launches. |
135
+ | `codexModel`, `cursorModel`, `model` | Unset | Per-agent or shared ACPX model override. |
136
+ | `defaultCodexSession`, `defaultClaudeSession`, `defaultCursorSession` | Generated per task | Named ACPX session to reuse. |
137
+ | `idleTimeoutMinutes` | `10080` | Time before an idle task is lazily closed. |
138
+ | `agentTimeoutMinutes` | `60` | Callback timeout; terminal bridges treat it as an inactivity timeout. |
139
+ | `agentHardTimeoutMinutes` | `720` | Maximum terminal bridge monitor lifetime. |
140
+ | `softLimit`, `hardLimit` | `50`, `100` | Response-requiring round limits. |
141
+
142
+ See [`openclaw.plugin.json`](openclaw.plugin.json) for the complete schema and compatibility aliases.
213
143
 
214
144
  ## Native Codex Takeover
215
145
 
216
- Experimental: AKK can list and take over Codex CLI sessions that were started outside AKK. This is useful when you started Codex in a terminal, left the machine, and want OpenClaw to continue managing that work from chat.
217
-
218
- List current AKK-managed and local agent work:
146
+ Experimental: AKK can discover Codex CLI sessions started outside AKK. `AKK list` separates managed `delegated` tasks, discovered `native` sessions, and tmux-backed `terminal_controlled` sessions.
219
147
 
220
- ```text
221
- AKK list
222
- ```
223
-
224
- `AKK list` returns separate groups for:
225
-
226
- - `delegated`: AKK-managed background tasks.
227
- - `native`: local native sessions that AKK can discover but cannot directly control.
228
- - `terminal_controlled`: local sessions running in a controllable terminal provider. The current provider is tmux. These entries include terminal metadata, command capabilities, and concise approval state when a visible approval prompt is detected.
229
- - `terminal_controlled` entries can be addressed directly by their `id` from `AKK list` for `AKK send <id>`, `AKK status <id>`, `AKK cancel <id>`, and `AKK approve <id>`. They do not need an AKK state file before terminal control.
230
- - Background sends to terminal-controlled Codex sessions use terminal bridge mode: AKK types only the user-facing task text into the tmux pane, monitors Codex rollout/terminal state, and delivers the OpenClaw callback itself when it observes completion.
231
- - Terminal bridge timeout is activity-aware. Visible Codex work, active background terminals, rollout updates, and meaningful terminal changes extend the inactivity deadline. A separate hard lifetime still stops permanently running monitors.
232
- - If a live terminal task is marked `stalled`, `AKK renew <conversation-id> --minutes <minutes>` restarts monitoring without sending text or keys to Codex. Renewal preserves the original callback destination and task hard deadline.
233
- - `AKK status <terminal-controlled-id>` is the unified way to inspect current terminal output. AKK captures the terminal pane internally and returns `terminal_screen`; there is no separate public screen-capture command.
234
- - `AKK describe <id>` summarizes what a listed session is about. AKK-managed sessions use saved conversation history; native and terminal-controlled Codex sessions use exact Codex rollout history when a session id is available, fall back to cwd-matched rollout history when needed, and otherwise report only visible terminal/process context with lower confidence.
235
-
236
- Takeover prompts:
237
-
238
- ```text
239
- AKK takeover Codex <native-session-id>
240
- AKK terminal takeover Codex <native-session-id>
241
- AKK fork takeover Codex <native-session-id>
242
- AKK approve <conversation-id>
243
- ```
148
+ | Strategy | Behavior |
149
+ | --- | --- |
150
+ | `AKK takeover Codex <session-id>` | After confirmation, stop and attach the matching CLI; the next send resumes it. |
151
+ | `AKK terminal takeover Codex <session-id>` | After confirmation, control the existing tmux session without stopping it. |
152
+ | `AKK fork takeover Codex <session-id>` | Keep the original running and create a new task from an OpenClaw-approved summary. |
244
153
 
245
- Strategies:
154
+ A terminal-controlled ID works directly with `send`, `status`, `describe`, `cancel`, and `approve`. Monitoring is activity-aware and has a separate hard lifetime. Use `renew` for a stalled monitor and `retry-callback` if callback delivery remains failed.
246
155
 
247
- - `takeover`: stop an active matching Codex CLI after explicit confirmation, then resume it under AKK.
248
- - `terminal takeover`: attach an active Codex CLI running inside a controllable terminal provider after explicit confirmation. AKK sends follow-ups directly to the terminal pane, can send Control-C for cancel, and can approve the currently visible Codex approval prompt.
249
- - `fork takeover`: keep the original Codex CLI running, ask OpenClaw to summarize bounded source context, then create a new AKK-managed fork from that summary.
156
+ New terminal-controlled IDs use `terminal:v2:tmux:<agent>:<target>:<pid>`, for example `terminal:v2:tmux:codex:codex-work:0.1:33389`. Legacy `terminal:tmux:<target>:<pid>` IDs remain valid and are treated as Codex. The production terminal adapter registry currently includes Codex; other agents require their own adapter.
250
157
 
251
- For long-running local Codex sessions that you may want OpenClaw to operate from WeChat, run Codex inside tmux. AKK does not require tmux, but tmux enables terminal-control takeover without stopping the original process:
158
+ Start sessions you may want to control remotely inside tmux:
252
159
 
253
160
  ```bash
254
161
  tmux new -s codex-work
255
162
  codex
256
163
  ```
257
164
 
258
- Avoid starting a second live client on the same active Codex session. It can mix session history in ways that neither live client sees until a later resume.
165
+ Avoid opening a second live client on the same Codex session; concurrent clients can produce inconsistent visible history.
259
166
 
260
- ## Approval Behavior
167
+ ## Approvals
261
168
 
262
- AKK sends ACPX-backed coding-agent prompts with `--approve-all` so ACPX permission requests can proceed without an additional OpenClaw turn.
169
+ AKK runs ACPX-backed agents with `--approve-all`. Claude Code surfaces permission requests through ACPX, but some Codex sandbox-sensitive operations fail directly. Keep Codex background work inside its workspace, or prefer Claude Code when a task requires ACPX-approved access elsewhere.
263
170
 
264
- Claude Code permission requests work with this model. For example, a Claude Code write outside the repository workspace triggers ACPX `session/request_permission`; with `--approve-all`, ACPX approves the request and the write can complete.
171
+ For tmux-backed Codex, AKK reports visible approval prompts through OpenClaw. Use `AKK approve <conversation-id>` to continue or `AKK cancel <conversation-id>` to deny and stop.
265
172
 
266
- Codex does not currently behave the same way for every sensitive operation under AKK. Some Codex sandbox-sensitive actions, such as writing outside the workspace in non-interactive execution, may fail directly with sandbox or permission errors instead of surfacing an ACPX permission request that AKK can approve. In those cases the action is currently unavailable through AKK's background Codex path; prefer Claude Code for tasks that require ACPX-approved filesystem access outside the workspace, or redesign the task to stay inside the configured workspace.
173
+ Trusted terminal commands can be auto-approved with a deterministic policy:
267
174
 
268
- For terminal bridge sends to tmux-backed Codex sessions, AKK watches the terminal pane. If Codex shows an approval prompt, AKK sends OpenClaw a `question` callback with a safe terminal excerpt and explicit routing instructions: approve with `AKK approve <conversation-id>` / `agent_knock_knock_approve`, or deny/stop with `AKK cancel <conversation-id>` / `agent_knock_knock_cancel`. After an approval is sent, AKK resumes terminal bridge monitoring and waits for the final Codex result callback.
269
-
270
- ## Development
271
-
272
- Build TypeScript sources:
273
-
274
- ```bash
275
- npm run build
175
+ ```json5
176
+ autoApprove: {
177
+ enabled: true,
178
+ rules: [{
179
+ id: "project-read-status",
180
+ agents: ["codex"],
181
+ workspaces: ["/Users/scott/project"],
182
+ commands: [
183
+ ["pwd"],
184
+ ["git", "status"],
185
+ ["git", "diff", "--stat"]
186
+ ]
187
+ }]
188
+ }
276
189
  ```
277
190
 
278
- Run type checking without writing `dist/`:
191
+ Place `autoApprove` inside the plugin `config` object. It is disabled by default and applies only to exact Codex `run command` argument vectors inside configured workspaces. Shell composition, substitutions, globs, environment assignments, unparseable commands, and out-of-workspace paths always require user approval. AKK rechecks the visible prompt immediately before approval and records the matched rule and policy fingerprint.
279
192
 
280
- ```bash
281
- npm run typecheck
282
- ```
193
+ ## Troubleshooting
283
194
 
284
- Run the full test suite. This builds first, then runs the compiled TypeScript tests from `dist/test` against the compiled `dist/src` output:
195
+ Start with `agent-knock-knock doctor`. It checks Node.js, OpenClaw, ACPX, at least one supported coding-agent command, and the packaged plugin files. The OpenClaw CLI must be on `PATH` or in a common user install directory for this check.
285
196
 
286
- ```bash
287
- npm test
288
- ```
197
+ | Symptom | Action |
198
+ | --- | --- |
199
+ | Installer or callbacks cannot find a local OpenClaw CLI | Set `openclawBin` and pass `--openclaw-bin` to `install-openclaw`. |
200
+ | Source changes do not appear | Build, reinstall from the checkout, and restart the Gateway. |
201
+ | Terminal bridge task is `stalled` | Run `AKK renew <conversation-id> --minutes <minutes>`. |
202
+ | ACPX task is `stalled` | Inspect `status --trace`; close and redelegate if the executor cannot continue. |
203
+ | Task is `callback_failed` | Run `AKK retry-callback <conversation-id>`. |
204
+ | Codex delegation rejects the deprecated adapter | Remove the old override or select a supported adapter as described below. |
205
+ | Terminal takeover is unavailable | Run Codex inside tmux and check `AKK list` for a `terminal_controlled` entry. |
289
206
 
290
- Run a two-Claude simulation:
207
+ For local diagnostics, use:
291
208
 
292
209
  ```bash
293
- node scripts/two-claude-weather-test.js --location 广州
210
+ agent-knock-knock status --conversation <conversation-id> --trace
211
+ agent-knock-knock list --terminal-debug
212
+ agent-knock-knock list --managed-only # skip native and terminal discovery
294
213
  ```
295
214
 
296
- Run named simulations:
215
+ ### Codex ACP Adapter
297
216
 
298
- ```bash
299
- npm run simulate:architecture
300
- npm run simulate:weather
301
- ```
302
-
303
- Print a readable transcript from an NDJSON log:
217
+ Codex delegation uses `npx -y @agentclientprotocol/codex-acp@^1.1.0` by default and rejects the deprecated `@zed-industries/codex-acp`. The first run may take longer while `npx` downloads the adapter. To select another compatible adapter, set this in the environment that runs OpenClaw/AKK:
304
218
 
305
219
  ```bash
306
- npm run transcript -- --conversation .agent-knock-knock/conversations/<conversation-id>
220
+ export AKK_CODEX_ACPX_AGENT_COMMAND='your-compatible-adapter-command'
307
221
  ```
308
222
 
309
- You can also read a specific event log file:
310
-
311
- ```bash
312
- npm run transcript -- --log .agent-knock-knock/conversations/<conversation-id>/events.ndjson
313
- ```
314
-
315
- Include raw model exchange events when debugging prompt/response payloads:
223
+ ## Development
316
224
 
317
225
  ```bash
318
- npm run transcript -- --conversation .agent-knock-knock/conversations/<conversation-id> --include-raw
226
+ npm run build # compile TypeScript into dist/
227
+ npm run typecheck # check types without writing output
228
+ npm test # build and run the full test suite
229
+ npm run simulate:architecture # run a named two-agent simulation
230
+ npm run simulate:weather
231
+ npm run transcript -- --conversation ~/.agent-knock-knock/conversations/<conversation-id>
319
232
  ```
320
233
 
321
- ## Storage
234
+ Pass `--include-raw` to the transcript command only when debugging model exchange events. See [CONTRIBUTING.md](CONTRIBUTING.md) for the development and pull request workflow.
322
235
 
323
- Conversation state is stored under the user's home directory so a new OpenClaw session can recover the shared context independently from OpenClaw's own app state:
236
+ ## Storage and Logs
324
237
 
325
238
  ```text
326
239
  ~/.agent-knock-knock/
@@ -333,47 +246,25 @@ Conversation state is stored under the user's home directory so a new OpenClaw s
333
246
  runtime-YYYY-MM-DD.ndjson
334
247
  ```
335
248
 
336
- Use `--store-dir <dir>` to override the conversation store location. `--log-dir <dir>` is still accepted as a compatibility alias. `<agent>-output.log` is diagnostic-only; OpenClaw should not read it as part of agent communication.
337
-
338
- Runtime logs are diagnostic-only and are safe to use for local troubleshooting. They keep local timestamps, preserve useful absolute paths, redact common secrets, and are cleaned up by retention policy. Use `AKK_LOG_DIR`, `AKK_LOG_LEVEL`, and `AKK_LOG_RETENTION_DAYS` to override the defaults.
339
-
340
- ## Defaults
249
+ Use `--store-dir <dir>` to override the conversation store; `--log-dir` remains a compatibility alias. Agent output and runtime logs are diagnostic-only and are not part of OpenClaw-agent communication.
341
250
 
342
- - Default agent: configured with `defaultAgent`; fallback is `codex`
343
- - OpenClaw session: inherited from the current OpenClaw session; fallback is `agent:main:main`
344
- - Delegated ACPX session: generated per new task, unless `session`, `codexSession`, `claudeSession`, or `cursorSession` is configured
345
- - Agent callback/terminal inactivity timeout: `60` minutes before an inactive waiting task is marked `stalled`
346
- - Terminal bridge hard lifetime: `720` minutes for a still-running monitor with no approval or completion result, even if other activity continues
347
- - Idle timeout: `10080` minutes before an idle task is lazily closed
348
- - Soft response limit: `50` rounds
349
- - Hard response limit: `100` rounds
350
- - Store directory: `~/.agent-knock-knock/conversations`
351
- - Runtime log directory: `~/.agent-knock-knock/logs`
352
- - Runtime log retention: `14` days
353
- - Codex model: unset by default; configure `codexModel` only when your ACPX Codex setup requires one
354
- - Cursor model: unset by default; configure `cursorModel` only when your ACPX Cursor setup requires one
251
+ Runtime logs use local timestamps, redact common secrets, and are cleaned by retention policy. Configure them with `AKK_LOG_DIR`, `AKK_LOG_LEVEL`, and `AKK_LOG_RETENTION_DAYS`. Defaults are `~/.agent-knock-knock/logs` and 14 days.
355
252
 
356
253
  ## Release
357
254
 
358
- `package.json` is the version source. Create releases with npm's version command so the version commit and git tag stay aligned:
255
+ `package.json` is the version source. Create a release with npm's version command, then push the commit and tag:
359
256
 
360
257
  ```bash
361
- npm version patch
258
+ npm version patch # or minor / major
362
259
  git push
363
260
  git push --tags
364
261
  ```
365
262
 
366
- Use `minor` for feature releases and `major` for breaking changes. Tags matching `v*` trigger the GitHub Actions release workflow, which runs the test suite, publishes `@scotthuang/agent-knock-knock` to npm with public access, and creates a GitHub Release from the tag notes.
367
-
368
- The release workflow requires an `NPM_TOKEN` repository secret with permission to publish the npm package. GitHub's built-in `GITHUB_TOKEN` is used for creating the GitHub Release.
369
-
370
- ## Contributing
371
-
372
- See [CONTRIBUTING.md](CONTRIBUTING.md) for local development, test, and pull request guidance.
263
+ Tags matching `v*` run the release workflow, which tests the package, publishes it to npm, and creates a GitHub Release. Publishing requires an `NPM_TOKEN` repository secret.
373
264
 
374
265
  ## Security
375
266
 
376
- Please do not open public issues for sensitive security reports. See [SECURITY.md](SECURITY.md).
267
+ Do not open public issues for sensitive security reports. See [SECURITY.md](SECURITY.md).
377
268
 
378
269
  ## License
379
270