@myagentroam/node 0.9.8 → 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 (213) 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 -841
  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 -973
  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 -83
  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 -0
  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 -93
  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 -169
  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 -35
  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/run-attachment-service.d.ts +0 -38
  170. package/dist/service/run-domain-state.d.ts +0 -4
  171. package/dist/service/run-event-service.d.ts +0 -33
  172. package/dist/service/run-workbench-service.d.ts +0 -25
  173. package/dist/service/runner-channel-message-service.d.ts +0 -13
  174. package/dist/service/runner-interaction-service.d.ts +0 -39
  175. package/dist/service/runner-service.d.ts +0 -46
  176. package/dist/service/session-catalog-service.d.ts +0 -45
  177. package/dist/service/session-command-service.d.ts +0 -24
  178. package/dist/service/session-context-service.d.ts +0 -35
  179. package/dist/service/session-domain-state.d.ts +0 -9
  180. package/dist/service/session-identity-service.d.ts +0 -24
  181. package/dist/service/session-lifecycle-service.d.ts +0 -31
  182. package/dist/service/session-message-service.d.ts +0 -33
  183. package/dist/service/session-presentation-service.d.ts +0 -34
  184. package/dist/service/session-query-service.d.ts +0 -35
  185. package/dist/service/skill-directory-service.d.ts +0 -20
  186. package/dist/service/skill-install-service.d.ts +0 -21
  187. package/dist/service/skill-node-operation-service.d.ts +0 -44
  188. package/dist/service/terminal-relay-state.d.ts +0 -6
  189. package/dist/service/terminal-service.d.ts +0 -12
  190. package/dist/service/workbench-event-service.d.ts +0 -9
  191. package/dist/service/workbench-manifest-service.d.ts +0 -90
  192. package/dist/service/workspace-change-service.d.ts +0 -9
  193. package/dist/service/workspace-content-search-service.d.ts +0 -14
  194. package/dist/service/workspace-domain-state.d.ts +0 -79
  195. package/dist/service/workspace-file-service.d.ts +0 -18
  196. package/dist/service/workspace-git-exclude-service.d.ts +0 -4
  197. package/dist/service/workspace-queue-workbench-service.d.ts +0 -86
  198. package/dist/service/workspace-service.d.ts +0 -15
  199. package/dist/service/workspace-session-service.d.ts +0 -23
  200. package/dist/service/workspace-upload-service.d.ts +0 -39
  201. package/dist/service/workspace-watch-service.d.ts +0 -23
  202. package/dist/service/workspace-workbench-service.d.ts +0 -58
  203. package/dist/service.d.ts +0 -4
  204. package/dist/storage.d.ts +0 -2
  205. package/dist/supervisor.d.ts +0 -1
  206. package/dist/terminal.d.ts +0 -133
  207. package/dist/util/node-operation-parsers.d.ts +0 -92
  208. package/dist/util/personal-instructions.d.ts +0 -2
  209. package/dist/util/runner-error.d.ts +0 -6
  210. package/dist/util/runner-native-session-parsers.d.ts +0 -74
  211. package/dist/util/safe-error.d.ts +0 -2
  212. package/dist/util/secret-environment.d.ts +0 -1
  213. package/dist/workspace.d.ts +0 -217
@@ -1,383 +1,2 @@
1
- import { isPlainRecord } from '../runner/codex/conversation-parser.js';
2
- const INTERVAL_MS = 2_000;
3
- const TTL_MS = 45_000;
4
- const MAX_FAILURES = 3;
5
- const INITIAL_TURN_LIMIT = 30;
6
- const EMITTED_TURN_LIMIT = 10;
7
- export class NativeSessionWatchService {
8
- options;
9
- watches = new Map();
10
- leases = new Map();
11
- snapshotSequence = 0;
12
- constructor(options) {
13
- this.options = options;
14
- }
15
- operations() {
16
- return {
17
- 'session.watch': (data) => this.executeWatch(isPlainRecord(data) ? data : {}),
18
- 'session.unwatch': (data) => this.executeUnwatch(isPlainRecord(data) ? data : {})
19
- };
20
- }
21
- async executeWatch(input) {
22
- const projectInitialPage = this.options.projectInitialPage;
23
- if (input.unit === 'SEGMENT' && projectInitialPage === undefined)
24
- throw new Error('SESSION_INVALID');
25
- if (typeof input.sessionId !== 'string' ||
26
- (input.workspaceId !== undefined && typeof input.workspaceId !== 'string') ||
27
- typeof input.watchId !== 'string' ||
28
- typeof input.workbenchConnectionId !== 'string' ||
29
- (input.mode !== 'initial' && input.mode !== 'renew') ||
30
- (input.unit !== undefined && input.unit !== 'SEGMENT'))
31
- throw new Error('SESSION_INVALID');
32
- const ownerKey = this.ownerKey(input);
33
- if (input.mode === 'renew') {
34
- const lease = this.leases.get(ownerKey);
35
- if (lease === undefined ||
36
- lease.watchId !== input.watchId ||
37
- lease.sessionId !== input.sessionId ||
38
- (input.workspaceId !== undefined && lease.workspaceId !== input.workspaceId))
39
- throw new Error('SESSION_WATCH_NOT_FOUND');
40
- if (lease.expiresAt <= Date.now()) {
41
- this.removeLease(ownerKey);
42
- throw new Error('SESSION_WATCH_NOT_FOUND');
43
- }
44
- lease.expiresAt = Date.now() + TTL_MS;
45
- const observer = this.watches.get(lease.sessionId);
46
- if (observer !== undefined)
47
- observer.expiresAt = this.latestLeaseExpiry(lease.sessionId);
48
- clearTimeout(lease.timer);
49
- lease.timer = this.leaseTimer(ownerKey);
50
- return this.accepted(lease);
51
- }
52
- const existing = this.leases.get(ownerKey);
53
- const unit = input.unit === 'SEGMENT' ? 'SEGMENT' : 'TURN';
54
- if (existing?.watchId === input.watchId &&
55
- existing.sessionId === input.sessionId &&
56
- (input.workspaceId === undefined || existing.workspaceId === input.workspaceId) &&
57
- existing.unit === unit &&
58
- existing.expiresAt > Date.now()) {
59
- existing.expiresAt = Date.now() + TTL_MS;
60
- clearTimeout(existing.timer);
61
- existing.timer = this.leaseTimer(ownerKey);
62
- return this.accepted(existing);
63
- }
64
- this.removeLease(ownerKey);
65
- const lease = {
66
- ownerKey,
67
- sessionHash: this.sessionHash(input),
68
- workbenchConnectionId: input.workbenchConnectionId,
69
- watchId: input.watchId,
70
- sessionId: input.sessionId,
71
- unit,
72
- nodeGeneration: this.options.nodeGeneration?.() ?? 'local-test-generation',
73
- ...(typeof input.workspaceId === 'string' ? { workspaceId: input.workspaceId } : {}),
74
- expiresAt: Date.now() + TTL_MS,
75
- timer: undefined
76
- };
77
- lease.timer = this.leaseTimer(ownerKey);
78
- this.leases.set(ownerKey, lease);
79
- const observer = this.watches.get(lease.sessionId);
80
- if (observer !== undefined)
81
- observer.expiresAt = this.latestLeaseExpiry(lease.sessionId);
82
- void this.initializeLease(lease, projectInitialPage);
83
- return this.accepted(lease);
84
- }
85
- executeUnwatch(input) {
86
- if (typeof input.sessionId !== 'string' ||
87
- typeof input.watchId !== 'string' ||
88
- typeof input.workbenchConnectionId !== 'string')
89
- throw new Error('SESSION_INVALID');
90
- const ownerKey = this.ownerKey(input);
91
- const lease = this.leases.get(ownerKey);
92
- if (lease?.watchId === input.watchId && lease.sessionId === input.sessionId)
93
- this.removeLease(ownerKey);
94
- return { stopped: true };
95
- }
96
- watch(session) {
97
- if (this.options.managedActive(session)) {
98
- this.stop(session.id);
99
- return undefined;
100
- }
101
- const existing = this.watches.get(session.id);
102
- if (existing !== undefined) {
103
- existing.expiresAt = Date.now() + TTL_MS;
104
- return { expiresAt: existing.expiresAt };
105
- }
106
- const watch = {
107
- expiresAt: Date.now() + TTL_MS,
108
- refresh: undefined,
109
- sessionSignature: undefined,
110
- signature: undefined,
111
- page: undefined,
112
- observedPage: undefined,
113
- authority: undefined,
114
- failures: 0,
115
- timer: undefined
116
- };
117
- watch.timer = this.refreshTimer(session.id);
118
- this.watches.set(session.id, watch);
119
- return { expiresAt: watch.expiresAt };
120
- }
121
- renew(session) {
122
- if (this.options.managedActive(session)) {
123
- this.stop(session.id);
124
- return undefined;
125
- }
126
- const watch = this.watches.get(session.id);
127
- if (watch === undefined || watch.expiresAt <= Date.now()) {
128
- this.stop(session.id);
129
- return undefined;
130
- }
131
- watch.expiresAt = Date.now() + TTL_MS;
132
- return { expiresAt: watch.expiresAt };
133
- }
134
- stop(sessionId) {
135
- const watch = this.watches.get(sessionId);
136
- if (watch === undefined)
137
- return;
138
- clearTimeout(watch.timer);
139
- this.watches.delete(sessionId);
140
- }
141
- clear() {
142
- for (const watch of this.watches.values())
143
- clearTimeout(watch.timer);
144
- this.watches.clear();
145
- for (const lease of this.leases.values())
146
- clearTimeout(lease.timer);
147
- this.leases.clear();
148
- }
149
- has(sessionId) {
150
- return this.watches.has(sessionId);
151
- }
152
- entry(sessionId) {
153
- return this.watches.get(sessionId);
154
- }
155
- get size() {
156
- return this.watches.size;
157
- }
158
- async refresh(sessionId, limit = 10, emit = true) {
159
- const watch = this.watches.get(sessionId);
160
- if (watch === undefined)
161
- return undefined;
162
- if (watch.refresh !== undefined)
163
- return watch.refresh;
164
- if (watch.expiresAt <= Date.now()) {
165
- this.stop(sessionId);
166
- return undefined;
167
- }
168
- const refresh = this.performRefresh(sessionId, watch, limit, emit);
169
- watch.refresh = refresh;
170
- try {
171
- return await refresh;
172
- }
173
- finally {
174
- if (this.watches.get(sessionId) === watch) {
175
- watch.refresh = undefined;
176
- clearTimeout(watch.timer);
177
- watch.timer = this.refreshTimer(sessionId);
178
- }
179
- }
180
- }
181
- async performRefresh(sessionId, watch, limit, emit) {
182
- try {
183
- if (this.options.suspended?.(sessionId) === true)
184
- return watch.page;
185
- const session = await this.options.resolve(sessionId);
186
- if (session === undefined ||
187
- session.externalSessionId === null ||
188
- this.options.managedActive(session)) {
189
- this.releaseSessionLeases(sessionId);
190
- return undefined;
191
- }
192
- await this.options.refreshActivity(session);
193
- if (this.options.suspended?.(sessionId) === true)
194
- return watch.page;
195
- const presented = this.options.present(session);
196
- const sessionSignature = JSON.stringify(presented);
197
- if (sessionSignature !== watch.sessionSignature) {
198
- watch.sessionSignature = sessionSignature;
199
- this.options.emitSession(presented);
200
- }
201
- const page = await this.options.readPage(session, limit);
202
- watch.failures = 0;
203
- const turns = page.turns.length <= EMITTED_TURN_LIMIT
204
- ? page.turns
205
- : page.turns.slice(-EMITTED_TURN_LIMIT);
206
- const observed = { ...page, turns };
207
- const convergence = this.options.convergePage(watch.page, watch.observedPage, observed, watch.authority);
208
- const converged = convergence.page;
209
- const accepted = converged.turns.length <= EMITTED_TURN_LIMIT + 1
210
- ? converged
211
- : {
212
- ...converged,
213
- turns: converged.turns.slice(-(EMITTED_TURN_LIMIT + 1))
214
- };
215
- watch.observedPage = observed;
216
- watch.authority = convergence.authority;
217
- const signature = JSON.stringify({ source: accepted.source, turns: accepted.turns });
218
- if (signature === watch.signature)
219
- return accepted;
220
- watch.signature = signature;
221
- watch.page = accepted;
222
- if (emit)
223
- this.emitObservedPage(session, accepted);
224
- return emit ? accepted : page;
225
- }
226
- catch {
227
- watch.failures += 1;
228
- if (watch.failures >= MAX_FAILURES)
229
- this.failSession(sessionId);
230
- return undefined;
231
- }
232
- }
233
- sessionHash(input) {
234
- return typeof input.__workspaceWatchSessionHash === 'string'
235
- ? input.__workspaceWatchSessionHash
236
- : 'local-test';
237
- }
238
- ownerKey(input) {
239
- return `${this.sessionHash(input)}:${input.workbenchConnectionId}`;
240
- }
241
- accepted(lease) {
242
- return {
243
- accepted: true,
244
- watchId: lease.watchId,
245
- nodeGeneration: lease.nodeGeneration,
246
- expiresAt: lease.expiresAt
247
- };
248
- }
249
- async initializeLease(lease, projectInitialPage) {
250
- try {
251
- const session = await this.options.resolve(lease.sessionId);
252
- if (session === undefined || session.externalSessionId === null)
253
- throw new Error('SESSION_NOT_FOUND');
254
- if (lease.workspaceId !== undefined && session.workspaceId !== lease.workspaceId)
255
- throw new Error('SESSION_WORKSPACE_MISMATCH');
256
- if (this.leases.get(lease.ownerKey) !== lease)
257
- return;
258
- lease.workspaceId = session.workspaceId;
259
- const watch = this.watch(session);
260
- const page = watch === undefined ? undefined : await this.refresh(session.id, INITIAL_TURN_LIMIT, false);
261
- if (page === undefined)
262
- throw new Error('NATIVE_TRANSCRIPT_UNAVAILABLE');
263
- const payload = lease.unit === 'SEGMENT' ? projectInitialPage(session, page, 'SEGMENT', 10) : page;
264
- if (this.leases.get(lease.ownerKey) !== lease)
265
- return;
266
- this.options.emitWatchEvent?.({
267
- type: 'watch.session.snapshot',
268
- workbenchConnectionId: lease.workbenchConnectionId,
269
- watchId: lease.watchId,
270
- nodeGeneration: lease.nodeGeneration,
271
- nodeId: this.options.nodeId?.() ?? 'local-test-node',
272
- workspaceId: session.workspaceId,
273
- sessionId: session.id,
274
- revision: 1,
275
- snapshotSequence: ++this.snapshotSequence,
276
- expiresAt: lease.expiresAt,
277
- payload
278
- });
279
- }
280
- catch (error) {
281
- if (this.leases.get(lease.ownerKey) !== lease)
282
- return;
283
- this.options.emitWatchEvent?.({
284
- type: 'watch.failed',
285
- workbenchConnectionId: lease.workbenchConnectionId,
286
- watchType: 'session',
287
- watchId: lease.watchId,
288
- nodeGeneration: lease.nodeGeneration,
289
- nodeId: this.options.nodeId?.() ?? 'local-test-node',
290
- workspaceId: lease.workspaceId ?? 'unknown',
291
- sessionId: lease.sessionId,
292
- code: error instanceof Error && /^[A-Z][A-Z0-9_]+$/.test(error.message)
293
- ? error.message
294
- : 'SESSION_WATCH_SNAPSHOT_FAILED',
295
- message: 'Session watch snapshot failed.'
296
- });
297
- this.removeLease(lease.ownerKey);
298
- }
299
- }
300
- removeLease(ownerKey) {
301
- const lease = this.leases.get(ownerKey);
302
- if (lease === undefined)
303
- return;
304
- clearTimeout(lease.timer);
305
- this.leases.delete(ownerKey);
306
- const observer = this.watches.get(lease.sessionId);
307
- const nextExpiry = this.latestLeaseExpiry(lease.sessionId);
308
- if (nextExpiry === 0)
309
- this.stop(lease.sessionId);
310
- else if (observer !== undefined)
311
- observer.expiresAt = nextExpiry;
312
- }
313
- emitObservedPage(session, page) {
314
- const leases = [...this.leases.values()].filter((lease) => lease.sessionId === session.id);
315
- if (leases.length === 0) {
316
- this.options.emitPage(session, page);
317
- return;
318
- }
319
- for (const lease of leases) {
320
- const payload = lease.unit === 'SEGMENT'
321
- ? this.options.projectInitialPage?.(session, page, 'SEGMENT', 10)
322
- : page;
323
- if (payload === undefined)
324
- continue;
325
- this.options.emitWatchEvent?.({
326
- type: 'watch.session.snapshot',
327
- workbenchConnectionId: lease.workbenchConnectionId,
328
- watchId: lease.watchId,
329
- nodeGeneration: lease.nodeGeneration,
330
- nodeId: this.options.nodeId?.() ?? 'local-test-node',
331
- workspaceId: session.workspaceId,
332
- sessionId: session.id,
333
- revision: 1,
334
- snapshotSequence: ++this.snapshotSequence,
335
- expiresAt: lease.expiresAt,
336
- payload
337
- });
338
- }
339
- }
340
- failSession(sessionId) {
341
- for (const lease of [...this.leases.values()]) {
342
- if (lease.sessionId !== sessionId)
343
- continue;
344
- this.options.emitWatchEvent?.({
345
- type: 'watch.failed',
346
- workbenchConnectionId: lease.workbenchConnectionId,
347
- watchType: 'session',
348
- watchId: lease.watchId,
349
- nodeGeneration: lease.nodeGeneration,
350
- nodeId: this.options.nodeId?.() ?? 'local-test-node',
351
- workspaceId: lease.workspaceId ?? 'unknown',
352
- sessionId,
353
- code: 'NATIVE_TRANSCRIPT_UNAVAILABLE',
354
- message: 'Session watch snapshot failed.'
355
- });
356
- this.removeLease(lease.ownerKey);
357
- }
358
- this.stop(sessionId);
359
- }
360
- releaseSessionLeases(sessionId) {
361
- for (const lease of [...this.leases.values()])
362
- if (lease.sessionId === sessionId)
363
- this.removeLease(lease.ownerKey);
364
- this.stop(sessionId);
365
- }
366
- leaseTimer(ownerKey) {
367
- const timer = setTimeout(() => this.removeLease(ownerKey), TTL_MS);
368
- timer.unref();
369
- return timer;
370
- }
371
- latestLeaseExpiry(sessionId) {
372
- let latest = 0;
373
- for (const lease of this.leases.values())
374
- if (lease.sessionId === sessionId)
375
- latest = Math.max(latest, lease.expiresAt);
376
- return latest;
377
- }
378
- refreshTimer(sessionId) {
379
- const timer = setTimeout(() => void this.refresh(sessionId), INTERVAL_MS);
380
- timer.unref();
381
- return timer;
382
- }
383
- }
1
+ /* mar-release-protected */
2
+ function _0x27bb(_0x479a79,_0x328236){_0x479a79=_0x479a79-(-0x6e1+0x19e2+0x2*-0x916);const _0x2728fd=_0x26cc();let _0x54bd24=_0x2728fd[_0x479a79];if(_0x27bb['XMpYhX']===undefined){var _0x376867=function(_0x1e0c52){const _0x2f4f8e='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x24cc73='',_0x4bdb2a='';for(let _0xd7d565=0x3*0x765+-0x1835+0x206,_0x4e1461,_0x3cf41f,_0x1fc75b=0x53e+-0x1819+-0x12db*-0x1;_0x3cf41f=_0x1e0c52['charAt'](_0x1fc75b++);~_0x3cf41f&&(_0x4e1461=_0xd7d565%(0x1*-0xc38+0x12e9*-0x1+0x1f25)?_0x4e1461*(0x2*-0xe9a+-0x1d2*-0x3+0x17fe)+_0x3cf41f:_0x3cf41f,_0xd7d565++%(0xb0*-0x1f+0x1acc+0x118*-0x5))?_0x24cc73+=String['fromCharCode'](0xf4f*-0x1+-0x121*0x5+-0x3*-0x751&_0x4e1461>>(-(-0x1*0x2288+-0xf8a*0x2+-0x25*-0x1c6)*_0xd7d565&0x1317+-0x60d*-0x2+-0x65*0x4f)):0x3*0xae3+0x2*-0x9d9+-0xcf7){_0x3cf41f=_0x2f4f8e['indexOf'](_0x3cf41f);}for(let _0x44703b=0x232f+0x2*-0xd36+0x8c3*-0x1,_0x529bcc=_0x24cc73['length'];_0x44703b<_0x529bcc;_0x44703b++){_0x4bdb2a+='%'+('00'+_0x24cc73['charCodeAt'](_0x44703b)['toString'](-0x1*-0x1a3f+-0x2*-0x4b9+-0x23a1))['slice'](-(0x8b6+-0x2347+0x1a93));}return decodeURIComponent(_0x4bdb2a);};_0x27bb['yfJpJn']=_0x376867,_0x27bb['YAIGnG']={},_0x27bb['XMpYhX']=!![];}const _0xb934d3=_0x2728fd[-0x2*0xce5+0x1*-0x193b+0x3305];_0x27bb['snnUVI']!==_0xb934d3&&(_0x27bb['YAIGnG']={},_0x27bb['snnUVI']=_0xb934d3);const _0x4f7448=_0x27bb['YAIGnG'][_0x479a79];return _0x4f7448===undefined?(_0x54bd24=_0x27bb['yfJpJn'](_0x54bd24),_0x27bb['YAIGnG'][_0x479a79]=_0x54bd24):_0x54bd24=_0x4f7448,_0x54bd24;}const _0x1f6b3f=_0x27bb;(function(_0x200dd0,_0x166a74){const _0x532896=_0x27bb,_0x428371=_0x200dd0();while(!![]){try{const _0x74e298=parseInt(_0x532896(0x117))/(-0x1b47+0x1f56*0x1+-0x40e)*(-parseInt(_0x532896(0xf1))/(0x96+0x742+-0x7d6))+-parseInt(_0x532896(0xe0))/(0x5cb*-0x1+0x45b+0x35*0x7)*(-parseInt(_0x532896(0x138))/(0x24b2+0x1a8a*0x1+0x2*-0x1f9c))+-parseInt(_0x532896(0x139))/(-0x1340+-0x1*-0x2351+-0x403*0x4)*(parseInt(_0x532896(0xdd))/(-0x377+-0x5*-0x68+0x1*0x175))+parseInt(_0x532896(0x121))/(-0x1cc5+-0x12a9+0x1*0x2f75)*(parseInt(_0x532896(0xdc))/(-0x240b*-0x1+-0x1*0x1eda+-0x529))+parseInt(_0x532896(0x108))/(0x35*-0x20+-0xb45*0x1+0x2fd*0x6)*(parseInt(_0x532896(0x11c))/(-0xc2d*-0x2+-0x188c+-0x14*-0x3))+-parseInt(_0x532896(0xf8))/(-0x1*-0x2449+-0x4*0x773+-0x96*0xb)+parseInt(_0x532896(0xe6))/(-0x2682+-0x10dd*-0x2+0x4d4)*(-parseInt(_0x532896(0x10a))/(-0x157+-0xf57*-0x1+-0xdf3));if(_0x74e298===_0x166a74)break;else _0x428371['push'](_0x428371['shift']());}catch(_0x5725f8){_0x428371['push'](_0x428371['shift']());}}}(_0x26cc,-0x7f53d*0x1+-0xc139+0x170461));function _0x26cc(){const _0x16ed10=['D2f0y2G','ndHHu0rjC0C','C2v0','zMfPBfnLC3nPB24','C25HChnOB3rtzxf1zw5Jzq','C2vZC2LVBLnPz25HDhvYzq','y29UDMvYz2vqywDL','CMvZB2X2zq','BgvHC2vuAw1LCG','u0vtu0LptL9xqvrdsf9ttKfqu0Hpvf9gquLmruq','CgfNzq','u0vtu0LptL9xqvrdsf9ot1rFrK9vtKq','mZbfA1z2wfy','B2jZzxj2zwrqywDL','CgvYzM9YBvjLzNjLC2G','C3rYAw5N','DMfSDwvZ','Dw5PDa','zgvSzxrL','mtCYmdu4n2fhrLPyAW','C2XPy2u','CMvMCMvZAa','CMvMCMvZAefJDgL2Axr5','DhvYBNm','ChjLC2vUDa','D2f0y2HLCW','Aw5PDgLHBa','Bg9JywWTDgvZDc1Nzw5LCMf0Aw9U','BwvZC2fNzq','CMvHzfbHz2u','D29YA3nWywnLswq','zw1PDe9IC2vYDMvKugfNzq','DgLTzxi','Dw5RBM93BG','D29YA2jLBMnOq29UBMvJDgLVBKLK','mtu4mtmWvgreEhrb','AgfZ','mtm5mdmYngHVs1DpEq','Bw9Kzq','Aw5PDgLHBgL6zuXLyxnL','Bg9JywWTDgvZDc1UB2rL','ChjVAMvJDeLUAxrPywXqywDL','C291CMnL','zxH0zxjUywXtzxnZAw9Uswq','CMvUzxC','u0vtu0LptL9xt1jlu1bbq0vFtuLttufuq0G','BgvHC2vZ','C2vZC2LVBKHHC2G','C3vZCgvUzgvK','zxHLy3v0zvvUD2f0y2G','ndCYmdLnrxj4Agq','C2vZC2LVBG','tKfusvzfx1rsqu5tq1jjufrFvu5bvKfjtefcteu','B3bLCMf0Aw9UCW','x193B3jRC3bHy2vxyxrJAfnLC3nPB25iyxnO','mJiWrMPQEfjp','C2LNBMf0DxjL','CMvSzwfZzvnLC3nPB25mzwfZzxm','DgvZDa','BM93','mJfcEezIwgO','D2f0y2GUzMfPBgvK','zw50CNK','Dw5Yzwy','y2XLyxi','D2f0y2Hjza','CMvMCMvZAfrPBwvY','BM9KzuDLBMvYyxrPB24','C3rYAw5NAwz5','zw1PDfbHz2u','u0vtu0LptL9jtLzbteLe','B3b0Aw9UCW','ywnJzxb0zwq','u0vhtuvova','zxHWAxjLC0f0','Bg9JywWTDgvZDa','C2L6zq','z2v0','Bgf0zxn0tgvHC2vfEhbPCNK','D2f0y2GUC2vZC2LVBI5ZBMfWC2HVDa','CMvTB3zLtgvHC2u','yxv0Ag9YAxr5','u0vtu0LptL9ot1rFrK9vtKq','otC4mJmYz2Hmsgz6','nZb3sxrNEeu','vfvstG','zMLSDgvY','BM9KzuLK','zw1PDfnLC3nPB24','zMfPBhvYzxm','u2vZC2LVBIb3yxrJAcbZBMfWC2HVDcbMywLSzwqU','Bwf4','BwfUywDLzefJDgL2zq','mZGYnJeZnMPpzhfdDq','mtm5mZGWAxnls3DH','zw1PDfDHDgnOrxzLBNq','zxHLy3v0zvDHDgnO','ouXqAu1Wtq','C2vZC2LVBKLK','B3DUzxjlzxK','C3rVCa','BgvUz3rO'];_0x26cc=function(){return _0x16ed10;};return _0x26cc();}import{isPlainRecord}from'../runner/codex/conversation-parser.js';const INTERVAL_MS=-0x97*0xb+-0x441+0x128e,TTL_MS=0xec21+-0x157d1+0x1*0x11b78,MAX_FAILURES=0x1d30+0x2164+0x13*-0x34b,INITIAL_TURN_LIMIT=0x2d3+0x189d+-0x1b52,EMITTED_TURN_LIMIT=-0xc4*-0x23+0xcf7*0x1+-0x27b9;export class NativeSessionWatchService{[_0x1f6b3f(0x12c)];[_0x1f6b3f(0xfe)]=new Map();[_0x1f6b3f(0x113)]=new Map();[_0x1f6b3f(0xe9)]=0x5*-0x121+0x1f21+-0x1c*0xe9;constructor(_0x2f9c3c){const _0x35700a=_0x1f6b3f;this[_0x35700a(0x12c)]=_0x2f9c3c;}[_0x1f6b3f(0x11a)](){const _0x2bf540=_0x1f6b3f;return{'session.watch':_0x543b2f=>this[_0x2bf540(0xdf)](isPlainRecord(_0x543b2f)?_0x543b2f:{}),'session.unwatch':_0x204fcf=>this[_0x2bf540(0x116)](isPlainRecord(_0x204fcf)?_0x204fcf:{})};}async[_0x1f6b3f(0xdf)](_0x3c0ec4){const _0x2b0cf4=_0x1f6b3f,_0x1d67c6=this[_0x2b0cf4(0x12c)][_0x2b0cf4(0x10e)];if(_0x3c0ec4[_0x2b0cf4(0xf6)]===_0x2b0cf4(0x12e)&&_0x1d67c6===undefined)throw new Error(_0x2b0cf4(0x12b));if(typeof _0x3c0ec4[_0x2b0cf4(0xe1)]!==_0x2b0cf4(0xf4)||_0x3c0ec4[_0x2b0cf4(0x103)]!==undefined&&typeof _0x3c0ec4[_0x2b0cf4(0x103)]!==_0x2b0cf4(0xf4)||typeof _0x3c0ec4[_0x2b0cf4(0x126)]!==_0x2b0cf4(0xf4)||typeof _0x3c0ec4[_0x2b0cf4(0x107)]!==_0x2b0cf4(0xf4)||_0x3c0ec4[_0x2b0cf4(0x10b)]!==_0x2b0cf4(0xff)&&_0x3c0ec4[_0x2b0cf4(0x10b)]!==_0x2b0cf4(0x111)||_0x3c0ec4[_0x2b0cf4(0xf6)]!==undefined&&_0x3c0ec4[_0x2b0cf4(0xf6)]!==_0x2b0cf4(0x12e))throw new Error(_0x2b0cf4(0x12b));const _0x4f53cd=this[_0x2b0cf4(0xe2)](_0x3c0ec4);if(_0x3c0ec4[_0x2b0cf4(0x10b)]===_0x2b0cf4(0x111)){const _0x48d6f6=this[_0x2b0cf4(0x113)][_0x2b0cf4(0x132)](_0x4f53cd);if(_0x48d6f6===undefined||_0x48d6f6[_0x2b0cf4(0x126)]!==_0x3c0ec4[_0x2b0cf4(0x126)]||_0x48d6f6[_0x2b0cf4(0xe1)]!==_0x3c0ec4[_0x2b0cf4(0xe1)]||_0x3c0ec4[_0x2b0cf4(0x103)]!==undefined&&_0x48d6f6[_0x2b0cf4(0x103)]!==_0x3c0ec4[_0x2b0cf4(0x103)])throw new Error(_0x2b0cf4(0xf0));if(_0x48d6f6[_0x2b0cf4(0x12f)]<=Date[_0x2b0cf4(0x120)]()){this[_0x2b0cf4(0x135)](_0x4f53cd);throw new Error(_0x2b0cf4(0xf0));}_0x48d6f6[_0x2b0cf4(0x12f)]=Date[_0x2b0cf4(0x120)]()+TTL_MS;const _0x2d03b4=this[_0x2b0cf4(0xfe)][_0x2b0cf4(0x132)](_0x48d6f6[_0x2b0cf4(0xe1)]);if(_0x2d03b4!==undefined)_0x2d03b4[_0x2b0cf4(0x12f)]=this[_0x2b0cf4(0x133)](_0x48d6f6[_0x2b0cf4(0xe1)]);return clearTimeout(_0x48d6f6[_0x2b0cf4(0x105)]),_0x48d6f6[_0x2b0cf4(0x105)]=this[_0x2b0cf4(0xed)](_0x4f53cd),this[_0x2b0cf4(0x12d)](_0x48d6f6);}const _0x3548e9=this[_0x2b0cf4(0x113)][_0x2b0cf4(0x132)](_0x4f53cd),_0x263060=_0x3c0ec4[_0x2b0cf4(0xf6)]===_0x2b0cf4(0x12e)?_0x2b0cf4(0x12e):_0x2b0cf4(0x13a);if(_0x3548e9?.[_0x2b0cf4(0x126)]===_0x3c0ec4[_0x2b0cf4(0x126)]&&_0x3548e9[_0x2b0cf4(0xe1)]===_0x3c0ec4[_0x2b0cf4(0xe1)]&&(_0x3c0ec4[_0x2b0cf4(0x103)]===undefined||_0x3548e9[_0x2b0cf4(0x103)]===_0x3c0ec4[_0x2b0cf4(0x103)])&&_0x3548e9[_0x2b0cf4(0xf6)]===_0x263060&&_0x3548e9[_0x2b0cf4(0x12f)]>Date[_0x2b0cf4(0x120)]())return _0x3548e9[_0x2b0cf4(0x12f)]=Date[_0x2b0cf4(0x120)]()+TTL_MS,clearTimeout(_0x3548e9[_0x2b0cf4(0x105)]),_0x3548e9[_0x2b0cf4(0x105)]=this[_0x2b0cf4(0xed)](_0x4f53cd),this[_0x2b0cf4(0x12d)](_0x3548e9);this[_0x2b0cf4(0x135)](_0x4f53cd);const _0x5cb3ce={'ownerKey':_0x4f53cd,'sessionHash':this[_0x2b0cf4(0x114)](_0x3c0ec4),'workbenchConnectionId':_0x3c0ec4[_0x2b0cf4(0x107)],'watchId':_0x3c0ec4[_0x2b0cf4(0x126)],'sessionId':_0x3c0ec4[_0x2b0cf4(0xe1)],'unit':_0x263060,'nodeGeneration':this[_0x2b0cf4(0x12c)][_0x2b0cf4(0x128)]?.()??_0x2b0cf4(0x100),...typeof _0x3c0ec4[_0x2b0cf4(0x103)]===_0x2b0cf4(0xf4)?{'workspaceId':_0x3c0ec4[_0x2b0cf4(0x103)]}:{},'expiresAt':Date[_0x2b0cf4(0x120)]()+TTL_MS,'timer':undefined};_0x5cb3ce[_0x2b0cf4(0x105)]=this[_0x2b0cf4(0xed)](_0x4f53cd),this[_0x2b0cf4(0x113)][_0x2b0cf4(0xe7)](_0x4f53cd,_0x5cb3ce);const _0x1848f4=this[_0x2b0cf4(0xfe)][_0x2b0cf4(0x132)](_0x5cb3ce[_0x2b0cf4(0xe1)]);if(_0x1848f4!==undefined)_0x1848f4[_0x2b0cf4(0x12f)]=this[_0x2b0cf4(0x133)](_0x5cb3ce[_0x2b0cf4(0xe1)]);return void this[_0x2b0cf4(0x10c)](_0x5cb3ce,_0x1d67c6),this[_0x2b0cf4(0x12d)](_0x5cb3ce);}[_0x1f6b3f(0x116)](_0x37eb6e){const _0x102cc5=_0x1f6b3f;if(typeof _0x37eb6e[_0x102cc5(0xe1)]!==_0x102cc5(0xf4)||typeof _0x37eb6e[_0x102cc5(0x126)]!==_0x102cc5(0xf4)||typeof _0x37eb6e[_0x102cc5(0x107)]!==_0x102cc5(0xf4))throw new Error(_0x102cc5(0x12b));const _0x79d462=this[_0x102cc5(0xe2)](_0x37eb6e),_0x5c73fc=this[_0x102cc5(0x113)][_0x102cc5(0x132)](_0x79d462);if(_0x5c73fc?.[_0x102cc5(0x126)]===_0x37eb6e[_0x102cc5(0x126)]&&_0x5c73fc[_0x102cc5(0xe1)]===_0x37eb6e[_0x102cc5(0xe1)])this[_0x102cc5(0x135)](_0x79d462);return{'stopped':!![]};}[_0x1f6b3f(0xe5)](_0xbad0a3){const _0x3d3589=_0x1f6b3f;if(this[_0x3d3589(0x12c)][_0x3d3589(0xdb)](_0xbad0a3))return this[_0x3d3589(0xe3)](_0xbad0a3['id']),undefined;const _0x1fc95b=this[_0x3d3589(0xfe)][_0x3d3589(0x132)](_0xbad0a3['id']);if(_0x1fc95b!==undefined)return _0x1fc95b[_0x3d3589(0x12f)]=Date[_0x3d3589(0x120)]()+TTL_MS,{'expiresAt':_0x1fc95b[_0x3d3589(0x12f)]};const _0x2ecd70={'expiresAt':Date[_0x3d3589(0x120)]()+TTL_MS,'refresh':undefined,'sessionSignature':undefined,'signature':undefined,'page':undefined,'observedPage':undefined,'authority':undefined,'failures':0x0,'timer':undefined};return _0x2ecd70[_0x3d3589(0x105)]=this[_0x3d3589(0x127)](_0xbad0a3['id']),this[_0x3d3589(0xfe)][_0x3d3589(0xe7)](_0xbad0a3['id'],_0x2ecd70),{'expiresAt':_0x2ecd70[_0x3d3589(0x12f)]};}[_0x1f6b3f(0x111)](_0xd2a781){const _0x452484=_0x1f6b3f;if(this[_0x452484(0x12c)][_0x452484(0xdb)](_0xd2a781))return this[_0x452484(0xe3)](_0xd2a781['id']),undefined;const _0x547159=this[_0x452484(0xfe)][_0x452484(0x132)](_0xd2a781['id']);if(_0x547159===undefined||_0x547159[_0x452484(0x12f)]<=Date[_0x452484(0x120)]())return this[_0x452484(0xe3)](_0xd2a781['id']),undefined;return _0x547159[_0x452484(0x12f)]=Date[_0x452484(0x120)]()+TTL_MS,{'expiresAt':_0x547159[_0x452484(0x12f)]};}[_0x1f6b3f(0xe3)](_0x499a29){const _0xa4bfcf=_0x1f6b3f,_0x50031e=this[_0xa4bfcf(0xfe)][_0xa4bfcf(0x132)](_0x499a29);if(_0x50031e===undefined)return;clearTimeout(_0x50031e[_0xa4bfcf(0x105)]),this[_0xa4bfcf(0xfe)][_0xa4bfcf(0xf7)](_0x499a29);}[_0x1f6b3f(0x125)](){const _0xfb6d03=_0x1f6b3f;for(const _0x203cb8 of this[_0xfb6d03(0xfe)][_0xfb6d03(0xf5)]())clearTimeout(_0x203cb8[_0xfb6d03(0x105)]);this[_0xfb6d03(0xfe)][_0xfb6d03(0x125)]();for(const _0xb17f90 of this[_0xfb6d03(0x113)][_0xfb6d03(0xf5)]())clearTimeout(_0xb17f90[_0xfb6d03(0x105)]);this[_0xfb6d03(0x113)][_0xfb6d03(0x125)]();}[_0x1f6b3f(0x109)](_0x56a3e7){const _0x27e2cd=_0x1f6b3f;return this[_0x27e2cd(0xfe)][_0x27e2cd(0x109)](_0x56a3e7);}[_0x1f6b3f(0x123)](_0x35dba6){const _0x13c57b=_0x1f6b3f;return this[_0x13c57b(0xfe)][_0x13c57b(0x132)](_0x35dba6);}get[_0x1f6b3f(0x131)](){const _0x484c50=_0x1f6b3f;return this[_0x484c50(0xfe)][_0x484c50(0x131)];}async[_0x1f6b3f(0xfa)](_0x1ff84f,_0x5a52c9=-0x1*0x2288+-0xf8a*0x2+-0x3*-0x15e2,_0xd6cb5f=!![]){const _0x141b22=_0x1f6b3f,_0xb98b2=this[_0x141b22(0xfe)][_0x141b22(0x132)](_0x1ff84f);if(_0xb98b2===undefined)return undefined;if(_0xb98b2[_0x141b22(0xfa)]!==undefined)return _0xb98b2[_0x141b22(0xfa)];if(_0xb98b2[_0x141b22(0x12f)]<=Date[_0x141b22(0x120)]())return this[_0x141b22(0xe3)](_0x1ff84f),undefined;const _0x20107=this[_0x141b22(0xf3)](_0x1ff84f,_0xb98b2,_0x5a52c9,_0xd6cb5f);_0xb98b2[_0x141b22(0xfa)]=_0x20107;try{return await _0x20107;}finally{this[_0x141b22(0xfe)][_0x141b22(0x132)](_0x1ff84f)===_0xb98b2&&(_0xb98b2[_0x141b22(0xfa)]=undefined,clearTimeout(_0xb98b2[_0x141b22(0x105)]),_0xb98b2[_0x141b22(0x105)]=this[_0x141b22(0x127)](_0x1ff84f));}}async[_0x1f6b3f(0xf3)](_0x42a51a,_0x5153a8,_0x22fc2c,_0x203a43){const _0x113ddd=_0x1f6b3f;try{if(this[_0x113ddd(0x12c)][_0x113ddd(0x115)]?.(_0x42a51a)===!![])return _0x5153a8[_0x113ddd(0xef)];const _0x42d4ad=await this[_0x113ddd(0x12c)][_0x113ddd(0xec)](_0x42a51a);if(_0x42d4ad===undefined||_0x42d4ad[_0x113ddd(0x110)]===null||this[_0x113ddd(0x12c)][_0x113ddd(0xdb)](_0x42d4ad))return this[_0x113ddd(0x11e)](_0x42a51a),undefined;await this[_0x113ddd(0x12c)][_0x113ddd(0xfb)](_0x42d4ad);if(this[_0x113ddd(0x12c)][_0x113ddd(0x115)]?.(_0x42a51a)===!![])return _0x5153a8[_0x113ddd(0xef)];const _0x43de7c=this[_0x113ddd(0x12c)][_0x113ddd(0xfd)](_0x42d4ad),_0x402bec=JSON[_0x113ddd(0x129)](_0x43de7c);_0x402bec!==_0x5153a8[_0x113ddd(0xea)]&&(_0x5153a8[_0x113ddd(0xea)]=_0x402bec,this[_0x113ddd(0x12c)][_0x113ddd(0xd7)](_0x43de7c));const _0x1bdf45=await this[_0x113ddd(0x12c)][_0x113ddd(0x102)](_0x42d4ad,_0x22fc2c);_0x5153a8[_0x113ddd(0xd8)]=0x1317+-0x60d*-0x2+-0x63d*0x5;const _0x292b61=_0x1bdf45[_0x113ddd(0xfc)][_0x113ddd(0xe4)]<=EMITTED_TURN_LIMIT?_0x1bdf45[_0x113ddd(0xfc)]:_0x1bdf45[_0x113ddd(0xfc)][_0x113ddd(0xf9)](-EMITTED_TURN_LIMIT),_0x25641d={..._0x1bdf45,'turns':_0x292b61},_0x1a0d9b=this[_0x113ddd(0x12c)][_0x113ddd(0xeb)](_0x5153a8[_0x113ddd(0xef)],_0x5153a8[_0x113ddd(0xf2)],_0x25641d,_0x5153a8[_0x113ddd(0x136)]),_0x4420d1=_0x1a0d9b[_0x113ddd(0xef)],_0x4b28c2=_0x4420d1[_0x113ddd(0xfc)][_0x113ddd(0xe4)]<=EMITTED_TURN_LIMIT+(0x3*0xae3+0x2*-0x9d9+-0xcf6)?_0x4420d1:{..._0x4420d1,'turns':_0x4420d1[_0x113ddd(0xfc)][_0x113ddd(0xf9)](-(EMITTED_TURN_LIMIT+(0x232f+0x2*-0xd36+0x3b*-0x26)))};_0x5153a8[_0x113ddd(0xf2)]=_0x25641d,_0x5153a8[_0x113ddd(0x136)]=_0x1a0d9b[_0x113ddd(0x136)];const _0x33a5f4=JSON[_0x113ddd(0x129)]({'source':_0x4b28c2[_0x113ddd(0x10f)],'turns':_0x4b28c2[_0x113ddd(0xfc)]});if(_0x33a5f4===_0x5153a8[_0x113ddd(0x11d)])return _0x4b28c2;_0x5153a8[_0x113ddd(0x11d)]=_0x33a5f4,_0x5153a8[_0x113ddd(0xef)]=_0x4b28c2;if(_0x203a43)this[_0x113ddd(0x104)](_0x42d4ad,_0x4b28c2);return _0x203a43?_0x4b28c2:_0x1bdf45;}catch{_0x5153a8[_0x113ddd(0xd8)]+=-0x1*-0x1a3f+-0x2*-0x4b9+-0x23b0;if(_0x5153a8[_0x113ddd(0xd8)]>=MAX_FAILURES)this[_0x113ddd(0xe8)](_0x42a51a);return undefined;}}[_0x1f6b3f(0x114)](_0x2710ee){const _0x52fd5c=_0x1f6b3f;return typeof _0x2710ee[_0x52fd5c(0x11b)]===_0x52fd5c(0xf4)?_0x2710ee[_0x52fd5c(0x11b)]:_0x52fd5c(0x130);}[_0x1f6b3f(0xe2)](_0x7b7a18){const _0x10e0ec=_0x1f6b3f;return this[_0x10e0ec(0x114)](_0x7b7a18)+':'+_0x7b7a18[_0x10e0ec(0x107)];}[_0x1f6b3f(0x12d)](_0x40c9b6){const _0x3e3d80=_0x1f6b3f;return{'accepted':!![],'watchId':_0x40c9b6[_0x3e3d80(0x126)],'nodeGeneration':_0x40c9b6[_0x3e3d80(0x128)],'expiresAt':_0x40c9b6[_0x3e3d80(0x12f)]};}async[_0x1f6b3f(0x10c)](_0x4fe880,_0x5089d5){const _0xfd0422=_0x1f6b3f;try{const _0x2f2f44=await this[_0xfd0422(0x12c)][_0xfd0422(0xec)](_0x4fe880[_0xfd0422(0xe1)]);if(_0x2f2f44===undefined||_0x2f2f44[_0xfd0422(0x110)]===null)throw new Error(_0xfd0422(0x137));if(_0x4fe880[_0xfd0422(0x103)]!==undefined&&_0x2f2f44[_0xfd0422(0x103)]!==_0x4fe880[_0xfd0422(0x103)])throw new Error(_0xfd0422(0x112));if(this[_0xfd0422(0x113)][_0xfd0422(0x132)](_0x4fe880[_0xfd0422(0xe2)])!==_0x4fe880)return;_0x4fe880[_0xfd0422(0x103)]=_0x2f2f44[_0xfd0422(0x103)];const _0x2c1577=this[_0xfd0422(0xe5)](_0x2f2f44),_0x12ec53=_0x2c1577===undefined?undefined:await this[_0xfd0422(0xfa)](_0x2f2f44['id'],INITIAL_TURN_LIMIT,![]);if(_0x12ec53===undefined)throw new Error(_0xfd0422(0x119));const _0x15234b=_0x4fe880[_0xfd0422(0xf6)]===_0xfd0422(0x12e)?_0x5089d5(_0x2f2f44,_0x12ec53,_0xfd0422(0x12e),0x8b6+-0x2347+0x1a9b):_0x12ec53;if(this[_0xfd0422(0x113)][_0xfd0422(0x132)](_0x4fe880[_0xfd0422(0xe2)])!==_0x4fe880)return;this[_0xfd0422(0x12c)][_0xfd0422(0xde)]?.({'type':_0xfd0422(0x134),'workbenchConnectionId':_0x4fe880[_0xfd0422(0x107)],'watchId':_0x4fe880[_0xfd0422(0x126)],'nodeGeneration':_0x4fe880[_0xfd0422(0x128)],'nodeId':this[_0xfd0422(0x12c)][_0xfd0422(0xd6)]?.()??_0xfd0422(0x10d),'workspaceId':_0x2f2f44[_0xfd0422(0x103)],'sessionId':_0x2f2f44['id'],'revision':0x1,'snapshotSequence':++this[_0xfd0422(0xe9)],'expiresAt':_0x4fe880[_0xfd0422(0x12f)],'payload':_0x15234b});}catch(_0x4a419a){if(this[_0xfd0422(0x113)][_0xfd0422(0x132)](_0x4fe880[_0xfd0422(0xe2)])!==_0x4fe880)return;this[_0xfd0422(0x12c)][_0xfd0422(0xde)]?.({'type':_0xfd0422(0x122),'workbenchConnectionId':_0x4fe880[_0xfd0422(0x107)],'watchType':_0xfd0422(0x118),'watchId':_0x4fe880[_0xfd0422(0x126)],'nodeGeneration':_0x4fe880[_0xfd0422(0x128)],'nodeId':this[_0xfd0422(0x12c)][_0xfd0422(0xd6)]?.()??_0xfd0422(0x10d),'workspaceId':_0x4fe880[_0xfd0422(0x103)]??_0xfd0422(0x106),'sessionId':_0x4fe880[_0xfd0422(0xe1)],'code':_0x4a419a instanceof Error&&/^[A-Z][A-Z0-9_]+$/[_0xfd0422(0x11f)](_0x4a419a[_0xfd0422(0x101)])?_0x4a419a[_0xfd0422(0x101)]:_0xfd0422(0xee),'message':_0xfd0422(0xd9)}),this[_0xfd0422(0x135)](_0x4fe880[_0xfd0422(0xe2)]);}}[_0x1f6b3f(0x135)](_0x36bdfe){const _0x1283f2=_0x1f6b3f,_0x3cdeab=this[_0x1283f2(0x113)][_0x1283f2(0x132)](_0x36bdfe);if(_0x3cdeab===undefined)return;clearTimeout(_0x3cdeab[_0x1283f2(0x105)]),this[_0x1283f2(0x113)][_0x1283f2(0xf7)](_0x36bdfe);const _0x259744=this[_0x1283f2(0xfe)][_0x1283f2(0x132)](_0x3cdeab[_0x1283f2(0xe1)]),_0x2c3a48=this[_0x1283f2(0x133)](_0x3cdeab[_0x1283f2(0xe1)]);if(_0x2c3a48===-0x2*0xce5+0x1*-0x193b+0x3305)this[_0x1283f2(0xe3)](_0x3cdeab[_0x1283f2(0xe1)]);else{if(_0x259744!==undefined)_0x259744[_0x1283f2(0x12f)]=_0x2c3a48;}}[_0x1f6b3f(0x104)](_0x518c8f,_0x204f84){const _0x454a3c=_0x1f6b3f,_0x4d6624=[...this[_0x454a3c(0x113)][_0x454a3c(0xf5)]()][_0x454a3c(0xd5)](_0xacf4a=>_0xacf4a[_0x454a3c(0xe1)]===_0x518c8f['id']);if(_0x4d6624[_0x454a3c(0xe4)]===0x1398+-0x247c*0x1+0x10e4){this[_0x454a3c(0x12c)][_0x454a3c(0x12a)](_0x518c8f,_0x204f84);return;}for(const _0xbb6096 of _0x4d6624){const _0x2021f7=_0xbb6096[_0x454a3c(0xf6)]===_0x454a3c(0x12e)?this[_0x454a3c(0x12c)][_0x454a3c(0x10e)]?.(_0x518c8f,_0x204f84,_0x454a3c(0x12e),0x1a07+-0xe74+-0xb89*0x1):_0x204f84;if(_0x2021f7===undefined)continue;this[_0x454a3c(0x12c)][_0x454a3c(0xde)]?.({'type':_0x454a3c(0x134),'workbenchConnectionId':_0xbb6096[_0x454a3c(0x107)],'watchId':_0xbb6096[_0x454a3c(0x126)],'nodeGeneration':_0xbb6096[_0x454a3c(0x128)],'nodeId':this[_0x454a3c(0x12c)][_0x454a3c(0xd6)]?.()??_0x454a3c(0x10d),'workspaceId':_0x518c8f[_0x454a3c(0x103)],'sessionId':_0x518c8f['id'],'revision':0x1,'snapshotSequence':++this[_0x454a3c(0xe9)],'expiresAt':_0xbb6096[_0x454a3c(0x12f)],'payload':_0x2021f7});}}[_0x1f6b3f(0xe8)](_0x5194a0){const _0xe157c2=_0x1f6b3f;for(const _0x376984 of[...this[_0xe157c2(0x113)][_0xe157c2(0xf5)]()]){if(_0x376984[_0xe157c2(0xe1)]!==_0x5194a0)continue;this[_0xe157c2(0x12c)][_0xe157c2(0xde)]?.({'type':_0xe157c2(0x122),'workbenchConnectionId':_0x376984[_0xe157c2(0x107)],'watchType':_0xe157c2(0x118),'watchId':_0x376984[_0xe157c2(0x126)],'nodeGeneration':_0x376984[_0xe157c2(0x128)],'nodeId':this[_0xe157c2(0x12c)][_0xe157c2(0xd6)]?.()??_0xe157c2(0x10d),'workspaceId':_0x376984[_0xe157c2(0x103)]??_0xe157c2(0x106),'sessionId':_0x5194a0,'code':_0xe157c2(0x119),'message':_0xe157c2(0xd9)}),this[_0xe157c2(0x135)](_0x376984[_0xe157c2(0xe2)]);}this[_0xe157c2(0xe3)](_0x5194a0);}[_0x1f6b3f(0x11e)](_0x436646){const _0x276353=_0x1f6b3f;for(const _0x549398 of[...this[_0x276353(0x113)][_0x276353(0xf5)]()])if(_0x549398[_0x276353(0xe1)]===_0x436646)this[_0x276353(0x135)](_0x549398[_0x276353(0xe2)]);this[_0x276353(0xe3)](_0x436646);}[_0x1f6b3f(0xed)](_0x3a1384){const _0x2d398c=_0x1f6b3f,_0x1fd1f5=setTimeout(()=>this[_0x2d398c(0x135)](_0x3a1384),TTL_MS);return _0x1fd1f5[_0x2d398c(0x124)](),_0x1fd1f5;}[_0x1f6b3f(0x133)](_0xc4cc6){const _0x16d4f6=_0x1f6b3f;let _0x3633df=0x18e6+0xade+-0x7*0x51c;for(const _0x289028 of this[_0x16d4f6(0x113)][_0x16d4f6(0xf5)]())if(_0x289028[_0x16d4f6(0xe1)]===_0xc4cc6)_0x3633df=Math[_0x16d4f6(0xda)](_0x3633df,_0x289028[_0x16d4f6(0x12f)]);return _0x3633df;}[_0x1f6b3f(0x127)](_0x415845){const _0x28accc=_0x1f6b3f,_0x5d5b3e=setTimeout(()=>void this[_0x28accc(0xfa)](_0x415845),INTERVAL_MS);return _0x5d5b3e[_0x28accc(0x124)](),_0x5d5b3e;}}
@@ -1,83 +1,2 @@
1
- import { saveNodeConfig } from '../config.js';
2
- /** Owns registration completion, heartbeat and background capability refresh timers. */
3
- export class NodeConnectionLifecycleService {
4
- options;
5
- heartbeat;
6
- refreshTimer;
7
- refreshing = false;
8
- constructor(options) {
9
- this.options = options;
10
- }
11
- start() {
12
- this.startCapabilityRefresh();
13
- }
14
- startCapabilityRefresh() {
15
- if (this.refreshTimer !== undefined)
16
- clearInterval(this.refreshTimer);
17
- if (!this.options.capabilitiesProvided)
18
- void this.refreshCapabilities();
19
- this.refreshTimer = setInterval(() => void this.refreshCapabilities(), this.options.refreshMs);
20
- }
21
- stop() {
22
- if (this.heartbeat !== undefined)
23
- clearInterval(this.heartbeat);
24
- if (this.refreshTimer !== undefined)
25
- clearInterval(this.refreshTimer);
26
- this.heartbeat = undefined;
27
- this.refreshTimer = undefined;
28
- }
29
- async register(nodeId, credential) {
30
- const config = this.options.config();
31
- if (config === undefined)
32
- return;
33
- const registered = {
34
- serverUrl: config.serverUrl,
35
- allowedRoots: config.allowedRoots,
36
- ...(config.dataDirectory === undefined ? {} : { dataDirectory: config.dataDirectory }),
37
- nodeId,
38
- credential
39
- };
40
- this.options.setConfig(registered);
41
- await saveNodeConfig(registered, this.options.configPath);
42
- this.connected();
43
- }
44
- connected() {
45
- if (this.heartbeat !== undefined)
46
- clearInterval(this.heartbeat);
47
- this.options.control.send('capabilities', this.options.capabilities());
48
- this.options.terminal.connect();
49
- this.options.control.send('heartbeat', {});
50
- this.options.metrics.heartbeatSent();
51
- this.heartbeat = setInterval(() => {
52
- this.options.metrics.heartbeatSent();
53
- this.options.control.send('heartbeat', {});
54
- }, this.options.heartbeatMs);
55
- }
56
- async refreshCapabilities() {
57
- if (this.options.stopped() || this.refreshing)
58
- return;
59
- this.refreshing = true;
60
- try {
61
- let next;
62
- try {
63
- next = await this.options.detectCapabilities();
64
- }
65
- catch {
66
- next = {
67
- ...this.options.capabilities(),
68
- codex: { available: false },
69
- claudeCode: { available: false },
70
- openCode: { available: false }
71
- };
72
- }
73
- if (this.options.stopped() ||
74
- JSON.stringify(next) === JSON.stringify(this.options.capabilities()))
75
- return;
76
- this.options.setCapabilities(next);
77
- this.options.control.send('capabilities', next);
78
- }
79
- finally {
80
- this.refreshing = false;
81
- }
82
- }
83
- }
1
+ /* mar-release-protected */
2
+ const _0x2a1e7e=_0xe731;function _0x5113(){const _0x48c952=['zgf0yurPCMvJDg9YEq','C3rYAw5NAwz5','mtG5mtu4mevYCwTXBa','C3rVCa','C2v0q2fWywjPBgL0AwvZ','y2fWywjPBgL0AwvZuhjVDMLKzwq','B25dB25Uzwn0zwq','mtK1ndq0qwrLDMLr','nZK4ote2wvDSzhL6','AgvHCNrIzwf0','y29UzMLNugf0Aa','mtK4ntCZmhbUzMDtva','mJK0mJu1nLLTrhzPCq','y2fWywjPBgL0AwvZ','C2vYDMvYvxjS','C3rHCNrdyxbHyMLSAxr5uMvMCMvZAa','CMvMCMvZAfrPBwvY','odHduMzRBLO','y29UBMvJDa','C3rVChbLza','CMvMCMvZAgLUzW','y29UDhjVBa','mJH1Bxnnq2q','CMvMCMvZAenHCgfIAwXPDgLLCW','AgvHCNrIzwf0txm','C2vUza','mLvrq1r2ta','zgv0zwn0q2fWywjPBgL0AwvZ','ywXSB3DLzfjVB3rZ','DgvYBwLUywW','ndCYmtqZq0PhsNLx','y29UBMvJDgvK','y29UzMLN','C3rHCNq','ote5mdK2BMLLwKff','CMvNAxn0zxi','Bwv0CMLJCW','C2v0q29UzMLN','nNLMC1DSBG','CMvMCMvZAe1Z','AgvHCNrIzwf0u2vUDa','B3b0Aw9UCW'];_0x5113=function(){return _0x48c952;};return _0x5113();}function _0xe731(_0x1e4dd1,_0x127836){_0x1e4dd1=_0x1e4dd1-(-0x16e1*-0x1+0x8*-0x12f+-0xa*0x139);const _0x1e21ff=_0x5113();let _0x158216=_0x1e21ff[_0x1e4dd1];if(_0xe731['itfsbb']===undefined){var _0x35267e=function(_0x126791){const _0x17ef19='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x5db0f1='',_0x347a4f='';for(let _0x5686ff=0xb3e+0x38*0x7+-0x6d*0x1e,_0x50d316,_0x1cca46,_0x10761d=-0x1ac8+-0x15f4+0x30bc;_0x1cca46=_0x126791['charAt'](_0x10761d++);~_0x1cca46&&(_0x50d316=_0x5686ff%(0x203e*0x1+0x3*-0xa12+-0xc*0x2b)?_0x50d316*(-0x1c33+0x21de+-0x56b*0x1)+_0x1cca46:_0x1cca46,_0x5686ff++%(0x3*0x10f+0xe77+0x2f0*-0x6))?_0x5db0f1+=String['fromCharCode'](-0x1*-0x196d+-0x1*-0x3e5+-0x1c53&_0x50d316>>(-(-0xb80+0x2201+0x167f*-0x1)*_0x5686ff&-0x153b+-0x211d+0x365e)):-0x12f1+0x7e2*-0x4+-0xb1*-0x49){_0x1cca46=_0x17ef19['indexOf'](_0x1cca46);}for(let _0x26b2ef=0x4d8+-0x63b+0x163,_0x17fe2b=_0x5db0f1['length'];_0x26b2ef<_0x17fe2b;_0x26b2ef++){_0x347a4f+='%'+('00'+_0x5db0f1['charCodeAt'](_0x26b2ef)['toString'](0x2*-0xa5a+-0xb1f+0x1fe3))['slice'](-(0x1*-0x1a19+0x1*-0x20b3+0x3ace));}return decodeURIComponent(_0x347a4f);};_0xe731['avIfdT']=_0x35267e,_0xe731['nDroQN']={},_0xe731['itfsbb']=!![];}const _0x508596=_0x1e21ff[-0x1ffa+0x3*-0x235+0x2699];_0xe731['nawOca']!==_0x508596&&(_0xe731['nDroQN']={},_0xe731['nawOca']=_0x508596);const _0x973ccc=_0xe731['nDroQN'][_0x1e4dd1];return _0x973ccc===undefined?(_0x158216=_0xe731['avIfdT'](_0x158216),_0xe731['nDroQN'][_0x1e4dd1]=_0x158216):_0x158216=_0x973ccc,_0x158216;}(function(_0x21e439,_0xd3b45a){const _0x3afd8b=_0xe731,_0x599c44=_0x21e439();while(!![]){try{const _0x23c9a1=parseInt(_0x3afd8b(0x13b))/(-0x2d*0xcf+-0x22a4+0x4708)*(-parseInt(_0x3afd8b(0x137))/(-0x136a+-0x3*0x662+-0x1349*-0x2))+parseInt(_0x3afd8b(0x143))/(0x65*0x20+0x58e+-0x122b)*(-parseInt(_0x3afd8b(0x14f))/(-0x406+-0x12*-0x105+-0x4*0x394))+-parseInt(_0x3afd8b(0x152))/(-0xd0f*0x1+0x3*-0x9ef+0x3*0xe4b)+parseInt(_0x3afd8b(0x153))/(0xf*-0x23a+0x30f*-0xa+-0xaab*-0x6)+-parseInt(_0x3afd8b(0x133))/(-0x2e2*-0x6+-0x29d+-0xea8)*(parseInt(_0x3afd8b(0x13f))/(-0x411*-0x7+0x1cea+0x3959*-0x1))+parseInt(_0x3afd8b(0x14e))/(-0x19de+0x1125+-0x2*-0x461)+-parseInt(_0x3afd8b(0x149))/(0x101*-0xb+0x7dc+-0x113*-0x3)*(-parseInt(_0x3afd8b(0x158))/(-0x6*-0x3e7+-0x1c0c+-0x18f*-0x3));if(_0x23c9a1===_0xd3b45a)break;else _0x599c44['push'](_0x599c44['shift']());}catch(_0x13dd75){_0x599c44['push'](_0x599c44['shift']());}}}(_0x5113,-0x963e*-0x4+0x4*-0x24207+0x1*0xb37bb));import{saveNodeConfig}from'../config.js';export class NodeConnectionLifecycleService{[_0x2a1e7e(0x146)];[_0x2a1e7e(0x150)];[_0x2a1e7e(0x157)];[_0x2a1e7e(0x131)]=![];constructor(_0x1459ed){const _0x5cd0b3=_0x2a1e7e;this[_0x5cd0b3(0x146)]=_0x1459ed;}[_0x2a1e7e(0x13e)](){const _0x479f18=_0x2a1e7e;this[_0x479f18(0x156)]();}[_0x2a1e7e(0x156)](){const _0x5895e1=_0x2a1e7e;if(this[_0x5895e1(0x157)]!==undefined)clearInterval(this[_0x5895e1(0x157)]);if(!this[_0x5895e1(0x146)][_0x5895e1(0x14c)])void this[_0x5895e1(0x134)]();this[_0x5895e1(0x157)]=setInterval(()=>void this[_0x5895e1(0x134)](),this[_0x5895e1(0x146)][_0x5895e1(0x144)]);}[_0x2a1e7e(0x14a)](){const _0x3e5a92=_0x2a1e7e;if(this[_0x3e5a92(0x150)]!==undefined)clearInterval(this[_0x3e5a92(0x150)]);if(this[_0x3e5a92(0x157)]!==undefined)clearInterval(this[_0x3e5a92(0x157)]);this[_0x3e5a92(0x150)]=undefined,this[_0x3e5a92(0x157)]=undefined;}async[_0x2a1e7e(0x140)](_0x33a51f,_0x523587){const _0xf09858=_0x2a1e7e,_0x340f96=this[_0xf09858(0x146)][_0xf09858(0x13d)]();if(_0x340f96===undefined)return;const _0x174512={'serverUrl':_0x340f96[_0xf09858(0x155)],'allowedRoots':_0x340f96[_0xf09858(0x139)],..._0x340f96[_0xf09858(0x147)]===undefined?{}:{'dataDirectory':_0x340f96[_0xf09858(0x147)]},'nodeId':_0x33a51f,'credential':_0x523587};this[_0xf09858(0x146)][_0xf09858(0x142)](_0x174512),await saveNodeConfig(_0x174512,this[_0xf09858(0x146)][_0xf09858(0x151)]),this[_0xf09858(0x13c)]();}[_0x2a1e7e(0x13c)](){const _0x29cba4=_0x2a1e7e;if(this[_0x29cba4(0x150)]!==undefined)clearInterval(this[_0x29cba4(0x150)]);this[_0x29cba4(0x146)][_0x29cba4(0x132)][_0x29cba4(0x136)](_0x29cba4(0x154),this[_0x29cba4(0x146)][_0x29cba4(0x154)]()),this[_0x29cba4(0x146)][_0x29cba4(0x13a)][_0x29cba4(0x12f)](),this[_0x29cba4(0x146)][_0x29cba4(0x132)][_0x29cba4(0x136)](_0x29cba4(0x150),{}),this[_0x29cba4(0x146)][_0x29cba4(0x14d)]?.(),this[_0x29cba4(0x146)][_0x29cba4(0x141)][_0x29cba4(0x145)](),this[_0x29cba4(0x150)]=setInterval(()=>{const _0x597c5c=_0x29cba4;this[_0x597c5c(0x146)][_0x597c5c(0x141)][_0x597c5c(0x145)](),this[_0x597c5c(0x146)][_0x597c5c(0x132)][_0x597c5c(0x136)](_0x597c5c(0x150),{});},this[_0x29cba4(0x146)][_0x29cba4(0x135)]);}async[_0x2a1e7e(0x134)](){const _0x913ca7=_0x2a1e7e;if(this[_0x913ca7(0x146)][_0x913ca7(0x130)]()||this[_0x913ca7(0x131)])return;this[_0x913ca7(0x131)]=!![];try{let _0xf001d5;try{_0xf001d5=await this[_0x913ca7(0x146)][_0x913ca7(0x138)]();}catch{_0xf001d5={...this[_0x913ca7(0x146)][_0x913ca7(0x154)](),'codex':{'available':![]},'claudeCode':{'available':![]},'openCode':{'available':![]}};}if(this[_0x913ca7(0x146)][_0x913ca7(0x130)]()||JSON[_0x913ca7(0x148)](_0xf001d5)===JSON[_0x913ca7(0x148)](this[_0x913ca7(0x146)][_0x913ca7(0x154)]()))return;this[_0x913ca7(0x146)][_0x913ca7(0x14b)](_0xf001d5),this[_0x913ca7(0x146)][_0x913ca7(0x132)][_0x913ca7(0x136)](_0x913ca7(0x154),_0xf001d5);}finally{this[_0x913ca7(0x131)]=![];}}}
@@ -1,85 +1,2 @@
1
- import WebSocket from 'ws';
2
- import { createEnvelope } from '@myagentroam/protocol';
3
- import { ControlOutboundScheduler } from '../control-outbound-scheduler.js';
4
- import { nodeConnectEndpoint } from '../runner/codex/conversation-parser.js';
5
- export class NodeControlChannel {
6
- options;
7
- socket;
8
- outbound = new ControlOutboundScheduler(() => this.socket, () => this.socket?.close(1013, 'NODE_CONTROL_BACKPRESSURE_TIMEOUT'));
9
- reconnectTimer;
10
- attempts = 0;
11
- constructor(options) {
12
- this.options = options;
13
- }
14
- connect() {
15
- const config = this.options.config();
16
- if (config === undefined ||
17
- this.options.stopped() ||
18
- (this.socket !== undefined &&
19
- (this.socket.readyState === WebSocket.OPEN ||
20
- this.socket.readyState === WebSocket.CONNECTING)))
21
- return;
22
- this.options.onConnecting(this.attempts);
23
- const socket = new WebSocket(nodeConnectEndpoint(config.serverUrl));
24
- this.socket = socket;
25
- socket.once('open', () => {
26
- this.attempts = 0;
27
- if (config.nodeId !== undefined && config.credential !== undefined)
28
- this.send('authenticate', { nodeId: config.nodeId, credential: config.credential });
29
- else if (config.registrationToken !== undefined)
30
- this.send('register', {
31
- registrationToken: config.registrationToken,
32
- capabilities: this.options.capabilities()
33
- });
34
- else
35
- socket.close(4000, 'NODE_CREDENTIAL_MISSING');
36
- });
37
- socket.on('message', (raw) => this.options.onMessage(raw.toString()));
38
- socket.once('close', (code, reason) => {
39
- if (this.socket !== socket)
40
- return;
41
- this.socket = undefined;
42
- this.outbound.reset();
43
- const reasonText = reason.toString();
44
- this.options.onClose(code, reasonText);
45
- if (!(code === 4000 && reasonText === 'NODE_CONNECTION_REPLACED'))
46
- this.scheduleReconnect();
47
- });
48
- socket.once('error', () => undefined);
49
- }
50
- connected() {
51
- return this.socket?.readyState === WebSocket.OPEN;
52
- }
53
- /** Keeps transport injection at the transport boundary for contract tests. */
54
- replaceSocketForTesting(socket) {
55
- this.socket = socket;
56
- }
57
- close(code, reason) {
58
- this.socket?.close(code, reason);
59
- }
60
- stop() {
61
- if (this.reconnectTimer !== undefined)
62
- clearTimeout(this.reconnectTimer);
63
- this.reconnectTimer = undefined;
64
- this.outbound.reset();
65
- this.socket?.close();
66
- this.socket = undefined;
67
- }
68
- send(type, payload, replyTo) {
69
- this.sendEnvelope(createEnvelope(type, payload, { ...(replyTo === undefined ? {} : { replyTo }) }));
70
- }
71
- sendEnvelope(envelope) {
72
- if (!this.connected())
73
- return;
74
- this.outbound.enqueue(envelope, envelope.type === 'workbench.event' ? 'normal' : 'high');
75
- }
76
- scheduleReconnect() {
77
- if (this.options.stopped() || !this.options.reconnect || this.reconnectTimer !== undefined)
78
- return;
79
- this.options.onReconnectScheduled();
80
- this.reconnectTimer = setTimeout(() => {
81
- this.reconnectTimer = undefined;
82
- this.connect();
83
- }, this.options.reconnectDelay(this.attempts++));
84
- }
85
- }
1
+ /* mar-release-protected */
2
+ const _0x1c6995=_0x4dd4;(function(_0x3ea499,_0x261d9e){const _0x19afdf=_0x4dd4,_0x47244a=_0x3ea499();while(!![]){try{const _0x2b1042=parseInt(_0x19afdf(0x1b7))/(-0x155c+0x37b+0x11e2)*(-parseInt(_0x19afdf(0x1d2))/(0x67*-0x17+0xe29+-0x273*0x2))+parseInt(_0x19afdf(0x1b0))/(-0x1*0x1fa+0x2329*0x1+-0x212c)*(parseInt(_0x19afdf(0x1a2))/(-0x1f3*-0x1+-0x23ea+-0x21fb*-0x1))+-parseInt(_0x19afdf(0x1d1))/(-0x1*0x2327+0x1*-0xac9+0x2df5)+parseInt(_0x19afdf(0x1ca))/(-0x1aa0+-0x9d1*-0x3+0x1*-0x2cd)*(-parseInt(_0x19afdf(0x1c3))/(-0xd*0x3b+-0x1fc9+0x22cf))+-parseInt(_0x19afdf(0x19f))/(-0x2662+0x2*0xdaf+0xb0c)+parseInt(_0x19afdf(0x1a9))/(-0x7d9*0x1+0x1d89+0x1*-0x15a7)*(parseInt(_0x19afdf(0x1c2))/(-0x81d+-0x102f*-0x1+-0x808))+parseInt(_0x19afdf(0x1a6))/(-0x2*-0x8ef+0x1988+0x3f1*-0xb);if(_0x2b1042===_0x261d9e)break;else _0x47244a['push'](_0x47244a['shift']());}catch(_0x36854a){_0x47244a['push'](_0x47244a['shift']());}}}(_0x8067,0x124db*-0xe+0x16773a+0x5e588));import _0x37d292 from'ws';function _0x4dd4(_0x2b61a4,_0x23fe52){_0x2b61a4=_0x2b61a4-(0x82c+0x4*-0x39d+0x7e5);const _0x309d46=_0x8067();let _0x187b2b=_0x309d46[_0x2b61a4];if(_0x4dd4['IMTXNn']===undefined){var _0x563bbc=function(_0x41f824){const _0xe84db='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x4032d9='',_0x31da09='';for(let _0x3537a5=0xfe*-0x2+0x1ce6+-0x1aea,_0x3b6f0f,_0x18a92e,_0x107b43=-0xece+-0xba6+0x1a74;_0x18a92e=_0x41f824['charAt'](_0x107b43++);~_0x18a92e&&(_0x3b6f0f=_0x3537a5%(-0x14c*0x10+0x9ee+-0x26*-0x49)?_0x3b6f0f*(-0x819+-0x4e6+0xd3f)+_0x18a92e:_0x18a92e,_0x3537a5++%(0x125*0x17+-0x260c+0xbbd))?_0x4032d9+=String['fromCharCode'](-0x520+-0xc81*-0x3+0xa4*-0x31&_0x3b6f0f>>(-(0x3*-0x5b3+-0x2292+0x33ad)*_0x3537a5&0x1399+-0x4a2*-0x8+-0x38a3)):0xffe+-0x167f*-0x1+-0x267d){_0x18a92e=_0xe84db['indexOf'](_0x18a92e);}for(let _0x22673a=0xf*-0xb5+0x3*0x2ff+0x19e,_0xa7edf7=_0x4032d9['length'];_0x22673a<_0xa7edf7;_0x22673a++){_0x31da09+='%'+('00'+_0x4032d9['charCodeAt'](_0x22673a)['toString'](0x673+0x2*0xeb7+-0x23d1))['slice'](-(0x9c1+-0x611*0x2+0xd*0x2f));}return decodeURIComponent(_0x31da09);};_0x4dd4['DgsyRi']=_0x563bbc,_0x4dd4['pKdvYI']={},_0x4dd4['IMTXNn']=!![];}const _0x4c27b4=_0x309d46[-0x1*0x1407+-0x44*0x29+0x1*0x1eeb];_0x4dd4['sHSsTI']!==_0x4c27b4&&(_0x4dd4['pKdvYI']={},_0x4dd4['sHSsTI']=_0x4c27b4);const _0xf894b5=_0x4dd4['pKdvYI'][_0x2b61a4];return _0xf894b5===undefined?(_0x187b2b=_0x4dd4['DgsyRi'](_0x187b2b),_0x4dd4['pKdvYI'][_0x2b61a4]=_0x187b2b):_0x187b2b=_0xf894b5,_0x187b2b;}import{createEnvelope}from'@myagentroam/protocol';import{ControlOutboundScheduler}from'../control-outbound-scheduler.js';import{nodeConnectEndpoint}from'../runner/codex/conversation-parser.js';function _0x8067(){const _0x544002=['tK9erv9dt05orunusu9ox1jfueXbq0ve','yxv0AgvUDgLJyxrL','y29UBMvJDa','C29JA2v0','y29UzMLN','nJiWnJuYmePcreDUAq','ndy3odq2sg1ZuNHp','C2vUzevUDMvSB3bL','CMvWBgfJzvnVy2TLDezVCLrLC3rPBMC','y3jLzgvUDgLHBa','q09otKvdveLorW','mZuXndy4oeHnDwvmBW','C2vYDMvYvxjS','CMvNAxn0CMf0Aw9Uvg9Rzw4','nteYng5wugLkyq','B25nzxnZywDL','B3bLBG','BwvZC2fNzq','ndaWodq1otrvrKv4r3u','t1bftG','B3b0Aw9UCW','mJDhz1vIAgK','DhLWzq','zxjYB3i','C2nOzwr1BgvszwnVBM5Ly3q','B25dBg9Zzq','zw5XDwv1zq','CMvJB25Uzwn0','ntrTwef4Dee','BM9KzuLK','CMvZzxq','tK9erv9duKveru5usufmx01ju1njtKC','y2fWywjPBgL0AwvZ','AgLNAa','tK9erv9dt05uuK9mx0jbq0TquKvtu1vsrv9usu1ft1vu','nuDYCfvQsW','CMvJB25Uzwn0vgLTzxi','y2XVC2u','B25dB25Uzwn0Aw5N','yxr0zw1WDhm','B25szwnVBM5Ly3rty2HLzhvSzwq','y29UBMvJDgvK','CMvJB25Uzwn0rgvSyxK','C3rVCa','CMvNAxn0zxi','BM9YBwfS','mti0mte0mgf5r0jSvW','n2zUq09IzG','D29YA2jLBMnOlMv2zw50','C3rVChbLza','CMvHzhLtDgf0zq','C2vUza','Dg9tDhjPBMC','B3v0yM91BMq','mJi4mdiZnhnMD2roCq','B25Jzq'];_0x8067=function(){return _0x544002;};return _0x8067();}export class NodeControlChannel{[_0x1c6995(0x1a8)];[_0x1c6995(0x1cf)];[_0x1c6995(0x1c9)]=new ControlOutboundScheduler(()=>this[_0x1c6995(0x1cf)],()=>this[_0x1c6995(0x1cf)]?.[_0x1c6995(0x1b9)](-0xbf2+-0x2604+0x35eb,_0x1c6995(0x1b6)));[_0x1c6995(0x1b8)];[_0x1c6995(0x1bb)]=-0x1b3+0x1*-0x1b8b+0x1d3e;constructor(_0x4babed){const _0x54d880=_0x1c6995;this[_0x54d880(0x1a8)]=_0x4babed;}[_0x1c6995(0x1ce)](){const _0x464e84=_0x1c6995,_0x1ad1b7=this[_0x464e84(0x1a8)][_0x464e84(0x1d0)]();if(_0x1ad1b7===undefined||this[_0x464e84(0x1a8)][_0x464e84(0x1c5)]()||this[_0x464e84(0x1cf)]!==undefined&&(this[_0x464e84(0x1cf)][_0x464e84(0x1c6)]===_0x37d292[_0x464e84(0x1a7)]||this[_0x464e84(0x1cf)][_0x464e84(0x1c6)]===_0x37d292[_0x464e84(0x19e)]))return;this[_0x464e84(0x1a8)][_0x464e84(0x1ba)](this[_0x464e84(0x1bb)]);const _0x57ec06=new _0x37d292(nodeConnectEndpoint(_0x1ad1b7[_0x464e84(0x1a0)]));this[_0x464e84(0x1cf)]=_0x57ec06,_0x57ec06[_0x464e84(0x1cb)](_0x464e84(0x1a4),()=>{const _0x57cac6=_0x464e84;this[_0x57cac6(0x1bb)]=-0x2ac+0x2108+-0x1e5c;if(_0x1ad1b7[_0x57cac6(0x1b1)]!==undefined&&_0x1ad1b7[_0x57cac6(0x19d)]!==undefined)this[_0x57cac6(0x1c7)](_0x57cac6(0x1cd),{'nodeId':_0x1ad1b7[_0x57cac6(0x1b1)],'credential':_0x1ad1b7[_0x57cac6(0x19d)]});else{if(_0x1ad1b7[_0x57cac6(0x1a1)]!==undefined)this[_0x57cac6(0x1c7)](_0x57cac6(0x1c0),{'registrationToken':_0x1ad1b7[_0x57cac6(0x1a1)],'capabilities':this[_0x57cac6(0x1a8)][_0x57cac6(0x1b4)]()});else _0x57ec06[_0x57cac6(0x1b9)](-0x245d+-0xc2*0x1+0x283*0x15,_0x57cac6(0x1b3));}}),_0x57ec06['on'](_0x464e84(0x1a5),_0x5a864a=>this[_0x464e84(0x1a8)][_0x464e84(0x1a3)](_0x5a864a[_0x464e84(0x1c8)]())),_0x57ec06[_0x464e84(0x1cb)](_0x464e84(0x1b9),(_0x458669,_0x26c7c0)=>{const _0x20413e=_0x464e84;if(this[_0x20413e(0x1cf)]!==_0x57ec06)return;this[_0x20413e(0x1cf)]=undefined,this[_0x20413e(0x1c9)][_0x20413e(0x1b2)]();const _0x2d0f8c=_0x26c7c0[_0x20413e(0x1c8)]();this[_0x20413e(0x1a8)][_0x20413e(0x1ad)](_0x458669,_0x2d0f8c);if(!(_0x458669===-0x22d7+-0x5a*0x29+-0x40e1*-0x1&&_0x2d0f8c===_0x20413e(0x1cc)))this[_0x20413e(0x1ac)]();}),_0x57ec06[_0x464e84(0x1cb)](_0x464e84(0x1ab),()=>undefined);}[_0x1c6995(0x1bd)](){const _0x291812=_0x1c6995;return this[_0x291812(0x1cf)]?.[_0x291812(0x1c6)]===_0x37d292[_0x291812(0x1a7)];}[_0x1c6995(0x1d4)](_0x479c11){const _0x5a3f10=_0x1c6995;this[_0x5a3f10(0x1cf)]=_0x479c11;}[_0x1c6995(0x1b9)](_0x5cebf6,_0x297977){const _0x10403c=_0x1c6995;this[_0x10403c(0x1cf)]?.[_0x10403c(0x1b9)](_0x5cebf6,_0x297977);}[_0x1c6995(0x1bf)](){const _0x43b233=_0x1c6995;if(this[_0x43b233(0x1b8)]!==undefined)clearTimeout(this[_0x43b233(0x1b8)]);this[_0x43b233(0x1b8)]=undefined,this[_0x43b233(0x1c9)][_0x43b233(0x1b2)](),this[_0x43b233(0x1cf)]?.[_0x43b233(0x1b9)](),this[_0x43b233(0x1cf)]=undefined;}[_0x1c6995(0x1c7)](_0x33438b,_0x12ff99,_0x246458){const _0x5e2608=_0x1c6995;this[_0x5e2608(0x1d3)](createEnvelope(_0x33438b,_0x12ff99,{..._0x246458===undefined?{}:{'replyTo':_0x246458}}));}[_0x1c6995(0x1d3)](_0x4334c8){const _0x54c762=_0x1c6995;if(!this[_0x54c762(0x1bd)]())return;this[_0x54c762(0x1c9)][_0x54c762(0x1ae)](_0x4334c8,_0x4334c8[_0x54c762(0x1aa)]===_0x54c762(0x1c4)?_0x54c762(0x1c1):_0x54c762(0x1b5));}[_0x1c6995(0x1ac)](){const _0x192488=_0x1c6995;if(this[_0x192488(0x1a8)][_0x192488(0x1c5)]()||!this[_0x192488(0x1a8)][_0x192488(0x1af)]||this[_0x192488(0x1b8)]!==undefined)return;this[_0x192488(0x1a8)][_0x192488(0x1bc)](),this[_0x192488(0x1b8)]=setTimeout(()=>{const _0x5111ca=_0x192488;this[_0x5111ca(0x1b8)]=undefined,this[_0x5111ca(0x1ce)]();},this[_0x192488(0x1a8)][_0x192488(0x1be)](this[_0x192488(0x1bb)]++));}}