@scotthuang/agent-knock-knock 0.13.16 → 0.13.18

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 (184) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/README.md +4 -4
  3. package/dist/src/claude-terminal-agent-adapter.js +1 -1
  4. package/dist/src/claude-terminal-agent-adapter.js.map +1 -1
  5. package/dist/src/codex-app-server-interaction-client.js +68 -26
  6. package/dist/src/codex-app-server-interaction-client.js.map +1 -1
  7. package/dist/src/codex-app-server-read-client.js +52 -20
  8. package/dist/src/codex-app-server-read-client.js.map +1 -1
  9. package/dist/src/codex-astra-composer-proof.js +1 -1
  10. package/dist/src/codex-astra-composer-proof.js.map +1 -1
  11. package/dist/src/codex-async-question-adapter.js +14 -4
  12. package/dist/src/codex-async-question-adapter.js.map +1 -1
  13. package/dist/src/codex-lifecycle-compatibility.d.ts +1 -1
  14. package/dist/src/codex-lifecycle-compatibility.js +9 -3
  15. package/dist/src/codex-lifecycle-compatibility.js.map +1 -1
  16. package/dist/src/codex-open-rollout-inventory.d.ts +51 -0
  17. package/dist/src/codex-open-rollout-inventory.js +365 -0
  18. package/dist/src/codex-open-rollout-inventory.js.map +1 -0
  19. package/dist/src/codex-paginated-thread-binding.js +1 -1
  20. package/dist/src/codex-paginated-thread-binding.js.map +1 -1
  21. package/dist/src/codex-permission-surface.d.ts +1 -1
  22. package/dist/src/codex-permission-surface.js +1 -1
  23. package/dist/src/codex-permission-surface.js.map +1 -1
  24. package/dist/src/codex-rollout-bound-completion.d.ts +44 -0
  25. package/dist/src/codex-rollout-bound-completion.js +357 -0
  26. package/dist/src/codex-rollout-bound-completion.js.map +1 -0
  27. package/dist/src/codex-rollout-file.d.ts +15 -0
  28. package/dist/src/codex-rollout-file.js +98 -0
  29. package/dist/src/codex-rollout-file.js.map +1 -0
  30. package/dist/src/codex-rollout-human-task.d.ts +61 -0
  31. package/dist/src/codex-rollout-human-task.js +555 -0
  32. package/dist/src/codex-rollout-human-task.js.map +1 -0
  33. package/dist/src/codex-rollout-interaction-evidence.d.ts +48 -0
  34. package/dist/src/codex-rollout-interaction-evidence.js +521 -0
  35. package/dist/src/codex-rollout-interaction-evidence.js.map +1 -0
  36. package/dist/src/codex-rollout-inventory.d.ts +5 -0
  37. package/dist/src/codex-rollout-inventory.js +81 -0
  38. package/dist/src/codex-rollout-inventory.js.map +1 -0
  39. package/dist/src/codex-rollout-records.d.ts +49 -0
  40. package/dist/src/codex-rollout-records.js +298 -0
  41. package/dist/src/codex-rollout-records.js.map +1 -0
  42. package/dist/src/codex-sqlite-thread-query.d.ts +85 -0
  43. package/dist/src/codex-sqlite-thread-query.js +440 -0
  44. package/dist/src/codex-sqlite-thread-query.js.map +1 -0
  45. package/dist/src/codex-status-history-navigation.d.ts +1 -1
  46. package/dist/src/codex-status-history-navigation.js +1 -1
  47. package/dist/src/codex-status-history-navigation.js.map +1 -1
  48. package/dist/src/codex-store-adapter.d.ts +3 -50
  49. package/dist/src/codex-store-adapter.js +5 -796
  50. package/dist/src/codex-store-adapter.js.map +1 -1
  51. package/dist/src/codex-terminal-agent-adapter.js +4 -2
  52. package/dist/src/codex-terminal-agent-adapter.js.map +1 -1
  53. package/dist/src/native-thread-lifecycle-cli-adapter.d.ts +4 -134
  54. package/dist/src/native-thread-lifecycle-cli-adapter.js +19 -633
  55. package/dist/src/native-thread-lifecycle-cli-adapter.js.map +1 -1
  56. package/dist/src/native-thread-lifecycle-cli-contract.d.ts +138 -0
  57. package/dist/src/native-thread-lifecycle-cli-contract.js +2 -0
  58. package/dist/src/native-thread-lifecycle-cli-contract.js.map +1 -0
  59. package/dist/src/semantic-permission-control.js +33 -6
  60. package/dist/src/semantic-permission-control.js.map +1 -1
  61. package/dist/src/semantic-tool-descriptions.d.ts +26 -0
  62. package/dist/src/semantic-tool-descriptions.js +259 -0
  63. package/dist/src/semantic-tool-descriptions.js.map +1 -0
  64. package/dist/src/semantic-tool-runtime.js +45 -37
  65. package/dist/src/semantic-tool-runtime.js.map +1 -1
  66. package/dist/src/semantic-tool-schemas.js +134 -33
  67. package/dist/src/semantic-tool-schemas.js.map +1 -1
  68. package/dist/src/terminal-action-contracts.d.ts +4 -0
  69. package/dist/src/terminal-action-contracts.js +695 -0
  70. package/dist/src/terminal-action-contracts.js.map +1 -0
  71. package/dist/src/terminal-composer-classifier.d.ts +1 -1
  72. package/dist/src/terminal-composer-classifier.js +2 -2
  73. package/dist/src/terminal-composer-classifier.js.map +1 -1
  74. package/dist/src/terminal-interaction-response-bridge.js +1 -1
  75. package/dist/src/terminal-interaction-response-bridge.js.map +1 -1
  76. package/dist/src/terminal-list-renderer.d.ts +1 -2
  77. package/dist/src/terminal-list-renderer.js +8 -424
  78. package/dist/src/terminal-list-renderer.js.map +1 -1
  79. package/dist/src/terminal-model-control-action-policy.d.ts +1 -1
  80. package/dist/src/terminal-model-control-availability.d.ts +1 -1
  81. package/dist/src/terminal-model-control-availability.js +1 -1
  82. package/dist/src/terminal-model-control-availability.js.map +1 -1
  83. package/dist/src/terminal-model-control-cli-adapter.d.ts +34 -0
  84. package/dist/src/terminal-model-control-cli-adapter.js +669 -0
  85. package/dist/src/terminal-model-control-cli-adapter.js.map +1 -0
  86. package/dist/src/terminal-model-control-contract.d.ts +198 -0
  87. package/dist/src/terminal-model-control-contract.js +15 -0
  88. package/dist/src/terminal-model-control-contract.js.map +1 -0
  89. package/dist/src/terminal-model-control-input.d.ts +29 -0
  90. package/dist/src/terminal-model-control-input.js +86 -0
  91. package/dist/src/terminal-model-control-input.js.map +1 -0
  92. package/dist/src/terminal-model-control-profile.d.ts +5 -1
  93. package/dist/src/terminal-model-control-profile.js +21 -7
  94. package/dist/src/terminal-model-control-profile.js.map +1 -1
  95. package/dist/src/terminal-model-control-subject.d.ts +52 -0
  96. package/dist/src/terminal-model-control-subject.js +73 -0
  97. package/dist/src/terminal-model-control-subject.js.map +1 -1
  98. package/dist/src/terminal-model-control-surface.d.ts +82 -0
  99. package/dist/src/terminal-model-control-surface.js +688 -0
  100. package/dist/src/terminal-model-control-surface.js.map +1 -0
  101. package/dist/src/terminal-model-control.d.ts +6 -270
  102. package/dist/src/terminal-model-control.js +11 -988
  103. package/dist/src/terminal-model-control.js.map +1 -1
  104. package/dist/src/terminal-model-selection.d.ts +33 -0
  105. package/dist/src/terminal-model-selection.js +143 -0
  106. package/dist/src/terminal-model-selection.js.map +1 -0
  107. package/dist/src/terminal-monitor-application-service.js +38 -59
  108. package/dist/src/terminal-monitor-application-service.js.map +1 -1
  109. package/dist/src/terminal-monitor-attention-store.d.ts +65 -0
  110. package/dist/src/terminal-monitor-attention-store.js +518 -0
  111. package/dist/src/terminal-monitor-attention-store.js.map +1 -0
  112. package/dist/src/terminal-monitor-collateral-recovery.d.ts +12 -0
  113. package/dist/src/terminal-monitor-collateral-recovery.js +415 -0
  114. package/dist/src/terminal-monitor-collateral-recovery.js.map +1 -0
  115. package/dist/src/terminal-monitor-interaction-projection.d.ts +19 -0
  116. package/dist/src/terminal-monitor-interaction-projection.js +48 -0
  117. package/dist/src/terminal-monitor-interaction-projection.js.map +1 -0
  118. package/dist/src/terminal-monitor-startup-recovery.d.ts +15 -0
  119. package/dist/src/terminal-monitor-startup-recovery.js +767 -0
  120. package/dist/src/terminal-monitor-startup-recovery.js.map +1 -0
  121. package/dist/src/terminal-monitor-state-cli-adapter.d.ts +2 -104
  122. package/dist/src/terminal-monitor-state-cli-adapter.js +28 -1640
  123. package/dist/src/terminal-monitor-state-cli-adapter.js.map +1 -1
  124. package/dist/src/terminal-monitor-state-contract.d.ts +108 -0
  125. package/dist/src/terminal-monitor-state-contract.js +8 -0
  126. package/dist/src/terminal-monitor-state-contract.js.map +1 -0
  127. package/dist/src/terminal-native-inspection-bridge.d.ts +4 -153
  128. package/dist/src/terminal-native-inspection-bridge.js +7 -646
  129. package/dist/src/terminal-native-inspection-bridge.js.map +1 -1
  130. package/dist/src/terminal-native-inspection-contract.d.ts +128 -0
  131. package/dist/src/terminal-native-inspection-contract.js +38 -0
  132. package/dist/src/terminal-native-inspection-contract.js.map +1 -0
  133. package/dist/src/terminal-native-inspection-profile.d.ts +15 -0
  134. package/dist/src/terminal-native-inspection-profile.js +189 -0
  135. package/dist/src/terminal-native-inspection-profile.js.map +1 -0
  136. package/dist/src/terminal-native-inspection-proof.d.ts +62 -0
  137. package/dist/src/terminal-native-inspection-proof.js +362 -0
  138. package/dist/src/terminal-native-inspection-proof.js.map +1 -0
  139. package/dist/src/terminal-permission-control-bridge.js +1 -1
  140. package/dist/src/terminal-permission-control-bridge.js.map +1 -1
  141. package/dist/src/terminal-permission-control.js +5 -1
  142. package/dist/src/terminal-permission-control.js.map +1 -1
  143. package/dist/src/terminal-questionnaire-adapter.js +5 -2
  144. package/dist/src/terminal-questionnaire-adapter.js.map +1 -1
  145. package/dist/src/terminal-runtime-cli-adapter.d.ts +2 -1
  146. package/dist/src/terminal-runtime-cli-adapter.js +1 -1
  147. package/dist/src/terminal-runtime-cli-adapter.js.map +1 -1
  148. package/dist/src/terminal-submission-acceptance.d.ts +5 -148
  149. package/dist/src/terminal-submission-acceptance.js +21 -1845
  150. package/dist/src/terminal-submission-acceptance.js.map +1 -1
  151. package/dist/src/terminal-watch-anchor-capture.d.ts +9 -0
  152. package/dist/src/terminal-watch-anchor-capture.js +139 -0
  153. package/dist/src/terminal-watch-anchor-capture.js.map +1 -0
  154. package/dist/src/terminal-watch-cli-adapter.d.ts +3 -117
  155. package/dist/src/terminal-watch-cli-adapter.js +10 -1992
  156. package/dist/src/terminal-watch-cli-adapter.js.map +1 -1
  157. package/dist/src/terminal-watch-cli-contract.d.ts +117 -0
  158. package/dist/src/terminal-watch-cli-contract.js +2 -0
  159. package/dist/src/terminal-watch-cli-contract.js.map +1 -0
  160. package/dist/src/terminal-watch-fallback-observation.d.ts +15 -0
  161. package/dist/src/terminal-watch-fallback-observation.js +249 -0
  162. package/dist/src/terminal-watch-fallback-observation.js.map +1 -0
  163. package/dist/src/terminal-watch-interaction-observation.d.ts +26 -0
  164. package/dist/src/terminal-watch-interaction-observation.js +262 -0
  165. package/dist/src/terminal-watch-interaction-observation.js.map +1 -0
  166. package/dist/src/terminal-watch-observation-adapter.d.ts +4 -0
  167. package/dist/src/terminal-watch-observation-adapter.js +307 -0
  168. package/dist/src/terminal-watch-observation-adapter.js.map +1 -0
  169. package/dist/src/terminal-watch-observation-evidence.d.ts +25 -0
  170. package/dist/src/terminal-watch-observation-evidence.js +184 -0
  171. package/dist/src/terminal-watch-observation-evidence.js.map +1 -0
  172. package/dist/src/terminal-watch-response-authority.d.ts +6 -0
  173. package/dist/src/terminal-watch-response-authority.js +333 -0
  174. package/dist/src/terminal-watch-response-authority.js.map +1 -0
  175. package/dist/src/terminal-watch-response-cli-adapter.d.ts +3 -0
  176. package/dist/src/terminal-watch-response-cli-adapter.js +230 -0
  177. package/dist/src/terminal-watch-response-cli-adapter.js.map +1 -0
  178. package/dist/src/terminal-watch-terminal-identity.d.ts +39 -0
  179. package/dist/src/terminal-watch-terminal-identity.js +380 -0
  180. package/dist/src/terminal-watch-terminal-identity.js.map +1 -0
  181. package/docs/codex-0.160.0-compatibility.md +126 -0
  182. package/docs/codex-permissions.md +12 -1
  183. package/package.json +3 -2
  184. package/templates/openclaw-skills/agent-knock-knock/SKILL.md +3 -3
@@ -1,232 +1,13 @@
1
+ export { CODEX_COMPOSER_MARKER, CODEX_COMPOSER_FOOTER, isExactClaudeIdleComposer, isExactClaudeNativeInspectionIdleComposer, exactClaudeComposerFrame, claudeNativeInspectionTrailingIsFooter, stripTerminalEscapeSequences, exactCodexReadyStyledComposerCapture, inferCodexVisibleViewportColumns } from "./terminal-native-inspection-proof.js";
2
+ import { assertNativeInspectionComposerSafe, exactNativeInspectionComposerCapture, nativeInspectionScreenFingerprint, bareDigestFromNativeInspectionScreenFingerprint, stripTerminalEscapeSequences, exactCodexReadyStyledComposerCapture, inferCodexVisibleViewportColumns, hasTruncatedCodexStatusSessionLine, codexNativeInspectionComposerMismatchDiagnostic } from "./terminal-native-inspection-proof.js";
3
+ import { codexFullscreenStatusVersion, codexNativeStatusPopupRows, codexNativeStatusMinimumViewport, assertClosedStatusInspectionPlan, assertClosedNativeInspectionDismissal } from "./terminal-native-inspection-profile.js";
4
+ export { NativeInspectionSubmissionError, NativeInspectionDismissalError } from "./terminal-native-inspection-contract.js";
5
+ import { NativeInspectionSubmissionError, NativeInspectionDiagnosticError, NativeInspectionDismissalError } from "./terminal-native-inspection-contract.js";
1
6
  import { isCodexPaginatedReadCandidate } from "./codex-lifecycle-compatibility.js";
2
- import { createHash } from "node:crypto";
3
- import { captureCodexFullscreenComposerFrame, exactCodexFullscreenSlashComposerCapture } from "./codex-fullscreen-composer-proof.js";
7
+ import { exactCodexFullscreenSlashComposerCapture } from "./codex-fullscreen-composer-proof.js";
4
8
  import { TerminalControlInputNotSentError } from "./terminal-control-provider.js";
5
9
  import { sameTerminalControlIncarnation } from "./terminal-control-ref.js";
6
- import { CODEX_EXACT_CANDIDATE_GRACE_CAPTURES, CODEX_MULTILINE_SETTLE_POLL_MS, CODEX_MULTILINE_SETTLE_SCROLLBACK_LINES, CODEX_MULTILINE_STABLE_CAPTURES, CODEX_PASTE_ENTER_SETTLE_MS } from "./terminal-text-submission-bridge.js";
7
- export const CODEX_COMPOSER_MARKER = /^[›»](?:\s|$)/u;
8
- export const CODEX_COMPOSER_FOOTER = /^(?:gpt-[\w.-]+(?:\s|$)|[-\w.]+ default ·)/u;
9
- // Keep every exact slash-completion shape closed per behavior profile so a
10
- // version adding another matching command cannot silently become an authorized
11
- // native command surface.
12
- const CODEX_FULLSCREEN_STATUS_POPUP_ROWS = [
13
- "› /status show current session configuration and token usage",
14
- " /statusline configure which items appear in the status line"
15
- ];
16
- const CODEX_NATIVE_STATUS_POPUP_BY_PROFILE = {
17
- "codex-tui-0.146.0": [
18
- " /status show current session configuration and token usage"
19
- ],
20
- "codex-tui-0.146.1": [
21
- " /status show current session configuration and token usage"
22
- ],
23
- "codex-tui-0.147.0": [
24
- " /status show current session configuration and token usage",
25
- " /statusline configure which items appear in the status line"
26
- ],
27
- "codex-tui-0.148.0": [
28
- " /status show current session configuration and token usage",
29
- " /statusline configure which items appear in the status line"
30
- ],
31
- "codex-tui-0.149.1": [
32
- " /status show current session configuration and token usage",
33
- " /statusline configure which items appear in the status line"
34
- ],
35
- "codex-tui-0.150.1": [
36
- " /status show current session configuration and token usage",
37
- " /statusline configure which items appear in the status line"
38
- ],
39
- "codex-tui-0.151.0": [
40
- " /status show current session configuration and token usage",
41
- " /statusline configure which items appear in the status line"
42
- ],
43
- "codex-tui-0.153.0": [
44
- " /status show current session configuration and token usage",
45
- " /statusline configure which items appear in the status line"
46
- ],
47
- "codex-tui-0.153.4": [
48
- " /status show current session configuration and token usage",
49
- " /statusline configure which items appear in the status line"
50
- ],
51
- "codex-tui-0.154.0": [
52
- " /status show current session configuration and token usage",
53
- " /statusline configure which items appear in the status line"
54
- ],
55
- "codex-tui-0.155.1": [
56
- " /status show current session configuration and token usage",
57
- " /statusline configure which items appear in the status line"
58
- ],
59
- "codex-tui-0.158.0": CODEX_FULLSCREEN_STATUS_POPUP_ROWS,
60
- "codex-tui-0.159.0": CODEX_FULLSCREEN_STATUS_POPUP_ROWS,
61
- "codex-tui-0.159.2": CODEX_FULLSCREEN_STATUS_POPUP_ROWS,
62
- "codex-tui-generic-v1": [
63
- " /status show current session configuration and token usage",
64
- " /statusline configure which items appear in the status line"
65
- ]
66
- };
67
- // Codex's verified `/status` profiles are exercised against its canonical
68
- // 80-column status surface. Narrower layouts can truncate the 36-character
69
- // Session UUID after a dynamically sized label column. Exact provider geometry
70
- // is required before input; ANSI visible-buffer width is only a conservative
71
- // fallback diagnostic and never upgrades unknown geometry to safe.
72
- const CODEX_NATIVE_STATUS_MIN_VIEWPORT_BY_PROFILE = {
73
- "codex-tui-0.146.0": 80,
74
- "codex-tui-0.146.1": 80,
75
- "codex-tui-0.147.0": 80,
76
- "codex-tui-0.148.0": 80,
77
- "codex-tui-0.149.1": 80,
78
- "codex-tui-0.150.1": 80,
79
- "codex-tui-0.151.0": 80,
80
- "codex-tui-0.153.0": 80,
81
- "codex-tui-0.153.4": 80,
82
- "codex-tui-0.154.0": 80,
83
- "codex-tui-0.155.1": 80,
84
- "codex-tui-0.158.0": 80,
85
- "codex-tui-0.159.0": 80,
86
- "codex-tui-0.159.2": 80,
87
- "codex-tui-generic-v1": 80
88
- };
89
- const CLAUDE_NATIVE_STATUS_POPUP_BY_PROFILE = {
90
- "claude-code-2.1.218-native-status": [
91
- "/status Show Claude Code status including version, model, account, API connectivity, and tool statuses",
92
- "/statusline Set up Claude Code's status line UI",
93
- "/ide Manage IDE integrations and show status",
94
- "/usage Show session cost, plan usage, and activity stats"
95
- ],
96
- "claude-code-2.1.226-native-status": [
97
- "/status Show Claude Code status including version, model, account, API connectivity, and tool statuses",
98
- "/statusline Set up Claude Code's status line UI",
99
- "/ide Manage IDE integrations and show status",
100
- "/usage Show session cost, plan usage, and activity stats"
101
- ],
102
- "claude-code-2.1.237-native-status": [
103
- "/status Show Claude Code status including version, model, account, API connectivity, and tool statuses",
104
- "/statusline Set up Claude Code's status line UI",
105
- "/ide Manage IDE integrations and show status",
106
- "/usage Show session cost, plan usage, and activity stats"
107
- ],
108
- "claude-code-2.1.251-native-status": [
109
- "/status Show Claude Code status including version, model, account, API connectivity, and tool statuses",
110
- "/statusline Set up Claude Code's status line UI",
111
- "/ide Manage IDE integrations and show status",
112
- "/usage Show session cost, plan usage, and activity stats"
113
- ],
114
- "claude-code-2.1.259-native-status": [
115
- "/status Show Claude Code status including version, model, account, API connectivity, and tool statuses",
116
- "/statusline Set up Claude Code's status line UI",
117
- "/ide Manage IDE integrations and show status",
118
- "/usage Show session cost, plan usage, and activity stats"
119
- ],
120
- "claude-code-2.1.263-native-status": [
121
- "/status Show Claude Code status including version, model, account, API connectivity, and tool statuses",
122
- "/statusline Set up Claude Code's status line UI",
123
- "/ide Manage IDE integrations and show status",
124
- "/usage Show session cost, plan usage, and activity stats"
125
- ],
126
- "claude-code-2.1.266-native-status": [
127
- "/status Show Claude Code status including version, model, account, API connectivity, and tool statuses",
128
- "/statusline Set up Claude Code's status line UI",
129
- "/ide Manage IDE integrations and show status",
130
- "/usage Show session cost, plan usage, and activity stats"
131
- ],
132
- "claude-code-2.1.267-native-status": [
133
- "/status Show Claude Code status including version, model, account, API connectivity, and tool statuses",
134
- "/statusline Set up Claude Code's status line UI",
135
- "/ide Manage IDE integrations and show status",
136
- "/usage Show session cost, plan usage, and activity stats"
137
- ],
138
- "claude-code-2.1.285-native-status": [
139
- "/status Show Claude Code status including version, model, account, API connectivity, and tool statuses",
140
- "/statusline Set up Claude Code's status line UI",
141
- "/ide Manage IDE integrations and show status",
142
- "/usage Show session cost, plan usage, and activity stats"
143
- ],
144
- "claude-code-unverified-native-status-v1": [
145
- "/status Show Claude Code status including version, model, account, API connectivity, and tool statuses",
146
- "/statusline Set up Claude Code's status line UI",
147
- "/ide Manage IDE integrations and show status",
148
- "/usage Show session cost, plan usage, and activity stats"
149
- ]
150
- };
151
- const CLAUDE_NATIVE_STATUS_SETTLE_BY_PROFILE = {
152
- "claude-code-2.1.218-native-status": {
153
- minimumStableMs: 80,
154
- maximumSettleMs: 2_000
155
- },
156
- "claude-code-2.1.226-native-status": {
157
- minimumStableMs: 80,
158
- maximumSettleMs: 5_000
159
- },
160
- "claude-code-2.1.237-native-status": {
161
- minimumStableMs: 80,
162
- maximumSettleMs: 5_000
163
- },
164
- "claude-code-2.1.251-native-status": {
165
- minimumStableMs: 80,
166
- maximumSettleMs: 5_000
167
- },
168
- "claude-code-2.1.259-native-status": {
169
- minimumStableMs: 80,
170
- maximumSettleMs: 5_000
171
- },
172
- "claude-code-2.1.263-native-status": {
173
- minimumStableMs: 80,
174
- maximumSettleMs: 5_000
175
- },
176
- "claude-code-2.1.266-native-status": {
177
- minimumStableMs: 80,
178
- maximumSettleMs: 5_000
179
- },
180
- "claude-code-2.1.267-native-status": {
181
- minimumStableMs: 80,
182
- maximumSettleMs: 5_000
183
- },
184
- "claude-code-2.1.285-native-status": {
185
- minimumStableMs: 80,
186
- maximumSettleMs: 5_000
187
- },
188
- "claude-code-unverified-native-status-v1": {
189
- minimumStableMs: 80,
190
- maximumSettleMs: 5_000
191
- }
192
- };
193
- /**
194
- * A fail-closed native-inspection submission result.
195
- *
196
- * Only `not_started` proves that a caller may safely retry. Once text has
197
- * reached the composer, or Enter has been attempted, automated retries could
198
- * duplicate input or execute a different command after terminal drift.
199
- */
200
- export class NativeInspectionSubmissionError extends Error {
201
- stage;
202
- code = "AKK_NATIVE_INSPECTION_SUBMISSION_FAILED";
203
- doNotRetry;
204
- constructor(stage, message, options = {}) {
205
- super(message, options);
206
- this.stage = stage;
207
- this.name = "NativeInspectionSubmissionError";
208
- this.doNotRetry = stage !== "not_started";
209
- this.diagnostic = options.diagnostic;
210
- }
211
- diagnostic;
212
- }
213
- class NativeInspectionDiagnosticError extends Error {
214
- diagnostic;
215
- constructor(diagnostic, message, options = {}) {
216
- super(message, options);
217
- this.diagnostic = diagnostic;
218
- this.name = "NativeInspectionDiagnosticError";
219
- }
220
- }
221
- /** A verified modal could not be dismissed across one exact key attempt. */
222
- export class NativeInspectionDismissalError extends Error {
223
- code = "AKK_NATIVE_INSPECTION_DISMISSAL_FAILED";
224
- doNotRetry = true;
225
- constructor(message, options = {}) {
226
- super(message, options);
227
- this.name = "NativeInspectionDismissalError";
228
- }
229
- }
10
+ import { CODEX_EXACT_CANDIDATE_GRACE_CAPTURES, CODEX_MULTILINE_SETTLE_POLL_MS, CODEX_MULTILINE_SETTLE_SCROLLBACK_LINES, CODEX_MULTILINE_STABLE_CAPTURES } from "./terminal-text-submission-bridge.js";
230
11
  /**
231
12
  * Closed native-inspection transport. Terminal locking, Store authority, and
232
13
  * the caller's one-shot input ledger remain outside this internal service.
@@ -787,424 +568,4 @@ function nativeInspectionSubmissionError(stage, error, fallbackDiagnostic) {
787
568
  }
788
569
  return new NativeInspectionSubmissionError(stage, error instanceof Error ? error.message : String(error), { cause: error, diagnostic });
789
570
  }
790
- function assertClosedStatusInspectionPlan(adapter, terminalControl, plan) {
791
- if (!terminalControl.capabilities.includes("send_keys")) {
792
- throw new Error(`${adapter.displayName} terminal input is not supported`);
793
- }
794
- if (!terminalControl.capabilities.includes("screen_status")) {
795
- throw new Error(`${adapter.displayName} terminal screen inspection is not supported`);
796
- }
797
- const codexProfile = adapter.agent === "codex" &&
798
- codexNativeStatusPopupRows(plan) !== undefined;
799
- const claudeProfile = adapter.agent === "claude" &&
800
- CLAUDE_NATIVE_STATUS_POPUP_BY_PROFILE[plan.behaviorProfile] !== undefined;
801
- const expectedSettle = codexProfile
802
- ? { minimumStableMs: CODEX_PASTE_ENTER_SETTLE_MS, maximumSettleMs: 2_000 }
803
- : CLAUDE_NATIVE_STATUS_SETTLE_BY_PROFILE[plan.behaviorProfile];
804
- const exactPresentation = codexProfile
805
- ? plan.expectedResult.presentation === "inline" &&
806
- plan.expectedResult.dismissal === undefined &&
807
- plan.composer.minimumStableMs === expectedSettle?.minimumStableMs &&
808
- plan.composer.maximumSettleMs === expectedSettle.maximumSettleMs
809
- : claudeProfile
810
- ? plan.expectedResult.presentation === "modal" &&
811
- plan.composer.minimumStableMs === expectedSettle?.minimumStableMs &&
812
- plan.composer.maximumSettleMs === expectedSettle.maximumSettleMs &&
813
- plan.expectedResult.dismissal?.expected === "idle_empty_composer" &&
814
- JSON.stringify(plan.expectedResult.dismissal.keys) ===
815
- JSON.stringify(["Escape"])
816
- : false;
817
- if (plan.operation.kind !== "status" ||
818
- plan.command !== "/status" ||
819
- plan.effect !== "read_only" ||
820
- plan.requiresIdle !== true ||
821
- plan.composer.kind !== "exact" ||
822
- !Number.isFinite(plan.composer.minimumStableMs) ||
823
- plan.composer.minimumStableMs < 0 ||
824
- !Number.isFinite(plan.composer.maximumSettleMs) ||
825
- plan.composer.maximumSettleMs < plan.composer.minimumStableMs ||
826
- plan.expectedResult.kind !== "native_status" ||
827
- !exactPresentation) {
828
- throw new Error("refusing a non-closed native inspection plan");
829
- }
830
- }
831
- function assertClosedNativeInspectionDismissal(plan) {
832
- if (plan.expectedResult.presentation !== "modal" ||
833
- plan.expectedResult.dismissal?.expected !== "idle_empty_composer" ||
834
- JSON.stringify(plan.expectedResult.dismissal.keys) !==
835
- JSON.stringify(["Escape"])) {
836
- throw new Error("native inspection has no closed modal dismissal plan");
837
- }
838
- }
839
- function assertNativeInspectionComposerSafe(inspection, displayName = "terminal agent", allowWorkingCodexStatus = false) {
840
- if (inspection.approval.blocked ||
841
- inspection.activity.state === "awaiting_approval" ||
842
- inspection.activity.state === "working" && !allowWorkingCodexStatus) {
843
- throw new NativeInspectionDiagnosticError("composer_not_ready", `${displayName} became busy or blocked while its /status composer was settling`);
844
- }
845
- // Codex's generic activity parser deliberately reports a non-empty slash
846
- // composer as unknown. At this stage the caller has already proved an idle,
847
- // empty styled composer under the terminal lock; the exact-current composer
848
- // capture below is the stronger continuation proof after AKK injected only
849
- // the adapter-owned /status command.
850
- }
851
- function exactNativeInspectionComposerCapture(agent, screen, plan) {
852
- return agent === "codex"
853
- ? exactCodexNativeInspectionComposerCapture(screen, plan)
854
- : exactClaudeNativeInspectionComposerCapture(screen, plan);
855
- }
856
- function exactCodexNativeInspectionComposerCapture(screen, plan) {
857
- if (codexFullscreenStatusVersion(plan) !== undefined) {
858
- const captured = exactCodexFullscreenSlashComposerCapture(stripTerminalEscapeSequences(screen), plan.command, codexNativeStatusPopupRows(plan), false, codexFullscreenStatusVersion(plan));
859
- return captured && { digest: captured.digest, kind: "exact_slash_popup" };
860
- }
861
- const lines = screen.replace(/\r\n?/gu, "\n").split("\n");
862
- let currentComposerIndex = -1;
863
- for (let index = lines.length - 1; index >= 0; index -= 1) {
864
- if (CODEX_COMPOSER_MARKER.test(lines[index])) {
865
- currentComposerIndex = index;
866
- break;
867
- }
868
- }
869
- if (currentComposerIndex < 0) {
870
- return undefined;
871
- }
872
- const composerText = lines[currentComposerIndex]
873
- .replace(/^[›»]\s?/u, "")
874
- .trimEnd();
875
- if (composerText !== plan.command) {
876
- return undefined;
877
- }
878
- const footerIndex = lines.findIndex((line, candidateIndex) => candidateIndex > currentComposerIndex &&
879
- CODEX_COMPOSER_FOOTER.test(line.trim()));
880
- const region = lines.slice(currentComposerIndex, footerIndex < 0 ? lines.length : footerIndex);
881
- while (region.length > 1 && region.at(-1)?.trim() === "") {
882
- region.pop();
883
- }
884
- const popupRows = region.slice(1).filter((line) => line.trim().length > 0);
885
- let kind;
886
- if (popupRows.length === 0) {
887
- kind = "exact_slash_composer";
888
- }
889
- else if (JSON.stringify(popupRows.map((line) => line.trimEnd())) ===
890
- JSON.stringify(codexNativeStatusPopupRows(plan))) {
891
- kind = "exact_slash_popup";
892
- }
893
- else {
894
- return undefined;
895
- }
896
- return {
897
- kind,
898
- digest: createHash("sha256").update(region.join("\n")).digest("hex")
899
- };
900
- }
901
- function exactClaudeNativeInspectionComposerCapture(screen, plan) {
902
- const frame = exactClaudeComposerFrame(screen);
903
- if (!frame) {
904
- return undefined;
905
- }
906
- const { lines, openIndex, closeIndex, composerRows, trailing } = frame;
907
- if (composerRows.length !== 1 ||
908
- !/^\s*❯(?:\s|$)/u.test(composerRows[0]) ||
909
- composerRows[0].replace(/^\s*❯\s?/u, "").trimEnd() !== plan.command) {
910
- return undefined;
911
- }
912
- let kind;
913
- if (trailing.length === 0 || claudeNativeInspectionTrailingIsFooter(trailing)) {
914
- kind = "exact_slash_composer";
915
- }
916
- else {
917
- const suggestions = [];
918
- for (const line of trailing) {
919
- const trimmed = line.trim();
920
- if (trimmed.startsWith("/")) {
921
- suggestions.push(trimmed.replace(/\s+/gu, " "));
922
- }
923
- else if (suggestions.length > 0) {
924
- suggestions[suggestions.length - 1] +=
925
- ` ${trimmed.replace(/\s+/gu, " ")}`;
926
- }
927
- else {
928
- return undefined;
929
- }
930
- }
931
- if (!closedClaudeNativeStatusSuggestionsMatch(suggestions, CLAUDE_NATIVE_STATUS_POPUP_BY_PROFILE[plan.behaviorProfile])) {
932
- return undefined;
933
- }
934
- kind = "exact_slash_popup";
935
- }
936
- return {
937
- kind,
938
- digest: createHash("sha256")
939
- .update(lines.slice(openIndex, closeIndex + 1).concat(trailing).join("\n"))
940
- .digest("hex")
941
- };
942
- }
943
- /**
944
- * Claude truncates a suggestion row with a Unicode ellipsis at narrow pane
945
- * widths. Keep authorization closed by accepting only an exact ordered row or
946
- * an explicit ellipsis whose preceding text is an exact, non-trivial prefix of
947
- * that same profiled row. A caller still cannot introduce, omit, or reorder a
948
- * slash command.
949
- */
950
- function closedClaudeNativeStatusSuggestionsMatch(observed, expected) {
951
- if (!expected || observed.length !== expected.length) {
952
- return false;
953
- }
954
- return observed.every((row, index) => {
955
- const exact = expected[index];
956
- if (row === exact) {
957
- return true;
958
- }
959
- if (!row.endsWith("…")) {
960
- return false;
961
- }
962
- const prefix = row.slice(0, -1);
963
- const commandEnd = exact.indexOf(" ");
964
- return (commandEnd > 0 &&
965
- prefix.length >= commandEnd + 12 &&
966
- exact.startsWith(prefix));
967
- });
968
- }
969
- /**
970
- * Prove Claude Code's exact current idle input frame. This is shared by every
971
- * automated-input path: a loose or historical `❯` prompt is not authority to
972
- * inject text into the terminal.
973
- */
974
- export function isExactClaudeIdleComposer(screen) {
975
- const frame = exactClaudeComposerFrame(screen);
976
- if (!frame) {
977
- return false;
978
- }
979
- return (frame.composerRows.length === 1 &&
980
- /^\s*❯\s*$/u.test(frame.composerRows[0]) &&
981
- (frame.trailing.length === 0 ||
982
- claudeNativeInspectionTrailingIsFooter(frame.trailing)));
983
- }
984
- /**
985
- * Compatibility export retained for callers that adopted the native-status
986
- * name before the same exact-frame proof was reused by lifecycle handoff.
987
- */
988
- export function isExactClaudeNativeInspectionIdleComposer(screen) {
989
- return isExactClaudeIdleComposer(screen);
990
- }
991
- export function exactClaudeComposerFrame(screen) {
992
- const lines = screen.replace(/\r\n?/gu, "\n").replace(/\u00a0/gu, " ")
993
- .split("\n");
994
- // Named Claude sessions render the display name inside the upper border.
995
- // It is only frame decoration, never native session or task identity.
996
- const plainDivider = /^\s*[─━]{8,}\s*$/u;
997
- const namedDivider = /^\s*[─━]{8,} [^\x00-\x1f\x7f]{1,128} [─━]+\s*$/u;
998
- const dividerIndexes = lines
999
- .map((line, index) => plainDivider.test(line) || namedDivider.test(line) ? index : -1)
1000
- .filter((index) => index >= 0);
1001
- if (dividerIndexes.length < 2) {
1002
- return undefined;
1003
- }
1004
- const closeIndex = dividerIndexes.at(-1);
1005
- if (!plainDivider.test(lines[closeIndex])) {
1006
- return undefined;
1007
- }
1008
- const openIndex = dividerIndexes.at(-2);
1009
- return {
1010
- lines,
1011
- openIndex,
1012
- closeIndex,
1013
- composerRows: lines.slice(openIndex + 1, closeIndex)
1014
- .filter((line) => line.trim().length > 0),
1015
- trailing: lines.slice(closeIndex + 1)
1016
- .filter((line) => line.trim().length > 0)
1017
- };
1018
- }
1019
- export function claudeNativeInspectionTrailingIsFooter(lines) {
1020
- return lines.length <= 2 && lines.every(isClaudeNativeComposerFooterLine);
1021
- }
1022
- function isClaudeNativeComposerFooterLine(line) {
1023
- return /^\s*(?:[⏵⏴⏸]{1,2}|\?)\s*.*(?:manual mode|shift\+tab|accept edits|bypass permissions|for shortcuts|← for agents)/iu
1024
- .test(line);
1025
- }
1026
- function nativeInspectionScreenFingerprint(screen) {
1027
- return `sha256:${createHash("sha256").update(screen).digest("hex")}`;
1028
- }
1029
- function bareDigestFromNativeInspectionScreenFingerprint(fingerprint) {
1030
- const match = /^sha256:([0-9a-f]{64})$/u.exec(fingerprint);
1031
- if (!match) {
1032
- throw new Error("native inspection screen fingerprint is malformed");
1033
- }
1034
- return match[1];
1035
- }
1036
- export function stripTerminalEscapeSequences(value) {
1037
- return value.replace(/\x1B(?:\[[0-?]*[ -/]*[@-~]|\][^\x07\x1B]*(?:\x07|\x1B\\))/gu, "");
1038
- }
1039
- export function exactCodexReadyStyledComposerCapture(screen, agentVersion) {
1040
- if (isCodexPaginatedReadCandidate(agentVersion)) {
1041
- const frame = captureCodexFullscreenComposerFrame(screen, agentVersion);
1042
- if (!frame || !frame.hasShortcutFooter ||
1043
- !["", "Ask Codex to do anything"].includes(frame.composerText)) {
1044
- return undefined;
1045
- }
1046
- }
1047
- const lines = screen.replace(/\r\n?/gu, "\n").split("\n");
1048
- while (lines.length > 0 &&
1049
- stripTerminalEscapeSequences(lines.at(-1) ?? "").trim().length === 0) {
1050
- lines.pop();
1051
- }
1052
- const composerLine = [...lines.slice(-12)].reverse().find((line) => CODEX_COMPOSER_MARKER.test(stripTerminalEscapeSequences(line).trimEnd()));
1053
- if (composerLine === undefined) {
1054
- return undefined;
1055
- }
1056
- let dim = false;
1057
- const visible = [];
1058
- for (let index = 0; index < composerLine.length;) {
1059
- if (composerLine[index] === "\x1b") {
1060
- const escape = /^(?:\x1B\[([0-9;]*)m|\x1B\][^\x07\x1B]*(?:\x07|\x1B\\))/u
1061
- .exec(composerLine.slice(index));
1062
- if (escape) {
1063
- if (escape[1] !== undefined) {
1064
- const codes = escape[1] === ""
1065
- ? [0]
1066
- : escape[1].split(";").map((value) => Number(value));
1067
- for (let codeIndex = 0; codeIndex < codes.length; codeIndex += 1) {
1068
- const code = codes[codeIndex];
1069
- if ([38, 48, 58].includes(code) &&
1070
- codes[codeIndex + 1] === 2) {
1071
- codeIndex += 4;
1072
- continue;
1073
- }
1074
- if ([38, 48, 58].includes(code) &&
1075
- codes[codeIndex + 1] === 5) {
1076
- codeIndex += 2;
1077
- continue;
1078
- }
1079
- if (code === 0 || code === 22) {
1080
- dim = false;
1081
- }
1082
- else if (code === 2) {
1083
- dim = true;
1084
- }
1085
- }
1086
- }
1087
- index += escape[0].length;
1088
- continue;
1089
- }
1090
- }
1091
- const codePoint = composerLine.codePointAt(index);
1092
- if (codePoint === undefined) {
1093
- break;
1094
- }
1095
- const character = String.fromCodePoint(codePoint);
1096
- visible.push({ character, dim });
1097
- index += character.length;
1098
- }
1099
- const promptIndex = visible.findIndex(({ character }) => character === "›" || character === "»");
1100
- if (promptIndex < 0) {
1101
- return undefined;
1102
- }
1103
- const content = visible.slice(promptIndex + 1)
1104
- .filter(({ character }) => !/^\s$/u.test(character));
1105
- if (content.length > 0 && !content.every((entry) => entry.dim)) {
1106
- return undefined;
1107
- }
1108
- return {
1109
- digest: createHash("sha256").update(composerLine).digest("hex")
1110
- };
1111
- }
1112
- /**
1113
- * Infer a viewport only from fixed-width visible-buffer rows. Trimmed captures
1114
- * deliberately return undefined: a short content row is not proof of a short
1115
- * terminal. This keeps the fallback provider-neutral and fail-closed only on
1116
- * positive geometry evidence.
1117
- */
1118
- export function inferCodexVisibleViewportColumns(screen) {
1119
- const rows = screen.replace(/\r\n?/gu, "\n").split("\n")
1120
- .map(stripTerminalEscapeSequences);
1121
- const widthOneRows = rows.filter((row) => /^[\x20-\x7e›»·─━╭╮╰╯│]*$/u.test(row));
1122
- const maxWidth = widthOneRows.reduce((maximum, row) => Math.max(maximum, Array.from(row).length), 0);
1123
- if (maxWidth < 20) {
1124
- return undefined;
1125
- }
1126
- const paddedAtMax = widthOneRows.filter((row) => row.endsWith(" ") && Array.from(row).length === maxWidth);
1127
- const composerAtMax = paddedAtMax.some((row) => CODEX_COMPOSER_MARKER.test(row.trimEnd()));
1128
- return paddedAtMax.length >= 3 && composerAtMax
1129
- ? maxWidth
1130
- : undefined;
1131
- }
1132
- function hasTruncatedCodexStatusSessionLine(screen) {
1133
- return screen.replace(/\r\n?/gu, "\n").split("\n").some((line) => {
1134
- const match = /^\s*│\s*Session:\s*([^│\s]+).*│?\s*$/iu.exec(line);
1135
- if (!match) {
1136
- return false;
1137
- }
1138
- return !/^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/iu
1139
- .test(match[1]);
1140
- });
1141
- }
1142
- function codexNativeInspectionComposerMismatchDiagnostic(screen, plan) {
1143
- const expectedRows = codexNativeStatusPopupRows(plan);
1144
- if (!expectedRows) {
1145
- return "composer_not_exact";
1146
- }
1147
- const lines = screen.replace(/\r\n?/gu, "\n").split("\n");
1148
- let composerIndex = -1;
1149
- for (let index = lines.length - 1; index >= 0; index -= 1) {
1150
- if (CODEX_COMPOSER_MARKER.test(lines[index])) {
1151
- composerIndex = index;
1152
- break;
1153
- }
1154
- }
1155
- if (composerIndex < 0 ||
1156
- lines[composerIndex].replace(/^[›»]\s?/u, "").trimEnd() !== plan.command) {
1157
- return "composer_not_exact";
1158
- }
1159
- const footerIndex = lines.findIndex((line, index) => index > composerIndex && CODEX_COMPOSER_FOOTER.test(line.trim()));
1160
- const popupRows = lines.slice(composerIndex + 1, footerIndex < 0 ? lines.length : footerIndex).filter((line) => line.trim().length > 0);
1161
- if (popupRows.length === 0) {
1162
- return "composer_not_exact";
1163
- }
1164
- const logicalRows = [];
1165
- let observedTruncation = false;
1166
- for (const row of popupRows) {
1167
- const trimmed = row.trim().replace(/\s+/gu, " ");
1168
- if (trimmed.startsWith("/")) {
1169
- logicalRows.push(trimmed);
1170
- }
1171
- else if (logicalRows.length > 0) {
1172
- logicalRows[logicalRows.length - 1] += ` ${trimmed}`;
1173
- observedTruncation = true;
1174
- }
1175
- else {
1176
- return "composer_not_exact";
1177
- }
1178
- observedTruncation ||= trimmed.endsWith("…");
1179
- }
1180
- const normalizedExpected = expectedRows.map((row) => row.trim().replace(/\s+/gu, " "));
1181
- const everyKnownPrefix = logicalRows.length <= normalizedExpected.length &&
1182
- logicalRows.every((row, index) => {
1183
- const withoutEllipsis = row.endsWith("…")
1184
- ? row.slice(0, -1).trimEnd()
1185
- : row;
1186
- return normalizedExpected[index]?.startsWith(withoutEllipsis) === true;
1187
- });
1188
- return observedTruncation && everyKnownPrefix
1189
- ? "composer_viewport_truncated"
1190
- : "composer_not_exact";
1191
- }
1192
- function codexFullscreenStatusVersion(plan) {
1193
- const version = /^codex-tui-fullscreen-status-v1@(\d+\.\d+\.\d+)$/u
1194
- .exec(plan.behaviorProfile)?.[1] ??
1195
- (CODEX_NATIVE_STATUS_POPUP_BY_PROFILE[plan.behaviorProfile]
1196
- ? /^codex-tui-(\d+\.\d+\.\d+)$/u.exec(plan.behaviorProfile)?.[1]
1197
- : undefined);
1198
- return isCodexPaginatedReadCandidate(version) ? version : undefined;
1199
- }
1200
- function codexNativeStatusPopupRows(plan) {
1201
- return CODEX_NATIVE_STATUS_POPUP_BY_PROFILE[plan.behaviorProfile] ??
1202
- (codexFullscreenStatusVersion(plan)
1203
- ? CODEX_FULLSCREEN_STATUS_POPUP_ROWS
1204
- : undefined);
1205
- }
1206
- function codexNativeStatusMinimumViewport(plan) {
1207
- return CODEX_NATIVE_STATUS_MIN_VIEWPORT_BY_PROFILE[plan.behaviorProfile] ??
1208
- (codexFullscreenStatusVersion(plan) ? 80 : undefined);
1209
- }
1210
571
  //# sourceMappingURL=terminal-native-inspection-bridge.js.map