@scotthuang/agent-knock-knock 0.15.0 → 0.16.1

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 (159) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/connectors/deepseek-harness/README.md +53 -13
  3. package/connectors/pi/README.md +38 -11
  4. package/dist/src/claude-conversation-routing-cli-adapter.js +5 -1
  5. package/dist/src/claude-conversation-routing-cli-adapter.js.map +1 -1
  6. package/dist/src/claude-managed-send-route.d.ts +2 -0
  7. package/dist/src/claude-managed-send-route.js +20 -3
  8. package/dist/src/claude-managed-send-route.js.map +1 -1
  9. package/dist/src/claude-terminal-agent-observation.d.ts +2 -0
  10. package/dist/src/claude-terminal-agent-observation.js +18 -1
  11. package/dist/src/claude-terminal-agent-observation.js.map +1 -1
  12. package/dist/src/claude-terminal-registry-observation.d.ts +12 -0
  13. package/dist/src/claude-terminal-registry-observation.js +32 -0
  14. package/dist/src/claude-terminal-registry-observation.js.map +1 -1
  15. package/dist/src/claude-user-explicit-input-proof.d.ts +9 -0
  16. package/dist/src/claude-user-explicit-input-proof.js +90 -0
  17. package/dist/src/claude-user-explicit-input-proof.js.map +1 -0
  18. package/dist/src/cli-core.js +8 -4
  19. package/dist/src/cli-core.js.map +1 -1
  20. package/dist/src/cli-usage.js +1 -0
  21. package/dist/src/cli-usage.js.map +1 -1
  22. package/dist/src/conversation-list.d.ts +3 -3
  23. package/dist/src/conversation-list.js +38 -14
  24. package/dist/src/conversation-list.js.map +1 -1
  25. package/dist/src/conversation-routing-cli-adapter.js +49 -2
  26. package/dist/src/conversation-routing-cli-adapter.js.map +1 -1
  27. package/dist/src/conversation-usage-guidance.d.ts +4 -0
  28. package/dist/src/conversation-usage-guidance.js +240 -0
  29. package/dist/src/conversation-usage-guidance.js.map +1 -0
  30. package/dist/src/host-adapter.js +3 -2
  31. package/dist/src/host-adapter.js.map +1 -1
  32. package/dist/src/managed-session.d.ts +11 -0
  33. package/dist/src/managed-session.js +24 -1
  34. package/dist/src/managed-session.js.map +1 -1
  35. package/dist/src/native-store-authority-cli-adapter.d.ts +20 -0
  36. package/dist/src/native-store-authority-cli-adapter.js +105 -0
  37. package/dist/src/native-store-authority-cli-adapter.js.map +1 -0
  38. package/dist/src/native-store-authority-ledger.d.ts +3 -0
  39. package/dist/src/native-store-authority-ledger.js +46 -0
  40. package/dist/src/native-store-authority-ledger.js.map +1 -0
  41. package/dist/src/native-store-authority-projection.d.ts +6 -0
  42. package/dist/src/native-store-authority-projection.js +68 -0
  43. package/dist/src/native-store-authority-projection.js.map +1 -0
  44. package/dist/src/native-store-authority-runtime.d.ts +9 -0
  45. package/dist/src/native-store-authority-runtime.js +77 -0
  46. package/dist/src/native-store-authority-runtime.js.map +1 -0
  47. package/dist/src/native-store-authority-transfer.d.ts +31 -0
  48. package/dist/src/native-store-authority-transfer.js +172 -0
  49. package/dist/src/native-store-authority-transfer.js.map +1 -0
  50. package/dist/src/native-store-authority-watch.d.ts +9 -0
  51. package/dist/src/native-store-authority-watch.js +43 -0
  52. package/dist/src/native-store-authority-watch.js.map +1 -0
  53. package/dist/src/native-store-authority.d.ts +29 -0
  54. package/dist/src/native-store-authority.js +181 -0
  55. package/dist/src/native-store-authority.js.map +1 -0
  56. package/dist/src/semantic-tool-descriptions.js +22 -16
  57. package/dist/src/semantic-tool-descriptions.js.map +1 -1
  58. package/dist/src/semantic-tool-list-budget.js +2 -1
  59. package/dist/src/semantic-tool-list-budget.js.map +1 -1
  60. package/dist/src/semantic-tool-list-projection.d.ts +2 -2
  61. package/dist/src/semantic-tool-list-projection.js +23 -11
  62. package/dist/src/semantic-tool-list-projection.js.map +1 -1
  63. package/dist/src/semantic-tool-private-authority.d.ts +5 -0
  64. package/dist/src/semantic-tool-private-authority.js +68 -4
  65. package/dist/src/semantic-tool-private-authority.js.map +1 -1
  66. package/dist/src/semantic-tool-relay.d.ts +1 -0
  67. package/dist/src/semantic-tool-relay.js +12 -5
  68. package/dist/src/semantic-tool-relay.js.map +1 -1
  69. package/dist/src/semantic-tool-runtime.js +5 -37
  70. package/dist/src/semantic-tool-runtime.js.map +1 -1
  71. package/dist/src/semantic-tool-schemas.d.ts +25 -0
  72. package/dist/src/semantic-tool-schemas.js +26 -10
  73. package/dist/src/semantic-tool-schemas.js.map +1 -1
  74. package/dist/src/session-store.js +5 -1
  75. package/dist/src/session-store.js.map +1 -1
  76. package/dist/src/store-owner-identity.d.ts +24 -0
  77. package/dist/src/store-owner-identity.js +127 -0
  78. package/dist/src/store-owner-identity.js.map +1 -0
  79. package/dist/src/store-owner-process.d.ts +24 -0
  80. package/dist/src/store-owner-process.js +104 -0
  81. package/dist/src/store-owner-process.js.map +1 -0
  82. package/dist/src/store-owner-registry.d.ts +13 -0
  83. package/dist/src/store-owner-registry.js +158 -0
  84. package/dist/src/store-owner-registry.js.map +1 -0
  85. package/dist/src/store.d.ts +3 -1
  86. package/dist/src/store.js +5 -2
  87. package/dist/src/store.js.map +1 -1
  88. package/dist/src/terminal-action-contracts.js +45 -16
  89. package/dist/src/terminal-action-contracts.js.map +1 -1
  90. package/dist/src/terminal-action-projection.d.ts +1 -1
  91. package/dist/src/terminal-action-projection.js.map +1 -1
  92. package/dist/src/terminal-agent-bridge.js +8 -11
  93. package/dist/src/terminal-agent-bridge.js.map +1 -1
  94. package/dist/src/terminal-composer-classifier.d.ts +1 -0
  95. package/dist/src/terminal-composer-classifier.js +7 -32
  96. package/dist/src/terminal-composer-classifier.js.map +1 -1
  97. package/dist/src/terminal-dispatch-execution.d.ts +4 -1
  98. package/dist/src/terminal-dispatch-execution.js +3 -2
  99. package/dist/src/terminal-dispatch-execution.js.map +1 -1
  100. package/dist/src/terminal-dispatch-ledger-codec.js +1 -1
  101. package/dist/src/terminal-dispatch-ledger-codec.js.map +1 -1
  102. package/dist/src/terminal-dispatch-recovery-cli-adapter.js +2 -21
  103. package/dist/src/terminal-dispatch-recovery-cli-adapter.js.map +1 -1
  104. package/dist/src/terminal-dispatch-repository-cli-adapter.d.ts +3 -1
  105. package/dist/src/terminal-dispatch-repository-cli-adapter.js +3 -2
  106. package/dist/src/terminal-dispatch-repository-cli-adapter.js.map +1 -1
  107. package/dist/src/terminal-human-explicit-send-cli-adapter.js +3 -0
  108. package/dist/src/terminal-human-explicit-send-cli-adapter.js.map +1 -1
  109. package/dist/src/terminal-list-cli-adapter.d.ts +6 -0
  110. package/dist/src/terminal-list-cli-adapter.js +42 -22
  111. package/dist/src/terminal-list-cli-adapter.js.map +1 -1
  112. package/dist/src/terminal-list-facts.d.ts +5 -0
  113. package/dist/src/terminal-list-facts.js.map +1 -1
  114. package/dist/src/terminal-list-inventory.d.ts +1 -0
  115. package/dist/src/terminal-list-inventory.js +1 -0
  116. package/dist/src/terminal-list-inventory.js.map +1 -1
  117. package/dist/src/terminal-list-native-identity-recheck.d.ts +35 -0
  118. package/dist/src/terminal-list-native-identity-recheck.js +76 -0
  119. package/dist/src/terminal-list-native-identity-recheck.js.map +1 -0
  120. package/dist/src/terminal-list-ownership-service.d.ts +1 -0
  121. package/dist/src/terminal-list-ownership-service.js +21 -0
  122. package/dist/src/terminal-list-ownership-service.js.map +1 -1
  123. package/dist/src/terminal-list-projection-service.js +2 -1
  124. package/dist/src/terminal-list-projection-service.js.map +1 -1
  125. package/dist/src/terminal-monitor-decision-policy.d.ts +1 -1
  126. package/dist/src/terminal-mutation-cli-runtime.d.ts +7 -2
  127. package/dist/src/terminal-mutation-cli-runtime.js +11 -3
  128. package/dist/src/terminal-mutation-cli-runtime.js.map +1 -1
  129. package/dist/src/terminal-permission-control-cli-adapter.js +7 -0
  130. package/dist/src/terminal-permission-control-cli-adapter.js.map +1 -1
  131. package/dist/src/terminal-runtime-cli-adapter.d.ts +1 -0
  132. package/dist/src/terminal-runtime-cli-adapter.js +4 -1
  133. package/dist/src/terminal-runtime-cli-adapter.js.map +1 -1
  134. package/dist/src/terminal-status-cli-adapter.js +1 -0
  135. package/dist/src/terminal-status-cli-adapter.js.map +1 -1
  136. package/dist/src/terminal-status-facts.d.ts +1 -0
  137. package/dist/src/terminal-status-facts.js +8 -1
  138. package/dist/src/terminal-status-facts.js.map +1 -1
  139. package/dist/src/terminal-user-explicit-send-clear.d.ts +6 -12
  140. package/dist/src/terminal-user-explicit-send-clear.js +43 -64
  141. package/dist/src/terminal-user-explicit-send-clear.js.map +1 -1
  142. package/dist/src/terminal-user-explicit-send-policy.js +1 -0
  143. package/dist/src/terminal-user-explicit-send-policy.js.map +1 -1
  144. package/dist/src/terminal-watch-cli-adapter.js +3 -2
  145. package/dist/src/terminal-watch-cli-adapter.js.map +1 -1
  146. package/dist/src/terminal-watch-response-cli-adapter.js +9 -0
  147. package/dist/src/terminal-watch-response-cli-adapter.js.map +1 -1
  148. package/docs/bidirectional-agent-protocol.md +2 -2
  149. package/docs/callback-compatibility.md +2 -1
  150. package/docs/claude-2.1.285-compatibility.md +72 -10
  151. package/docs/claude-cli-direct.md +69 -1
  152. package/docs/list-output.md +97 -1
  153. package/docs/operator-guide.md +136 -9
  154. package/docs/quickstart-herdr.md +1 -1
  155. package/docs/quickstart-tmux.md +5 -3
  156. package/docs/storage-and-logging.md +10 -5
  157. package/docs/testing.md +5 -6
  158. package/package.json +1 -1
  159. package/templates/openclaw-skills/agent-knock-knock/SKILL.md +24 -9
@@ -0,0 +1,172 @@
1
+ import { randomUUID } from "node:crypto";
2
+ import { cliEnv } from "./cli-runtime-context.js";
3
+ import { canonicalJson } from "./canonical-json.js";
4
+ import { loadManagedSession, saveManagedSession, listManagedSessions, tryLoadManagedSession } from "./session-store.js";
5
+ import { withStoreWriterLease } from "./store.js";
6
+ import { captureStoreOwnerIdentity } from "./store-owner-identity.js";
7
+ import { readStoreOwnerInventory, registerStoreOwnerIdentity, probeStoreOwnerInventory } from "./store-owner-registry.js";
8
+ import { canonicalAuthorityStore, inspectNativeStoreAuthority, nativeAuthorityWorkSettled } from "./native-store-authority.js";
9
+ import { recordValue } from "./value-guards.js";
10
+ function readJournal(ledger) {
11
+ const journal = recordValue(ledger.store_authority_transfer);
12
+ if (!journal || journal.phase === "committed")
13
+ return undefined;
14
+ if (journal.version !== 1 || !journal.source_session || !journal.target_session ||
15
+ typeof journal.source_store_dir !== "string" || typeof journal.target_store_dir !== "string" ||
16
+ typeof journal.transfer_id !== "string" || !["prepared", "source_retired", "target_created"].includes(String(journal.phase))) {
17
+ throw new Error("Store authority transfer journal is invalid; preserve evidence and repair it before retrying");
18
+ }
19
+ return journal;
20
+ }
21
+ function verifySourceOwner(journal) {
22
+ const inventory = readStoreOwnerInventory(journal.source_store_dir);
23
+ if (inventory.fingerprint !== journal.source_inventory)
24
+ throw new Error("source Store owner registrations changed during transfer; no input sent");
25
+ if (journal.legacy_acknowledged && inventory.reason === "owner_inventory_absent")
26
+ return;
27
+ if (probeStoreOwnerInventory(inventory).state !== "dead")
28
+ throw new Error("source Store has an active or unverifiable owner; transfer refused; no input sent");
29
+ }
30
+ function prepareJournal(input, ledger) {
31
+ const inspection = inspectNativeStoreAuthority({ ...input, ledger });
32
+ if (!inspection.transferEligible || !inspection.session || !inspection.sourceStoreDir) {
33
+ throw new Error(`Store authority transfer refused: ${inspection.reason ?? inspection.state}; no input sent`);
34
+ }
35
+ if (input.automatic ? !inspection.automaticEligible : inspection.fingerprint !== input.expectedAuthorityToken) {
36
+ throw new Error("Store authority changed or is not automatically reclaimable; refresh AKK list; no input sent");
37
+ }
38
+ if (inspection.ownerStatus === "legacy" && input.maintenanceAcknowledgement !== true) {
39
+ throw new Error("legacy Store owner is unknown; stop all associated Hosts/writers, then explicitly supply maintenance_acknowledgement=true");
40
+ }
41
+ const source = inspection.session;
42
+ const now = new Date().toISOString();
43
+ const id = randomUUID();
44
+ const target = { ...source, revision: undefined, status: "bound",
45
+ binding: { ...source.binding, binding_id: randomUUID(), generation: source.binding.generation + 1,
46
+ bound_at: now, last_verified_at: now },
47
+ updated_at: now, detached_at: undefined, quarantine_reason: undefined,
48
+ authority_transfer: undefined,
49
+ authority_received: { transfer_id: id, source_store_dir: inspection.sourceStoreDir, received_at: now } };
50
+ return { version: 1, transfer_id: id, phase: "prepared", source_store_dir: inspection.sourceStoreDir,
51
+ target_store_dir: canonicalAuthorityStore(input.storeDir),
52
+ source_inventory: readStoreOwnerInventory(inspection.sourceStoreDir).fingerprint,
53
+ source_session: source, target_session: JSON.parse(JSON.stringify(target)),
54
+ generation: (inspection.generation ?? 1) + 1,
55
+ automatic: input.automatic === true, legacy_acknowledged: inspection.ownerStatus === "legacy",
56
+ started_at: now, initial_authority_token: input.expectedAuthorityToken };
57
+ }
58
+ export function completedNativeStoreAuthorityReceipt(input, ledger) {
59
+ const journal = recordValue(ledger?.store_authority_transfer);
60
+ if (!journal || journal.phase !== "committed" || journal.target_store_dir !== canonicalAuthorityStore(input.storeDir) ||
61
+ (input.automatic ? journal.automatic !== true : !input.expectedAuthorityToken || input.expectedAuthorityToken !== journal.initial_authority_token))
62
+ return undefined;
63
+ return { transferred: true, transfer_id: String(journal.transfer_id),
64
+ session_id: String(recordValue(journal.target_session)?.session_id), store_dir: String(journal.target_store_dir) };
65
+ }
66
+ function targetAvailable(journal) {
67
+ const existing = listManagedSessions(journal.target_store_dir);
68
+ for (const session of existing) {
69
+ if ((session.session_id === journal.target_session.session_id ||
70
+ session.binding?.native_thread_id === journal.target_session.binding?.native_thread_id) &&
71
+ session.authority_received?.transfer_id !== journal.transfer_id) {
72
+ throw new Error("destination Store already has a competing Session; transfer refused");
73
+ }
74
+ }
75
+ }
76
+ /** Caller holds the shared terminal lock. Store leases are deliberately sequential. */
77
+ export function transferNativeStoreAuthorityWhileLocked(input, repository) {
78
+ let ledger = repository.load(input.terminalControl);
79
+ if (!ledger || !repository.matchesControl(ledger, input.terminalControl)) {
80
+ throw new Error("Store authority terminal incarnation changed; refresh AKK list; no input sent");
81
+ }
82
+ const completed = completedNativeStoreAuthorityReceipt(input, ledger);
83
+ if (completed)
84
+ return completed;
85
+ let journal = readJournal(ledger);
86
+ if (journal) {
87
+ const inspection = inspectNativeStoreAuthority({ ...input, ledger });
88
+ if (canonicalAuthorityStore(input.storeDir) !== journal.target_store_dir ||
89
+ (input.automatic ? !journal.automatic : inspection.fingerprint !== input.expectedAuthorityToken)) {
90
+ throw new Error("unfinished Store authority transfer belongs to another destination or snapshot");
91
+ }
92
+ }
93
+ else
94
+ journal = prepareJournal(input, ledger);
95
+ const transaction = journal;
96
+ const persist = (phase) => {
97
+ transaction.phase = phase;
98
+ ledger = { ...ledger, store_authority_transfer: { ...transaction } };
99
+ repository.save(input.terminalControl, ledger, { authorityTransfer: true });
100
+ };
101
+ // Upgrade/check destination before installing a durable fence. Once prepared,
102
+ // every crash point is resumed by this journal, without any terminal input.
103
+ withStoreWriterLease(transaction.target_store_dir, () => {
104
+ targetAvailable(transaction);
105
+ const owner = captureStoreOwnerIdentity(transaction.target_store_dir, cliEnv());
106
+ registerStoreOwnerIdentity(owner);
107
+ if (!readStoreOwnerInventory(transaction.target_store_dir).complete)
108
+ throw new Error("destination owner inventory is incomplete; source authority unchanged");
109
+ transaction.target_owner ??= owner;
110
+ });
111
+ withStoreWriterLease(transaction.source_store_dir, () => {
112
+ verifySourceOwner(transaction);
113
+ const source = loadManagedSession(transaction.source_store_dir, transaction.source_session.session_id);
114
+ if (source.authority_transfer?.transfer_id === transaction.transfer_id)
115
+ return;
116
+ if (canonicalJson(source) !== canonicalJson(transaction.source_session) ||
117
+ !nativeAuthorityWorkSettled(transaction.source_store_dir, source)) {
118
+ throw new Error("source Session/work changed during authority transfer; no input sent");
119
+ }
120
+ persist("prepared");
121
+ saveManagedSession(transaction.source_store_dir, { ...source, status: "quarantined",
122
+ quarantine_reason: "native Store authority transferred", updated_at: transaction.started_at,
123
+ authority_transfer: { transfer_id: transaction.transfer_id, target_store_dir: transaction.target_store_dir,
124
+ transferred_at: transaction.started_at } }, { expectedRevision: source.revision });
125
+ persist("source_retired");
126
+ });
127
+ withStoreWriterLease(transaction.target_store_dir, () => {
128
+ verifySourceOwner(transaction);
129
+ targetAvailable(transaction);
130
+ const present = tryLoadManagedSession(transaction.target_store_dir, transaction.target_session.session_id);
131
+ const { revision: _revision, ...presentBody } = present ?? {};
132
+ if (present && canonicalJson(presentBody) !== canonicalJson(transaction.target_session)) {
133
+ throw new Error("destination Session changed before authority transfer commit; preserve the journal and inspect the destination");
134
+ }
135
+ if (!present)
136
+ saveManagedSession(transaction.target_store_dir, transaction.target_session, { expectedRevision: null });
137
+ persist("target_created");
138
+ const owner = captureStoreOwnerIdentity(transaction.target_store_dir, cliEnv());
139
+ registerStoreOwnerIdentity(owner);
140
+ const session = loadManagedSession(transaction.target_store_dir, transaction.target_session.session_id);
141
+ // No old Turn is adopted or replayed. Its callback/history stay in source.
142
+ ledger = { status: "resolved", store_dir: transaction.target_store_dir,
143
+ native_thread_id: session.binding.native_thread_id, session_id: session.session_id,
144
+ binding: session.binding, resolved_at: new Date().toISOString(),
145
+ reason: "native Store authority transferred without terminal input",
146
+ store_authority: { version: 1, generation: transaction.generation,
147
+ store_dir: transaction.target_store_dir, owner },
148
+ store_authority_transfer: { ...transaction, phase: "committed" } };
149
+ repository.save(input.terminalControl, ledger, { authorityTransfer: true });
150
+ });
151
+ return { transferred: true, transfer_id: transaction.transfer_id,
152
+ session_id: transaction.target_session.session_id, store_dir: transaction.target_store_dir };
153
+ }
154
+ export function transferNativeStoreAuthority(input, repository) {
155
+ const release = repository.acquire(input.storeDir, input.terminalControl);
156
+ try {
157
+ return transferNativeStoreAuthorityWhileLocked(input, repository);
158
+ }
159
+ finally {
160
+ release();
161
+ }
162
+ }
163
+ /** Called after the terminal lock and before the destination Store lease. */
164
+ export function recoverNativeStoreAuthorityWhileLocked(input, repository) {
165
+ const ledger = repository.load(input.terminalControl);
166
+ const inspection = inspectNativeStoreAuthority({ ...input, ledger });
167
+ const journal = ledger && readJournal(ledger);
168
+ if (inspection.automaticEligible || journal?.automatic && journal.target_store_dir === canonicalAuthorityStore(input.storeDir)) {
169
+ transferNativeStoreAuthorityWhileLocked({ ...input, automatic: true }, repository);
170
+ }
171
+ }
172
+ //# sourceMappingURL=native-store-authority-transfer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"native-store-authority-transfer.js","sourceRoot":"","sources":["../../src/native-store-authority-transfer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AACxH,OAAO,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAClD,OAAO,EAAE,yBAAyB,EAA2B,MAAM,2BAA2B,CAAC;AAC/F,OAAO,EAAE,uBAAuB,EAAE,0BAA0B,EAAE,wBAAwB,EAAE,MAAM,2BAA2B,CAAC;AAC1H,OAAO,EAAE,uBAAuB,EAAE,2BAA2B,EAAE,0BAA0B,EAAE,MAAM,6BAA6B,CAAC;AAI/H,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AA2BhD,SAAS,WAAW,CAAC,MAAc;IACjC,MAAM,OAAO,GAAG,WAAW,CAAC,MAAM,CAAC,wBAAwB,CAAC,CAAC;IAC7D,IAAI,CAAC,OAAO,IAAI,OAAO,CAAC,KAAK,KAAK,WAAW;QAAE,OAAO,SAAS,CAAC;IAChE,IAAI,OAAO,CAAC,OAAO,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,cAAc,IAAI,CAAC,OAAO,CAAC,cAAc;QAC7E,OAAO,OAAO,CAAC,gBAAgB,KAAK,QAAQ,IAAI,OAAO,OAAO,CAAC,gBAAgB,KAAK,QAAQ;QAC5F,OAAO,OAAO,CAAC,WAAW,KAAK,QAAQ,IAAI,CAAC,CAAC,UAAU,EAAE,gBAAgB,EAAE,gBAAgB,CAAC,CAAC,QAAQ,CAAC,MAAM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C,KAA6D,EAClH,UAAgD;IAChD,MAAM,MAAM,GAAG,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC;IACtD,MAAM,UAAU,GAAG,2BAA2B,CAAC,EAAE,GAAG,KAAK,EAAE,MAAM,EAAE,CAAC,CAAC;IACrE,MAAM,OAAO,GAAG,MAAM,IAAI,WAAW,CAAC,MAAM,CAAC,CAAC;IAC9C,IAAI,UAAU,CAAC,iBAAiB,IAAI,OAAO,EAAE,SAAS,IAAI,OAAO,CAAC,gBAAgB,KAAK,uBAAuB,CAAC,KAAK,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC/H,uCAAuC,CAAC,EAAE,GAAG,KAAK,EAAE,SAAS,EAAE,IAAI,EAAE,EAAE,UAAU,CAAC,CAAC;IACrF,CAAC;AACH,CAAC"}
@@ -0,0 +1,9 @@
1
+ import { type TerminalControlRef } from "./terminal-control-ref.js";
2
+ /** Register the creating Host atomically with the Watch's durable authority. */
3
+ export declare function withNativeAuthorityWatchOwner<T>(storeDir: string, create: () => T): T;
4
+ /** Read only: a transfer must retain outstanding Watch observation/callback ownership. */
5
+ export declare function hasOutstandingNativeAuthorityWatch(input: {
6
+ storeDir: string;
7
+ terminalControl: TerminalControlRef;
8
+ nativeThreadId?: string;
9
+ }): boolean;
@@ -0,0 +1,43 @@
1
+ import { terminalControlEvidenceMatches } from "./terminal-control-ref.js";
2
+ import { listTerminalWatches } from "./terminal-watch-store.js";
3
+ import { cliEnv } from "./cli-runtime-context.js";
4
+ import { captureStoreOwnerIdentity } from "./store-owner-identity.js";
5
+ import { registerStoreOwnerIdentity } from "./store-owner-registry.js";
6
+ import { withStoreWriterLease } from "./store.js";
7
+ /** Register the creating Host atomically with the Watch's durable authority. */
8
+ export function withNativeAuthorityWatchOwner(storeDir, create) {
9
+ return withStoreWriterLease(storeDir, () => {
10
+ registerStoreOwnerIdentity(captureStoreOwnerIdentity(storeDir, cliEnv()));
11
+ return create();
12
+ });
13
+ }
14
+ function watchNativeThreadId(watch) {
15
+ const anchor = watch.anchor;
16
+ if (anchor.schema === "agent-knock-knock/claude-human-started-active-task-anchor")
17
+ return anchor.session_id;
18
+ if (anchor.schema === "agent-knock-knock/claude-user-explicit-fallback-watch-anchor")
19
+ return anchor.transcript_anchor.session_id;
20
+ if (anchor.schema === "agent-knock-knock/codex-human-started-active-task-anchor" ||
21
+ anchor.schema === "agent-knock-knock/codex-paginated-task-anchor")
22
+ return anchor.native_thread_id;
23
+ if (anchor.schema !== "agent-knock-knock/codex-user-explicit-fallback-watch-anchor")
24
+ return undefined;
25
+ const checkpoint = watch.observation_checkpoint;
26
+ if ("schema" in checkpoint && checkpoint.schema === "agent-knock-knock/codex-user-explicit-fallback-watch-checkpoint") {
27
+ const accepted = checkpoint.accepted_identity?.native_thread_id;
28
+ if (accepted)
29
+ return accepted;
30
+ }
31
+ return anchor.acceptance_anchor.version === 1 ? anchor.acceptance_anchor.native_thread_id : undefined;
32
+ }
33
+ /** Read only: a transfer must retain outstanding Watch observation/callback ownership. */
34
+ export function hasOutstandingNativeAuthorityWatch(input) {
35
+ return listTerminalWatches(input.storeDir).some(watch => {
36
+ const nativeThreadId = watchNativeThreadId(watch);
37
+ const related = nativeThreadId && input.nativeThreadId
38
+ ? nativeThreadId.toLowerCase() === input.nativeThreadId.toLowerCase()
39
+ : terminalControlEvidenceMatches(watch.terminal.terminal_endpoint, input.terminalControl);
40
+ return related && (watch.status === "active" || watch.notification_outbox.some(notification => notification.status !== "delivered" && notification.status !== "superseded"));
41
+ });
42
+ }
43
+ //# sourceMappingURL=native-store-authority-watch.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"native-store-authority-watch.js","sourceRoot":"","sources":["../../src/native-store-authority-watch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,8BAA8B,EAA2B,MAAM,2BAA2B,CAAC;AACpG,OAAO,EAAE,mBAAmB,EAAsB,MAAM,2BAA2B,CAAC;AACpF,OAAO,EAAE,MAAM,EAAE,MA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AiB,CAAC,gBAAgB,CAAC,CAAC,CAAC,SAAS,CAAC;AACxG,CAAC;AAED,0FAA0F;AAC1F,MAAM,UAAU,kCAAkC,CAAC,KAIlD;IACC,OAAO,mBAAmB,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE;QACtD,MAAM,cAAc,GAAG,mBAAmB,CAAC,KAAK,CAAC,CAAC;QAClD,MAAM,OAAO,GAAG,cAAc,IAAI,KAAK,CAAC,cAAc;YACpD,CAAC,CAAC,cAAc,CAAC,WAAW,EAAE,KAAK,KAAK,CAAC,cAAc,CAAC,WAAW,EAAE;YACrE,CAAC,CAAC,8BAA8B,CAAC,KAAK,CAAC,QAAQ,CAAC,iBAAiB,EAAE,KAAK,CAAC,eAAe,CAAC,CAAC;QAC5F,OAAO,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,KAAK,QAAQ,IAAI,KAAK,CAAC,mBAAmB,CAAC,IAAI,CAAC,YAAY,CAAC,EAAE,CAC5F,YAAY,CAAC,MAAM,KAAK,WAAW,IAAI,YAAY,CAAC,MAAM,KAAK,YAAY,CAAC,CAAC,CAAC;IAClF,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,29 @@
1
+ import type { ManagedSessionState } from "./managed-session.js";
2
+ import { type TerminalControlRef } from "./terminal-control-ref.js";
3
+ import type { TerminalDispatchLedgerDocument } from "./terminal-dispatch-ledger-codec.js";
4
+ export interface NativeStoreAuthorityInspection {
5
+ state: "none" | "current" | "conflict" | "transferring";
6
+ reason?: string;
7
+ sourceStoreDir?: string;
8
+ sessionId?: string;
9
+ generation?: number;
10
+ fingerprint?: string;
11
+ transferEligible: boolean;
12
+ automaticEligible: boolean;
13
+ ownerStatus: "alive" | "dead" | "unknown" | "legacy";
14
+ session?: ManagedSessionState;
15
+ }
16
+ export declare function canonicalAuthorityStore(storeDir: string): string;
17
+ export declare function nativeAuthorityStore(ledger: TerminalDispatchLedgerDocument): string | undefined;
18
+ export declare function nativeAuthorityThreadIds(ledger: TerminalDispatchLedgerDocument): string[];
19
+ /** A resolved dispatch releases the Turn, not this native thread's Store authority. */
20
+ export declare function nativeAuthorityWorkSettled(storeDir: string, session: ManagedSessionState): boolean;
21
+ export declare function nativeAuthorityFingerprint(value: unknown): string;
22
+ /** Shared, read-only authority predicate for List, Status and mutation preflight. */
23
+ export declare function inspectNativeStoreAuthority(input: {
24
+ ledger?: TerminalDispatchLedgerDocument;
25
+ terminalControl: TerminalControlRef;
26
+ nativeThreadId?: string;
27
+ storeDir: string;
28
+ }): NativeStoreAuthorityInspection;
29
+ export declare function assertNativeStoreAuthorityCurrent(input: Parameters<typeof inspectNativeStoreAuthority>[0]): void;
@@ -0,0 +1,181 @@
1
+ import { createHash } from "node:crypto";
2
+ import fs from "node:fs";
3
+ import path from "node:path";
4
+ import { canonicalJson } from "./canonical-json.js";
5
+ import { listDeferredForegroundTransfers } from "./deferred-foreground-transfer.js";
6
+ import { isFinalDeferredForegroundTransferStatus } from "./deferred-foreground-transfer-policy.js";
7
+ import { listManagedSessions, listNativeThreadTransitions } from "./session-store.js";
8
+ import { listConversations, pathsForConversationDir, storeManifestPath } from "./store.js";
9
+ import { readJsonFileNoFollow } from "./durable-json-file.js";
10
+ import { hasOutstandingNativeAuthorityWatch } from "./native-store-authority-watch.js";
11
+ import { isSessionSendBlockingStatus, sessionIdForConversation } from "./protocol.js";
12
+ import { terminalControlEvidence, terminalControlEvidenceMatches } from "./terminal-control-ref.js";
13
+ import { isStoreOwnerIdentity, storeOwnerKind } from "./store-owner-identity.js";
14
+ import { readStoreOwnerInventory, probeStoreOwnerInventory } from "./store-owner-registry.js";
15
+ import { nonBlankString, recordValue } from "./value-guards.js";
16
+ export function canonicalAuthorityStore(storeDir) {
17
+ const resolved = path.resolve(storeDir);
18
+ try {
19
+ return fs.realpathSync(resolved);
20
+ }
21
+ catch {
22
+ return resolved;
23
+ }
24
+ }
25
+ export function nativeAuthorityStore(ledger) {
26
+ const stored = nonBlankString(ledger.store_dir);
27
+ if (stored)
28
+ return canonicalAuthorityStore(stored);
29
+ const statePath = nonBlankString(ledger.state_path);
30
+ if (!statePath)
31
+ return undefined;
32
+ try {
33
+ return canonicalAuthorityStore(pathsForConversationDir(path.dirname(statePath)).storeDir);
34
+ }
35
+ catch {
36
+ return undefined;
37
+ }
38
+ }
39
+ export function nativeAuthorityThreadIds(ledger) {
40
+ const binding = recordValue(ledger.binding);
41
+ return [ledger.native_thread_id, binding?.native_thread_id,
42
+ ledger.before_native_thread_id, ledger.target_native_thread_id]
43
+ .flatMap(value => nonBlankString(value)?.toLowerCase() ?? []);
44
+ }
45
+ /** A resolved dispatch releases the Turn, not this native thread's Store authority. */
46
+ export function nativeAuthorityWorkSettled(storeDir, session) {
47
+ if (!["bound", "detached"].includes(session.status) || session.authority_transfer)
48
+ return false;
49
+ const turns = listConversations(storeDir).filter(turn => sessionIdForConversation(turn) === session.session_id);
50
+ if (turns.some(turn => isSessionSendBlockingStatus(turn.status) ||
51
+ recordValue(turn.approval_state)?.blocked === true ||
52
+ [turn.callback_delivery, turn.callback_notification_delivery].some(hasUnsettledAuthorityCallback)))
53
+ return false;
54
+ if (listNativeThreadTransitions(storeDir).some(transition => (transition.source_session_id === session.session_id || transition.target_session_id === session.session_id) &&
55
+ !["committed", "aborted"].includes(transition.status)))
56
+ return false;
57
+ if (session.binding && hasOutstandingNativeAuthorityWatch({ storeDir,
58
+ terminalControl: session.binding.terminal_control, nativeThreadId: session.binding.native_thread_id }))
59
+ return false;
60
+ // Conservatively wait for all Store transfers: a callback/deferred handoff may
61
+ // carry authority indirectly through a Turn rather than the Session id.
62
+ return !listDeferredForegroundTransfers(storeDir).some(transfer => !isFinalDeferredForegroundTransferStatus(transfer.status));
63
+ }
64
+ function hasUnsettledAuthorityCallback(value) {
65
+ const delivery = recordValue(value);
66
+ return Boolean(delivery && !["delivered", "accepted", "superseded"].includes(String(delivery.status)));
67
+ }
68
+ export function nativeAuthorityFingerprint(value) {
69
+ return createHash("sha256").update(canonicalJson(value)).digest("hex");
70
+ }
71
+ /** Shared, read-only authority predicate for List, Status and mutation preflight. */
72
+ export function inspectNativeStoreAuthority(input) {
73
+ const result = {
74
+ state: "none", ownerStatus: "legacy", transferEligible: false, automaticEligible: false
75
+ };
76
+ const ledger = input.ledger;
77
+ if (!ledger)
78
+ return result;
79
+ const ids = nativeAuthorityThreadIds(ledger);
80
+ if (!ids.length || input.nativeThreadId && !ids.includes(input.nativeThreadId.toLowerCase()))
81
+ return result;
82
+ const evidence = ledger.terminal_endpoint ?? ledger.terminal_control;
83
+ if (!terminalControlEvidenceMatches(evidence, input.terminalControl, { requireProcessAnchor: false })) {
84
+ return { ...result, state: "conflict", reason: "authority_terminal_identity_unverified" };
85
+ }
86
+ result.sourceStoreDir = nativeAuthorityStore(ledger);
87
+ result.sessionId = nonBlankString(ledger.session_id ?? ledger.target_session_id);
88
+ const authority = recordValue(ledger.store_authority);
89
+ result.generation = Number(authority?.generation ?? 1);
90
+ const transfer = recordValue(ledger.store_authority_transfer);
91
+ const inProgress = transfer && transfer.phase !== "committed";
92
+ result.state = inProgress ? "transferring" : result.sourceStoreDir === canonicalAuthorityStore(input.storeDir) ? "current" : "conflict";
93
+ if (result.state === "current")
94
+ return result;
95
+ result.reason = inProgress ? "store_authority_transfer_incomplete" : "native_thread_authoritative_in_another_store";
96
+ if (!result.sourceStoreDir || !result.sessionId) {
97
+ result.reason = "authority_store_or_session_unverified";
98
+ return result;
99
+ }
100
+ return inspectForeignStoreAuthority(input, ledger, result);
101
+ }
102
+ function inspectForeignStoreAuthority(input, ledger, result) {
103
+ const sourceStoreDir = result.sourceStoreDir;
104
+ const ids = nativeAuthorityThreadIds(ledger);
105
+ const authority = recordValue(ledger.store_authority);
106
+ const transfer = recordValue(ledger.store_authority_transfer);
107
+ const inProgress = transfer && transfer.phase !== "committed";
108
+ try {
109
+ const inventory = readStoreOwnerInventory(sourceStoreDir);
110
+ result.ownerStatus = inspectStoreAuthorityOwner(ledger.store_authority, inventory, sourceStoreDir);
111
+ const sessions = listManagedSessions(sourceStoreDir);
112
+ const session = sessions.find(value => value.session_id === result.sessionId);
113
+ if (!session || !session.binding || !ids.includes(session.binding.native_thread_id?.toLowerCase() ?? "")) {
114
+ result.reason = "authority_session_binding_unverified";
115
+ return result;
116
+ }
117
+ result.session = session;
118
+ result.fingerprint = nativeAuthorityFingerprint({ ledger, session, inventory: inventory.fingerprint,
119
+ targetStore: canonicalAuthorityStore(input.storeDir), terminal: terminalControlEvidence(input.terminalControl) });
120
+ if (inProgress)
121
+ return inspectPendingTransfer(result, transfer, inventory.fingerprint, input.storeDir);
122
+ if (ledger.status !== "resolved" || !nativeAuthorityWorkSettled(sourceStoreDir, session)) {
123
+ result.reason = "authority_has_unresolved_work";
124
+ return result;
125
+ }
126
+ if (["alive", "unknown"].includes(result.ownerStatus)) {
127
+ result.reason = `authority_owner_${result.ownerStatus}`;
128
+ return result;
129
+ }
130
+ result.transferEligible = true;
131
+ result.automaticEligible = automaticOwnerEvidence(result, authority, inventory);
132
+ return result;
133
+ }
134
+ catch {
135
+ return { ...result, reason: "authority_evidence_unreadable", transferEligible: false, automaticEligible: false };
136
+ }
137
+ }
138
+ function inspectStoreAuthorityOwner(value, inventory, sourceStoreDir) {
139
+ const authority = recordValue(value);
140
+ if (value !== undefined && (!authority || authority.version !== 1 || !isStoreOwnerIdentity(authority.owner)))
141
+ return "unknown";
142
+ if (authority && (canonicalAuthorityStore(String(authority.store_dir)) !== sourceStoreDir ||
143
+ !inventory.owners.some(owner => canonicalJson(owner) === canonicalJson(authority.owner))))
144
+ return "unknown";
145
+ if (!authority && inventory.reason === "owner_inventory_absent")
146
+ return "legacy";
147
+ const state = probeStoreOwnerInventory(inventory).state;
148
+ if (state !== "dead")
149
+ return state;
150
+ const manifest = recordValue(readJsonFileNoFollow(storeManifestPath(sourceStoreDir), "Store manifest"));
151
+ return !authority || authority.legacy_owner_coverage === true || manifest?.owner_registration !== "required" ? "legacy" : "dead";
152
+ }
153
+ function automaticOwnerEvidence(result, authority, inventory) {
154
+ return result.ownerStatus === "dead" && isStoreOwnerIdentity(authority?.owner) && inventory.complete &&
155
+ inventory.owners.some(owner => canonicalJson(owner) === canonicalJson(authority.owner)) &&
156
+ inventory.owners.every(owner => owner.store_kind === "ephemeral") &&
157
+ storeOwnerKind(result.sourceStoreDir, { AKK_EPHEMERAL_STORE: "1" }) === "ephemeral";
158
+ }
159
+ function inspectPendingTransfer(result, transfer, inventoryFingerprint, storeDir) {
160
+ if (transfer.source_inventory !== inventoryFingerprint) {
161
+ result.reason = "authority_owner_registrations_changed";
162
+ return result;
163
+ }
164
+ if (result.ownerStatus === "alive" || result.ownerStatus === "unknown" ||
165
+ result.ownerStatus === "legacy" && transfer.legacy_acknowledged !== true) {
166
+ result.reason = `authority_owner_${result.ownerStatus}`;
167
+ return result;
168
+ }
169
+ result.transferEligible = canonicalAuthorityStore(String(transfer.target_store_dir)) === canonicalAuthorityStore(storeDir);
170
+ return result;
171
+ }
172
+ export function assertNativeStoreAuthorityCurrent(input) {
173
+ const inspected = inspectNativeStoreAuthority(input);
174
+ if (!["conflict", "transferring"].includes(inspected.state))
175
+ return;
176
+ throw new Error(`terminal ${input.terminalControl.target} native thread is authoritative in another Store ` +
177
+ `${inspected.sourceStoreDir ?? "(unverified)"}: ${inspected.reason}. Refresh AKK list and use its ` +
178
+ "transfer_store_authority action (agent_knock_knock_reconcile_binding operation=transfer_store_authority). " +
179
+ "Active or unverifiable owners must be stopped/repaired first; do not delete the Store or runtime ledger.");
180
+ }
181
+ //# sourceMappingURL=native-store-authority.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"native-store-authority.js","sourceRoot":"","sources":["../../src/native-store-authority.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,aAAa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;IACxG,MAAM,SAAS,GAAG,2BAA2B,CAAC,KAAK,CAAC,CAAC;IACrD,IAAI,CAAC,CAAC,UAAU,EAAE,cAAc,CAAC,CAAC,QAAQ,CAAC,SAAS,CAAC,KAAK,CAAC;QAAE,OAAO;IACpE,MAAM,IAAI,KAAK,CAAC,YAAY,KAAK,CAAC,eAAe,CAAC,MAAM,mDAAmD;QACzG,GAAG,SAAS,CAAC,cAAc,IAAI,cAAc,KAAK,SAAS,CAAC,MAAM,iCAAiC;QACnG,4GAA4G;QAC5G,0GAA0G,CAAC,CAAC;AAChH,CAAC"}
@@ -50,11 +50,11 @@ export const semanticToolDescriptions = {
50
50
  "callable with a compatibility warning. AKK refreshes lifecycle authority " +
51
51
  "privately. Never send /clear as ordinary task text. This creates a new AKK " +
52
52
  "Session but no Turn.",
53
- reconcile_binding: "Detach one exact conflicting managed Session binding without adopting the " +
54
- "live replacement thread. Pass only the advertised terminal_id and " +
55
- "conflicting_session_id after explicit user confirmation; AKK refreshes all " +
56
- "revision and binding authority privately. This sends no coding-agent input " +
57
- "and creates no Turn.",
53
+ reconcile_binding: "Recover only the exact action advertised by fresh List after explicit user confirmation. " +
54
+ "The original terminal_id + conflicting_session_id form detaches that binding without adopting the live thread. " +
55
+ "For transfer_store_authority, pass operation: transfer_store_authority and the advertised terminal_id to move settled native-thread Store authority to this Host's Store. " +
56
+ "If the action requires maintenance_acknowledgement, pass true only after the user confirms every associated source-Store Host and old writer has stopped; idle Claude/Codex does not prove this. " +
57
+ "AKK consumes the displayed offer, refreshes private fences, and refuses active or unverifiable owners. Never supply tokens or Store paths. This sends no coding-agent input and creates no Turn; refresh List afterward.",
58
58
  resume_thread: "Resume one exact structurally verified historical native thread after " +
59
59
  "explicit user intent. A valid unverified agent version remains callable with " +
60
60
  "a compatibility warning. Pass only terminal_id and one complete " +
@@ -89,17 +89,21 @@ export const semanticToolDescriptions = {
89
89
  "request and may use session_id or terminal_id exactly as advertised. " +
90
90
  "The physical fallback rules below apply to retained legacy routes/receipts and other explicitly advertised terminal_user_explicit paths; " +
91
91
  "new ordinary Claude sends require managed terminal delivery and cannot degrade to unmanaged work after a Store or ownership failure. " +
92
+ "When List advertises a physical Send for a window whose native session is unresolved, use its exact terminal_id; " +
93
+ "AKK can submit through that interactive window, including one displaying a background session, without claiming background-task acceptance or completion. " +
92
94
  "terminal_user_explicit requires one exact live physical terminal/process, a " +
93
95
  "scanned non-blocked approval state, and no input-owning native " +
94
- "questionnaire/editor, menu, or read-only viewer; parsed working activity, " +
95
- "Codex rollout ambiguity, AKK management state, ordinary main-Composer " +
96
+ "questionnaire/editor, menu, or read-only viewer. Codex parsed working activity, " +
97
+ "rollout ambiguity, AKK management state, ordinary main-Composer " +
96
98
  "visibility, stability, exactness, and existing draft contents do not veto " +
97
- "physical delivery. Profiled Codex 0.154.0/0.155.1 exact collapsed " +
99
+ "Codex physical delivery. Claude requires an empty recognized main Composer, a known native footer, " +
100
+ "and no running or unproven foreground turn; background shells alone do not block Send. Profiled Codex 0.154.0/0.155.1 exact collapsed " +
98
101
  "async-question summaries remain sendable, while expanded, clipped, or " +
99
102
  "ambiguous editors receive zero input. Codex sends C-u once to replace the " +
100
- "current Composer; Claude Code uses a sentinel-backed native C-s stash-clear " +
101
- "transaction that is independent of the cursor position and does not " +
102
- "interrupt an active turn, then proves the main Composer empty. Each injects " +
103
+ "current Composer. Claude refuses an existing stashed draft before input, then uses one C-s on a freshly empty Composer " +
104
+ "to check for a hidden stash. Restored content stops task submission and remains for the user; AKK writes no sentinel " +
105
+ "and deletes no draft. An uncertain probe is not automatically retried. Failure gives manual recovery instructions; " +
106
+ "no cleanup runs after Enter. Each injects " +
103
107
  "the request, waits through the paste window, and dispatches Enter exactly " +
104
108
  "once without a post-text Composer veto. A source-less Codex terminal freezes " +
105
109
  "all current rollout roots before input, then promotes a provisional " +
@@ -269,16 +273,18 @@ export const semanticCommandGuidance = [
269
273
  "mode. An uncertain result must not be retried automatically.",
270
274
  "Use /akk <task> when exactly one send-ready coding-agent terminal pane " +
271
275
  "should receive new work. Send-ready means an exact live process and terminal " +
272
- "plus a scanned, non-blocked approval state. Parsed working activity and " +
276
+ "plus a scanned, non-blocked approval state. For Codex, parsed working activity and " +
273
277
  "ordinary main-Composer visibility, stability, exactness, or existing draft " +
274
- "contents do not veto this user-priority path. A proven input-owning native " +
278
+ "contents do not veto this user-priority path. Claude requires an empty recognized main Composer, " +
279
+ "a known native footer, and no running or unproven foreground turn; background shells alone do not block Send. A proven input-owning native " +
275
280
  "approval, questionnaire/editor, menu, or read-only viewer remains a " +
276
281
  "zero-input boundary; profiled Codex 0.154.0/0.155.1 exact collapsed " +
277
282
  "async-question summaries remain sendable, while expanded, clipped, or " +
278
283
  "ambiguous editors do not. Codex sends C-u once to replace the current " +
279
- "Composer; Claude Code uses a sentinel-backed native C-s stash-clear " +
280
- "transaction that is independent of the cursor position and does not " +
281
- "interrupt an active turn, then proves the main Composer empty. Each injects " +
284
+ "Composer. Claude refuses an existing stashed draft before input, then uses one C-s on a freshly empty Composer " +
285
+ "to check for a hidden stash. Restored content stops task submission and remains for the user; AKK writes no sentinel " +
286
+ "and deletes no draft. An uncertain probe is not automatically retried. Failure gives manual recovery instructions; " +
287
+ "no cleanup runs after Enter. Each injects " +
282
288
  "the request, waits through the paste window, and dispatches Enter exactly " +
283
289
  "once; after text injection, no Composer observation may veto Enter. Managed " +
284
290
  "Send may still require exact empty before input, while native inspection and " +
@@ -1 +1 @@
1
- {"version":3,"file":"semantic-tool-descriptions.js","sourceRoot":"","sources":["../../src/semantic-tool-descriptions.ts"],"names":[],"mappings":"AAAA,kFAAkF;AAClF,MAAM,CAAC,MAAM,wBAAwB,GAAG;IACtC,GAAG,EAAE,ojBAAojB;QACvjB,iFAAiF;QACjF,kIAAkI;QAClI,+JAA+J;QAC/J,0DAA0D;QAC1D,uEAAuE;QACvE,yEAAyE;QACzE,oEAAoE;IACtE,KAAK,EAAE,ocAAoc;QACzc,2KAA2K;QAC3K,gFAAgF;QAChF,8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QAC7E,yDAAyD;CACnD,CAAC"}
1
+ {"version":3,"file":"semantic-tool-descriptions.js","sourceRoot":"","sources":["../../src/semantic-tool-descriptions.ts"],"names":[],"mappings":"AAAA,kFAAkF;AAClF,MAAM,CAAC,MAAM,wBAAwB,GAAG;IACtC,GAAG,EAAE,ojBAAojB;QACvjB,iFAAiF;QACjF,kIAAkI;QAClI,+JAA+J;QAC/J,0DAA0D;QAC1D,uEAAuE;QACvE,yEAAyE;QACzE,oEAAoE;IACtE,KAAK,EAAE,ocAAoc;QACzc,2KAA2K;QAC3K,gFAAgF;QAChF,8EAA8E;QAC9E,gFAAgF;QAChF,4FAA4F;QAC5F,0FAA0F;QAC1F,8EAA8E;QAC9E,+EAA+E;QAC/E,uEAAuE;QACvE,6EAA6E;QAC7E,4EAA4E;QAC5E,2HAA2H;IAC7H,OAAO,EAAE,yGAAyG;QAChH,+EAA+E;QAC/E,2DAA2D;IAC7D,sBAAsB,EAAE,+EAA+E;QACrG,qEAAqE;QACrE,+EAA+E;QAC/E,8EAA8E;QAC9E,2EAA2E;QAC3E,0EAA0E;QAC1E,6CAA6C;IAC/C,cAAc,EAAE,8KAA8K;QAC5L,mHAAmH;QACnH,8EAA8E;QAC9E,+EAA+E;QAC/E,gEAAgE;QAChE,0EAA0E;QAC1E,wEAAwE;QACxE,gCAAgC;IAClC,cAAc,EAAE,+GAA+G;QAC7H,gKAAgK;QAChK,+IAA+I;QAC/I,oIAAoI;QACpI,+IAA+I;QAC/I,2HAA2H;IAC7H,UAAU,EAAE,+EAA+E;QACzF,uEAAuE;QACvE,2EAA2E;QAC3E,6EAA6E;QAC7E,sBAAsB;IACxB,iBAAiB,EAAE,2FAA2F;QAC5G,iHAAiH;QACjH,4KAA4K;QAC5K,mMAAmM;QACnM,0NAA0N;IAC5N,aAAa,EAAE,wEAAwE;QACrF,+EAA+E;QAC/E,kEAAkE;QAClE,wEAAwE;QACxE,+EAA+E;QAC/E,UAAU;IACZ,MAAM,EAAE,kXAAkX;QAC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E,+EAA+E;QAC/E,4EAA4E;QAC5E,8EAA8E;QAC9E,wEAAwE;QACxE,+EAA+E;QAC/E,8EAA8E;QAC9E,yDAAyD;QACzD,mEAAmE;QACnE,gEAAgE;QAChE,4EAA4E;QAC5E,+EAA+E;QAC/E,wEAAwE;QACxE,UAAU;IACZ,8EAA8E;QAC5E,6EAA6E;QAC7E,yEAAyE;QACzE,4EAA4E;QAC5E,8EAA8E;QAC9E,0EAA0E;QAC1E,+EAA+E;QAC/E,8EAA8E;QAC9E,yEAAyE;QACzE,+EAA+E;QAC/E,0EAA0E;QAC1E,yEAAyE;QACzE,6EAA6E;QAC7E,8EAA8E;QAC9E,mEAAmE;QACnE,+EAA+E;QAC/E,6EAA6E;QAC7E,yDAAyD;CACnD,CAAC"}
@@ -1,6 +1,7 @@
1
1
  import { createHash } from "node:crypto";
2
2
  import { arrayValue } from "./semantic-tool-value-helpers.js";
3
3
  import { recordValue } from "./value-guards.js";
4
+ import { withConversationUsage } from "./conversation-usage-guidance.js";
4
5
  // A byte budget also bounds UTF-16 output and leaves room for Host envelopes.
5
6
  // It is not a token budget, and does not reduce the native discovery/read cost.
6
7
  export const HOST_LIST_MAX_BYTES = 24 * 1024;
@@ -170,7 +171,7 @@ function statusReference(row) {
170
171
  const id = row.watch_id ? { watch_id: row.watch_id } : row.turn_id ? { turn_id: row.turn_id } : { conversation_id: row.conversation_id ?? row.id };
171
172
  result.action_inputs = { status: { arguments: id } };
172
173
  result.next_action = "Read exact Status for current actions and interaction/callback details; omitted actions are not unsupported.";
173
- return result;
174
+ return withConversationUsage(result);
174
175
  }
175
176
  function digest(text) { return createHash("sha256").update(text).digest("hex"); }
176
177
  function bytes(value) { return Buffer.byteLength(JSON.stringify(value) ?? "null", "utf8"); }