@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,503 +1,2 @@
1
- import { spawn, spawnSync } from 'node:child_process';
2
- import { randomUUID } from 'node:crypto';
3
- import { existsSync } from 'node:fs';
4
- import { unlink } from 'node:fs/promises';
5
- import { connect } from 'node:net';
6
- import { tmpdir } from 'node:os';
7
- import { join } from 'node:path';
8
- import { createInterface } from 'node:readline';
9
- import { minimalRunnerEnvironment, platformCliInvocation, runRunnerProbe } from './operational.js';
10
- const REQUEST_TIMEOUT_MS = 15_000;
11
- /**
12
- * Maps the facts that the Node can actually establish to user-visible
13
- * controls. In particular, seeing an external thread never implies that it
14
- * is safe to write to its active turn.
15
- */
16
- export function codexSessionControl(input) {
17
- if (!input.available)
18
- return { level: 'UNAVAILABLE', capabilities: [] };
19
- if (input.sharedControl) {
20
- return {
21
- level: 'SHARED_CONTROL',
22
- capabilities: ['history.read', 'events.live', 'turn.start', 'turn.steer', 'turn.interrupt']
23
- };
24
- }
25
- if (input.nativeThreadId !== null && input.nativeControl === 'EXTERNAL') {
26
- return { level: 'OBSERVE_ONLY', capabilities: ['history.read'] };
27
- }
28
- if (input.activeTurn) {
29
- return {
30
- level: 'MANAGED',
31
- capabilities: ['history.read', 'events.live', 'turn.steer', 'turn.interrupt']
32
- };
33
- }
34
- return {
35
- level: 'RESUMABLE',
36
- capabilities: ['history.read', 'turn.start']
37
- };
38
- }
39
- export class CodexAppServerRpcError extends Error {
40
- code;
41
- rpcMessage;
42
- data;
43
- constructor(payload) {
44
- const rpcMessage = typeof payload.message === 'string' ? payload.message : 'Codex App Server request failed';
45
- super(`CODEX_APP_SERVER_RPC_ERROR:${JSON.stringify(payload)}`);
46
- this.name = 'CodexAppServerRpcError';
47
- this.code = payload.code;
48
- this.rpcMessage = rpcMessage;
49
- this.data = payload.data;
50
- }
51
- }
52
- export function isCodexRolloutMissingError(error) {
53
- return (error instanceof CodexAppServerRpcError &&
54
- error.code === -32600 &&
55
- (/^no rollout found for thread id\b/i.test(error.rpcMessage) ||
56
- /^thread not loaded:\s*/i.test(error.rpcMessage)));
57
- }
58
- /**
59
- * Local JSON-RPC client for a Node-supervised Codex App Server. Linux uses a
60
- * private Unix socket by default; Windows uses stdio. Neither is exposed to
61
- * MAR Server or the browser.
62
- */
63
- export class CodexAppServerClient {
64
- options;
65
- child;
66
- transport;
67
- socketPath;
68
- nextId = 1;
69
- pending = new Map();
70
- pendingDrainWaiters = new Set();
71
- notifications = new Set();
72
- environment = {};
73
- starting;
74
- restarting;
75
- lifecycleRevision = 0;
76
- constructor(options = {}) {
77
- this.options = options;
78
- }
79
- configureEnvironment(environment) {
80
- if (this.child !== undefined)
81
- throw new Error('CODEX_APP_SERVER_ALREADY_STARTED');
82
- this.environment = { ...environment };
83
- }
84
- clearEnvironment() {
85
- if (this.child !== undefined)
86
- throw new Error('CODEX_APP_SERVER_ALREADY_STARTED');
87
- this.environment = {};
88
- }
89
- start() {
90
- if (this.restarting !== undefined)
91
- return this.restarting;
92
- if (this.starting !== undefined)
93
- return this.starting;
94
- if (this.child !== undefined)
95
- return Promise.resolve();
96
- const starting = this.startManaged();
97
- this.starting = starting;
98
- const clearStarting = () => {
99
- if (this.starting === starting)
100
- this.starting = undefined;
101
- };
102
- void starting.then(clearStarting, clearStarting);
103
- return starting;
104
- }
105
- restart() {
106
- if (this.restarting !== undefined)
107
- return this.restarting;
108
- const restarting = this.restartManaged(this.lifecycleRevision);
109
- this.restarting = restarting;
110
- const clearRestarting = () => {
111
- if (this.restarting === restarting)
112
- this.restarting = undefined;
113
- };
114
- void restarting.then(clearRestarting, clearRestarting);
115
- return restarting;
116
- }
117
- async startManaged() {
118
- const command = this.options.command ?? 'codex';
119
- const mode = this.transportMode();
120
- this.socketPath =
121
- mode === 'unix' ? (this.options.socketPath ?? privateSocketPath()) : undefined;
122
- const baseArgs = this.options.args ?? ['app-server'];
123
- const args = [
124
- ...baseArgs,
125
- ...(mode === 'unix' ? ['--listen', `unix://${this.socketPath}`] : [])
126
- ];
127
- const spawnProcess = this.options.spawnProcess ?? defaultSpawn;
128
- let child = spawnProcess(command, args, {
129
- ...(this.options.cwd === undefined ? {} : { cwd: this.options.cwd }),
130
- env: { ...minimalRunnerEnvironment(), ...this.environment }
131
- });
132
- this.child = child;
133
- let socket;
134
- if (mode === 'unix') {
135
- try {
136
- socket = await connectUnix(this.socketPath, (this.options.transport ?? 'auto') === 'auto'
137
- ? Math.min(this.options.timeoutMs ?? REQUEST_TIMEOUT_MS, 1_000)
138
- : (this.options.timeoutMs ?? REQUEST_TIMEOUT_MS));
139
- }
140
- catch (error) {
141
- if ((this.options.transport ?? 'auto') !== 'auto')
142
- throw error;
143
- child.kill();
144
- if (this.socketPath !== undefined && existsSync(this.socketPath))
145
- await unlink(this.socketPath);
146
- this.socketPath = undefined;
147
- child = spawnProcess(command, baseArgs, {
148
- ...(this.options.cwd === undefined ? {} : { cwd: this.options.cwd }),
149
- env: { ...minimalRunnerEnvironment(), ...this.environment }
150
- });
151
- this.child = child;
152
- }
153
- }
154
- this.transport = socket ?? stdioTransport(child);
155
- const lines = createInterface({ input: socket ?? child.stdout });
156
- lines.on('line', (line) => this.handleLine(line));
157
- const managedChild = child;
158
- child.once('error', (error) => {
159
- if (this.child !== managedChild)
160
- return;
161
- this.failAll(new Error(`CODEX_APP_SERVER_START_FAILED:${error.message}`));
162
- });
163
- child.once('exit', () => {
164
- if (this.child !== managedChild)
165
- return;
166
- this.child = undefined;
167
- this.failAll(new Error('CODEX_APP_SERVER_EXITED'));
168
- });
169
- await this.requestDirect('initialize', {
170
- clientInfo: { name: 'codex_vscode', title: 'MyAgentRoam', version: '0.1.4' },
171
- capabilities: { experimentalApi: true }
172
- });
173
- this.notify('initialized', {});
174
- }
175
- async restartManaged(lifecycleRevision) {
176
- await Promise.resolve();
177
- if (this.starting !== undefined)
178
- await this.starting;
179
- await this.waitForPendingRequests();
180
- if (this.lifecycleRevision !== lifecycleRevision)
181
- throw new Error('CODEX_APP_SERVER_STOPPED');
182
- this.stopManaged();
183
- await this.startManaged();
184
- }
185
- stop() {
186
- this.lifecycleRevision += 1;
187
- this.stopManaged();
188
- }
189
- stopManaged() {
190
- this.transport?.destroy();
191
- this.transport = undefined;
192
- this.child?.kill();
193
- this.child = undefined;
194
- if (this.socketPath !== undefined && existsSync(this.socketPath))
195
- void unlink(this.socketPath);
196
- this.socketPath = undefined;
197
- this.failAll(new Error('CODEX_APP_SERVER_STOPPED'));
198
- }
199
- onNotification(listener) {
200
- this.notifications.add(listener);
201
- return () => this.notifications.delete(listener);
202
- }
203
- async request(method, params) {
204
- if (this.restarting !== undefined)
205
- await this.restarting;
206
- else if (this.starting !== undefined)
207
- await this.starting;
208
- return this.requestDirect(method, params);
209
- }
210
- requestDirect(method, params) {
211
- const transport = this.transport;
212
- if (transport === undefined || !transport.writable)
213
- throw new Error('CODEX_APP_SERVER_UNAVAILABLE');
214
- const id = this.nextId++;
215
- const timeoutMs = this.options.timeoutMs ?? REQUEST_TIMEOUT_MS;
216
- const result = new Promise((resolve, reject) => {
217
- const timer = setTimeout(() => {
218
- this.pending.delete(id);
219
- this.resolvePendingDrain();
220
- reject(new Error('CODEX_APP_SERVER_TIMEOUT'));
221
- }, timeoutMs);
222
- this.pending.set(id, { resolve, reject, timer });
223
- });
224
- transport.write(`${JSON.stringify({ method, id, params })}\n`);
225
- return result;
226
- }
227
- waitForPendingRequests() {
228
- if (this.pending.size === 0)
229
- return Promise.resolve();
230
- return new Promise((resolve) => this.pendingDrainWaiters.add(resolve));
231
- }
232
- resolvePendingDrain() {
233
- if (this.pending.size !== 0)
234
- return;
235
- for (const resolve of this.pendingDrainWaiters)
236
- resolve();
237
- this.pendingDrainWaiters.clear();
238
- }
239
- notify(method, params) {
240
- const transport = this.transport;
241
- if (transport === undefined || !transport.writable)
242
- throw new Error('CODEX_APP_SERVER_UNAVAILABLE');
243
- transport.write(`${JSON.stringify({ method, params })}\n`);
244
- }
245
- respond(requestId, result) {
246
- const transport = this.transport;
247
- if (transport === undefined || !transport.writable)
248
- throw new Error('CODEX_APP_SERVER_UNAVAILABLE');
249
- transport.write(`${JSON.stringify({ id: requestId, result })}\n`);
250
- }
251
- startThread(cwd, configuration = {}) {
252
- return this.request('thread/start', {
253
- cwd,
254
- ...codexThreadConfiguration(cwd, configuration)
255
- });
256
- }
257
- listThreads() {
258
- return this.request('thread/list', {});
259
- }
260
- listCollaborationModes() {
261
- return this.request('collaborationMode/list', {});
262
- }
263
- listModels(params) {
264
- return this.request('model/list', params);
265
- }
266
- readThread(threadId, includeTurns = true) {
267
- return this.request('thread/read', { threadId, includeTurns });
268
- }
269
- forkThread(threadId, cwd, lastTurnId, configuration = {}) {
270
- return this.request('thread/fork', {
271
- threadId,
272
- lastTurnId,
273
- cwd,
274
- ...codexThreadConfiguration(cwd, configuration)
275
- });
276
- }
277
- setThreadName(threadId, name) {
278
- return this.request('thread/name/set', { threadId, name });
279
- }
280
- resumeThread(threadId, cwd, configuration = {}) {
281
- return this.request('thread/resume', {
282
- threadId,
283
- cwd,
284
- ...codexThreadConfiguration(cwd, configuration)
285
- });
286
- }
287
- startTurn(threadId, text, cwd, configuration = {}, attachments = []) {
288
- return this.request('turn/start', {
289
- threadId,
290
- cwd,
291
- input: [{ type: 'text', text }, ...attachments],
292
- ...codexTurnConfiguration(cwd, configuration)
293
- });
294
- }
295
- steerTurn(threadId, expectedTurnId, text) {
296
- return this.request('turn/steer', {
297
- threadId,
298
- expectedTurnId,
299
- input: [{ type: 'text', text }]
300
- });
301
- }
302
- interruptTurn(threadId, turnId) {
303
- return this.request('turn/interrupt', { threadId, turnId });
304
- }
305
- handleLine(line) {
306
- let message;
307
- try {
308
- message = JSON.parse(line);
309
- }
310
- catch {
311
- return;
312
- }
313
- if ((typeof message.id === 'number' || typeof message.id === 'string') &&
314
- typeof message.method === 'string') {
315
- for (const listener of this.notifications) {
316
- listener({ method: message.method, params: message.params, requestId: message.id });
317
- }
318
- return;
319
- }
320
- if (typeof message.id === 'number') {
321
- const pending = this.pending.get(message.id);
322
- if (pending === undefined)
323
- return;
324
- clearTimeout(pending.timer);
325
- this.pending.delete(message.id);
326
- this.resolvePendingDrain();
327
- if (message.error !== undefined) {
328
- pending.reject(new CodexAppServerRpcError(isRecord(message.error) ? message.error : { message: String(message.error) }));
329
- }
330
- else {
331
- pending.resolve(message.result);
332
- }
333
- return;
334
- }
335
- if (typeof message.method === 'string') {
336
- for (const listener of this.notifications)
337
- listener({ method: message.method, params: message.params });
338
- }
339
- }
340
- failAll(error) {
341
- for (const [id, pending] of this.pending) {
342
- clearTimeout(pending.timer);
343
- pending.reject(error);
344
- this.pending.delete(id);
345
- }
346
- this.resolvePendingDrain();
347
- }
348
- transportMode() {
349
- const requested = this.options.transport ?? 'auto';
350
- if (requested === 'auto')
351
- return process.platform === 'linux' ? 'unix' : 'stdio';
352
- if (requested === 'unix' && process.platform !== 'linux') {
353
- throw new Error('CODEX_UNIX_SOCKET_PLATFORM_UNSUPPORTED');
354
- }
355
- return requested;
356
- }
357
- }
358
- function codexThreadConfiguration(cwd, configuration) {
359
- return {
360
- ...modelOption(configuration.model),
361
- ...(configuration.developerInstructions === undefined
362
- ? {}
363
- : { developerInstructions: configuration.developerInstructions }),
364
- ...(configuration.mcpServers === undefined
365
- ? {}
366
- : { config: { mcp_servers: configuration.mcpServers } }),
367
- ...codexPermissionConfiguration(cwd, configuration.access, 'thread')
368
- };
369
- }
370
- function codexTurnConfiguration(cwd, configuration) {
371
- return {
372
- ...modelOption(configuration.model),
373
- ...(typeof configuration.effort === 'string' ? { effort: configuration.effort } : {}),
374
- ...(configuration.serviceTier === 'fast' ? { serviceTier: 'fast' } : {}),
375
- ...(configuration.collaborationMode === undefined
376
- ? {}
377
- : {
378
- collaborationMode: {
379
- mode: configuration.collaborationMode,
380
- settings: {
381
- model: configuration.model ?? 'gpt-5.6-sol',
382
- reasoningEffort: configuration.effort ?? null
383
- }
384
- }
385
- }),
386
- ...codexPermissionConfiguration(cwd, configuration.access, 'turn')
387
- };
388
- }
389
- function modelOption(model) {
390
- return model === undefined || model === null ? {} : { model };
391
- }
392
- function codexPermissionConfiguration(cwd, access, phase) {
393
- const sandbox = access === 'read-only'
394
- ? 'read-only'
395
- : access === 'workspace-write' || access === 'on-request'
396
- ? 'workspace-write'
397
- : access === 'full-access'
398
- ? 'danger-full-access'
399
- : undefined;
400
- const approvalPolicy = access === 'workspace-write' || access === 'full-access' ? 'never' : 'on-request';
401
- if (phase === 'thread')
402
- return {
403
- ...(sandbox === undefined ? {} : { sandbox }),
404
- approvalPolicy
405
- };
406
- return {
407
- ...(sandbox === undefined
408
- ? {}
409
- : {
410
- sandboxPolicy: sandbox === 'read-only'
411
- ? { type: 'readOnly' }
412
- : sandbox === 'danger-full-access'
413
- ? { type: 'dangerFullAccess' }
414
- : { type: 'workspaceWrite', writableRoots: [cwd], networkAccess: true }
415
- }),
416
- approvalPolicy
417
- };
418
- }
419
- export function probeCodex(command = 'codex') {
420
- const invocation = platformCliInvocation(command, ['--version']);
421
- const result = spawnSync(invocation.command, invocation.args, {
422
- windowsHide: true,
423
- env: minimalRunnerEnvironment(),
424
- timeout: 3_000,
425
- encoding: 'utf8'
426
- });
427
- if (result.status !== 0 || result.error !== undefined)
428
- return { available: false, compatible: false };
429
- const version = `${result.stdout}${result.stderr}`.trim().slice(0, 128);
430
- return {
431
- available: true,
432
- ...(version.length === 0 ? {} : { version }),
433
- // The CLI version is metadata only. Actual compatibility is established
434
- // by the App Server initialize handshake when the client starts.
435
- compatible: true
436
- };
437
- }
438
- export async function probeCodexAsync(command = 'codex') {
439
- const invocation = platformCliInvocation(command, ['--version']);
440
- const result = await runRunnerProbe(invocation.command, invocation.args, {
441
- env: minimalRunnerEnvironment(),
442
- timeoutMs: 3_000
443
- });
444
- if (result.status !== 0)
445
- return { available: false, compatible: false };
446
- const version = `${result.stdout}${result.stderr}`.trim().slice(0, 128);
447
- return {
448
- available: true,
449
- ...(version.length === 0 ? {} : { version }),
450
- // Do not reject a newer CLI before its App Server has had a chance to
451
- // negotiate the protocol it actually supports.
452
- compatible: true
453
- };
454
- }
455
- export function isSupportedCodexVersion(version) {
456
- return version.trim().length > 0;
457
- }
458
- function defaultSpawn(command, args, options) {
459
- const invocation = platformCliInvocation(command, args);
460
- return spawn(invocation.command, invocation.args, {
461
- stdio: ['pipe', 'pipe', 'pipe'],
462
- shell: false,
463
- windowsHide: true,
464
- ...(options.cwd === undefined ? {} : { cwd: options.cwd }),
465
- ...(options.env === undefined ? {} : { env: options.env })
466
- });
467
- }
468
- function isRecord(value) {
469
- return typeof value === 'object' && value !== null && !Array.isArray(value);
470
- }
471
- function stdioTransport(child) {
472
- return {
473
- get writable() {
474
- return child.stdin.writable;
475
- },
476
- write: (data) => child.stdin.write(data),
477
- on: (event, listener) => child.stdout.on(event, listener),
478
- once: (event, listener) => child.stdout.once(event, listener),
479
- destroy: () => child.stdout.destroy()
480
- };
481
- }
482
- function privateSocketPath() {
483
- return join(tmpdir(), `myagentroam-codex-${process.pid}-${randomUUID()}.sock`);
484
- }
485
- function connectUnix(socketPath, timeoutMs) {
486
- return new Promise((resolve, reject) => {
487
- const deadline = Date.now() + timeoutMs;
488
- const attempt = () => {
489
- const socket = connect(socketPath);
490
- const retry = (error) => {
491
- socket.destroy();
492
- if (Date.now() >= deadline) {
493
- reject(new Error(`CODEX_UNIX_SOCKET_CONNECT_FAILED:${error.message}`));
494
- return;
495
- }
496
- setTimeout(attempt, 25);
497
- };
498
- socket.once('connect', () => resolve(socket));
499
- socket.once('error', retry);
500
- };
501
- attempt();
502
- });
503
- }
1
+ /* mar-release-protected */
2
+ const _0x3398cb=_0x29ac;(function(_0x1beea2,_0x1fa0df){const _0x5afb67=_0x29ac,_0x1e8595=_0x1beea2();while(!![]){try{const _0x306d4c=-parseInt(_0x5afb67(0x197))/(0x41d+-0x2*0x1af+0x5*-0x26)+-parseInt(_0x5afb67(0x18f))/(0x1f9a*-0x1+-0x238a*0x1+0x4326)+-parseInt(_0x5afb67(0x17b))/(-0x10*0x255+-0xb9b*0x2+-0x3c89*-0x1)+-parseInt(_0x5afb67(0x162))/(-0x1caf*-0x1+0x120*-0x3+-0x194b)*(-parseInt(_0x5afb67(0x194))/(-0xa27+0x1358+0x4*-0x24b))+parseInt(_0x5afb67(0x16a))/(0x1*-0x2142+-0x20c5+0x420d)+parseInt(_0x5afb67(0x158))/(-0x13ce+-0x10d2+0x24a7)*(-parseInt(_0x5afb67(0x1b3))/(-0x23fa+0x278*0x8+0x2*0x821))+-parseInt(_0x5afb67(0x12c))/(0x1cf*-0x3+0x1*0x2471+-0x1efb)*(-parseInt(_0x5afb67(0x10d))/(-0xd*-0x11b+-0x1639+0x7e4));if(_0x306d4c===_0x1fa0df)break;else _0x1e8595['push'](_0x1e8595['shift']());}catch(_0x12e1b1){_0x1e8595['push'](_0x1e8595['shift']());}}}(_0x3617,0x75e*-0x161+-0x62c2c+0x1ae581));import{spawn,spawnSync}from'node:child_process';import{randomUUID}from'node:crypto';import{existsSync}from'node:fs';import{unlink}from'node:fs/promises';import{connect}from'node:net';import{tmpdir}from'node:os';import{join}from'node:path';import{createInterface}from'node:readline';import{minimalRunnerEnvironment,platformCliInvocation,runRunnerProbe}from'./operational.js';const REQUEST_TIMEOUT_MS=-0x1*-0x3637+-0x713b+0x759c;export function codexSessionControl(_0x21cfc7){const _0x2fd74e=_0x29ac;if(!_0x21cfc7[_0x2fd74e(0x18d)])return{'level':_0x2fd74e(0x171),'capabilities':[]};if(_0x21cfc7[_0x2fd74e(0x168)])return{'level':_0x2fd74e(0x180),'capabilities':[_0x2fd74e(0x1b2),_0x2fd74e(0x10e),_0x2fd74e(0x12d),_0x2fd74e(0x13e),_0x2fd74e(0x16f)]};if(_0x21cfc7[_0x2fd74e(0x154)]!==null&&_0x21cfc7[_0x2fd74e(0x13a)]===_0x2fd74e(0x10b))return{'level':_0x2fd74e(0x157),'capabilities':[_0x2fd74e(0x1b2)]};if(_0x21cfc7[_0x2fd74e(0x179)])return{'level':_0x2fd74e(0x19b),'capabilities':[_0x2fd74e(0x1b2),_0x2fd74e(0x10e),_0x2fd74e(0x13e),_0x2fd74e(0x16f)]};return{'level':_0x2fd74e(0x14d),'capabilities':[_0x2fd74e(0x1b2),_0x2fd74e(0x12d)]};}export class CodexAppServerRpcError extends Error{[_0x3398cb(0x16b)];[_0x3398cb(0x119)];[_0x3398cb(0x165)];constructor(_0x5444e){const _0x4ef841=_0x3398cb,_0xd033ab=typeof _0x5444e[_0x4ef841(0x1b4)]===_0x4ef841(0x172)?_0x5444e[_0x4ef841(0x1b4)]:_0x4ef841(0x1ad);super(_0x4ef841(0x17e)+JSON[_0x4ef841(0x163)](_0x5444e)),this[_0x4ef841(0x15f)]=_0x4ef841(0x155),this[_0x4ef841(0x16b)]=_0x5444e[_0x4ef841(0x16b)],this[_0x4ef841(0x119)]=_0xd033ab,this[_0x4ef841(0x165)]=_0x5444e[_0x4ef841(0x165)];}}export function isCodexRolloutMissingError(_0x2260e6){const _0x52f45f=_0x3398cb;return _0x2260e6 instanceof CodexAppServerRpcError&&_0x2260e6[_0x52f45f(0x16b)]===-(0xa076+-0xaac2+0x89a4)&&(/^no rollout found for thread id\b/i[_0x52f45f(0x10f)](_0x2260e6[_0x52f45f(0x119)])||/^thread not loaded:\s*/i[_0x52f45f(0x10f)](_0x2260e6[_0x52f45f(0x119)]));}export class CodexAppServerClient{[_0x3398cb(0x13d)];[_0x3398cb(0x117)];[_0x3398cb(0x11e)];[_0x3398cb(0x193)];[_0x3398cb(0x130)]=0x1*0x1ec5+-0xa*-0xe9+-0x27de;[_0x3398cb(0x14a)]=new Map();[_0x3398cb(0x190)]=new Set();[_0x3398cb(0x12b)]=new Set();[_0x3398cb(0x174)]={};[_0x3398cb(0x11f)];[_0x3398cb(0x184)];[_0x3398cb(0x19c)]=-0xefb+0x1698+-0x1*0x79d;constructor(_0x4539ff={}){const _0x4cdc2f=_0x3398cb;this[_0x4cdc2f(0x13d)]=_0x4539ff;}[_0x3398cb(0x191)](_0x16b81b){const _0x2273e4=_0x3398cb;if(this[_0x2273e4(0x117)]!==undefined)throw new Error(_0x2273e4(0x18c));this[_0x2273e4(0x174)]={..._0x16b81b};}[_0x3398cb(0x195)](){const _0x372fe6=_0x3398cb;if(this[_0x372fe6(0x117)]!==undefined)throw new Error(_0x372fe6(0x18c));this[_0x372fe6(0x174)]={};}[_0x3398cb(0x1a1)](){const _0x302213=_0x3398cb;if(this[_0x302213(0x184)]!==undefined)return this[_0x302213(0x184)];if(this[_0x302213(0x11f)]!==undefined)return this[_0x302213(0x11f)];if(this[_0x302213(0x117)]!==undefined)return Promise[_0x302213(0x118)]();const _0x1ce164=this[_0x302213(0x153)]();this[_0x302213(0x11f)]=_0x1ce164;const _0x52039c=()=>{const _0x4bb469=_0x302213;if(this[_0x4bb469(0x11f)]===_0x1ce164)this[_0x4bb469(0x11f)]=undefined;};return void _0x1ce164[_0x302213(0x129)](_0x52039c,_0x52039c),_0x1ce164;}[_0x3398cb(0x132)](){const _0x59fed5=_0x3398cb;if(this[_0x59fed5(0x184)]!==undefined)return this[_0x59fed5(0x184)];const _0x442eed=this[_0x59fed5(0x14f)](this[_0x59fed5(0x19c)]);this[_0x59fed5(0x184)]=_0x442eed;const _0x597ee6=()=>{const _0x5164a9=_0x59fed5;if(this[_0x5164a9(0x184)]===_0x442eed)this[_0x5164a9(0x184)]=undefined;};return void _0x442eed[_0x59fed5(0x129)](_0x597ee6,_0x597ee6),_0x442eed;}async[_0x3398cb(0x153)](){const _0x2060fa=_0x3398cb,_0x78415a=this[_0x2060fa(0x13d)][_0x2060fa(0x137)]??_0x2060fa(0x110),_0x58fa00=this[_0x2060fa(0x169)]();this[_0x2060fa(0x193)]=_0x58fa00===_0x2060fa(0x1a8)?this[_0x2060fa(0x13d)][_0x2060fa(0x193)]??privateSocketPath():undefined;const _0x3039b1=this[_0x2060fa(0x13d)][_0x2060fa(0x109)]??[_0x2060fa(0x12f)],_0x2b9405=[..._0x3039b1,..._0x58fa00===_0x2060fa(0x1a8)?[_0x2060fa(0x182),_0x2060fa(0x1a9)+this[_0x2060fa(0x193)]]:[]],_0x4cf7d2=this[_0x2060fa(0x13d)][_0x2060fa(0x11d)]??defaultSpawn;let _0x2bcb52=_0x4cf7d2(_0x78415a,_0x2b9405,{...this[_0x2060fa(0x13d)][_0x2060fa(0x150)]===undefined?{}:{'cwd':this[_0x2060fa(0x13d)][_0x2060fa(0x150)]},'env':{...minimalRunnerEnvironment(),...this[_0x2060fa(0x174)]}});this[_0x2060fa(0x117)]=_0x2bcb52;let _0x56cd01;if(_0x58fa00===_0x2060fa(0x1a8))try{_0x56cd01=await connectUnix(this[_0x2060fa(0x193)],(this[_0x2060fa(0x13d)][_0x2060fa(0x11e)]??_0x2060fa(0x17d))===_0x2060fa(0x17d)?Math[_0x2060fa(0x1a3)](this[_0x2060fa(0x13d)][_0x2060fa(0x18e)]??REQUEST_TIMEOUT_MS,0x27*-0xc7+-0x61*0x26+0x309f):this[_0x2060fa(0x13d)][_0x2060fa(0x18e)]??REQUEST_TIMEOUT_MS);}catch(_0x5a5769){if((this[_0x2060fa(0x13d)][_0x2060fa(0x11e)]??_0x2060fa(0x17d))!==_0x2060fa(0x17d))throw _0x5a5769;_0x2bcb52[_0x2060fa(0x147)]();if(this[_0x2060fa(0x193)]!==undefined&&existsSync(this[_0x2060fa(0x193)]))await unlink(this[_0x2060fa(0x193)]);this[_0x2060fa(0x193)]=undefined,_0x2bcb52=_0x4cf7d2(_0x78415a,_0x3039b1,{...this[_0x2060fa(0x13d)][_0x2060fa(0x150)]===undefined?{}:{'cwd':this[_0x2060fa(0x13d)][_0x2060fa(0x150)]},'env':{...minimalRunnerEnvironment(),...this[_0x2060fa(0x174)]}}),this[_0x2060fa(0x117)]=_0x2bcb52;}this[_0x2060fa(0x11e)]=_0x56cd01??stdioTransport(_0x2bcb52);const _0x2521f5=createInterface({'input':_0x56cd01??_0x2bcb52[_0x2060fa(0x15b)]});_0x2521f5['on'](_0x2060fa(0x113),_0xd50d6c=>this[_0x2060fa(0x15c)](_0xd50d6c));const _0x4c0048=_0x2bcb52;_0x2bcb52[_0x2060fa(0x11b)](_0x2060fa(0x175),_0x16a70e=>{const _0x41cfe6=_0x2060fa;if(this[_0x41cfe6(0x117)]!==_0x4c0048)return;this[_0x41cfe6(0x167)](new Error(_0x41cfe6(0x152)+_0x16a70e[_0x41cfe6(0x1b4)]));}),_0x2bcb52[_0x2060fa(0x11b)](_0x2060fa(0x1ab),()=>{const _0x14f13e=_0x2060fa;if(this[_0x14f13e(0x117)]!==_0x4c0048)return;this[_0x14f13e(0x117)]=undefined,this[_0x14f13e(0x167)](new Error(_0x14f13e(0x15a)));}),await this[_0x2060fa(0x15d)](_0x2060fa(0x1a6),{'clientInfo':{'name':_0x2060fa(0x188),'title':_0x2060fa(0x126),'version':_0x2060fa(0x196)},'capabilities':{'experimentalApi':!![]}}),this[_0x2060fa(0x131)](_0x2060fa(0x173),{});}async[_0x3398cb(0x14f)](_0x229bdb){const _0xd4cc02=_0x3398cb;await Promise[_0xd4cc02(0x118)]();if(this[_0xd4cc02(0x11f)]!==undefined)await this[_0xd4cc02(0x11f)];await this[_0xd4cc02(0x17a)]();if(this[_0xd4cc02(0x19c)]!==_0x229bdb)throw new Error(_0xd4cc02(0x125));this[_0xd4cc02(0x123)](),await this[_0xd4cc02(0x153)]();}[_0x3398cb(0x149)](){const _0x4137bd=_0x3398cb;this[_0x4137bd(0x19c)]+=-0x1a4*-0x1+0x2*-0x164+-0x1*-0x125,this[_0x4137bd(0x123)]();}[_0x3398cb(0x123)](){const _0x3575b5=_0x3398cb;this[_0x3575b5(0x11e)]?.[_0x3575b5(0x12a)](),this[_0x3575b5(0x11e)]=undefined,this[_0x3575b5(0x117)]?.[_0x3575b5(0x147)](),this[_0x3575b5(0x117)]=undefined;if(this[_0x3575b5(0x193)]!==undefined&&existsSync(this[_0x3575b5(0x193)]))void unlink(this[_0x3575b5(0x193)]);this[_0x3575b5(0x193)]=undefined,this[_0x3575b5(0x167)](new Error(_0x3575b5(0x125)));}[_0x3398cb(0x121)](_0x14bd68){const _0x5ca501=_0x3398cb;return this[_0x5ca501(0x12b)][_0x5ca501(0x13f)](_0x14bd68),()=>this[_0x5ca501(0x12b)][_0x5ca501(0x16c)](_0x14bd68);}async[_0x3398cb(0x16d)](_0x38de57,_0x1ec18d){const _0x50bd99=_0x3398cb;if(this[_0x50bd99(0x184)]!==undefined)await this[_0x50bd99(0x184)];else{if(this[_0x50bd99(0x11f)]!==undefined)await this[_0x50bd99(0x11f)];}return this[_0x50bd99(0x15d)](_0x38de57,_0x1ec18d);}[_0x3398cb(0x15d)](_0x4bddc8,_0x1ab01f){const _0x106686=_0x3398cb,_0xc28c6e=this[_0x106686(0x11e)];if(_0xc28c6e===undefined||!_0xc28c6e[_0x106686(0x13b)])throw new Error(_0x106686(0x11a));const _0x5e4d31=this[_0x106686(0x130)]++,_0x5a71ae=this[_0x106686(0x13d)][_0x106686(0x18e)]??REQUEST_TIMEOUT_MS,_0xd6208a=new Promise((_0x1f52c9,_0x41312a)=>{const _0x530c93=_0x106686,_0x483812=setTimeout(()=>{const _0x5ba390=_0x29ac;this[_0x5ba390(0x14a)][_0x5ba390(0x16c)](_0x5e4d31),this[_0x5ba390(0x192)](),_0x41312a(new Error(_0x5ba390(0x1ac)));},_0x5a71ae);this[_0x530c93(0x14a)][_0x530c93(0x1af)](_0x5e4d31,{'resolve':_0x1f52c9,'reject':_0x41312a,'timer':_0x483812});});return _0xc28c6e[_0x106686(0x14b)](JSON[_0x106686(0x163)]({'method':_0x4bddc8,'id':_0x5e4d31,'params':_0x1ab01f})+'\x0a'),_0xd6208a;}[_0x3398cb(0x17a)](){const _0x2d0b04=_0x3398cb;if(this[_0x2d0b04(0x14a)][_0x2d0b04(0x164)]===0x1b03+-0x4*0xc1+-0x17ff)return Promise[_0x2d0b04(0x118)]();return new Promise(_0x4bc49b=>this[_0x2d0b04(0x190)][_0x2d0b04(0x13f)](_0x4bc49b));}[_0x3398cb(0x192)](){const _0x4fdb7f=_0x3398cb;if(this[_0x4fdb7f(0x14a)][_0x4fdb7f(0x164)]!==0xc31+0x139f*0x1+-0x1fd0)return;for(const _0x418806 of this[_0x4fdb7f(0x190)])_0x418806();this[_0x4fdb7f(0x190)][_0x4fdb7f(0x156)]();}[_0x3398cb(0x131)](_0x34e72c,_0x2a04fb){const _0x1e21cf=_0x3398cb,_0x109ac3=this[_0x1e21cf(0x11e)];if(_0x109ac3===undefined||!_0x109ac3[_0x1e21cf(0x13b)])throw new Error(_0x1e21cf(0x11a));_0x109ac3[_0x1e21cf(0x14b)](JSON[_0x1e21cf(0x163)]({'method':_0x34e72c,'params':_0x2a04fb})+'\x0a');}[_0x3398cb(0x1a2)](_0x46e779,_0x10150a){const _0x655583=_0x3398cb,_0x172af8=this[_0x655583(0x11e)];if(_0x172af8===undefined||!_0x172af8[_0x655583(0x13b)])throw new Error(_0x655583(0x11a));_0x172af8[_0x655583(0x14b)](JSON[_0x655583(0x163)]({'id':_0x46e779,'result':_0x10150a})+'\x0a');}[_0x3398cb(0x161)](_0x4ca1a5,_0x376deb={}){const _0x5ee886=_0x3398cb;return this[_0x5ee886(0x16d)](_0x5ee886(0x111),{'cwd':_0x4ca1a5,...codexThreadConfiguration(_0x4ca1a5,_0x376deb)});}[_0x3398cb(0x115)](){const _0x38fef4=_0x3398cb;return this[_0x38fef4(0x16d)](_0x38fef4(0x176),{});}[_0x3398cb(0x135)](){const _0x3ee4cf=_0x3398cb;return this[_0x3ee4cf(0x16d)](_0x3ee4cf(0x116),{});}[_0x3398cb(0x177)](_0x46c685){const _0x15a735=_0x3398cb;return this[_0x15a735(0x16d)](_0x15a735(0x10c),_0x46c685);}[_0x3398cb(0x181)](_0x5cb35b,_0x7c30d2=!![]){const _0x4e4cf9=_0x3398cb;return this[_0x4e4cf9(0x16d)](_0x4e4cf9(0x1b0),{'threadId':_0x5cb35b,'includeTurns':_0x7c30d2});}[_0x3398cb(0x134)](_0x4e7ad6,_0x545841,_0x1de7b8,_0x3fdce8={}){const _0x277f58=_0x3398cb;return this[_0x277f58(0x16d)](_0x277f58(0x143),{'threadId':_0x4e7ad6,'lastTurnId':_0x1de7b8,'cwd':_0x545841,...codexThreadConfiguration(_0x545841,_0x3fdce8)});}[_0x3398cb(0x160)](_0x10c17e,_0x59f6b3){const _0x3fb6c1=_0x3398cb;return this[_0x3fb6c1(0x16d)](_0x3fb6c1(0x166),{'threadId':_0x10c17e,'name':_0x59f6b3});}[_0x3398cb(0x198)](_0x5c0347,_0x5e2130,_0x260220={}){const _0x522293=_0x3398cb;return this[_0x522293(0x16d)](_0x522293(0x170),{'threadId':_0x5c0347,'cwd':_0x5e2130,...codexThreadConfiguration(_0x5e2130,_0x260220)});}[_0x3398cb(0x19a)](_0x2e4278,_0x5b4330,_0x23098d,_0xe7b82e={},_0x305c5e=[]){const _0x37b01a=_0x3398cb;return this[_0x37b01a(0x16d)](_0x37b01a(0x127),{'threadId':_0x2e4278,'cwd':_0x23098d,'input':[{'type':_0x37b01a(0x159),'text':_0x5b4330},..._0x305c5e],...codexTurnConfiguration(_0x23098d,_0xe7b82e)});}[_0x3398cb(0x102)](_0x1b3264,_0x52b792,_0x52c01e){const _0x29c9d4=_0x3398cb;return this[_0x29c9d4(0x16d)](_0x29c9d4(0x178),{'threadId':_0x1b3264,'expectedTurnId':_0x52b792,'input':[{'type':_0x29c9d4(0x159),'text':_0x52c01e}]});}[_0x3398cb(0x14e)](_0x36d866,_0x4a529f){const _0x22f4b3=_0x3398cb;return this[_0x22f4b3(0x16d)](_0x22f4b3(0x120),{'threadId':_0x36d866,'turnId':_0x4a529f});}[_0x3398cb(0x15c)](_0x4e78ea){const _0x782efa=_0x3398cb;let _0x1e0489;try{_0x1e0489=JSON[_0x782efa(0x18a)](_0x4e78ea);}catch{return;}if((typeof _0x1e0489['id']===_0x782efa(0x1a5)||typeof _0x1e0489['id']===_0x782efa(0x172))&&typeof _0x1e0489[_0x782efa(0x124)]===_0x782efa(0x172)){for(const _0x3a3e8c of this[_0x782efa(0x12b)]){_0x3a3e8c({'method':_0x1e0489[_0x782efa(0x124)],'params':_0x1e0489[_0x782efa(0x112)],'requestId':_0x1e0489['id']});}return;}if(typeof _0x1e0489['id']===_0x782efa(0x1a5)){const _0x2c1f55=this[_0x782efa(0x14a)][_0x782efa(0x1aa)](_0x1e0489['id']);if(_0x2c1f55===undefined)return;clearTimeout(_0x2c1f55[_0x782efa(0x183)]),this[_0x782efa(0x14a)][_0x782efa(0x16c)](_0x1e0489['id']),this[_0x782efa(0x192)]();_0x1e0489[_0x782efa(0x175)]!==undefined?_0x2c1f55[_0x782efa(0x17c)](new CodexAppServerRpcError(isRecord(_0x1e0489[_0x782efa(0x175)])?_0x1e0489[_0x782efa(0x175)]:{'message':String(_0x1e0489[_0x782efa(0x175)])})):_0x2c1f55[_0x782efa(0x118)](_0x1e0489[_0x782efa(0x1a4)]);return;}if(typeof _0x1e0489[_0x782efa(0x124)]===_0x782efa(0x172)){for(const _0x21a36f of this[_0x782efa(0x12b)])_0x21a36f({'method':_0x1e0489[_0x782efa(0x124)],'params':_0x1e0489[_0x782efa(0x112)]});}}[_0x3398cb(0x167)](_0xa73923){const _0x51c087=_0x3398cb;for(const [_0x47caad,_0x34ec4e]of this[_0x51c087(0x14a)]){clearTimeout(_0x34ec4e[_0x51c087(0x183)]),_0x34ec4e[_0x51c087(0x17c)](_0xa73923),this[_0x51c087(0x14a)][_0x51c087(0x16c)](_0x47caad);}this[_0x51c087(0x192)]();}[_0x3398cb(0x169)](){const _0x21640e=_0x3398cb,_0x3e0f8b=this[_0x21640e(0x13d)][_0x21640e(0x11e)]??_0x21640e(0x17d);if(_0x3e0f8b===_0x21640e(0x17d))return process[_0x21640e(0x16e)]===_0x21640e(0x185)?_0x21640e(0x1a8):_0x21640e(0x19d);if(_0x3e0f8b===_0x21640e(0x1a8)&&process[_0x21640e(0x16e)]!==_0x21640e(0x185))throw new Error(_0x21640e(0x1a7));return _0x3e0f8b;}}function codexThreadConfiguration(_0x514de0,_0x4a33e2){const _0xd346ea=_0x3398cb;return{...modelOption(_0x4a33e2[_0xd346ea(0x14c)]),..._0x4a33e2[_0xd346ea(0x19e)]===undefined?{}:{'developerInstructions':_0x4a33e2[_0xd346ea(0x19e)]},..._0x4a33e2[_0xd346ea(0x148)]===undefined?{}:{'config':{'mcp_servers':_0x4a33e2[_0xd346ea(0x148)]}},...codexPermissionConfiguration(_0x514de0,_0x4a33e2[_0xd346ea(0x128)],_0xd346ea(0x1b1))};}function _0x29ac(_0x4b5305,_0x38699a){_0x4b5305=_0x4b5305-(-0x1*0x1ad5+0xfd3+0xc04*0x1);const _0x4ece43=_0x3617();let _0x1360e4=_0x4ece43[_0x4b5305];if(_0x29ac['IlaDGM']===undefined){var _0x31fb15=function(_0x18333a){const _0x2d4865='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x9a867f='',_0xa78902='';for(let _0xf6549e=0x2f*0x9b+0x23e0+-0x2b*0x17f,_0x1aa57e,_0x168758,_0xa40838=-0x8a*0x16+-0x24+0xc00;_0x168758=_0x18333a['charAt'](_0xa40838++);~_0x168758&&(_0x1aa57e=_0xf6549e%(0x1*-0x493+0x1ec5*0x1+-0x1a2e)?_0x1aa57e*(-0x6*0x32f+-0xefb+-0x1*-0x2255)+_0x168758:_0x168758,_0xf6549e++%(0x27*-0xc7+-0x61*0x26+0x2cbb))?_0x9a867f+=String['fromCharCode'](-0x1a4*-0x1+0x2*-0x164+-0x1*-0x223&_0x1aa57e>>(-(0x1b03+-0x4*0xc1+-0x17fd)*_0xf6549e&0xc31+0x139f*0x1+-0x1fca)):-0x2168+-0xcee+0x2e56){_0x168758=_0x2d4865['indexOf'](_0x168758);}for(let _0x4cd075=-0xffd+0x2381+-0x1384,_0x135be3=_0x9a867f['length'];_0x4cd075<_0x135be3;_0x4cd075++){_0xa78902+='%'+('00'+_0x9a867f['charCodeAt'](_0x4cd075)['toString'](0x2559*0x1+-0x6c6+-0x1e83))['slice'](-(0x16e9+0x294+-0x197b));}return decodeURIComponent(_0xa78902);};_0x29ac['wzUsBu']=_0x31fb15,_0x29ac['ngcNxi']={},_0x29ac['IlaDGM']=!![];}const _0xd668f3=_0x4ece43[0x9f3+0x1815+-0x2208];_0x29ac['JheipB']!==_0xd668f3&&(_0x29ac['ngcNxi']={},_0x29ac['JheipB']=_0xd668f3);const _0x500d14=_0x29ac['ngcNxi'][_0x4b5305];return _0x500d14===undefined?(_0x1360e4=_0x29ac['wzUsBu'](_0x1360e4),_0x29ac['ngcNxi'][_0x4b5305]=_0x1360e4):_0x1360e4=_0x500d14,_0x1360e4;}function codexTurnConfiguration(_0x452b33,_0x123a7e){const _0x4d2d70=_0x3398cb;return{...modelOption(_0x123a7e[_0x4d2d70(0x14c)]),...typeof _0x123a7e[_0x4d2d70(0x145)]===_0x4d2d70(0x172)?{'effort':_0x123a7e[_0x4d2d70(0x145)]}:{},..._0x123a7e[_0x4d2d70(0x136)]===_0x4d2d70(0x141)?{'serviceTier':_0x4d2d70(0x141)}:{},..._0x123a7e[_0x4d2d70(0x146)]===undefined?{}:{'collaborationMode':{'mode':_0x123a7e[_0x4d2d70(0x146)],'settings':{'model':_0x123a7e[_0x4d2d70(0x14c)]??_0x4d2d70(0x186),'reasoningEffort':_0x123a7e[_0x4d2d70(0x145)]??null}}},...codexPermissionConfiguration(_0x452b33,_0x123a7e[_0x4d2d70(0x128)],_0x4d2d70(0x199))};}function modelOption(_0xc6a4ae){return _0xc6a4ae===undefined||_0xc6a4ae===null?{}:{'model':_0xc6a4ae};}function codexPermissionConfiguration(_0x380044,_0x587c75,_0x1087dc){const _0x299099=_0x3398cb,_0x47bfea=_0x587c75===_0x299099(0x106)?_0x299099(0x106):_0x587c75===_0x299099(0x13c)||_0x587c75===_0x299099(0x151)?_0x299099(0x13c):_0x587c75===_0x299099(0x144)?_0x299099(0x10a):undefined,_0x5d8b13=_0x587c75===_0x299099(0x13c)||_0x587c75===_0x299099(0x144)?_0x299099(0x103):_0x299099(0x151);if(_0x1087dc===_0x299099(0x1b1))return{..._0x47bfea===undefined?{}:{'sandbox':_0x47bfea},'approvalPolicy':_0x5d8b13};return{..._0x47bfea===undefined?{}:{'sandboxPolicy':_0x47bfea===_0x299099(0x106)?{'type':_0x299099(0x138)}:_0x47bfea===_0x299099(0x10a)?{'type':_0x299099(0x18b)}:{'type':_0x299099(0x104),'writableRoots':[_0x380044],'networkAccess':!![]}},'approvalPolicy':_0x5d8b13};}export function probeCodex(_0x24183e=_0x3398cb(0x110)){const _0x7c6692=_0x3398cb,_0x253802=platformCliInvocation(_0x24183e,[_0x7c6692(0x187)]),_0xc13892=spawnSync(_0x253802[_0x7c6692(0x137)],_0x253802[_0x7c6692(0x109)],{'windowsHide':!![],'env':minimalRunnerEnvironment(),'timeout':0xbb8,'encoding':_0x7c6692(0x108)});if(_0xc13892[_0x7c6692(0x189)]!==-0x2168+-0xcee+0x2e56||_0xc13892[_0x7c6692(0x175)]!==undefined)return{'available':![],'compatible':![]};const _0xd0879=(''+_0xc13892[_0x7c6692(0x15b)]+_0xc13892[_0x7c6692(0x12e)])[_0x7c6692(0x105)]()[_0x7c6692(0x15e)](-0xffd+0x2381+-0x1384,0x2559*0x1+-0x6c6+-0x1e13);return{'available':!![],..._0xd0879[_0x7c6692(0x107)]===0x16e9+0x294+-0x197d?{}:{'version':_0xd0879},'compatible':!![]};}export async function probeCodexAsync(_0x1f8e80=_0x3398cb(0x110)){const _0x1de881=_0x3398cb,_0x4a0bfc=platformCliInvocation(_0x1f8e80,[_0x1de881(0x187)]),_0x114e6f=await runRunnerProbe(_0x4a0bfc[_0x1de881(0x137)],_0x4a0bfc[_0x1de881(0x109)],{'env':minimalRunnerEnvironment(),'timeoutMs':0xbb8});if(_0x114e6f[_0x1de881(0x189)]!==0x9f3+0x1815+-0x2208)return{'available':![],'compatible':![]};const _0x4e7c64=(''+_0x114e6f[_0x1de881(0x15b)]+_0x114e6f[_0x1de881(0x12e)])[_0x1de881(0x105)]()[_0x1de881(0x15e)](-0xbb*-0x1f+-0x131*-0x6+-0x1d*0x107,-0x1f9+-0x1f29+0x21a2);return{'available':!![],..._0x4e7c64[_0x1de881(0x107)]===-0x6df*0x3+0x97*-0x34+0x3349?{}:{'version':_0x4e7c64},'compatible':!![]};}export function isSupportedCodexVersion(_0x25b1a8){const _0x1d0d89=_0x3398cb;return _0x25b1a8[_0x1d0d89(0x105)]()[_0x1d0d89(0x107)]>0x5*0xef+-0xf47*0x1+0x184*0x7;}function _0x3617(){const _0x4ce52b=['AgfUzgXLtgLUzq','CMvXDwvZDerPCMvJDa','C2XPy2u','BMfTzq','C2v0vgHYzwfKtMfTzq','C3rHCNruAhjLywq','mZm5mZe0oe9buLrUCW','C3rYAw5NAwz5','C2L6zq','zgf0yq','DgHYzwfKl25HBwuVC2v0','zMfPBefSBa','C2HHCMvKq29UDhjVBa','DhjHBNnWB3j0tw9Kzq','mZG2mtG1oe5mwK9JqG','y29Kzq','zgvSzxrL','CMvXDwvZDa','CgXHDgzVCM0','DhvYBI5PBNrLCNj1Chq','DgHYzwfKl3jLC3vTzq','vu5bvKfjtefcteu','C3rYAw5N','Aw5PDgLHBgL6zwq','zw52AxjVBM1LBNq','zxjYB3i','DgHYzwfKl2XPC3q','BgLZDe1VzgvSCW','DhvYBI9ZDgvLCG','ywn0AxzLvhvYBG','D2fPDezVCLbLBMrPBMDszxf1zxn0CW','oty5nte2yuvJyuXd','CMvQzwn0','yxv0BW','q09ervHFqvbqx1nfuLzfuL9suenFrvjst1i6','q09ervHFvu5jwf9tt0nlrvrFq09otKvdvf9gquLmruq6','u0HbuKvex0nptLrst0W','CMvHzfrOCMvHza','ls1SAxn0zw4','DgLTzxi','CMvZDgfYDgLUzW','BgLUDxG','z3b0ltuUnI1ZB2W','ls12zxjZAw9U','y29KzxHFDNnJB2rL','C3rHDhvZ','CgfYC2u','zgfUz2vYrNvSBefJy2vZCW','q09ervHFqvbqx1nfuLzfuL9btfjfqurzx1nuqvjuruq','yxzHAwXHyMXL','DgLTzw91De1Z','ntC4otuYChzVq1DW','CgvUzgLUz0rYywLUv2fPDgvYCW','y29UzMLNDxjLrw52AxjVBM1LBNq','CMvZB2X2zvbLBMrPBMDeCMfPBG','C29JA2v0ugf0Aa','nu5Vy1bOra','y2XLyxjfBNzPCM9UBwvUDa','mc4XlJq','nZC1nZq5wxLuAxzO','CMvZDw1LvgHYzwfK','DhvYBG','C3rHCNruDxjU','tufoquDfra','BgLMzwn5y2XLuMv2AxnPB24','C3rKAw8','zgv2zwXVCgvYsw5ZDhj1y3rPB25Z','AxnbCNjHEq','B2jQzwn0','C3rHCNq','CMvZCg9Uza','BwLU','CMvZDwX0','BNvTyMvY','Aw5PDgLHBgL6zq','q09ervHFvu5jwf9tt0nlrvrFueXbvezpuK1Fvu5tvvbqt1juruq','Dw5PEa','Dw5PEdOVlW','z2v0','zxHPDa','q09ervHFqvbqx1nfuLzfuL9usu1ft1vu','q29KzxGGqxbWifnLCNzLCIbYzxf1zxn0igzHAwXLza','BM93','C2v0','DgHYzwfKl3jLywq','DgHYzwfK','AgLZDg9YEs5YzwfK','mZjfwKLsufu','BwvZC2fNzq','C3rLzxjuDxjU','BMv2zxi','D29YA3nWywnLv3jPDgu','DhjPBq','CMvHzc1VBMX5','BgvUz3rO','DxrMoa','yxjNCW','zgfUz2vYlwz1BgWTywnJzxnZ','rvHurvjoquW','Bw9KzwWVBgLZDa','mZaYmhr0EeLTva','zxzLBNrZlMXPDMu','DgvZDa','y29KzxG','DgHYzwfKl3n0yxj0','CgfYyw1Z','BgLUzq','CgLK','BgLZDfrOCMvHzhm','y29SBgfIB3jHDgLVBK1VzguVBgLZDa','y2HPBgq','CMvZB2X2zq','CNbJtwvZC2fNzq','q09ervHFqvbqx1nfuLzfuL9vtKfwquLmqujmrq','B25Jzq','C3rKAw4','C3bHD25qCM9JzxnZ','DhjHBNnWB3j0','C3rHCNrPBMC','DhvYBI9PBNrLCNj1Chq','B25oB3rPzMLJyxrPB24','CgLWzq','C3rVCe1HBMfNzwq','Bwv0Ag9K','q09ervHFqvbqx1nfuLzfuL9tve9queve','txLbz2vUDfjVyw0','DhvYBI9ZDgfYDa','ywnJzxnZ','DgHLBG','zgvZDhjVEq','BM90AwzPy2f0Aw9UCW','ntm4mJLur2L2uLe','DhvYBI5ZDgfYDa','C3rKzxjY','yxbWlxnLCNzLCG','BMv4DeLK','BM90Awz5','CMvZDgfYDa','lNnVy2S','zM9YA1rOCMvHza','BgLZDenVBgXHyM9YyxrPB25nB2rLCW','C2vYDMLJzvrPzxi','y29TBwfUza','CMvHze9UBhK','y29UBMvJDa','BMf0AxzLq29UDhjVBa','D3jPDgfIBgu','D29YA3nWywnLlxDYAxrL','B3b0Aw9UCW','DhvYBI5ZDgvLCG','ywrK','BxLHz2vUDhjVyw0Ty29KzxGT','zMfZDa','zw52','DgHYzwfKl2zVCMS','zNvSBc1Hy2nLC3m','zwzMB3j0','y29SBgfIB3jHDgLVBK1Vzgu','A2LSBa','BwnWu2vYDMvYCW','C3rVCa','CgvUzgLUzW','D3jPDgu','Bw9KzwW','uKvtvu1bqKXf','Aw50zxjYDxb0vhvYBG','CMvZDgfYDe1HBMfNzwq','y3DK','B24TCMvXDwvZDa','q09ervHFqvbqx1nfuLzfuL9tvefsvf9gquLmruq6','C3rHCNrnyw5Hz2vK','BMf0AxzLvgHYzwfKswq','q29KzxHbChbtzxj2zxjsCgnfCNjVCG','y2XLyxi','t0jtrvjwrv9ptKXz','mJeZmdqYouDwv1r0yW','Dgv4Da','q09ervHFqvbqx1nfuLzfuL9fweLuruq','C3rKB3v0'];_0x3617=function(){return _0x4ce52b;};return _0x3617();}function defaultSpawn(_0x1e1981,_0x391090,_0x29cfe3){const _0x2ac765=_0x3398cb,_0x537e43=platformCliInvocation(_0x1e1981,_0x391090);return spawn(_0x537e43[_0x2ac765(0x137)],_0x537e43[_0x2ac765(0x109)],{'stdio':[_0x2ac765(0x122),_0x2ac765(0x122),_0x2ac765(0x122)],'shell':![],'windowsHide':!![],..._0x29cfe3[_0x2ac765(0x150)]===undefined?{}:{'cwd':_0x29cfe3[_0x2ac765(0x150)]},..._0x29cfe3[_0x2ac765(0x142)]===undefined?{}:{'env':_0x29cfe3[_0x2ac765(0x142)]}});}function isRecord(_0xfb18a){const _0x582b21=_0x3398cb;return typeof _0xfb18a===_0x582b21(0x1a0)&&_0xfb18a!==null&&!Array[_0x582b21(0x19f)](_0xfb18a);}function stdioTransport(_0x484ef2){const _0x33445a=_0x3398cb;return{get 'writable'(){const _0xa5433d=_0x29ac;return _0x484ef2[_0xa5433d(0x11c)][_0xa5433d(0x13b)];},'write':_0x4ffc61=>_0x484ef2[_0x33445a(0x11c)][_0x33445a(0x14b)](_0x4ffc61),'on':(_0x1cc3a3,_0x19eafc)=>_0x484ef2[_0x33445a(0x15b)]['on'](_0x1cc3a3,_0x19eafc),'once':(_0x2e6fdb,_0x28fd69)=>_0x484ef2[_0x33445a(0x15b)][_0x33445a(0x11b)](_0x2e6fdb,_0x28fd69),'destroy':()=>_0x484ef2[_0x33445a(0x15b)][_0x33445a(0x12a)]()};}function privateSocketPath(){const _0x5bb59a=_0x3398cb;return join(tmpdir(),_0x5bb59a(0x140)+process[_0x5bb59a(0x114)]+'-'+randomUUID()+_0x5bb59a(0x133));}function connectUnix(_0x47217c,_0x55b559){return new Promise((_0x340de6,_0x5e2e83)=>{const _0x482a24=_0x29ac,_0x496390=Date[_0x482a24(0x1ae)]()+_0x55b559,_0x4ae08c=()=>{const _0x1b6972=_0x482a24,_0x246d08=connect(_0x47217c),_0x2bdef3=_0x15439e=>{const _0x2bfcd4=_0x29ac;_0x246d08[_0x2bfcd4(0x12a)]();if(Date[_0x2bfcd4(0x1ae)]()>=_0x496390){_0x5e2e83(new Error(_0x2bfcd4(0x17f)+_0x15439e[_0x2bfcd4(0x1b4)]));return;}setTimeout(_0x4ae08c,-0x5d1+0x1dee+0x6a*-0x3a);};_0x246d08[_0x1b6972(0x11b)](_0x1b6972(0x139),()=>_0x340de6(_0x246d08)),_0x246d08[_0x1b6972(0x11b)](_0x1b6972(0x175),_0x2bdef3);};_0x4ae08c();});}
package/dist/config.js CHANGED
@@ -1,56 +1,2 @@
1
- import { chmod, mkdir, readFile, writeFile } from 'node:fs/promises';
2
- import { homedir } from 'node:os';
3
- import { dirname, resolve, win32 } from 'node:path';
4
- export function nodeConfigPath() {
5
- return resolve(process.env['MAR_NODE_CONFIG'] ?? 'data/mar-node.json');
6
- }
7
- export async function loadNodeConfig(path = nodeConfigPath()) {
8
- const parsed = JSON.parse(await readFile(path, 'utf8'));
9
- if (typeof parsed !== 'object' ||
10
- parsed === null ||
11
- !('serverUrl' in parsed) ||
12
- typeof parsed.serverUrl !== 'string' ||
13
- 'databasePath' in parsed ||
14
- ('allowedRoots' in parsed &&
15
- (!Array.isArray(parsed.allowedRoots) ||
16
- !parsed.allowedRoots.every((root) => typeof root === 'string')))) {
17
- throw new Error('NODE_CONFIG_INVALID');
18
- }
19
- const input = parsed;
20
- const optionalString = (name) => typeof input[name] === 'string' ? input[name] : undefined;
21
- const nodeId = optionalString('nodeId');
22
- const credential = optionalString('credential');
23
- const registrationToken = optionalString('registrationToken');
24
- const dataDirectory = optionalString('dataDirectory');
25
- const allowedRoots = Array.isArray(input['allowedRoots'])
26
- ? input['allowedRoots']
27
- : defaultAllowedRoots();
28
- return {
29
- serverUrl: parsed.serverUrl,
30
- allowedRoots,
31
- ...(nodeId === undefined ? {} : { nodeId }),
32
- ...(credential === undefined ? {} : { credential }),
33
- ...(registrationToken === undefined ? {} : { registrationToken }),
34
- ...(dataDirectory === undefined ? {} : { dataDirectory })
35
- };
36
- }
37
- /** Uses the Node service account's scope when no Workspace roots are configured. */
38
- export function defaultAllowedRoots(platform = process.platform, homePath = homedir(), currentDirectory = process.cwd()) {
39
- return platform === 'win32' ? [win32.parse(currentDirectory).root] : [homePath];
40
- }
41
- export function nodeDatabasePath(config, configPath = nodeConfigPath()) {
42
- return resolve(nodeDataDirectory(config, configPath), 'node-runtime.sqlite');
43
- }
44
- export function nodeDataDirectory(config, configPath = nodeConfigPath()) {
45
- if (config.dataDirectory !== undefined)
46
- return resolve(dirname(configPath), config.dataDirectory);
47
- return resolve(dirname(configPath));
48
- }
49
- /** Credentials are always written with owner-only POSIX permissions where supported. */
50
- export async function saveNodeConfig(config, path = nodeConfigPath()) {
51
- await mkdir(dirname(path), { recursive: true, mode: 0o700 });
52
- await writeFile(path, `${JSON.stringify(config, undefined, 2)}\n`, { mode: 0o600 });
53
- if (process.platform !== 'win32') {
54
- await chmod(path, 0o600);
55
- }
56
- }
1
+ /* mar-release-protected */
2
+ const _0x5cdfcb=_0x2d83;(function(_0x2e0db7,_0x2c6e9c){const _0x1e9108=_0x2d83,_0x541413=_0x2e0db7();while(!![]){try{const _0x2969d3=parseInt(_0x1e9108(0x183))/(0x1*0x122e+-0x114d+-0xe0)*(parseInt(_0x1e9108(0x17b))/(-0x117f+0xf85+0x1fc))+parseInt(_0x1e9108(0x172))/(0x7bf+-0x1984*-0x1+-0x2140)*(-parseInt(_0x1e9108(0x18c))/(-0x19*0x37+0x1e5d+-0x18fa*0x1))+-parseInt(_0x1e9108(0x17a))/(-0x22af+0xabe+0x17f6)*(-parseInt(_0x1e9108(0x16b))/(-0x84*-0x1e+0x15bb+-0x252d))+-parseInt(_0x1e9108(0x17e))/(-0x1416+0x1711+-0x6c*0x7)*(-parseInt(_0x1e9108(0x182))/(0x2*0x305+0x1*-0x2d8+-0x1b*0x1e))+-parseInt(_0x1e9108(0x185))/(0x46c*-0x1+-0xf6f+0x13e4)*(-parseInt(_0x1e9108(0x173))/(0x260e+-0xd29*-0x1+-0x332d))+parseInt(_0x1e9108(0x16f))/(0xd9*-0x8+0x2268+-0x1b95)*(-parseInt(_0x1e9108(0x17d))/(0xd63+-0x843+-0x514))+parseInt(_0x1e9108(0x174))/(0x1c08+-0x1471+-0x182*0x5)*(-parseInt(_0x1e9108(0x17f))/(-0x3b9+0x1b4a*-0x1+-0xb*-0x2d3));if(_0x2969d3===_0x2c6e9c)break;else _0x541413['push'](_0x541413['shift']());}catch(_0x4d57d7){_0x541413['push'](_0x541413['shift']());}}}(_0x56c0,-0xca217*0x1+0x146cf7+0x2*0x2fde9));import{chmod,mkdir,readFile,writeFile}from'node:fs/promises';import{homedir}from'node:os';function _0x2d83(_0x3ea1a0,_0x31e96f){_0x3ea1a0=_0x3ea1a0-(-0x1*-0x911+-0x63f*0x1+-0x168);const _0x323d11=_0x56c0();let _0x137f52=_0x323d11[_0x3ea1a0];if(_0x2d83['UthjSx']===undefined){var _0x19d402=function(_0x2914ab){const _0x3b1b65='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x79ae61='',_0x587b44='';for(let _0xdd16d7=0x3*0xb60+0x17b7+-0x39d7,_0xe66d64,_0xad7078,_0x357d57=0x13e9+0x85a*0x1+0x1*-0x1c43;_0xad7078=_0x2914ab['charAt'](_0x357d57++);~_0xad7078&&(_0xe66d64=_0xdd16d7%(0x58f+-0x7*0x3a3+0x13ea)?_0xe66d64*(0x2b*0x3b+0x3e+-0x9e7)+_0xad7078:_0xad7078,_0xdd16d7++%(-0x5ee+0x18d7+-0x12e5))?_0x79ae61+=String['fromCharCode'](0x9c3*-0x3+0x779+0x16cf&_0xe66d64>>(-(0x1ea1+0x15*0x11b+-0x2*0x1aeb)*_0xdd16d7&0xdd*0x13+-0x3ad*-0x1+-0x2*0xa07)):0x10*0x37+0x1*-0x2450+0x20e0){_0xad7078=_0x3b1b65['indexOf'](_0xad7078);}for(let _0x5df757=0x1b48+0x1844*0x1+0x2*-0x19c6,_0x409b71=_0x79ae61['length'];_0x5df757<_0x409b71;_0x5df757++){_0x587b44+='%'+('00'+_0x79ae61['charCodeAt'](_0x5df757)['toString'](-0x10b9+-0x1a9d+0x2b66))['slice'](-(-0x132e+-0x1*-0x168e+-0x35e));}return decodeURIComponent(_0x587b44);};_0x2d83['HpEFKi']=_0x19d402,_0x2d83['VWHBBm']={},_0x2d83['UthjSx']=!![];}const _0x59850a=_0x323d11[0x8*0x34b+0x6f2*-0x1+-0x1366];_0x2d83['TymISG']!==_0x59850a&&(_0x2d83['VWHBBm']={},_0x2d83['TymISG']=_0x59850a);const _0x527240=_0x2d83['VWHBBm'][_0x3ea1a0];return _0x527240===undefined?(_0x137f52=_0x2d83['HpEFKi'](_0x137f52),_0x2d83['VWHBBm'][_0x3ea1a0]=_0x137f52):_0x137f52=_0x527240,_0x137f52;}import{dirname,resolve,win32}from'node:path';export function nodeConfigPath(){const _0x14f161=_0x2d83;return resolve(process.env['MAR_NODE_CONFIG']??_0x14f161(0x18b));}export async function loadNodeConfig(_0x5edf56=nodeConfigPath()){const _0x2705b3=_0x2d83,_0x2561ed=JSON[_0x2705b3(0x186)](await readFile(_0x5edf56,_0x2705b3(0x188)));if(typeof _0x2561ed!==_0x2705b3(0x181)||_0x2561ed===null||!(_0x2705b3(0x171)in _0x2561ed)||typeof _0x2561ed[_0x2705b3(0x171)]!==_0x2705b3(0x179)||_0x2705b3(0x178)in _0x2561ed||_0x2705b3(0x177)in _0x2561ed&&(!Array[_0x2705b3(0x175)](_0x2561ed[_0x2705b3(0x177)])||!_0x2561ed[_0x2705b3(0x177)][_0x2705b3(0x170)](_0x2873cf=>typeof _0x2873cf===_0x2705b3(0x179))))throw new Error(_0x2705b3(0x16a));const _0x81d381=_0x2561ed,_0x3bc87a=_0x4e01d2=>typeof _0x81d381[_0x4e01d2]===_0x2705b3(0x179)?_0x81d381[_0x4e01d2]:undefined,_0x2ffbef=_0x3bc87a(_0x2705b3(0x187)),_0x304150=_0x3bc87a(_0x2705b3(0x16e)),_0x465a0e=_0x3bc87a(_0x2705b3(0x17c)),_0x281a98=_0x3bc87a(_0x2705b3(0x16d)),_0x23cc42=Array[_0x2705b3(0x175)](_0x81d381[_0x2705b3(0x177)])?_0x81d381[_0x2705b3(0x177)]:defaultAllowedRoots();return{'serverUrl':_0x2561ed[_0x2705b3(0x171)],'allowedRoots':_0x23cc42,..._0x2ffbef===undefined?{}:{'nodeId':_0x2ffbef},..._0x304150===undefined?{}:{'credential':_0x304150},..._0x465a0e===undefined?{}:{'registrationToken':_0x465a0e},..._0x281a98===undefined?{}:{'dataDirectory':_0x281a98}};}export function defaultAllowedRoots(_0x16e9b8=process[_0x5cdfcb(0x180)],_0x2ce03e=homedir(),_0xdbed1b=process[_0x5cdfcb(0x176)]()){const _0x41d03b=_0x5cdfcb;return _0x16e9b8===_0x41d03b(0x184)?[win32[_0x41d03b(0x186)](_0xdbed1b)[_0x41d03b(0x189)]]:[_0x2ce03e];}function _0x56c0(){const _0x533dd5=['B2jQzwn0','nZa3ntC4nePetMrZDq','mwrtuwXiwq','D2LUmZi','nZC5mdGWnxDusNfsuG','CgfYC2u','BM9KzuLK','DxrMoa','CM9VDa','C3rYAw5NAwz5','zgf0ys9TyxiTBM9Kzs5QC29U','ogTsDKrjwa','tK9erv9dt05gsuDFsu5wquXjra','mtjVv1n3r2u','BM9Kzs1YDw50Aw1LlNnXBgL0zq','zgf0yurPCMvJDg9YEq','y3jLzgvUDgLHBa','mti2nvfYEKvRAq','zxzLCNK','C2vYDMvYvxjS','mtiZmtq3m2HUuhLhEG','mtblrLzXyKe','mtnIvuvksu4','AxnbCNjHEq','y3DK','ywXSB3DLzfjVB3rZ','zgf0ywjHC2vqyxrO','C3rYAw5N','ndq2mdC4mfLHsujcAW','mJe0nJiWnezjB2LIAq','CMvNAxn0CMf0Aw9Uvg9Rzw4','mJK1ntz5qKfdtMq','n1DOAgzewG','mZy0mdy1otr5AKLNBNy','CgXHDgzVCM0'];_0x56c0=function(){return _0x533dd5;};return _0x56c0();}export function nodeDatabasePath(_0xbf19ef,_0x38cf91=nodeConfigPath()){const _0x30606e=_0x5cdfcb;return resolve(nodeDataDirectory(_0xbf19ef,_0x38cf91),_0x30606e(0x16c));}export function nodeDataDirectory(_0x4f9efc,_0x5baa9a=nodeConfigPath()){const _0x7c861d=_0x5cdfcb;if(_0x4f9efc[_0x7c861d(0x16d)]!==undefined)return resolve(dirname(_0x5baa9a),_0x4f9efc[_0x7c861d(0x16d)]);return resolve(dirname(_0x5baa9a));}export async function saveNodeConfig(_0x193046,_0x24f569=nodeConfigPath()){const _0x2729cd=_0x5cdfcb;await mkdir(dirname(_0x24f569),{'recursive':!![],'mode':0x1c0}),await writeFile(_0x24f569,JSON[_0x2729cd(0x18a)](_0x193046,undefined,0x247+0x3*-0x887+0x1750)+'\x0a',{'mode':0x180}),process[_0x2729cd(0x180)]!==_0x2729cd(0x184)&&await chmod(_0x24f569,0x1*0x267f+-0x2197*-0x1+-0x4696);}
@@ -1 +1,2 @@
1
- export {};
1
+ /* mar-release-protected */
2
+ export{};
@@ -1,22 +1,2 @@
1
- /** Exact allow-list dispatcher for protocol-defined Node operations. */
2
- export class NodeOperationRouter {
3
- handlers = new Map();
4
- register(operation, handler) {
5
- if (this.handlers.has(operation))
6
- throw new Error(`NODE_OPERATION_ALREADY_REGISTERED:${operation}`);
7
- this.handlers.set(operation, handler);
8
- }
9
- registerAll(handlers) {
10
- for (const [operation, handler] of Object.entries(handlers))
11
- this.register(operation, handler);
12
- }
13
- has(operation) {
14
- return this.handlers.has(operation);
15
- }
16
- execute(operation, data) {
17
- const handler = this.handlers.get(operation);
18
- if (handler === undefined)
19
- return Promise.reject(new Error('OPERATION_UNSUPPORTED'));
20
- return Promise.resolve(handler(data));
21
- }
22
- }
1
+ /* mar-release-protected */
2
+ const _0x178f5a=_0x139b;function _0x139b(_0x60f191,_0x5d8fb1){_0x60f191=_0x60f191-(-0x8c*-0x1d+0x4db+0x5*-0x409);const _0x588c24=_0x3c16();let _0x273a4b=_0x588c24[_0x60f191];if(_0x139b['qiMLoz']===undefined){var _0x36b7c0=function(_0x4dc197){const _0x43e5e1='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x234262='',_0x251deb='';for(let _0x46bb56=-0x1*0x13c9+-0xe39+0x2202,_0x4e4013,_0x5324bc,_0x181332=-0x9c7+0x553*-0x5+0x2*0x1233;_0x5324bc=_0x4dc197['charAt'](_0x181332++);~_0x5324bc&&(_0x4e4013=_0x46bb56%(-0x1ed9+0x1b4*-0x10+0x57*0xab)?_0x4e4013*(0x3*0x3cd+-0x9d*-0x3+-0xcfe)+_0x5324bc:_0x5324bc,_0x46bb56++%(-0x15e2*0x1+-0xd0*0x2c+0x5e*0x9d))?_0x234262+=String['fromCharCode'](-0x2390+-0x9c7*-0x2+0x1101&_0x4e4013>>(-(0x2*-0x306+0x5a6+-0x2*-0x34)*_0x46bb56&-0x42f+0xf0b*-0x1+-0x8*-0x268)):-0x2*-0xaa1+-0x1*0x31e+-0x1224){_0x5324bc=_0x43e5e1['indexOf'](_0x5324bc);}for(let _0x316ec3=0x117f+-0x22a0+0x1121,_0x51cf57=_0x234262['length'];_0x316ec3<_0x51cf57;_0x316ec3++){_0x251deb+='%'+('00'+_0x234262['charCodeAt'](_0x316ec3)['toString'](0x16b4+-0xe1d*0x1+-0x887))['slice'](-(-0x10df+0xa5c+0x1*0x685));}return decodeURIComponent(_0x251deb);};_0x139b['onDvee']=_0x36b7c0,_0x139b['nQechu']={},_0x139b['qiMLoz']=!![];}const _0x493ce7=_0x588c24[0x371*-0xb+-0xb2*-0x8+-0x7*-0x49d];_0x139b['xpTuhA']!==_0x493ce7&&(_0x139b['nQechu']={},_0x139b['xpTuhA']=_0x493ce7);const _0x1b3150=_0x139b['nQechu'][_0x60f191];return _0x1b3150===undefined?(_0x273a4b=_0x139b['onDvee'](_0x273a4b),_0x139b['nQechu'][_0x60f191]=_0x273a4b):_0x273a4b=_0x1b3150,_0x273a4b;}function _0x3c16(){const _0x51755c=['zw50CMLLCW','nJy1nZqYngvJB0DLDa','AgfZ','CMvZB2X2zq','mtrpyKrRt0S','mZq4DNHWA09p','t1bfuKfusu9ox1vou1vque9sveve','ndu4ntqWnNnTuhfPwG','ota3mZy0mfzRrNnKwG','CMvNAxn0zxjbBgW','mtCXotqYmfL3t3HtDq','mtHcExjmy3C','mJKZntj2re5dzuS','CMvQzwn0','AgfUzgXLCNm','C2v0','CMvNAxn0zxi','z2v0','zxHLy3v0zq','mtm3nJu0y050uMP6','tK9erv9puevsqvrjt05FquXsrufewv9sruDju1rfuKveoG','otu1nZy2n09hyuryuG'];_0x3c16=function(){return _0x51755c;};return _0x3c16();}(function(_0x2d056f,_0x28262b){const _0x1e6007=_0x139b,_0x18da60=_0x2d056f();while(!![]){try{const _0x2654a5=parseInt(_0x1e6007(0x8e))/(0x359*0xa+-0x6ef+0x4f*-0x56)*(-parseInt(_0x1e6007(0x9d))/(0xed*-0xb+-0x3*0x2e3+0xfe*0x13))+parseInt(_0x1e6007(0x96))/(0x1cd+0xc6f+0xe39*-0x1)*(-parseInt(_0x1e6007(0x8f))/(0xe46+0x26bd*-0x1+0x187b*0x1))+parseInt(_0x1e6007(0x94))/(-0x1*0x1b3f+0x1a66+0xde)*(-parseInt(_0x1e6007(0x95))/(0x14cd+0x705+-0x6*0x4a2))+parseInt(_0x1e6007(0x91))/(-0x161*0x1+0xa36+0x1*-0x8ce)+parseInt(_0x1e6007(0x8b))/(0x494*-0x6+0xc95+0xeeb)+parseInt(_0x1e6007(0x9f))/(0x1*-0xd74+0x1188+-0xcf*0x5)+parseInt(_0x1e6007(0x92))/(-0x1b6e+0x1dd2+0x2b*-0xe);if(_0x2654a5===_0x28262b)break;else _0x18da60['push'](_0x18da60['shift']());}catch(_0x515ce7){_0x18da60['push'](_0x18da60['shift']());}}}(_0x3c16,-0x306*-0xe6+-0xd0c94+0x427*0x4bb));export class NodeOperationRouter{[_0x178f5a(0x98)]=new Map();[_0x178f5a(0x9a)](_0x2f8de8,_0x2353fc){const _0x337311=_0x178f5a;if(this[_0x337311(0x98)][_0x337311(0x8c)](_0x2f8de8))throw new Error(_0x337311(0x9e)+_0x2f8de8);this[_0x337311(0x98)][_0x337311(0x99)](_0x2f8de8,_0x2353fc);}[_0x178f5a(0x93)](_0x208754){const _0x4a4a69=_0x178f5a;for(const [_0x23c17d,_0xf327c6]of Object[_0x4a4a69(0x8a)](_0x208754))this[_0x4a4a69(0x9a)](_0x23c17d,_0xf327c6);}[_0x178f5a(0x8c)](_0x2ce50c){const _0x2856a4=_0x178f5a;return this[_0x2856a4(0x98)][_0x2856a4(0x8c)](_0x2ce50c);}[_0x178f5a(0x9c)](_0x4c5c25,_0x577396){const _0x3bffa2=_0x178f5a,_0x503341=this[_0x3bffa2(0x98)][_0x3bffa2(0x9b)](_0x4c5c25);if(_0x503341===undefined)return Promise[_0x3bffa2(0x97)](new Error(_0x3bffa2(0x90)));return Promise[_0x3bffa2(0x8d)](_0x503341(_0x577396));}}