@scotthuang/agent-knock-knock 0.2.1 → 0.2.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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.2.2 - 2026-06-24
4
+
5
+ ### Added
6
+
7
+ - Added tmux-backed terminal-control takeover for native Codex sessions, including tmux pane metadata in active discovery, confirmed `terminal_control` attachment, direct follow-up sends to the existing pane, and a conservative `approve` command for the currently visible Codex approval prompt.
8
+
3
9
  ## 0.2.1 - 2026-06-22
4
10
 
5
11
  ### Changed
package/README.md CHANGED
@@ -12,6 +12,8 @@ Channels such as WeChat and many direct-message surfaces do not provide that sam
12
12
 
13
13
  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.
14
14
 
15
+ 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.
16
+
15
17
  ## What It Provides
16
18
 
17
19
  - ACPX-backed delegation to Codex, Claude Code, and Cursor
@@ -24,10 +26,6 @@ Agent Knock Knock fills that gap. It keeps local task state outside the chat cha
24
26
 
25
27
  See [ROADMAP.md](ROADMAP.md) for planned reliability work and future orchestration features.
26
28
 
27
- ## Project Status
28
-
29
- Agent Knock Knock is an early public project. The core local OpenClaw delegation flow is usable, and the package can be installed globally from npm. The OpenClaw plugin and skill are still installed locally by the `agent-knock-knock install-openclaw` helper rather than through an OpenClaw plugin registry.
30
-
31
29
  ## Architecture
32
30
 
33
31
  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.
@@ -109,25 +107,7 @@ Run this after pulling new code or editing TypeScript/plugin files. The OpenClaw
109
107
 
110
108
  ## OpenClaw Plugin
111
109
 
112
- The native OpenClaw plugin registers tools that let OpenClaw delegate implementation work to Codex, Claude Code, or Cursor, list open sessions, send follow-up messages, inspect status, request cooperative cancellation, and close sessions without exposing raw terminal output as tool results.
113
-
114
- Natural-language routing is designed around the short name `AKK`; lowercase `akk` should be treated the same way. When a user says `AKK` without naming an agent, OpenClaw should omit the agent parameter and let the plugin use `defaultAgent`. If `defaultAgent` is not configured, AKK falls back to Codex. Explicit requests such as `AKK Claude`, `AKK Cursor`, or `AKK Codex` override the default.
115
-
116
- Configure the default coding agent in the plugin config:
117
-
118
- ```json5
119
- {
120
- plugins: {
121
- entries: {
122
- "agent-knock-knock": {
123
- config: {
124
- defaultAgent: "codex" // "codex", "claude", or "cursor"
125
- }
126
- }
127
- }
128
- }
129
- }
130
- ```
110
+ 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.
131
111
 
132
112
  Useful chat-style prompts:
133
113
 
@@ -139,11 +119,10 @@ AKK Cursor: fix the flaky UI test
139
119
  akk list
140
120
  akk send <conversation-id>: continue with the smaller implementation
141
121
  akk cancel <conversation-id>
142
- akk recover <conversation-id>
143
122
  akk close <conversation-id>
144
123
  ```
145
124
 
146
- The plugin also registers the `/akk` slash command for channel surfaces that support OpenClaw native commands:
125
+ Surfaces that support OpenClaw native commands can use the same workflow through `/akk`:
147
126
 
148
127
  ```text
149
128
  /akk <task>
@@ -154,152 +133,62 @@ The plugin also registers the `/akk` slash command for channel surfaces that sup
154
133
  /akk status <conversation-id>
155
134
  /akk send <conversation-id> <message>
156
135
  /akk cancel <conversation-id>
157
- /akk recover <conversation-id>
158
136
  /akk close <conversation-id> [reason]
159
137
  ```
160
138
 
161
- If your OpenClaw config uses a restrictive tool allowlist, allow the tool:
139
+ Optional default-agent config:
162
140
 
163
141
  ```json5
164
142
  {
165
- tools: {
166
- allow: [
167
- "agent_knock_knock_delegate",
168
- "agent_knock_knock_list",
169
- "agent_knock_knock_status",
170
- "agent_knock_knock_send",
171
- "agent_knock_knock_cancel",
172
- "agent_knock_knock_recover",
173
- "agent_knock_knock_close"
174
- ]
143
+ plugins: {
144
+ entries: {
145
+ "agent-knock-knock": {
146
+ config: {
147
+ defaultAgent: "codex" // "codex", "claude", or "cursor"
148
+ }
149
+ }
150
+ }
175
151
  }
176
152
  }
177
153
  ```
178
154
 
179
- The delegate tool launches the selected coding agent in the background and returns `status: "async_pending"`, `conversation_id`, `state_path`, `event_log_path`, launch status, and executor metadata. OpenClaw should yield after receiving this tool result and wait for the callback turn; follow-up communication should happen through structured protocol callbacks or `agent_knock_knock_send`, not by reading event logs, processes, files, session internals, stdout, or stderr.
180
-
181
- The plugin also registers the Gateway method `agent-knock-knock.callback`. Coding-agent callback commands use this method to enqueue a durable next-turn injection for the OpenClaw session. Actionable callbacks such as `question`, `blocked`, `done`, `error`, or any message with `requires_response: true` are delivered into the OpenClaw session through Gateway `chat.send` with `deliver: true`, so OpenClaw receives only the structured protocol message and can route the final reply back through the original channel without polling the raw execution channel.
182
-
183
- Coding-agent `done` callbacks mark the AKK conversation `idle`, not closed. Idle conversations remain visible in the default list and can receive `send` follow-ups until they are manually closed or lazily closed by the idle timeout. The default idle timeout is 10080 minutes.
184
-
185
- New delegations create a fresh ACPX session by default, using a name like `akk-codex-20260620183511-88811e97`, `akk-claude-...`, or `akk-cursor-...`. This keeps concurrent AKK tasks isolated. Reuse happens through `AKK send <conversation-id>: <message>` against an existing AKK conversation, or by explicitly configuring/passing a fixed coding-agent session.
186
-
187
- Background launches also start a small AKK monitor process. The monitor exits when the conversation receives a callback or otherwise leaves the agent-waiting state. If the executor process disappears before a callback, or if no callback arrives before `agentTimeoutMinutes`, the conversation is marked `stalled` and AKK attempts to notify the original OpenClaw session through the callback Gateway route. The default agent timeout is 60 minutes.
188
-
189
- Some coding agents may not reliably resume a named ACPX session after their backing process disappears. By default, `AKK send <conversation-id>: <message>` automatically falls back to AKK replay recovery: it starts a fresh ACPX session, gives the agent a bounded summary of AKK's saved protocol history, and includes the pending message. The result includes `auto_recovered: true` when this happens.
190
-
191
- If a caller uses the explicit recovery policy, or if automatic recovery cannot complete, the AKK conversation can enter `needs_recovery`. The user can then choose:
192
-
193
- - `AKK recover <conversation-id>`: start a new coding-agent session with AKK's saved protocol history summary plus the pending message.
194
- - `AKK close <conversation-id>`: close the AKK task without recovery.
195
- - Start a new independent AKK delegation if the old task should not be recovered.
196
-
197
- Recover is AKK replay recovery, not guaranteed native coding-agent session resume. Codex, Claude Code, and Cursor all use the same default `send` auto-recovery behavior when the existing ACPX session is unavailable.
198
-
199
- Task status can include a safe executor trace with `--trace` or the OpenClaw status tool's `trace: true` parameter. Trace summaries show client lifecycle events, tool call names and statuses, permission-request markers, monitor events, and short sanitized output previews. Agent thinking content is never returned; it is counted and marked as redacted.
200
-
201
- ## CLI Examples
155
+ ## Native Codex Takeover
202
156
 
203
- The CLI is useful for local debugging, tests, and scripting outside OpenClaw.
157
+ Experimental: AKK can discover 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.
204
158
 
205
- Create a conversation and print the task payload:
159
+ Discovery prompts:
206
160
 
207
- ```bash
208
- node dist/src/cli.js new --request "Implement a small feature"
209
- ```
210
-
211
- Delegate a Codex task through ACPX:
212
-
213
- ```bash
214
- node dist/src/cli.js delegate \
215
- --agent codex \
216
- --request "Implement a small feature" \
217
- --background
218
- ```
219
-
220
- Delegate a Cursor task through ACPX:
221
-
222
- ```bash
223
- node dist/src/cli.js delegate \
224
- --agent cursor \
225
- --request "Implement a small feature" \
226
- --background
227
- ```
228
-
229
- List open coding-agent tasks:
230
-
231
- ```bash
232
- node dist/src/cli.js list
233
- ```
234
-
235
- Inspect a task with a safe executor trace:
236
-
237
- ```bash
238
- node dist/src/cli.js status \
239
- --conversation <conversation-id> \
240
- --trace
241
- ```
242
-
243
- Send a follow-up message to an existing task:
244
-
245
- ```bash
246
- node dist/src/cli.js send \
247
- --conversation <conversation-id> \
248
- --message "Use the smaller implementation."
249
- ```
250
-
251
- Request cooperative cancellation of the current in-flight prompt:
252
-
253
- ```bash
254
- node dist/src/cli.js cancel \
255
- --conversation <conversation-id>
161
+ ```text
162
+ AKK Codex sessions
163
+ AKK Codex active
164
+ AKK Codex capabilities
256
165
  ```
257
166
 
258
- Recover a task that is waiting for an explicit recovery decision:
167
+ Takeover prompts:
259
168
 
260
- ```bash
261
- node dist/src/cli.js recover \
262
- --conversation <conversation-id>
169
+ ```text
170
+ AKK safe resume Codex <native-session-id>
171
+ AKK takeover Codex <native-session-id>
172
+ AKK terminal takeover Codex <native-session-id>
173
+ AKK fork takeover Codex <native-session-id>
174
+ AKK approve <conversation-id>
263
175
  ```
264
176
 
265
- Inspect and take over native Codex sessions that were started outside AKK:
177
+ Strategies:
266
178
 
267
- Experimental: native Codex takeover depends on best-effort local Codex session metadata, process scanning, and Codex CLI resume behavior. It may be unstable across Codex versions or unusual terminal states, so review the returned plan before confirming any takeover.
179
+ - `safe resume`: attach a stopped/inactive Codex session to AKK.
180
+ - `takeover`: stop an active matching Codex CLI after explicit confirmation, then resume it under AKK.
181
+ - `terminal takeover`: attach an active Codex CLI running inside tmux after explicit confirmation. AKK sends follow-ups directly to the tmux pane and can approve the currently visible Codex approval prompt.
182
+ - `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.
268
183
 
269
- ```bash
270
- node dist/src/cli.js agent discover \
271
- --agent codex \
272
- --scope active
273
-
274
- node dist/src/cli.js agent takeover \
275
- --agent codex \
276
- --session-id <native-codex-session-id> \
277
- --strategy terminate_then_resume
278
- ```
279
-
280
- `terminate_then_resume` is intentionally two-step. The first command returns the exact pid, cwd, and session that would be stopped. After confirming that plan, execute the takeover:
184
+ 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:
281
185
 
282
186
  ```bash
283
- node dist/src/cli.js agent takeover \
284
- --agent codex \
285
- --session-id <native-codex-session-id> \
286
- --strategy terminate_then_resume \
287
- --create-conversation \
288
- --confirm-terminate \
289
- --expected-pid <confirmed-pid>
187
+ tmux new -s codex-work
188
+ codex
290
189
  ```
291
190
 
292
- AKK re-scans before terminating and only proceeds when the confirmed pid is still an exact match for the requested Codex session. After the process exits, AKK creates a managed conversation and future sends use native `codex exec resume`.
293
-
294
- Some Codex TUI processes do not expose the native session id in argv. In that case the default takeover remains blocked as ambiguous. For a deliberate local test or an operator-confirmed handoff, add `--allow-cwd-only` with `--expected-pid`; AKK will still re-scan and require that pid to be active in the target session cwd before terminating it.
295
-
296
- Close a task locally:
297
-
298
- ```bash
299
- node dist/src/cli.js close \
300
- --conversation <conversation-id> \
301
- --reason "No longer needed"
302
- ```
191
+ 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.
303
192
 
304
193
  ## Approval Behavior
305
194
 
@@ -381,21 +270,18 @@ Runtime logs are diagnostic-only and are safe to use for local troubleshooting.
381
270
 
382
271
  ## Defaults
383
272
 
384
- - OpenClaw session: `agent:main:main`
385
- - OpenClaw plugin default agent: configured with `defaultAgent`; fallback is `codex`
386
- - Delegated ACPX session: generated per new task, unless explicitly configured with `session`, `codexSession`, `claudeSession`, or `cursorSession`
387
- - CLI `new` fallback Claude session: `bidirectional`
388
- - CLI `new` fallback Codex session: `codex`
389
- - CLI `new` fallback Cursor session: `cursor`
390
- - Codex model, when needed for ChatGPT-account compatibility: pass `model`/`codexModel` using ACPX's bracket form such as `gpt-5.5[medium]`. AKK also normalizes the older slash shorthand `gpt-5.5/medium` to `gpt-5.5[medium]`.
391
- - Cursor model, when needed: pass `model`/`cursorModel`
392
- - Gateway URL: `ws://127.0.0.1:18789`
393
- - Agent callback timeout: `60` minutes
394
- - Soft response limit: `50`
395
- - Hard response limit: `100`
273
+ - Default agent: configured with `defaultAgent`; fallback is `codex`
274
+ - OpenClaw session: inherited from the current OpenClaw session; fallback is `agent:main:main`
275
+ - Delegated ACPX session: generated per new task, unless `session`, `codexSession`, `claudeSession`, or `cursorSession` is configured
276
+ - Agent callback timeout: `60` minutes before a waiting task is marked `stalled`
277
+ - Idle timeout: `10080` minutes before an idle task is lazily closed
278
+ - Soft response limit: `50` rounds
279
+ - Hard response limit: `100` rounds
396
280
  - Store directory: `~/.agent-knock-knock/conversations`
397
281
  - Runtime log directory: `~/.agent-knock-knock/logs`
398
282
  - Runtime log retention: `14` days
283
+ - Codex model: unset by default; configure `codexModel` only when your ACPX Codex setup requires one
284
+ - Cursor model: unset by default; configure `cursorModel` only when your ACPX Cursor setup requires one
399
285
 
400
286
  ## Release
401
287