@scotthuang/agent-knock-knock 0.12.11 → 0.12.13
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 +40 -0
- package/README.md +43 -30
- package/dist/src/approval-policy.d.ts +11 -2
- package/dist/src/approval-policy.js +33 -7
- package/dist/src/approval-policy.js.map +1 -1
- package/dist/src/callback-cli-adapter.d.ts +47 -0
- package/dist/src/callback-cli-adapter.js +156 -0
- package/dist/src/callback-cli-adapter.js.map +1 -0
- package/dist/src/callback-outbox-policy.d.ts +95 -0
- package/dist/src/callback-outbox-policy.js +149 -0
- package/dist/src/callback-outbox-policy.js.map +1 -0
- package/dist/src/callback-outbox-service.d.ts +247 -0
- package/dist/src/callback-outbox-service.js +1053 -0
- package/dist/src/callback-outbox-service.js.map +1 -0
- package/dist/src/callback-outbox-settlement.d.ts +54 -0
- package/dist/src/callback-outbox-settlement.js +241 -0
- package/dist/src/callback-outbox-settlement.js.map +1 -0
- package/dist/src/canonical-json.d.ts +1 -0
- package/dist/src/canonical-json.js +14 -0
- package/dist/src/canonical-json.js.map +1 -0
- package/dist/src/claude-lifecycle-compatibility.js +15 -0
- package/dist/src/claude-lifecycle-compatibility.js.map +1 -1
- package/dist/src/claude-local-transcript-provider.d.ts +82 -1
- package/dist/src/claude-local-transcript-provider.js +873 -23
- package/dist/src/claude-local-transcript-provider.js.map +1 -1
- package/dist/src/cli-command-runtime.d.ts +14 -0
- package/dist/src/cli-command-runtime.js +164 -0
- package/dist/src/cli-command-runtime.js.map +1 -0
- package/dist/src/cli-core.d.ts +4 -42
- package/dist/src/cli-core.js +958 -28684
- package/dist/src/cli-core.js.map +1 -1
- package/dist/src/cli-runtime-context.d.ts +57 -0
- package/dist/src/cli-runtime-context.js +118 -0
- package/dist/src/cli-runtime-context.js.map +1 -0
- package/dist/src/codex-lifecycle-compatibility.js +2 -1
- package/dist/src/codex-lifecycle-compatibility.js.map +1 -1
- package/dist/src/codex-local-session-provider.d.ts +18 -0
- package/dist/src/codex-local-session-provider.js +67 -0
- package/dist/src/codex-local-session-provider.js.map +1 -1
- package/dist/src/codex-session-provider.js +1 -3
- package/dist/src/codex-session-provider.js.map +1 -1
- package/dist/src/conversation-trace.d.ts +30 -0
- package/dist/src/conversation-trace.js +185 -0
- package/dist/src/conversation-trace.js.map +1 -0
- package/dist/src/deferred-foreground-application-service.d.ts +84 -0
- package/dist/src/deferred-foreground-application-service.js +742 -0
- package/dist/src/deferred-foreground-application-service.js.map +1 -0
- package/dist/src/deferred-foreground-authority-cli-adapter.d.ts +78 -0
- package/dist/src/deferred-foreground-authority-cli-adapter.js +795 -0
- package/dist/src/deferred-foreground-authority-cli-adapter.js.map +1 -0
- package/dist/src/deferred-foreground-boundary.d.ts +61 -0
- package/dist/src/deferred-foreground-boundary.js +2 -0
- package/dist/src/deferred-foreground-boundary.js.map +1 -0
- package/dist/src/deferred-foreground-capability.d.ts +4 -0
- package/dist/src/deferred-foreground-capability.js +184 -0
- package/dist/src/deferred-foreground-capability.js.map +1 -0
- package/dist/src/deferred-foreground-preparation-cli-adapter.d.ts +53 -0
- package/dist/src/deferred-foreground-preparation-cli-adapter.js +210 -0
- package/dist/src/deferred-foreground-preparation-cli-adapter.js.map +1 -0
- package/dist/src/deferred-foreground-preparation-service.d.ts +72 -0
- package/dist/src/deferred-foreground-preparation-service.js +179 -0
- package/dist/src/deferred-foreground-preparation-service.js.map +1 -0
- package/dist/src/deferred-foreground-recovery-cli-adapter.d.ts +139 -0
- package/dist/src/deferred-foreground-recovery-cli-adapter.js +1125 -0
- package/dist/src/deferred-foreground-recovery-cli-adapter.js.map +1 -0
- package/dist/src/deferred-foreground-recovery-service.d.ts +48 -0
- package/dist/src/deferred-foreground-recovery-service.js +91 -0
- package/dist/src/deferred-foreground-recovery-service.js.map +1 -0
- package/dist/src/deferred-foreground-transfer-policy.d.ts +2 -0
- package/dist/src/deferred-foreground-transfer-policy.js +10 -0
- package/dist/src/deferred-foreground-transfer-policy.js.map +1 -0
- package/dist/src/deferred-foreground-transfer.js +46 -105
- package/dist/src/deferred-foreground-transfer.js.map +1 -1
- package/dist/src/doctor-capabilities.d.ts +9 -0
- package/dist/src/doctor-capabilities.js +22 -0
- package/dist/src/doctor-capabilities.js.map +1 -1
- package/dist/src/durable-json-file.d.ts +22 -0
- package/dist/src/durable-json-file.js +127 -0
- package/dist/src/durable-json-file.js.map +1 -0
- package/dist/src/file-lock-cli-adapter.d.ts +43 -0
- package/dist/src/file-lock-cli-adapter.js +150 -0
- package/dist/src/file-lock-cli-adapter.js.map +1 -0
- package/dist/src/herdr-terminal-control-provider.js +1 -3
- package/dist/src/herdr-terminal-control-provider.js.map +1 -1
- package/dist/src/install-doctor-command-adapter.d.ts +17 -0
- package/dist/src/install-doctor-command-adapter.js +225 -0
- package/dist/src/install-doctor-command-adapter.js.map +1 -0
- package/dist/src/live-lifecycle-evidence.js +76 -46
- package/dist/src/live-lifecycle-evidence.js.map +1 -1
- package/dist/src/live-lifecycle-smoke.js +74 -50
- package/dist/src/live-lifecycle-smoke.js.map +1 -1
- package/dist/src/managed-session.d.ts +2 -0
- package/dist/src/managed-session.js +24 -0
- package/dist/src/managed-session.js.map +1 -1
- package/dist/src/managed-turn-recovery-service.d.ts +86 -0
- package/dist/src/managed-turn-recovery-service.js +145 -0
- package/dist/src/managed-turn-recovery-service.js.map +1 -0
- package/dist/src/mutation-transaction.d.ts +48 -0
- package/dist/src/mutation-transaction.js +73 -0
- package/dist/src/mutation-transaction.js.map +1 -0
- package/dist/src/native-thread-lifecycle-cli-adapter.d.ts +154 -0
- package/dist/src/native-thread-lifecycle-cli-adapter.js +786 -0
- package/dist/src/native-thread-lifecycle-cli-adapter.js.map +1 -0
- package/dist/src/native-thread-lifecycle-ledger-cli-adapter.d.ts +25 -0
- package/dist/src/native-thread-lifecycle-ledger-cli-adapter.js +50 -0
- package/dist/src/native-thread-lifecycle-ledger-cli-adapter.js.map +1 -0
- package/dist/src/native-thread-lifecycle-query-service.d.ts +75 -0
- package/dist/src/native-thread-lifecycle-query-service.js +297 -0
- package/dist/src/native-thread-lifecycle-query-service.js.map +1 -0
- package/dist/src/native-thread-lifecycle-recovery-adapter.d.ts +45 -0
- package/dist/src/native-thread-lifecycle-recovery-adapter.js +154 -0
- package/dist/src/native-thread-lifecycle-recovery-adapter.js.map +1 -0
- package/dist/src/native-thread-lifecycle-recovery-service.d.ts +211 -0
- package/dist/src/native-thread-lifecycle-recovery-service.js +1093 -0
- package/dist/src/native-thread-lifecycle-recovery-service.js.map +1 -0
- package/dist/src/native-thread-resume-snapshot-policy.d.ts +73 -0
- package/dist/src/native-thread-resume-snapshot-policy.js +218 -0
- package/dist/src/native-thread-resume-snapshot-policy.js.map +1 -0
- package/dist/src/native-thread-resume-snapshot.d.ts +3 -61
- package/dist/src/native-thread-resume-snapshot.js +2 -143
- package/dist/src/native-thread-resume-snapshot.js.map +1 -1
- package/dist/src/native-thread-transition-application.d.ts +147 -0
- package/dist/src/native-thread-transition-application.js +974 -0
- package/dist/src/native-thread-transition-application.js.map +1 -0
- package/dist/src/native-thread-transition-policy.d.ts +127 -0
- package/dist/src/native-thread-transition-policy.js +154 -0
- package/dist/src/native-thread-transition-policy.js.map +1 -0
- package/dist/src/native-thread-transition-resource-adapter.d.ts +12 -0
- package/dist/src/native-thread-transition-resource-adapter.js +44 -0
- package/dist/src/native-thread-transition-resource-adapter.js.map +1 -0
- package/dist/src/native-thread-transition-settlement-service.d.ts +94 -0
- package/dist/src/native-thread-transition-settlement-service.js +134 -0
- package/dist/src/native-thread-transition-settlement-service.js.map +1 -0
- package/dist/src/native-thread-transition-verification-adapter.d.ts +62 -0
- package/dist/src/native-thread-transition-verification-adapter.js +451 -0
- package/dist/src/native-thread-transition-verification-adapter.js.map +1 -0
- package/dist/src/openclaw-callback-transport.d.ts +69 -0
- package/dist/src/openclaw-callback-transport.js +583 -0
- package/dist/src/openclaw-callback-transport.js.map +1 -0
- package/dist/src/openclaw-plugin-callback-adapter.d.ts +1 -0
- package/dist/src/openclaw-plugin-callback-adapter.js +423 -0
- package/dist/src/openclaw-plugin-callback-adapter.js.map +1 -0
- package/dist/src/openclaw-plugin-command-adapter.d.ts +16 -0
- package/dist/src/openclaw-plugin-command-adapter.js +1868 -0
- package/dist/src/openclaw-plugin-command-adapter.js.map +1 -0
- package/dist/src/openclaw-plugin-helpers.d.ts +27 -4
- package/dist/src/openclaw-plugin-helpers.js +356 -81
- package/dist/src/openclaw-plugin-helpers.js.map +1 -1
- package/dist/src/openclaw-plugin-schemas.d.ts +358 -0
- package/dist/src/openclaw-plugin-schemas.js +366 -0
- package/dist/src/openclaw-plugin-schemas.js.map +1 -0
- package/dist/src/openclaw-plugin-supervisor.d.ts +6 -0
- package/dist/src/openclaw-plugin-supervisor.js +123 -0
- package/dist/src/openclaw-plugin-supervisor.js.map +1 -0
- package/dist/src/openclaw-plugin.js +7 -2212
- package/dist/src/openclaw-plugin.js.map +1 -1
- package/dist/src/openclaw-private-authority-offers.d.ts +22 -0
- package/dist/src/openclaw-private-authority-offers.js +177 -0
- package/dist/src/openclaw-private-authority-offers.js.map +1 -0
- package/dist/src/protocol.d.ts +5 -0
- package/dist/src/protocol.js +59 -3
- package/dist/src/protocol.js.map +1 -1
- package/dist/src/session-store.d.ts +1 -0
- package/dist/src/session-store.js +84 -106
- package/dist/src/session-store.js.map +1 -1
- package/dist/src/store.d.ts +1 -0
- package/dist/src/store.js +5 -2
- package/dist/src/store.js.map +1 -1
- package/dist/src/terminal-acceptance-application-service.d.ts +65 -0
- package/dist/src/terminal-acceptance-application-service.js +63 -0
- package/dist/src/terminal-acceptance-application-service.js.map +1 -0
- package/dist/src/terminal-acceptance-cli-adapter.d.ts +210 -0
- package/dist/src/terminal-acceptance-cli-adapter.js +957 -0
- package/dist/src/terminal-acceptance-cli-adapter.js.map +1 -0
- package/dist/src/terminal-action-projection.d.ts +309 -0
- package/dist/src/terminal-action-projection.js +376 -0
- package/dist/src/terminal-action-projection.js.map +1 -0
- package/dist/src/terminal-agent-bridge.d.ts +3 -0
- package/dist/src/terminal-agent-bridge.js +29 -8
- package/dist/src/terminal-agent-bridge.js.map +1 -1
- package/dist/src/terminal-authority-policy.d.ts +141 -0
- package/dist/src/terminal-authority-policy.js +367 -0
- package/dist/src/terminal-authority-policy.js.map +1 -0
- package/dist/src/terminal-binding-authority.d.ts +118 -0
- package/dist/src/terminal-binding-authority.js +245 -0
- package/dist/src/terminal-binding-authority.js.map +1 -0
- package/dist/src/terminal-binding-reconciliation-service.d.ts +75 -0
- package/dist/src/terminal-binding-reconciliation-service.js +73 -0
- package/dist/src/terminal-binding-reconciliation-service.js.map +1 -0
- package/dist/src/terminal-command-cli-adapter.d.ts +380 -0
- package/dist/src/terminal-command-cli-adapter.js +3288 -0
- package/dist/src/terminal-command-cli-adapter.js.map +1 -0
- package/dist/src/terminal-control-ref.d.ts +4 -0
- package/dist/src/terminal-control-ref.js +11 -8
- package/dist/src/terminal-control-ref.js.map +1 -1
- package/dist/src/terminal-delegate-cli-adapter.d.ts +41 -0
- package/dist/src/terminal-delegate-cli-adapter.js +242 -0
- package/dist/src/terminal-delegate-cli-adapter.js.map +1 -0
- package/dist/src/terminal-dispatch-abort.d.ts +22 -0
- package/dist/src/terminal-dispatch-abort.js +30 -0
- package/dist/src/terminal-dispatch-abort.js.map +1 -0
- package/dist/src/terminal-dispatch-application.d.ts +115 -0
- package/dist/src/terminal-dispatch-application.js +478 -0
- package/dist/src/terminal-dispatch-application.js.map +1 -0
- package/dist/src/terminal-dispatch-capability.d.ts +63 -0
- package/dist/src/terminal-dispatch-capability.js +133 -0
- package/dist/src/terminal-dispatch-capability.js.map +1 -0
- package/dist/src/terminal-dispatch-completion-cli-adapter.d.ts +22 -0
- package/dist/src/terminal-dispatch-completion-cli-adapter.js +96 -0
- package/dist/src/terminal-dispatch-completion-cli-adapter.js.map +1 -0
- package/dist/src/terminal-dispatch-composition.d.ts +79 -0
- package/dist/src/terminal-dispatch-composition.js +2 -0
- package/dist/src/terminal-dispatch-composition.js.map +1 -0
- package/dist/src/terminal-dispatch-execution.d.ts +290 -0
- package/dist/src/terminal-dispatch-execution.js +916 -0
- package/dist/src/terminal-dispatch-execution.js.map +1 -0
- package/dist/src/terminal-dispatch-ledger-codec.d.ts +110 -0
- package/dist/src/terminal-dispatch-ledger-codec.js +399 -0
- package/dist/src/terminal-dispatch-ledger-codec.js.map +1 -0
- package/dist/src/terminal-dispatch-policy.d.ts +93 -0
- package/dist/src/terminal-dispatch-policy.js +122 -0
- package/dist/src/terminal-dispatch-policy.js.map +1 -0
- package/dist/src/terminal-dispatch-presenter.d.ts +65 -0
- package/dist/src/terminal-dispatch-presenter.js +258 -0
- package/dist/src/terminal-dispatch-presenter.js.map +1 -0
- package/dist/src/terminal-dispatch-receipt.d.ts +79 -0
- package/dist/src/terminal-dispatch-receipt.js +314 -0
- package/dist/src/terminal-dispatch-receipt.js.map +1 -0
- package/dist/src/terminal-dispatch-recovery-cli-adapter.d.ts +132 -0
- package/dist/src/terminal-dispatch-recovery-cli-adapter.js +1330 -0
- package/dist/src/terminal-dispatch-recovery-cli-adapter.js.map +1 -0
- package/dist/src/terminal-dispatch-recovery-service.d.ts +271 -0
- package/dist/src/terminal-dispatch-recovery-service.js +374 -0
- package/dist/src/terminal-dispatch-recovery-service.js.map +1 -0
- package/dist/src/terminal-dispatch-repository-cli-adapter.d.ts +35 -0
- package/dist/src/terminal-dispatch-repository-cli-adapter.js +483 -0
- package/dist/src/terminal-dispatch-repository-cli-adapter.js.map +1 -0
- package/dist/src/terminal-handoff-application-service.d.ts +7 -0
- package/dist/src/terminal-handoff-application-service.js +18 -0
- package/dist/src/terminal-handoff-application-service.js.map +1 -0
- package/dist/src/terminal-handoff-cli-adapter.d.ts +229 -0
- package/dist/src/terminal-handoff-cli-adapter.js +1389 -0
- package/dist/src/terminal-handoff-cli-adapter.js.map +1 -0
- package/dist/src/terminal-handoff-facts.d.ts +12 -0
- package/dist/src/terminal-handoff-facts.js +16 -0
- package/dist/src/terminal-handoff-facts.js.map +1 -0
- package/dist/src/terminal-identity-authority-cli-adapter.d.ts +318 -0
- package/dist/src/terminal-identity-authority-cli-adapter.js +1072 -0
- package/dist/src/terminal-identity-authority-cli-adapter.js.map +1 -0
- package/dist/src/terminal-identity-authority-service.d.ts +48 -0
- package/dist/src/terminal-identity-authority-service.js +45 -0
- package/dist/src/terminal-identity-authority-service.js.map +1 -0
- package/dist/src/terminal-list-cli-adapter.d.ts +274 -0
- package/dist/src/terminal-list-cli-adapter.js +2444 -0
- package/dist/src/terminal-list-cli-adapter.js.map +1 -0
- package/dist/src/terminal-list-renderer.d.ts +34 -0
- package/dist/src/terminal-list-renderer.js +643 -0
- package/dist/src/terminal-list-renderer.js.map +1 -0
- package/dist/src/terminal-maintenance-cli-adapter.d.ts +102 -0
- package/dist/src/terminal-maintenance-cli-adapter.js +1059 -0
- package/dist/src/terminal-maintenance-cli-adapter.js.map +1 -0
- package/dist/src/terminal-monitor-application-service.d.ts +275 -0
- package/dist/src/terminal-monitor-application-service.js +982 -0
- package/dist/src/terminal-monitor-application-service.js.map +1 -0
- package/dist/src/terminal-monitor-cli-adapter.d.ts +130 -0
- package/dist/src/terminal-monitor-cli-adapter.js +442 -0
- package/dist/src/terminal-monitor-cli-adapter.js.map +1 -0
- package/dist/src/terminal-monitor-decision-policy.d.ts +98 -0
- package/dist/src/terminal-monitor-decision-policy.js +246 -0
- package/dist/src/terminal-monitor-decision-policy.js.map +1 -0
- package/dist/src/terminal-monitor-launch-plan.d.ts +45 -0
- package/dist/src/terminal-monitor-launch-plan.js +94 -0
- package/dist/src/terminal-monitor-launch-plan.js.map +1 -0
- package/dist/src/terminal-monitor-ownership-policy.d.ts +31 -0
- package/dist/src/terminal-monitor-ownership-policy.js +64 -0
- package/dist/src/terminal-monitor-ownership-policy.js.map +1 -0
- package/dist/src/terminal-monitor-poll-policy.d.ts +48 -0
- package/dist/src/terminal-monitor-poll-policy.js +67 -0
- package/dist/src/terminal-monitor-poll-policy.js.map +1 -0
- package/dist/src/terminal-monitor-reconciliation-eligibility.d.ts +53 -0
- package/dist/src/terminal-monitor-reconciliation-eligibility.js +114 -0
- package/dist/src/terminal-monitor-reconciliation-eligibility.js.map +1 -0
- package/dist/src/terminal-monitor-state-cli-adapter.d.ts +106 -0
- package/dist/src/terminal-monitor-state-cli-adapter.js +1492 -0
- package/dist/src/terminal-monitor-state-cli-adapter.js.map +1 -0
- package/dist/src/terminal-monitor-state-reconciliation-service.d.ts +87 -0
- package/dist/src/terminal-monitor-state-reconciliation-service.js +106 -0
- package/dist/src/terminal-monitor-state-reconciliation-service.js.map +1 -0
- package/dist/src/terminal-monitor-supervision-cli-adapter.d.ts +122 -0
- package/dist/src/terminal-monitor-supervision-cli-adapter.js +685 -0
- package/dist/src/terminal-monitor-supervision-cli-adapter.js.map +1 -0
- package/dist/src/terminal-process-facts.d.ts +2 -0
- package/dist/src/terminal-process-facts.js +19 -0
- package/dist/src/terminal-process-facts.js.map +1 -0
- package/dist/src/terminal-process-source.d.ts +6 -4
- package/dist/src/terminal-process-source.js +25 -20
- package/dist/src/terminal-process-source.js.map +1 -1
- package/dist/src/terminal-runtime-cli-adapter.d.ts +80 -0
- package/dist/src/terminal-runtime-cli-adapter.js +488 -0
- package/dist/src/terminal-runtime-cli-adapter.js.map +1 -0
- package/dist/src/terminal-scoped-approval-authority.d.ts +62 -0
- package/dist/src/terminal-scoped-approval-authority.js +281 -0
- package/dist/src/terminal-scoped-approval-authority.js.map +1 -0
- package/dist/src/terminal-selector-projection-service.d.ts +26 -0
- package/dist/src/terminal-selector-projection-service.js +81 -0
- package/dist/src/terminal-selector-projection-service.js.map +1 -0
- package/dist/src/terminal-status-cli-adapter.d.ts +126 -0
- package/dist/src/terminal-status-cli-adapter.js +577 -0
- package/dist/src/terminal-status-cli-adapter.js.map +1 -0
- package/dist/src/terminal-status-facts.d.ts +56 -0
- package/dist/src/terminal-status-facts.js +199 -0
- package/dist/src/terminal-status-facts.js.map +1 -0
- package/dist/src/terminal-submission-acceptance.d.ts +62 -145
- package/dist/src/terminal-submission-acceptance.js +555 -222
- package/dist/src/terminal-submission-acceptance.js.map +1 -1
- package/dist/src/terminal-submission-facts.d.ts +123 -0
- package/dist/src/terminal-submission-facts.js +205 -0
- package/dist/src/terminal-submission-facts.js.map +1 -0
- package/dist/src/terminal-turn-binding-authority-cli-adapter.d.ts +14 -0
- package/dist/src/terminal-turn-binding-authority-cli-adapter.js +90 -0
- package/dist/src/terminal-turn-binding-authority-cli-adapter.js.map +1 -0
- package/dist/src/terminal-watch-callback-cli-adapter.d.ts +20 -0
- package/dist/src/terminal-watch-callback-cli-adapter.js +55 -0
- package/dist/src/terminal-watch-callback-cli-adapter.js.map +1 -0
- package/dist/src/terminal-watch-cli-adapter.d.ts +64 -0
- package/dist/src/terminal-watch-cli-adapter.js +508 -0
- package/dist/src/terminal-watch-cli-adapter.js.map +1 -0
- package/dist/src/terminal-watch-service.d.ts +97 -0
- package/dist/src/terminal-watch-service.js +714 -0
- package/dist/src/terminal-watch-service.js.map +1 -0
- package/dist/src/terminal-watch-store.d.ts +149 -0
- package/dist/src/terminal-watch-store.js +861 -0
- package/dist/src/terminal-watch-store.js.map +1 -0
- package/dist/src/value-guards.d.ts +4 -0
- package/dist/src/value-guards.js +12 -0
- package/dist/src/value-guards.js.map +1 -0
- package/dist/src/verified-dead-agent-policy.d.ts +192 -0
- package/dist/src/verified-dead-agent-policy.js +262 -0
- package/dist/src/verified-dead-agent-policy.js.map +1 -0
- package/docs/quickstart-herdr.md +8 -0
- package/docs/quickstart-tmux.md +33 -6
- package/openclaw.plugin.json +11 -3
- package/package.json +3 -1
- package/templates/openclaw-skills/agent-knock-knock/SKILL.md +58 -40
|
@@ -1,4 +1,161 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
|
+
import { recordValue } from "./value-guards.js";
|
|
3
|
+
const MODEL_FACING_PRIVATE_AUTHORITY_PARTS = [
|
|
4
|
+
["expected", "terminal", "token"],
|
|
5
|
+
["expected", "binding", "token"],
|
|
6
|
+
["expected", "handoff", "token"],
|
|
7
|
+
["candidate", "token"],
|
|
8
|
+
["expected", "approval", "fingerprint"],
|
|
9
|
+
["approval", "fingerprint"],
|
|
10
|
+
["expected", "session", "revision"],
|
|
11
|
+
["lifecycle", "binding", "token"],
|
|
12
|
+
["binding", "token"],
|
|
13
|
+
["binding", "id"],
|
|
14
|
+
["binding", "generation"],
|
|
15
|
+
["terminal", "binding", "id"],
|
|
16
|
+
["terminal", "binding", "generation"],
|
|
17
|
+
["selection", "handle"],
|
|
18
|
+
["selection", "snapshot"],
|
|
19
|
+
["selection", "scope"],
|
|
20
|
+
["expected", "callback", "conversation", "id"],
|
|
21
|
+
["expected", "callback", "session", "id"],
|
|
22
|
+
["expected", "callback", "turn", "id"],
|
|
23
|
+
["expected", "callback", "message", "id"],
|
|
24
|
+
["expected", "callback", "openclaw", "session"]
|
|
25
|
+
];
|
|
26
|
+
// The optional separator accepts the three spellings that can be emitted by
|
|
27
|
+
// old CLI/JSON diagnostics: snake_case, kebab-case, and camelCase. These are
|
|
28
|
+
// exact AKK authority names rather than generic words such as "token" or
|
|
29
|
+
// "revision", so ordinary user and agent text remains intact.
|
|
30
|
+
const MODEL_FACING_PRIVATE_AUTHORITY_NAME = `(?:${MODEL_FACING_PRIVATE_AUTHORITY_PARTS
|
|
31
|
+
.map((parts) => parts.join("[_-]?"))
|
|
32
|
+
.join("|")})`;
|
|
33
|
+
const MODEL_FACING_SCALAR = `(?:"(?:\\\\.|[^"\\\\])*"|'(?:\\\\.|[^'\\\\])*'|` +
|
|
34
|
+
"`(?:\\\\.|[^`\\\\])*`|true|false|null|" +
|
|
35
|
+
`-?(?:\\d+(?:\\.\\d*)?|\\.\\d+)(?:[eE][+-]?\\d+)?|[^\\s,;}\\]]+)`;
|
|
36
|
+
const MODEL_FACING_PRIVATE_AUTHORITY_JSON = new RegExp(`"${MODEL_FACING_PRIVATE_AUTHORITY_NAME}"\\s*:\\s*${MODEL_FACING_SCALAR}`, "giu");
|
|
37
|
+
const MODEL_FACING_PRIVATE_AUTHORITY_CLI = new RegExp(`--${MODEL_FACING_PRIVATE_AUTHORITY_NAME}(?:=|\\s+)${MODEL_FACING_SCALAR}`, "giu");
|
|
38
|
+
const MODEL_FACING_PRIVATE_AUTHORITY_ASSIGNMENT = new RegExp(`(^|[^A-Za-z0-9])${MODEL_FACING_PRIVATE_AUTHORITY_NAME}` +
|
|
39
|
+
`\\s*(?:=|:)\\s*${MODEL_FACING_SCALAR}`, "gimu");
|
|
40
|
+
const MODEL_FACING_PRIVATE_AUTHORITY_LINE = new RegExp(`^\\s*(?:[-*]\\s*)?(?:` +
|
|
41
|
+
`(?:["']?${MODEL_FACING_PRIVATE_AUTHORITY_NAME}["']?\\s*(?:=|:))|` +
|
|
42
|
+
`(?:--${MODEL_FACING_PRIVATE_AUTHORITY_NAME}(?:=|\\s+)))`, "iu");
|
|
43
|
+
const LEGACY_APPROVAL_TAIL_MARKER = "If the user approves, call `agent_knock_knock_approve`";
|
|
44
|
+
const LEGACY_APPROVAL_TERMINAL_INSTRUCTION = "Do not use raw tmux, shell, or manual key presses for this approval. Do not approve without explicit user confirmation.";
|
|
45
|
+
const MODEL_OPAQUE_AUTHORITY_FIELDS = new Set([
|
|
46
|
+
"acceptanceevidence",
|
|
47
|
+
"candidaterollouts",
|
|
48
|
+
"claudetranscriptanchor",
|
|
49
|
+
"codexopenrootrolloutinventory",
|
|
50
|
+
"codexrolloutacceptanceanchor",
|
|
51
|
+
"challenge",
|
|
52
|
+
"etag",
|
|
53
|
+
"expectedapprovalfingerprint",
|
|
54
|
+
"expectedcallbackconversationid",
|
|
55
|
+
"expectedcallbackmessageid",
|
|
56
|
+
"expectedcallbackopenclawsession",
|
|
57
|
+
"expectedcallbacksessionid",
|
|
58
|
+
"expectedcallbackturnid",
|
|
59
|
+
"generationid",
|
|
60
|
+
"livenativethreadid",
|
|
61
|
+
"nativesessiontakeover",
|
|
62
|
+
"nonce",
|
|
63
|
+
"proof",
|
|
64
|
+
"selectionhandle",
|
|
65
|
+
"selectionsnapshot",
|
|
66
|
+
"selectionscope",
|
|
67
|
+
"snapshotid"
|
|
68
|
+
]);
|
|
69
|
+
export function normalizeAkkModelFacingFieldName(key) {
|
|
70
|
+
return key.toLowerCase().replace(/[^a-z0-9]/gu, "");
|
|
71
|
+
}
|
|
72
|
+
export function isAkkModelFacingPrivateAuthorityField(key) {
|
|
73
|
+
const compact = normalizeAkkModelFacingFieldName(key);
|
|
74
|
+
return compact.endsWith("token") ||
|
|
75
|
+
compact.endsWith("fingerprint") ||
|
|
76
|
+
compact.endsWith("hash") ||
|
|
77
|
+
compact.endsWith("sha256") ||
|
|
78
|
+
compact.endsWith("digest") ||
|
|
79
|
+
compact.endsWith("revision") ||
|
|
80
|
+
compact.endsWith("revisions") ||
|
|
81
|
+
compact.endsWith("bindingid") ||
|
|
82
|
+
compact.endsWith("bindingids") ||
|
|
83
|
+
compact.endsWith("bindinggeneration") ||
|
|
84
|
+
compact.endsWith("bindinggenerations") ||
|
|
85
|
+
compact === "generation" ||
|
|
86
|
+
MODEL_OPAQUE_AUTHORITY_FIELDS.has(compact);
|
|
87
|
+
}
|
|
88
|
+
export function isAkkModelFacingDiagnosticField(key) {
|
|
89
|
+
if (!key)
|
|
90
|
+
return false;
|
|
91
|
+
const separated = key
|
|
92
|
+
.replace(/([a-z0-9])([A-Z])/gu, "$1_$2")
|
|
93
|
+
.toLowerCase();
|
|
94
|
+
return /(?:^|[_-])(?:reasons?|errors?|warnings?|diagnostics?)$/u.test(separated) || /(?:^|[_-])(?:error|warning|diagnostic)_message$/u.test(separated);
|
|
95
|
+
}
|
|
96
|
+
function sanitizeAkkModelFacingEmbeddedAuthorityText(value) {
|
|
97
|
+
return value
|
|
98
|
+
.replace(MODEL_FACING_PRIVATE_AUTHORITY_JSON, '"internal_authority":"[retained by AKK]"')
|
|
99
|
+
.replace(MODEL_FACING_PRIVATE_AUTHORITY_CLI, "[AKK internal authority omitted]")
|
|
100
|
+
.replace(MODEL_FACING_PRIVATE_AUTHORITY_ASSIGNMENT, (_match, prefix) => `${prefix}[AKK internal authority omitted]`);
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Remove only AKK-generated pre-v18 authority instructions from callback/event
|
|
104
|
+
* text. Exact authority-looking text outside one of these fixed machine-owned
|
|
105
|
+
* forms is business content and must remain byte-for-byte visible.
|
|
106
|
+
*/
|
|
107
|
+
export function sanitizeAkkModelFacingLegacyAuthorityInstructionText(value) {
|
|
108
|
+
const reviewOnly = stripAkkLegacyApprovalInstructionTail(value);
|
|
109
|
+
let machineAuthorityBlock = false;
|
|
110
|
+
return reviewOnly.split("\n").map((line) => {
|
|
111
|
+
const text = line.endsWith("\r") ? line.slice(0, -1) : line;
|
|
112
|
+
const carriageReturn = line.endsWith("\r") ? "\r" : "";
|
|
113
|
+
if (/^\s*(?:\[?AKK\]?\s+)?(?:approval|internal) authority\s*:?\s*$/iu
|
|
114
|
+
.test(text)) {
|
|
115
|
+
machineAuthorityBlock = true;
|
|
116
|
+
return line;
|
|
117
|
+
}
|
|
118
|
+
if (text.trim().length === 0) {
|
|
119
|
+
machineAuthorityBlock = false;
|
|
120
|
+
return line;
|
|
121
|
+
}
|
|
122
|
+
const fixedCommand = /^\s*(?:equivalent (?:user )?command|AKK (?:approval )?command)\s*:/iu
|
|
123
|
+
.test(text) && containsEmbeddedPrivateAuthority(text);
|
|
124
|
+
const blockAuthority = machineAuthorityBlock &&
|
|
125
|
+
containsEmbeddedPrivateAuthority(text);
|
|
126
|
+
if (fixedCommand || blockAuthority) {
|
|
127
|
+
return `${text.match(/^\s*/u)?.[0] ?? ""}` +
|
|
128
|
+
`[AKK internal authority omitted]${carriageReturn}`;
|
|
129
|
+
}
|
|
130
|
+
if (machineAuthorityBlock)
|
|
131
|
+
machineAuthorityBlock = false;
|
|
132
|
+
return line;
|
|
133
|
+
}).join("\n");
|
|
134
|
+
}
|
|
135
|
+
/** Remove only the exact legacy approval instruction appended by AKK. */
|
|
136
|
+
export function stripAkkLegacyApprovalInstructionTail(value) {
|
|
137
|
+
const markerIndex = value.lastIndexOf(LEGACY_APPROVAL_TAIL_MARKER);
|
|
138
|
+
const markerSuffix = markerIndex === -1 ? "" : value.slice(markerIndex);
|
|
139
|
+
const fixedTail = markerIndex !== -1 && (markerSuffix.trimEnd().endsWith(LEGACY_APPROVAL_TERMINAL_INSTRUCTION) ||
|
|
140
|
+
markerSuffix.split(/\r?\n/u).some(isLegacyMachineAuthorityLine));
|
|
141
|
+
return fixedTail ? value.slice(0, markerIndex) : value;
|
|
142
|
+
}
|
|
143
|
+
function isLegacyMachineAuthorityLine(line) {
|
|
144
|
+
return containsEmbeddedPrivateAuthority(line) && (MODEL_FACING_PRIVATE_AUTHORITY_LINE.test(line) ||
|
|
145
|
+
/^\s*(?:equivalent (?:user )?command|AKK (?:approval )?command)\s*:/iu
|
|
146
|
+
.test(line));
|
|
147
|
+
}
|
|
148
|
+
function containsEmbeddedPrivateAuthority(value) {
|
|
149
|
+
return sanitizeAkkModelFacingEmbeddedAuthorityText(value) !== value;
|
|
150
|
+
}
|
|
151
|
+
export function sanitizeAkkModelFacingDiagnosticText(message) {
|
|
152
|
+
const sanitized = sanitizeAkkModelFacingEmbeddedAuthorityText(message);
|
|
153
|
+
if (sanitized !== message ||
|
|
154
|
+
/(?:\bexpected\s+(?:session\s+)?revision\b|\bactual\s+(?:session\s+)?revision\b|\b(?:terminal|binding|handoff|candidate)\s+token\b|\bapproval\s+fingerprint\b|\bbinding\s+(?:id|generation)\b|\bcompare-and-swap\b|\bCAS\b)/iu.test(message)) {
|
|
155
|
+
return "AKK's private authority changed or could not be verified. Refresh AKK list/status and retry only the currently advertised semantic action.";
|
|
156
|
+
}
|
|
157
|
+
return sanitized;
|
|
158
|
+
}
|
|
2
159
|
export const AKK_CALLBACK_METHOD = "agent-knock-knock.callback";
|
|
3
160
|
export function parseAkkCommand(args) {
|
|
4
161
|
const input = String(args ?? "").trim();
|
|
@@ -15,6 +172,14 @@ export function parseAkkCommand(args) {
|
|
|
15
172
|
}
|
|
16
173
|
const { token, rest } = takeToken(input);
|
|
17
174
|
const action = token.toLowerCase();
|
|
175
|
+
const lifecycleCommand = parseAkkLifecycleCommand(action, rest);
|
|
176
|
+
if (lifecycleCommand) {
|
|
177
|
+
return lifecycleCommand;
|
|
178
|
+
}
|
|
179
|
+
const turnCommand = parseAkkTurnCommand(action, rest);
|
|
180
|
+
return turnCommand ?? { action: "delegate", request: input };
|
|
181
|
+
}
|
|
182
|
+
function parseAkkLifecycleCommand(action, rest) {
|
|
18
183
|
if (action === "list" || action === "ls" || action === "tasks") {
|
|
19
184
|
return { action: "list" };
|
|
20
185
|
}
|
|
@@ -24,6 +189,23 @@ export function parseAkkCommand(args) {
|
|
|
24
189
|
}
|
|
25
190
|
return { action: "doctor" };
|
|
26
191
|
}
|
|
192
|
+
if (action === "watch") {
|
|
193
|
+
const usage = "Usage: /akk watch <exact-terminal-id>";
|
|
194
|
+
const { token: terminalId, rest: extra } = takeRequiredToken(rest, usage);
|
|
195
|
+
assertExactTerminalId(terminalId, usage);
|
|
196
|
+
if (extra.trim()) {
|
|
197
|
+
throw new Error(usage);
|
|
198
|
+
}
|
|
199
|
+
return { action: "watch", terminalId };
|
|
200
|
+
}
|
|
201
|
+
if (action === "unwatch") {
|
|
202
|
+
const usage = "Usage: /akk unwatch <watch-id>";
|
|
203
|
+
const { token: watchId, rest: extra } = takeRequiredToken(rest, usage);
|
|
204
|
+
if (extra.trim() || !isTerminalWatchId(watchId)) {
|
|
205
|
+
throw new Error(usage);
|
|
206
|
+
}
|
|
207
|
+
return { action: "unwatch", watchId };
|
|
208
|
+
}
|
|
27
209
|
if (action === "threads" || action === "list-resumable-threads") {
|
|
28
210
|
const usage = "Usage: /akk threads <exact-terminal-id>";
|
|
29
211
|
const { token: terminalId, rest: extra } = takeRequiredToken(rest, usage);
|
|
@@ -44,7 +226,7 @@ export function parseAkkCommand(args) {
|
|
|
44
226
|
}
|
|
45
227
|
if (action === "resume-thread") {
|
|
46
228
|
const usage = "Usage: /akk resume-thread <exact-terminal-id> " +
|
|
47
|
-
"[native-thread-uuid|previous|刚才那个|number|@short-id
|
|
229
|
+
"[native-thread-uuid|previous|刚才那个|number|@short-id]";
|
|
48
230
|
const { token: terminalId, rest: nativeInput } = takeRequiredToken(rest, usage);
|
|
49
231
|
assertExactTerminalId(terminalId, usage);
|
|
50
232
|
const { token: selectionInput, rest: extra } = takeToken(nativeInput);
|
|
@@ -62,12 +244,17 @@ export function parseAkkCommand(args) {
|
|
|
62
244
|
: {})
|
|
63
245
|
};
|
|
64
246
|
}
|
|
247
|
+
return undefined;
|
|
248
|
+
}
|
|
249
|
+
function parseAkkTurnCommand(action, rest) {
|
|
65
250
|
if (action === "status" || action === "show") {
|
|
66
251
|
const { token: turnId, rest: extra } = takeToken(rest);
|
|
67
252
|
if (extra.trim()) {
|
|
68
|
-
throw new Error("Usage: /akk status [turn-selector]");
|
|
253
|
+
throw new Error("Usage: /akk status [turn-selector|terminal-watch-id]");
|
|
69
254
|
}
|
|
70
|
-
return
|
|
255
|
+
return turnId && isTerminalWatchId(turnId)
|
|
256
|
+
? { action: "status", watchId: turnId }
|
|
257
|
+
: { action: "status", turnId: turnId || undefined };
|
|
71
258
|
}
|
|
72
259
|
if (action === "describe" || action === "summary" || action === "about") {
|
|
73
260
|
throw new Error("AKK describe was removed; use /akk status [turn-selector]");
|
|
@@ -87,15 +274,13 @@ export function parseAkkCommand(args) {
|
|
|
87
274
|
throw new Error("AKK reply syntax changed; use /akk respond <turn-selector>: <answer>");
|
|
88
275
|
}
|
|
89
276
|
if (action === "approve") {
|
|
90
|
-
const { token: turnId, rest: approvalInput } = takeRequiredToken(rest, "Usage: /akk approve <turn-selector>
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
throw new Error("Usage: /akk approve <turn-selector> --expected-approval-fingerprint <fingerprint>");
|
|
277
|
+
const { token: turnId, rest: approvalInput } = takeRequiredToken(rest, "Usage: /akk approve <turn-selector>");
|
|
278
|
+
if (approvalInput.trim()) {
|
|
279
|
+
throw new Error("Usage: /akk approve <turn-selector>");
|
|
94
280
|
}
|
|
95
281
|
return {
|
|
96
282
|
action: "approve",
|
|
97
|
-
turnId
|
|
98
|
-
expectedApprovalFingerprint: approval[1]
|
|
283
|
+
turnId
|
|
99
284
|
};
|
|
100
285
|
}
|
|
101
286
|
if (action === "cancel" || action === "stop") {
|
|
@@ -115,40 +300,43 @@ export function parseAkkCommand(args) {
|
|
|
115
300
|
return { action: "retry-callback", turnId };
|
|
116
301
|
}
|
|
117
302
|
if (action === "close" || action === "done") {
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
? "Native-thread lifecycle transition recovered from /akk command"
|
|
135
|
-
: "Orphaned terminal dispatch resolved from /akk command";
|
|
136
|
-
return {
|
|
137
|
-
action: "close",
|
|
138
|
-
turnId,
|
|
139
|
-
reason: recoveryReason ||
|
|
140
|
-
(recovery
|
|
141
|
-
? defaultRecoveryReason
|
|
142
|
-
: recoveryInput || "Closed from /akk command"),
|
|
143
|
-
...(recoveryKind === "message" && recoveryId
|
|
144
|
-
? { expectedMessageId: recoveryId }
|
|
145
|
-
: {}),
|
|
146
|
-
...(recoveryKind === "transition" && recoveryId
|
|
147
|
-
? { expectedTransitionId: recoveryId }
|
|
148
|
-
: {})
|
|
149
|
-
};
|
|
303
|
+
return parseAkkCloseCommand(rest);
|
|
304
|
+
}
|
|
305
|
+
return undefined;
|
|
306
|
+
}
|
|
307
|
+
function parseAkkCloseCommand(rest) {
|
|
308
|
+
const usage = "Usage: /akk close <turn-selector> " +
|
|
309
|
+
"[(--expected-message-id <id> | --expected-transition-id <id>)] [reason]";
|
|
310
|
+
const { token: turnId, rest: reasonInput } = takeRequiredToken(rest, usage);
|
|
311
|
+
const recoveryInput = reasonInput.trim();
|
|
312
|
+
const recoveryFlags = recoveryInput.match(/(?:^|\s)--expected-(?:message|transition)-id(?=\s|$)/gu) ?? [];
|
|
313
|
+
if (recoveryFlags.length > 1) {
|
|
314
|
+
throw new Error(`${usage}; expected-message-id and expected-transition-id are mutually exclusive`);
|
|
315
|
+
}
|
|
316
|
+
const recovery = /^--expected-(message|transition)-id\s+(\S+)(?:\s+([\s\S]*))?$/u.exec(recoveryInput);
|
|
317
|
+
if (recoveryFlags.length === 1 && !recovery) {
|
|
318
|
+
throw new Error(usage);
|
|
150
319
|
}
|
|
151
|
-
|
|
320
|
+
const recoveryKind = recovery?.[1];
|
|
321
|
+
const recoveryId = recovery?.[2];
|
|
322
|
+
const recoveryReason = recovery?.[3]?.trim();
|
|
323
|
+
const defaultRecoveryReason = recoveryKind === "transition"
|
|
324
|
+
? "Native-thread lifecycle transition recovered from /akk command"
|
|
325
|
+
: "Orphaned terminal dispatch resolved from /akk command";
|
|
326
|
+
return {
|
|
327
|
+
action: "close",
|
|
328
|
+
turnId,
|
|
329
|
+
reason: recoveryReason ||
|
|
330
|
+
(recovery
|
|
331
|
+
? defaultRecoveryReason
|
|
332
|
+
: recoveryInput || "Closed from /akk command"),
|
|
333
|
+
...(recoveryKind === "message" && recoveryId
|
|
334
|
+
? { expectedMessageId: recoveryId }
|
|
335
|
+
: {}),
|
|
336
|
+
...(recoveryKind === "transition" && recoveryId
|
|
337
|
+
? { expectedTransitionId: recoveryId }
|
|
338
|
+
: {})
|
|
339
|
+
};
|
|
152
340
|
}
|
|
153
341
|
export function akkUsageText() {
|
|
154
342
|
return [
|
|
@@ -158,21 +346,26 @@ export function akkUsageText() {
|
|
|
158
346
|
"/akk claude: <request>",
|
|
159
347
|
"/akk <session-selector>: <message>",
|
|
160
348
|
"/akk list",
|
|
349
|
+
"/akk watch <exact-terminal-id>",
|
|
350
|
+
"/akk unwatch <watch-id>",
|
|
161
351
|
"/akk threads <exact-terminal-id>",
|
|
162
352
|
"/akk new-thread <exact-terminal-id>",
|
|
163
353
|
"/akk clear-thread <exact-terminal-id>",
|
|
164
|
-
"/akk resume-thread <exact-terminal-id> [uuid|previous|number|@short-id
|
|
354
|
+
"/akk resume-thread <exact-terminal-id> [uuid|previous|number|@short-id]",
|
|
165
355
|
"/akk doctor",
|
|
166
|
-
"/akk status [turn-selector]",
|
|
356
|
+
"/akk status [turn-selector|terminal-watch-id]",
|
|
167
357
|
"/akk respond <turn-selector>: <answer>",
|
|
168
|
-
"/akk approve <turn-selector>
|
|
358
|
+
"/akk approve <turn-selector>",
|
|
169
359
|
"/akk cancel <turn-selector>"
|
|
170
360
|
].join("\n");
|
|
171
361
|
}
|
|
172
362
|
export function formatAkkListCommandResult(result) {
|
|
173
363
|
const terminals = arrayValue(result.terminals);
|
|
364
|
+
const terminalWatches = arrayValue(result.terminal_watches);
|
|
174
365
|
const unavailableManagedTurns = arrayValue(result.unavailable_managed_turns);
|
|
175
|
-
if (terminals.length === 0 &&
|
|
366
|
+
if (terminals.length === 0 &&
|
|
367
|
+
terminalWatches.length === 0 &&
|
|
368
|
+
unavailableManagedTurns.length === 0) {
|
|
176
369
|
return "AKK found no live terminals or unavailable managed turns.";
|
|
177
370
|
}
|
|
178
371
|
const terminalLines = terminals.slice(0, 20).flatMap((terminal) => {
|
|
@@ -192,11 +385,15 @@ export function formatAkkListCommandResult(result) {
|
|
|
192
385
|
"new_thread",
|
|
193
386
|
"resume_thread"
|
|
194
387
|
].some((name) => Object.hasOwn(availableActions, name));
|
|
388
|
+
const hasWatchAction = Object.hasOwn(availableActions, "watch");
|
|
195
389
|
return [
|
|
196
390
|
`- ${formatTerminalLine(terminal)}`,
|
|
197
391
|
...(hasLifecycleAction && terminalId
|
|
198
392
|
? [` lifecycle terminal_id: ${terminalId}`]
|
|
199
393
|
: []),
|
|
394
|
+
...(hasWatchAction && terminalId
|
|
395
|
+
? [` AKK Watch available: /akk watch ${terminalId} — monitor this human-started task and receive attention/completion callbacks without polling.`]
|
|
396
|
+
: []),
|
|
200
397
|
...(sessionId || sessionShortRef
|
|
201
398
|
? [` AKK session: ${sessionShortRef ?? sessionId}`]
|
|
202
399
|
: []),
|
|
@@ -231,11 +428,21 @@ export function formatAkkListCommandResult(result) {
|
|
|
231
428
|
...(recovery ? [` recovery: ${recovery}`] : [])
|
|
232
429
|
];
|
|
233
430
|
});
|
|
431
|
+
const watchLines = terminalWatches.slice(0, 20).flatMap((watch) => [
|
|
432
|
+
`- ${formatTerminalWatchLine(watch)}`,
|
|
433
|
+
...formatAvailableActions(" actions", watch)
|
|
434
|
+
]);
|
|
435
|
+
const heading = terminalWatches.length > 0
|
|
436
|
+
? `AKK terminals (${terminals.length} live, ${terminalWatches.length} terminal watches, ${unavailableManagedTurns.length} unavailable managed turns):`
|
|
437
|
+
: `AKK terminals (${terminals.length} live, ${unavailableManagedTurns.length} unavailable managed turns):`;
|
|
234
438
|
return [
|
|
235
|
-
|
|
439
|
+
heading,
|
|
236
440
|
...(terminalLines.length > 0
|
|
237
441
|
? ["live terminals:", ...terminalLines]
|
|
238
442
|
: []),
|
|
443
|
+
...(watchLines.length > 0
|
|
444
|
+
? ["terminal watches:", ...watchLines]
|
|
445
|
+
: []),
|
|
239
446
|
...(unavailableManagedTurns.length > 0
|
|
240
447
|
? [
|
|
241
448
|
"unavailable managed turns:",
|
|
@@ -247,6 +454,63 @@ export function formatAkkListCommandResult(result) {
|
|
|
247
454
|
: [])
|
|
248
455
|
].join("\n");
|
|
249
456
|
}
|
|
457
|
+
export function formatAkkWatchCommandResult(result) {
|
|
458
|
+
const watch = terminalWatchRecord(result);
|
|
459
|
+
return [
|
|
460
|
+
"AKK Terminal Watch started:",
|
|
461
|
+
`watch: ${nonEmptyString(watch.watch_id) ?? "unknown"}`,
|
|
462
|
+
`terminal: ${nonEmptyString(watch.terminal_id) ?? "unknown"}`,
|
|
463
|
+
`agent: ${nonEmptyString(watch.agent) ?? "unknown"}`,
|
|
464
|
+
`status: ${nonEmptyString(watch.status) ?? "watching"}`,
|
|
465
|
+
"AKK did not send or adopt this task; it is observing work the human started in the terminal."
|
|
466
|
+
].join("\n");
|
|
467
|
+
}
|
|
468
|
+
export function formatAkkUnwatchCommandResult(result) {
|
|
469
|
+
const watch = terminalWatchRecord(result);
|
|
470
|
+
return [
|
|
471
|
+
"AKK Terminal Watch stopped:",
|
|
472
|
+
`watch: ${nonEmptyString(watch.watch_id) ?? "unknown"}`,
|
|
473
|
+
`status: ${nonEmptyString(watch.status) ?? "cancelled"}`,
|
|
474
|
+
"The terminal and its task were not interrupted."
|
|
475
|
+
].join("\n");
|
|
476
|
+
}
|
|
477
|
+
export function formatAkkWatchStatusCommandResult(result) {
|
|
478
|
+
const watch = terminalWatchRecord(result);
|
|
479
|
+
const settlement = recordValue(watch.settlement) ?? {};
|
|
480
|
+
const reason = nonEmptyString(settlement.reason_code) ??
|
|
481
|
+
nonEmptyString(watch.reason);
|
|
482
|
+
const completionText = nonEmptyString(settlement.completion_text);
|
|
483
|
+
return [
|
|
484
|
+
"AKK Terminal Watch status:",
|
|
485
|
+
`watch: ${nonEmptyString(watch.watch_id) ?? "unknown"}`,
|
|
486
|
+
`terminal: ${nonEmptyString(watch.terminal_id) ?? "unknown"}`,
|
|
487
|
+
`agent: ${nonEmptyString(watch.agent) ?? "unknown"}`,
|
|
488
|
+
`status: ${nonEmptyString(watch.status) ?? "unknown"}`,
|
|
489
|
+
...(reason
|
|
490
|
+
? [`reason: ${reason}`]
|
|
491
|
+
: []),
|
|
492
|
+
...(completionText
|
|
493
|
+
? [`completion: ${truncateText(completionText, 500)}`]
|
|
494
|
+
: []),
|
|
495
|
+
"This is observed external work; AKK did not send or adopt the task."
|
|
496
|
+
].join("\n");
|
|
497
|
+
}
|
|
498
|
+
export function formatAkkTerminalWatchHint(result) {
|
|
499
|
+
const hint = recordValue(result.terminal_watch_hint);
|
|
500
|
+
if (hint?.kind !== "terminal_watch_discovery" ||
|
|
501
|
+
hint.available_action_required !== true) {
|
|
502
|
+
return [];
|
|
503
|
+
}
|
|
504
|
+
const command = nonEmptyString(hint.command);
|
|
505
|
+
const instruction = nonEmptyString(hint.instruction);
|
|
506
|
+
if (!command || !instruction) {
|
|
507
|
+
return [];
|
|
508
|
+
}
|
|
509
|
+
return [
|
|
510
|
+
`AKK Watch available: ${command}`,
|
|
511
|
+
`next: ${instruction}`
|
|
512
|
+
];
|
|
513
|
+
}
|
|
250
514
|
export function formatAkkRespondCommandResult(result) {
|
|
251
515
|
const conversation = recordValue(result.conversation) ?? {};
|
|
252
516
|
const compatibilityId = nonEmptyString(conversation.conversation_id) ??
|
|
@@ -342,7 +606,6 @@ export function formatAkkThreadsCommandResult(result) {
|
|
|
342
606
|
const nativeThreadId = nonEmptyString(thread.native_thread_id) ?? "unknown";
|
|
343
607
|
const selectionNumber = finiteNumber(thread.selection_number);
|
|
344
608
|
const shortId = nonEmptyString(thread.short_id);
|
|
345
|
-
const selectionHandle = nonEmptyString(thread.selection_handle);
|
|
346
609
|
const status = thread.resumable === true
|
|
347
610
|
? "resumable"
|
|
348
611
|
: nonEmptyString(thread.unavailable_reason) ?? "unavailable";
|
|
@@ -350,11 +613,10 @@ export function formatAkkThreadsCommandResult(result) {
|
|
|
350
613
|
nonEmptyString(thread.title),
|
|
351
614
|
nonEmptyString(thread.preview)
|
|
352
615
|
].filter((value) => Boolean(value)).join(" · ");
|
|
353
|
-
const selector = selectionNumber !== undefined || shortId
|
|
616
|
+
const selector = selectionNumber !== undefined || shortId
|
|
354
617
|
? [
|
|
355
618
|
selectionNumber !== undefined ? `${selectionNumber}.` : undefined,
|
|
356
|
-
shortId
|
|
357
|
-
selectionHandle ? `[${selectionHandle}]` : undefined
|
|
619
|
+
shortId
|
|
358
620
|
].filter(Boolean).join(" ")
|
|
359
621
|
: `- ${nativeThreadId}`;
|
|
360
622
|
const previousMarker = nativeThreadId === previousNativeThreadId
|
|
@@ -383,7 +645,7 @@ export function formatAkkThreadsCommandResult(result) {
|
|
|
383
645
|
...(resumableCount > 0
|
|
384
646
|
? [
|
|
385
647
|
`next: /akk resume-thread ${terminalId} <native-thread-uuid>`,
|
|
386
|
-
`shortcuts: /akk resume-thread ${terminalId} <number|@short-id
|
|
648
|
+
`shortcuts: /akk resume-thread ${terminalId} <number|@short-id>`,
|
|
387
649
|
...(previousNativeThreadId
|
|
388
650
|
? [`previous: /akk resume-thread ${terminalId} previous`]
|
|
389
651
|
: []),
|
|
@@ -407,7 +669,9 @@ export function formatAkkThreadTransitionCommandResult(result) {
|
|
|
407
669
|
? [`transition: ${nonEmptyString(result.transition_id)}`]
|
|
408
670
|
: []),
|
|
409
671
|
...(nonEmptyString(result.reason)
|
|
410
|
-
? [
|
|
672
|
+
? [
|
|
673
|
+
`reason: ${sanitizeAkkModelFacingDiagnosticText(nonEmptyString(result.reason) ?? "")}`
|
|
674
|
+
]
|
|
411
675
|
: []),
|
|
412
676
|
"No AKK Turn was created.",
|
|
413
677
|
"Next: do not retry automatically; refresh /akk list and use only its exact lifecycle recovery action."
|
|
@@ -433,9 +697,6 @@ export function formatAkkThreadTransitionCommandResult(result) {
|
|
|
433
697
|
]
|
|
434
698
|
: []),
|
|
435
699
|
`native thread: ${nonEmptyString(result.native_thread_id) ?? "unknown"}`,
|
|
436
|
-
...(finiteNumber(result.binding_generation) !== undefined
|
|
437
|
-
? [`binding generation: ${finiteNumber(result.binding_generation)}`]
|
|
438
|
-
: []),
|
|
439
700
|
"No AKK Turn was created. The next ordinary send creates the first Turn in this native context."
|
|
440
701
|
].join("\n");
|
|
441
702
|
}
|
|
@@ -457,6 +718,20 @@ export function buildAkkCommandCliArgs(command, config, context = {}) {
|
|
|
457
718
|
switch (command.action) {
|
|
458
719
|
case "list":
|
|
459
720
|
return withOptionalArgs(["list", "--reconcile"], ["--store-dir", storeDir], ["--idle-timeout-minutes", idleTimeoutMinutes]);
|
|
721
|
+
case "watch": {
|
|
722
|
+
const openclawSession = nonEmptyString(context.sessionKey) ??
|
|
723
|
+
"agent:main:main";
|
|
724
|
+
return withOptionalArgs([
|
|
725
|
+
"watch-terminal",
|
|
726
|
+
"--terminal",
|
|
727
|
+
command.terminalId
|
|
728
|
+
], ["--store-dir", storeDir], [
|
|
729
|
+
"--hard-timeout-minutes",
|
|
730
|
+
finiteNumberString(config.agentHardTimeoutMinutes)
|
|
731
|
+
], ["--openclaw-session", openclawSession], ["--openclaw-bin", nonEmptyString(config.openclawBin)]);
|
|
732
|
+
}
|
|
733
|
+
case "unwatch":
|
|
734
|
+
return withOptionalArgs(["unwatch-terminal", "--watch", command.watchId], ["--store-dir", storeDir]);
|
|
460
735
|
case "list-resumable-threads":
|
|
461
736
|
return withOptionalArgs([
|
|
462
737
|
"list-resumable-threads",
|
|
@@ -505,17 +780,6 @@ export function buildAkkCommandCliArgs(command, config, context = {}) {
|
|
|
505
780
|
requiredSelectionScope(context.selectionScope)
|
|
506
781
|
], ["--store-dir", storeDir], ["--codex-home", codexHome]);
|
|
507
782
|
}
|
|
508
|
-
if (command.selection.kind === "snapshot-handle") {
|
|
509
|
-
return withOptionalArgs([
|
|
510
|
-
"resume-thread",
|
|
511
|
-
"--terminal",
|
|
512
|
-
command.terminalId,
|
|
513
|
-
"--selection-handle",
|
|
514
|
-
command.selection.selectionHandle,
|
|
515
|
-
"--selection-scope",
|
|
516
|
-
requiredSelectionScope(context.selectionScope)
|
|
517
|
-
], ["--store-dir", storeDir], ["--codex-home", codexHome]);
|
|
518
|
-
}
|
|
519
783
|
return withOptionalArgs([
|
|
520
784
|
"resume-thread",
|
|
521
785
|
"--terminal",
|
|
@@ -528,6 +792,9 @@ export function buildAkkCommandCliArgs(command, config, context = {}) {
|
|
|
528
792
|
requiredCandidateToken(context.candidateToken)
|
|
529
793
|
], ["--store-dir", storeDir], ["--codex-home", codexHome]);
|
|
530
794
|
case "status":
|
|
795
|
+
if (command.watchId) {
|
|
796
|
+
return withOptionalArgs(["watch-status", "--watch", command.watchId], ["--store-dir", storeDir]);
|
|
797
|
+
}
|
|
531
798
|
return withOptionalArgs([
|
|
532
799
|
"status",
|
|
533
800
|
"--reconcile",
|
|
@@ -556,13 +823,9 @@ export function buildAkkCommandCliArgs(command, config, context = {}) {
|
|
|
556
823
|
command.message
|
|
557
824
|
], ["--store-dir", storeDir]);
|
|
558
825
|
case "approve":
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
command.turnId,
|
|
563
|
-
"--expected-approval-fingerprint",
|
|
564
|
-
command.expectedApprovalFingerprint
|
|
565
|
-
], ["--store-dir", storeDir]);
|
|
826
|
+
// The OpenClaw command adapter resolves the current private approval
|
|
827
|
+
// authority immediately before invoking the CLI.
|
|
828
|
+
return undefined;
|
|
566
829
|
case "renew":
|
|
567
830
|
return withOptionalArgs(["renew", "--turn", command.turnId], [
|
|
568
831
|
"--minutes",
|
|
@@ -583,6 +846,9 @@ export function buildAkkCommandCliArgs(command, config, context = {}) {
|
|
|
583
846
|
], ["--expected-message-id", command.expectedMessageId], ["--expected-transition-id", command.expectedTransitionId], ["--store-dir", storeDir]);
|
|
584
847
|
}
|
|
585
848
|
}
|
|
849
|
+
function isTerminalWatchId(value) {
|
|
850
|
+
return /^terminal-watch-[A-Za-z0-9._:-]+$/u.test(value);
|
|
851
|
+
}
|
|
586
852
|
function parseSelectorMessage(input) {
|
|
587
853
|
const match = /^((?:(?:codex|claude):latest|only|latest|codex|claude|@[0-9a-f]+))\s*:\s*([\s\S]*)$/iu.exec(input);
|
|
588
854
|
const message = match?.[2]?.trim();
|
|
@@ -631,9 +897,6 @@ function parseAkkResumeSelection(value, usage) {
|
|
|
631
897
|
if (/^@[a-f0-9]{8,32}$/u.test(normalized)) {
|
|
632
898
|
return { kind: "short-id", shortId: normalized };
|
|
633
899
|
}
|
|
634
|
-
if (/^rs_[A-Za-z0-9_-]{22}:[1-9][0-9]*$/u.test(value)) {
|
|
635
|
-
return { kind: "snapshot-handle", selectionHandle: value };
|
|
636
|
-
}
|
|
637
900
|
throw new Error(`${usage}; use a complete UUID or a selection exactly returned by /akk threads`);
|
|
638
901
|
}
|
|
639
902
|
function requiredExpectedBindingToken(value) {
|
|
@@ -715,10 +978,10 @@ function arrayValue(value) {
|
|
|
715
978
|
? value.filter((item) => item !== null && typeof item === "object" && !Array.isArray(item))
|
|
716
979
|
: [];
|
|
717
980
|
}
|
|
718
|
-
function
|
|
719
|
-
return
|
|
720
|
-
|
|
721
|
-
|
|
981
|
+
function terminalWatchRecord(result) {
|
|
982
|
+
return recordValue(result.watch) ??
|
|
983
|
+
recordValue(result.terminal_watch) ??
|
|
984
|
+
result;
|
|
722
985
|
}
|
|
723
986
|
function finiteNumber(value) {
|
|
724
987
|
return typeof value === "number" && Number.isFinite(value)
|
|
@@ -762,6 +1025,16 @@ function formatManagedTurnLine(turn) {
|
|
|
762
1025
|
truncateText(context, 90)
|
|
763
1026
|
].filter(Boolean).join(" | ");
|
|
764
1027
|
}
|
|
1028
|
+
function formatTerminalWatchLine(watch) {
|
|
1029
|
+
return [
|
|
1030
|
+
nonEmptyString(watch.short_ref) ??
|
|
1031
|
+
nonEmptyString(watch.watch_id) ??
|
|
1032
|
+
"unknown",
|
|
1033
|
+
nonEmptyString(watch.agent) ?? "agent",
|
|
1034
|
+
nonEmptyString(watch.status) ?? "unknown",
|
|
1035
|
+
nonEmptyString(watch.terminal_id)
|
|
1036
|
+
].filter(Boolean).join(" | ");
|
|
1037
|
+
}
|
|
765
1038
|
function formatAvailableActions(label, resource) {
|
|
766
1039
|
const actions = recordValue(resource.available_actions);
|
|
767
1040
|
if (!actions) {
|
|
@@ -769,6 +1042,8 @@ function formatAvailableActions(label, resource) {
|
|
|
769
1042
|
}
|
|
770
1043
|
const displayedActions = new Set([
|
|
771
1044
|
"send",
|
|
1045
|
+
"watch",
|
|
1046
|
+
"unwatch",
|
|
772
1047
|
"respond",
|
|
773
1048
|
"status",
|
|
774
1049
|
"approve",
|