@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,982 +1,2 @@
1
- import { randomUUID } from 'node:crypto';
2
- /**
3
- * Deliberately process-local runtime domain. No method in this class writes
4
- * into Node SQLite: a Node restart loses active runs, approvals, leases and
5
- * managed-session aliases by design. Durable conversation history belongs to
6
- * the Runner/native transcript, never to MAR.
7
- */
8
- export class NodeRuntimeState {
9
- nodeId;
10
- getWorkspace;
11
- now;
12
- onRunChanged;
13
- static MAX_RUN_EVENTS_PER_RUN = 100;
14
- static MAX_COMPLETED_TURNS_PER_SESSION = 10;
15
- sessions = new Map();
16
- runs = new Map();
17
- messageRuns = new Map();
18
- events = new Map();
19
- turns = new Map();
20
- approvals = new Map();
21
- /** A Session owns at most one running turn; Workspace sessions may run concurrently. */
22
- leases = new Map();
23
- /** Session FIFO metadata is deliberately process-local with the rest of run state. */
24
- queuedRuns = new Map();
25
- queueVersions = new Map();
26
- pausedQueues = new Set();
27
- /** Bounded tombstones reject stale internal start envelopes after terminal cleanup. */
28
- terminalRunIds = new Set();
29
- nextEventId = 1;
30
- constructor(nodeId, getWorkspace, now = Date.now, onRunChanged) {
31
- this.nodeId = nodeId;
32
- this.getWorkspace = getWorkspace;
33
- this.now = now;
34
- this.onRunChanged = onRunChanged;
35
- }
36
- activeWorkspaceLeaseCount() {
37
- return this.leases.size;
38
- }
39
- activeSessionRun(sessionId) {
40
- const runId = this.leases.get(sessionId);
41
- return runId === undefined ? undefined : this.runs.get(runId);
42
- }
43
- hasActiveSessionLease(sessionId) {
44
- return this.leases.has(sessionId);
45
- }
46
- createAgentSession(input) {
47
- if (this.getWorkspace(input.workspaceId) === undefined)
48
- throw new Error('WORKSPACE_NOT_FOUND');
49
- const now = this.now();
50
- const id = input.externalSessionId ?? randomUUID();
51
- if (this.sessions.has(id))
52
- throw new Error('SESSION_ID_CONFLICT');
53
- const value = {
54
- id,
55
- nodeId: this.nodeId(),
56
- workspaceId: input.workspaceId,
57
- runner: input.runner,
58
- externalSessionId: input.externalSessionId ?? null,
59
- nativeControl: input.externalSessionId === undefined ? 'MAR_MANAGED' : (input.nativeControl ?? 'EXTERNAL'),
60
- channelToken: null,
61
- cwd: input.cwd,
62
- model: input.model ?? null,
63
- effort: input.effort ?? null,
64
- access: input.access ?? null,
65
- customTitle: null,
66
- runnerTitle: input.title?.trim().slice(0, 160) || null,
67
- pinnedAt: null,
68
- // A first user prompt is only a process-local temporary title. A
69
- // Runner/native title can replace it on the next discovery refresh.
70
- titleSource: 'AUTO',
71
- lastActivityAt: now,
72
- createdAt: now
73
- };
74
- this.sessions.set(value.id, value);
75
- return value;
76
- }
77
- /** Internal envelope compatibility for a Run already accepted in this process. */
78
- adoptRun(input) {
79
- if (this.terminalRunIds.has(input.runId))
80
- throw new Error('RUN_TERMINAL');
81
- let session = this.sessions.get(input.sessionId);
82
- if (session === undefined) {
83
- const now = this.now();
84
- session = {
85
- id: input.sessionId,
86
- nodeId: this.nodeId(),
87
- workspaceId: input.workspaceId ?? `runtime:${input.cwd}`,
88
- runner: input.runner,
89
- externalSessionId: input.externalSessionId ?? null,
90
- nativeControl: input.externalSessionId === undefined ? 'MAR_MANAGED' : 'EXTERNAL',
91
- channelToken: null,
92
- cwd: input.cwd,
93
- model: null,
94
- effort: null,
95
- access: null,
96
- customTitle: null,
97
- runnerTitle: null,
98
- pinnedAt: null,
99
- titleSource: 'AUTO',
100
- lastActivityAt: now,
101
- createdAt: now
102
- };
103
- this.sessions.set(session.id, session);
104
- }
105
- const existing = this.runs.get(input.runId);
106
- if (existing !== undefined)
107
- return existing;
108
- const now = this.now();
109
- const run = {
110
- id: input.runId,
111
- sessionId: session.id,
112
- nodeId: this.nodeId(),
113
- workspaceId: session.workspaceId,
114
- runner: session.runner,
115
- status: 'QUEUED',
116
- recoveryState: 'ACTIVE',
117
- version: 0,
118
- clientMessageId: input.clientMessageId ?? input.runId,
119
- createdAt: now,
120
- updatedAt: now
121
- };
122
- this.runs.set(run.id, run);
123
- this.leases.set(run.sessionId, run.id);
124
- this.onRunChanged?.(run, session);
125
- return run;
126
- }
127
- getAgentSession(id) {
128
- return (this.sessions.get(id) ??
129
- [...this.sessions.values()].find((value) => value.externalSessionId === id));
130
- }
131
- listAgentSessions() {
132
- return [...this.sessions.values()].sort((a, b) => b.lastActivityAt - a.lastActivityAt);
133
- }
134
- findAgentSessionByExternalSession(runner, externalSessionId) {
135
- return [...this.sessions.values()].find((value) => value.runner === runner && value.externalSessionId === externalSessionId);
136
- }
137
- updateAgentSessionConfiguration(input) {
138
- return this.replaceSession(input.sessionId, {
139
- model: input.model,
140
- effort: input.effort,
141
- access: input.access
142
- });
143
- }
144
- setNativeControl(id, nativeControl) {
145
- this.replaceSession(id, { nativeControl });
146
- }
147
- setExternalSessionId(id, externalSessionId) {
148
- if (externalSessionId.length === 0)
149
- throw new Error('SESSION_EXTERNAL_ID_INVALID');
150
- this.promoteSessionIdentity(id, externalSessionId);
151
- }
152
- /**
153
- * Atomically replaces the bootstrap Session key with the Runner-native ID.
154
- * No caller may migrate the individual runtime maps independently.
155
- */
156
- promoteSessionIdentity(id, nativeSessionId) {
157
- if (nativeSessionId.length === 0)
158
- throw new Error('SESSION_EXTERNAL_ID_INVALID');
159
- const current = this.requireSession(id);
160
- if (id === nativeSessionId)
161
- return this.replaceSession(id, {
162
- externalSessionId: nativeSessionId,
163
- nativeControl: 'MAR_MANAGED'
164
- });
165
- const collision = this.sessions.get(nativeSessionId);
166
- if (collision !== undefined && collision.id !== current.id)
167
- throw new Error('SESSION_ID_CONFLICT');
168
- const next = {
169
- ...current,
170
- id: nativeSessionId,
171
- externalSessionId: nativeSessionId,
172
- nativeControl: 'MAR_MANAGED'
173
- };
174
- const runs = this.listRunsForSession(id);
175
- const turns = this.turns.get(id) ?? [];
176
- const queue = this.queuedRuns.get(id);
177
- const queueVersion = this.queueVersions.get(id);
178
- const lease = this.leases.get(id);
179
- const paused = this.pausedQueues.has(id);
180
- this.sessions.delete(id);
181
- this.sessions.set(nativeSessionId, next);
182
- for (const run of runs)
183
- this.runs.set(run.id, { ...run, sessionId: nativeSessionId });
184
- this.turns.delete(id);
185
- this.turns.set(nativeSessionId, turns.map((turn) => ({
186
- ...turn,
187
- sessionId: nativeSessionId,
188
- items: turn.items.map((item) => ({ ...item, sessionId: nativeSessionId }))
189
- })));
190
- if (queue !== undefined) {
191
- this.queuedRuns.delete(id);
192
- this.queuedRuns.set(nativeSessionId, queue);
193
- }
194
- if (queueVersion !== undefined) {
195
- this.queueVersions.delete(id);
196
- this.queueVersions.set(nativeSessionId, queueVersion);
197
- }
198
- if (lease !== undefined) {
199
- this.leases.delete(id);
200
- this.leases.set(nativeSessionId, lease);
201
- }
202
- if (paused) {
203
- this.pausedQueues.delete(id);
204
- this.pausedQueues.add(nativeSessionId);
205
- }
206
- for (const [key, runId] of [...this.messageRuns]) {
207
- if (!key.startsWith(`${id}\u0000`))
208
- continue;
209
- this.messageRuns.delete(key);
210
- this.messageRuns.set(`${nativeSessionId}${key.slice(id.length)}`, runId);
211
- }
212
- return next;
213
- }
214
- setChannelToken(id, channelToken) {
215
- if (channelToken.length < 16)
216
- throw new Error('SESSION_CHANNEL_TOKEN_INVALID');
217
- this.replaceSession(id, { channelToken });
218
- }
219
- updateSessionMetadata(input) {
220
- const current = this.requireSession(input.sessionId);
221
- const title = input.customTitle === undefined ? current.customTitle : input.customTitle?.trim() || null;
222
- if (title !== null && title.length > 160)
223
- throw new Error('SESSION_TITLE_INVALID');
224
- return this.replaceSession(current.id, {
225
- customTitle: title,
226
- pinnedAt: input.pinned === undefined ? current.pinnedAt : input.pinned ? this.now() : null,
227
- titleSource: title === null ? 'AUTO' : 'CUSTOM'
228
- });
229
- }
230
- /**
231
- * Give a just-created managed Session a readable local title before the
232
- * Runner has written its own transcript title. This intentionally never
233
- * replaces a user rename or a Runner-provided title.
234
- */
235
- setTemporaryTitleIfMissing(id, title) {
236
- const current = this.requireSession(id);
237
- const value = title.trim().replace(/\s+/g, ' ').slice(0, 160);
238
- if (value.length === 0 || current.customTitle !== null || current.runnerTitle !== null)
239
- return current;
240
- return this.replaceSession(id, { runnerTitle: value, titleSource: 'AUTO' });
241
- }
242
- /**
243
- * Runner/native discovery is authoritative for its own title. Keep it on
244
- * the managed Session so later `session.get` polls cannot regress to an
245
- * empty fallback after a discovery response has already shown the title.
246
- */
247
- setRunnerTitleFromNative(id, title) {
248
- const current = this.requireSession(id);
249
- const value = title.trim().replace(/\s+/g, ' ').slice(0, 160);
250
- if (value.length === 0 || current.customTitle !== null || current.runnerTitle === value)
251
- return current;
252
- return this.replaceSession(id, { runnerTitle: value, titleSource: 'RUNNER' });
253
- }
254
- createMessageRun(input) {
255
- const key = `${input.sessionId}\u0000${input.clientMessageId}`;
256
- const duplicate = this.messageRuns.get(key);
257
- if (duplicate !== undefined)
258
- return { run: this.requireRun(duplicate), created: false };
259
- const session = this.requireSession(input.sessionId);
260
- const now = this.now();
261
- const run = {
262
- id: input.runId ?? randomUUID(),
263
- sessionId: session.id,
264
- nodeId: this.nodeId(),
265
- workspaceId: session.workspaceId,
266
- runner: session.runner,
267
- status: 'QUEUED',
268
- recoveryState: 'ACTIVE',
269
- version: 0,
270
- clientMessageId: input.clientMessageId,
271
- ...(input.initiatedByUserId === undefined
272
- ? {}
273
- : { initiatedByUserId: input.initiatedByUserId }),
274
- createdAt: now,
275
- updatedAt: now
276
- };
277
- let imageIndex = 0;
278
- const attachments = (input.attachments ?? []).map(({ name, mime, dataBase64 }) => {
279
- const attachment = {
280
- name,
281
- mime,
282
- byteSize: Buffer.byteLength(dataBase64, 'base64'),
283
- runId: run.id
284
- };
285
- if (!mime.startsWith('image/'))
286
- return attachment;
287
- return { ...attachment, imageIndex: imageIndex++ };
288
- });
289
- const user = {
290
- id: randomUUID(),
291
- sessionId: session.id,
292
- turnId: '',
293
- runId: run.id,
294
- parentItemId: null,
295
- sourceSequence: null,
296
- revision: 0,
297
- kind: 'user_message',
298
- status: 'COMPLETED',
299
- payload: {
300
- clientMessageId: input.clientMessageId,
301
- text: input.content,
302
- contexts: [],
303
- attachments,
304
- delivery: 'ACCEPTED'
305
- },
306
- startedAt: now,
307
- completedAt: now
308
- };
309
- const turn = {
310
- id: randomUUID(),
311
- sessionId: session.id,
312
- runId: run.id,
313
- userItemId: user.id,
314
- status: 'QUEUED',
315
- model: session.model,
316
- effort: session.effort,
317
- access: session.access,
318
- items: [user],
319
- startedAt: null,
320
- completedAt: null
321
- };
322
- const fixedTurn = { ...turn, items: [{ ...user, turnId: turn.id }] };
323
- this.runs.set(run.id, run);
324
- this.messageRuns.set(key, run.id);
325
- this.queuedRuns.set(session.id, [...(this.queuedRuns.get(session.id) ?? []), run.id]);
326
- this.bumpQueueVersion(session.id);
327
- this.turns.set(session.id, [...(this.turns.get(session.id) ?? []), fixedTurn]);
328
- this.replaceSession(session.id, { lastActivityAt: now });
329
- this.onRunChanged?.(run, this.requireSession(session.id));
330
- return { run, created: true };
331
- }
332
- sessionQueue(sessionId) {
333
- return {
334
- version: this.queueVersions.get(sessionId) ?? 0,
335
- paused: this.pausedQueues.has(sessionId),
336
- runIds: this.queuedRuns.get(sessionId) ?? []
337
- };
338
- }
339
- isQueuedRun(runId) {
340
- const run = this.requireRun(runId);
341
- return (this.queuedRuns.get(run.sessionId) ?? []).includes(runId);
342
- }
343
- claimNextQueuedRun(sessionId) {
344
- if (this.leases.has(sessionId) || this.pausedQueues.has(sessionId))
345
- return undefined;
346
- const queue = this.queuedRuns.get(sessionId) ?? [];
347
- const runId = queue[0];
348
- if (runId === undefined)
349
- return undefined;
350
- this.queuedRuns.set(sessionId, queue.slice(1));
351
- this.bumpQueueVersion(sessionId);
352
- const run = this.requireRun(runId);
353
- this.leases.set(sessionId, run.id);
354
- return run;
355
- }
356
- pauseSessionQueue(sessionId) {
357
- this.pausedQueues.add(sessionId);
358
- this.bumpQueueVersion(sessionId);
359
- }
360
- resumeSessionQueue(sessionId) {
361
- if (!this.pausedQueues.delete(sessionId))
362
- return;
363
- this.bumpQueueVersion(sessionId);
364
- }
365
- reorderSessionQueue(sessionId, expectedVersion, runIds) {
366
- const current = this.queuedRuns.get(sessionId) ?? [];
367
- if (this.sessionQueue(sessionId).version !== expectedVersion ||
368
- current.length !== runIds.length ||
369
- new Set(current).size !== current.length ||
370
- current.some((runId) => !runIds.includes(runId)))
371
- throw new Error('QUEUE_VERSION_CONFLICT');
372
- if (runIds.some((runId) => this.requireRun(runId).status !== 'QUEUED'))
373
- throw new Error('QUEUE_ITEM_INVALID');
374
- this.queuedRuns.set(sessionId, [...runIds]);
375
- this.bumpQueueVersion(sessionId);
376
- }
377
- prioritizeQueuedRun(runId) {
378
- const run = this.requireRun(runId);
379
- const queue = this.queuedRuns.get(run.sessionId) ?? [];
380
- if (!queue.includes(runId) || run.status !== 'QUEUED')
381
- throw new Error('QUEUE_ITEM_INVALID');
382
- this.queuedRuns.set(run.sessionId, [
383
- runId,
384
- ...queue.filter((candidate) => candidate !== runId)
385
- ]);
386
- this.bumpQueueVersion(run.sessionId);
387
- return run;
388
- }
389
- updateQueuedMessage(runId, content) {
390
- const run = this.requireRun(runId);
391
- if (!(this.queuedRuns.get(run.sessionId) ?? []).includes(runId) || run.status !== 'QUEUED')
392
- throw new Error('QUEUE_ITEM_INVALID');
393
- this.updateTurnForRun(runId, (turn) => ({
394
- ...turn,
395
- items: turn.items.map((item) => item.id === turn.userItemId && isRecord(item.payload)
396
- ? { ...item, payload: { ...item.payload, text: content } }
397
- : item)
398
- }));
399
- this.bumpQueueVersion(run.sessionId);
400
- return run;
401
- }
402
- deleteQueuedRun(runId) {
403
- const run = this.requireRun(runId);
404
- const queue = this.queuedRuns.get(run.sessionId) ?? [];
405
- if (!queue.includes(runId) || run.status !== 'QUEUED')
406
- throw new Error('QUEUE_ITEM_INVALID');
407
- this.queuedRuns.set(run.sessionId, queue.filter((candidate) => candidate !== runId));
408
- this.bumpQueueVersion(run.sessionId);
409
- this.runs.delete(runId);
410
- this.events.delete(runId);
411
- this.turns.set(run.sessionId, (this.turns.get(run.sessionId) ?? []).filter((turn) => turn.runId !== runId));
412
- for (const [key, candidate] of this.messageRuns)
413
- if (candidate === runId)
414
- this.messageRuns.delete(key);
415
- }
416
- queuedMessageText(runId) {
417
- const run = this.requireRun(runId);
418
- const turn = (this.turns.get(run.sessionId) ?? []).find((candidate) => candidate.runId === runId);
419
- const item = turn?.items.find((candidate) => candidate.id === turn.userItemId);
420
- return isRecord(item?.payload) && typeof item.payload.text === 'string'
421
- ? item.payload.text
422
- : '';
423
- }
424
- getRun(id) {
425
- return this.runs.get(id);
426
- }
427
- findMessageRun(sessionId, clientMessageId) {
428
- const runId = this.messageRuns.get(`${sessionId}\u0000${clientMessageId}`);
429
- return runId === undefined ? undefined : this.runs.get(runId);
430
- }
431
- listRunsForSession(sessionId) {
432
- return [...this.runs.values()]
433
- .filter((run) => run.sessionId === sessionId)
434
- .sort((a, b) => b.createdAt - a.createdAt);
435
- }
436
- transitionRun(id, next) {
437
- const current = this.requireRun(id);
438
- if (!transitionAllowed(current.status, next))
439
- throw new Error('RUN_STATE_INVALID');
440
- const value = { ...current, status: next, version: current.version + 1, updatedAt: this.now() };
441
- this.runs.set(id, value);
442
- this.onRunChanged?.(value, this.requireSession(value.sessionId));
443
- if (terminal(next) && this.leases.get(value.sessionId) === value.id)
444
- this.leases.delete(value.sessionId);
445
- this.updateTurnForRun(id, (turn) => ({
446
- ...turn,
447
- status: next,
448
- completedAt: terminal(next) ? this.now() : turn.completedAt,
449
- items: terminal(next)
450
- ? turn.items.map((item) => activeConversationItem(item.status)
451
- ? { ...item, status: completedStatusForRun(next), completedAt: this.now() }
452
- : item)
453
- : turn.items
454
- }));
455
- return value;
456
- }
457
- appendRunEvent(input) {
458
- this.requireRun(input.runId);
459
- const prior = this.events.get(input.runId) ?? [];
460
- if (prior.some((event) => event.sequence === input.sequence))
461
- return undefined;
462
- if (input.sequence > (prior.at(-1)?.sequence ?? 0) + 1)
463
- throw new Error('EVENT_SEQUENCE_GAP');
464
- const value = {
465
- id: this.nextEventId++,
466
- runId: input.runId,
467
- sequence: input.sequence,
468
- eventType: input.eventType,
469
- payload: input.payload,
470
- ...(input.status === undefined ? {} : { status: input.status }),
471
- createdAt: this.now()
472
- };
473
- this.events.set(input.runId, [...prior, value].slice(-NodeRuntimeState.MAX_RUN_EVENTS_PER_RUN));
474
- if (input.status !== undefined)
475
- this.transitionRun(input.runId, input.status);
476
- this.projectEvent(value);
477
- return value;
478
- }
479
- listRunEvents(id, after = 0) {
480
- return (this.events.get(id) ?? []).filter((event) => event.sequence > after);
481
- }
482
- listConversationTurns(input) {
483
- this.requireSession(input.sessionId);
484
- // A managed Turn keeps the user's acceptance time as its stable timeline
485
- // position. Runner start/completion timestamps must not move it behind a
486
- // message that was accepted later. Native Turns without a user timestamp
487
- // fall back to their own lifecycle time.
488
- const all = [...(this.turns.get(input.sessionId) ?? [])]
489
- .map((turn, index) => ({ turn, index }))
490
- .sort((a, b) => {
491
- const timestamp = (value) => value.items.find((item) => item.id === value.userItemId)?.startedAt ??
492
- value.startedAt ??
493
- value.completedAt ??
494
- 0;
495
- return timestamp(a.turn) - timestamp(b.turn) || a.index - b.index;
496
- })
497
- .map(({ turn }) => turn);
498
- const end = input.cursor === undefined ? all.length : decodeCursor(input.cursor, input.sessionId);
499
- const limit = Math.min(Math.max(input.limit ?? 30, 1), 500);
500
- const start = Math.max(0, end - limit);
501
- const slice = all.slice(start, end);
502
- return {
503
- turns: slice,
504
- nextCursor: start > 0 ? encodeCursor(input.sessionId, start) : null
505
- };
506
- }
507
- conversationTurnForRun(runId) {
508
- for (const turns of this.turns.values()) {
509
- const turn = turns.find((candidate) => candidate.runId === runId);
510
- if (turn !== undefined)
511
- return turn;
512
- }
513
- return undefined;
514
- }
515
- listConversationItems(input) {
516
- const turns = this.listConversationTurns(input).turns;
517
- return { items: turns.flatMap((turn) => turn.items), nextCursor: null };
518
- }
519
- recordCommandExecution(input) {
520
- const session = this.requireSession(input.sessionId);
521
- const now = this.now();
522
- const item = {
523
- id: randomUUID(),
524
- sessionId: input.sessionId,
525
- turnId: '',
526
- runId: null,
527
- parentItemId: null,
528
- sourceSequence: null,
529
- revision: 1,
530
- kind: 'command_execution',
531
- status: input.failed ? 'FAILED' : 'COMPLETED',
532
- payload: {
533
- command: input.command,
534
- cwd: input.cwd,
535
- outputPreview: input.outputPreview.slice(0, 10_000),
536
- outputRef: null,
537
- exitCode: input.failed ? 1 : 0,
538
- durationMs: 0,
539
- truncated: false
540
- },
541
- startedAt: now,
542
- completedAt: now
543
- };
544
- const turn = {
545
- id: randomUUID(),
546
- sessionId: input.sessionId,
547
- runId: null,
548
- userItemId: null,
549
- status: input.failed ? 'FAILED' : 'SUCCEEDED',
550
- model: session.model,
551
- effort: session.effort,
552
- access: session.access,
553
- items: [],
554
- startedAt: now,
555
- completedAt: now
556
- };
557
- const completedItem = { ...item, turnId: turn.id };
558
- const completedTurn = { ...turn, items: [completedItem] };
559
- this.turns.set(input.sessionId, [...(this.turns.get(input.sessionId) ?? []), completedTurn]);
560
- this.replaceSession(session.id, { lastActivityAt: now });
561
- return completedTurn;
562
- }
563
- createApproval(input) {
564
- this.requireRun(input.runId);
565
- if (this.approvals.has(input.approvalId))
566
- throw new Error('APPROVAL_ALREADY_EXISTS');
567
- if (input.expiresAt <= this.now())
568
- throw new Error('APPROVAL_EXPIRED');
569
- const value = {
570
- id: input.approvalId,
571
- runId: input.runId,
572
- status: 'PENDING',
573
- payload: input.payload,
574
- expiresAt: input.expiresAt,
575
- createdAt: this.now(),
576
- decidedAt: null
577
- };
578
- this.approvals.set(value.id, value);
579
- return value;
580
- }
581
- getApproval(id) {
582
- const value = this.approvals.get(id);
583
- if (value?.status === 'PENDING' && value.expiresAt <= this.now())
584
- return this.expireApproval(id);
585
- return value;
586
- }
587
- listApprovals(runId) {
588
- return [...this.approvals.values()]
589
- .filter((value) => value.runId === runId)
590
- .map((value) => this.getApproval(value.id));
591
- }
592
- expireApproval(id) {
593
- const value = this.requireApproval(id);
594
- if (value.status !== 'PENDING')
595
- return value;
596
- if (value.expiresAt > this.now())
597
- throw new Error('APPROVAL_NOT_EXPIRED');
598
- const next = { ...value, status: 'EXPIRED', decidedAt: this.now() };
599
- this.approvals.set(id, next);
600
- return next;
601
- }
602
- decideApproval(id, decision) {
603
- const value = this.getApproval(id);
604
- if (value === undefined)
605
- throw new Error('APPROVAL_NOT_FOUND');
606
- if (value.status === 'EXPIRED')
607
- throw new Error('APPROVAL_EXPIRED');
608
- if (value.status !== 'PENDING')
609
- throw new Error('APPROVAL_ALREADY_DECIDED');
610
- const next = { ...value, status: decision, decidedAt: this.now() };
611
- this.approvals.set(id, next);
612
- return next;
613
- }
614
- expireDueApprovals() {
615
- return [...this.approvals.values()]
616
- .filter((value) => value.status === 'PENDING' && value.expiresAt <= this.now())
617
- .map((value) => this.expireApproval(value.id));
618
- }
619
- listNonterminalRuns() {
620
- return [...this.runs.values()].filter((run) => !terminal(run.status));
621
- }
622
- lastRunSequence(id) {
623
- return this.events.get(id)?.at(-1)?.sequence ?? 0;
624
- }
625
- removeTerminalRun(runId) {
626
- const run = this.requireRun(runId);
627
- if (!terminal(run.status))
628
- throw new Error('RUN_ACTIVE');
629
- this.terminalRunIds.add(runId);
630
- if (this.terminalRunIds.size > 1_024)
631
- this.terminalRunIds.delete(this.terminalRunIds.values().next().value);
632
- const queue = this.queuedRuns.get(run.sessionId) ?? [];
633
- if (queue.includes(runId)) {
634
- this.queuedRuns.set(run.sessionId, queue.filter((candidate) => candidate !== runId));
635
- this.bumpQueueVersion(run.sessionId);
636
- }
637
- this.runs.delete(runId);
638
- this.events.delete(runId);
639
- const turns = (this.turns.get(run.sessionId) ?? []).filter((turn) => {
640
- const hasVisibleError = turn.items.some((item) => item.kind === 'error');
641
- if (turn.runId === runId)
642
- return run.status === 'SUCCEEDED' || run.status === 'INTERRUPTED' || hasVisibleError;
643
- const isTransientErrorTurn = hasVisibleError && turn.status !== 'SUCCEEDED' && turn.status !== 'INTERRUPTED';
644
- return run.status !== 'SUCCEEDED' || !isTransientErrorTurn;
645
- });
646
- const completed = turns.filter((turn) => terminalTurn(turn.status));
647
- const retainedCompleted = new Set(completed.slice(-NodeRuntimeState.MAX_COMPLETED_TURNS_PER_SESSION).map((turn) => turn.id));
648
- this.turns.set(run.sessionId, turns.filter((turn) => !terminalTurn(turn.status) || retainedCompleted.has(turn.id)));
649
- for (const [key, candidate] of this.messageRuns)
650
- if (candidate === runId)
651
- this.messageRuns.delete(key);
652
- for (const [approvalId, approval] of this.approvals)
653
- if (approval.runId === runId)
654
- this.approvals.delete(approvalId);
655
- }
656
- hasActiveWorkspaceLease(workspaceId) {
657
- return [...this.leases.values()]
658
- .map((runId) => this.runs.get(runId))
659
- .some((run) => run?.workspaceId === workspaceId);
660
- }
661
- /** Removes a terminal Session's process-local projection after its native history is deleted. */
662
- removeAgentSession(sessionId) {
663
- this.requireSession(sessionId);
664
- const runs = this.listRunsForSession(sessionId);
665
- if (runs.some((run) => !terminal(run.status)))
666
- throw new Error('SESSION_ACTIVE');
667
- const runIds = new Set(runs.map((run) => run.id));
668
- this.sessions.delete(sessionId);
669
- this.turns.delete(sessionId);
670
- this.queuedRuns.delete(sessionId);
671
- this.queueVersions.delete(sessionId);
672
- this.pausedQueues.delete(sessionId);
673
- this.leases.delete(sessionId);
674
- for (const runId of runIds) {
675
- this.runs.delete(runId);
676
- this.events.delete(runId);
677
- }
678
- for (const [key, runId] of this.messageRuns)
679
- if (runIds.has(runId))
680
- this.messageRuns.delete(key);
681
- for (const [approvalId, approval] of this.approvals)
682
- if (runIds.has(approval.runId))
683
- this.approvals.delete(approvalId);
684
- }
685
- removeWorkspace(workspaceId) {
686
- if (this.hasActiveWorkspaceLease(workspaceId))
687
- throw new Error('WORKSPACE_BUSY');
688
- const sessionIds = new Set([...this.sessions.values()]
689
- .filter((session) => session.workspaceId === workspaceId)
690
- .map((session) => session.id));
691
- const runIds = new Set([...this.runs.values()].filter((run) => run.workspaceId === workspaceId).map((run) => run.id));
692
- for (const sessionId of sessionIds) {
693
- this.sessions.delete(sessionId);
694
- this.turns.delete(sessionId);
695
- }
696
- for (const runId of runIds) {
697
- this.runs.delete(runId);
698
- this.events.delete(runId);
699
- }
700
- for (const [key, runId] of this.messageRuns)
701
- if (runIds.has(runId))
702
- this.messageRuns.delete(key);
703
- for (const [approvalId, approval] of this.approvals)
704
- if (runIds.has(approval.runId))
705
- this.approvals.delete(approvalId);
706
- for (const sessionId of sessionIds) {
707
- this.queuedRuns.delete(sessionId);
708
- this.queueVersions.delete(sessionId);
709
- this.pausedQueues.delete(sessionId);
710
- this.leases.delete(sessionId);
711
- }
712
- }
713
- reconcileRun(id, active) {
714
- // There is no cross-restart run recovery: this process-local state is
715
- // discarded on restart and cannot be reconciled from SQLite.
716
- void id;
717
- void active;
718
- }
719
- replaceSession(id, patch) {
720
- const value = this.requireSession(id);
721
- const next = { ...value, ...patch };
722
- this.sessions.set(id, next);
723
- if (value.customTitle !== next.customTitle || value.runnerTitle !== next.runnerTitle)
724
- for (const run of this.listRunsForSession(id))
725
- this.onRunChanged?.(run, next);
726
- return next;
727
- }
728
- bumpQueueVersion(sessionId) {
729
- this.queueVersions.set(sessionId, (this.queueVersions.get(sessionId) ?? 0) + 1);
730
- }
731
- requireSession(id) {
732
- const value = this.sessions.get(id);
733
- if (value === undefined)
734
- throw new Error('SESSION_NOT_FOUND');
735
- return value;
736
- }
737
- requireRun(id) {
738
- const value = this.runs.get(id);
739
- if (value === undefined)
740
- throw new Error('RUN_NOT_FOUND');
741
- return value;
742
- }
743
- requireApproval(id) {
744
- const value = this.approvals.get(id);
745
- if (value === undefined)
746
- throw new Error('APPROVAL_NOT_FOUND');
747
- return value;
748
- }
749
- updateTurnForRun(runId, update) {
750
- const run = this.requireRun(runId);
751
- const current = this.turns.get(run.sessionId) ?? [];
752
- this.turns.set(run.sessionId, current.map((turn) => (turn.runId === runId ? update(turn) : turn)));
753
- }
754
- projectEvent(event) {
755
- const run = this.requireRun(event.runId);
756
- this.updateTurnForRun(event.runId, (turn) => {
757
- if (event.eventType === 'text.delta' &&
758
- isRecord(event.payload) &&
759
- typeof event.payload.text === 'string') {
760
- const nativeItemId = typeof event.payload.itemId === 'string' && event.payload.itemId.length <= 88
761
- ? event.payload.itemId
762
- : undefined;
763
- const stableItemId = nativeItemId === undefined ? undefined : `${event.runId}:${nativeItemId}`;
764
- const lastItem = turn.items.at(-1);
765
- const existing = stableItemId === undefined
766
- ? lastItem?.kind === 'assistant_message' && activeConversationItem(lastItem.status)
767
- ? lastItem
768
- : undefined
769
- : turn.items.find((item) => item.id === stableItemId && item.kind === 'assistant_message');
770
- const text = `${existing === undefined ? '' : readableText(existing.payload)}${event.payload.text}`;
771
- const item = {
772
- id: existing?.id ?? stableItemId ?? `${event.runId}:assistant:${event.sequence}`,
773
- sessionId: run.sessionId,
774
- turnId: turn.id,
775
- runId: event.runId,
776
- parentItemId: null,
777
- sourceSequence: existing?.sourceSequence ?? event.sequence,
778
- revision: event.sequence,
779
- kind: 'assistant_message',
780
- status: 'IN_PROGRESS',
781
- payload: { text, format: 'markdown', model: null },
782
- startedAt: existing?.startedAt ?? event.createdAt,
783
- completedAt: null
784
- };
785
- return {
786
- ...turn,
787
- status: 'RUNNING',
788
- startedAt: turn.startedAt ?? event.createdAt,
789
- items: existing === undefined
790
- ? [...turn.items, item]
791
- : turn.items.map((value) => (value.id === item.id ? item : value))
792
- };
793
- }
794
- const projected = conversationItemFromEvent(event);
795
- if (projected !== undefined) {
796
- const trailingItem = turn.items.at(-1);
797
- const orderedItems = trailingItem?.kind === 'assistant_message' && activeConversationItem(trailingItem.status)
798
- ? turn.items.map((item) => item.id === trailingItem.id
799
- ? { ...item, status: 'COMPLETED', completedAt: event.createdAt }
800
- : item)
801
- : turn.items;
802
- const existing = orderedItems.find((item) => item.id === `${event.runId}:${projected.itemId}`);
803
- const status = projected.status;
804
- const item = {
805
- id: `${event.runId}:${projected.itemId}`,
806
- sessionId: run.sessionId,
807
- turnId: turn.id,
808
- runId: event.runId,
809
- parentItemId: null,
810
- sourceSequence: existing?.sourceSequence ?? event.sequence,
811
- revision: (existing?.revision ?? -1) + 1,
812
- kind: projected.kind,
813
- status,
814
- payload: mergeConversationItemPayload(existing?.payload, projected),
815
- startedAt: existing?.startedAt ?? event.createdAt,
816
- completedAt: completedConversationItem(status) ? event.createdAt : null
817
- };
818
- return {
819
- ...turn,
820
- status: terminal(run.status) ? run.status : 'RUNNING',
821
- startedAt: turn.startedAt ?? event.createdAt,
822
- items: existing === undefined
823
- ? [...orderedItems, item]
824
- : orderedItems.map((value) => (value.id === item.id ? item : value))
825
- };
826
- }
827
- if (event.eventType === 'run.started' || event.eventType === 'run.running')
828
- return { ...turn, status: 'RUNNING', startedAt: turn.startedAt ?? event.createdAt };
829
- if (event.eventType === 'run.completed' ||
830
- event.eventType === 'run.failed' ||
831
- event.eventType === 'run.rejected') {
832
- return {
833
- ...turn,
834
- status: this.requireRun(event.runId).status,
835
- completedAt: event.createdAt,
836
- items: turn.items.map((item) => activeConversationItem(item.status)
837
- ? {
838
- ...item,
839
- status: completedStatusForRun(this.requireRun(event.runId).status),
840
- completedAt: event.createdAt
841
- }
842
- : item)
843
- };
844
- }
845
- return turn;
846
- });
847
- }
848
- }
849
- function terminal(status) {
850
- return ['SUCCEEDED', 'FAILED', 'CANCELLED', 'INTERRUPTED', 'LOST'].includes(status);
851
- }
852
- function terminalTurn(status) {
853
- return ['SUCCEEDED', 'FAILED', 'CANCELLED', 'INTERRUPTED', 'LOST'].includes(status);
854
- }
855
- function transitionAllowed(from, to) {
856
- return !terminal(from) || from === to;
857
- }
858
- function isRecord(value) {
859
- return typeof value === 'object' && value !== null;
860
- }
861
- function readableText(value) {
862
- return isRecord(value) && typeof value.text === 'string' ? value.text : '';
863
- }
864
- function conversationItemFromEvent(event) {
865
- if (event.eventType !== 'conversation.item' || !isRecord(event.payload))
866
- return undefined;
867
- const itemId = event.payload.itemId;
868
- const kind = event.payload.kind;
869
- const status = event.payload.status;
870
- const payload = event.payload.payload;
871
- if (typeof itemId !== 'string' ||
872
- itemId.length === 0 ||
873
- itemId.length > 88 ||
874
- typeof kind !== 'string' ||
875
- !projectableConversationKind(kind) ||
876
- typeof status !== 'string' ||
877
- !projectableConversationStatus(status) ||
878
- !isRecord(payload))
879
- return undefined;
880
- const append = event.payload.append;
881
- return {
882
- itemId,
883
- kind,
884
- status,
885
- payload,
886
- merge: event.payload.merge === true,
887
- ...(append === 'sections' || append === 'outputPreview' || append === 'outputSummary'
888
- ? { append }
889
- : {})
890
- };
891
- }
892
- function projectableConversationKind(value) {
893
- return (value === 'assistant_message' ||
894
- value === 'reasoning_summary' ||
895
- value === 'tool_call' ||
896
- value === 'command_execution' ||
897
- value === 'user_input_request' ||
898
- value === 'plan' ||
899
- value === 'file_change' ||
900
- value === 'context_compaction' ||
901
- value === 'unknown' ||
902
- value === 'warning' ||
903
- value === 'error');
904
- }
905
- function projectableConversationStatus(value) {
906
- return [
907
- 'PENDING',
908
- 'IN_PROGRESS',
909
- 'COMPLETED',
910
- 'FAILED',
911
- 'DECLINED',
912
- 'CANCELLED',
913
- 'INTERRUPTED'
914
- ].includes(value);
915
- }
916
- function mergeConversationItemPayload(existing, next) {
917
- const base = next.merge && isRecord(existing) ? existing : {};
918
- const value = { ...base, ...next.payload };
919
- if (next.append === 'sections') {
920
- const prior = Array.isArray(base.sections) ? base.sections : [];
921
- const incoming = Array.isArray(next.payload.sections) ? next.payload.sections : [];
922
- const sections = new Map();
923
- for (const section of [...prior, ...incoming]) {
924
- if (!isRecord(section) ||
925
- typeof section.index !== 'number' ||
926
- !Number.isInteger(section.index) ||
927
- section.index < 0 ||
928
- typeof section.text !== 'string')
929
- continue;
930
- sections.set(section.index, appendProjectionText(sections.get(section.index) ?? '', section.text));
931
- }
932
- value.sections = [...sections]
933
- .sort(([left], [right]) => left - right)
934
- .map(([index, text]) => ({ index, text }));
935
- }
936
- if (next.append === 'outputPreview') {
937
- const prior = typeof base.outputPreview === 'string' ? base.outputPreview : '';
938
- const incoming = typeof next.payload.outputPreview === 'string' ? next.payload.outputPreview : '';
939
- value.outputPreview = appendProjectionText(prior, incoming);
940
- }
941
- if (next.append === 'outputSummary') {
942
- const prior = typeof base.outputSummary === 'string' ? base.outputSummary : '';
943
- const incoming = typeof next.payload.outputSummary === 'string' ? next.payload.outputSummary : '';
944
- value.outputSummary = appendProjectionText(prior, incoming);
945
- }
946
- return value;
947
- }
948
- function appendProjectionText(previous, next) {
949
- const text = `${previous}${next}`;
950
- return text.length <= 10_000 ? text : `${text.slice(0, 9_999)}…`;
951
- }
952
- function activeConversationItem(status) {
953
- return status === 'PENDING' || status === 'IN_PROGRESS';
954
- }
955
- function completedConversationItem(status) {
956
- return !activeConversationItem(status);
957
- }
958
- function completedStatusForRun(status) {
959
- if (status === 'INTERRUPTED')
960
- return 'INTERRUPTED';
961
- if (status === 'CANCELLED')
962
- return 'CANCELLED';
963
- if (status === 'FAILED')
964
- return 'FAILED';
965
- return 'COMPLETED';
966
- }
967
- function encodeCursor(scope, value) {
968
- return Buffer.from(JSON.stringify({ scope, value })).toString('base64url');
969
- }
970
- function decodeCursor(cursor, scope) {
971
- if (cursor === undefined)
972
- return 0;
973
- try {
974
- const value = JSON.parse(Buffer.from(cursor, 'base64url').toString('utf8'));
975
- return value.scope === scope && Number.isInteger(value.value) && value.value >= 0
976
- ? value.value
977
- : 0;
978
- }
979
- catch {
980
- return 0;
981
- }
982
- }
1
+ /* mar-release-protected */
2
+ function _0x1a18(_0x4508c3,_0x53e948){_0x4508c3=_0x4508c3-(-0x33*-0x63+0x236e+-0x36c1);const _0x4366ef=_0x589c();let _0x1f6862=_0x4366ef[_0x4508c3];if(_0x1a18['AyzwNZ']===undefined){var _0x2af0e3=function(_0x37b053){const _0x13f1e4='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x205ac3='',_0x469a4a='';for(let _0x51bcff=0x2151+-0x2*0x455+0x18a7*-0x1,_0x56dcae,_0x4231b1,_0x471c48=-0x125*0x1b+0xd90+0x1157;_0x4231b1=_0x37b053['charAt'](_0x471c48++);~_0x4231b1&&(_0x56dcae=_0x51bcff%(-0x1*0x971+-0x1*0xa67+0x1*0x13dc)?_0x56dcae*(0x986+-0xffc+0x6b6)+_0x4231b1:_0x4231b1,_0x51bcff++%(-0xcdf+0x1f95+0x2*-0x959))?_0x205ac3+=String['fromCharCode'](-0x2615*-0x1+0xd2f*0x2+-0xfdd*0x4&_0x56dcae>>(-(0x2601+-0x1227+-0x3f8*0x5)*_0x51bcff&0x1df9*-0x1+0x156a+0x895)):-0x3a*0x6a+-0x2657+0x3e5b){_0x4231b1=_0x13f1e4['indexOf'](_0x4231b1);}for(let _0x4e95ca=-0x1a3*-0x1+-0x76e*0x5+0x2383,_0x1c883c=_0x205ac3['length'];_0x4e95ca<_0x1c883c;_0x4e95ca++){_0x469a4a+='%'+('00'+_0x205ac3['charCodeAt'](_0x4e95ca)['toString'](-0x1ede+-0x657*0x6+0x44f8))['slice'](-(0x11fc+0x224+0x2*-0xa0f));}return decodeURIComponent(_0x469a4a);};_0x1a18['uTGgDx']=_0x2af0e3,_0x1a18['wUqQXM']={},_0x1a18['AyzwNZ']=!![];}const _0x4d82df=_0x4366ef[0x40d*0x1+-0x5cc+0x1bf];_0x1a18['otRQod']!==_0x4d82df&&(_0x1a18['wUqQXM']={},_0x1a18['otRQod']=_0x4d82df);const _0x359e4f=_0x1a18['wUqQXM'][_0x4508c3];return _0x359e4f===undefined?(_0x1f6862=_0x1a18['uTGgDx'](_0x1f6862),_0x1a18['wUqQXM'][_0x4508c3]=_0x1f6862):_0x1f6862=_0x359e4f,_0x1f6862;}const _0x561507=_0x1a18;(function(_0x2ae54a,_0x3c6d01){const _0x415901=_0x1a18,_0x41ff4d=_0x2ae54a();while(!![]){try{const _0x4691ce=-parseInt(_0x415901(0xa8))/(0x18e0*-0x1+0x41e+0x14c3)*(parseInt(_0x415901(0x95))/(0x1713+0x7cb+0x4*-0x7b7))+parseInt(_0x415901(0xce))/(-0x1b*-0xc+-0xf1a+0xdd9)*(-parseInt(_0x415901(0x137))/(-0xab*-0x1f+0x29*-0x79+-0x150))+parseInt(_0x415901(0x123))/(-0xd8d*0x1+0x443*0x3+0x43*0x3)*(-parseInt(_0x415901(0xb5))/(0x206b+0xd*0x25+-0x2246))+-parseInt(_0x415901(0xbf))/(0x2e*-0x49+-0xc6f+-0x1994*-0x1)*(parseInt(_0x415901(0xa7))/(0x2*-0x241+-0x2135*-0x1+-0x1cab))+parseInt(_0x415901(0x127))/(0x1b7*0x4+0x78e*0x5+-0xe9*0x31)*(-parseInt(_0x415901(0xb2))/(0x2466*0x1+0x5*0x45d+-0x3a2d))+-parseInt(_0x415901(0x89))/(0x37a*-0x3+0x39b+-0x24a*-0x3)*(-parseInt(_0x415901(0xbb))/(0x371*0x1+-0x267*-0xc+-0x2039))+parseInt(_0x415901(0x96))/(0x42b*0x1+0x1065+-0x1*0x1483);if(_0x4691ce===_0x3c6d01)break;else _0x41ff4d['push'](_0x41ff4d['shift']());}catch(_0x40f555){_0x41ff4d['push'](_0x41ff4d['shift']());}}}(_0x589c,0xa93*-0x5d+-0x30d1*0xf+-0x5*-0x1d581));import{randomUUID}from'node:crypto';export class NodeRuntimeState{[_0x561507(0x14b)];[_0x561507(0xec)];[_0x561507(0x109)];[_0x561507(0x13c)];static [_0x561507(0xbc)]=-0x12d6*0x1+0x46b*0x7+-0xc0d;[_0x561507(0x102)]=new Map();[_0x561507(0xe6)]=new Map();[_0x561507(0xed)]=new Map();[_0x561507(0xb7)]=new Map();[_0x561507(0xe2)]=new Map();[_0x561507(0xc8)]=new Map();[_0x561507(0x82)]=new Map();[_0x561507(0xf9)]=new Map();[_0x561507(0x121)]=new Map();[_0x561507(0xb4)]=new Set();[_0x561507(0xa0)]=new Set();constructor(_0x23a6ce,_0x3df355,_0x4cfa15=Date[_0x561507(0x109)],_0x295b7a){const _0x7d89b8=_0x561507;this[_0x7d89b8(0x14b)]=_0x23a6ce,this[_0x7d89b8(0xec)]=_0x3df355,this[_0x7d89b8(0x109)]=_0x4cfa15,this[_0x7d89b8(0x13c)]=_0x295b7a;}[_0x561507(0xb6)](){const _0x1d65b3=_0x561507;return this[_0x1d65b3(0x82)][_0x1d65b3(0x11f)];}[_0x561507(0x103)](_0x19e9e4){const _0x25d0e7=_0x561507,_0x1c5731=this[_0x25d0e7(0x82)][_0x25d0e7(0xea)](_0x19e9e4);return _0x1c5731===undefined?undefined:this[_0x25d0e7(0xe6)][_0x25d0e7(0xea)](_0x1c5731);}[_0x561507(0xc9)](_0x5d2427){const _0x996c7=_0x561507;return this[_0x996c7(0x82)][_0x996c7(0xd5)](_0x5d2427);}[_0x561507(0x143)](_0x42249c){const _0x4b284a=_0x561507;if(this[_0x4b284a(0xec)](_0x42249c[_0x4b284a(0x7d)])===undefined)throw new Error(_0x4b284a(0xb3));const _0x90c9c0=this[_0x4b284a(0x109)](),_0x523ccf=_0x42249c[_0x4b284a(0x10a)]??randomUUID();if(this[_0x4b284a(0x102)][_0x4b284a(0xd5)](_0x523ccf))throw new Error(_0x4b284a(0xc5));const _0x5047b7={'id':_0x523ccf,'nodeId':this[_0x4b284a(0x14b)](),'workspaceId':_0x42249c[_0x4b284a(0x7d)],'runner':_0x42249c[_0x4b284a(0x67)],'externalSessionId':_0x42249c[_0x4b284a(0x10a)]??null,'nativeControl':_0x42249c[_0x4b284a(0x10a)]===undefined?_0x4b284a(0x81):_0x42249c[_0x4b284a(0x128)]??_0x4b284a(0xd6),'channelToken':null,'cwd':_0x42249c[_0x4b284a(0x13d)],'model':_0x42249c[_0x4b284a(0xb9)]??null,'effort':_0x42249c[_0x4b284a(0xe9)]??null,'access':_0x42249c[_0x4b284a(0x93)]??null,'customTitle':null,'runnerTitle':_0x42249c[_0x4b284a(0xa6)]?.[_0x4b284a(0x133)]()[_0x4b284a(0x13b)](-0x12bb+-0xe62+-0x1*-0x211d,0x1*0x210d+-0x1b*0xab+-0xe64)||null,'pinnedAt':null,'titleSource':_0x4b284a(0x8e),'lastActivityAt':_0x90c9c0,'createdAt':_0x90c9c0};return this[_0x4b284a(0x102)][_0x4b284a(0xcc)](_0x5047b7['id'],_0x5047b7),_0x5047b7;}[_0x561507(0xca)](_0x17a790){const _0x327504=_0x561507;if(this[_0x327504(0xa0)][_0x327504(0xd5)](_0x17a790[_0x327504(0xde)]))throw new Error(_0x327504(0xf7));let _0x1e9df6=this[_0x327504(0x102)][_0x327504(0xea)](_0x17a790[_0x327504(0x14c)]);if(_0x1e9df6===undefined){const _0x4929ed=this[_0x327504(0x109)]();_0x1e9df6={'id':_0x17a790[_0x327504(0x14c)],'nodeId':this[_0x327504(0x14b)](),'workspaceId':_0x17a790[_0x327504(0x7d)]??_0x327504(0xf2)+_0x17a790[_0x327504(0x13d)],'runner':_0x17a790[_0x327504(0x67)],'externalSessionId':_0x17a790[_0x327504(0x10a)]??null,'nativeControl':_0x17a790[_0x327504(0x10a)]===undefined?_0x327504(0x81):_0x327504(0xd6),'channelToken':null,'cwd':_0x17a790[_0x327504(0x13d)],'model':null,'effort':null,'access':null,'customTitle':null,'runnerTitle':null,'pinnedAt':null,'titleSource':_0x327504(0x8e),'lastActivityAt':_0x4929ed,'createdAt':_0x4929ed},this[_0x327504(0x102)][_0x327504(0xcc)](_0x1e9df6['id'],_0x1e9df6);}const _0x33ac65=this[_0x327504(0xe6)][_0x327504(0xea)](_0x17a790[_0x327504(0xde)]);if(_0x33ac65!==undefined)return _0x33ac65;const _0x5759f9=this[_0x327504(0x109)](),_0xc6a1d4={'id':_0x17a790[_0x327504(0xde)],'sessionId':_0x1e9df6['id'],'nodeId':this[_0x327504(0x14b)](),'workspaceId':_0x1e9df6[_0x327504(0x7d)],'runner':_0x1e9df6[_0x327504(0x67)],'status':_0x327504(0x12c),'recoveryState':_0x327504(0xfb),'version':0x0,'clientMessageId':_0x17a790[_0x327504(0x6a)]??_0x17a790[_0x327504(0xde)],'createdAt':_0x5759f9,'updatedAt':_0x5759f9};return this[_0x327504(0xe6)][_0x327504(0xcc)](_0xc6a1d4['id'],_0xc6a1d4),this[_0x327504(0x82)][_0x327504(0xcc)](_0xc6a1d4[_0x327504(0x14c)],_0xc6a1d4['id']),this[_0x327504(0x13c)]?.(_0xc6a1d4,_0x1e9df6),_0xc6a1d4;}[_0x561507(0xee)](_0x4d631d){const _0x58f4d9=_0x561507;return this[_0x58f4d9(0x102)][_0x58f4d9(0xea)](_0x4d631d)??[...this[_0x58f4d9(0x102)][_0x58f4d9(0xd0)]()][_0x58f4d9(0xeb)](_0x9a5e5e=>_0x9a5e5e[_0x58f4d9(0x10a)]===_0x4d631d);}[_0x561507(0xba)](){const _0x5e9b1e=_0x561507;return[...this[_0x5e9b1e(0x102)][_0x5e9b1e(0xd0)]()][_0x5e9b1e(0xa9)]((_0x1fcc5f,_0x541b44)=>_0x541b44[_0x5e9b1e(0xb8)]-_0x1fcc5f[_0x5e9b1e(0xb8)]);}[_0x561507(0x10c)](_0x3a7e5e,_0xd76e85){const _0x527d3d=_0x561507;return[...this[_0x527d3d(0x102)][_0x527d3d(0xd0)]()][_0x527d3d(0xeb)](_0x2a0cd4=>_0x2a0cd4[_0x527d3d(0x67)]===_0x3a7e5e&&_0x2a0cd4[_0x527d3d(0x10a)]===_0xd76e85);}[_0x561507(0x147)](_0x4b8aa5){const _0x3fc135=_0x561507;return this[_0x3fc135(0xef)](_0x4b8aa5[_0x3fc135(0x14c)],{'model':_0x4b8aa5[_0x3fc135(0xb9)],'effort':_0x4b8aa5[_0x3fc135(0xe9)],'access':_0x4b8aa5[_0x3fc135(0x93)]});}[_0x561507(0xad)](_0x369c48,_0x27685a){const _0x39b0c6=_0x561507;this[_0x39b0c6(0xef)](_0x369c48,{'nativeControl':_0x27685a});}[_0x561507(0xe3)](_0x2e6c53,_0x3d76ac){const _0x22749d=_0x561507;if(_0x3d76ac[_0x22749d(0xd2)]===-0x1385+-0xc*0x23f+0x2e79)throw new Error(_0x22749d(0xa4));this[_0x22749d(0x12f)](_0x2e6c53,_0x3d76ac);}[_0x561507(0x12f)](_0x395f71,_0x59c26e){const _0x42f762=_0x561507;if(_0x59c26e[_0x42f762(0xd2)]===0x29d*0x7+-0x6f8*-0x2+0x203b*-0x1)throw new Error(_0x42f762(0xa4));const _0x3e9475=this[_0x42f762(0xac)](_0x395f71);if(_0x395f71===_0x59c26e)return this[_0x42f762(0xef)](_0x395f71,{'externalSessionId':_0x59c26e,'nativeControl':_0x42f762(0x81)});const _0x120575=this[_0x42f762(0x102)][_0x42f762(0xea)](_0x59c26e);if(_0x120575!==undefined&&_0x120575['id']!==_0x3e9475['id'])throw new Error(_0x42f762(0xc5));const _0x33a415={..._0x3e9475,'id':_0x59c26e,'externalSessionId':_0x59c26e,'nativeControl':_0x42f762(0x81)},_0x1d2f03=this[_0x42f762(0x138)](_0x395f71),_0x39f4c5=this[_0x42f762(0xe2)][_0x42f762(0xea)](_0x395f71)??[],_0x15fefe=this[_0x42f762(0xf9)][_0x42f762(0xea)](_0x395f71),_0x1a6305=this[_0x42f762(0x121)][_0x42f762(0xea)](_0x395f71),_0x23520e=this[_0x42f762(0x82)][_0x42f762(0xea)](_0x395f71),_0x4823b9=this[_0x42f762(0xb4)][_0x42f762(0xd5)](_0x395f71);this[_0x42f762(0x102)][_0x42f762(0x12d)](_0x395f71),this[_0x42f762(0x102)][_0x42f762(0xcc)](_0x59c26e,_0x33a415);for(const _0x3ab737 of _0x1d2f03)this[_0x42f762(0xe6)][_0x42f762(0xcc)](_0x3ab737['id'],{..._0x3ab737,'sessionId':_0x59c26e});this[_0x42f762(0xe2)][_0x42f762(0x12d)](_0x395f71),this[_0x42f762(0xe2)][_0x42f762(0xcc)](_0x59c26e,_0x39f4c5[_0x42f762(0x7a)](_0x5547ff=>({..._0x5547ff,'sessionId':_0x59c26e,'items':_0x5547ff[_0x42f762(0x90)][_0x42f762(0x7a)](_0x12ffb1=>({..._0x12ffb1,'sessionId':_0x59c26e}))})));_0x15fefe!==undefined&&(this[_0x42f762(0xf9)][_0x42f762(0x12d)](_0x395f71),this[_0x42f762(0xf9)][_0x42f762(0xcc)](_0x59c26e,_0x15fefe));_0x1a6305!==undefined&&(this[_0x42f762(0x121)][_0x42f762(0x12d)](_0x395f71),this[_0x42f762(0x121)][_0x42f762(0xcc)](_0x59c26e,_0x1a6305));_0x23520e!==undefined&&(this[_0x42f762(0x82)][_0x42f762(0x12d)](_0x395f71),this[_0x42f762(0x82)][_0x42f762(0xcc)](_0x59c26e,_0x23520e));_0x4823b9&&(this[_0x42f762(0xb4)][_0x42f762(0x12d)](_0x395f71),this[_0x42f762(0xb4)][_0x42f762(0xd4)](_0x59c26e));for(const [_0x528860,_0x8b86a]of[...this[_0x42f762(0xed)]]){if(!_0x528860[_0x42f762(0x69)](_0x395f71+'\x00'))continue;this[_0x42f762(0xed)][_0x42f762(0x12d)](_0x528860),this[_0x42f762(0xed)][_0x42f762(0xcc)](''+_0x59c26e+_0x528860[_0x42f762(0x13b)](_0x395f71[_0x42f762(0xd2)]),_0x8b86a);}return _0x33a415;}[_0x561507(0xab)](_0x1ab755,_0x4aad50){const _0x1c34ef=_0x561507;if(_0x4aad50[_0x1c34ef(0xd2)]<-0x23*-0x4b+-0x1e80+0x144f)throw new Error(_0x1c34ef(0x101));this[_0x1c34ef(0xef)](_0x1ab755,{'channelToken':_0x4aad50});}[_0x561507(0x140)](_0x3ef398){const _0x51bc1d=_0x561507,_0xc1702f=this[_0x51bc1d(0xac)](_0x3ef398[_0x51bc1d(0x14c)]),_0x21fe3a=_0x3ef398[_0x51bc1d(0x99)]===undefined?_0xc1702f[_0x51bc1d(0x99)]:_0x3ef398[_0x51bc1d(0x99)]?.[_0x51bc1d(0x133)]()||null;if(_0x21fe3a!==null&&_0x21fe3a[_0x51bc1d(0xd2)]>0x9fc+0x467*-0x7+-0x3*-0x727)throw new Error(_0x51bc1d(0x11b));return this[_0x51bc1d(0xef)](_0xc1702f['id'],{'customTitle':_0x21fe3a,'pinnedAt':_0x3ef398[_0x51bc1d(0x13e)]===undefined?_0xc1702f[_0x51bc1d(0xbd)]:_0x3ef398[_0x51bc1d(0x13e)]?this[_0x51bc1d(0x109)]():null,'titleSource':_0x21fe3a===null?_0x51bc1d(0x8e):_0x51bc1d(0x112)});}[_0x561507(0x66)](_0x46dd64,_0x48c93f){const _0x18fff3=_0x561507,_0x213c93=this[_0x18fff3(0xac)](_0x46dd64),_0x4d1e10=_0x48c93f[_0x18fff3(0x133)]()[_0x18fff3(0xaf)](/\s+/g,'\x20')[_0x18fff3(0x13b)](-0x90b+-0x3a*0x6a+0x210f,-0x21f9+-0x1a3*-0x1+-0x20f6*-0x1);if(_0x4d1e10[_0x18fff3(0xd2)]===-0x1e25+-0x1ede+-0x3d03*-0x1||_0x213c93[_0x18fff3(0x99)]!==null||_0x213c93[_0x18fff3(0x110)]!==null)return _0x213c93;return this[_0x18fff3(0xef)](_0x46dd64,{'runnerTitle':_0x4d1e10,'titleSource':_0x18fff3(0x8e)});}[_0x561507(0x118)](_0x508c29,_0x21a7f9){const _0x558ccc=_0x561507,_0xfc34c=this[_0x558ccc(0xac)](_0x508c29),_0x38a089=_0x21a7f9[_0x558ccc(0x133)]()[_0x558ccc(0xaf)](/\s+/g,'\x20')[_0x558ccc(0x13b)](-0x64b*0x1+0x11fc+0x1*-0xbb1,0x40d*0x1+-0x5cc+0x25f);if(_0x38a089[_0x558ccc(0xd2)]===-0x25*-0x79+0x1dae+-0xfb9*0x3||_0xfc34c[_0x558ccc(0x99)]!==null||_0xfc34c[_0x558ccc(0x110)]===_0x38a089)return _0xfc34c;return this[_0x558ccc(0xef)](_0x508c29,{'runnerTitle':_0x38a089,'titleSource':_0x558ccc(0xa2)});}[_0x561507(0x113)](_0x269692){const _0x540610=_0x561507,_0x31d7da=_0x269692[_0x540610(0x14c)]+'\x00'+_0x269692[_0x540610(0x6a)],_0x5bf969=this[_0x540610(0xed)][_0x540610(0xea)](_0x31d7da);if(_0x5bf969!==undefined)return{'run':this[_0x540610(0xd9)](_0x5bf969),'created':![]};const _0x919e29=this[_0x540610(0xac)](_0x269692[_0x540610(0x14c)]),_0x595a=this[_0x540610(0x109)](),_0x6ba35={'id':_0x269692[_0x540610(0xde)]??randomUUID(),'sessionId':_0x919e29['id'],'nodeId':this[_0x540610(0x14b)](),'workspaceId':_0x919e29[_0x540610(0x7d)],'runner':_0x919e29[_0x540610(0x67)],'status':_0x540610(0x12c),'recoveryState':_0x540610(0xfb),'version':0x0,'clientMessageId':_0x269692[_0x540610(0x6a)],..._0x269692[_0x540610(0x80)]===undefined?{}:{'initiatedByUserId':_0x269692[_0x540610(0x80)]},'createdAt':_0x595a,'updatedAt':_0x595a};let _0x50037e=0x68e+0x23d*-0x11+0xb*0x2dd;const _0x54ed32=(_0x269692[_0x540610(0x92)]??[])[_0x540610(0x7a)](({name:_0x581c08,mime:_0x24d440,dataBase64:_0x293204})=>{const _0x2bb380=_0x540610,_0x4d46df={'name':_0x581c08,'mime':_0x24d440,'byteSize':Buffer[_0x2bb380(0xf1)](_0x293204,_0x2bb380(0x141)),'runId':_0x6ba35['id']};if(!_0x24d440[_0x2bb380(0x69)](_0x2bb380(0x125)))return _0x4d46df;return{..._0x4d46df,'imageIndex':_0x50037e++};}),_0x583990={'id':randomUUID(),'sessionId':_0x919e29['id'],'turnId':'','runId':_0x6ba35['id'],'parentItemId':null,'sourceSequence':null,'revision':0x0,'kind':_0x540610(0x97),'status':_0x540610(0x149),'payload':{'clientMessageId':_0x269692[_0x540610(0x6a)],'text':_0x269692[_0x540610(0x7b)],'contexts':[],'attachments':_0x54ed32,'delivery':_0x540610(0x131)},'startedAt':_0x595a,'completedAt':_0x595a},_0x458571={'id':randomUUID(),'sessionId':_0x919e29['id'],'runId':_0x6ba35['id'],'userItemId':_0x583990['id'],'status':_0x540610(0x12c),'model':_0x919e29[_0x540610(0xb9)],'effort':_0x919e29[_0x540610(0xe9)],'access':_0x919e29[_0x540610(0x93)],'items':[_0x583990],'startedAt':null,'completedAt':null},_0x199e19={..._0x458571,'items':[{..._0x583990,'turnId':_0x458571['id']}]};return this[_0x540610(0xe6)][_0x540610(0xcc)](_0x6ba35['id'],_0x6ba35),this[_0x540610(0xed)][_0x540610(0xcc)](_0x31d7da,_0x6ba35['id']),this[_0x540610(0xf9)][_0x540610(0xcc)](_0x919e29['id'],[...this[_0x540610(0xf9)][_0x540610(0xea)](_0x919e29['id'])??[],_0x6ba35['id']]),this[_0x540610(0xc3)](_0x919e29['id']),this[_0x540610(0xe2)][_0x540610(0xcc)](_0x919e29['id'],[...this[_0x540610(0xe2)][_0x540610(0xea)](_0x919e29['id'])??[],_0x199e19]),this[_0x540610(0xef)](_0x919e29['id'],{'lastActivityAt':_0x595a}),this[_0x540610(0x13c)]?.(_0x6ba35,this[_0x540610(0xac)](_0x919e29['id']),_0x269692[_0x540610(0x7b)]),{'run':_0x6ba35,'created':!![]};}[_0x561507(0xcb)](_0x59bd0f){const _0x389b88=_0x561507;return{'version':this[_0x389b88(0x121)][_0x389b88(0xea)](_0x59bd0f)??0x1331+-0x5*-0x510+-0x2c81,'paused':this[_0x389b88(0xb4)][_0x389b88(0xd5)](_0x59bd0f),'runIds':this[_0x389b88(0xf9)][_0x389b88(0xea)](_0x59bd0f)??[]};}[_0x561507(0xc2)](_0x2a534a){const _0xfe6fe0=_0x561507,_0xd9acb5=this[_0xfe6fe0(0xd9)](_0x2a534a);return(this[_0xfe6fe0(0xf9)][_0xfe6fe0(0xea)](_0xd9acb5[_0xfe6fe0(0x14c)])??[])[_0xfe6fe0(0x6c)](_0x2a534a);}[_0x561507(0x9e)](_0x43dd5f){const _0x521255=_0x561507;if(this[_0x521255(0x82)][_0x521255(0xd5)](_0x43dd5f)||this[_0x521255(0xb4)][_0x521255(0xd5)](_0x43dd5f))return undefined;const _0x462e52=this[_0x521255(0xf9)][_0x521255(0xea)](_0x43dd5f)??[],_0x8a1b3c=_0x462e52[0x2*0x11d8+0xce*0xd+-0x7b1*0x6];if(_0x8a1b3c===undefined)return undefined;this[_0x521255(0xf9)][_0x521255(0xcc)](_0x43dd5f,_0x462e52[_0x521255(0x13b)](0x1*0x1041+-0x1e3e+0xdfe)),this[_0x521255(0xc3)](_0x43dd5f);const _0x5de529=this[_0x521255(0xd9)](_0x8a1b3c);return this[_0x521255(0x82)][_0x521255(0xcc)](_0x43dd5f,_0x5de529['id']),_0x5de529;}[_0x561507(0x11d)](_0x5a5958){const _0x541513=_0x561507;this[_0x541513(0xb4)][_0x541513(0xd4)](_0x5a5958),this[_0x541513(0xc3)](_0x5a5958);}[_0x561507(0x73)](_0x498943){const _0x3a2805=_0x561507;if(!this[_0x3a2805(0xb4)][_0x3a2805(0x12d)](_0x498943))return;this[_0x3a2805(0xc3)](_0x498943);}[_0x561507(0xae)](_0x473791,_0x5251fa,_0x2f543e){const _0x255e41=_0x561507,_0x5ca2ec=this[_0x255e41(0xf9)][_0x255e41(0xea)](_0x473791)??[];if(this[_0x255e41(0xcb)](_0x473791)[_0x255e41(0x148)]!==_0x5251fa||_0x5ca2ec[_0x255e41(0xd2)]!==_0x2f543e[_0x255e41(0xd2)]||new Set(_0x5ca2ec)[_0x255e41(0x11f)]!==_0x5ca2ec[_0x255e41(0xd2)]||_0x5ca2ec[_0x255e41(0xda)](_0x33d9df=>!_0x2f543e[_0x255e41(0x6c)](_0x33d9df)))throw new Error(_0x255e41(0x132));if(_0x2f543e[_0x255e41(0xda)](_0x464d2d=>this[_0x255e41(0xd9)](_0x464d2d)[_0x255e41(0x68)]!==_0x255e41(0x12c)))throw new Error(_0x255e41(0xe1));this[_0x255e41(0xf9)][_0x255e41(0xcc)](_0x473791,[..._0x2f543e]),this[_0x255e41(0xc3)](_0x473791);}[_0x561507(0xf4)](_0x2a3919){const _0x17fcd8=_0x561507,_0x272445=this[_0x17fcd8(0xd9)](_0x2a3919),_0x23de71=this[_0x17fcd8(0xf9)][_0x17fcd8(0xea)](_0x272445[_0x17fcd8(0x14c)])??[];if(!_0x23de71[_0x17fcd8(0x6c)](_0x2a3919)||_0x272445[_0x17fcd8(0x68)]!==_0x17fcd8(0x12c))throw new Error(_0x17fcd8(0xe1));return this[_0x17fcd8(0xf9)][_0x17fcd8(0xcc)](_0x272445[_0x17fcd8(0x14c)],[_0x2a3919,..._0x23de71[_0x17fcd8(0x115)](_0x36ae38=>_0x36ae38!==_0x2a3919)]),this[_0x17fcd8(0xc3)](_0x272445[_0x17fcd8(0x14c)]),_0x272445;}[_0x561507(0xf0)](_0xe3e18e,_0x456621){const _0x4c1a94=_0x561507,_0x3eeabd=this[_0x4c1a94(0xd9)](_0xe3e18e);if(!(this[_0x4c1a94(0xf9)][_0x4c1a94(0xea)](_0x3eeabd[_0x4c1a94(0x14c)])??[])[_0x4c1a94(0x6c)](_0xe3e18e)||_0x3eeabd[_0x4c1a94(0x68)]!==_0x4c1a94(0x12c))throw new Error(_0x4c1a94(0xe1));return this[_0x4c1a94(0x91)](_0xe3e18e,_0x56a239=>({..._0x56a239,'items':_0x56a239[_0x4c1a94(0x90)][_0x4c1a94(0x7a)](_0x127656=>_0x127656['id']===_0x56a239[_0x4c1a94(0x11a)]&&isRecord(_0x127656[_0x4c1a94(0x108)])?{..._0x127656,'payload':{..._0x127656[_0x4c1a94(0x108)],'text':_0x456621}}:_0x127656)})),this[_0x4c1a94(0xc3)](_0x3eeabd[_0x4c1a94(0x14c)]),_0x3eeabd;}[_0x561507(0x136)](_0x35d6cb){const _0x2ddacd=_0x561507,_0x1196f3=this[_0x2ddacd(0xd9)](_0x35d6cb),_0x4dd868=this[_0x2ddacd(0xf9)][_0x2ddacd(0xea)](_0x1196f3[_0x2ddacd(0x14c)])??[];if(!_0x4dd868[_0x2ddacd(0x6c)](_0x35d6cb)||_0x1196f3[_0x2ddacd(0x68)]!==_0x2ddacd(0x12c))throw new Error(_0x2ddacd(0xe1));this[_0x2ddacd(0xf9)][_0x2ddacd(0xcc)](_0x1196f3[_0x2ddacd(0x14c)],_0x4dd868[_0x2ddacd(0x115)](_0x2dd61f=>_0x2dd61f!==_0x35d6cb)),this[_0x2ddacd(0xc3)](_0x1196f3[_0x2ddacd(0x14c)]),this[_0x2ddacd(0xe6)][_0x2ddacd(0x12d)](_0x35d6cb),this[_0x2ddacd(0xb7)][_0x2ddacd(0x12d)](_0x35d6cb),this[_0x2ddacd(0xe2)][_0x2ddacd(0xcc)](_0x1196f3[_0x2ddacd(0x14c)],(this[_0x2ddacd(0xe2)][_0x2ddacd(0xea)](_0x1196f3[_0x2ddacd(0x14c)])??[])[_0x2ddacd(0x115)](_0x5b31ab=>_0x5b31ab[_0x2ddacd(0xde)]!==_0x35d6cb));for(const [_0x4aef47,_0x45e567]of this[_0x2ddacd(0xed)])if(_0x45e567===_0x35d6cb)this[_0x2ddacd(0xed)][_0x2ddacd(0x12d)](_0x4aef47);}[_0x561507(0x14a)](_0x23b32f){const _0x245699=_0x561507,_0x166020=this[_0x245699(0xd9)](_0x23b32f),_0x51a79b=(this[_0x245699(0xe2)][_0x245699(0xea)](_0x166020[_0x245699(0x14c)])??[])[_0x245699(0xeb)](_0x2c20cf=>_0x2c20cf[_0x245699(0xde)]===_0x23b32f),_0xe8f096=_0x51a79b?.[_0x245699(0x90)][_0x245699(0xeb)](_0x4c7273=>_0x4c7273['id']===_0x51a79b[_0x245699(0x11a)]);return isRecord(_0xe8f096?.[_0x245699(0x108)])&&typeof _0xe8f096[_0x245699(0x108)][_0x245699(0x6b)]===_0x245699(0x116)?_0xe8f096[_0x245699(0x108)][_0x245699(0x6b)]:'';}[_0x561507(0x7c)](_0x2b4c86){const _0x4e247a=_0x561507;return this[_0x4e247a(0xe6)][_0x4e247a(0xea)](_0x2b4c86);}[_0x561507(0x134)](_0x4ea61d,_0x3a4a3b){const _0x484b75=_0x561507,_0x453ccf=this[_0x484b75(0xed)][_0x484b75(0xea)](_0x4ea61d+'\x00'+_0x3a4a3b);return _0x453ccf===undefined?undefined:this[_0x484b75(0xe6)][_0x484b75(0xea)](_0x453ccf);}[_0x561507(0x138)](_0x2872dd){const _0x47b362=_0x561507;return[...this[_0x47b362(0xe6)][_0x47b362(0xd0)]()][_0x47b362(0x115)](_0x333714=>_0x333714[_0x47b362(0x14c)]===_0x2872dd)[_0x47b362(0xa9)]((_0x5323c8,_0x17650b)=>_0x17650b[_0x47b362(0x75)]-_0x5323c8[_0x47b362(0x75)]);}[_0x561507(0x107)](_0x7ad1a4,_0x14bb1f){const _0x3d2621=_0x561507,_0x4228b2=this[_0x3d2621(0xd9)](_0x7ad1a4);if(!transitionAllowed(_0x4228b2[_0x3d2621(0x68)],_0x14bb1f))throw new Error(_0x3d2621(0x85));const _0x163747={..._0x4228b2,'status':_0x14bb1f,'version':_0x4228b2[_0x3d2621(0x148)]+(-0x44*-0x3d+0xc1b*-0x1+-0x8*0x83),'updatedAt':this[_0x3d2621(0x109)]()};this[_0x3d2621(0xe6)][_0x3d2621(0xcc)](_0x7ad1a4,_0x163747),this[_0x3d2621(0x13c)]?.(_0x163747,this[_0x3d2621(0xac)](_0x163747[_0x3d2621(0x14c)]));if(terminal(_0x14bb1f)&&this[_0x3d2621(0x82)][_0x3d2621(0xea)](_0x163747[_0x3d2621(0x14c)])===_0x163747['id'])this[_0x3d2621(0x82)][_0x3d2621(0x12d)](_0x163747[_0x3d2621(0x14c)]);return this[_0x3d2621(0x91)](_0x7ad1a4,_0x4b8884=>({..._0x4b8884,'status':_0x14bb1f,'completedAt':terminal(_0x14bb1f)?this[_0x3d2621(0x109)]():_0x4b8884[_0x3d2621(0x94)],'items':terminal(_0x14bb1f)?_0x4b8884[_0x3d2621(0x90)][_0x3d2621(0x7a)](_0x1c859e=>activeConversationItem(_0x1c859e[_0x3d2621(0x68)])?{..._0x1c859e,'status':completedStatusForRun(_0x14bb1f),'completedAt':this[_0x3d2621(0x109)]()}:_0x1c859e):_0x4b8884[_0x3d2621(0x90)]})),_0x163747;}[_0x561507(0xfa)](_0x320e98){const _0x148173=_0x561507;this[_0x148173(0xd9)](_0x320e98[_0x148173(0xde)]);const _0xf1f368=this[_0x148173(0xb7)][_0x148173(0xea)](_0x320e98[_0x148173(0xde)])??0x1e1+-0xa1*-0x27+-0x208*0xd;if(_0x320e98[_0x148173(0x105)]<=_0xf1f368)return undefined;if(_0x320e98[_0x148173(0x105)]>_0xf1f368+(0xbe8+-0x1b07+0xf20))throw new Error(_0x148173(0xaa));const _0x982f5f={'runId':_0x320e98[_0x148173(0xde)],'sequence':_0x320e98[_0x148173(0x105)],'eventType':_0x320e98[_0x148173(0xdd)],'payload':_0x320e98[_0x148173(0x108)],..._0x320e98[_0x148173(0x68)]===undefined?{}:{'status':_0x320e98[_0x148173(0x68)]},'createdAt':this[_0x148173(0x109)]()};this[_0x148173(0xb7)][_0x148173(0xcc)](_0x320e98[_0x148173(0xde)],_0x320e98[_0x148173(0x105)]);if(_0x320e98[_0x148173(0x68)]!==undefined)this[_0x148173(0x107)](_0x320e98[_0x148173(0xde)],_0x320e98[_0x148173(0x68)]);return this[_0x148173(0x98)](_0x982f5f),_0x982f5f;}[_0x561507(0x9d)](_0x4880d0){const _0x385c6c=_0x561507;this[_0x385c6c(0xac)](_0x4880d0[_0x385c6c(0x14c)]);const _0x55bf74=[...this[_0x385c6c(0xe2)][_0x385c6c(0xea)](_0x4880d0[_0x385c6c(0x14c)])??[]][_0x385c6c(0x7a)]((_0x22122b,_0x5356d5)=>({'turn':_0x22122b,'index':_0x5356d5}))[_0x385c6c(0xa9)]((_0x8ba8f2,_0x3f400d)=>{const _0x3d1c6f=_0x385c6c,_0x3a4860=_0x2f7339=>_0x2f7339[_0x3d1c6f(0x90)][_0x3d1c6f(0xeb)](_0x5e2461=>_0x5e2461['id']===_0x2f7339[_0x3d1c6f(0x11a)])?.[_0x3d1c6f(0xfe)]??_0x2f7339[_0x3d1c6f(0xfe)]??_0x2f7339[_0x3d1c6f(0x94)]??0x1*0xa6b+0x2*-0x99e+0x8d1;return _0x3a4860(_0x8ba8f2[_0x3d1c6f(0xff)])-_0x3a4860(_0x3f400d[_0x3d1c6f(0xff)])||_0x8ba8f2[_0x3d1c6f(0x79)]-_0x3f400d[_0x3d1c6f(0x79)];})[_0x385c6c(0x7a)](({turn:_0x19168b})=>_0x19168b),_0x591f2a=_0x4880d0[_0x385c6c(0xe4)]===undefined?_0x55bf74[_0x385c6c(0xd2)]:decodeCursor(_0x4880d0[_0x385c6c(0xe4)],_0x4880d0[_0x385c6c(0x14c)]),_0x706a75=Math[_0x385c6c(0x8b)](Math[_0x385c6c(0xf8)](_0x4880d0[_0x385c6c(0x7e)]??-0xddb*0x1+0x185*-0x9+0x1ba6,-0x1af8*0x1+0x24fe*-0x1+-0x1*-0x3ff7),0xaac+-0x1c*-0x15b+0x74*-0x67),_0x2539a6=Math[_0x385c6c(0xf8)](-0x5*0x33+0x2070+-0x1f71,_0x591f2a-_0x706a75),_0x2175f5=_0x55bf74[_0x385c6c(0x13b)](_0x2539a6,_0x591f2a);return{'turns':_0x2175f5,'nextCursor':_0x2539a6>-0x1c10+0x1b91*-0x1+0x37a1?encodeCursor(_0x4880d0[_0x385c6c(0x14c)],_0x2539a6):null};}[_0x561507(0x13a)](_0x4b583b){const _0x4d598f=_0x561507;for(const _0x3d59b7 of this[_0x4d598f(0xe2)][_0x4d598f(0xd0)]()){const _0xa5f60c=_0x3d59b7[_0x4d598f(0xeb)](_0x594797=>_0x594797[_0x4d598f(0xde)]===_0x4b583b);if(_0xa5f60c!==undefined)return _0xa5f60c;}return undefined;}[_0x561507(0x13f)](_0x435c1b){const _0x3e126a=_0x561507,_0x17deff=this[_0x3e126a(0x9d)](_0x435c1b)[_0x3e126a(0xe2)];return{'items':_0x17deff[_0x3e126a(0xb0)](_0x4cbbba=>_0x4cbbba[_0x3e126a(0x90)]),'nextCursor':null};}[_0x561507(0xa5)](_0x424710){const _0x3d2062=_0x561507,_0x3f82ad=this[_0x3d2062(0xac)](_0x424710[_0x3d2062(0x14c)]),_0x4581d7=this[_0x3d2062(0x109)](),_0x16357f={'id':randomUUID(),'sessionId':_0x424710[_0x3d2062(0x14c)],'turnId':'','runId':null,'parentItemId':null,'sourceSequence':null,'revision':0x1,'kind':_0x3d2062(0x124),'status':_0x424710[_0x3d2062(0x11e)]?_0x3d2062(0x6f):_0x3d2062(0x149),'payload':{'command':_0x424710[_0x3d2062(0x9a)],'cwd':_0x424710[_0x3d2062(0x13d)],'outputPreview':_0x424710[_0x3d2062(0xc4)][_0x3d2062(0x13b)](-0x204c+0xd1*-0x4+-0x8e4*-0x4,0x3d07+-0x1*-0x4115+0x26b*-0x24),'outputRef':null,'exitCode':_0x424710[_0x3d2062(0x11e)]?-0x1296+-0x3c8+0x165f:0x1*0xac9+-0x12b0+0x7e7,'durationMs':0x0,'truncated':![]},'startedAt':_0x4581d7,'completedAt':_0x4581d7},_0x2e8546={'id':randomUUID(),'sessionId':_0x424710[_0x3d2062(0x14c)],'runId':null,'userItemId':null,'status':_0x424710[_0x3d2062(0x11e)]?_0x3d2062(0x6f):_0x3d2062(0x12e),'model':_0x3f82ad[_0x3d2062(0xb9)],'effort':_0x3f82ad[_0x3d2062(0xe9)],'access':_0x3f82ad[_0x3d2062(0x93)],'items':[],'startedAt':_0x4581d7,'completedAt':_0x4581d7},_0x144e2e={..._0x16357f,'turnId':_0x2e8546['id']},_0x580336={..._0x2e8546,'items':[_0x144e2e]};return this[_0x3d2062(0xe2)][_0x3d2062(0xcc)](_0x424710[_0x3d2062(0x14c)],[...this[_0x3d2062(0xe2)][_0x3d2062(0xea)](_0x424710[_0x3d2062(0x14c)])??[],_0x580336]),this[_0x3d2062(0xef)](_0x3f82ad['id'],{'lastActivityAt':_0x4581d7}),_0x580336;}[_0x561507(0x84)](_0x55cd6e){const _0x216bd7=_0x561507;this[_0x216bd7(0xd9)](_0x55cd6e[_0x216bd7(0xde)]);if(this[_0x216bd7(0xc8)][_0x216bd7(0xd5)](_0x55cd6e[_0x216bd7(0xbe)]))throw new Error(_0x216bd7(0x10b));if(_0x55cd6e[_0x216bd7(0x7f)]<=this[_0x216bd7(0x109)]())throw new Error(_0x216bd7(0x76));const _0xd55cf={'id':_0x55cd6e[_0x216bd7(0xbe)],'runId':_0x55cd6e[_0x216bd7(0xde)],'status':_0x216bd7(0x74),'payload':_0x55cd6e[_0x216bd7(0x108)],'expiresAt':_0x55cd6e[_0x216bd7(0x7f)],'createdAt':this[_0x216bd7(0x109)](),'decidedAt':null};return this[_0x216bd7(0xc8)][_0x216bd7(0xcc)](_0xd55cf['id'],_0xd55cf),_0xd55cf;}[_0x561507(0x72)](_0x14931d){const _0x166f35=_0x561507,_0x420ec9=this[_0x166f35(0xc8)][_0x166f35(0xea)](_0x14931d);if(_0x420ec9?.[_0x166f35(0x68)]===_0x166f35(0x74)&&_0x420ec9[_0x166f35(0x7f)]<=this[_0x166f35(0x109)]())return this[_0x166f35(0x8c)](_0x14931d);return _0x420ec9;}[_0x561507(0xe8)](_0x2b9df9){const _0x4ce157=_0x561507;return[...this[_0x4ce157(0xc8)][_0x4ce157(0xd0)]()][_0x4ce157(0x115)](_0x4cfbb2=>_0x4cfbb2[_0x4ce157(0xde)]===_0x2b9df9)[_0x4ce157(0x7a)](_0x40d28c=>this[_0x4ce157(0x72)](_0x40d28c['id']));}[_0x561507(0x8c)](_0x64e0d7){const _0x41befe=_0x561507,_0x8c1359=this[_0x41befe(0xe0)](_0x64e0d7);if(_0x8c1359[_0x41befe(0x68)]!==_0x41befe(0x74))return _0x8c1359;if(_0x8c1359[_0x41befe(0x7f)]>this[_0x41befe(0x109)]())throw new Error(_0x41befe(0xb1));const _0x4211e8={..._0x8c1359,'status':_0x41befe(0x10e),'decidedAt':this[_0x41befe(0x109)]()};return this[_0x41befe(0xc8)][_0x41befe(0xcc)](_0x64e0d7,_0x4211e8),_0x4211e8;}[_0x561507(0x8a)](_0x52fb68,_0x8df47){const _0x389e2a=_0x561507,_0x531bac=this[_0x389e2a(0x72)](_0x52fb68);if(_0x531bac===undefined)throw new Error(_0x389e2a(0xe7));if(_0x531bac[_0x389e2a(0x68)]===_0x389e2a(0x10e))throw new Error(_0x389e2a(0x76));if(_0x531bac[_0x389e2a(0x68)]!==_0x389e2a(0x74))throw new Error(_0x389e2a(0x88));const _0x26f90a={..._0x531bac,'status':_0x8df47,'decidedAt':this[_0x389e2a(0x109)]()};return this[_0x389e2a(0xc8)][_0x389e2a(0xcc)](_0x52fb68,_0x26f90a),_0x26f90a;}[_0x561507(0x8f)](){const _0x43b5c2=_0x561507;return[...this[_0x43b5c2(0xc8)][_0x43b5c2(0xd0)]()][_0x43b5c2(0x115)](_0xb80742=>_0xb80742[_0x43b5c2(0x68)]===_0x43b5c2(0x74)&&_0xb80742[_0x43b5c2(0x7f)]<=this[_0x43b5c2(0x109)]())[_0x43b5c2(0x7a)](_0xcff4f7=>this[_0x43b5c2(0x8c)](_0xcff4f7['id']));}[_0x561507(0x6e)](){const _0x5ceebc=_0x561507;return[...this[_0x5ceebc(0xe6)][_0x5ceebc(0xd0)]()][_0x5ceebc(0x115)](_0x43b72e=>!terminal(_0x43b72e[_0x5ceebc(0x68)]));}[_0x561507(0xdb)](_0x1f0b5e){const _0x9f8a8c=_0x561507;return this[_0x9f8a8c(0xb7)][_0x9f8a8c(0xea)](_0x1f0b5e)??-0x1053+-0x25a0+-0x1*-0x35f3;}[_0x561507(0x6d)](_0x5aced8){const _0x409667=_0x561507,_0x28ae29=this[_0x409667(0xd9)](_0x5aced8);if(!terminal(_0x28ae29[_0x409667(0x68)]))throw new Error(_0x409667(0xc6));this[_0x409667(0xa0)][_0x409667(0xd4)](_0x5aced8);if(this[_0x409667(0xa0)][_0x409667(0x11f)]>0x199*-0xe+-0x7*0x34d+0x3179)this[_0x409667(0xa0)][_0x409667(0x12d)](this[_0x409667(0xa0)][_0x409667(0xd0)]()[_0x409667(0xdc)]()[_0x409667(0xf6)]);const _0x20db1e=this[_0x409667(0xf9)][_0x409667(0xea)](_0x28ae29[_0x409667(0x14c)])??[];_0x20db1e[_0x409667(0x6c)](_0x5aced8)&&(this[_0x409667(0xf9)][_0x409667(0xcc)](_0x28ae29[_0x409667(0x14c)],_0x20db1e[_0x409667(0x115)](_0x4e66d7=>_0x4e66d7!==_0x5aced8)),this[_0x409667(0xc3)](_0x28ae29[_0x409667(0x14c)]));this[_0x409667(0xe6)][_0x409667(0x12d)](_0x5aced8),this[_0x409667(0xb7)][_0x409667(0x12d)](_0x5aced8);const _0xba2561=(this[_0x409667(0xe2)][_0x409667(0xea)](_0x28ae29[_0x409667(0x14c)])??[])[_0x409667(0x115)](_0x3e8edd=>{const _0x4f6008=_0x409667,_0x12c32d=_0x3e8edd[_0x4f6008(0x90)][_0x4f6008(0xda)](_0x200d2f=>_0x200d2f[_0x4f6008(0xcd)]===_0x4f6008(0x10f));if(_0x3e8edd[_0x4f6008(0xde)]===_0x5aced8)return _0x28ae29[_0x4f6008(0x68)]===_0x4f6008(0x12e)||_0x28ae29[_0x4f6008(0x68)]===_0x4f6008(0x12b)||_0x12c32d;const _0x3897ff=_0x12c32d&&_0x3e8edd[_0x4f6008(0x68)]!==_0x4f6008(0x12e)&&_0x3e8edd[_0x4f6008(0x68)]!==_0x4f6008(0x12b);return _0x28ae29[_0x4f6008(0x68)]!==_0x4f6008(0x12e)||!_0x3897ff;}),_0x3b763f=_0xba2561[_0x409667(0x115)](_0x20852=>terminalTurn(_0x20852[_0x409667(0x68)])),_0x49ae9e=new Set(_0x3b763f[_0x409667(0x13b)](-NodeRuntimeState[_0x409667(0xbc)])[_0x409667(0x7a)](_0xe790ee=>_0xe790ee['id']));this[_0x409667(0xe2)][_0x409667(0xcc)](_0x28ae29[_0x409667(0x14c)],_0xba2561[_0x409667(0x115)](_0x415c9e=>!terminalTurn(_0x415c9e[_0x409667(0x68)])||_0x49ae9e[_0x409667(0xd5)](_0x415c9e['id'])));for(const [_0x189bce,_0x13bbd3]of this[_0x409667(0xed)])if(_0x13bbd3===_0x5aced8)this[_0x409667(0xed)][_0x409667(0x12d)](_0x189bce);for(const [_0x525903,_0x19e979]of this[_0x409667(0xc8)])if(_0x19e979[_0x409667(0xde)]===_0x5aced8)this[_0x409667(0xc8)][_0x409667(0x12d)](_0x525903);}[_0x561507(0xf3)](_0x100dd5){const _0x37e203=_0x561507;return[...this[_0x37e203(0x82)][_0x37e203(0xd0)]()][_0x37e203(0x7a)](_0xcf374a=>this[_0x37e203(0xe6)][_0x37e203(0xea)](_0xcf374a))[_0x37e203(0xda)](_0x2a8fa1=>_0x2a8fa1?.[_0x37e203(0x7d)]===_0x100dd5);}[_0x561507(0x130)](_0x212254){const _0xa56ce5=_0x561507;this[_0xa56ce5(0xac)](_0x212254);const _0x290ca9=this[_0xa56ce5(0x138)](_0x212254);if(_0x290ca9[_0xa56ce5(0xda)](_0x2397b3=>!terminal(_0x2397b3[_0xa56ce5(0x68)])))throw new Error(_0xa56ce5(0xd3));const _0x1a70bf=new Set(_0x290ca9[_0xa56ce5(0x7a)](_0x504db9=>_0x504db9['id']));this[_0xa56ce5(0x102)][_0xa56ce5(0x12d)](_0x212254),this[_0xa56ce5(0xe2)][_0xa56ce5(0x12d)](_0x212254),this[_0xa56ce5(0xf9)][_0xa56ce5(0x12d)](_0x212254),this[_0xa56ce5(0x121)][_0xa56ce5(0x12d)](_0x212254),this[_0xa56ce5(0xb4)][_0xa56ce5(0x12d)](_0x212254),this[_0xa56ce5(0x82)][_0xa56ce5(0x12d)](_0x212254);for(const _0x4e4971 of _0x1a70bf){this[_0xa56ce5(0xe6)][_0xa56ce5(0x12d)](_0x4e4971),this[_0xa56ce5(0xb7)][_0xa56ce5(0x12d)](_0x4e4971);}for(const [_0x38e4b1,_0x56c025]of this[_0xa56ce5(0xed)])if(_0x1a70bf[_0xa56ce5(0xd5)](_0x56c025))this[_0xa56ce5(0xed)][_0xa56ce5(0x12d)](_0x38e4b1);for(const [_0x4b64f3,_0x346712]of this[_0xa56ce5(0xc8)])if(_0x1a70bf[_0xa56ce5(0xd5)](_0x346712[_0xa56ce5(0xde)]))this[_0xa56ce5(0xc8)][_0xa56ce5(0x12d)](_0x4b64f3);}[_0x561507(0x9f)](_0x56c08a){const _0x5bba7e=_0x561507;if(this[_0x5bba7e(0xf3)](_0x56c08a))throw new Error(_0x5bba7e(0x9c));const _0x36faa9=new Set([...this[_0x5bba7e(0x102)][_0x5bba7e(0xd0)]()][_0x5bba7e(0x115)](_0x3e2774=>_0x3e2774[_0x5bba7e(0x7d)]===_0x56c08a)[_0x5bba7e(0x7a)](_0x40075c=>_0x40075c['id'])),_0x5eb98f=new Set([...this[_0x5bba7e(0xe6)][_0x5bba7e(0xd0)]()][_0x5bba7e(0x115)](_0x599dc6=>_0x599dc6[_0x5bba7e(0x7d)]===_0x56c08a)[_0x5bba7e(0x7a)](_0x3d3acc=>_0x3d3acc['id']));for(const _0x46d66d of _0x36faa9){this[_0x5bba7e(0x102)][_0x5bba7e(0x12d)](_0x46d66d),this[_0x5bba7e(0xe2)][_0x5bba7e(0x12d)](_0x46d66d);}for(const _0x39ffba of _0x5eb98f){this[_0x5bba7e(0xe6)][_0x5bba7e(0x12d)](_0x39ffba),this[_0x5bba7e(0xb7)][_0x5bba7e(0x12d)](_0x39ffba);}for(const [_0x3dae75,_0x10f832]of this[_0x5bba7e(0xed)])if(_0x5eb98f[_0x5bba7e(0xd5)](_0x10f832))this[_0x5bba7e(0xed)][_0x5bba7e(0x12d)](_0x3dae75);for(const [_0x48b51c,_0xeb6522]of this[_0x5bba7e(0xc8)])if(_0x5eb98f[_0x5bba7e(0xd5)](_0xeb6522[_0x5bba7e(0xde)]))this[_0x5bba7e(0xc8)][_0x5bba7e(0x12d)](_0x48b51c);for(const _0x168fbd of _0x36faa9){this[_0x5bba7e(0xf9)][_0x5bba7e(0x12d)](_0x168fbd),this[_0x5bba7e(0x121)][_0x5bba7e(0x12d)](_0x168fbd),this[_0x5bba7e(0xb4)][_0x5bba7e(0x12d)](_0x168fbd),this[_0x5bba7e(0x82)][_0x5bba7e(0x12d)](_0x168fbd);}}[_0x561507(0x9b)](_0x1f08e4,_0x23399e){void _0x1f08e4,void _0x23399e;}[_0x561507(0xef)](_0x15e984,_0x46f0f5){const _0x429ab3=_0x561507,_0xee6c8f=this[_0x429ab3(0xac)](_0x15e984),_0xd3dbbf={..._0xee6c8f,..._0x46f0f5};this[_0x429ab3(0x102)][_0x429ab3(0xcc)](_0x15e984,_0xd3dbbf);if(_0xee6c8f[_0x429ab3(0x99)]!==_0xd3dbbf[_0x429ab3(0x99)]||_0xee6c8f[_0x429ab3(0x110)]!==_0xd3dbbf[_0x429ab3(0x110)]){for(const _0x485dd1 of this[_0x429ab3(0x138)](_0x15e984))this[_0x429ab3(0x13c)]?.(_0x485dd1,_0xd3dbbf);}return _0xd3dbbf;}[_0x561507(0xc3)](_0xcdf14b){const _0x53d2ec=_0x561507;this[_0x53d2ec(0x121)][_0x53d2ec(0xcc)](_0xcdf14b,(this[_0x53d2ec(0x121)][_0x53d2ec(0xea)](_0xcdf14b)??-0x12bb+-0x10fd*0x1+0x23b8)+(-0xace*0x2+-0x169e+0x2c3b));}[_0x561507(0xac)](_0x23ae6f){const _0x7f79a3=_0x561507,_0x1c131a=this[_0x7f79a3(0x102)][_0x7f79a3(0xea)](_0x23ae6f);if(_0x1c131a===undefined)throw new Error(_0x7f79a3(0x120));return _0x1c131a;}[_0x561507(0xd9)](_0x41c1f9){const _0x211520=_0x561507,_0x3c29b0=this[_0x211520(0xe6)][_0x211520(0xea)](_0x41c1f9);if(_0x3c29b0===undefined)throw new Error(_0x211520(0x111));return _0x3c29b0;}[_0x561507(0xe0)](_0x126740){const _0x375711=_0x561507,_0x255fbb=this[_0x375711(0xc8)][_0x375711(0xea)](_0x126740);if(_0x255fbb===undefined)throw new Error(_0x375711(0xe7));return _0x255fbb;}[_0x561507(0x91)](_0x72158a,_0x22a4b8){const _0x17c7fb=_0x561507,_0x201b1b=this[_0x17c7fb(0xd9)](_0x72158a),_0x11d2ef=this[_0x17c7fb(0xe2)][_0x17c7fb(0xea)](_0x201b1b[_0x17c7fb(0x14c)])??[];this[_0x17c7fb(0xe2)][_0x17c7fb(0xcc)](_0x201b1b[_0x17c7fb(0x14c)],_0x11d2ef[_0x17c7fb(0x7a)](_0x1d20cb=>_0x1d20cb[_0x17c7fb(0xde)]===_0x72158a?_0x22a4b8(_0x1d20cb):_0x1d20cb));}[_0x561507(0x98)](_0x187d29){const _0x57205f=_0x561507,_0x19a568=this[_0x57205f(0xd9)](_0x187d29[_0x57205f(0xde)]);this[_0x57205f(0x91)](_0x187d29[_0x57205f(0xde)],_0x3b00b1=>{const _0x107f12=_0x57205f;if(_0x187d29[_0x107f12(0xdd)]===_0x107f12(0x70)&&isRecord(_0x187d29[_0x107f12(0x108)])&&typeof _0x187d29[_0x107f12(0x108)][_0x107f12(0x6b)]===_0x107f12(0x116)){const _0x56fd4d=typeof _0x187d29[_0x107f12(0x108)][_0x107f12(0x71)]===_0x107f12(0x116)&&_0x187d29[_0x107f12(0x108)][_0x107f12(0x71)][_0x107f12(0xd2)]<=-0x125*0x15+-0x11b6*0x1+0x2a17*0x1?_0x187d29[_0x107f12(0x108)][_0x107f12(0x71)]:undefined,_0x4f696b=_0x56fd4d===undefined?undefined:_0x187d29[_0x107f12(0xde)]+':'+_0x56fd4d,_0x9cd78e=_0x3b00b1[_0x107f12(0x90)]['at'](-(-0x12d6+-0x2651*-0x1+-0x137a*0x1)),_0x4f2d8b=_0x4f696b===undefined?_0x9cd78e?.[_0x107f12(0xcd)]===_0x107f12(0x106)&&activeConversationItem(_0x9cd78e[_0x107f12(0x68)])?_0x9cd78e:undefined:_0x3b00b1[_0x107f12(0x90)][_0x107f12(0xeb)](_0x3c0a95=>_0x3c0a95['id']===_0x4f696b&&_0x3c0a95[_0x107f12(0xcd)]===_0x107f12(0x106)),_0x1f376d=''+(_0x4f2d8b===undefined?'':readableText(_0x4f2d8b[_0x107f12(0x108)]))+_0x187d29[_0x107f12(0x108)][_0x107f12(0x6b)],_0x284bcf={'id':_0x4f2d8b?.['id']??_0x4f696b??_0x187d29[_0x107f12(0xde)]+_0x107f12(0x126)+_0x187d29[_0x107f12(0x105)],'sessionId':_0x19a568[_0x107f12(0x14c)],'turnId':_0x3b00b1['id'],'runId':_0x187d29[_0x107f12(0xde)],'parentItemId':null,'sourceSequence':_0x4f2d8b?.[_0x107f12(0x114)]??_0x187d29[_0x107f12(0x105)],'revision':_0x187d29[_0x107f12(0x105)],'kind':_0x107f12(0x106),'status':_0x107f12(0xd1),'payload':{'text':_0x1f376d,'format':_0x107f12(0xcf),'model':null},'startedAt':_0x4f2d8b?.[_0x107f12(0xfe)]??_0x187d29[_0x107f12(0x75)],'completedAt':null};return{..._0x3b00b1,'status':_0x107f12(0xc7),'startedAt':_0x3b00b1[_0x107f12(0xfe)]??_0x187d29[_0x107f12(0x75)],'items':_0x4f2d8b===undefined?[..._0x3b00b1[_0x107f12(0x90)],_0x284bcf]:_0x3b00b1[_0x107f12(0x90)][_0x107f12(0x7a)](_0x3bd6a9=>_0x3bd6a9['id']===_0x284bcf['id']?_0x284bcf:_0x3bd6a9)};}const _0x4681eb=conversationItemFromEvent(_0x187d29);if(_0x4681eb!==undefined){const _0x25f691=_0x3b00b1[_0x107f12(0x90)]['at'](-(-0x1*0x24c5+-0x8c3*0x2+0x364c)),_0x1cfa5a=_0x25f691?.[_0x107f12(0xcd)]===_0x107f12(0x106)&&activeConversationItem(_0x25f691[_0x107f12(0x68)])?_0x3b00b1[_0x107f12(0x90)][_0x107f12(0x7a)](_0x4d0acd=>_0x4d0acd['id']===_0x25f691['id']?{..._0x4d0acd,'status':_0x107f12(0x149),'completedAt':_0x187d29[_0x107f12(0x75)]}:_0x4d0acd):_0x3b00b1[_0x107f12(0x90)],_0x3a5e4f=_0x1cfa5a[_0x107f12(0xeb)](_0x2ed177=>_0x2ed177['id']===_0x187d29[_0x107f12(0xde)]+':'+_0x4681eb[_0x107f12(0x71)]),_0x406021=_0x4681eb[_0x107f12(0x68)],_0x5a7ea7={'id':_0x187d29[_0x107f12(0xde)]+':'+_0x4681eb[_0x107f12(0x71)],'sessionId':_0x19a568[_0x107f12(0x14c)],'turnId':_0x3b00b1['id'],'runId':_0x187d29[_0x107f12(0xde)],'parentItemId':null,'sourceSequence':_0x3a5e4f?.[_0x107f12(0x114)]??_0x187d29[_0x107f12(0x105)],'revision':(_0x3a5e4f?.[_0x107f12(0x83)]??-(0x430+0x322+-0x751*0x1))+(0x103f+0x3d*-0x1f+0x1*-0x8db),'kind':_0x4681eb[_0x107f12(0xcd)],'status':_0x406021,'payload':mergeConversationItemPayload(_0x3a5e4f?.[_0x107f12(0x108)],_0x4681eb),'startedAt':_0x3a5e4f?.[_0x107f12(0xfe)]??_0x187d29[_0x107f12(0x75)],'completedAt':completedConversationItem(_0x406021)?_0x187d29[_0x107f12(0x75)]:null};return{..._0x3b00b1,'status':terminal(_0x19a568[_0x107f12(0x68)])?_0x19a568[_0x107f12(0x68)]:_0x107f12(0xc7),'startedAt':_0x3b00b1[_0x107f12(0xfe)]??_0x187d29[_0x107f12(0x75)],'items':_0x3a5e4f===undefined?[..._0x1cfa5a,_0x5a7ea7]:_0x1cfa5a[_0x107f12(0x7a)](_0x50d328=>_0x50d328['id']===_0x5a7ea7['id']?_0x5a7ea7:_0x50d328)};}if(_0x187d29[_0x107f12(0xdd)]===_0x107f12(0xdf)||_0x187d29[_0x107f12(0xdd)]===_0x107f12(0x14d))return{..._0x3b00b1,'status':_0x107f12(0xc7),'startedAt':_0x3b00b1[_0x107f12(0xfe)]??_0x187d29[_0x107f12(0x75)]};if(_0x187d29[_0x107f12(0xdd)]===_0x107f12(0x100)||_0x187d29[_0x107f12(0xdd)]===_0x107f12(0xfc)||_0x187d29[_0x107f12(0xdd)]===_0x107f12(0xa3))return{..._0x3b00b1,'status':this[_0x107f12(0xd9)](_0x187d29[_0x107f12(0xde)])[_0x107f12(0x68)],'completedAt':_0x187d29[_0x107f12(0x75)],'items':_0x3b00b1[_0x107f12(0x90)][_0x107f12(0x7a)](_0x1daddd=>activeConversationItem(_0x1daddd[_0x107f12(0x68)])?{..._0x1daddd,'status':completedStatusForRun(this[_0x107f12(0xd9)](_0x187d29[_0x107f12(0xde)])[_0x107f12(0x68)]),'completedAt':_0x187d29[_0x107f12(0x75)]}:_0x1daddd)};return _0x3b00b1;});}}function terminal(_0x1bffcf){const _0x17723e=_0x561507;return[_0x17723e(0x12e),_0x17723e(0x6f),_0x17723e(0xd8),_0x17723e(0x12b),_0x17723e(0x142)][_0x17723e(0x6c)](_0x1bffcf);}function terminalTurn(_0x41437d){const _0x5286b8=_0x561507;return[_0x5286b8(0x12e),_0x5286b8(0x6f),_0x5286b8(0xd8),_0x5286b8(0x12b),_0x5286b8(0x142)][_0x5286b8(0x6c)](_0x41437d);}function transitionAllowed(_0x182e5d,_0x2ebafb){return!terminal(_0x182e5d)||_0x182e5d===_0x2ebafb;}function isRecord(_0x99f3f2){const _0x97049f=_0x561507;return typeof _0x99f3f2===_0x97049f(0x146)&&_0x99f3f2!==null;}function readableText(_0x496544){const _0x50efb4=_0x561507;return isRecord(_0x496544)&&typeof _0x496544[_0x50efb4(0x6b)]===_0x50efb4(0x116)?_0x496544[_0x50efb4(0x6b)]:'';}function conversationItemFromEvent(_0x39a8d2){const _0x316058=_0x561507;if(_0x39a8d2[_0x316058(0xdd)]!==_0x316058(0xd7)||!isRecord(_0x39a8d2[_0x316058(0x108)]))return undefined;const _0x18891e=_0x39a8d2[_0x316058(0x108)][_0x316058(0x71)],_0x3a0b21=_0x39a8d2[_0x316058(0x108)][_0x316058(0xcd)],_0x4bdb6b=_0x39a8d2[_0x316058(0x108)][_0x316058(0x68)],_0x4e33ed=_0x39a8d2[_0x316058(0x108)][_0x316058(0x108)];if(typeof _0x18891e!==_0x316058(0x116)||_0x18891e[_0x316058(0xd2)]===0x9bf*0x1+0xb42+-0x1501||_0x18891e[_0x316058(0xd2)]>0x274*0x6+0x235f+0x9*-0x587||typeof _0x3a0b21!==_0x316058(0x116)||!projectableConversationKind(_0x3a0b21)||typeof _0x4bdb6b!==_0x316058(0x116)||!projectableConversationStatus(_0x4bdb6b)||!isRecord(_0x4e33ed))return undefined;const _0x220206=_0x39a8d2[_0x316058(0x108)][_0x316058(0x86)];return{'itemId':_0x18891e,'kind':_0x3a0b21,'status':_0x4bdb6b,'payload':_0x4e33ed,'merge':_0x39a8d2[_0x316058(0x108)][_0x316058(0x10d)]===!![],..._0x220206===_0x316058(0x104)||_0x220206===_0x316058(0xc4)||_0x220206===_0x316058(0x145)?{'append':_0x220206}:{}};}function projectableConversationKind(_0x249021){const _0x4a0107=_0x561507;return _0x249021===_0x4a0107(0x106)||_0x249021===_0x4a0107(0x122)||_0x249021===_0x4a0107(0x87)||_0x249021===_0x4a0107(0x124)||_0x249021===_0x4a0107(0xc0)||_0x249021===_0x4a0107(0xe5)||_0x249021===_0x4a0107(0x12a)||_0x249021===_0x4a0107(0x139)||_0x249021===_0x4a0107(0xc1)||_0x249021===_0x4a0107(0x78)||_0x249021===_0x4a0107(0x10f);}function _0x589c(){const _0x556b15=['DMvYC2LVBG','q09nueXfveve','CxvLDwvKtwvZC2fNzvrLEhq','BM9KzuLK','C2vZC2LVBKLK','CNvUlNj1BM5PBMC','C2v0vgvTCg9Yyxj5vgL0BgvjzK1PC3nPBMC','CNvUBMvY','C3rHDhvZ','C3rHCNrZv2L0Aa','y2XPzw50twvZC2fNzuLK','Dgv4Da','Aw5JBhvKzxm','CMvTB3zLvgvYBwLUywXsDw4','BgLZDe5VBNrLCM1PBMfSuNvUCW','rKfjteve','Dgv4Dc5KzwX0yq','AxrLBuLK','z2v0qxbWCM92ywW','CMvZDw1Lu2vZC2LVBLf1zxvL','uevoreLorW','y3jLyxrLzef0','qvbquK9wquXFrvHqsvjfra','DxrMoa','D2fYBMLUzW','Aw5KzxG','BwfW','y29UDgvUDa','z2v0uNvU','D29YA3nWywnLswq','BgLTAxq','zxHWAxjLC0f0','Aw5PDgLHDgvKqNLvC2vYswq','tufsx01btKfhruq','BgvHC2vZ','CMv2AxnPB24','y3jLyxrLqxbWCM92ywW','uLvox1nuqvrfx0LovKfmsuq','yxbWzw5K','Dg9VBf9JywXS','qvbquK9wquXFquXsrufewv9erunjreve','odaYndyXy25lALzO','zgvJAwrLqxbWCM92ywW','BwLU','zxHWAxjLqxbWCM92ywW','C3rYAw5NAwz5','qvvutW','zxHWAxjLrhvLqxbWCM92ywXZ','AxrLBxm','DxbKyxrLvhvYBKzVCLj1BG','yxr0ywnOBwvUDhm','ywnJzxnZ','y29TCgXLDgvKqxq','mLH3A3fIzW','mta1nJG4mtHXwu9AEe8','DxnLCL9TzxnZywDL','ChjVAMvJDev2zw50','y3vZDg9TvgL0Bgu','y29TBwfUza','CMvJB25JAwXLuNvU','v09ss1nqqunfx0jvu1K','BgLZDenVBNzLCNnHDgLVBLr1CM5Z','y2XHAw1ozxH0uxvLDwvKuNvU','CMvTB3zLv29YA3nWywnL','DgvYBwLUywXsDw5jzhm','BNvTyMvY','uLvotKvs','CNvUlNjLAMvJDgvK','u0vtu0LptL9fwfrfuK5btf9jrf9jtLzbteLe','CMvJB3jKq29TBwfUzev4zwn1DgLVBG','DgL0Bgu','og9ysKXltq','mJCZmJa2DNPougnJ','C29YDa','rvzftLrFu0vrvuvoq0vFr0fq','C2v0q2HHBM5LBfrVA2vU','CMvXDwLYzvnLC3nPB24','C2v0tMf0AxzLq29UDhjVBa','CMvVCMrLCLnLC3nPB25rDwv1zq','CMvWBgfJzq','zMXHDe1HCa','qvbquK9wquXFtK9ux0vyueLsruq','mte0mdKWAwvcCLzb','v09ss1nqqunfx05pvf9gt1vora','Cgf1C2vKuxvLDwvZ','mteYotHrswzLzKq','ywn0AxzLv29YA3nWywnLtgvHC2vdB3vUDa','CNvUu2vXDwvUy2vZ','BgfZDefJDgL2Axr5qxq','Bw9KzwW','BgLZDefNzw50u2vZC2LVBNm','mZz3D3f4z1i','tufyx0nptvbmrvrfrf9uvvjou19qrvjFu0vtu0LptG','CgLUBMvKqxq','yxbWCM92ywXjza','nZe1ody5C09eCg52','DxnLCL9PBNb1Df9Yzxf1zxn0','Dw5RBM93BG','AxnrDwv1zwrsDw4','yNvTCff1zxvLvMvYC2LVBG','B3v0Chv0uhjLDMLLDW','u0vtu0LptL9jrf9dt05gteLdva','uLvox0fdveLwrq','uLvotKLorW','yxbWCM92ywXZ','AgfZqwn0AxzLu2vZC2LVBKXLyxnL','ywrVChrsDw4','C2vZC2LVBLf1zxvL','C2v0','A2LUza','m1Dss05qva','BwfYA2rVD24','DMfSDwvZ','su5Fufjpr1jfu1m','BgvUz3rO','u0vtu0LptL9bq1rjvKu','ywrK','AgfZ','rvHurvjoquW','y29UDMvYC2f0Aw9UlML0zw0','q0foq0vmteve','CMvXDwLYzvj1BG','C29Tzq','BgfZDfj1BLnLCxvLBMnL','BMv4Da','zxzLBNruExbL','CNvUswq','CNvUlNn0yxj0zwq','CMvXDwLYzufWChjVDMfS','uvvfvuvFsvrftv9jtLzbteLe','DhvYBNm','C2v0rxH0zxjUywXtzxnZAw9Uswq','y3vYC29Y','CgXHBG','CNvUCW','qvbquK9wquXFtK9ux0zpvu5e','BgLZDefWChjVDMfSCW','zwzMB3j0','z2v0','zMLUza','z2v0v29YA3nWywnL','BwvZC2fNzvj1BNm','z2v0qwDLBNrtzxnZAw9U','CMvWBgfJzvnLC3nPB24','DxbKyxrLuxvLDwvKtwvZC2fNzq','yNL0zuXLBMD0Aa','CNvUDgLTztO','AgfZqwn0AxzLv29YA3nWywnLtgvHC2u','ChjPB3jPDgL6zvf1zxvLzfj1BG','CgfYC2u','DMfSDwu','uLvox1rfuK1jtKfm','Bwf4','CxvLDwvKuNvUCW','yxbWzw5KuNvUrxzLBNq','qunusvzf','CNvUlMzHAwXLza','AxnjBNrLz2vY','C3rHCNrLzef0','DhvYBG','CNvUlMnVBxbSzxrLza','u0vtu0LptL9dsefotKvmx1rps0vox0LovKfmsuq','C2vZC2LVBNm','ywn0AxzLu2vZC2LVBLj1BG','C2vJDgLVBNm','C2vXDwvUy2u','yxnZAxn0yw50x21LC3nHz2u','DhjHBNnPDgLVBLj1BG','Cgf5Bg9Hza','BM93','zxH0zxjUywXtzxnZAw9Uswq','qvbquK9wquXFquXsrufewv9fweLtvfm','zMLUzefNzw50u2vZC2LVBKj5rxH0zxjUywXtzxnZAw9U','BwvYz2u','rvHqsvjfra','zxjYB3i','CNvUBMvYvgL0Bgu','uLvox05pvf9gt1vora','q1vtve9n','y3jLyxrLtwvZC2fNzvj1BG','C291CMnLu2vXDwvUy2u','zMLSDgvY','C3rYAw5N','C2nVCgu','C2v0uNvUBMvYvgL0BgvgCM9TtMf0AxzL','AxnbCNjHEq','DxnLCKL0zw1jza','u0vtu0LptL9usvrmrv9jtLzbteLe','Dg9tDhjPBMC','Cgf1C2vtzxnZAw9UuxvLDwu','zMfPBgvK','C2L6zq','u0vtu0LptL9ot1rFrK9vtKq','CxvLDwvwzxjZAw9UCW','CMvHC29UAw5Nx3n1Bw1HCNK','nJy1rLnPwuv1','y29TBwfUzf9LEgvJDxrPB24','Aw1Hz2uV','oMfZC2LZDgfUDdO','oxPRwxDLtq','BMf0AxzLq29UDhjVBa','yMfZzty0DxjS','zMLSzv9JAgfUz2u','su5urvjsvvburuq','uvvfvuve','zgvSzxrL','u1vdq0vfreve','ChjVBw90zvnLC3nPB25jzgvUDgL0Eq','CMvTB3zLqwDLBNrtzxnZAw9U','qundrvburuq','uvvfvuvFvKvsu0LptL9dt05gteLdva','DhjPBq','zMLUze1LC3nHz2vsDw4','revdteLoruq','zgvSzxrLuxvLDwvKuNvU','otmXmdm2tg56wKrL','BgLZDfj1BNngB3jtzxnZAw9U','y29UDgv4Df9JB21Wywn0Aw9U','y29UDMvYC2f0Aw9UvhvYBKzVCLj1BG','C2XPy2u','B25sDw5dAgfUz2vK','y3DK','CgLUBMvK','BgLZDenVBNzLCNnHDgLVBKL0zw1Z','DxbKyxrLu2vZC2LVBK1LDgfKyxrH','yMfZzty0','te9tva','y3jLyxrLqwDLBNrtzxnZAw9U','zNjVBq','B3v0Chv0u3vTBwfYEq','B2jQzwn0','DxbKyxrLqwDLBNrtzxnZAw9Uq29UzMLNDxjHDgLVBG'];_0x589c=function(){return _0x556b15;};return _0x589c();}function projectableConversationStatus(_0x161261){const _0x1122f9=_0x561507;return[_0x1122f9(0x74),_0x1122f9(0xd1),_0x1122f9(0x149),_0x1122f9(0x6f),_0x1122f9(0x135),_0x1122f9(0xd8),_0x1122f9(0x12b)][_0x1122f9(0x6c)](_0x161261);}function mergeConversationItemPayload(_0x262ba3,_0x3ec8bf){const _0x4df410=_0x561507,_0x2f28aa=_0x3ec8bf[_0x4df410(0x10d)]&&isRecord(_0x262ba3)?_0x262ba3:{},_0x82bf7e={..._0x2f28aa,..._0x3ec8bf[_0x4df410(0x108)]};if(_0x3ec8bf[_0x4df410(0x86)]===_0x4df410(0x104)){const _0x412b9e=Array[_0x4df410(0x119)](_0x2f28aa[_0x4df410(0x104)])?_0x2f28aa[_0x4df410(0x104)]:[],_0x2bae12=Array[_0x4df410(0x119)](_0x3ec8bf[_0x4df410(0x108)][_0x4df410(0x104)])?_0x3ec8bf[_0x4df410(0x108)][_0x4df410(0x104)]:[],_0x109c64=new Map();for(const _0x1e4a4d of[..._0x412b9e,..._0x2bae12]){if(!isRecord(_0x1e4a4d)||typeof _0x1e4a4d[_0x4df410(0x79)]!==_0x4df410(0xa1)||!Number[_0x4df410(0xfd)](_0x1e4a4d[_0x4df410(0x79)])||_0x1e4a4d[_0x4df410(0x79)]<-0x95*-0x37+-0x979*-0x1+-0x127*0x24||typeof _0x1e4a4d[_0x4df410(0x6b)]!==_0x4df410(0x116))continue;_0x109c64[_0x4df410(0xcc)](_0x1e4a4d[_0x4df410(0x79)],appendProjectionText(_0x109c64[_0x4df410(0xea)](_0x1e4a4d[_0x4df410(0x79)])??'',_0x1e4a4d[_0x4df410(0x6b)]));}_0x82bf7e[_0x4df410(0x104)]=[..._0x109c64][_0x4df410(0xa9)](([_0x52f3de],[_0x454218])=>_0x52f3de-_0x454218)[_0x4df410(0x7a)](([_0x40534a,_0xf55c8])=>({'index':_0x40534a,'text':_0xf55c8}));}if(_0x3ec8bf[_0x4df410(0x86)]===_0x4df410(0xc4)){const _0x461de7=typeof _0x2f28aa[_0x4df410(0xc4)]===_0x4df410(0x116)?_0x2f28aa[_0x4df410(0xc4)]:'',_0x1be938=typeof _0x3ec8bf[_0x4df410(0x108)][_0x4df410(0xc4)]===_0x4df410(0x116)?_0x3ec8bf[_0x4df410(0x108)][_0x4df410(0xc4)]:'';_0x82bf7e[_0x4df410(0xc4)]=appendProjectionText(_0x461de7,_0x1be938);}if(_0x3ec8bf[_0x4df410(0x86)]===_0x4df410(0x145)){const _0x44c591=typeof _0x2f28aa[_0x4df410(0x145)]===_0x4df410(0x116)?_0x2f28aa[_0x4df410(0x145)]:'',_0x434bf5=typeof _0x3ec8bf[_0x4df410(0x108)][_0x4df410(0x145)]===_0x4df410(0x116)?_0x3ec8bf[_0x4df410(0x108)][_0x4df410(0x145)]:'';_0x82bf7e[_0x4df410(0x145)]=appendProjectionText(_0x44c591,_0x434bf5);}return _0x82bf7e;}function appendProjectionText(_0x1110f3,_0x4fe56b){const _0x9824fa=_0x561507,_0x4b8d36=''+_0x1110f3+_0x4fe56b;return _0x4b8d36[_0x9824fa(0xd2)]<=0x1e32+0x1*0x3e36+0x6*-0x8e4?_0x4b8d36:_0x4b8d36[_0x9824fa(0x13b)](-0x118d+-0x2*-0xb8d+0x7*-0xcb,-0x3bc3+-0x33fc+0x96ce)+'…';}function activeConversationItem(_0x1f4906){const _0x9eaa37=_0x561507;return _0x1f4906===_0x9eaa37(0x74)||_0x1f4906===_0x9eaa37(0xd1);}function completedConversationItem(_0x5e6907){return!activeConversationItem(_0x5e6907);}function completedStatusForRun(_0x376094){const _0x3c1a4c=_0x561507;if(_0x376094===_0x3c1a4c(0x12b))return _0x3c1a4c(0x12b);if(_0x376094===_0x3c1a4c(0xd8))return _0x3c1a4c(0xd8);if(_0x376094===_0x3c1a4c(0x6f))return _0x3c1a4c(0x6f);return _0x3c1a4c(0x149);}function encodeCursor(_0x10ac8b,_0x1cd1af){const _0xc5e6ec=_0x561507;return Buffer[_0xc5e6ec(0x144)](JSON[_0xc5e6ec(0x8d)]({'scope':_0x10ac8b,'value':_0x1cd1af}))[_0xc5e6ec(0x11c)](_0xc5e6ec(0x129));}function decodeCursor(_0x477b73,_0x30baa5){const _0x12229c=_0x561507;if(_0x477b73===undefined)return 0xad5+-0x1*-0x412+-0xee7;try{const _0x465811=JSON[_0x12229c(0xf5)](Buffer[_0x12229c(0x144)](_0x477b73,_0x12229c(0x129))[_0x12229c(0x11c)](_0x12229c(0x77)));return _0x465811[_0x12229c(0x117)]===_0x30baa5&&Number[_0x12229c(0xfd)](_0x465811[_0x12229c(0xf6)])&&_0x465811[_0x12229c(0xf6)]>=0x1e+0xb41+-0xb5f?_0x465811[_0x12229c(0xf6)]:-0x527+0xdf8+-0x8d1;}catch{return-0x191d*0x1+-0x1c3b+0x3558;}}