@myagentroam/node 0.9.9 → 0.9.10

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 (214) hide show
  1. package/dist/capabilities.js +2 -92
  2. package/dist/claude-agent-sdk.js +2 -330
  3. package/dist/claude-channel.js +2 -44
  4. package/dist/codex-app-server.js +2 -503
  5. package/dist/config.js +2 -56
  6. package/dist/connector/node-connector-options.js +2 -1
  7. package/dist/connector/node-operation-router.js +2 -22
  8. package/dist/connector.js +2 -845
  9. package/dist/control-outbound-scheduler.js +2 -154
  10. package/dist/database.js +2 -1418
  11. package/dist/event-buffer.js +2 -19
  12. package/dist/fake-runner.js +2 -129
  13. package/dist/health.js +2 -3
  14. package/dist/main.js +2 -54
  15. package/dist/migrations/v001.js +3 -144
  16. package/dist/migrations/v002.js +2 -143
  17. package/dist/migrations/v003.js +2 -44
  18. package/dist/migrations/v004.js +34 -30
  19. package/dist/native-jsonl-reader.js +2 -186
  20. package/dist/native-session-history.js +2 -1119
  21. package/dist/opencode-runtime.js +2 -80
  22. package/dist/opencode-server.js +2 -263
  23. package/dist/operational.js +2 -122
  24. package/dist/process-tree.js +2 -18
  25. package/dist/rotating-log.js +2 -67
  26. package/dist/runner/abstract-runner.js +2 -232
  27. package/dist/runner/claude/managed-run-controller.js +2 -345
  28. package/dist/runner/claude-code-runner.js +2 -303
  29. package/dist/runner/codex/composer-image-markers.js +2 -0
  30. package/dist/runner/codex/conversation-parser.js +2 -861
  31. package/dist/runner/codex/managed-run-controller.js +2 -460
  32. package/dist/runner/codex-runner.js +2 -628
  33. package/dist/runner/fake-test-runner.js +2 -47
  34. package/dist/runner/opencode/conversation-parser.js +2 -221
  35. package/dist/runner/opencode/managed-run-controller.js +2 -537
  36. package/dist/runner/opencode-runner.js +2 -448
  37. package/dist/runner/runner-registry.js +2 -90
  38. package/dist/runner-command-engine.js +2 -70
  39. package/dist/runner-profiles.js +2 -215
  40. package/dist/runner-usage.js +2 -190
  41. package/dist/runtime-command-detector.js +2 -73
  42. package/dist/runtime-state.js +2 -982
  43. package/dist/service/attachment-domain-state.js +2 -7
  44. package/dist/service/conversation-history-service.js +2 -457
  45. package/dist/service/conversation-segment-service.js +2 -162
  46. package/dist/service/external-session-resume-service.js +2 -118
  47. package/dist/service/fake-managed-run-service.js +2 -60
  48. package/dist/service/managed-runner-session-service.js +2 -35
  49. package/dist/service/mcp-installation-verifier.js +2 -87
  50. package/dist/service/mcp-node-operation-service.js +2 -90
  51. package/dist/service/mcp-package-installer.js +2 -136
  52. package/dist/service/native-session-projection-service.js +2 -280
  53. package/dist/service/native-session-watch-service.js +2 -383
  54. package/dist/service/node-connection-lifecycle-service.js +2 -84
  55. package/dist/service/node-control-channel.js +2 -85
  56. package/dist/service/node-control-message-service.js +2 -107
  57. package/dist/service/node-request-service.js +2 -52
  58. package/dist/service/node-run-event-bridge.js +2 -83
  59. package/dist/service/node-terminal-channel.js +2 -182
  60. package/dist/service/node-upgrade-coordinator.js +2 -137
  61. package/dist/service/node-workspace-coordinator.js +2 -70
  62. package/dist/service/recent-run-projection-service.js +2 -78
  63. package/dist/service/run-attachment-service.js +2 -194
  64. package/dist/service/run-domain-state.js +2 -4
  65. package/dist/service/run-event-service.js +2 -193
  66. package/dist/service/run-workbench-service.js +2 -104
  67. package/dist/service/runner-channel-message-service.js +2 -20
  68. package/dist/service/runner-interaction-service.js +2 -243
  69. package/dist/service/runner-service.js +2 -71
  70. package/dist/service/session-catalog-service.js +2 -224
  71. package/dist/service/session-command-service.js +2 -76
  72. package/dist/service/session-context-service.js +2 -101
  73. package/dist/service/session-domain-state.js +2 -9
  74. package/dist/service/session-identity-service.js +2 -86
  75. package/dist/service/session-lifecycle-service.js +2 -240
  76. package/dist/service/session-message-service.js +2 -173
  77. package/dist/service/session-presentation-service.js +2 -43
  78. package/dist/service/session-query-service.js +2 -82
  79. package/dist/service/skill-directory-service.js +2 -238
  80. package/dist/service/skill-install-service.js +2 -434
  81. package/dist/service/skill-node-operation-service.js +2 -206
  82. package/dist/service/terminal-relay-state.js +2 -3
  83. package/dist/service/terminal-service.js +2 -52
  84. package/dist/service/workbench-event-service.js +2 -19
  85. package/dist/service/workbench-manifest-service.js +2 -69
  86. package/dist/service/workspace-change-service.js +2 -86
  87. package/dist/service/workspace-content-search-service.js +2 -477
  88. package/dist/service/workspace-domain-state.js +2 -41
  89. package/dist/service/workspace-file-service.js +2 -122
  90. package/dist/service/workspace-git-exclude-service.js +2 -119
  91. package/dist/service/workspace-queue-workbench-service.js +2 -304
  92. package/dist/service/workspace-service.js +2 -69
  93. package/dist/service/workspace-session-service.js +2 -139
  94. package/dist/service/workspace-upload-service.js +2 -262
  95. package/dist/service/workspace-watch-service.js +2 -146
  96. package/dist/service/workspace-workbench-service.js +2 -405
  97. package/dist/service.js +2 -38
  98. package/dist/storage.js +2 -32
  99. package/dist/supervisor.js +2 -136
  100. package/dist/terminal.js +2 -416
  101. package/dist/util/node-operation-parsers.js +2 -382
  102. package/dist/util/personal-instructions.js +2 -31
  103. package/dist/util/runner-error.js +2 -52
  104. package/dist/util/runner-native-session-parsers.js +2 -490
  105. package/dist/util/safe-error.js +2 -5
  106. package/dist/util/secret-environment.js +2 -25
  107. package/dist/workspace.js +2 -1519
  108. package/package.json +3 -3
  109. package/dist/capabilities.d.ts +0 -12
  110. package/dist/claude-agent-sdk.d.ts +0 -92
  111. package/dist/claude-channel.d.ts +0 -28
  112. package/dist/codex-app-server.d.ts +0 -133
  113. package/dist/config.d.ts +0 -18
  114. package/dist/connector/node-connector-options.d.ts +0 -27
  115. package/dist/connector/node-operation-router.d.ts +0 -9
  116. package/dist/connector.d.ts +0 -94
  117. package/dist/control-outbound-scheduler.d.ts +0 -29
  118. package/dist/database.d.ts +0 -305
  119. package/dist/event-buffer.d.ts +0 -9
  120. package/dist/fake-runner.d.ts +0 -42
  121. package/dist/health.d.ts +0 -4
  122. package/dist/main.d.ts +0 -2
  123. package/dist/migrations/v001.d.ts +0 -3
  124. package/dist/migrations/v002.d.ts +0 -4
  125. package/dist/migrations/v003.d.ts +0 -4
  126. package/dist/migrations/v004.d.ts +0 -4
  127. package/dist/native-jsonl-reader.d.ts +0 -35
  128. package/dist/native-session-history.d.ts +0 -126
  129. package/dist/opencode-runtime.d.ts +0 -33
  130. package/dist/opencode-server.d.ts +0 -49
  131. package/dist/operational.d.ts +0 -39
  132. package/dist/process-tree.d.ts +0 -9
  133. package/dist/rotating-log.d.ts +0 -17
  134. package/dist/runner/abstract-runner.d.ts +0 -172
  135. package/dist/runner/claude/managed-run-controller.d.ts +0 -51
  136. package/dist/runner/claude-code-runner.d.ts +0 -72
  137. package/dist/runner/codex/conversation-parser.d.ts +0 -59
  138. package/dist/runner/codex/managed-run-controller.d.ts +0 -90
  139. package/dist/runner/codex-runner.d.ts +0 -103
  140. package/dist/runner/fake-test-runner.d.ts +0 -26
  141. package/dist/runner/opencode/conversation-parser.d.ts +0 -31
  142. package/dist/runner/opencode/managed-run-controller.d.ts +0 -82
  143. package/dist/runner/opencode-runner.d.ts +0 -71
  144. package/dist/runner/runner-registry.d.ts +0 -19
  145. package/dist/runner-command-engine.d.ts +0 -28
  146. package/dist/runner-profiles.d.ts +0 -15
  147. package/dist/runner-usage.d.ts +0 -33
  148. package/dist/runtime-command-detector.d.ts +0 -3
  149. package/dist/runtime-state.d.ts +0 -171
  150. package/dist/service/attachment-domain-state.d.ts +0 -7
  151. package/dist/service/conversation-history-service.d.ts +0 -43
  152. package/dist/service/conversation-segment-service.d.ts +0 -20
  153. package/dist/service/external-session-resume-service.d.ts +0 -34
  154. package/dist/service/fake-managed-run-service.d.ts +0 -28
  155. package/dist/service/managed-runner-session-service.d.ts +0 -12
  156. package/dist/service/mcp-installation-verifier.d.ts +0 -9
  157. package/dist/service/mcp-node-operation-service.d.ts +0 -11
  158. package/dist/service/mcp-package-installer.d.ts +0 -8
  159. package/dist/service/native-session-projection-service.d.ts +0 -52
  160. package/dist/service/native-session-watch-service.d.ts +0 -62
  161. package/dist/service/node-connection-lifecycle-service.d.ts +0 -36
  162. package/dist/service/node-control-channel.d.ts +0 -32
  163. package/dist/service/node-control-message-service.d.ts +0 -27
  164. package/dist/service/node-request-service.d.ts +0 -14
  165. package/dist/service/node-run-event-bridge.d.ts +0 -40
  166. package/dist/service/node-terminal-channel.d.ts +0 -29
  167. package/dist/service/node-upgrade-coordinator.d.ts +0 -29
  168. package/dist/service/node-workspace-coordinator.d.ts +0 -29
  169. package/dist/service/recent-run-projection-service.d.ts +0 -14
  170. package/dist/service/run-attachment-service.d.ts +0 -38
  171. package/dist/service/run-domain-state.d.ts +0 -4
  172. package/dist/service/run-event-service.d.ts +0 -33
  173. package/dist/service/run-workbench-service.d.ts +0 -25
  174. package/dist/service/runner-channel-message-service.d.ts +0 -13
  175. package/dist/service/runner-interaction-service.d.ts +0 -39
  176. package/dist/service/runner-service.d.ts +0 -46
  177. package/dist/service/session-catalog-service.d.ts +0 -45
  178. package/dist/service/session-command-service.d.ts +0 -24
  179. package/dist/service/session-context-service.d.ts +0 -35
  180. package/dist/service/session-domain-state.d.ts +0 -9
  181. package/dist/service/session-identity-service.d.ts +0 -24
  182. package/dist/service/session-lifecycle-service.d.ts +0 -31
  183. package/dist/service/session-message-service.d.ts +0 -33
  184. package/dist/service/session-presentation-service.d.ts +0 -34
  185. package/dist/service/session-query-service.d.ts +0 -35
  186. package/dist/service/skill-directory-service.d.ts +0 -20
  187. package/dist/service/skill-install-service.d.ts +0 -21
  188. package/dist/service/skill-node-operation-service.d.ts +0 -44
  189. package/dist/service/terminal-relay-state.d.ts +0 -6
  190. package/dist/service/terminal-service.d.ts +0 -12
  191. package/dist/service/workbench-event-service.d.ts +0 -9
  192. package/dist/service/workbench-manifest-service.d.ts +0 -90
  193. package/dist/service/workspace-change-service.d.ts +0 -9
  194. package/dist/service/workspace-content-search-service.d.ts +0 -14
  195. package/dist/service/workspace-domain-state.d.ts +0 -79
  196. package/dist/service/workspace-file-service.d.ts +0 -18
  197. package/dist/service/workspace-git-exclude-service.d.ts +0 -4
  198. package/dist/service/workspace-queue-workbench-service.d.ts +0 -86
  199. package/dist/service/workspace-service.d.ts +0 -15
  200. package/dist/service/workspace-session-service.d.ts +0 -23
  201. package/dist/service/workspace-upload-service.d.ts +0 -39
  202. package/dist/service/workspace-watch-service.d.ts +0 -23
  203. package/dist/service/workspace-workbench-service.d.ts +0 -58
  204. package/dist/service.d.ts +0 -4
  205. package/dist/storage.d.ts +0 -2
  206. package/dist/supervisor.d.ts +0 -1
  207. package/dist/terminal.d.ts +0 -133
  208. package/dist/util/node-operation-parsers.d.ts +0 -92
  209. package/dist/util/personal-instructions.d.ts +0 -2
  210. package/dist/util/runner-error.d.ts +0 -6
  211. package/dist/util/runner-native-session-parsers.d.ts +0 -74
  212. package/dist/util/safe-error.d.ts +0 -2
  213. package/dist/util/secret-environment.d.ts +0 -1
  214. package/dist/workspace.d.ts +0 -217
@@ -1,861 +1,2 @@
1
- const MAX_COMPOSER_ATTACHMENT_BYTES = 5 * 1024 * 1024;
2
- const MAX_COMPOSER_ATTACHMENTS_BYTES = 10 * 1024 * 1024;
3
- const MAX_ASSISTANT_MESSAGE_CHARACTERS = 64 * 1024;
4
- export * from '../../util/runner-native-session-parsers.js';
5
- export function codexOfficialConversationPage(session, result, input, managedTurnForNative) {
6
- if (!isPlainRecord(result) || !isPlainRecord(result.thread))
7
- return undefined;
8
- const thread = result.thread;
9
- if (thread.id !== session.externalSessionId || !Array.isArray(thread.turns))
10
- return undefined;
11
- const parsedTurns = thread.turns.flatMap((value, sequence) => {
12
- const nativeTurnId = typeof value === 'object' && value !== null && typeof value.id === 'string'
13
- ? value.id
14
- : undefined;
15
- const turn = codexOfficialTurn(session, value, sequence, nativeTurnId === undefined ? undefined : managedTurnForNative(nativeTurnId));
16
- return turn === undefined || nativeTurnId === undefined ? [] : [{ nativeTurnId, turn }];
17
- });
18
- const allTurns = parsedTurns.map(({ nativeTurnId, turn }, index) => ({
19
- ...turn,
20
- rewind: { before: parsedTurns[index - 1]?.nativeTurnId ?? null, after: nativeTurnId }
21
- }));
22
- if (allTurns.length === 0)
23
- return undefined;
24
- const limit = Math.min(Math.max(input.limit ?? 30, 1), 500);
25
- const end = nativePageEnd(input.cursor, session.id, allTurns.length);
26
- const start = Math.max(0, end - limit);
27
- return {
28
- turns: allTurns.slice(start, end),
29
- nextCursor: start > 0
30
- ? Buffer.from(JSON.stringify({ sessionId: session.id, end: start })).toString('base64url')
31
- : null
32
- };
33
- }
34
- export function codexOfficialTurn(session, value, sequence, managedTurn) {
35
- if (!isPlainRecord(value) || typeof value.id !== 'string' || !Array.isArray(value.items))
36
- return undefined;
37
- const startedAt = codexTimestamp(value.startedAt);
38
- const completedAt = codexTimestamp(value.completedAt) ?? startedAt;
39
- const items = codexOfficialItems(session, value.id, value.items, sequence, startedAt, completedAt);
40
- if (items.length === 0)
41
- return undefined;
42
- if (managedTurn !== undefined) {
43
- const localUser = managedTurn.items.find((item) => item.kind === 'user_message');
44
- const officialNativeItemIds = codexNativeItemIds(value.items);
45
- const officialAssistantCount = items.filter((item) => item.kind === 'assistant_message').length;
46
- const officialAssistantMessage = officialAssistantCount > 0;
47
- const managedAssistants = managedTurn.items.filter((item) => item.kind === 'assistant_message' && conversationItemNativeId(item.id) === undefined);
48
- const managedAssistantCandidates = officialAssistantCount === 0 ? [] : managedAssistants.slice(-officialAssistantCount);
49
- const assistantLength = (values) => values.reduce((length, item) => {
50
- if (item.kind !== 'assistant_message' || !isPlainRecord(item.payload))
51
- return length;
52
- return length + (typeof item.payload.text === 'string' ? item.payload.text.length : 0);
53
- }, 0);
54
- const preferLocalAssistant = officialAssistantMessage &&
55
- (assistantLength(managedAssistantCandidates) > assistantLength(items) ||
56
- ((managedTurn.completedAt ?? 0) > (completedAt ?? 0) &&
57
- assistantLength(managedAssistantCandidates) > 0));
58
- const replacedManagedAssistantIds = new Set(preferLocalAssistant
59
- ? []
60
- : officialAssistantCount === 0
61
- ? []
62
- : managedAssistantCandidates.map((item) => item.id));
63
- const localLiveItems = managedTurn.items.filter((item) => {
64
- if (item.kind === 'user_message')
65
- return false;
66
- // `item/agentMessage/delta` uses a synthetic runtime ID. Once
67
- // `thread/read` returns the final Agent message, it is the same reply
68
- // without a shared native item ID and must replace that transient item.
69
- if (item.kind === 'assistant_message' && replacedManagedAssistantIds.has(item.id))
70
- return false;
71
- const nativeItemId = conversationItemNativeId(item.id);
72
- return nativeItemId === undefined || !officialNativeItemIds.has(nativeItemId);
73
- });
74
- const officialItems = [
75
- ...retainManagedImageAttachments(managedTurn, value.id, items
76
- .filter((item) => item.kind !== 'assistant_message' || !preferLocalAssistant)
77
- .map((item) => item.kind === 'user_message' && localUser !== undefined
78
- ? { ...localUser, turnId: managedTurn.id }
79
- : { ...item, turnId: managedTurn.id, runId: managedTurn.runId }))
80
- ];
81
- if (localUser !== undefined && !officialItems.some((item) => item.kind === 'user_message'))
82
- officialItems.unshift({ ...localUser, turnId: managedTurn.id });
83
- const retainedLocalIds = new Set(localLiveItems.map((item) => item.id));
84
- const consumedOfficialIds = new Set();
85
- const officialUser = officialItems.find((item) => item.kind === 'user_message');
86
- const officialAssistants = officialItems.filter((item) => item.kind === 'assistant_message');
87
- const officialContextCompactions = officialItems.filter((item) => item.kind === 'context_compaction');
88
- const officialItemMarker = `:official:${value.id}:`;
89
- const officialByNativeId = new Map(officialItems.flatMap((item) => {
90
- const markerIndex = item.id.lastIndexOf(officialItemMarker);
91
- return markerIndex < 0
92
- ? []
93
- : [[item.id.slice(markerIndex + officialItemMarker.length), item]];
94
- }));
95
- const reconciledItems = [];
96
- for (const managedItem of managedTurn.items) {
97
- let replacement;
98
- if (managedItem.kind === 'user_message')
99
- replacement = officialUser;
100
- else if (managedItem.kind === 'context_compaction')
101
- replacement = officialContextCompactions.find((item) => !consumedOfficialIds.has(item.id));
102
- else {
103
- const nativeId = conversationItemNativeId(managedItem.id);
104
- if (nativeId !== undefined)
105
- replacement = officialByNativeId.get(nativeId);
106
- if (replacement === undefined &&
107
- managedItem.kind === 'assistant_message' &&
108
- replacedManagedAssistantIds.has(managedItem.id))
109
- replacement = officialAssistants.find((item) => !consumedOfficialIds.has(item.id));
110
- }
111
- if (replacement !== undefined) {
112
- if (managedItem.kind === 'assistant_message' &&
113
- replacement.kind === 'assistant_message' &&
114
- (assistantLength([managedItem]) > assistantLength([replacement]) ||
115
- ((managedTurn.completedAt ?? 0) > (completedAt ?? 0) &&
116
- assistantLength([managedItem]) > 0))) {
117
- reconciledItems.push(managedItem);
118
- consumedOfficialIds.add(replacement.id);
119
- continue;
120
- }
121
- if (!consumedOfficialIds.has(replacement.id)) {
122
- reconciledItems.push(replacement);
123
- consumedOfficialIds.add(replacement.id);
124
- }
125
- }
126
- else if (retainedLocalIds.has(managedItem.id))
127
- reconciledItems.push(managedItem);
128
- }
129
- for (const item of officialItems)
130
- if (!consumedOfficialIds.has(item.id))
131
- reconciledItems.push(item);
132
- return {
133
- ...managedTurn,
134
- status: 'SUCCEEDED',
135
- // Reconcile against the managed runtime order. Official items replace
136
- // matching live projections in place; newly visible terminal items such
137
- // as a plan are appended after the commentary and tools that preceded it.
138
- items: reconciledItems,
139
- startedAt,
140
- completedAt
141
- };
142
- }
143
- return {
144
- id: `${session.id}:official:${value.id}`,
145
- sessionId: session.id,
146
- runId: null,
147
- userItemId: items.find((item) => item.kind === 'user_message')?.id ?? null,
148
- status: 'SUCCEEDED',
149
- model: null,
150
- effort: null,
151
- access: null,
152
- items,
153
- startedAt,
154
- completedAt
155
- };
156
- }
157
- /**
158
- * Codex's authoritative thread records omit MAR's Node-local generated-image
159
- * references. Preserve those references like user-image metadata: cache expiry
160
- * only makes the bytes unavailable, while the conversation still renders its
161
- * image placeholder.
162
- */
163
- export function retainManagedImageAttachments(managedTurn, nativeTurnId, officialItems) {
164
- const localAttachments = new Map();
165
- for (const item of managedTurn.items) {
166
- const nativeItemId = conversationItemNativeId(item.id);
167
- if (nativeItemId === undefined || !isPlainRecord(item.payload))
168
- continue;
169
- if (!Array.isArray(item.payload.attachments) || item.payload.attachments.length === 0)
170
- continue;
171
- localAttachments.set(nativeItemId, item.payload.attachments);
172
- }
173
- if (localAttachments.size === 0)
174
- return officialItems;
175
- const marker = `:official:${nativeTurnId}:`;
176
- return officialItems.map((item) => {
177
- if (!isPlainRecord(item.payload) || Array.isArray(item.payload.attachments))
178
- return item;
179
- const markerIndex = item.id.lastIndexOf(marker);
180
- if (markerIndex < 0)
181
- return item;
182
- const attachments = localAttachments.get(item.id.slice(markerIndex + marker.length));
183
- return attachments === undefined
184
- ? item
185
- : { ...item, payload: { ...item.payload, attachments } };
186
- });
187
- }
188
- export function codexNativeItemIds(values) {
189
- return new Set(values.flatMap((value) => {
190
- if (!isPlainRecord(value))
191
- return [];
192
- const id = typeof value.call_id === 'string'
193
- ? value.call_id
194
- : typeof value.id === 'string'
195
- ? value.id
196
- : undefined;
197
- return id === undefined ? [] : [id];
198
- }));
199
- }
200
- export function conversationItemNativeId(itemId) {
201
- if (itemId.startsWith('codex:'))
202
- return itemId.slice('codex:'.length);
203
- const marker = ':codex:';
204
- const markerIndex = itemId.lastIndexOf(marker);
205
- return markerIndex < 0 ? undefined : itemId.slice(markerIndex + marker.length);
206
- }
207
- /** Keep a custom tool invocation and its output in one Workbench card. */
208
- export function codexOfficialItems(session, nativeTurnId, values, turnSequence, startedAt, completedAt) {
209
- const items = [];
210
- const pairedToolIndexes = new Map();
211
- // App Server preserves execution order within a Turn. Keep that order while
212
- // merging a paired tool invocation with its output into one Workbench card.
213
- for (const [itemSequence, value] of values.entries()) {
214
- const item = codexOfficialItem(session, nativeTurnId, value, turnSequence, itemSequence, startedAt, completedAt);
215
- if (item === undefined)
216
- continue;
217
- // Codex persists one compaction as both `compacted` state and a
218
- // `context_compacted` event. App Server normalizes both records to
219
- // consecutive `contextCompaction` items without preserving their source.
220
- if (item.kind === 'context_compaction' && items.at(-1)?.kind === 'context_compaction')
221
- continue;
222
- const key = codexPairedToolCallId(value);
223
- if (key === undefined) {
224
- items.push(item);
225
- continue;
226
- }
227
- const existingIndex = pairedToolIndexes.get(key);
228
- if (existingIndex === undefined) {
229
- pairedToolIndexes.set(key, items.length);
230
- items.push(item);
231
- continue;
232
- }
233
- const previous = items[existingIndex];
234
- const invocation = isPlainRecord(value) && (value.type === 'custom_tool_call' || value.type === 'function_call')
235
- ? item
236
- : previous;
237
- const result = invocation === item ? previous : item;
238
- items[existingIndex] = mergeCodexCustomToolItems(invocation, result);
239
- }
240
- return items;
241
- }
242
- export function codexPairedToolCallId(value) {
243
- if (!isPlainRecord(value))
244
- return undefined;
245
- if (value.type !== 'custom_tool_call' &&
246
- value.type !== 'custom_tool_call_output' &&
247
- value.type !== 'function_call' &&
248
- value.type !== 'function_call_output')
249
- return undefined;
250
- return typeof value.call_id === 'string'
251
- ? value.call_id
252
- : typeof value.id === 'string'
253
- ? value.id
254
- : undefined;
255
- }
256
- export function mergeCodexCustomToolItems(invocation, result) {
257
- if (invocation.kind !== 'tool_call' || result.kind !== 'tool_call')
258
- return invocation;
259
- const invocationPayload = isPlainRecord(invocation.payload) ? invocation.payload : {};
260
- const resultPayload = isPlainRecord(result.payload) ? result.payload : {};
261
- return {
262
- ...invocation,
263
- status: result.status,
264
- completedAt: result.completedAt,
265
- payload: {
266
- ...invocationPayload,
267
- outputSummary: resultPayload.outputSummary ?? invocationPayload.outputSummary,
268
- errorCode: resultPayload.errorCode ?? invocationPayload.errorCode,
269
- truncated: invocationPayload.truncated === true || resultPayload.truncated === true,
270
- ...(resultPayload.attachments === undefined ? {} : { attachments: resultPayload.attachments })
271
- }
272
- };
273
- }
274
- export function coalesceImageGenerationItems(items) {
275
- const merged = [];
276
- for (const item of items) {
277
- const payload = isPlainRecord(item.payload) ? item.payload : undefined;
278
- const previous = merged.at(-1);
279
- const previousPayload = previous !== undefined && isPlainRecord(previous.payload) ? previous.payload : undefined;
280
- if (item.kind !== 'tool_call' ||
281
- payload?.toolName !== 'imagegen' ||
282
- previous?.kind !== 'tool_call' ||
283
- previousPayload?.toolName !== 'imagegen') {
284
- merged.push(item);
285
- continue;
286
- }
287
- const attachments = [
288
- ...(Array.isArray(previousPayload.attachments) ? previousPayload.attachments : []),
289
- ...(Array.isArray(payload.attachments) ? payload.attachments : [])
290
- ];
291
- merged[merged.length - 1] = {
292
- ...previous,
293
- completedAt: item.completedAt ?? previous.completedAt,
294
- payload: { ...previousPayload, attachments }
295
- };
296
- }
297
- return merged;
298
- }
299
- export function codexPlanText(value) {
300
- if (typeof value.type !== 'string' || typeof value.text !== 'string')
301
- return undefined;
302
- const text = value.text.trim();
303
- if (text.length === 0)
304
- return undefined;
305
- if (value.type.toLocaleLowerCase() === 'plan')
306
- return text;
307
- if (value.type !== 'agentMessage' || !text.startsWith('<proposed_plan>'))
308
- return undefined;
309
- const plan = text
310
- .slice('<proposed_plan>'.length)
311
- .replace(/<\/proposed_plan>\s*$/, '')
312
- .trim();
313
- return plan.length > 0 ? plan : undefined;
314
- }
315
- /**
316
- * A final Claude tagged Plan Mode plan is fully wrapped in `<proposed_plan>` tags;
317
- * text with missing or unclosed tags remains a regular assistant message.
318
- */
319
- export function codexOfficialItem(session, nativeTurnId, value, turnSequence, itemSequence, startedAt, completedAt) {
320
- if (!isPlainRecord(value) || typeof value.type !== 'string')
321
- return undefined;
322
- const id = (value.type === 'custom_tool_call' ||
323
- value.type === 'custom_tool_call_output' ||
324
- value.type === 'function_call' ||
325
- value.type === 'function_call_output') &&
326
- typeof value.call_id === 'string'
327
- ? value.call_id
328
- : typeof value.id === 'string'
329
- ? value.id
330
- : typeof value.call_id === 'string'
331
- ? value.call_id
332
- : `${nativeTurnId}:${itemSequence}`;
333
- const base = {
334
- id: `${session.id}:official:${nativeTurnId}:${id}`,
335
- sessionId: session.id,
336
- turnId: `${session.id}:official:${nativeTurnId}`,
337
- runId: null,
338
- parentItemId: null,
339
- sourceSequence: turnSequence * 10_000 + itemSequence,
340
- revision: 0,
341
- status: 'COMPLETED',
342
- startedAt,
343
- completedAt
344
- };
345
- if (value.type === 'userMessage') {
346
- const text = codexContentText(value.content);
347
- return text.length === 0
348
- ? undefined
349
- : {
350
- ...base,
351
- kind: 'user_message',
352
- payload: { clientMessageId: null, text, contexts: [], delivery: 'ACCEPTED' }
353
- };
354
- }
355
- const planText = codexPlanText(value);
356
- if (planText !== undefined)
357
- return { ...base, kind: 'plan', payload: { explanation: planText, steps: [] } };
358
- if (value.type === 'agentMessage' &&
359
- typeof value.text === 'string' &&
360
- value.text.trim().length > 0)
361
- return {
362
- ...base,
363
- kind: 'assistant_message',
364
- payload: { text: value.text, format: 'markdown', source: 'codex-app-server' }
365
- };
366
- if (value.type === 'reasoning') {
367
- const sections = Array.isArray(value.summary)
368
- ? value.summary.flatMap((text, index) => typeof text === 'string' && text.trim().length > 0
369
- ? [{ index, text: compactRunnerText(text, 10_000) }]
370
- : [])
371
- : [];
372
- return { ...base, kind: 'reasoning_summary', payload: { sections } };
373
- }
374
- if (value.type === 'commandExecution') {
375
- const output = typeof value.aggregatedOutput === 'string' ? value.aggregatedOutput : '';
376
- return {
377
- ...base,
378
- kind: 'command_execution',
379
- payload: {
380
- command: typeof value.command === 'string'
381
- ? compactRunnerText(value.command, 10_000)
382
- : '(No command provided)',
383
- cwd: typeof value.cwd === 'string' ? compactRunnerText(value.cwd, 4_096) : null,
384
- outputPreview: compactRunnerText(output, 10_000),
385
- outputRef: null,
386
- exitCode: typeof value.exitCode === 'number' && Number.isInteger(value.exitCode)
387
- ? value.exitCode
388
- : null,
389
- durationMs: typeof value.durationMs === 'number' &&
390
- Number.isInteger(value.durationMs) &&
391
- value.durationMs >= 0
392
- ? value.durationMs
393
- : null,
394
- truncated: output.length > 10_000
395
- }
396
- };
397
- }
398
- if (value.type === 'mcpToolCall')
399
- return {
400
- ...base,
401
- kind: 'tool_call',
402
- payload: {
403
- title: [
404
- typeof value.server === 'string' ? value.server : '',
405
- typeof value.tool === 'string' ? value.tool : ''
406
- ]
407
- .filter(Boolean)
408
- .join('.'),
409
- namespace: typeof value.server === 'string' ? value.server : '',
410
- toolName: typeof value.tool === 'string' ? value.tool : '',
411
- inputSummary: codexCompactJson(value.arguments),
412
- outputSummary: codexCompactJson(value.result),
413
- ...(value.error === undefined ? {} : { errorCode: codexCompactJson(value.error) })
414
- }
415
- };
416
- if (value.type === 'webSearch')
417
- return {
418
- ...base,
419
- kind: 'tool_call',
420
- payload: {
421
- title: 'Web Search',
422
- namespace: 'web',
423
- toolName: 'search',
424
- inputSummary: typeof value.query === 'string' ? value.query : ''
425
- }
426
- };
427
- if (value.type === 'imageGeneration')
428
- return {
429
- ...base,
430
- kind: 'tool_call',
431
- payload: {
432
- title: 'imagegen',
433
- namespace: 'codex',
434
- toolName: 'imagegen',
435
- inputSummary: typeof value.revisedPrompt === 'string' ? value.revisedPrompt : null,
436
- outputSummary: value.status === 'completed' ? 'Image generation completed' : 'Image generation failed',
437
- progressLabel: null,
438
- errorCode: value.status === 'failed' ? 'IMAGE_GENERATION_FAILED' : null,
439
- truncated: false
440
- }
441
- };
442
- if (value.type === 'dynamicToolCall' ||
443
- value.type === 'custom_tool_call' ||
444
- value.type === 'custom_tool_call_output' ||
445
- value.type === 'function_call' ||
446
- value.type === 'function_call_output' ||
447
- value.type === 'customToolCall' ||
448
- value.type === 'customToolCallOutput' ||
449
- value.type === 'functionCall' ||
450
- value.type === 'functionCallOutput') {
451
- const name = typeof value.tool === 'string'
452
- ? value.tool
453
- : typeof value.name === 'string'
454
- ? value.name
455
- : 'tool';
456
- return {
457
- ...base,
458
- kind: 'tool_call',
459
- payload: {
460
- title: name,
461
- namespace: typeof value.namespace === 'string' ? value.namespace : 'codex',
462
- toolName: name,
463
- inputSummary: codexCompactJson(value.arguments ?? value.input),
464
- outputSummary: codexToolOutputSummary(value.contentItems ?? value.output),
465
- progressLabel: null,
466
- errorCode: null,
467
- truncated: false
468
- }
469
- };
470
- }
471
- if (value.type === 'fileChange' && Array.isArray(value.changes))
472
- return { ...base, kind: 'file_change', payload: { changes: value.changes } };
473
- if (value.type === 'contextCompaction')
474
- return {
475
- ...base,
476
- kind: 'context_compaction',
477
- payload: {
478
- phase: 'COMPLETED',
479
- summary: 'Context compacted',
480
- summaryCode: 'CONTEXT_COMPACTED'
481
- }
482
- };
483
- return codexUnknownOfficialItem(base, value);
484
- }
485
- export function codexLiveConversationItem(value, completed, imageAttachments = []) {
486
- if (typeof value.type !== 'string')
487
- return undefined;
488
- const nativeId = typeof value.call_id === 'string'
489
- ? value.call_id
490
- : typeof value.id === 'string'
491
- ? value.id
492
- : undefined;
493
- if (nativeId === undefined)
494
- return undefined;
495
- const itemId = boundedConversationItemId('codex', nativeId);
496
- if (value.type === 'reasoning') {
497
- const sections = Array.isArray(value.summary)
498
- ? value.summary.flatMap((text, index) => typeof text === 'string' && text.trim().length > 0
499
- ? [{ index, text: compactRunnerText(text, 10_000) }]
500
- : [])
501
- : [];
502
- return {
503
- itemId,
504
- kind: 'reasoning_summary',
505
- status: completed ? 'COMPLETED' : 'IN_PROGRESS',
506
- payload: { sections }
507
- };
508
- }
509
- const planText = codexPlanText(value);
510
- if (planText !== undefined)
511
- return {
512
- itemId,
513
- kind: 'plan',
514
- status: completed ? 'COMPLETED' : 'IN_PROGRESS',
515
- payload: { explanation: compactRunnerText(planText, 20_000), steps: [] }
516
- };
517
- if (value.type === 'agentMessage') {
518
- if (!completed || typeof value.text !== 'string' || value.text.length === 0)
519
- return undefined;
520
- return {
521
- itemId,
522
- kind: 'assistant_message',
523
- status: 'COMPLETED',
524
- payload: {
525
- text: compactRunnerText(value.text, MAX_ASSISTANT_MESSAGE_CHARACTERS),
526
- format: 'markdown',
527
- model: null
528
- }
529
- };
530
- }
531
- if (value.type === 'commandExecution') {
532
- const output = typeof value.aggregatedOutput === 'string' ? value.aggregatedOutput : '';
533
- return {
534
- itemId,
535
- kind: 'command_execution',
536
- status: codexItemStatus(value.status, completed),
537
- payload: {
538
- command: typeof value.command === 'string'
539
- ? compactRunnerText(value.command, 10_000)
540
- : '(No command provided)',
541
- cwd: typeof value.cwd === 'string' ? compactRunnerText(value.cwd, 4_096) : null,
542
- outputPreview: compactRunnerText(output, 10_000),
543
- outputRef: null,
544
- exitCode: typeof value.exitCode === 'number' && Number.isInteger(value.exitCode)
545
- ? value.exitCode
546
- : null,
547
- durationMs: typeof value.durationMs === 'number' &&
548
- Number.isInteger(value.durationMs) &&
549
- value.durationMs >= 0
550
- ? value.durationMs
551
- : null,
552
- truncated: output.length > 10_000
553
- }
554
- };
555
- }
556
- if (value.type === 'mcpToolCall') {
557
- const input = compactRunnerValue(value.arguments, 10_000);
558
- const output = compactRunnerValue(value.result, 10_000);
559
- const error = compactRunnerValue(value.error, 80);
560
- const server = typeof value.server === 'string' ? value.server : 'mcp';
561
- const tool = typeof value.tool === 'string' ? value.tool : 'tool';
562
- return {
563
- itemId,
564
- kind: 'tool_call',
565
- status: codexItemStatus(value.status, completed),
566
- payload: {
567
- namespace: compactRunnerText(server, 128),
568
- toolName: compactRunnerText(tool, 128),
569
- title: compactRunnerText(`${server}.${tool}`, 500),
570
- inputSummary: input.text || null,
571
- outputSummary: output.text || null,
572
- progressLabel: null,
573
- errorCode: error.text || null,
574
- truncated: input.truncated || output.truncated || error.truncated
575
- }
576
- };
577
- }
578
- if (value.type === 'webSearch')
579
- return {
580
- itemId,
581
- kind: 'tool_call',
582
- status: completed ? 'COMPLETED' : 'IN_PROGRESS',
583
- payload: {
584
- namespace: 'web',
585
- toolName: 'search',
586
- title: 'Web Search',
587
- inputSummary: typeof value.query === 'string' ? compactRunnerText(value.query, 10_000) : null,
588
- outputSummary: null,
589
- progressLabel: completed ? null : 'Searching',
590
- progressLabelCode: completed ? null : 'SEARCHING',
591
- errorCode: null,
592
- truncated: false
593
- }
594
- };
595
- if (value.type === 'fileChange' && Array.isArray(value.changes))
596
- return {
597
- itemId,
598
- kind: 'file_change',
599
- status: completed ? 'COMPLETED' : 'IN_PROGRESS',
600
- payload: { changes: value.changes },
601
- merge: true
602
- };
603
- if (value.type === 'imageGeneration')
604
- return {
605
- itemId,
606
- kind: 'tool_call',
607
- status: codexItemStatus(value.status, completed),
608
- payload: {
609
- namespace: 'codex',
610
- toolName: 'imagegen',
611
- title: 'imagegen',
612
- inputSummary: typeof value.revisedPrompt === 'string'
613
- ? compactRunnerText(value.revisedPrompt, 10_000)
614
- : null,
615
- outputSummary: completed ? 'Image generation completed' : null,
616
- outputSummaryCode: completed ? 'IMAGE_GENERATION_COMPLETED' : null,
617
- progressLabel: completed ? null : 'Generating image',
618
- progressLabelCode: completed ? null : 'GENERATING_IMAGE',
619
- errorCode: value.status === 'failed' ? 'IMAGE_GENERATION_FAILED' : null,
620
- truncated: false,
621
- ...(imageAttachments.length === 0 ? {} : { attachments: imageAttachments })
622
- },
623
- merge: true
624
- };
625
- if (value.type === 'contextCompaction')
626
- return {
627
- itemId,
628
- kind: 'context_compaction',
629
- status: completed ? 'COMPLETED' : 'IN_PROGRESS',
630
- payload: { phase: completed ? 'COMPLETED' : 'STARTED', summary: null }
631
- };
632
- if (value.type === 'dynamicToolCall' ||
633
- value.type === 'custom_tool_call' ||
634
- value.type === 'custom_tool_call_output' ||
635
- value.type === 'function_call' ||
636
- value.type === 'function_call_output' ||
637
- value.type === 'customToolCall' ||
638
- value.type === 'customToolCallOutput' ||
639
- value.type === 'functionCall' ||
640
- value.type === 'functionCallOutput') {
641
- const name = typeof value.tool === 'string'
642
- ? value.tool
643
- : typeof value.name === 'string'
644
- ? value.name
645
- : 'tool';
646
- const input = compactRunnerValue(value.arguments ?? value.input, 10_000);
647
- const output = compactRunnerValue(codexToolOutput(value.contentItems ?? value.output), 10_000);
648
- if (value.type === 'custom_tool_call_output' ||
649
- value.type === 'function_call_output' ||
650
- value.type === 'customToolCallOutput' ||
651
- value.type === 'functionCallOutput')
652
- return {
653
- itemId,
654
- kind: 'tool_call',
655
- status: codexItemStatus(value.status, completed),
656
- payload: {
657
- outputSummary: output.text || null,
658
- ...(imageAttachments.length === 0 ? {} : { attachments: imageAttachments })
659
- },
660
- merge: true
661
- };
662
- return {
663
- itemId,
664
- kind: 'tool_call',
665
- status: codexItemStatus(value.status, completed),
666
- payload: {
667
- namespace: typeof value.namespace === 'string' ? compactRunnerText(value.namespace, 128) : 'codex',
668
- toolName: compactRunnerText(name, 128),
669
- title: compactRunnerText(name, 500),
670
- inputSummary: input.text || null,
671
- outputSummary: output.text || null,
672
- progressLabel: null,
673
- errorCode: null,
674
- truncated: input.truncated || output.truncated,
675
- ...(imageAttachments.length === 0 ? {} : { attachments: imageAttachments })
676
- }
677
- };
678
- }
679
- return codexUnknownLiveItem(itemId, value.type, completed);
680
- }
681
- function codexUnknownOfficialItem(base, value) {
682
- if (value.type === 'userMessage' || value.type === 'agentMessage')
683
- return undefined;
684
- const type = typeof value.type === 'string' ? value.type : 'unknown';
685
- return {
686
- ...base,
687
- kind: 'unknown',
688
- payload: { sourceEventType: `codex:${type}`, label: `Codex ${compactRunnerText(type, 128)}` }
689
- };
690
- }
691
- function codexUnknownLiveItem(itemId, type, completed) {
692
- if (type === 'userMessage' || type === 'agentMessage')
693
- return undefined;
694
- return {
695
- itemId,
696
- kind: 'unknown',
697
- status: completed ? 'COMPLETED' : 'IN_PROGRESS',
698
- payload: { sourceEventType: `codex:${type}`, label: `Codex ${compactRunnerText(type, 128)}` }
699
- };
700
- }
701
- export function codexImageAttachments(value) {
702
- const found = [];
703
- let totalBytes = 0;
704
- const visit = (current, depth) => {
705
- if (found.length >= 5 || depth > 4 || current === null || current === undefined)
706
- return;
707
- if (Array.isArray(current)) {
708
- for (const entry of current)
709
- visit(entry, depth + 1);
710
- return;
711
- }
712
- if (!isPlainRecord(current))
713
- return;
714
- const type = typeof current.type === 'string' ? current.type : '';
715
- if (type === 'input_text' && typeof current.text === 'string') {
716
- const embeddedImage = /["']image_url["']\s*:\s*["'](data:image\/[^"']+)["']/.exec(current.text)?.[1];
717
- if (embeddedImage !== undefined) {
718
- visit({ type: 'input_image', image_url: embeddedImage }, depth + 1);
719
- }
720
- }
721
- const rawData = typeof current.data === 'string' ? current.data : undefined;
722
- const rawUrl = isPlainRecord(current.image_url)
723
- ? typeof current.image_url.url === 'string'
724
- ? current.image_url.url
725
- : undefined
726
- : typeof current.image_url === 'string'
727
- ? current.image_url
728
- : undefined;
729
- const data = rawData ?? (rawUrl?.startsWith('data:') ? rawUrl : undefined);
730
- if ((type === 'image' || type === 'input_image' || type === 'output_image') &&
731
- data !== undefined) {
732
- const match = /^data:([^;,]+);base64,(.*)$/.exec(data);
733
- const mime = typeof current.mimeType === 'string'
734
- ? current.mimeType
735
- : typeof current.mime === 'string'
736
- ? current.mime
737
- : (match?.[1] ?? 'image/png');
738
- const dataBase64 = match?.[2] ?? data;
739
- if (mime.startsWith('image/') &&
740
- isCanonicalBase64(dataBase64) &&
741
- dataBase64.length > 0 &&
742
- Buffer.byteLength(dataBase64, 'base64') <= MAX_COMPOSER_ATTACHMENT_BYTES &&
743
- totalBytes + Buffer.byteLength(dataBase64, 'base64') <= MAX_COMPOSER_ATTACHMENTS_BYTES) {
744
- totalBytes += Buffer.byteLength(dataBase64, 'base64');
745
- found.push({
746
- name: typeof current.name === 'string'
747
- ? current.name
748
- : `generated-image-${found.length + 1}.png`,
749
- mime,
750
- dataBase64
751
- });
752
- }
753
- }
754
- for (const [key, child] of Object.entries(current)) {
755
- if (key === 'data' || key === 'image_url')
756
- continue;
757
- visit(child, depth + 1);
758
- }
759
- };
760
- visit(value, 0);
761
- return found;
762
- }
763
- export function codexUserInputQuestions(value) {
764
- if (!Array.isArray(value) || value.length === 0 || value.length > 3)
765
- return [];
766
- const questions = value.map((raw) => {
767
- if (!isPlainRecord(raw) || typeof raw.id !== 'string' || typeof raw.question !== 'string')
768
- return undefined;
769
- const options = Array.isArray(raw.options)
770
- ? raw.options.flatMap((option) => isPlainRecord(option) && typeof option.label === 'string'
771
- ? [
772
- {
773
- value: compactRunnerText(option.label, 500),
774
- label: compactRunnerText(option.label, 500),
775
- description: typeof option.description === 'string'
776
- ? compactRunnerText(option.description, 1_000)
777
- : null
778
- }
779
- ]
780
- : [])
781
- : [];
782
- return {
783
- id: compactRunnerText(raw.id, 128),
784
- prompt: compactRunnerText(raw.question, 5_000),
785
- options,
786
- allowOther: raw.isOther === true
787
- };
788
- });
789
- return questions.some((question) => question === undefined)
790
- ? []
791
- : questions;
792
- }
793
- export function codexItemStatus(value, completed) {
794
- if (value === 'failed')
795
- return 'FAILED';
796
- if (value === 'declined')
797
- return 'DECLINED';
798
- return completed || value === 'completed' ? 'COMPLETED' : 'IN_PROGRESS';
799
- }
800
- export function codexContentText(value) {
801
- if (!Array.isArray(value))
802
- return '';
803
- return value
804
- .flatMap((part) => {
805
- if (typeof part === 'string')
806
- return [part];
807
- if (!isPlainRecord(part))
808
- return [];
809
- return typeof part.text === 'string' ? [part.text] : [];
810
- })
811
- .join('\n')
812
- .trim();
813
- }
814
- export function codexCompactJson(value) {
815
- if (value === undefined || value === null)
816
- return '';
817
- if (typeof value === 'string')
818
- return compactRunnerText(value, 10_000);
819
- try {
820
- return compactRunnerText(JSON.stringify(value), 10_000);
821
- }
822
- catch {
823
- return '';
824
- }
825
- }
826
- export function codexToolOutputSummary(value) {
827
- return codexCompactJson(codexToolOutput(value));
828
- }
829
- /** App Server custom output is an array of text blocks, not JSON to show verbatim. */
830
- export function codexToolOutput(value) {
831
- if (!Array.isArray(value))
832
- return value;
833
- const text = value.flatMap((block) => {
834
- if (typeof block === 'string')
835
- return [block];
836
- if (!isPlainRecord(block))
837
- return [];
838
- if (typeof block.text === 'string') {
839
- const visible = codexVisibleToolText(block.text);
840
- return visible.length > 0 ? [visible] : [];
841
- }
842
- if (typeof block.content === 'string')
843
- return [block.content];
844
- return [];
845
- });
846
- return text.length > 0
847
- ? text.join('')
848
- : value.some(isCodexImageBlock)
849
- ? 'Image generated'
850
- : value;
851
- }
852
- export function codexVisibleToolText(value) {
853
- return value.replace(/(["']image_url["']\s*:\s*["'])data:image\/[^"']+(["'])/g, '$1[Image content extracted]$2');
854
- }
855
- export function isCodexImageBlock(value) {
856
- if (!isPlainRecord(value))
857
- return false;
858
- return value.type === 'image' || value.type === 'input_image' || value.type === 'output_image';
859
- }
860
- import { codexTimestamp, compactRunnerText, compactRunnerValue, boundedConversationItemId, isCanonicalBase64, isPlainRecord, nativePageEnd } from '../../util/node-operation-parsers.js';
861
- export * from '../../util/node-operation-parsers.js';
1
+ /* mar-release-protected */
2
+ (function(_0x1c38d5,_0x29c9ff){const _0xf50964=_0x4693,_0x1d4ba5=_0x1c38d5();while(!![]){try{const _0xb43b5b=-parseInt(_0xf50964(0x8e))/(-0xf31*-0x1+-0x101d*-0x2+0x11*-0x2ca)+parseInt(_0xf50964(0xe8))/(-0x3ea+-0x2*0x24b+0x882)*(parseInt(_0xf50964(0x12d))/(-0x20eb+0x1e5b+0x293))+-parseInt(_0xf50964(0xcc))/(0x8c*-0x3b+0x23*-0x26+0x257a)*(parseInt(_0xf50964(0xe4))/(-0x258e+0x2097+-0x27e*-0x2))+-parseInt(_0xf50964(0x93))/(0xa1*-0x8+-0x224d*-0x1+-0x1d3f)*(parseInt(_0xf50964(0xce))/(0x3*-0x1a8+0x10ad*-0x1+0x15ac))+-parseInt(_0xf50964(0xaf))/(-0x1a*0x67+-0x13a1*0x1+-0x1*-0x1e1f)+-parseInt(_0xf50964(0xa7))/(0x1a51+-0x1fb1+0x569)+parseInt(_0xf50964(0x11d))/(-0x1bc5+0x1041+0xb8e);if(_0xb43b5b===_0x29c9ff)break;else _0x1d4ba5['push'](_0x1d4ba5['shift']());}catch(_0x4d61d3){_0x1d4ba5['push'](_0x1d4ba5['shift']());}}}(_0x4137,0x1*-0x10df75+-0x41b4c+-0x7341*-0x50));import{parseCodexComposerImageMarkers}from'./composer-image-markers.js';const MAX_COMPOSER_ATTACHMENT_BYTES=(-0x24*-0x8+-0xff7+0x27a*0x6)*(-0x26e4+-0xdba*0x1+0x389e)*(0x1d*0x3+-0x125c+0x1605),MAX_COMPOSER_ATTACHMENTS_BYTES=(0x1*-0xb6f+-0x603+0x175*0xc)*(0x1*-0x95+-0x1bb6*-0x1+-0x1721)*(0x1*0x6b6+-0x5*0x70a+-0x16*-0x17a),MAX_ASSISTANT_MESSAGE_CHARACTERS=(-0x8f8*0x1+0x1a1a+-0x10e2)*(0x18a6+-0x35a+-0x114c);export*from'../../util/runner-native-session-parsers.js';export function codexOfficialConversationPage(_0x1753e3,_0x4dec52,_0x1f4e64,_0x479b7f){const _0x59efba=_0x4693;if(!isPlainRecord(_0x4dec52)||!isPlainRecord(_0x4dec52[_0x59efba(0xb5)]))return undefined;const _0x4e7098=_0x4dec52[_0x59efba(0xb5)];if(_0x4e7098['id']!==_0x1753e3[_0x59efba(0xc9)]||!Array[_0x59efba(0x111)](_0x4e7098[_0x59efba(0x9f)]))return undefined;const _0x1ac4f3=_0x4e7098[_0x59efba(0x9f)][_0x59efba(0xa5)]((_0x2c5cbc,_0x39cbde)=>{const _0x2b6d2a=_0x59efba,_0x3a5b11=typeof _0x2c5cbc===_0x2b6d2a(0x10d)&&_0x2c5cbc!==null&&typeof _0x2c5cbc['id']===_0x2b6d2a(0xfa)?_0x2c5cbc['id']:undefined,_0x358008=codexOfficialTurn(_0x1753e3,_0x2c5cbc,_0x39cbde,_0x3a5b11===undefined?undefined:_0x479b7f(_0x3a5b11));return _0x358008===undefined||_0x3a5b11===undefined?[]:[{'nativeTurnId':_0x3a5b11,'turn':_0x358008}];}),_0x1db863=_0x1ac4f3[_0x59efba(0xf0)](({nativeTurnId:_0x40dd63,turn:_0x164710},_0x231b8b)=>({..._0x164710,'rewind':{'before':_0x1ac4f3[_0x231b8b-(0x19*0x47+-0x435*0x2+-0x5*-0x4c)]?.[_0x59efba(0x99)]??null,'after':_0x40dd63}}));if(_0x1db863[_0x59efba(0x113)]===0xa3d*0x1+0xa2a+0x3*-0x6cd)return undefined;const _0x49dad2=Math[_0x59efba(0xe5)](Math[_0x59efba(0x130)](_0x1f4e64[_0x59efba(0xcb)]??-0x3c*0x57+-0x1a42+0x2ec4,-0x1*-0x773+0x29*0x7+-0x891),-0x3f3+-0x2*0xf49+-0x1*-0x2479),_0x14b4c1=nativePageEnd(_0x1f4e64[_0x59efba(0x108)],_0x1753e3['id'],_0x1db863[_0x59efba(0x113)]),_0x229515=Math[_0x59efba(0x130)](-0x168d+0x3*-0xb39+0x3838,_0x14b4c1-_0x49dad2);return{'turns':_0x1db863[_0x59efba(0x102)](_0x229515,_0x14b4c1),'nextCursor':_0x229515>0x2660+-0x2*0x59a+-0x1b2c?Buffer[_0x59efba(0x12c)](JSON[_0x59efba(0x129)]({'sessionId':_0x1753e3['id'],'end':_0x229515}))[_0x59efba(0x106)](_0x59efba(0xc2)):null};}export function codexOfficialTurn(_0x37b229,_0x52a379,_0x4eabbe,_0x19ef9a){const _0x5ca304=_0x4693;if(!isPlainRecord(_0x52a379)||typeof _0x52a379['id']!==_0x5ca304(0xfa)||!Array[_0x5ca304(0x111)](_0x52a379[_0x5ca304(0xff)]))return undefined;const _0x5e30a1=codexTimestamp(_0x52a379[_0x5ca304(0xe7)]),_0x29fdb4=codexTimestamp(_0x52a379[_0x5ca304(0x8f)])??_0x5e30a1,_0x4ae580=codexOfficialItems(_0x37b229,_0x52a379['id'],_0x52a379[_0x5ca304(0xff)],_0x4eabbe,_0x5e30a1,_0x29fdb4);if(_0x4ae580[_0x5ca304(0x113)]===-0x1*-0x1e13+-0x138b+0x2a2*-0x4)return undefined;if(_0x19ef9a!==undefined){const _0xbbb121=_0x19ef9a[_0x5ca304(0xff)][_0x5ca304(0x8d)](_0x23892b=>_0x23892b[_0x5ca304(0xd5)]===_0x5ca304(0xd8)),_0x468a60=codexNativeItemIds(_0x52a379[_0x5ca304(0xff)]),_0x237e97=_0x4ae580[_0x5ca304(0xfb)](_0x14705c=>_0x14705c[_0x5ca304(0xd5)]===_0x5ca304(0x125))[_0x5ca304(0x113)],_0x269779=_0x237e97>-0x11*0x14e+0x4fd*-0x1+-0x1b2b*-0x1,_0x5cf248=_0x19ef9a[_0x5ca304(0xff)][_0x5ca304(0xfb)](_0x3c0f99=>_0x3c0f99[_0x5ca304(0xd5)]===_0x5ca304(0x125)&&conversationItemNativeId(_0x3c0f99['id'])===undefined),_0x29ebad=_0x237e97===-0x1d06+-0x2d2*-0x7+-0x1*-0x948?[]:_0x5cf248[_0x5ca304(0x102)](-_0x237e97),_0x49ba25=_0x684b44=>_0x684b44[_0x5ca304(0x11a)]((_0x27f3e7,_0x514811)=>{const _0x14079f=_0x5ca304;if(_0x514811[_0x14079f(0xd5)]!==_0x14079f(0x125)||!isPlainRecord(_0x514811[_0x14079f(0xc4)]))return _0x27f3e7;return _0x27f3e7+(typeof _0x514811[_0x14079f(0xc4)][_0x14079f(0x11c)]===_0x14079f(0xfa)?_0x514811[_0x14079f(0xc4)][_0x14079f(0x11c)][_0x14079f(0x113)]:-0x83*-0x1a+-0x1b52+0xe04);},0x1675+-0x3*0x92a+0x1*0x509),_0x538316=_0x269779&&(_0x49ba25(_0x29ebad)>_0x49ba25(_0x4ae580)||(_0x19ef9a[_0x5ca304(0x8f)]??0x5ce+-0x26c+-0x362)>(_0x29fdb4??-0xd1a+-0x21e5+0xe3*0x35)&&_0x49ba25(_0x29ebad)>-0x4cf+-0x9ab+0xe7a),_0x794793=new Set(_0x538316?[]:_0x237e97===-0xc10+0x14b*0x7+-0x3*-0x101?[]:_0x29ebad[_0x5ca304(0xf0)](_0x4d58df=>_0x4d58df['id'])),_0x213043=_0x19ef9a[_0x5ca304(0xff)][_0x5ca304(0xfb)](_0x314a32=>{const _0x24e7d4=_0x5ca304;if(_0x314a32[_0x24e7d4(0xd5)]===_0x24e7d4(0xd8))return![];if(_0x314a32[_0x24e7d4(0xd5)]===_0x24e7d4(0x125)&&_0x794793[_0x24e7d4(0x104)](_0x314a32['id']))return![];const _0x5f3742=conversationItemNativeId(_0x314a32['id']);return _0x5f3742===undefined||!_0x468a60[_0x24e7d4(0x104)](_0x5f3742);}),_0x1eabfd=[...retainManagedImageAttachments(_0x19ef9a,_0x52a379['id'],_0x4ae580[_0x5ca304(0xfb)](_0xa742a9=>_0xa742a9[_0x5ca304(0xd5)]!==_0x5ca304(0x125)||!_0x538316)[_0x5ca304(0xf0)](_0x1215c=>_0x1215c[_0x5ca304(0xd5)]===_0x5ca304(0xd8)&&_0xbbb121!==undefined?{..._0xbbb121,'turnId':_0x19ef9a['id']}:{..._0x1215c,'turnId':_0x19ef9a['id'],'runId':_0x19ef9a[_0x5ca304(0x9a)]}))];if(_0xbbb121!==undefined&&!_0x1eabfd[_0x5ca304(0x91)](_0x4d3ee=>_0x4d3ee[_0x5ca304(0xd5)]===_0x5ca304(0xd8)))_0x1eabfd[_0x5ca304(0xa6)]({..._0xbbb121,'turnId':_0x19ef9a['id']});const _0x34ede4=new Set(_0x213043[_0x5ca304(0xf0)](_0x59a33f=>_0x59a33f['id'])),_0x116662=new Set(),_0x3e6d83=_0x1eabfd[_0x5ca304(0x8d)](_0xd5f0cf=>_0xd5f0cf[_0x5ca304(0xd5)]===_0x5ca304(0xd8)),_0x393301=_0x1eabfd[_0x5ca304(0xfb)](_0x5d668e=>_0x5d668e[_0x5ca304(0xd5)]===_0x5ca304(0x125)),_0xb9d8a5=_0x1eabfd[_0x5ca304(0xfb)](_0x37a0f2=>_0x37a0f2[_0x5ca304(0xd5)]===_0x5ca304(0x127)),_0x32742c=_0x5ca304(0xb9)+_0x52a379['id']+':',_0x283136=new Map(_0x1eabfd[_0x5ca304(0xa5)](_0x273b35=>{const _0x1d9b4c=_0x5ca304,_0x8c626e=_0x273b35['id'][_0x1d9b4c(0x8b)](_0x32742c);return _0x8c626e<0x24d2*0x1+0xa3*-0x1e+-0x1f8*0x9?[]:[[_0x273b35['id'][_0x1d9b4c(0x102)](_0x8c626e+_0x32742c[_0x1d9b4c(0x113)]),_0x273b35]];})),_0x4ba365=[];for(const _0x15d581 of _0x19ef9a[_0x5ca304(0xff)]){let _0x13d697;if(_0x15d581[_0x5ca304(0xd5)]===_0x5ca304(0xd8))_0x13d697=_0x3e6d83;else{if(_0x15d581[_0x5ca304(0xd5)]===_0x5ca304(0x127))_0x13d697=_0xb9d8a5[_0x5ca304(0x8d)](_0x5106bd=>!_0x116662[_0x5ca304(0x104)](_0x5106bd['id']));else{const _0x4c4647=conversationItemNativeId(_0x15d581['id']);if(_0x4c4647!==undefined)_0x13d697=_0x283136[_0x5ca304(0x120)](_0x4c4647);if(_0x13d697===undefined&&_0x15d581[_0x5ca304(0xd5)]===_0x5ca304(0x125)&&_0x794793[_0x5ca304(0x104)](_0x15d581['id']))_0x13d697=_0x393301[_0x5ca304(0x8d)](_0x278fa3=>!_0x116662[_0x5ca304(0x104)](_0x278fa3['id']));}}if(_0x13d697!==undefined){if(_0x15d581[_0x5ca304(0xd5)]===_0x5ca304(0x125)&&_0x13d697[_0x5ca304(0xd5)]===_0x5ca304(0x125)&&(_0x49ba25([_0x15d581])>_0x49ba25([_0x13d697])||(_0x19ef9a[_0x5ca304(0x8f)]??0x1db8+0x75d+-0x2515)>(_0x29fdb4??0x16c3+-0x552*0x5+-0x1*-0x3d7)&&_0x49ba25([_0x15d581])>0xe67*0x1+0x1115*0x1+-0x1f7c)){_0x4ba365[_0x5ca304(0x112)](_0x15d581),_0x116662[_0x5ca304(0xab)](_0x13d697['id']);continue;}!_0x116662[_0x5ca304(0x104)](_0x13d697['id'])&&(_0x4ba365[_0x5ca304(0x112)](_0x13d697),_0x116662[_0x5ca304(0xab)](_0x13d697['id']));}else{if(_0x34ede4[_0x5ca304(0x104)](_0x15d581['id']))_0x4ba365[_0x5ca304(0x112)](_0x15d581);}}for(const _0x5ead72 of _0x1eabfd)if(!_0x116662[_0x5ca304(0x104)](_0x5ead72['id']))_0x4ba365[_0x5ca304(0x112)](_0x5ead72);return{..._0x19ef9a,'status':_0x5ca304(0xe2),'items':_0x4ba365,'startedAt':_0x5e30a1,'completedAt':_0x29fdb4};}return{'id':_0x37b229['id']+_0x5ca304(0xb9)+_0x52a379['id'],'sessionId':_0x37b229['id'],'runId':null,'userItemId':_0x4ae580[_0x5ca304(0x8d)](_0x9ea912=>_0x9ea912[_0x5ca304(0xd5)]===_0x5ca304(0xd8))?.['id']??null,'status':_0x5ca304(0xe2),'model':null,'effort':null,'access':null,'items':_0x4ae580,'startedAt':_0x5e30a1,'completedAt':_0x29fdb4};}export function retainManagedImageAttachments(_0xe7a47c,_0x124237,_0x56889d){const _0x2e8b90=_0x4693,_0x33abc0=new Map();for(const _0x3de2e2 of _0xe7a47c[_0x2e8b90(0xff)]){const _0x5b4cc5=conversationItemNativeId(_0x3de2e2['id']);if(_0x5b4cc5===undefined||!isPlainRecord(_0x3de2e2[_0x2e8b90(0xc4)]))continue;if(!Array[_0x2e8b90(0x111)](_0x3de2e2[_0x2e8b90(0xc4)][_0x2e8b90(0x122)])||_0x3de2e2[_0x2e8b90(0xc4)][_0x2e8b90(0x122)][_0x2e8b90(0x113)]===-0xf31+0x1*-0x1521+-0x2452*-0x1)continue;_0x33abc0[_0x2e8b90(0xf1)](_0x5b4cc5,_0x3de2e2[_0x2e8b90(0xc4)][_0x2e8b90(0x122)]);}if(_0x33abc0[_0x2e8b90(0xa0)]===-0x1449+0x1f5*0x1+-0xcc*-0x17)return _0x56889d;const _0x4963f7=_0x2e8b90(0xb9)+_0x124237+':';return _0x56889d[_0x2e8b90(0xf0)](_0xe37e9a=>{const _0x44d2fb=_0x2e8b90;if(!isPlainRecord(_0xe37e9a[_0x44d2fb(0xc4)])||Array[_0x44d2fb(0x111)](_0xe37e9a[_0x44d2fb(0xc4)][_0x44d2fb(0x122)]))return _0xe37e9a;const _0x3e1d98=_0xe37e9a['id'][_0x44d2fb(0x8b)](_0x4963f7);if(_0x3e1d98<-0x2*0x36d+0x1635+-0xf5b)return _0xe37e9a;const _0x1e4874=_0x33abc0[_0x44d2fb(0x120)](_0xe37e9a['id'][_0x44d2fb(0x102)](_0x3e1d98+_0x4963f7[_0x44d2fb(0x113)]));return _0x1e4874===undefined?_0xe37e9a:{..._0xe37e9a,'payload':{..._0xe37e9a[_0x44d2fb(0xc4)],'attachments':_0x1e4874}};});}export function codexNativeItemIds(_0xb243d6){const _0x1ef7e0=_0x4693;return new Set(_0xb243d6[_0x1ef7e0(0xa5)](_0x197e58=>{const _0x133aab=_0x1ef7e0;if(!isPlainRecord(_0x197e58))return[];const _0x55be4d=typeof _0x197e58[_0x133aab(0xb1)]===_0x133aab(0xfa)?_0x197e58[_0x133aab(0xb1)]:typeof _0x197e58['id']===_0x133aab(0xfa)?_0x197e58['id']:undefined;return _0x55be4d===undefined?[]:[_0x55be4d];}));}export function conversationItemNativeId(_0x25f1da){const _0x4efdb9=_0x4693;if(_0x25f1da[_0x4efdb9(0xa3)](_0x4efdb9(0xb6)))return _0x25f1da[_0x4efdb9(0x102)](_0x4efdb9(0xb6)[_0x4efdb9(0x113)]);const _0x54dab4=_0x4efdb9(0xb7),_0xcbff42=_0x25f1da[_0x4efdb9(0x8b)](_0x54dab4);return _0xcbff42<0x42d*-0x6+-0x2402+0x3d10?undefined:_0x25f1da[_0x4efdb9(0x102)](_0xcbff42+_0x54dab4[_0x4efdb9(0x113)]);}export function codexOfficialItems(_0x5c8418,_0x40ab41,_0x4bbaa0,_0x251e70,_0x423e88,_0x49490a){const _0x2e1641=_0x4693,_0x2a8258=[],_0x2bceee=new Map();for(const [_0x338186,_0x32a8b2]of _0x4bbaa0[_0x2e1641(0x124)]()){const _0xd5a586=codexOfficialItem(_0x5c8418,_0x40ab41,_0x32a8b2,_0x251e70,_0x338186,_0x423e88,_0x49490a);if(_0xd5a586===undefined)continue;if(_0xd5a586[_0x2e1641(0xd5)]===_0x2e1641(0x127)&&_0x2a8258['at'](-(0x127e+-0x1*0x1de+-0x353*0x5))?.[_0x2e1641(0xd5)]===_0x2e1641(0x127))continue;const _0x5cf3c9=codexPairedToolCallId(_0x32a8b2);if(_0x5cf3c9===undefined){_0x2a8258[_0x2e1641(0x112)](_0xd5a586);continue;}const _0x161f77=_0x2bceee[_0x2e1641(0x120)](_0x5cf3c9);if(_0x161f77===undefined){_0x2bceee[_0x2e1641(0xf1)](_0x5cf3c9,_0x2a8258[_0x2e1641(0x113)]),_0x2a8258[_0x2e1641(0x112)](_0xd5a586);continue;}const _0x9bdd56=_0x2a8258[_0x161f77],_0x979607=isPlainRecord(_0x32a8b2)&&(_0x32a8b2[_0x2e1641(0xd7)]===_0x2e1641(0x11e)||_0x32a8b2[_0x2e1641(0xd7)]===_0x2e1641(0x10c))?_0xd5a586:_0x9bdd56,_0x15e18e=_0x979607===_0xd5a586?_0x9bdd56:_0xd5a586;_0x2a8258[_0x161f77]=mergeCodexCustomToolItems(_0x979607,_0x15e18e);}return _0x2a8258;}export function codexPairedToolCallId(_0x295fcd){const _0x574125=_0x4693;if(!isPlainRecord(_0x295fcd))return undefined;if(_0x295fcd[_0x574125(0xd7)]!==_0x574125(0x11e)&&_0x295fcd[_0x574125(0xd7)]!==_0x574125(0xdf)&&_0x295fcd[_0x574125(0xd7)]!==_0x574125(0x10c)&&_0x295fcd[_0x574125(0xd7)]!==_0x574125(0xf3))return undefined;return typeof _0x295fcd[_0x574125(0xb1)]===_0x574125(0xfa)?_0x295fcd[_0x574125(0xb1)]:typeof _0x295fcd['id']===_0x574125(0xfa)?_0x295fcd['id']:undefined;}export function mergeCodexCustomToolItems(_0x1eaaf6,_0x4cc155){const _0x54a15c=_0x4693;if(_0x1eaaf6[_0x54a15c(0xd5)]!==_0x54a15c(0x126)||_0x4cc155[_0x54a15c(0xd5)]!==_0x54a15c(0x126))return _0x1eaaf6;const _0xf2b970=isPlainRecord(_0x1eaaf6[_0x54a15c(0xc4)])?_0x1eaaf6[_0x54a15c(0xc4)]:{},_0xc13001=isPlainRecord(_0x4cc155[_0x54a15c(0xc4)])?_0x4cc155[_0x54a15c(0xc4)]:{};return{..._0x1eaaf6,'status':_0x4cc155[_0x54a15c(0xc0)],'completedAt':_0x4cc155[_0x54a15c(0x8f)],'payload':{..._0xf2b970,'outputSummary':_0xc13001[_0x54a15c(0xcf)]??_0xf2b970[_0x54a15c(0xcf)],'errorCode':_0xc13001[_0x54a15c(0xae)]??_0xf2b970[_0x54a15c(0xae)],'truncated':_0xf2b970[_0x54a15c(0xfd)]===!![]||_0xc13001[_0x54a15c(0xfd)]===!![],..._0xc13001[_0x54a15c(0x122)]===undefined?{}:{'attachments':_0xc13001[_0x54a15c(0x122)]}}};}export function coalesceImageGenerationItems(_0x2e9a17){const _0x2fc872=_0x4693,_0x1c6545=[];for(const _0x147ca1 of _0x2e9a17){const _0x169cd0=isPlainRecord(_0x147ca1[_0x2fc872(0xc4)])?_0x147ca1[_0x2fc872(0xc4)]:undefined,_0x5823dc=_0x1c6545['at'](-(0xd0*-0x17+0x44*0x2+-0x1229*-0x1)),_0x2cb841=_0x5823dc!==undefined&&isPlainRecord(_0x5823dc[_0x2fc872(0xc4)])?_0x5823dc[_0x2fc872(0xc4)]:undefined;if(_0x147ca1[_0x2fc872(0xd5)]!==_0x2fc872(0x126)||_0x169cd0?.[_0x2fc872(0x123)]!==_0x2fc872(0x118)||_0x5823dc?.[_0x2fc872(0xd5)]!==_0x2fc872(0x126)||_0x2cb841?.[_0x2fc872(0x123)]!==_0x2fc872(0x118)){_0x1c6545[_0x2fc872(0x112)](_0x147ca1);continue;}const _0x5a0f9b=[...Array[_0x2fc872(0x111)](_0x2cb841[_0x2fc872(0x122)])?_0x2cb841[_0x2fc872(0x122)]:[],...Array[_0x2fc872(0x111)](_0x169cd0[_0x2fc872(0x122)])?_0x169cd0[_0x2fc872(0x122)]:[]];_0x1c6545[_0x1c6545[_0x2fc872(0x113)]-(-0x2d*0xbe+-0x22*0xf8+0x4257)]={..._0x5823dc,'completedAt':_0x147ca1[_0x2fc872(0x8f)]??_0x5823dc[_0x2fc872(0x8f)],'payload':{..._0x2cb841,'attachments':_0x5a0f9b}};}return _0x1c6545;}export function codexPlanText(_0x458331){const _0x1ef034=_0x4693;if(typeof _0x458331[_0x1ef034(0xd7)]!==_0x1ef034(0xfa)||typeof _0x458331[_0x1ef034(0x11c)]!==_0x1ef034(0xfa))return undefined;const _0x56feef=_0x458331[_0x1ef034(0x11c)][_0x1ef034(0xd1)]();if(_0x56feef[_0x1ef034(0x113)]===0x34*0x97+0x1031+-0x2edd)return undefined;if(_0x458331[_0x1ef034(0xd7)][_0x1ef034(0xf6)]()===_0x1ef034(0xf2))return _0x56feef;if(_0x458331[_0x1ef034(0xd7)]!==_0x1ef034(0xe0)||!_0x56feef[_0x1ef034(0xa3)](_0x1ef034(0x9c)))return undefined;const _0x320bfd=_0x56feef[_0x1ef034(0x102)](_0x1ef034(0x9c)[_0x1ef034(0x113)])[_0x1ef034(0xd4)](/<\/proposed_plan>\s*$/,'')[_0x1ef034(0xd1)]();return _0x320bfd[_0x1ef034(0x113)]>0x2301+-0xbe7*-0x1+-0x2ee8?_0x320bfd:undefined;}export function codexOfficialItem(_0x348e53,_0x53cfee,_0x614247,_0x2144f1,_0x403741,_0x4b813c,_0x22c65a){const _0x316d66=_0x4693;if(!isPlainRecord(_0x614247)||typeof _0x614247[_0x316d66(0xd7)]!==_0x316d66(0xfa))return undefined;const _0x2e4f89=(_0x614247[_0x316d66(0xd7)]===_0x316d66(0x11e)||_0x614247[_0x316d66(0xd7)]===_0x316d66(0xdf)||_0x614247[_0x316d66(0xd7)]===_0x316d66(0x10c)||_0x614247[_0x316d66(0xd7)]===_0x316d66(0xf3))&&typeof _0x614247[_0x316d66(0xb1)]===_0x316d66(0xfa)?_0x614247[_0x316d66(0xb1)]:typeof _0x614247['id']===_0x316d66(0xfa)?_0x614247['id']:typeof _0x614247[_0x316d66(0xb1)]===_0x316d66(0xfa)?_0x614247[_0x316d66(0xb1)]:_0x53cfee+':'+_0x403741,_0x35e741={'id':_0x348e53['id']+_0x316d66(0xb9)+_0x53cfee+':'+_0x2e4f89,'sessionId':_0x348e53['id'],'turnId':_0x348e53['id']+_0x316d66(0xb9)+_0x53cfee,'runId':null,'parentItemId':null,'sourceSequence':_0x2144f1*(0x1505+0x1e8b+0x2*-0x640)+_0x403741,'revision':0x0,'status':_0x316d66(0x90),'startedAt':_0x4b813c,'completedAt':_0x22c65a};if(_0x614247[_0x316d66(0xd7)]===_0x316d66(0xaa)){const _0x419d76=codexContentText(_0x614247[_0x316d66(0xf5)]);return _0x419d76[_0x316d66(0x113)]===-0x204d+0x1*-0x14b9+0x3506?undefined:{..._0x35e741,'kind':_0x316d66(0xd8),'payload':{'clientMessageId':null,'text':_0x419d76,'contexts':[],'delivery':_0x316d66(0x119)}};}const _0x1b0e5b=codexPlanText(_0x614247);if(_0x1b0e5b!==undefined)return{..._0x35e741,'kind':_0x316d66(0xf2),'payload':{'explanation':_0x1b0e5b,'steps':[]}};if(_0x614247[_0x316d66(0xd7)]===_0x316d66(0xe0)&&typeof _0x614247[_0x316d66(0x11c)]===_0x316d66(0xfa)&&_0x614247[_0x316d66(0x11c)][_0x316d66(0xd1)]()[_0x316d66(0x113)]>-0x5bf*-0x6+0x36b+-0x25e5)return{..._0x35e741,'kind':_0x316d66(0x125),'payload':{'text':_0x614247[_0x316d66(0x11c)],'format':_0x316d66(0xdb),'source':_0x316d66(0xde)}};if(_0x614247[_0x316d66(0xd7)]===_0x316d66(0xc6)){const _0x5c78a9=Array[_0x316d66(0x111)](_0x614247[_0x316d66(0xc8)])?_0x614247[_0x316d66(0xc8)][_0x316d66(0xa5)]((_0xa6e2b,_0x2d68f1)=>typeof _0xa6e2b===_0x316d66(0xfa)&&_0xa6e2b[_0x316d66(0xd1)]()[_0x316d66(0x113)]>0x65f*-0x3+-0x11c7+0x24e4?[{'index':_0x2d68f1,'text':compactRunnerText(_0xa6e2b,-0x7a4+0x1f2c+0xf88)}]:[]):[];return{..._0x35e741,'kind':_0x316d66(0xbe),'payload':{'sections':_0x5c78a9}};}if(_0x614247[_0x316d66(0xd7)]===_0x316d66(0xbf)){const _0x5d1fb6=typeof _0x614247[_0x316d66(0x11f)]===_0x316d66(0xfa)?_0x614247[_0x316d66(0x11f)]:'';return{..._0x35e741,'kind':_0x316d66(0xef),'payload':{'command':typeof _0x614247[_0x316d66(0x95)]===_0x316d66(0xfa)?compactRunnerText(_0x614247[_0x316d66(0x95)],-0x1*0x1d55+-0x4ad5+0x8f3a):_0x316d66(0x96),'cwd':typeof _0x614247[_0x316d66(0xe1)]===_0x316d66(0xfa)?compactRunnerText(_0x614247[_0x316d66(0xe1)],-0xf9+0xa5a+0x69f):null,'outputPreview':compactRunnerText(_0x5d1fb6,0x91*-0x45+-0x4f*0x3b+0x605a),'outputRef':null,'exitCode':typeof _0x614247[_0x316d66(0xc1)]===_0x316d66(0x92)&&Number[_0x316d66(0x132)](_0x614247[_0x316d66(0xc1)])?_0x614247[_0x316d66(0xc1)]:null,'durationMs':typeof _0x614247[_0x316d66(0x10b)]===_0x316d66(0x92)&&Number[_0x316d66(0x132)](_0x614247[_0x316d66(0x10b)])&&_0x614247[_0x316d66(0x10b)]>=-0x19*0x55+-0x1*0x623+0x7*0x210?_0x614247[_0x316d66(0x10b)]:null,'truncated':_0x5d1fb6[_0x316d66(0x113)]>-0x4564+-0x37c7+0xa43b}};}if(_0x614247[_0x316d66(0xd7)]===_0x316d66(0x110))return{..._0x35e741,'kind':_0x316d66(0x126),'payload':{'title':[typeof _0x614247[_0x316d66(0x101)]===_0x316d66(0xfa)?_0x614247[_0x316d66(0x101)]:'',typeof _0x614247[_0x316d66(0xd6)]===_0x316d66(0xfa)?_0x614247[_0x316d66(0xd6)]:''][_0x316d66(0xfb)](Boolean)[_0x316d66(0x107)]('.'),'namespace':typeof _0x614247[_0x316d66(0x101)]===_0x316d66(0xfa)?_0x614247[_0x316d66(0x101)]:'','toolName':typeof _0x614247[_0x316d66(0xd6)]===_0x316d66(0xfa)?_0x614247[_0x316d66(0xd6)]:'','inputSummary':codexCompactJson(_0x614247[_0x316d66(0x97)]),'outputSummary':codexCompactJson(_0x614247[_0x316d66(0xf4)]),..._0x614247[_0x316d66(0xd9)]===undefined?{}:{'errorCode':codexCompactJson(_0x614247[_0x316d66(0xd9)])}}};if(_0x614247[_0x316d66(0xd7)]===_0x316d66(0x114))return{..._0x35e741,'kind':_0x316d66(0x126),'payload':{'title':_0x316d66(0xa1),'namespace':_0x316d66(0x128),'toolName':_0x316d66(0x115),'inputSummary':typeof _0x614247[_0x316d66(0x133)]===_0x316d66(0xfa)?_0x614247[_0x316d66(0x133)]:''}};if(_0x614247[_0x316d66(0xd7)]===_0x316d66(0xea))return{..._0x35e741,'kind':_0x316d66(0x126),'payload':{'title':_0x316d66(0x118),'namespace':_0x316d66(0xa8),'toolName':_0x316d66(0x118),'inputSummary':typeof _0x614247[_0x316d66(0x105)]===_0x316d66(0xfa)?_0x614247[_0x316d66(0x105)]:null,'outputSummary':_0x614247[_0x316d66(0xc0)]===_0x316d66(0xb3)?_0x316d66(0xe3):_0x316d66(0xc3),'progressLabel':null,'errorCode':_0x614247[_0x316d66(0xc0)]===_0x316d66(0xec)?_0x316d66(0xfc):null,'truncated':![]}};if(_0x614247[_0x316d66(0xd7)]===_0x316d66(0x121)||_0x614247[_0x316d66(0xd7)]===_0x316d66(0x11e)||_0x614247[_0x316d66(0xd7)]===_0x316d66(0xdf)||_0x614247[_0x316d66(0xd7)]===_0x316d66(0x10c)||_0x614247[_0x316d66(0xd7)]===_0x316d66(0xf3)||_0x614247[_0x316d66(0xd7)]===_0x316d66(0xbd)||_0x614247[_0x316d66(0xd7)]===_0x316d66(0xac)||_0x614247[_0x316d66(0xd7)]===_0x316d66(0xb4)||_0x614247[_0x316d66(0xd7)]===_0x316d66(0x12b)){const _0x165414=typeof _0x614247[_0x316d66(0xd6)]===_0x316d66(0xfa)?_0x614247[_0x316d66(0xd6)]:typeof _0x614247[_0x316d66(0x94)]===_0x316d66(0xfa)?_0x614247[_0x316d66(0x94)]:_0x316d66(0xd6);return{..._0x35e741,'kind':_0x316d66(0x126),'payload':{'title':_0x165414,'namespace':typeof _0x614247[_0x316d66(0xa2)]===_0x316d66(0xfa)?_0x614247[_0x316d66(0xa2)]:_0x316d66(0xa8),'toolName':_0x165414,'inputSummary':codexCompactJson(_0x614247[_0x316d66(0x97)]??_0x614247[_0x316d66(0xa4)]),'outputSummary':codexToolOutputSummary(_0x614247[_0x316d66(0xd0)]??_0x614247[_0x316d66(0x116)]),'progressLabel':null,'errorCode':null,'truncated':![]}};}if(_0x614247[_0x316d66(0xd7)]===_0x316d66(0x100)&&Array[_0x316d66(0x111)](_0x614247[_0x316d66(0x98)]))return{..._0x35e741,'kind':_0x316d66(0x9b),'payload':{'changes':_0x614247[_0x316d66(0x98)]}};if(_0x614247[_0x316d66(0xd7)]===_0x316d66(0xe9))return{..._0x35e741,'kind':_0x316d66(0x127),'payload':{'phase':_0x316d66(0x90),'summary':_0x316d66(0xf7),'summaryCode':_0x316d66(0xeb)}};return codexUnknownOfficialItem(_0x35e741,_0x614247);}export function codexLiveConversationItem(_0x2ac868,_0x175a11,_0x1ca2e7=[]){const _0x71d092=_0x4693;if(typeof _0x2ac868[_0x71d092(0xd7)]!==_0x71d092(0xfa))return undefined;const _0x3b03b9=typeof _0x2ac868[_0x71d092(0xb1)]===_0x71d092(0xfa)?_0x2ac868[_0x71d092(0xb1)]:typeof _0x2ac868['id']===_0x71d092(0xfa)?_0x2ac868['id']:undefined;if(_0x3b03b9===undefined)return undefined;const _0x59ebf2=boundedConversationItemId(_0x71d092(0xa8),_0x3b03b9);if(_0x2ac868[_0x71d092(0xd7)]===_0x71d092(0xc6)){const _0x3003bb=Array[_0x71d092(0x111)](_0x2ac868[_0x71d092(0xc8)])?_0x2ac868[_0x71d092(0xc8)][_0x71d092(0xa5)]((_0x12f414,_0x158ebf)=>typeof _0x12f414===_0x71d092(0xfa)&&_0x12f414[_0x71d092(0xd1)]()[_0x71d092(0x113)]>-0x21*-0x1+-0x1d9d+0x4ea*0x6?[{'index':_0x158ebf,'text':compactRunnerText(_0x12f414,0x1117+0x4c9b*-0x1+0x6294)}]:[]):[];return{'itemId':_0x59ebf2,'kind':_0x71d092(0xbe),'status':_0x175a11?_0x71d092(0x90):_0x71d092(0xd3),'payload':{'sections':_0x3003bb}};}const _0x3a2d46=codexPlanText(_0x2ac868);if(_0x3a2d46!==undefined)return{'itemId':_0x59ebf2,'kind':_0x71d092(0xf2),'status':_0x175a11?_0x71d092(0x90):_0x71d092(0xd3),'payload':{'explanation':compactRunnerText(_0x3a2d46,0xc*-0x90f+0x1*0x45fb+0x8fd*0xd),'steps':[]}};if(_0x2ac868[_0x71d092(0xd7)]===_0x71d092(0xe0)){if(!_0x175a11||typeof _0x2ac868[_0x71d092(0x11c)]!==_0x71d092(0xfa)||_0x2ac868[_0x71d092(0x11c)][_0x71d092(0x113)]===-0x13e4+0x2*0x10c1+-0xa6*0x15)return undefined;return{'itemId':_0x59ebf2,'kind':_0x71d092(0x125),'status':_0x71d092(0x90),'payload':{'text':compactRunnerText(_0x2ac868[_0x71d092(0x11c)],MAX_ASSISTANT_MESSAGE_CHARACTERS),'format':_0x71d092(0xdb),'model':null}};}if(_0x2ac868[_0x71d092(0xd7)]===_0x71d092(0xbf)){const _0x31c09a=typeof _0x2ac868[_0x71d092(0x11f)]===_0x71d092(0xfa)?_0x2ac868[_0x71d092(0x11f)]:'';return{'itemId':_0x59ebf2,'kind':_0x71d092(0xef),'status':codexItemStatus(_0x2ac868[_0x71d092(0xc0)],_0x175a11),'payload':{'command':typeof _0x2ac868[_0x71d092(0x95)]===_0x71d092(0xfa)?compactRunnerText(_0x2ac868[_0x71d092(0x95)],0x147*0x2a+-0x1bef+-0x473*-0x3):_0x71d092(0x96),'cwd':typeof _0x2ac868[_0x71d092(0xe1)]===_0x71d092(0xfa)?compactRunnerText(_0x2ac868[_0x71d092(0xe1)],0x3*0x413+0x43a*-0x2+0xc3b):null,'outputPreview':compactRunnerText(_0x31c09a,-0xab*-0x5f+-0xd68+-0x1d*0x61),'outputRef':null,'exitCode':typeof _0x2ac868[_0x71d092(0xc1)]===_0x71d092(0x92)&&Number[_0x71d092(0x132)](_0x2ac868[_0x71d092(0xc1)])?_0x2ac868[_0x71d092(0xc1)]:null,'durationMs':typeof _0x2ac868[_0x71d092(0x10b)]===_0x71d092(0x92)&&Number[_0x71d092(0x132)](_0x2ac868[_0x71d092(0x10b)])&&_0x2ac868[_0x71d092(0x10b)]>=-0xe*0x27f+0x338+0x1fba?_0x2ac868[_0x71d092(0x10b)]:null,'truncated':_0x31c09a[_0x71d092(0x113)]>-0x7fa*-0x4+0x4793*0x1+-0x1579*0x3}};}if(_0x2ac868[_0x71d092(0xd7)]===_0x71d092(0x110)){const _0x59909c=compactRunnerValue(_0x2ac868[_0x71d092(0x97)],0x30e9+0x4*-0x29+-0x1*0x935),_0x2bedd2=compactRunnerValue(_0x2ac868[_0x71d092(0xf4)],0x1b4c+0x86a*0x3+-0xd7a),_0x344beb=compactRunnerValue(_0x2ac868[_0x71d092(0xd9)],-0x202e+-0x2*-0x3f7+0x1890),_0x960e20=typeof _0x2ac868[_0x71d092(0x101)]===_0x71d092(0xfa)?_0x2ac868[_0x71d092(0x101)]:_0x71d092(0x8c),_0x1414bf=typeof _0x2ac868[_0x71d092(0xd6)]===_0x71d092(0xfa)?_0x2ac868[_0x71d092(0xd6)]:_0x71d092(0xd6);return{'itemId':_0x59ebf2,'kind':_0x71d092(0x126),'status':codexItemStatus(_0x2ac868[_0x71d092(0xc0)],_0x175a11),'payload':{'namespace':compactRunnerText(_0x960e20,-0x6*0x53f+-0x398*0x2+0x272a),'toolName':compactRunnerText(_0x1414bf,-0x2421+0xa54+-0x1a4d*-0x1),'title':compactRunnerText(_0x960e20+'.'+_0x1414bf,-0x1600+0xd*0x184+0x440),'inputSummary':_0x59909c[_0x71d092(0x11c)]||null,'outputSummary':_0x2bedd2[_0x71d092(0x11c)]||null,'progressLabel':null,'errorCode':_0x344beb[_0x71d092(0x11c)]||null,'truncated':_0x59909c[_0x71d092(0xfd)]||_0x2bedd2[_0x71d092(0xfd)]||_0x344beb[_0x71d092(0xfd)]}};}if(_0x2ac868[_0x71d092(0xd7)]===_0x71d092(0x114))return{'itemId':_0x59ebf2,'kind':_0x71d092(0x126),'status':_0x175a11?_0x71d092(0x90):_0x71d092(0xd3),'payload':{'namespace':_0x71d092(0x128),'toolName':_0x71d092(0x115),'title':_0x71d092(0xa1),'inputSummary':typeof _0x2ac868[_0x71d092(0x133)]===_0x71d092(0xfa)?compactRunnerText(_0x2ac868[_0x71d092(0x133)],-0x1d*0xb3+-0x42d6+0x7e2d):null,'outputSummary':null,'progressLabel':_0x175a11?null:_0x71d092(0x12e),'progressLabelCode':_0x175a11?null:_0x71d092(0x131),'errorCode':null,'truncated':![]}};if(_0x2ac868[_0x71d092(0xd7)]===_0x71d092(0x100)&&Array[_0x71d092(0x111)](_0x2ac868[_0x71d092(0x98)]))return{'itemId':_0x59ebf2,'kind':_0x71d092(0x9b),'status':_0x175a11?_0x71d092(0x90):_0x71d092(0xd3),'payload':{'changes':_0x2ac868[_0x71d092(0x98)]},'merge':!![]};if(_0x2ac868[_0x71d092(0xd7)]===_0x71d092(0xea))return{'itemId':_0x59ebf2,'kind':_0x71d092(0x126),'status':codexItemStatus(_0x2ac868[_0x71d092(0xc0)],_0x175a11),'payload':{'namespace':_0x71d092(0xa8),'toolName':_0x71d092(0x118),'title':_0x71d092(0x118),'inputSummary':typeof _0x2ac868[_0x71d092(0x105)]===_0x71d092(0xfa)?compactRunnerText(_0x2ac868[_0x71d092(0x105)],-0x2ceb*-0x1+-0x4bc7+0x45ec):null,'outputSummary':_0x175a11?_0x71d092(0xe3):null,'outputSummaryCode':_0x175a11?_0x71d092(0x9e):null,'progressLabel':_0x175a11?null:_0x71d092(0xee),'progressLabelCode':_0x175a11?null:_0x71d092(0x10e),'errorCode':_0x2ac868[_0x71d092(0xc0)]===_0x71d092(0xec)?_0x71d092(0xfc):null,'truncated':![],..._0x1ca2e7[_0x71d092(0x113)]===0xab5+-0x255b+-0xd53*-0x2?{}:{'attachments':_0x1ca2e7}},'merge':!![]};if(_0x2ac868[_0x71d092(0xd7)]===_0x71d092(0xe9))return{'itemId':_0x59ebf2,'kind':_0x71d092(0x127),'status':_0x175a11?_0x71d092(0x90):_0x71d092(0xd3),'payload':{'phase':_0x175a11?_0x71d092(0x90):_0x71d092(0xca),'summary':null}};if(_0x2ac868[_0x71d092(0xd7)]===_0x71d092(0x121)||_0x2ac868[_0x71d092(0xd7)]===_0x71d092(0x11e)||_0x2ac868[_0x71d092(0xd7)]===_0x71d092(0xdf)||_0x2ac868[_0x71d092(0xd7)]===_0x71d092(0x10c)||_0x2ac868[_0x71d092(0xd7)]===_0x71d092(0xf3)||_0x2ac868[_0x71d092(0xd7)]===_0x71d092(0xbd)||_0x2ac868[_0x71d092(0xd7)]===_0x71d092(0xac)||_0x2ac868[_0x71d092(0xd7)]===_0x71d092(0xb4)||_0x2ac868[_0x71d092(0xd7)]===_0x71d092(0x12b)){const _0x27cc20=typeof _0x2ac868[_0x71d092(0xd6)]===_0x71d092(0xfa)?_0x2ac868[_0x71d092(0xd6)]:typeof _0x2ac868[_0x71d092(0x94)]===_0x71d092(0xfa)?_0x2ac868[_0x71d092(0x94)]:_0x71d092(0xd6),_0x2eff8e=compactRunnerValue(_0x2ac868[_0x71d092(0x97)]??_0x2ac868[_0x71d092(0xa4)],-0x1d6a*0x1+-0x4a7+0x1*0x4921),_0x12bf12=compactRunnerValue(codexToolOutput(_0x2ac868[_0x71d092(0xd0)]??_0x2ac868[_0x71d092(0x116)]),-0x4c46+-0x1*-0x6d9+0x6c7d);if(_0x2ac868[_0x71d092(0xd7)]===_0x71d092(0xdf)||_0x2ac868[_0x71d092(0xd7)]===_0x71d092(0xf3)||_0x2ac868[_0x71d092(0xd7)]===_0x71d092(0xac)||_0x2ac868[_0x71d092(0xd7)]===_0x71d092(0x12b))return{'itemId':_0x59ebf2,'kind':_0x71d092(0x126),'status':codexItemStatus(_0x2ac868[_0x71d092(0xc0)],_0x175a11),'payload':{'outputSummary':_0x12bf12[_0x71d092(0x11c)]||null,..._0x1ca2e7[_0x71d092(0x113)]===-0x1*-0x1f37+0x55b*0x2+-0x29ed?{}:{'attachments':_0x1ca2e7}},'merge':!![]};return{'itemId':_0x59ebf2,'kind':_0x71d092(0x126),'status':codexItemStatus(_0x2ac868[_0x71d092(0xc0)],_0x175a11),'payload':{'namespace':typeof _0x2ac868[_0x71d092(0xa2)]===_0x71d092(0xfa)?compactRunnerText(_0x2ac868[_0x71d092(0xa2)],0x265*-0x3+0x868+-0xb9):_0x71d092(0xa8),'toolName':compactRunnerText(_0x27cc20,0x73a+-0x11bb+0xb01),'title':compactRunnerText(_0x27cc20,-0x1163+-0x20*0x89+0x2477),'inputSummary':_0x2eff8e[_0x71d092(0x11c)]||null,'outputSummary':_0x12bf12[_0x71d092(0x11c)]||null,'progressLabel':null,'errorCode':null,'truncated':_0x2eff8e[_0x71d092(0xfd)]||_0x12bf12[_0x71d092(0xfd)],..._0x1ca2e7[_0x71d092(0x113)]===0x606+0xaf7*-0x1+0x1*0x4f1?{}:{'attachments':_0x1ca2e7}}};}return codexUnknownLiveItem(_0x59ebf2,_0x2ac868[_0x71d092(0xd7)],_0x175a11);}function codexUnknownOfficialItem(_0x2c5e0d,_0x38c353){const _0x29ff94=_0x4693;if(_0x38c353[_0x29ff94(0xd7)]===_0x29ff94(0xaa)||_0x38c353[_0x29ff94(0xd7)]===_0x29ff94(0xe0))return undefined;const _0xc929f3=typeof _0x38c353[_0x29ff94(0xd7)]===_0x29ff94(0xfa)?_0x38c353[_0x29ff94(0xd7)]:_0x29ff94(0xdc);return{..._0x2c5e0d,'kind':_0x29ff94(0xdc),'payload':{'sourceEventType':_0x29ff94(0xb6)+_0xc929f3,'label':_0x29ff94(0xad)+compactRunnerText(_0xc929f3,0x1dce+-0x1b78+-0x1d6)}};}function codexUnknownLiveItem(_0x496399,_0xc9e70,_0x309116){const _0x2bccf1=_0x4693;if(_0xc9e70===_0x2bccf1(0xaa)||_0xc9e70===_0x2bccf1(0xe0))return undefined;return{'itemId':_0x496399,'kind':_0x2bccf1(0xdc),'status':_0x309116?_0x2bccf1(0x90):_0x2bccf1(0xd3),'payload':{'sourceEventType':_0x2bccf1(0xb6)+_0xc9e70,'label':_0x2bccf1(0xad)+compactRunnerText(_0xc9e70,0x82c+-0x1b5b+0x13af*0x1)}};}export function codexImageAttachments(_0x3d52a8){const _0x24e934=[];let _0x1e2665=-0x1*0x256e+0x1715+-0x1*-0xe59;const _0x587ff4=(_0xd1d33f,_0x5d0512)=>{const _0x557204=_0x4693;if(_0x24e934[_0x557204(0x113)]>=0x392*0x2+0x24ce+-0x2bed||_0x5d0512>0x5d7+-0x21ea+-0x31f*-0x9||_0xd1d33f===null||_0xd1d33f===undefined)return;if(Array[_0x557204(0x111)](_0xd1d33f)){for(const _0x2d10f0 of _0xd1d33f)_0x587ff4(_0x2d10f0,_0x5d0512+(0x1*-0xda8+0xed*0x22+0x11d1*-0x1));return;}if(!isPlainRecord(_0xd1d33f))return;const _0x13fe8a=typeof _0xd1d33f[_0x557204(0xd7)]===_0x557204(0xfa)?_0xd1d33f[_0x557204(0xd7)]:'';if(_0x13fe8a===_0x557204(0xed)&&typeof _0xd1d33f[_0x557204(0x11c)]===_0x557204(0xfa)){const _0x37cfda=/["']image_url["']\s*:\s*["'](data:image\/[^"']+)["']/[_0x557204(0x109)](_0xd1d33f[_0x557204(0x11c)])?.[-0xcc9*0x1+-0xa30+0x16fa];_0x37cfda!==undefined&&_0x587ff4({'type':_0x557204(0xc7),'image_url':_0x37cfda},_0x5d0512+(0x2ca*0x1+-0x1c18+0x155*0x13));}const _0x373918=typeof _0xd1d33f[_0x557204(0xe6)]===_0x557204(0xfa)?_0xd1d33f[_0x557204(0xe6)]:undefined,_0x312a38=isPlainRecord(_0xd1d33f[_0x557204(0xa9)])?typeof _0xd1d33f[_0x557204(0xa9)][_0x557204(0xcd)]===_0x557204(0xfa)?_0xd1d33f[_0x557204(0xa9)][_0x557204(0xcd)]:undefined:typeof _0xd1d33f[_0x557204(0xa9)]===_0x557204(0xfa)?_0xd1d33f[_0x557204(0xa9)]:undefined,_0xa79669=_0x373918??(_0x312a38?.[_0x557204(0xa3)](_0x557204(0xb0))?_0x312a38:undefined);if((_0x13fe8a===_0x557204(0xba)||_0x13fe8a===_0x557204(0xc7)||_0x13fe8a===_0x557204(0xc5))&&_0xa79669!==undefined){const _0x26e416=/^data:([^;,]+);base64,(.*)$/[_0x557204(0x109)](_0xa79669),_0x5dd989=typeof _0xd1d33f[_0x557204(0x12a)]===_0x557204(0xfa)?_0xd1d33f[_0x557204(0x12a)]:typeof _0xd1d33f[_0x557204(0xd2)]===_0x557204(0xfa)?_0xd1d33f[_0x557204(0xd2)]:_0x26e416?.[0x1ecd+0x4*-0x101+-0x1ac8]??_0x557204(0xdd),_0x35526a=_0x26e416?.[0xad9+0xf4b+0x1e*-0xdf]??_0xa79669;_0x5dd989[_0x557204(0xa3)](_0x557204(0x10f))&&isCanonicalBase64(_0x35526a)&&_0x35526a[_0x557204(0x113)]>0x492+-0x722+0x4*0xa4&&Buffer[_0x557204(0xf9)](_0x35526a,_0x557204(0x11b))<=MAX_COMPOSER_ATTACHMENT_BYTES&&_0x1e2665+Buffer[_0x557204(0xf9)](_0x35526a,_0x557204(0x11b))<=MAX_COMPOSER_ATTACHMENTS_BYTES&&(_0x1e2665+=Buffer[_0x557204(0xf9)](_0x35526a,_0x557204(0x11b)),_0x24e934[_0x557204(0x112)]({'name':typeof _0xd1d33f[_0x557204(0x94)]===_0x557204(0xfa)?_0xd1d33f[_0x557204(0x94)]:_0x557204(0x12f)+(_0x24e934[_0x557204(0x113)]+(0x2363*-0x1+-0x4c*0x8+0x25c4))+_0x557204(0xbb),'mime':_0x5dd989,'dataBase64':_0x35526a}));}for(const [_0x380469,_0x1ecf92]of Object[_0x557204(0x124)](_0xd1d33f)){if(_0x380469===_0x557204(0xe6)||_0x380469===_0x557204(0xa9))continue;_0x587ff4(_0x1ecf92,_0x5d0512+(0x7e0+0x12ef+-0x1ace));}};return _0x587ff4(_0x3d52a8,0x22*-0xee+0xac7+0x14d5*0x1),_0x24e934;}function _0x4137(){const _0x1a3bb1=['BgvUz3rO','D2vIu2vHCMnO','C2vHCMnO','B3v0Chv0','rKfjteve','Aw1Hz2vNzw4','qundrvburuq','CMvKDwnL','yMfZzty0','Dgv4Da','mtC4mJeZmZb5svfdsKK','y3vZDg9Tx3rVB2XFy2fSBa','ywDNCMvNyxrLze91Dhb1Da','z2v0','zhLUyw1Py1rVB2XdywXS','yxr0ywnOBwvUDhm','Dg9VBe5HBwu','zw50CMLLCW','yxnZAxn0yw50x21LC3nHz2u','Dg9VBf9JywXS','y29UDgv4Df9JB21Wywn0Aw9U','D2vI','C3rYAw5NAwz5','BwLTzvr5Cgu','zNvUy3rPB25dywXSt3v0Chv0','zNjVBq','odi4wNfuu2TR','u2vHCMnOAw5N','z2vUzxjHDgvKlwLTywDLlq','Bwf4','u0vbuKnisu5h','AxnjBNrLz2vY','CxvLCNK','BgfZDeLUzgv4t2y','BwnW','zMLUza','mZe4ntG0uNfWtu5O','y29TCgXLDgvKqxq','q09nueXfveve','C29Tzq','BNvTyMvY','mJi3mZyYoePmDenVBa','BMfTzq','y29TBwfUza','ke5VignVBw1HBMqGChjVDMLKzwqP','yxjNDw1LBNrZ','y2HHBMDLCW','BMf0AxzLvhvYBKLK','CNvUswq','zMLSzv9JAgfUz2u','phbYB3bVC2vKx3bSyw4+','sw1Hz2uGz2vUzxjHDgvK','su1br0vFr0vorvjbveLptL9dt01qtevuruq','DhvYBNm','C2L6zq','v2vIifnLyxjJAa','BMfTzxnWywnL','C3rHCNrZv2L0Aa','Aw5WDxq','zMXHDe1HCa','Dw5ZAgLMDa','mJq3nJGZnMHlBxbXBW','y29KzxG','Aw1Hz2vFDxjS','DxnLCK1LC3nHz2u','ywrK','y3vZDg9Tvg9VBenHBgXpDxrWDxq','q29KzxGG','zxjYB3jdB2rL','ntCWodi0yKvyDfDN','zgf0ytO','y2fSBf9Pza','revdteLoruq','y29TCgXLDgvK','zNvUy3rPB25dywXS','DgHYzwfK','y29KzxG6','oMnVzgv4oG','jdfBsw1Hz2uGy29UDgvUDcbLEhrYywn0zwrDjdi','oM9MzMLJAwfSoG','Aw1Hz2u','lNbUzW','B3b0Aw9UCW','y3vZDg9Tvg9VBenHBgW','CMvHC29UAw5Nx3n1Bw1HCNK','y29TBwfUzev4zwn1DgLVBG','C3rHDhvZ','zxHPDenVzgu','yMfZzty0DxjS','sw1Hz2uGz2vUzxjHDgLVBIbMywLSzwq','Cgf5Bg9Hza','B3v0Chv0x2LTywDL','CMvHC29UAw5N','Aw5WDxrFAw1Hz2u','C3vTBwfYEq','zxH0zxjUywXtzxnZAw9Uswq','u1rbuLrfra','BgLTAxq','mte5mJG3nKjou3jvua','DxjS','n29py2TJvW','B3v0Chv0u3vTBwfYEq','y29UDgvUDeL0zw1Z','DhjPBq','BwLTzq','su5Fufjpr1jfu1m','CMvWBgfJzq','A2LUza','Dg9VBa','DhLWzq','DxnLCL9TzxnZywDL','zxjYB3i','AxnpDgHLCG','BwfYA2rVD24','Dw5RBM93BG','Aw1Hz2uVCg5N','y29KzxGTyxbWlxnLCNzLCG','y3vZDg9Tx3rVB2XFy2fSBf9VDxrWDxq','ywDLBNrnzxnZywDL','y3DK','u1vdq0vfreve','sw1Hz2uGz2vUzxjHDgLVBIbJB21WBgv0zwq','nxHTtMn0sW','BwLU','zgf0yq','C3rHCNrLzef0','mZK1nhvgBhLqzG','y29UDgv4DenVBxbHy3rPB24','Aw1Hz2vhzw5LCMf0Aw9U','q09ovevyvf9dt01qqunuruq','zMfPBgvK','Aw5WDxrFDgv4Da','r2vUzxjHDgLUzYbPBwfNzq','y29TBwfUzf9LEgvJDxrPB24','BwfW','C2v0','CgXHBG','zNvUy3rPB25Fy2fSBf9VDxrWDxq','CMvZDwX0','y29UDgvUDa','Dg9mB2nHBgvmB3DLCKnHC2u','q29UDgv4DcbJB21Wywn0zwq','zgvJBgLUzwq','yNL0zuXLBMD0Aa','C3rYAw5N','zMLSDgvY','su1br0vFr0vorvjbveLptL9gquLmruq','Dhj1BMnHDgvK','BgfIzwW','AxrLBxm','zMLSzunOyw5Nzq','C2vYDMvY','C2XPy2u','CxvLC3rPB24','AgfZ','CMv2AxnLzfbYB21WDa','Dg9tDhjPBMC','AM9PBG','y3vYC29Y','zxHLyW','zgvZy3jPChrPB24','zhvYyxrPB25nCW','zNvUy3rPB25Fy2fSBa','B2jQzwn0','r0vorvjbveLor19jtufhrq','Aw1Hz2uV','BwnWvg9VBenHBgW','AxnbCNjHEq','ChvZAa'];_0x4137=function(){return _0x1a3bb1;};return _0x4137();}export function codexUserInputQuestions(_0x4538c5){const _0x4bdf61=_0x4693;if(!Array[_0x4bdf61(0x111)](_0x4538c5)||_0x4538c5[_0x4bdf61(0x113)]===-0x9f7*-0x2+-0x2602+0x1214||_0x4538c5[_0x4bdf61(0x113)]>-0x3f8+0x725+0x10e*-0x3)return[];const _0x431b83=_0x4538c5[_0x4bdf61(0xf0)](_0x5eabd4=>{const _0x896c69=_0x4bdf61;if(!isPlainRecord(_0x5eabd4)||typeof _0x5eabd4['id']!==_0x896c69(0xfa)||typeof _0x5eabd4[_0x896c69(0x103)]!==_0x896c69(0xfa))return undefined;const _0x3e0cbb=Array[_0x896c69(0x111)](_0x5eabd4[_0x896c69(0xbc)])?_0x5eabd4[_0x896c69(0xbc)][_0x896c69(0xa5)](_0x3be938=>isPlainRecord(_0x3be938)&&typeof _0x3be938[_0x896c69(0xfe)]===_0x896c69(0xfa)?[{'value':compactRunnerText(_0x3be938[_0x896c69(0xfe)],-0x8*0x374+0xcf0+-0x1*-0x10a4),'label':compactRunnerText(_0x3be938[_0x896c69(0xfe)],0x426+0x1*-0x19c7+0x1795),'description':typeof _0x3be938[_0x896c69(0x10a)]===_0x896c69(0xfa)?compactRunnerText(_0x3be938[_0x896c69(0x10a)],-0x19a9+-0x2a5+0x2036):null}]:[]):[];return{'id':compactRunnerText(_0x5eabd4['id'],0x541+0x1*-0x2443+-0x1*-0x1f82),'prompt':compactRunnerText(_0x5eabd4[_0x896c69(0x103)],-0x2c*0x5+0x4*-0x564+0x29f4),'options':_0x3e0cbb,'allowOther':_0x5eabd4[_0x896c69(0xda)]===!![]};});return _0x431b83[_0x4bdf61(0x91)](_0x3cb2ab=>_0x3cb2ab===undefined)?[]:_0x431b83;}export function codexItemStatus(_0x3e3c9c,_0x227826){const _0x505556=_0x4693;if(_0x3e3c9c===_0x505556(0xec))return _0x505556(0x117);if(_0x3e3c9c===_0x505556(0xf8))return _0x505556(0xb2);return _0x227826||_0x3e3c9c===_0x505556(0xb3)?_0x505556(0x90):_0x505556(0xd3);}export function codexContentText(_0x3b7e84){const _0x4fc3da=_0x4693;if(!Array[_0x4fc3da(0x111)](_0x3b7e84))return'';const _0x294b2a=_0x3b7e84[_0x4fc3da(0xa5)](_0xeca054=>{const _0x5939ec=_0x4fc3da;if(typeof _0xeca054===_0x5939ec(0xfa))return[_0xeca054];if(!isPlainRecord(_0xeca054))return[];return typeof _0xeca054[_0x5939ec(0x11c)]===_0x5939ec(0xfa)?[_0xeca054[_0x5939ec(0x11c)]]:[];})[_0x4fc3da(0x107)]('\x0a')[_0x4fc3da(0xd1)]();return parseCodexComposerImageMarkers(_0x294b2a)[_0x4fc3da(0x11c)][_0x4fc3da(0xd1)]();}export function codexCompactJson(_0x44baaf){const _0xe73523=_0x4693;if(_0x44baaf===undefined||_0x44baaf===null)return'';if(typeof _0x44baaf===_0xe73523(0xfa))return compactRunnerText(_0x44baaf,-0x83a+0x3ae2+-0x35*0x38);try{return compactRunnerText(JSON[_0xe73523(0x129)](_0x44baaf),0x2f04+0x169b*0x3+0x4bc5*-0x1);}catch{return'';}}export function codexToolOutputSummary(_0x5723f9){return codexCompactJson(codexToolOutput(_0x5723f9));}export function codexToolOutput(_0x1ab8a4){const _0x4a6a77=_0x4693;if(!Array[_0x4a6a77(0x111)](_0x1ab8a4))return _0x1ab8a4;const _0x1ee10f=_0x1ab8a4[_0x4a6a77(0xa5)](_0x49239f=>{const _0x2a73ce=_0x4a6a77;if(typeof _0x49239f===_0x2a73ce(0xfa))return[_0x49239f];if(!isPlainRecord(_0x49239f))return[];if(typeof _0x49239f[_0x2a73ce(0x11c)]===_0x2a73ce(0xfa)){const _0x241b7e=codexVisibleToolText(_0x49239f[_0x2a73ce(0x11c)]);return _0x241b7e[_0x2a73ce(0x113)]>-0x1e2c+0x2da+0x21a*0xd?[_0x241b7e]:[];}if(typeof _0x49239f[_0x2a73ce(0xf5)]===_0x2a73ce(0xfa))return[_0x49239f[_0x2a73ce(0xf5)]];return[];});return _0x1ee10f[_0x4a6a77(0x113)]>-0xb2*0x2c+-0x357+0x21ef?_0x1ee10f[_0x4a6a77(0x107)](''):_0x1ab8a4[_0x4a6a77(0x91)](isCodexImageBlock)?_0x4a6a77(0x9d):_0x1ab8a4;}export function codexVisibleToolText(_0x5eeb31){const _0x15acd5=_0x4693;return _0x5eeb31[_0x15acd5(0xd4)](/(["']image_url["']\s*:\s*["'])data:image\/[^"']+(["'])/g,_0x15acd5(0xb8));}export function isCodexImageBlock(_0x51fc37){const _0x550c4=_0x4693;if(!isPlainRecord(_0x51fc37))return![];return _0x51fc37[_0x550c4(0xd7)]===_0x550c4(0xba)||_0x51fc37[_0x550c4(0xd7)]===_0x550c4(0xc7)||_0x51fc37[_0x550c4(0xd7)]===_0x550c4(0xc5);}import{codexTimestamp,compactRunnerText,compactRunnerValue,boundedConversationItemId,isCanonicalBase64,isPlainRecord,nativePageEnd}from'../../util/node-operation-parsers.js';function _0x4693(_0x3c53d2,_0x2eff4c){_0x3c53d2=_0x3c53d2-(0x3*0x7c9+-0x916+-0xdba);const _0x1429d6=_0x4137();let _0x6986a0=_0x1429d6[_0x3c53d2];if(_0x4693['kxAYQq']===undefined){var _0x1b7763=function(_0x28bf8a){const _0x5e86be='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x220429='',_0x19f900='';for(let _0x45ea09=0xfe*-0xf+-0x3a*0x76+-0x5f2*-0x7,_0x28d354,_0xbd64e,_0x5464f4=-0x19ec*0x1+0x1a95+-0xa9;_0xbd64e=_0x28bf8a['charAt'](_0x5464f4++);~_0xbd64e&&(_0x28d354=_0x45ea09%(0x1443+-0x3*0xd01+0x962*0x2)?_0x28d354*(-0x25db+-0x1720+0x13*0x339)+_0xbd64e:_0xbd64e,_0x45ea09++%(-0x1*0xb08+0x18a9*0x1+0xcd*-0x11))?_0x220429+=String['fromCharCode'](-0x2078*0x1+0x5*-0x341+-0x2*-0x18de&_0x28d354>>(-(0x1212+0x49*-0x25+-0x783)*_0x45ea09&-0x3*0x813+-0x1525+0x2d64)):-0x17ac+0x19*0x47+-0x10bd*-0x1){_0xbd64e=_0x5e86be['indexOf'](_0xbd64e);}for(let _0x17d593=0x3*0xaf3+0x13e*-0x8+-0x16e9,_0x2fdcf1=_0x220429['length'];_0x17d593<_0x2fdcf1;_0x17d593++){_0x19f900+='%'+('00'+_0x220429['charCodeAt'](_0x17d593)['toString'](0x1a1f+0xf65+-0x1c*0x17b))['slice'](-(0x1*-0x30f+-0x1*0x1636+0x2cf*0x9));}return decodeURIComponent(_0x19f900);};_0x4693['VmVuEK']=_0x1b7763,_0x4693['nIFbNE']={},_0x4693['kxAYQq']=!![];}const _0x565020=_0x1429d6[-0x11f+-0x3f3+-0x1*-0x512];_0x4693['afUwNu']!==_0x565020&&(_0x4693['nIFbNE']={},_0x4693['afUwNu']=_0x565020);const _0x354c9e=_0x4693['nIFbNE'][_0x3c53d2];return _0x354c9e===undefined?(_0x6986a0=_0x4693['VmVuEK'](_0x6986a0),_0x4693['nIFbNE'][_0x3c53d2]=_0x6986a0):_0x6986a0=_0x354c9e,_0x6986a0;}export*from'../../util/node-operation-parsers.js';