@myagentroam/node 0.1.3 → 0.1.6

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 (195) hide show
  1. package/README.md +9 -1
  2. package/dist/capabilities.d.ts +2 -0
  3. package/dist/capabilities.js +15 -4
  4. package/dist/claude-agent-sdk.d.ts +4 -16
  5. package/dist/claude-agent-sdk.js +18 -79
  6. package/dist/claude-channel.js +0 -1
  7. package/dist/codex-app-server.d.ts +5 -0
  8. package/dist/codex-app-server.js +26 -5
  9. package/dist/config.d.ts +3 -0
  10. package/dist/config.js +18 -2
  11. package/dist/connector/node-connector-options.d.ts +26 -0
  12. package/dist/connector/node-connector-options.js +1 -0
  13. package/dist/connector/node-operation-router.d.ts +9 -0
  14. package/dist/connector/node-operation-router.js +22 -0
  15. package/dist/connector.d.ts +62 -356
  16. package/dist/connector.js +714 -6176
  17. package/dist/control-outbound-scheduler.d.ts +26 -0
  18. package/dist/control-outbound-scheduler.js +121 -0
  19. package/dist/database.d.ts +4 -0
  20. package/dist/database.js +15 -10
  21. package/dist/event-buffer.js +0 -1
  22. package/dist/fake-runner.js +0 -1
  23. package/dist/health.js +0 -1
  24. package/dist/main.js +6 -1
  25. package/dist/migrations/v001.js +0 -1
  26. package/dist/migrations/v002.js +0 -1
  27. package/dist/migrations/v003.d.ts +4 -0
  28. package/dist/migrations/v003.js +44 -0
  29. package/dist/native-jsonl-reader.d.ts +14 -0
  30. package/dist/native-jsonl-reader.js +97 -0
  31. package/dist/native-session-history.d.ts +41 -4
  32. package/dist/native-session-history.js +340 -159
  33. package/dist/opencode-runtime.d.ts +33 -0
  34. package/dist/opencode-runtime.js +80 -0
  35. package/dist/opencode-server.d.ts +47 -0
  36. package/dist/opencode-server.js +250 -0
  37. package/dist/operational.js +10 -3
  38. package/dist/process-tree.js +0 -1
  39. package/dist/runner/abstract-runner.d.ts +153 -0
  40. package/dist/runner/abstract-runner.js +154 -0
  41. package/dist/runner/claude/managed-run-controller.d.ts +52 -0
  42. package/dist/runner/claude/managed-run-controller.js +326 -0
  43. package/dist/runner/claude-code-runner.d.ts +70 -0
  44. package/dist/runner/claude-code-runner.js +286 -0
  45. package/dist/runner/codex/conversation-parser.d.ts +59 -0
  46. package/dist/runner/codex/conversation-parser.js +816 -0
  47. package/dist/runner/codex/managed-run-controller.d.ts +80 -0
  48. package/dist/runner/codex/managed-run-controller.js +388 -0
  49. package/dist/runner/codex-runner.d.ts +85 -0
  50. package/dist/runner/codex-runner.js +365 -0
  51. package/dist/runner/fake-test-runner.d.ts +26 -0
  52. package/dist/runner/fake-test-runner.js +47 -0
  53. package/dist/runner/opencode/conversation-parser.d.ts +27 -0
  54. package/dist/runner/opencode/conversation-parser.js +217 -0
  55. package/dist/runner/opencode/managed-run-controller.d.ts +76 -0
  56. package/dist/runner/opencode/managed-run-controller.js +451 -0
  57. package/dist/runner/opencode-runner.d.ts +60 -0
  58. package/dist/runner/opencode-runner.js +330 -0
  59. package/dist/runner/runner-registry.d.ts +19 -0
  60. package/dist/runner/runner-registry.js +75 -0
  61. package/dist/runner-command-engine.js +0 -1
  62. package/dist/runner-profiles.d.ts +4 -0
  63. package/dist/runner-profiles.js +76 -3
  64. package/dist/runner-usage.d.ts +2 -2
  65. package/dist/runner-usage.js +3 -6
  66. package/dist/runtime-state.js +26 -14
  67. package/dist/service/attachment-domain-state.d.ts +5 -0
  68. package/dist/service/attachment-domain-state.js +5 -0
  69. package/dist/service/conversation-history-service.d.ts +34 -0
  70. package/dist/service/conversation-history-service.js +158 -0
  71. package/dist/service/external-session-resume-service.d.ts +32 -0
  72. package/dist/service/external-session-resume-service.js +98 -0
  73. package/dist/service/fake-managed-run-service.d.ts +29 -0
  74. package/dist/service/fake-managed-run-service.js +62 -0
  75. package/dist/service/managed-runner-session-service.d.ts +12 -0
  76. package/dist/service/managed-runner-session-service.js +35 -0
  77. package/dist/service/native-session-projection-service.d.ts +51 -0
  78. package/dist/service/native-session-projection-service.js +271 -0
  79. package/dist/service/native-session-watch-service.d.ts +37 -0
  80. package/dist/service/native-session-watch-service.js +150 -0
  81. package/dist/service/node-connection-lifecycle-service.d.ts +37 -0
  82. package/dist/service/node-connection-lifecycle-service.js +85 -0
  83. package/dist/service/node-control-channel.d.ts +32 -0
  84. package/dist/service/node-control-channel.js +85 -0
  85. package/dist/service/node-control-message-service.d.ts +28 -0
  86. package/dist/service/node-control-message-service.js +104 -0
  87. package/dist/service/node-request-service.d.ts +14 -0
  88. package/dist/service/node-request-service.js +50 -0
  89. package/dist/service/node-run-event-bridge.d.ts +40 -0
  90. package/dist/service/node-run-event-bridge.js +83 -0
  91. package/dist/service/node-terminal-channel.d.ts +29 -0
  92. package/dist/service/node-terminal-channel.js +182 -0
  93. package/dist/service/node-upgrade-coordinator.d.ts +29 -0
  94. package/dist/service/node-upgrade-coordinator.js +137 -0
  95. package/dist/service/node-workspace-coordinator.d.ts +32 -0
  96. package/dist/service/node-workspace-coordinator.js +80 -0
  97. package/dist/service/run-attachment-service.d.ts +37 -0
  98. package/dist/service/run-attachment-service.js +160 -0
  99. package/dist/service/run-domain-state.d.ts +4 -0
  100. package/dist/service/run-domain-state.js +4 -0
  101. package/dist/service/run-event-service.d.ts +31 -0
  102. package/dist/service/run-event-service.js +102 -0
  103. package/dist/service/run-workbench-service.d.ts +27 -0
  104. package/dist/service/run-workbench-service.js +113 -0
  105. package/dist/service/runner-channel-message-service.d.ts +13 -0
  106. package/dist/service/runner-channel-message-service.js +20 -0
  107. package/dist/service/runner-interaction-service.d.ts +40 -0
  108. package/dist/service/runner-interaction-service.js +246 -0
  109. package/dist/service/runner-service.d.ts +44 -0
  110. package/dist/service/runner-service.js +68 -0
  111. package/dist/service/session-catalog-service.d.ts +45 -0
  112. package/dist/service/session-catalog-service.js +224 -0
  113. package/dist/service/session-command-service.d.ts +23 -0
  114. package/dist/service/session-command-service.js +69 -0
  115. package/dist/service/session-context-service.d.ts +34 -0
  116. package/dist/service/session-context-service.js +87 -0
  117. package/dist/service/session-domain-state.d.ts +8 -0
  118. package/dist/service/session-domain-state.js +8 -0
  119. package/dist/service/session-identity-service.d.ts +24 -0
  120. package/dist/service/session-identity-service.js +86 -0
  121. package/dist/service/session-lifecycle-service.d.ts +31 -0
  122. package/dist/service/session-lifecycle-service.js +242 -0
  123. package/dist/service/session-message-service.d.ts +33 -0
  124. package/dist/service/session-message-service.js +157 -0
  125. package/dist/service/session-presentation-service.d.ts +33 -0
  126. package/dist/service/session-presentation-service.js +36 -0
  127. package/dist/service/session-query-service.d.ts +31 -0
  128. package/dist/service/session-query-service.js +77 -0
  129. package/dist/service/terminal-relay-state.d.ts +6 -0
  130. package/dist/service/terminal-relay-state.js +3 -0
  131. package/dist/service/terminal-service.d.ts +12 -0
  132. package/dist/service/terminal-service.js +52 -0
  133. package/dist/service/workbench-event-service.d.ts +21 -0
  134. package/dist/service/workbench-event-service.js +53 -0
  135. package/dist/service/workbench-manifest-service.d.ts +89 -0
  136. package/dist/service/workbench-manifest-service.js +70 -0
  137. package/dist/service/workspace-change-service.d.ts +9 -0
  138. package/dist/service/workspace-change-service.js +86 -0
  139. package/dist/service/workspace-content-search-service.d.ts +14 -0
  140. package/dist/service/workspace-content-search-service.js +477 -0
  141. package/dist/service/workspace-domain-state.d.ts +75 -0
  142. package/dist/service/workspace-domain-state.js +40 -0
  143. package/dist/service/workspace-file-service.d.ts +17 -0
  144. package/dist/service/workspace-file-service.js +109 -0
  145. package/dist/service/workspace-queue-workbench-service.d.ts +55 -0
  146. package/dist/service/workspace-queue-workbench-service.js +226 -0
  147. package/dist/service/workspace-service.d.ts +15 -0
  148. package/dist/service/workspace-service.js +67 -0
  149. package/dist/service/workspace-session-service.d.ts +23 -0
  150. package/dist/service/workspace-session-service.js +139 -0
  151. package/dist/service/workspace-upload-service.d.ts +37 -0
  152. package/dist/service/workspace-upload-service.js +240 -0
  153. package/dist/service/workspace-watch-service.d.ts +18 -0
  154. package/dist/service/workspace-watch-service.js +120 -0
  155. package/dist/service/workspace-workbench-service.d.ts +47 -0
  156. package/dist/service/workspace-workbench-service.js +223 -0
  157. package/dist/service.js +2 -3
  158. package/dist/storage.js +0 -1
  159. package/dist/supervisor.d.ts +1 -0
  160. package/dist/supervisor.js +154 -0
  161. package/dist/terminal.d.ts +1 -0
  162. package/dist/terminal.js +1 -2
  163. package/dist/util/node-operation-parsers.d.ts +92 -0
  164. package/dist/util/node-operation-parsers.js +382 -0
  165. package/dist/util/runner-native-session-parsers.d.ts +72 -0
  166. package/dist/util/runner-native-session-parsers.js +381 -0
  167. package/dist/util/secret-environment.d.ts +1 -0
  168. package/dist/util/secret-environment.js +25 -0
  169. package/dist/workspace.d.ts +62 -2
  170. package/dist/workspace.js +539 -57
  171. package/package.json +3 -2
  172. package/dist/capabilities.js.map +0 -1
  173. package/dist/claude-agent-sdk.js.map +0 -1
  174. package/dist/claude-channel.js.map +0 -1
  175. package/dist/codex-app-server.js.map +0 -1
  176. package/dist/config.js.map +0 -1
  177. package/dist/connector.js.map +0 -1
  178. package/dist/database.js.map +0 -1
  179. package/dist/event-buffer.js.map +0 -1
  180. package/dist/fake-runner.js.map +0 -1
  181. package/dist/health.js.map +0 -1
  182. package/dist/main.js.map +0 -1
  183. package/dist/migrations/v001.js.map +0 -1
  184. package/dist/migrations/v002.js.map +0 -1
  185. package/dist/native-session-history.js.map +0 -1
  186. package/dist/operational.js.map +0 -1
  187. package/dist/process-tree.js.map +0 -1
  188. package/dist/runner-command-engine.js.map +0 -1
  189. package/dist/runner-profiles.js.map +0 -1
  190. package/dist/runner-usage.js.map +0 -1
  191. package/dist/runtime-state.js.map +0 -1
  192. package/dist/service.js.map +0 -1
  193. package/dist/storage.js.map +0 -1
  194. package/dist/terminal.js.map +0 -1
  195. package/dist/workspace.js.map +0 -1
@@ -0,0 +1,286 @@
1
+ import { ClaudeAgentSdkAdapter } from '../claude-agent-sdk.js';
2
+ import { AbstractRunner } from './abstract-runner.js';
3
+ import { claudeDefaultModel, declaredRunnerProfiles } from '../runner-profiles.js';
4
+ import { withClaudePlanTag } from '../runner-command-engine.js';
5
+ import { discoverNativeSessions, readNativeSession, readClaudeNativeContextUsage } from '../native-session-history.js';
6
+ import { claudeDiscoveredSession, deduplicateDirectSessions, externalResumeFailureDetail, isNativeHistory, isWithinWorkspace, latestNativeActivity } from './codex/conversation-parser.js';
7
+ export class ClaudeCodeRunner extends AbstractRunner {
8
+ client;
9
+ environment;
10
+ name = 'claude-code';
11
+ discoveryScope = 'WORKSPACE_REQUIRED';
12
+ execution = new ClaudeExecutionState();
13
+ constructor(client = new ClaudeAgentSdkAdapter(), environment = process.env) {
14
+ super();
15
+ this.client = client;
16
+ this.environment = environment;
17
+ }
18
+ profile(capabilities) {
19
+ return declaredRunnerProfiles({
20
+ codexAvailable: capabilities.codex.available,
21
+ claudeCodeAvailable: capabilities.claudeCode.available,
22
+ environment: this.environment,
23
+ openCodeAvailable: capabilities.openCode?.available === true
24
+ }).find((profile) => profile.runner === this.name);
25
+ }
26
+ available(capabilities) {
27
+ return capabilities.claudeCode.available;
28
+ }
29
+ profileForValidation() {
30
+ return this.profile({
31
+ platform: 'linux',
32
+ architecture: 'validation',
33
+ nodeAppVersion: 'validation',
34
+ nodeVersion: 'validation',
35
+ codex: { available: false },
36
+ claudeCode: { available: true },
37
+ openCode: { available: false }
38
+ });
39
+ }
40
+ defaultConfiguration() {
41
+ return {
42
+ runner: this.name,
43
+ model: claudeDefaultModel(this.environment),
44
+ effort: 'medium',
45
+ access: 'default'
46
+ };
47
+ }
48
+ async resumeExternal(external, context) {
49
+ if (external.runner !== this.name ||
50
+ external.nativeControl !== 'EXTERNAL' ||
51
+ external.externalSessionId === null ||
52
+ !context.available)
53
+ return {
54
+ failureCode: 'RUNNER_UNAVAILABLE',
55
+ messageFailureCode: 'SESSION_RESUME_REJECTED'
56
+ };
57
+ const nativeAlias = context.managedAliasFor(external);
58
+ if (nativeAlias !== undefined)
59
+ return { session: context.ensureConfiguration(nativeAlias), activity: 'IDLE' };
60
+ const existing = context.currentResumed(external.id);
61
+ if (existing !== undefined)
62
+ return { session: context.ensureConfiguration(existing), activity: 'IDLE' };
63
+ try {
64
+ const sessionInfo = await this.sessionInfo(external.externalSessionId, external.cwd);
65
+ if (sessionInfo === undefined)
66
+ return {
67
+ failureCode: 'RUNNER_SESSION_NOT_FOUND',
68
+ messageFailureCode: 'SESSION_RESUME_REJECTED'
69
+ };
70
+ const workspacePath = context.workspacePath(external.workspaceId);
71
+ if (workspacePath === undefined ||
72
+ (typeof sessionInfo.cwd === 'string' && !isWithinWorkspace(sessionInfo.cwd, workspacePath)))
73
+ return {
74
+ failureCode: 'RUNNER_SESSION_WORKSPACE_MISMATCH',
75
+ messageFailureCode: 'SESSION_RESUME_REJECTED'
76
+ };
77
+ const resumed = context.currentResumed(external.id);
78
+ if (resumed !== undefined)
79
+ return { session: context.ensureConfiguration(resumed), activity: 'IDLE' };
80
+ const projection = context.projectionFor(external);
81
+ const session = projection === undefined ? context.create(external) : context.promote(projection.id);
82
+ if (session === undefined)
83
+ return {
84
+ failureCode: 'RUNNER_RESUME_FAILED',
85
+ messageFailureCode: 'SESSION_RESUME_REJECTED'
86
+ };
87
+ const configured = context.ensureConfiguration(session);
88
+ context.rememberManagedNative(external.externalSessionId, configured.id);
89
+ return { session: configured, activity: 'IDLE' };
90
+ }
91
+ catch (error) {
92
+ return {
93
+ failureCode: 'RUNNER_RESUME_FAILED',
94
+ messageFailureCode: 'SESSION_RESUME_REJECTED',
95
+ failureDetail: externalResumeFailureDetail(error)
96
+ };
97
+ }
98
+ }
99
+ async discoverSessions(context, workspace) {
100
+ const sessions = [];
101
+ for (const target of workspace === undefined ? context.workspaces : [workspace]) {
102
+ let official = [];
103
+ try {
104
+ official = await this.listSessions(target.path);
105
+ }
106
+ catch {
107
+ // Native transcripts remain authoritative when SDK listing is unavailable.
108
+ }
109
+ const native = await discoverNativeSessions(this.name, target.path);
110
+ sessions.push(...this.projectDiscoveredSessions(context, target, [
111
+ ...official.flatMap((value) => {
112
+ const parsed = claudeDiscoveredSession(value, target.path);
113
+ return parsed === undefined ? [] : [parsed];
114
+ }),
115
+ ...native
116
+ ]));
117
+ }
118
+ return deduplicateDirectSessions(sessions);
119
+ }
120
+ readContextUsage(session) {
121
+ return session.externalSessionId === null
122
+ ? Promise.resolve(undefined)
123
+ : readClaudeNativeContextUsage(session.cwd, session.externalSessionId);
124
+ }
125
+ forkNative(session, boundary, title) {
126
+ if (session.externalSessionId === null)
127
+ throw new Error('SESSION_REWIND_UNAVAILABLE');
128
+ return boundary === null
129
+ ? Promise.resolve(null)
130
+ : this.client.forkSession(session.externalSessionId, session.cwd, boundary, title);
131
+ }
132
+ presentSession(session, capabilities, context) {
133
+ if (capabilities.claudeCode.available && session.nativeControl === 'MAR_MANAGED') {
134
+ const runtimeCapabilities = [
135
+ 'history.read',
136
+ 'events.live',
137
+ 'turn.start',
138
+ 'turn.queue',
139
+ 'turn.interrupt',
140
+ 'run.cancel',
141
+ 'approval.respond',
142
+ 'session.rename',
143
+ 'session.remove',
144
+ 'session.pin',
145
+ ...(session.externalSessionId === null ? [] : ['session.rewind'])
146
+ ];
147
+ return {
148
+ activity: context.managedActive ? 'MANAGED_ACTIVE' : 'IDLE',
149
+ control: {
150
+ level: 'MANAGED',
151
+ capabilities: ['history.read', 'events.live', 'turn.start', 'turn.interrupt']
152
+ },
153
+ commandStates: context.commandStates,
154
+ runtime: { level: 'MANAGED', capabilities: runtimeCapabilities, reasonCode: null }
155
+ };
156
+ }
157
+ if (capabilities.claudeCode.available && session.externalSessionId !== null) {
158
+ const runtimeCapabilities = [
159
+ 'history.read',
160
+ 'turn.start',
161
+ 'session.rename',
162
+ 'session.remove',
163
+ 'session.pin',
164
+ 'session.rewind'
165
+ ];
166
+ return {
167
+ activity: 'IDLE',
168
+ control: { level: 'RESUMABLE', capabilities: ['history.read', 'turn.start'] },
169
+ commandStates: context.commandStates,
170
+ runtime: { level: 'RESUMABLE', capabilities: runtimeCapabilities, reasonCode: null }
171
+ };
172
+ }
173
+ const runtimeCapabilities = [
174
+ 'history.read',
175
+ 'events.live',
176
+ 'session.rename',
177
+ 'session.remove',
178
+ 'session.pin'
179
+ ];
180
+ return {
181
+ activity: 'UNAVAILABLE',
182
+ control: { level: 'OBSERVE_ONLY', capabilities: ['history.read', 'events.live'] },
183
+ commandStates: context.commandStates,
184
+ runtime: {
185
+ level: 'OBSERVE_ONLY',
186
+ capabilities: runtimeCapabilities,
187
+ reasonCode: 'EXTERNAL_SESSION_OBSERVE_ONLY'
188
+ }
189
+ };
190
+ }
191
+ prepareMessageInput(input, collaborationMode) {
192
+ return collaborationMode === 'plan' ? withClaudePlanTag(input) : input;
193
+ }
194
+ channelToken(sessionId) {
195
+ return [...this.execution.runs.values()].find((run) => run.marSessionId === sessionId)?.gate
196
+ .token;
197
+ }
198
+ deliverChannel(sessionId, messageId, senderId, token, content, notify) {
199
+ const found = [...this.execution.runs.entries()].find(([, value]) => value.marSessionId === sessionId);
200
+ if (found === undefined)
201
+ return 'REJECTED';
202
+ const [runId, active] = found;
203
+ const prior = active.gate.delivery(messageId);
204
+ const accepted = active.gate.accept({ id: messageId, senderId, token, content });
205
+ if (accepted === 'REJECTED') {
206
+ if (prior === undefined)
207
+ notify(runId, messageId, 'REJECTED');
208
+ return 'REJECTED';
209
+ }
210
+ if (prior === undefined && accepted === 'PENDING_RECEIPT') {
211
+ void active.handle.deliver(content).then(() => notify(runId, messageId, active.gate.acknowledge({ messageId, result: 'STEERED' })), () => notify(runId, messageId, active.gate.acknowledge({ messageId, result: 'REJECTED' })));
212
+ }
213
+ return accepted;
214
+ }
215
+ managedAliasId(nativeSessionId) {
216
+ return this.execution.managedSessionByNativeId.get(nativeSessionId);
217
+ }
218
+ nativeAliasesFor(managedSessionId) {
219
+ return [...this.execution.managedSessionByNativeId]
220
+ .filter(([, sessionId]) => sessionId === managedSessionId)
221
+ .map(([nativeSessionId]) => nativeSessionId);
222
+ }
223
+ forgetNativeAlias(nativeSessionId) {
224
+ this.execution.managedSessionByNativeId.delete(nativeSessionId);
225
+ this.execution.managedNativeIds.delete(nativeSessionId);
226
+ }
227
+ rememberManagedNative(session, nativeSessionId) {
228
+ this.execution.managedNativeIds.add(nativeSessionId);
229
+ this.execution.managedSessionByNativeId.set(nativeSessionId, session.id);
230
+ }
231
+ async readManagedRunnerTitle(session, nativeSessionId) {
232
+ let history = await readNativeSession(this.name, session.cwd, nativeSessionId);
233
+ if (history === undefined) {
234
+ const discovered = await discoverNativeSessions(this.name, session.cwd);
235
+ history = discovered.find((candidate) => candidate.externalSessionId === nativeSessionId);
236
+ }
237
+ return history?.title;
238
+ }
239
+ projectDiscoveredSessions(context, workspace, discovered) {
240
+ const sessions = [];
241
+ for (const item of discovered) {
242
+ if (!isWithinWorkspace(item.cwd, workspace.path))
243
+ continue;
244
+ const session = context.createProjection({
245
+ workspace,
246
+ runner: this.name,
247
+ externalSessionId: item.externalSessionId,
248
+ cwd: item.cwd,
249
+ ...(item.title === undefined ? {} : { title: item.title }),
250
+ ...(isNativeHistory(item) ? { lastActivityAt: latestNativeActivity(item) } : {})
251
+ });
252
+ const index = sessions.findIndex((candidate) => candidate.id === session.id);
253
+ if (index < 0)
254
+ sessions.push(session);
255
+ else if (session.lastActivityAt >= sessions[index].lastActivityAt) {
256
+ const existing = sessions[index];
257
+ sessions[index] = {
258
+ ...session,
259
+ runnerTitle: session.runnerTitle ?? existing.runnerTitle,
260
+ titleSource: session.runnerTitle === null ? existing.titleSource : session.titleSource
261
+ };
262
+ }
263
+ }
264
+ return deduplicateDirectSessions(sessions);
265
+ }
266
+ stop() { }
267
+ start(input) {
268
+ return this.client.start(input);
269
+ }
270
+ startChannel(input) {
271
+ return this.client.startChannel(input);
272
+ }
273
+ listSessions(cwd) {
274
+ return this.client.listSessions(cwd);
275
+ }
276
+ sessionInfo(sessionId, cwd) {
277
+ return this.client.sessionInfo(sessionId, cwd);
278
+ }
279
+ }
280
+ export class ClaudeExecutionState {
281
+ runs = new Map();
282
+ managedNativeIds = new Set();
283
+ managedSessionByNativeId = new Map();
284
+ approvals = new Map();
285
+ userInputs = new Map();
286
+ }
@@ -0,0 +1,59 @@
1
+ import type { NodeAgentSession, NodeConversationItem, NodeConversationTurn, NodeMessageAttachmentInput } from '../../database.js';
2
+ export type PublicConversationItem = {
3
+ readonly itemId: string;
4
+ readonly kind: 'reasoning_summary' | 'tool_call' | 'command_execution' | 'user_input_request' | 'plan' | 'context_compaction' | 'file_change' | 'unknown';
5
+ readonly status: 'PENDING' | 'IN_PROGRESS' | 'COMPLETED' | 'FAILED' | 'DECLINED';
6
+ readonly payload: Record<string, unknown>;
7
+ readonly merge?: boolean;
8
+ readonly append?: 'sections' | 'outputPreview' | 'outputSummary';
9
+ };
10
+ export * from '../../util/runner-native-session-parsers.js';
11
+ export declare function codexOfficialConversationPage(session: NodeAgentSession, result: unknown, input: {
12
+ readonly cursor?: string;
13
+ readonly limit?: number;
14
+ }, managedTurnForNative: (nativeTurnId: string) => NodeConversationTurn | undefined): {
15
+ readonly turns: readonly NodeConversationTurn[];
16
+ readonly nextCursor: string | null;
17
+ } | undefined;
18
+ export declare function codexOfficialTurn(session: NodeAgentSession, value: unknown, sequence: number, managedTurn: NodeConversationTurn | undefined): NodeConversationTurn | undefined;
19
+ /**
20
+ * Codex's authoritative thread records omit MAR's Node-local generated-image
21
+ * references. Preserve those references like user-image metadata: cache expiry
22
+ * only makes the bytes unavailable, while the conversation still renders its
23
+ * image placeholder.
24
+ */
25
+ export declare function retainManagedImageAttachments(managedTurn: NodeConversationTurn, nativeTurnId: string, officialItems: readonly NodeConversationItem[]): readonly NodeConversationItem[];
26
+ export declare function codexNativeItemIds(values: readonly unknown[]): ReadonlySet<string>;
27
+ export declare function conversationItemNativeId(itemId: string): string | undefined;
28
+ /** Keep a custom tool invocation and its output in one Workbench card. */
29
+ export declare function codexOfficialItems(session: NodeAgentSession, nativeTurnId: string, values: readonly unknown[], turnSequence: number, startedAt: number | null, completedAt: number | null): NodeConversationItem[];
30
+ export declare function codexPairedToolCallId(value: unknown): string | undefined;
31
+ export declare function mergeCodexCustomToolItems(invocation: NodeConversationItem, result: NodeConversationItem): NodeConversationItem;
32
+ export declare function coalesceImageGenerationItems(items: readonly NodeConversationItem[]): readonly NodeConversationItem[];
33
+ export declare function codexPlanText(value: Record<string, unknown>): string | undefined;
34
+ /**
35
+ * Claude 标签式 Plan Mode 的最终计划以 `<proposed_plan>` 完整包裹输出;
36
+ * 未闭合或缺失标签的文本保持普通 assistant 消息。
37
+ */
38
+ export declare function codexOfficialItem(session: NodeAgentSession, nativeTurnId: string, value: unknown, turnSequence: number, itemSequence: number, startedAt: number | null, completedAt: number | null): NodeConversationItem | undefined;
39
+ export declare function codexLiveConversationItem(value: Record<string, unknown>, completed: boolean, imageAttachments?: readonly Record<string, unknown>[]): PublicConversationItem | undefined;
40
+ export declare function codexImageAttachments(value: unknown): readonly NodeMessageAttachmentInput[];
41
+ export declare function codexUserInputQuestions(value: unknown): readonly {
42
+ readonly id: string;
43
+ readonly prompt: string;
44
+ readonly options: readonly {
45
+ readonly value: string;
46
+ readonly label: string;
47
+ readonly description: string | null;
48
+ }[];
49
+ readonly allowOther: boolean;
50
+ }[];
51
+ export declare function codexItemStatus(value: unknown, completed: boolean): PublicConversationItem['status'];
52
+ export declare function codexContentText(value: unknown): string;
53
+ export declare function codexCompactJson(value: unknown): string;
54
+ export declare function codexToolOutputSummary(value: unknown): string;
55
+ /** App Server custom output is an array of text blocks, not JSON to show verbatim. */
56
+ export declare function codexToolOutput(value: unknown): unknown;
57
+ export declare function codexVisibleToolText(value: string): string;
58
+ export declare function isCodexImageBlock(value: unknown): boolean;
59
+ export * from '../../util/node-operation-parsers.js';