@scotthuang/agent-knock-knock 0.12.14 → 0.12.16

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 (112) hide show
  1. package/CHANGELOG.md +47 -0
  2. package/README.md +15 -11
  3. package/dist/src/cli-core.js +100 -16
  4. package/dist/src/cli-core.js.map +1 -1
  5. package/dist/src/cli-runtime-context.d.ts +2 -0
  6. package/dist/src/cli-runtime-context.js.map +1 -1
  7. package/dist/src/command-json-callback-transport.d.ts +38 -0
  8. package/dist/src/command-json-callback-transport.js +298 -0
  9. package/dist/src/command-json-callback-transport.js.map +1 -0
  10. package/dist/src/deferred-foreground-authority-cli-adapter.js +8 -0
  11. package/dist/src/deferred-foreground-authority-cli-adapter.js.map +1 -1
  12. package/dist/src/host-adapter.d.ts +52 -0
  13. package/dist/src/host-adapter.js +123 -0
  14. package/dist/src/host-adapter.js.map +1 -0
  15. package/dist/src/host-bridge-mcp.d.ts +22 -0
  16. package/dist/src/host-bridge-mcp.js +145 -0
  17. package/dist/src/host-bridge-mcp.js.map +1 -0
  18. package/dist/src/host-bridge-tools.d.ts +61 -0
  19. package/dist/src/host-bridge-tools.js +130 -0
  20. package/dist/src/host-bridge-tools.js.map +1 -0
  21. package/dist/src/host-bridge.d.ts +28 -0
  22. package/dist/src/host-bridge.js +156 -0
  23. package/dist/src/host-bridge.js.map +1 -0
  24. package/dist/src/host-lifecycle-service.d.ts +39 -0
  25. package/dist/src/host-lifecycle-service.js +101 -0
  26. package/dist/src/host-lifecycle-service.js.map +1 -0
  27. package/dist/src/host-profile-callback-transport.d.ts +14 -0
  28. package/dist/src/host-profile-callback-transport.js +70 -0
  29. package/dist/src/host-profile-callback-transport.js.map +1 -0
  30. package/dist/src/host-profile-cli-adapter.d.ts +8 -0
  31. package/dist/src/host-profile-cli-adapter.js +169 -0
  32. package/dist/src/host-profile-cli-adapter.js.map +1 -0
  33. package/dist/src/host-profile-runtime.d.ts +55 -0
  34. package/dist/src/host-profile-runtime.js +152 -0
  35. package/dist/src/host-profile-runtime.js.map +1 -0
  36. package/dist/src/host-profile.d.ts +121 -0
  37. package/dist/src/host-profile.js +723 -0
  38. package/dist/src/host-profile.js.map +1 -0
  39. package/dist/src/install-doctor-command-adapter.js +1 -1
  40. package/dist/src/install-doctor-command-adapter.js.map +1 -1
  41. package/dist/src/native-thread-resume-snapshot.js +1 -1
  42. package/dist/src/native-thread-resume-snapshot.js.map +1 -1
  43. package/dist/src/openclaw-doctor.js +16 -2
  44. package/dist/src/openclaw-doctor.js.map +1 -1
  45. package/dist/src/openclaw-plugin-command-adapter.d.ts +13 -0
  46. package/dist/src/openclaw-plugin-command-adapter.js +191 -56
  47. package/dist/src/openclaw-plugin-command-adapter.js.map +1 -1
  48. package/dist/src/openclaw-plugin-helpers.d.ts +1 -0
  49. package/dist/src/openclaw-plugin-helpers.js +2 -2
  50. package/dist/src/openclaw-plugin-helpers.js.map +1 -1
  51. package/dist/src/openclaw-plugin-schemas.js +1 -1
  52. package/dist/src/openclaw-plugin-schemas.js.map +1 -1
  53. package/dist/src/openclaw-plugin-supervisor.d.ts +1 -1
  54. package/dist/src/openclaw-plugin-supervisor.js +44 -72
  55. package/dist/src/openclaw-plugin-supervisor.js.map +1 -1
  56. package/dist/src/store.d.ts +3 -1
  57. package/dist/src/store.js +2 -2
  58. package/dist/src/store.js.map +1 -1
  59. package/dist/src/terminal-action-projection.d.ts +30 -1
  60. package/dist/src/terminal-action-projection.js +60 -4
  61. package/dist/src/terminal-action-projection.js.map +1 -1
  62. package/dist/src/terminal-agent-bridge.js +16 -0
  63. package/dist/src/terminal-agent-bridge.js.map +1 -1
  64. package/dist/src/terminal-command-cli-adapter.d.ts +17 -2
  65. package/dist/src/terminal-command-cli-adapter.js +923 -100
  66. package/dist/src/terminal-command-cli-adapter.js.map +1 -1
  67. package/dist/src/terminal-delegate-cli-adapter.d.ts +4 -22
  68. package/dist/src/terminal-delegate-cli-adapter.js +239 -192
  69. package/dist/src/terminal-delegate-cli-adapter.js.map +1 -1
  70. package/dist/src/terminal-delegate-send-binding.d.ts +63 -0
  71. package/dist/src/terminal-delegate-send-binding.js +360 -0
  72. package/dist/src/terminal-delegate-send-binding.js.map +1 -0
  73. package/dist/src/terminal-dispatch-composition.d.ts +5 -0
  74. package/dist/src/terminal-dispatch-presenter.js +1 -1
  75. package/dist/src/terminal-dispatch-presenter.js.map +1 -1
  76. package/dist/src/terminal-dispatch-repository-cli-adapter.d.ts +4 -2
  77. package/dist/src/terminal-dispatch-repository-cli-adapter.js +10 -3
  78. package/dist/src/terminal-dispatch-repository-cli-adapter.js.map +1 -1
  79. package/dist/src/terminal-identity-authority-cli-adapter.js +4 -0
  80. package/dist/src/terminal-identity-authority-cli-adapter.js.map +1 -1
  81. package/dist/src/terminal-list-cli-adapter.d.ts +5 -0
  82. package/dist/src/terminal-list-cli-adapter.js +341 -146
  83. package/dist/src/terminal-list-cli-adapter.js.map +1 -1
  84. package/dist/src/terminal-list-renderer.js +8 -7
  85. package/dist/src/terminal-list-renderer.js.map +1 -1
  86. package/dist/src/terminal-process-source.d.ts +13 -0
  87. package/dist/src/terminal-process-source.js +37 -0
  88. package/dist/src/terminal-process-source.js.map +1 -1
  89. package/dist/src/terminal-runtime-cli-adapter.js +14 -2
  90. package/dist/src/terminal-runtime-cli-adapter.js.map +1 -1
  91. package/dist/src/terminal-user-send-intent.d.ts +65 -0
  92. package/dist/src/terminal-user-send-intent.js +317 -0
  93. package/dist/src/terminal-user-send-intent.js.map +1 -0
  94. package/dist/src/terminal-watch-callback-cli-adapter.d.ts +2 -1
  95. package/dist/src/terminal-watch-callback-cli-adapter.js +4 -3
  96. package/dist/src/terminal-watch-callback-cli-adapter.js.map +1 -1
  97. package/dist/src/terminal-watch-cli-adapter.d.ts +4 -0
  98. package/dist/src/terminal-watch-cli-adapter.js +33 -3
  99. package/dist/src/terminal-watch-cli-adapter.js.map +1 -1
  100. package/dist/src/terminal-watch-service.d.ts +5 -0
  101. package/dist/src/terminal-watch-service.js +6 -1
  102. package/dist/src/terminal-watch-service.js.map +1 -1
  103. package/dist/src/terminal-watch-store.d.ts +2 -0
  104. package/dist/src/terminal-watch-store.js +13 -0
  105. package/dist/src/terminal-watch-store.js.map +1 -1
  106. package/docs/host-bridge-profiles.md +325 -0
  107. package/docs/quickstart-herdr.md +1 -1
  108. package/docs/quickstart-tmux.md +2 -2
  109. package/examples/host-profiles/command-json-starter.json +62 -0
  110. package/package.json +30 -2
  111. package/schemas/host-profile-v1.schema.json +266 -0
  112. package/templates/openclaw-skills/agent-knock-knock/SKILL.md +8 -8
package/CHANGELOG.md CHANGED
@@ -1,5 +1,52 @@
1
1
  # Changelog
2
2
 
3
+ ## Unreleased
4
+
5
+ ## 0.12.16 - 2026-08-26
6
+
7
+ ### Added
8
+
9
+ - Add a Host-owned foreground MCP/stdio Bridge that exposes the existing 16 semantic AKK tools without introducing a second state or tool model.
10
+ - Add strict Host Profile v1 configuration with trusted environment session binding, a shell-free `command_json_v1` callback driver, compatibility/doctor commands, a published JSON Schema, and a starter user Profile.
11
+ - Add the public `./host-adapter` facade used by native controller integrations, with exact per-controller command/tool authority and one shared Host-owned lifecycle.
12
+ - Add a first-party DeepSeek Harness Web connector package that derives the controller route from the exact invoking Agent, registers `/akk` plus all 16 semantic tools, and returns callbacks through idle `followup` or running `inject` without a user-visible bind step.
13
+
14
+ ### Changed
15
+
16
+ - Reuse the shared Host lifecycle and existing durable callback route, outbox, retry, and settlement core for configuration-only Hosts while preserving the native OpenClaw adapter unchanged.
17
+ - Persist complete route-bound Terminal Watch callback authority and keep callbacks pinned to the initiating Host/Agent incarnation instead of redirecting them after replacement or restart.
18
+
19
+ ### Security
20
+
21
+ - Keep Profile selection, controller identity, executable, arguments, credentials, and acknowledgement rules outside model-facing tool inputs; exact route fingerprints and delivery/message acknowledgements fail closed on drift.
22
+ - Keep DeepSeek session routing outside slash/tool arguments, authenticate its private callback socket, and reject disposed or replaced Agent objects rather than trusting a reused session-id string.
23
+
24
+ ## 0.12.15 - 2026-08-25
25
+
26
+ ### Added
27
+
28
+ - Add the `terminal_user_explicit` physical Send authority domain, global message intent, and immutable omitted-target binding so an explicit user Send remains actionable independently of AKK management state.
29
+
30
+ ### Fixed
31
+
32
+ - Prevent stale, stalled, deferred, corrupt, or missing Store, Session, Turn, transfer, activity, and dispatch-ledger state from vetoing an explicit user Send. When a zero-wait managed attempt proves that no input was submitted, fall back once to exact physical delivery and leave subsequent observation to Terminal Watch.
33
+ - Detach an exact same-incarnation bound Session left behind by failed managed preparation after physical fallback when no live blocking Turn remains, so a later Terminal Watch can attach normally.
34
+ - Retire an exact same-incarnation ordinary dispatch ledger whose owner Turn is gone after physical fallback, so a refreshed List can advertise Watch again; unresolved native lifecycle ledgers remain preserved.
35
+ - Reject ordinary native slash-command text before selector discovery, avoiding terminal or host-process scans for an invalid Send or Respond.
36
+ - Make OpenClaw doctor skill verification compatible with multi-agent installations that require an explicit `main` owner.
37
+ - Scope durable omitted-target delegate bindings to the active runtime directory, preventing in-process hosts with scoped `AKK_RUNTIME_DIR` values from sharing message-ID state.
38
+ - Bind explicit physical Send authority to the exact operating-system process incarnation and reject stale supplied authority before managed preparation or terminal input.
39
+
40
+ ### Changed
41
+
42
+ - Advance the action contract to 19 and expose Send readiness from physical terminal evidence while retaining the existing Store format and writer protocol.
43
+
44
+ ### Security
45
+
46
+ - Continue to require exact live terminal and process identity, approval eligibility, an empty composer, and unambiguous input evidence before physical Send. Possible prior input, true concurrency, or same-message ambiguity remains fail-closed and never triggers duplicate delivery.
47
+ - Keep fallback delivery free of synthetic Turns or callbacks, and treat post-delivery bookkeeping or cleanup failures as warnings without automatically replaying user input.
48
+ - Preserve a Session still named by an unresolved native lifecycle ledger instead of fabricating a transition outcome; the physical Send remains delivered and cleanup reports the retained recovery boundary.
49
+
3
50
  ## 0.12.14 - 2026-08-24
4
51
 
5
52
  ### Added
package/README.md CHANGED
@@ -4,7 +4,7 @@
4
4
  [![Node.js](https://img.shields.io/badge/Node.js-%3E%3D22.19-339933)](https://nodejs.org/)
5
5
  [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://github.com/scotthuang/agent-knock-knock/blob/main/LICENSE)
6
6
 
7
- Most agent orchestrators bring Codex or Claude Code into their own interface. AKK does the reverse: it brings OpenClaw into the live tmux or Herdr terminal where you already work. Human and agent share the same native session, so either can take over at any time without leaving the other on a forked context.
7
+ Most agent orchestrators bring Codex or Claude Code into their own interface. AKK does the reverse: it brings a controller Host into the live tmux or Herdr terminal where you already work. OpenClaw has the bundled native integration; compatible third-party Hosts can use the foreground MCP/stdio Host Bridge and a declarative Profile without forking AKK. Human and agent share the same native session, so either can take over at any time without leaving the other on a forked context.
8
8
 
9
9
  **Stay in the terminal. Stay in control. No hooks. No agent-side plugins. No YOLO.**
10
10
 
@@ -42,7 +42,7 @@ After doctor reports `AKK doctor: ready`, send a separate message:
42
42
  /akk inspect this repository and summarize it
43
43
  ```
44
44
 
45
- The second command proves that AKK can find the one eligible idle pane, revalidate its process and pane identity, confirm that their working directories match, send the task, and return the result. Direct `/akk ...` commands need no OpenClaw tool-policy changes.
45
+ The second command proves that AKK can find the one send-ready pane, revalidate its process and pane identity, verify a non-blocked approval state and exact empty composer, send the task, and return the result. Parsed `activity_state` and broken AKK management state do not veto this user-explicit Send. Direct `/akk ...` commands need no OpenClaw tool-policy changes.
46
46
 
47
47
  ## See It in Action
48
48
 
@@ -56,6 +56,10 @@ The second command proves that AKK can find the one eligible idle pane, revalida
56
56
 
57
57
  **Orchestrate specialist agents.** OpenClaw can coordinate handoffs: Claude Code can plan, Codex can implement, and Claude Code can review. At any point, you can take over the live terminal, keep working yourself, then hand the same native session back to OpenClaw with its context intact.
58
58
 
59
+ **Connect another controller Host without an AKK fork.** A compatible Host can launch `agent-knock-knock host-bridge` as a foreground MCP/stdio child, bind its trusted current session through `environment_v1`, and inject callbacks through `command_json_v1`. The Bridge exposes the same 16 semantic tools and reuses the same Session, Turn, Watch, Store, callback, and terminal core as OpenClaw. See [Host Bridge and Host Profiles](docs/host-bridge-profiles.md) for the configuration-only prerequisites, starter Profile, validation commands, and thin-connector fallback.
60
+
61
+ **Use AKK natively from DeepSeek Harness.** DeepSeek Harness Web `0.1.1-rc.2` can install the first-party connector bundle with `dsh plugin --profile web add @scotthuang/agent-knock-knock-deepseek-harness@next`. After one restart, every conversation receives `/akk` and the same 16 semantic tools without `/akk-bind`, copied session IDs, an AKK fork, or a standalone supervisor. The connector derives callback authority from the exact command/tool Agent and returns completion to that same live conversation. See [the connector package](connectors/deepseek-harness/README.md) for its prerelease compatibility and recovery boundaries.
62
+
59
63
  ![Agent Knock Knock cover: OpenClaw knocking on coding agents' door](docs/assets/agent-knock-knock-cover.jpg)
60
64
 
61
65
  ## How It Works
@@ -89,15 +93,15 @@ terminal resource / process incarnation
89
93
  └─ Turn 3 (turn_id)
90
94
  ```
91
95
 
92
- The v18 model-facing action contract is semantic-ID only. `send(session_id, request)` is **session-scoped** (`session_exact`): it creates a new `turn_id` in that exact native coding-agent context and never silently follows a different thread now visible in the pane. `send(terminal_id, request)` is **terminal-scoped follow-current** (`terminal_follow_current`): it means “send this ordinary task to the current verified context in this pane,” including when AKK cannot yet name its foreground native thread. `session_id` and `terminal_id` are mutually exclusive; callers may omit both only when AKK must prove one unique eligible pane. Human-facing slash selectors remain a discovery convenience, but structured tools never carry selectors or opaque authority values. The trusted plugin/CLI derives fresh terminal, binding, candidate, prompt, and handoff fences internally, then revalidates them under the canonical terminal and Store locks before a side effect. AKK sends the task once and binds only the single rollout that durably accepts that exact request. The `turn_id` is not a destination for later ordinary sends; it is the exact identity used for status, approval, cancellation, renewal, callback retry, close, and callback correlation. If a Turn is `waiting_for_openclaw`, `respond(turn_id, answer)` supplies the answer inside that same Turn instead of creating another one.
96
+ The v19 model-facing action contract remains semantic-ID only. `send(session_id, request)` is **session-scoped** (`session_exact`): it creates a new `turn_id` in that exact native coding-agent context and never silently follows a different thread now visible in the pane. `send(terminal_id, request)` may be managed follow-current (`terminal_follow_current`) or the user-priority physical-terminal path (`terminal_user_explicit`), exactly as advertised by the current row. `session_id` and `terminal_id` are mutually exclusive; callers may omit both only when AKK must prove one unique send-ready pane. Human-facing slash selectors remain a discovery convenience, but structured tools never carry selectors or opaque authority values. The trusted plugin/CLI derives fresh terminal, binding, candidate, prompt, and handoff fences internally. Every mutation holds the terminal lock; managed operations additionally use Store locks, while unmanaged user-priority fallback deliberately does not depend on Store health. A managed send creates a Turn and binds only the single rollout that durably accepts that exact request. The `turn_id` is not a destination for later ordinary sends; it is the exact identity used for status, approval, cancellation, renewal, callback retry, close, and callback correlation. If a Turn is `waiting_for_openclaw`, `respond(turn_id, answer)` supplies the answer inside that same Turn instead of creating another one.
93
97
 
94
- v15 generalized the human-priority Codex path; v18 preserves that safety while removing opaque fences from model arguments. It covers a status-card-only Session with no rollout, a quiescent managed pane whose exact open-rollout inventory is complete but cannot identify the foreground candidate, and a supported manual `/clear` whose new logical thread is visible before its rollout materializes. The complete exact inventory domain binds the provider terminal, PID and process birth, workspace and canonical endpoint, and every open rollout's UUID, descriptor, device, inode, canonical path, and pre-submit byte offset. Native foreground resolution may be unavailable only when that independent domain is complete and exact; an incomplete, missing, stale, or changed domain fails closed. A `/clear` resume hint is advisory only. Under the terminal lock, AKK isolates the old Session, creates a separate zero-UUID provisional Session and Turn, sends only the real task, and promotes that target only after the post-submit monitor finds a unique exact request acceptance in the pinned rollout domain. The resulting native UUID may match or differ from the old Session; it is never silently merged back into the predecessor. A rollout-backed Codex row therefore advertises `terminal_follow_current` with `terminal_id`, not `session_exact`; a cached or direct `session_exact` attempt revalidates under the terminal lock, rejects before task text, and never downgrades itself to the follow-current path. Only released predecessor Turn history from a strictly earlier binding epoch is excluded from current-send authority; unresolved current-epoch state still blocks. The freshly listed semantic-ID action can work in a narrow pane without `/status`. Until promotion commits, strict `session_id` send, `respond`, managed `approve`, `cancel`, native lifecycle, callback delivery, and `native_inspect` remain unavailable. If terminal delivery or native acceptance is uncertain, AKK does not retry the input. Explicit Close is the user's management escape hatch: AKK closes the selected Turn first, sends no terminal input, leaves the coding agent and pane running, and then best-effort releases only linked AKK metadata. Missing, malformed, stale, or newer cleanup records are preserved and reported as warnings instead of vetoing Close. Refresh the list afterward; if the coding agent is still working, Watch can observe it again.
98
+ v15 generalized the human-priority Codex path; v18 preserves that safety while removing opaque fences from model arguments. It covers a status-card-only Session with no rollout, a quiescent managed pane whose exact open-rollout inventory is complete but cannot identify the foreground candidate, and a supported manual `/clear` whose new logical thread is visible before its rollout materializes. The complete exact inventory domain binds the provider terminal, PID and process birth, workspace and canonical endpoint, and every open rollout's UUID, descriptor, device, inode, canonical path, and pre-submit byte offset. Native foreground resolution may be unavailable only when that independent domain is complete and exact; an incomplete, missing, stale, or changed domain fails closed. A `/clear` resume hint is advisory only. Under the terminal lock, AKK isolates the old Session, creates a separate zero-UUID provisional Session and Turn, sends only the real task, and promotes that target only after the post-submit monitor finds a unique exact request acceptance in the pinned rollout domain. The resulting native UUID may match or differ from the old Session; it is never silently merged back into the predecessor. A rollout-backed Codex row therefore advertises `terminal_follow_current` with `terminal_id`, not `session_exact`; a cached or direct `session_exact` attempt revalidates under the terminal lock, rejects before task text, and never downgrades itself to the follow-current path. Only released predecessor Turn history from a strictly earlier binding epoch is excluded from current-send authority; unresolved current-epoch state still blocks the managed path. The freshly listed semantic-ID action can work in a narrow pane without `/status`. Until promotion commits, strict `session_id` send, `respond`, managed `approve`, `cancel`, native lifecycle, callback delivery, and `native_inspect` remain unavailable. If terminal delivery or native acceptance is uncertain, AKK does not retry the input. Explicit Close is the user's management escape hatch: AKK closes the selected Turn first, sends no terminal input, leaves the coding agent and pane running, and then best-effort releases only linked AKK metadata. Missing, malformed, stale, or newer cleanup records are preserved and reported as warnings instead of vetoing Close. Refresh the list afterward; if the coding agent is still working, Watch can observe it again. v19 adds `terminal_user_explicit`: when the user chooses an advertised exact live physical prompt, only terminal/process identity, a visible prompt with no active approval, and an exactly empty composer may veto a new Send. Broken AKK Turn, Session, deferred-transfer, transition, ledger, or Store state cannot veto that user decision. AKK tries the managed fast path first; if internal state prevents it, AKK delivers the request once as unmanaged work and then best-effort releases the conflicting management. For an omitted target, AKK durably binds the `message_id` to the first selected physical terminal before input whenever runtime durability is available, so a retry cannot move the same request to another pane. An existing or possibly existing same-ID record rejects automatic replay. If no record exists and durability is unavailable, user priority wins: AKK proceeds with a warning, and strict cross-process replay or reselection protection is unavailable for that degraded invocation, so callers must not automatically retry its result. The fallback creates no callback Turn and sends no callback; refresh the list and use Watch to observe the task.
95
99
 
96
100
  Approval remains separate from managed attribution. When `list` can prove one exact visible Codex approval prompt, it may advertise managed `approve({turn_id})` or terminal-scoped `approve({terminal_id})`; the latter remains possible when foreground rollout attribution is temporarily unavailable. The user must inspect and explicitly confirm that exact prompt. The plugin/CLI then keeps the confirmation offer private, recaptures the prompt, and revalidates the Store, terminal, process, and prompt fence under lock immediately before sending the exact key once. No token or fingerprint is transported through the model call. Terminal-scoped approval does not attribute the approval to a Turn, mutate Session identity, or create a durable approval receipt, so an uncertain transport result must not be retried blindly. It is never available to auto-approve. A changed prompt, identity, owner, or confirmation offer remains blocked.
97
101
 
98
102
  The private approval fence remains prompt-scoped. AKK hashes the adapter-isolated, exact unredacted approval region together with the terminal/process identity, decision keys and label, prompt kind, working directory, reason/detail, and any request or policy evidence. The whole-screen digest and redacted excerpt remain diagnostic only: output outside the approval region may change without invalidating the same reviewed prompt. A change inside the region—including the command or an otherwise identically redacted secret, choices, highlighted option, prompt kind, or request identity—or a change in the bound process, working directory, or request evidence still rejects with zero approval keys. If the adapter cannot isolate one complete bounded prompt region, approval fails closed. The raw prompt region and its opaque fence are never returned to the model, persisted as public action data, or logged.
99
103
 
100
- Human-friendly selectors such as `only`, `codex`, `claude`, a terminal ID, or `@short-ref` remain a slash-command discovery layer. Structured model tools use semantic IDs instead: strict continuation pre-fills `session_id`, while follow-current continuation pre-fills `terminal_id`. Merely observing a mismatch or an unbound rollout inventory never mutates the Store. AKK advertises a send only when it can prove a single source claim, an exact live terminal/process incarnation, an idle empty composer, a stable complete rollout inventory, and no unresolved Turn, transition, dispatch, or approval. A foreground ambiguity inside that complete inventory may be resolved after the real request is accepted; incomplete, stale, or unverifiable evidence remains blocked. Other actions likewise expose only their semantic identities, while opaque freshness fences are derived and consumed inside the trusted plugin/CLI boundary.
104
+ Human-friendly selectors such as `only`, `codex`, `claude`, a terminal ID, or `@short-ref` remain a slash-command discovery layer. Structured model tools use semantic IDs instead: strict continuation pre-fills `session_id`, while terminal-scoped Send pre-fills `terminal_id`. Merely observing a mismatch or an unbound rollout inventory never mutates the Store. Managed Send remains available only when AKK can prove its complete managed authority. A listed `terminal_user_explicit` action has the narrower user-priority boundary instead: one exact live physical prompt, no active approval prompt, and an exactly empty composer. AKK internal management or persistence damage does not suppress that action. Other actions likewise expose only their semantic identities, while opaque freshness fences are derived and consumed inside the trusted plugin/CLI boundary.
101
105
 
102
106
  An exact human switch while the old Session still has one active Turn is a decision point, not an automatic redirect. The terminal row may expose `handoff_decision` instead of a follow-current send. If the user chooses to close the old Turn, explicit Close takes priority and releases only its AKK management; it does not depend on the live native thread remaining unchanged, sends no terminal input, and does not stop the coding agent. Then list again and use only the newly advertised follow-current send or Watch action. Choosing `keep_source` changes no AKK state: restore the old native thread in the Codex or Claude TUI, then refresh the list.
103
107
 
@@ -213,7 +217,7 @@ For one complete first run, follow [Agent Knock Knock in 5 minutes](https://gith
213
217
 
214
218
  AKK discovers verified Codex and Claude Code panes across workspaces. It sends work only to a pane that is already running in tmux or supported Herdr and at a verified idle prompt; it never starts a coding agent for you.
215
219
 
216
- If exactly one eligible idle coding-agent pane exists across all workspaces, send a task directly:
220
+ If exactly one send-ready coding-agent pane exists across all workspaces, send a task directly:
217
221
 
218
222
  ```text
219
223
  /akk inspect this repository and summarize it
@@ -246,7 +250,7 @@ The core command surface is intentionally small:
246
250
 
247
251
  `/akk list` performs a controlled reconciliation across managed turns, and managed `/akk status` limits reconciliation to the selected turn. This can close records whose idle retention has elapsed and restore eligible missing monitors, but it does not send terminal input or retry managed-Turn callback delivery. A `watch_id` status reads that independent Watch record. The running OpenClaw supervisor coordinates two separate reconciliation passes every five seconds and at startup: one restores eligible `waiting_for_agent` Turn monitors, while the other observes active Terminal Watches and retries their durable callback outboxes. Each pass has its own error boundary, so one failure does not starve the other. Standalone shell queries are read-only unless their command explicitly reconciles, and resolving a selector never changes turn state.
248
252
 
249
- Selectors fail closed: `only` works only with one actionable target, `latest` requires a unique newest target, and `codex` or `claude` must identify exactly one eligible pane. These names and `@short-ref` are human-facing slash-command resolution inputs. The v18 structured model contract does not expose a `selector`: JSON actions carry an authoritative `session_id`, `terminal_id`, `turn_id`, `watch_id`, or other semantic entity ID. For ordinary send, exactly one of `session_id` and `terminal_id` may be supplied, or both may be omitted to require one unique pane. Approval likewise uses only `turn_id` or `terminal_id` after explicit confirmation. Before every terminal operation, AKK derives fresh opaque authority internally, revalidates the expected agent PID and provider-owned terminal identity, confirms that the process and pane working directories still match, and—before send—revalidates the idle prompt.
253
+ Selectors fail closed: `only` works only with one actionable target, `latest` requires a unique newest target, and `codex` or `claude` must identify exactly one eligible pane. These names and `@short-ref` are human-facing slash-command resolution inputs. The v19 structured model contract does not expose a `selector`: JSON actions carry an authoritative `session_id`, `terminal_id`, `turn_id`, `watch_id`, or other semantic entity ID. For ordinary send, exactly one of `session_id` and `terminal_id` may be supplied, or both may be omitted to require one unique send-ready pane. Approval likewise uses only `turn_id` or `terminal_id` after explicit confirmation. Before every terminal operation, AKK derives fresh opaque authority internally and revalidates the expected agent PID and provider-owned terminal identity. `terminal_user_explicit` additionally requires the exact live prompt, no active approval, and an empty composer, but does not require healthy AKK management state.
250
254
 
251
255
  To ask AKK itself to change native context, first copy the full `terminal_id` from `/akk list`; lifecycle commands do not accept an ordinary-send `@short-ref` or loose agent selector. `/akk threads <exact-terminal-id>` lists exact, same-workspace candidates with a deterministic number, a collision-safe display-only `@short-id`, and the complete UUID. `/akk resume-thread <exact-terminal-id>` without a selection shows that list. A complete UUID remains compatible. A number or short ID resolves only against the latest list displayed in the same OpenClaw conversation incarnation; both expire after five minutes and fail after terminal, process, workspace, binding, candidate-set, or relevant action changes. AKK resolves that human navigation to the complete UUID and derives fresh private evidence under lock. `previous` (or `刚才那个`) is advertised only when the current Session's latest committed lifecycle transition identifies exactly one currently verified resumable source; it never guesses from title, recency, or static lineage. If `previous` is present, use only its exact prefilled semantic-ID action for a natural-language “刚才那个” request. Structured lifecycle mutations are `new_thread({terminal_id})` and `resume_thread({terminal_id,native_thread_id})`. AKK does not poll bindings or adopt observed switches in the background: a human-driven switch is adopted only as part of an explicit, fresh terminal-scoped send. If a recorded owner process exits, the next lifecycle listing can classify that sole historical binding as resumable, and the resume mutation compare-and-swap detaches it before touching the terminal. Stale, expired, unsupported, busy, ambiguous, active-elsewhere, or unverifiable transitions fail closed. Do not ask AKK to send `/clear`, `/new`, `/resume`, `/status`, Codex `/fork`, `/side`, or `/btw`, Claude `/branch`, or any other first-line native slash command as an ordinary task or answer; use an advertised AKK action, express the request in natural language, or enter an unsupported native command manually in the terminal UI.
252
256
 
@@ -254,15 +258,15 @@ The number and short-ID resume forms refer only to that displayed snapshot; neit
254
258
 
255
259
  To request a native Codex status card or Claude Status panel, first run `agent_knock_knock_list` and use only that terminal row's advertised `native_inspect({terminal_id,inspection:"status"})` action. The structured tool schema is closed to those two semantic fields; callers cannot provide `/status`, another slash command, or an authority token. AKK serializes the inspection with terminal mutations, derives and revalidates its private binding fence and exact terminal identity, and returns only after it proves one fresh bounded status result and an idle postcondition. Codex status probes additionally require an exact viewport of at least 80 columns to preserve the full Session UUID, cross the versioned paste-settle boundary, and dispatch Enter exactly once. An initially narrow or unknown viewport fails before text input with a widen/zoom diagnostic; post-injection viewport or composer drift fails closed before Enter and leaves the draft for manual inspection. Codex `/status` and that viewport requirement apply only to operations that must prove the UUID before terminal input. An otherwise eligible terminal-scoped ordinary task can send once and bind from exact native acceptance afterward, so it does not run `/status` or fail merely because the pane is narrow. For Claude, the inspection safely dismisses the exact modal once. It never turns ordinary `send` or `respond` into a slash-command escape hatch.
256
260
 
257
- The current OpenClaw surface registers 16 tools, and the top-level v18 `action_contracts` documents Terminal Watch alongside closed native inspection, human-priority current-pane send/approval, lifecycle, and Turn actions. Every model-facing action carries semantic IDs only; opaque freshness and compare-and-swap fences stay inside the trusted plugin/CLI boundary. `available_actions` remains the authority for ordinary current actions. Explicit Close is always available for a selected managed Turn after user confirmation, including deferred-transfer and handoff conflicts; it releases AKK management without terminal input or stopping the coding agent. A terminal row may also expose a nested `blocking_turns[].recovery_action` for the same user-owned Close. Invoke the advertised semantic-ID action, then refresh the list before doing anything else.
261
+ The current OpenClaw surface registers 16 tools, and the top-level v19 `action_contracts` documents Terminal Watch alongside closed native inspection, user-priority current-pane Send/approval, lifecycle, and Turn actions. Every model-facing action carries semantic IDs only; opaque freshness and compare-and-swap fences stay inside the trusted plugin/CLI boundary. `available_actions` remains the authority for ordinary current actions. A listed `terminal_user_explicit` Send prioritizes the user's exact live physical prompt over broken AKK internal state: AKK attempts managed delivery first, then may deliver unmanaged without a callback before attempting best-effort management release. Refresh and use Watch afterward. Explicit Close is always available for a selected managed Turn after user confirmation, including deferred-transfer and handoff conflicts; it releases AKK management without terminal input or stopping the coding agent. A terminal row may also expose a nested `blocking_turns[].recovery_action` for the same user-owned Close. Invoke the advertised semantic-ID action, then refresh the list before doing anything else.
258
262
 
259
- For natural-language tool use, `agent_knock_knock_list` is terminal-first. Each live pane appears exactly once in `terminals[]`; `process_state` reports whether its coding-agent process is alive and `activity_state` reports the parsed screen state. `managed.session_id` identifies the continuing AKK session, `managed.current_turn` is its optional active Turn, and `managed.recent_turn` is retained history; retained Turns do not occupy the terminal. A human-driven native-thread mismatch remains honestly classified as `management_state="conflict"`; its `handoff_state` is `external_handoff_adoptable` only when the row advertises the fenced follow-current `send`, otherwise it is `external_handoff_blocked`. Listing never performs the adoption. Pass `all=true` to include older entries in `managed.history`. By default, `unavailable_managed_turns[]` contains attention-needed records whose pane cannot be presented as a live terminal; `all=true` also includes retained unavailable history.
263
+ For natural-language tool use, `agent_knock_knock_list` is terminal-first. Each live pane appears exactly once in `terminals[]`; `process_state` reports whether its coding-agent process is alive and `activity_state` reports the parsed screen state. `managed.session_id` identifies the continuing AKK session, `managed.current_turn` is its optional active Turn, and `managed.recent_turn` is retained history; retained Turns do not occupy the terminal. A human-driven native-thread mismatch remains honestly classified as `management_state="conflict"`; its `handoff_state` is `external_handoff_adoptable` only when the row advertises the fenced follow-current `send`, otherwise it is `external_handoff_blocked`. `management_state="unavailable"` means only that AKK's management projection could not be read; the separately observed live terminal facts and any advertised `terminal_user_explicit` Send remain authoritative. Listing never performs the adoption. Pass `all=true` to include older entries in `managed.history`. By default, `unavailable_managed_turns[]` contains attention-needed records whose pane cannot be presented as a live terminal; `all=true` also includes retained unavailable history.
260
264
 
261
- Use only an `available_actions` entry returned in the current list, begin with its prefilled semantic IDs, and supply every `missing_required` field. The only additional action sources are a terminal row's nested `handoff_decision.choices.take_over_current.action` and an exact `blocking_turns[].recovery_action`; both require explicit user confirmation. When advertised, a managed Session's strict send uses `send({session_id,request})` and creates a new Turn only in that Session's native context. A follow-current send uses `send({terminal_id,request})`; this is the human-priority path when the pane is exact but its foreground Codex UUID is not yet attributable. Structured send never exposes a selector. `respond` and managed controls use `turn_id`; terminal-scoped approval uses `terminal_id` only after explicit confirmation. Native inspection uses `{terminal_id,inspection:"status"}`. Other raw controls may be used only through the exact action their row advertises. `timeoutSeconds` is unsupported, and monitoring limits should be omitted unless the user explicitly asks to change them. AKK derives fresh opaque fences and revalidates availability under lock before every side effect.
265
+ Use only an `available_actions` entry returned in the current list, begin with its prefilled semantic IDs, and supply every `missing_required` field. The only additional action sources are a terminal row's nested `handoff_decision.choices.take_over_current.action` and an exact `blocking_turns[].recovery_action`; both require explicit user confirmation. When advertised, a managed Session's strict send uses `send({session_id,request})` and creates a new Turn only in that Session's native context. Terminal-scoped Send uses `send({terminal_id,request})`. A `terminal_user_explicit` action is the user-priority path: healthy AKK state still takes the managed fast path, while broken AKK state receives one unmanaged delivery with no callback before best-effort management release. Refresh the list and use Watch afterward. Structured Send never exposes a selector. `respond` and managed controls use `turn_id`; terminal-scoped approval uses `terminal_id` only after explicit confirmation. Native inspection uses `{terminal_id,inspection:"status"}`. Other raw controls may be used only through the exact action their row advertises. `timeoutSeconds` is unsupported, and monitoring limits should be omitted unless the user explicitly asks to change them. AKK derives fresh opaque fences and revalidates availability under lock before every side effect.
262
266
 
263
267
  On first attach, the target terminal must be explicitly named by the user; AKK never guesses which already-running pane should receive a task.
264
268
 
265
- The top-level v18 action contracts include `watch` and `unwatch` as well as `send`, manual `approve`, `native_inspect`, `list_resumable_threads`, `new_thread`, `resume_thread`, and conflict-only `reconcile_binding`. Their model-facing mutation shapes are deliberately small: `watch({terminal_id})`; `send({session_id|terminal_id,request})` with the targets mutually exclusive; managed `approve({turn_id})` or terminal-scoped `approve({terminal_id})`; `native_inspect({terminal_id,inspection})`; `new_thread({terminal_id})`; `resume_thread({terminal_id,native_thread_id})`; and `reconcile_binding({terminal_id,conflicting_session_id})`. Approval, handoff takeover, and reconciliation require explicit user confirmation, but none transports a token, revision, binding ID/generation, candidate fence, handoff-only live-native-UUID fence, or approval fingerprint through the model. `native_thread_id` remains the intentional semantic identity for resume. `watch` returns a `watch_id`; Watch status and `unwatch` use only that ID. Human-facing resume numbers and short IDs remain conversation-scoped navigation aids that AKK resolves to the complete native thread ID before the structured action. Orphan close retains `expected_message_id` or `expected_transition_id` because those are entity identities, not opaque authority tokens. The plugin/CLI derives and revalidates all freshness fences privately under the canonical locks. Store format remains 1 and writer protocol remains 5.
269
+ The top-level v19 action contracts include `watch` and `unwatch` as well as `send`, manual `approve`, `native_inspect`, `list_resumable_threads`, `new_thread`, `resume_thread`, and conflict-only `reconcile_binding`. Their model-facing mutation shapes are deliberately small: `watch({terminal_id})`; `send({session_id|terminal_id,request})` with the targets mutually exclusive; managed `approve({turn_id})` or terminal-scoped `approve({terminal_id})`; `native_inspect({terminal_id,inspection})`; `new_thread({terminal_id})`; `resume_thread({terminal_id,native_thread_id})`; and `reconcile_binding({terminal_id,conflicting_session_id})`. The listed Send scope distinguishes managed delivery from `terminal_user_explicit`; the latter is gated by physical prompt safety, not AKK management health, and an unmanaged fallback has no callback. Approval, handoff takeover, and reconciliation require explicit user confirmation, but none transports a token, revision, binding ID/generation, candidate fence, handoff-only live-native-UUID fence, or approval fingerprint through the model. `native_thread_id` remains the intentional semantic identity for resume. `watch` returns a `watch_id`; Watch status and `unwatch` use only that ID. Human-facing resume numbers and short IDs remain conversation-scoped navigation aids that AKK resolves to the complete native thread ID before the structured action. Orphan close retains `expected_message_id` or `expected_transition_id` because those are entity identities, not opaque authority tokens. The plugin/CLI derives and revalidates all freshness fences privately under the canonical locks. Store format remains 1 and writer protocol remains 5.
266
270
 
267
271
  Workspace is not a routing boundary. AKK can list, inspect, and control verified panes across projects; when more than one target matches, choose one listed `terminal_id` for a structured tool or one listed selector for a slash command.
268
272
 
@@ -25,6 +25,7 @@ import { createTerminalCommandCliFacade } from "./terminal-command-cli-adapter.j
25
25
  import { createTerminalAcceptanceCliFacade } from "./terminal-acceptance-cli-adapter.js";
26
26
  import { createTerminalHandoffCliFacade } from "./terminal-handoff-cli-adapter.js";
27
27
  import { createTerminalDelegateCliFacade } from "./terminal-delegate-cli-adapter.js";
28
+ import { createTerminalDelegateSendBindingRepository } from "./terminal-delegate-send-binding.js";
28
29
  import { createNativeThreadLifecycleCliAdapter } from "./native-thread-lifecycle-cli-adapter.js";
29
30
  import { createNativeThreadLifecycleLedgerCliAdapter } from "./native-thread-lifecycle-ledger-cli-adapter.js";
30
31
  import { createNativeThreadTransitionApplication } from "./native-thread-transition-application.js";
@@ -33,9 +34,14 @@ import { createTerminalTurnBindingAuthorityCliAdapter } from "./terminal-turn-bi
33
34
  import { assertSafeTerminalSend } from "./terminal-authority-policy.js";
34
35
  import { canonicalMutationResource, capabilityGatedRepositoryOperation, capabilityGatedRepositoryPairOperation, withCanonicalStateMutationLock } from "./mutation-transaction.js";
35
36
  import { bindTerminalDispatchRoute, terminalDispatchStateLockPath, terminalDispatchStateMutationResource, terminalDispatchStateResourceForStore } from "./terminal-dispatch-capability.js";
37
+ import { terminalSubmissionPayload } from "./terminal-dispatch-execution.js";
36
38
  import { createCallbackCliFacade } from "./callback-cli-adapter.js";
37
39
  import { createOpenClawManagedCallbackCliAdapter } from "./openclaw-managed-callback-cli-adapter.js";
40
+ import { createHostProfileCallbackTransport } from "./host-profile-callback-transport.js";
41
+ import { applyTrustedHostProfileCliOptions } from "./host-profile-runtime.js";
42
+ import { runHostProfileCommand, runHostProfileDoctor } from "./host-profile-cli-adapter.js";
38
43
  import { createTerminalMaintenanceCliFacade } from "./terminal-maintenance-cli-adapter.js";
44
+ import { createTerminalWatchCallbackCliAdapter } from "./terminal-watch-callback-cli-adapter.js";
39
45
  import { createTerminalMonitorStateCliAdapter } from "./terminal-monitor-state-cli-adapter.js";
40
46
  import { createTerminalMonitorSupervisionCliAdapter } from "./terminal-monitor-supervision-cli-adapter.js";
41
47
  import { createTerminalDispatchRepositoryCliAdapter } from "./terminal-dispatch-repository-cli-adapter.js";
@@ -43,7 +49,7 @@ import { createTerminalDispatchRecoveryCliAdapter } from "./terminal-dispatch-re
43
49
  import * as deferredRecoveryAdapter from "./deferred-foreground-recovery-cli-adapter.js";
44
50
  import * as dispatchReceipt from "./terminal-dispatch-receipt.js";
45
51
  import { openClawYieldNextAction } from "./terminal-dispatch-presenter.js";
46
- import { isProcessAlive } from "./terminal-process-source.js";
52
+ import { isProcessAlive, terminalProcessIncarnationForPid } from "./terminal-process-source.js";
47
53
  import { assertConfiguredWorkspace, canonicalWorkspace, expandHome, matchesConfiguredWorkspace, packageRootDir, parseJsonOption, positiveMinutes, redactCliOutput, required, writeCliJson as printJson } from "./cli-command-runtime.js";
48
54
  import { cliCwd, cliDependencies, cliEnv, cliExit, cliNow, cliNowMs, cliPid, cliRuntimeLog as runtimeLog, cliSleep, cliSleepSync as sleepSync, runCliCommandExecution, setCliExitCode, writeCliStdout } from "./cli-runtime-context.js";
49
55
  const cliFileLock = createFileLockCliAdapter({
@@ -54,6 +60,10 @@ const cliFileLock = createFileLockCliAdapter({
54
60
  });
55
61
  const acquireFileLock = cliFileLock.acquire;
56
62
  const terminalDispatchRepository = createTerminalDispatchRepositoryCliAdapter();
63
+ const terminalDelegateSendBindingRepository = createTerminalDelegateSendBindingRepository({
64
+ runtimeDir: terminalDispatchRepository.runtimeDir,
65
+ acquireLock: (lockPath) => acquireFileLock(lockPath, { timeoutMs: 30_000 })
66
+ });
57
67
  const acquireTerminalBridgeSendLock = terminalDispatchRepository.acquire;
58
68
  const terminalBridgeRuntimeKey = terminalDispatchRepository.runtimeKey;
59
69
  const loadTerminalBridgeDispatchLedger = terminalDispatchRepository.load;
@@ -91,15 +101,17 @@ const mutationManagedSessions = Object.freeze({
91
101
  load: gateRepository(["storeWriter"], "storeWriter", loadManagedSession),
92
102
  save: gateRepository(["storeWriter"], "storeWriter", saveManagedSession)
93
103
  });
94
- function terminalWriterMutationLocks(storeDir, terminalControl) {
104
+ function terminalWriterMutationLocks(storeDir, terminalControl, options = {}) {
95
105
  const canonicalStoreDir = path.resolve(storeDir);
96
106
  return {
97
107
  resources: {
98
108
  terminal: canonicalMutationResource(terminalBridgeRuntimeKey(terminalControl), terminalControl),
99
109
  storeWriter: canonicalMutationResource(canonicalStoreDir, canonicalStoreDir)
100
110
  },
101
- acquireTerminal: () => acquireTerminalBridgeSendLock(canonicalStoreDir, terminalControl, { timeoutMs: 30000 }),
102
- withStoreWriter: (operation) => withStoreWriterLeaseAsync(canonicalStoreDir, operation)
111
+ acquireTerminal: () => acquireTerminalBridgeSendLock(canonicalStoreDir, terminalControl, { timeoutMs: options.timeoutMs ?? 30_000, retryMs: options.retryMs }),
112
+ withStoreWriter: (operation) => withStoreWriterLeaseAsync(canonicalStoreDir, operation, {
113
+ timeoutMs: options.timeoutMs
114
+ })
103
115
  };
104
116
  }
105
117
  function terminalWriterStateMutationLocks(storeDir, terminalControl, statePath, logPath) {
@@ -113,11 +125,11 @@ function terminalWriterStateMutationLocks(storeDir, terminalControl, statePath,
113
125
  acquireState: () => acquireFileLock(terminalDispatchStateLockPath(stateResource))
114
126
  };
115
127
  }
116
- function withTerminalDispatchStateScope(scopes, resources, statePath, logPath, operation) {
128
+ function withTerminalDispatchStateScope(scopes, resources, statePath, logPath, operation, options = {}) {
117
129
  const stateResource = terminalDispatchStateMutationResource(scopes, resources, statePath, logPath);
118
130
  return withCanonicalStateMutationLock(scopes, resources, {
119
131
  resource: stateResource,
120
- acquire: () => acquireFileLock(terminalDispatchStateLockPath(stateResource))
132
+ acquire: () => acquireFileLock(terminalDispatchStateLockPath(stateResource), options)
121
133
  }, operation);
122
134
  }
123
135
  function terminalDispatchCapabilityRepositories({ previousLedger, preparedMessageEvent, restoreDeferred, rollbackBeforeInput }) {
@@ -206,15 +218,59 @@ const STORE_MUTATION_COMMANDS = new Set([
206
218
  ]);
207
219
  export function parseCliCommand(argv) {
208
220
  const [command, ...rawArgs] = argv;
221
+ if (command === "host-profile") {
222
+ const [action, ...actionArgs] = rawArgs;
223
+ if (action === undefined || action.startsWith("--")) {
224
+ throw new Error("host-profile requires example, list, or validate");
225
+ }
226
+ const positionalProfile = action === "validate" &&
227
+ actionArgs[0] !== undefined &&
228
+ !actionArgs[0].startsWith("--")
229
+ ? actionArgs[0]
230
+ : undefined;
231
+ const options = parseArgs(positionalProfile ? actionArgs.slice(1) : actionArgs);
232
+ if (positionalProfile && options.profile !== undefined) {
233
+ throw new Error("host-profile validate accepts the Profile only once");
234
+ }
235
+ return {
236
+ command,
237
+ options: {
238
+ ...options,
239
+ action,
240
+ ...(positionalProfile ? { profile: positionalProfile } : {})
241
+ }
242
+ };
243
+ }
209
244
  return {
210
245
  command,
211
246
  options: parseArgs(rawArgs)
212
247
  };
213
248
  }
214
249
  export async function executeCliCommand(commandName, options = {}, dependencies = {}) {
215
- return runCliCommandExecution(commandName, options, dependencies, () => dispatchCliCommand(commandName, options));
250
+ return runCliCommandExecution(commandName, options, dependencies, () => dispatchCliCommand(commandName, applyTrustedHostProfileCliOptions(commandName, options, cliEnv(), cliCwd())));
216
251
  }
217
252
  async function dispatchCliCommand(commandName, options) {
253
+ if (commandName === "host-profile") {
254
+ runHostProfileCommand(options);
255
+ return;
256
+ }
257
+ if (commandName === "host-bridge") {
258
+ const { runHostBridgeCli } = await import("./host-bridge.js");
259
+ await runHostBridgeCli(options);
260
+ return;
261
+ }
262
+ if (commandName === "doctor" && options.hostProfile !== undefined) {
263
+ runHostProfileDoctor({ ...options, profile: options.hostProfile });
264
+ return;
265
+ }
266
+ if (((commandName === "send" && !stringValue(options.turn)) ||
267
+ commandName === "respond") &&
268
+ typeof (options.message ?? options.request) === "string") {
269
+ // This pure syntax fence must run before selector discovery. Native
270
+ // lifecycle commands never need terminal, process, or Store observation.
271
+ // runSend retains the same check at the execution boundary.
272
+ terminalSubmissionPayload(options.message ?? options.request);
273
+ }
218
274
  if (!(commandName === "send" && options.turn)) {
219
275
  await terminalListCliFacade.resolveConversationSelectorOption(commandName, options);
220
276
  }
@@ -309,6 +365,15 @@ function preflightStoreWriter(commandName, options) {
309
365
  if (!STORE_MUTATION_COMMANDS.has(String(commandName ?? ""))) {
310
366
  return;
311
367
  }
368
+ const terminalSendSelector = stringValue(options.session ?? options.conversation ?? options.conversationId);
369
+ if (commandName === "delegate" ||
370
+ (commandName === "send" &&
371
+ terminalSendSelector?.startsWith("terminal:v") &&
372
+ stringValue(options.expectedTerminalToken))) {
373
+ // User-priority Send owns a Store-independent physical fallback; its managed
374
+ // path checks Store state, but damaged Store state cannot veto terminal input.
375
+ return;
376
+ }
312
377
  const statePath = stringValue(options.state);
313
378
  const storeDir = statePath
314
379
  ? pathsForConversationDir(path.dirname(expandHome(statePath))).storeDir
@@ -435,6 +500,15 @@ const managedOpenClawCallbackDelivery = createOpenClawManagedCallbackCliAdapter(
435
500
  textSummary,
436
501
  log: runtimeLog
437
502
  });
503
+ const hostProfileCallbackTransport = createHostProfileCallbackTransport({
504
+ legacyTransport: managedOpenClawCallbackDelivery.transport,
505
+ environment: cliEnv,
506
+ now: cliNow
507
+ });
508
+ const managedCallbackDelivery = Object.freeze({
509
+ ...managedOpenClawCallbackDelivery,
510
+ transport: hostProfileCallbackTransport
511
+ });
438
512
  const callbackCliFacade = createCallbackCliFacade({
439
513
  state: { acquireFileLock, loadConversation: loadConversationFromOptions,
440
514
  readEvents: (logPath) => terminalDispatchRecovery.readEvents(logPath),
@@ -448,7 +522,7 @@ const callbackCliFacade = createCallbackCliFacade({
448
522
  isProcessAlive,
449
523
  attemptLeaseMs: CALLBACK_ATTEMPT_LEASE_MS,
450
524
  delaysMs: CALLBACK_RETRY_DELAYS_MS },
451
- delivery: managedOpenClawCallbackDelivery,
525
+ delivery: managedCallbackDelivery,
452
526
  runtime: { textSummary }
453
527
  });
454
528
  const terminalDispatchRecovery = createTerminalDispatchRecoveryCliAdapter({
@@ -731,6 +805,8 @@ const terminalListCliFacade = createTerminalListCliFacade({
731
805
  codexLatentClearResumeObservation,
732
806
  codexManagedIdentityResolutionContext,
733
807
  codexProcessIncarnationForPid,
808
+ processIncarnationForPid: (pid) => terminalProcessIncarnationForPid(pid, cliDependencies().processBirthForPid ??
809
+ cliDependencies().codexProcessBirthForPid),
734
810
  createRuntimeTerminalAgentRegistry,
735
811
  createTerminalAgentBridge,
736
812
  createTerminalControlProvider,
@@ -787,6 +863,11 @@ const terminalWatchCliFacade = createTerminalWatchCliAdapter({
787
863
  storeDirFromOptions,
788
864
  terminalDispatchOwnership: (terminalControl) => terminalListCliFacade.terminalDispatchOwnership(terminalControl),
789
865
  terminalIncarnationBlockingTurns: (storeDir, terminalControl) => terminalListCliFacade.terminalIncarnationBlockingTurns(storeDir, terminalControl),
866
+ callback: createTerminalWatchCallbackCliAdapter({
867
+ environment: cliEnv,
868
+ now: cliNow,
869
+ transport: hostProfileCallbackTransport
870
+ }),
790
871
  printJson
791
872
  });
792
873
  const terminalHandoffCliFacade = createTerminalHandoffCliFacade({
@@ -1082,6 +1163,8 @@ const terminalCommandCliFacade = createTerminalCommandCliFacade({
1082
1163
  parseJsonOption,
1083
1164
  persistManagedSessionNativeIdentity,
1084
1165
  positiveMinutes,
1166
+ processIncarnationForPid: (pid) => terminalProcessIncarnationForPid(pid, cliDependencies().processBirthForPid ??
1167
+ cliDependencies().codexProcessBirthForPid),
1085
1168
  prepareDeferredCodexForegroundBinding,
1086
1169
  quarantineManagedSessionBinding,
1087
1170
  reattachManagedSessionForNativeIdentity,
@@ -1090,6 +1173,7 @@ const terminalCommandCliFacade = createTerminalCommandCliFacade({
1090
1173
  refineTerminalTurnEndpoint,
1091
1174
  required,
1092
1175
  resolveCurrentNativeAgentSessionIdentity,
1176
+ resolveTerminalBridgeDispatchLedger,
1093
1177
  resolveTerminalConversationFromOptions,
1094
1178
  resolveTerminalDispatchLedgerPaneIncarnation,
1095
1179
  soleBoundManagedSessionClaimForTerminal,
@@ -1123,18 +1207,13 @@ const terminalDelegateCliFacade = createTerminalDelegateCliFacade({
1123
1207
  runtime: {
1124
1208
  canonicalWorkspace,
1125
1209
  required,
1126
- storeDir: storeDirFromOptions
1127
- },
1128
- repository: {
1129
- listConversations,
1130
- readEvents: readNdjsonLog,
1131
- storeDirForConversation: managedSessionStoreDirForConversation
1210
+ terminalRuntimeKey: terminalDispatchRepository.runtimeKey
1132
1211
  },
1133
- authority: { assertSafeAbortedTerminalRetryBinding },
1134
1212
  terminalList: {
1135
1213
  buildTerminalListGroup: terminalListCliFacade.buildTerminalListGroup,
1136
- terminalDispatchOwnership: terminalListCliFacade.terminalDispatchOwnership
1214
+ observeExactTerminal: terminalListCliFacade.observeExactTerminal
1137
1215
  },
1216
+ sendBinding: terminalDelegateSendBindingRepository,
1138
1217
  terminalCommand: { runSend: terminalCommandCliFacade.runSend }
1139
1218
  });
1140
1219
  function usage() {
@@ -1165,6 +1244,11 @@ function usage() {
1165
1244
  agent-knock-knock close [--turn <turn-id|selector>] [--conversation <selector>] [--reason <text>] [--expected-message-id <message-id> | --expected-transition-id <transition-id> | --expected-handoff-token <token>]
1166
1245
  agent-knock-knock install-openclaw [--verify] [--openclaw-bin <path>] [--skill-path <path>] [--skill-only] [--no-restart]
1167
1246
  agent-knock-knock doctor [--openclaw-bin <path>] [--tmux-bin <path>] [--herdr-bin <path>]
1247
+ agent-knock-knock host-profile example
1248
+ agent-knock-knock host-profile list
1249
+ agent-knock-knock host-profile validate <profile.json|built-in-id> [--host <id> --host-version <version>]
1250
+ agent-knock-knock doctor --host-profile <profile.json|built-in-id> --host <id> --host-version <version>
1251
+ agent-knock-knock host-bridge --profile <profile.json|built-in-id> --host <id> --host-version <version> [--store-dir <dir>]
1168
1252
  agent-knock-knock callback --state <file> --message-json <json> [--record-only]
1169
1253
  agent-knock-knock transcript --log <file> [--include-raw]
1170
1254
  agent-knock-knock transcript --conversation <dir> [--include-raw]