@agentrix/cli 0.0.11 → 0.0.13

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.
@@ -4,13 +4,17 @@ import os from 'node:os';
4
4
  import { randomUUID } from 'node:crypto';
5
5
  import { existsSync, writeFileSync, constants, readFileSync, unlinkSync, mkdirSync } from 'node:fs';
6
6
  import { readFile, writeFile, unlink, open } from 'node:fs/promises';
7
- import { join } from 'node:path';
7
+ import { join as join$1 } from 'node:path';
8
8
  import { setAgentContext, createKeyPair } from '@agentrix/shared';
9
- import { dirname, resolve } from 'path';
9
+ import { join, dirname, resolve } from 'path';
10
10
  import { fileURLToPath } from 'url';
11
+ import { z } from 'zod';
12
+ import { SandboxInstanceConfigSchema, NetworkConfigSchema } from '@xmz-ai/sandbox-runtime';
13
+ import { homedir } from 'os';
14
+ import { getPlatform } from '@xmz-ai/sandbox-runtime/dist/utils/platform.js';
11
15
 
12
16
  var name = "@agentrix/cli";
13
- var version = "0.0.11";
17
+ var version = "0.0.13";
14
18
  var description = "Mobile and Web client for Claude Code and Codex";
15
19
  var author = "agentrix.xmz.ai";
16
20
  var type = "module";
@@ -55,7 +59,7 @@ var files = [
55
59
  var scripts = {
56
60
  "why do we need to build before running tests / dev?": "We need the binary to be built so we run daemon commands which directly run the binary",
57
61
  typecheck: "tsc --noEmit --skipLibCheck 2>&1 | (grep -v 'node_modules/effect' | grep -v 'Symbol.dispose' || true)",
58
- build: "shx rm -rf dist && npx tsc --noEmit --skipLibCheck 2>&1 | (grep -v 'node_modules/effect' | grep -v 'Symbol.dispose' || true) && pkgroll",
62
+ build: "shx rm -rf dist && npx tsc --noEmit --skipLibCheck 2>&1 | (grep -v 'node_modules/effect' | grep -v 'Symbol.dispose' || true) && pkgroll && shx mkdir -p dist/sandbox && shx cp src/sandbox/node-proxy-boot.js dist/sandbox/",
59
63
  prod: "node --env-file=.env ./bin/agentrix.mjs",
60
64
  test: "yarn build && tsx --env-file .env.integration-test node_modules/.bin/vitest run",
61
65
  dev: "yarn build && tsx --env-file .env.dev src/index.ts",
@@ -70,9 +74,9 @@ var pkgroll = {
70
74
  };
71
75
  var dependencies = {
72
76
  "@agentrix/shared": "*",
73
- "@anthropic-ai/claude-agent-sdk": "^0.1.30",
77
+ "@anthropic-ai/claude-agent-sdk": "^0.1.61",
74
78
  "@anthropic-ai/claude-code": "2.0.14",
75
- "@anthropic-ai/sdk": "0.65.0",
79
+ "@anthropic-ai/sdk": "0.71.2",
76
80
  "@modelcontextprotocol/sdk": "^1.15.1",
77
81
  "@openai/codex-sdk": "^0.58.0",
78
82
  "@stablelib/base64": "^2.0.1",
@@ -84,6 +88,7 @@ var dependencies = {
84
88
  "@types/react": "^19.1.9",
85
89
  "@types/tmp": "^0.2.6",
86
90
  "@types/yargs": "^17.0.33",
91
+ "@xmz-ai/sandbox-runtime": "^0.2.1",
87
92
  axios: "^1.10.0",
88
93
  chalk: "^5.4.1",
89
94
  "cross-spawn": "^7.0.6",
@@ -106,6 +111,7 @@ var dependencies = {
106
111
  tar: "^7.4.3",
107
112
  tmp: "^0.2.5",
108
113
  tweetnacl: "^1.0.3",
114
+ undici: "^7.16.0",
109
115
  winston: "^3.18.3",
110
116
  "winston-daily-rotate-file": "^5.0.0",
111
117
  yargs: "^17.7.2",
@@ -186,6 +192,71 @@ var _package = /*#__PURE__*/Object.freeze({
186
192
  version: version
187
193
  });
188
194
 
195
+ const SandboxSettingsSchema = z.object({
196
+ enabled: z.boolean().default(true),
197
+ network: NetworkConfigSchema,
198
+ filesystem: SandboxInstanceConfigSchema.shape.filesystem.optional(),
199
+ env: SandboxInstanceConfigSchema.shape.env.optional()
200
+ });
201
+ function getCommonConfig(projectPath, agentrixHomeDir) {
202
+ const homeDir = homedir();
203
+ return {
204
+ enabled: true,
205
+ network: {
206
+ allowedDomains: "*",
207
+ deniedDomains: []
208
+ },
209
+ commonWritePaths: [
210
+ join(homeDir, ".codex"),
211
+ join(homeDir, ".claude"),
212
+ join(homeDir, ".claude.json"),
213
+ join(homeDir, ".claude.json.lock")
214
+ ],
215
+ agentrixHomeDir,
216
+ env: {
217
+ DEBUG: null,
218
+ AGENTRIX_SERVER_URL: null,
219
+ AGENTRIX_WEBAPP_URL: null,
220
+ AGENTRIX_HOME_DIR: null,
221
+ AGENTRIX_WORKSPACE_HOME_DIR: null,
222
+ AGENTRIX_AGENTS_HOME_DIR: null,
223
+ SRT_DEBUG: null,
224
+ NODE_OPTIONS: `--require ${join(projectPath, "dist", "sandbox", "node-proxy-boot.js")}`
225
+ }
226
+ };
227
+ }
228
+ function getDefaultMacOSSettings(projectPath, agentrixHomeDir) {
229
+ const homeDir = homedir();
230
+ const common = getCommonConfig(projectPath, agentrixHomeDir);
231
+ return {
232
+ enabled: common.enabled,
233
+ network: common.network,
234
+ filesystem: {
235
+ denyRead: [join(homeDir, ".ssh")],
236
+ allowWrite: common.commonWritePaths,
237
+ denyWrite: []
238
+ },
239
+ env: common.env
240
+ };
241
+ }
242
+ function getDefaultLinuxSettings(projectPath, agentrixHomeDir) {
243
+ const common = getCommonConfig(projectPath, agentrixHomeDir);
244
+ return {
245
+ enabled: common.enabled,
246
+ network: common.network,
247
+ filesystem: {
248
+ allowRead: [agentrixHomeDir],
249
+ autoAllowSystemPaths: true,
250
+ allowWrite: common.commonWritePaths,
251
+ denyWrite: []
252
+ },
253
+ env: common.env
254
+ };
255
+ }
256
+ function getDefaultSandboxSettings(platform, projectPath, agentrixHomeDir) {
257
+ return platform === "macos" ? getDefaultMacOSSettings(projectPath, agentrixHomeDir) : getDefaultLinuxSettings(projectPath, agentrixHomeDir);
258
+ }
259
+
189
260
  const __dirname$1 = dirname(fileURLToPath(import.meta.url));
190
261
  function projectPath() {
191
262
  const path = resolve(__dirname$1, "..");
@@ -202,14 +273,15 @@ class Machine {
202
273
  disableCaffeinate;
203
274
  statePaths;
204
275
  secretKey;
276
+ sandboxSettings;
205
277
  constructor() {
206
278
  const args = process.argv.slice(2);
207
279
  this.isDaemonProcess = args[0] === "daemon";
208
280
  this.serverUrl = process.env.AGENTRIX_SERVER_URL || "https://agentrix.xmz.ai";
209
281
  this.webappUrl = process.env.AGENTRIX_WEBAPP_URL || "https://agentrix.xmz.ai";
210
- this.agentrixHomeDir = process.env.AGENTRIX_HOME_DIR ? process.env.AGENTRIX_HOME_DIR.replace(/^~/, os.homedir()) : join(os.homedir(), ".agentrix");
211
- this.agentrixWorkspaceHomeDir = process.env.AGENTRIX_WORKSPACE_HOME_DIR ? process.env.AGENTRIX_WORKSPACE_HOME_DIR.replace(/^~/, os.homedir()) : join(this.agentrixHomeDir, "workspaces");
212
- this.agentrixAgentsHomeDir = process.env.AGENTRIX_AGENTS_HOME_DIR ? process.env.AGENTRIX_AGENTS_HOME_DIR.replace(/^~/, os.homedir()) : join(this.agentrixHomeDir, "agents");
282
+ this.agentrixHomeDir = process.env.AGENTRIX_HOME_DIR ? process.env.AGENTRIX_HOME_DIR.replace(/^~/, os.homedir()) : join$1(os.homedir(), ".agentrix");
283
+ this.agentrixWorkspaceHomeDir = process.env.AGENTRIX_WORKSPACE_HOME_DIR ? process.env.AGENTRIX_WORKSPACE_HOME_DIR.replace(/^~/, os.homedir()) : join$1(this.agentrixHomeDir, "workspaces");
284
+ this.agentrixAgentsHomeDir = process.env.AGENTRIX_AGENTS_HOME_DIR ? process.env.AGENTRIX_AGENTS_HOME_DIR.replace(/^~/, os.homedir()) : join$1(this.agentrixHomeDir, "agents");
213
285
  this.disableCaffeinate = ["true", "1", "yes"].includes(
214
286
  (process.env.AGENTRIX_DISABLE_CAFFEINATE ?? "").toLowerCase()
215
287
  );
@@ -219,12 +291,13 @@ class Machine {
219
291
  this.ensureDir(this.agentrixAgentsHomeDir);
220
292
  this.statePaths = {
221
293
  rootDir: this.agentrixHomeDir,
222
- logsDir: this.ensureDir(join(this.agentrixHomeDir, "logs")),
223
- settingsFile: join(this.agentrixHomeDir, "settings.json"),
224
- credentialsFile: join(this.agentrixHomeDir, "credentials.json"),
225
- daemonStateFile: join(this.agentrixHomeDir, "daemon.state.json"),
226
- daemonLockFile: join(this.agentrixHomeDir, "daemon.state.json.lock")
294
+ logsDir: this.ensureDir(join$1(this.agentrixHomeDir, "logs")),
295
+ settingsFile: join$1(this.agentrixHomeDir, "settings.json"),
296
+ credentialsFile: join$1(this.agentrixHomeDir, "credentials.json"),
297
+ daemonStateFile: join$1(this.agentrixHomeDir, "daemon.state.json"),
298
+ daemonLockFile: join$1(this.agentrixHomeDir, "daemon.state.json.lock")
227
299
  };
300
+ this.sandboxSettings = this.loadSandboxSettings();
228
301
  }
229
302
  generateMachineId() {
230
303
  return `machine-${randomUUID()}`;
@@ -354,26 +427,30 @@ class Machine {
354
427
  }
355
428
  return target;
356
429
  }
430
+ resolveTaskDir(userId, taskId) {
431
+ const dataDir = join$1(this.agentrixWorkspaceHomeDir, "users", userId, taskId);
432
+ return this.ensureDir(dataDir);
433
+ }
357
434
  resolveProjectDir(cwd, userId, taskId) {
358
435
  if (cwd) {
359
436
  return this.ensureDir(cwd.replace(/^~/, os.homedir()));
360
437
  }
361
- const workspaceDir = join(this.agentrixWorkspaceHomeDir, "users", userId, taskId, "project");
438
+ const workspaceDir = join$1(this.agentrixWorkspaceHomeDir, "users", userId, taskId, "project");
362
439
  return this.ensureDir(workspaceDir);
363
440
  }
364
441
  resolveDataDir(userId, taskId) {
365
- const dataDir = join(this.agentrixWorkspaceHomeDir, "users", userId, taskId, "data");
442
+ const dataDir = join$1(this.agentrixWorkspaceHomeDir, "users", userId, taskId, "data");
366
443
  return this.ensureDir(dataDir);
367
444
  }
368
445
  resolveAttachmentsDir(userId, taskId) {
369
- const attachmentsDir = join(this.resolveDataDir(userId, taskId), "attachments");
446
+ const attachmentsDir = join$1(this.resolveDataDir(userId, taskId), "attachments");
370
447
  return this.ensureDir(attachmentsDir);
371
448
  }
372
449
  resolveAgentDir(agentId) {
373
- return join(this.agentrixAgentsHomeDir, agentId);
450
+ return join$1(this.agentrixAgentsHomeDir, agentId);
374
451
  }
375
452
  getInitialCommitHashPath(userId, taskId) {
376
- return join(this.resolveDataDir(userId, taskId), "initial-commit-hash.txt");
453
+ return join$1(this.resolveDataDir(userId, taskId), "initial-commit-hash.txt");
377
454
  }
378
455
  async readInitialCommitHash(userId, taskId) {
379
456
  const path = this.getInitialCommitHashPath(userId, taskId);
@@ -392,7 +469,7 @@ class Machine {
392
469
  await writeFile(path, hash);
393
470
  }
394
471
  getLastSentCommitHashPath(userId, taskId) {
395
- return join(this.resolveDataDir(userId, taskId), "last-sent-commit-hash.txt");
472
+ return join$1(this.resolveDataDir(userId, taskId), "last-sent-commit-hash.txt");
396
473
  }
397
474
  async readLastSentCommitHash(userId, taskId) {
398
475
  const path = this.getLastSentCommitHashPath(userId, taskId);
@@ -412,12 +489,12 @@ class Machine {
412
489
  }
413
490
  writeTaskInput(data) {
414
491
  const path = this.resolveDataDir(data.userId, data.taskId);
415
- const inputFile = join(path, "input.json");
492
+ const inputFile = join$1(path, "input.json");
416
493
  writeFileSync(inputFile, JSON.stringify(data, null, 2));
417
494
  }
418
495
  readTaskInput(userId, taskId) {
419
496
  const path = this.resolveDataDir(userId, taskId);
420
- const inputFile = join(path, "input.json");
497
+ const inputFile = join$1(path, "input.json");
421
498
  if (!existsSync(inputFile)) {
422
499
  throw new Error(`Task input file does not exist: ${inputFile}`);
423
500
  }
@@ -435,10 +512,67 @@ class Machine {
435
512
  }
436
513
  return this.secretKey;
437
514
  }
515
+ /**
516
+ * Read settings file, returns null if file doesn't exist
517
+ */
518
+ readSettings() {
519
+ const { settingsFile } = this.statePaths;
520
+ if (!existsSync(settingsFile)) {
521
+ return null;
522
+ }
523
+ try {
524
+ const content = readFileSync(settingsFile, "utf-8");
525
+ return JSON.parse(content);
526
+ } catch (error) {
527
+ throw new Error(`Failed to parse settings file: ${error}`);
528
+ }
529
+ }
530
+ /**
531
+ * Write settings to file, creating parent directories if needed
532
+ */
533
+ writeSettings(settings) {
534
+ const { settingsFile } = this.statePaths;
535
+ this.ensureDir(dirname(settingsFile));
536
+ writeFileSync(settingsFile, JSON.stringify(settings, null, 2), "utf-8");
537
+ }
538
+ /**
539
+ * Read or initialize settings with default value
540
+ * If file doesn't exist, writes defaultSettings and returns it
541
+ */
542
+ readOrInitSettings(defaultSettings) {
543
+ let settings = this.readSettings();
544
+ if (!settings) {
545
+ this.writeSettings(defaultSettings);
546
+ settings = defaultSettings;
547
+ }
548
+ return settings;
549
+ }
550
+ loadSandboxSettings() {
551
+ const platform = getPlatform();
552
+ const defaultSettings = getDefaultSandboxSettings(platform, projectPath(), this.agentrixHomeDir);
553
+ const defaultFullSettings = {
554
+ sandbox: defaultSettings
555
+ };
556
+ const settings = this.readOrInitSettings(defaultFullSettings);
557
+ if (!settings.sandbox) {
558
+ return defaultSettings;
559
+ }
560
+ return SandboxSettingsSchema.parse(settings.sandbox);
561
+ }
562
+ getSandboxSettings() {
563
+ return this.sandboxSettings;
564
+ }
438
565
  }
439
566
  const machine = new Machine();
440
567
  setAgentContext(machine);
441
568
 
569
+ var machine$1 = /*#__PURE__*/Object.freeze({
570
+ __proto__: null,
571
+ Machine: Machine,
572
+ machine: machine,
573
+ projectPath: projectPath
574
+ });
575
+
442
576
  const consoleFormat = winston.format.printf(({ level, message, timestamp, ...meta }) => {
443
577
  const timeStr = new Date(timestamp).toLocaleTimeString("en-US", {
444
578
  hour12: false,
@@ -523,7 +657,7 @@ function getLogPath(context) {
523
657
  return "";
524
658
  }
525
659
  const filename = context.type === "daemon" ? "daemon.log" : `task-${context.taskId}.log`;
526
- return join(logsDir, filename);
660
+ return join$1(logsDir, filename);
527
661
  }
528
662
 
529
663
  var logger$1 = /*#__PURE__*/Object.freeze({
@@ -533,4 +667,4 @@ var logger$1 = /*#__PURE__*/Object.freeze({
533
667
  logger: logger
534
668
  });
535
669
 
536
- export { Machine as M, _package as _, packageJson as a, logger$1 as b, createLogger as c, getLogPath as g, logger as l, machine as m, projectPath as p };
670
+ export { Machine as M, _package as _, packageJson as a, logger$1 as b, createLogger as c, machine$1 as d, getLogPath as g, logger as l, machine as m, projectPath as p };
@@ -10,10 +10,14 @@ var path$1 = require('node:path');
10
10
  var shared = require('@agentrix/shared');
11
11
  var path = require('path');
12
12
  var require$$7 = require('url');
13
+ var zod = require('zod');
14
+ var sandboxRuntime = require('@xmz-ai/sandbox-runtime');
15
+ var require$$0 = require('os');
16
+ var platform_js = require('@xmz-ai/sandbox-runtime/dist/utils/platform.js');
13
17
 
14
18
  var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
15
19
  var name = "@agentrix/cli";
16
- var version = "0.0.11";
20
+ var version = "0.0.13";
17
21
  var description = "Mobile and Web client for Claude Code and Codex";
18
22
  var author = "agentrix.xmz.ai";
19
23
  var type = "module";
@@ -58,7 +62,7 @@ var files = [
58
62
  var scripts = {
59
63
  "why do we need to build before running tests / dev?": "We need the binary to be built so we run daemon commands which directly run the binary",
60
64
  typecheck: "tsc --noEmit --skipLibCheck 2>&1 | (grep -v 'node_modules/effect' | grep -v 'Symbol.dispose' || true)",
61
- build: "shx rm -rf dist && npx tsc --noEmit --skipLibCheck 2>&1 | (grep -v 'node_modules/effect' | grep -v 'Symbol.dispose' || true) && pkgroll",
65
+ build: "shx rm -rf dist && npx tsc --noEmit --skipLibCheck 2>&1 | (grep -v 'node_modules/effect' | grep -v 'Symbol.dispose' || true) && pkgroll && shx mkdir -p dist/sandbox && shx cp src/sandbox/node-proxy-boot.js dist/sandbox/",
62
66
  prod: "node --env-file=.env ./bin/agentrix.mjs",
63
67
  test: "yarn build && tsx --env-file .env.integration-test node_modules/.bin/vitest run",
64
68
  dev: "yarn build && tsx --env-file .env.dev src/index.ts",
@@ -73,9 +77,9 @@ var pkgroll = {
73
77
  };
74
78
  var dependencies = {
75
79
  "@agentrix/shared": "*",
76
- "@anthropic-ai/claude-agent-sdk": "^0.1.30",
80
+ "@anthropic-ai/claude-agent-sdk": "^0.1.61",
77
81
  "@anthropic-ai/claude-code": "2.0.14",
78
- "@anthropic-ai/sdk": "0.65.0",
82
+ "@anthropic-ai/sdk": "0.71.2",
79
83
  "@modelcontextprotocol/sdk": "^1.15.1",
80
84
  "@openai/codex-sdk": "^0.58.0",
81
85
  "@stablelib/base64": "^2.0.1",
@@ -87,6 +91,7 @@ var dependencies = {
87
91
  "@types/react": "^19.1.9",
88
92
  "@types/tmp": "^0.2.6",
89
93
  "@types/yargs": "^17.0.33",
94
+ "@xmz-ai/sandbox-runtime": "^0.2.1",
90
95
  axios: "^1.10.0",
91
96
  chalk: "^5.4.1",
92
97
  "cross-spawn": "^7.0.6",
@@ -109,6 +114,7 @@ var dependencies = {
109
114
  tar: "^7.4.3",
110
115
  tmp: "^0.2.5",
111
116
  tweetnacl: "^1.0.3",
117
+ undici: "^7.16.0",
112
118
  winston: "^3.18.3",
113
119
  "winston-daily-rotate-file": "^5.0.0",
114
120
  yargs: "^17.7.2",
@@ -189,7 +195,72 @@ var _package = /*#__PURE__*/Object.freeze({
189
195
  version: version
190
196
  });
191
197
 
192
- const __dirname$1 = path.dirname(require$$7.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('logger-BZKdzrRM.cjs', document.baseURI).href))));
198
+ const SandboxSettingsSchema = zod.z.object({
199
+ enabled: zod.z.boolean().default(true),
200
+ network: sandboxRuntime.NetworkConfigSchema,
201
+ filesystem: sandboxRuntime.SandboxInstanceConfigSchema.shape.filesystem.optional(),
202
+ env: sandboxRuntime.SandboxInstanceConfigSchema.shape.env.optional()
203
+ });
204
+ function getCommonConfig(projectPath, agentrixHomeDir) {
205
+ const homeDir = require$$0.homedir();
206
+ return {
207
+ enabled: true,
208
+ network: {
209
+ allowedDomains: "*",
210
+ deniedDomains: []
211
+ },
212
+ commonWritePaths: [
213
+ path.join(homeDir, ".codex"),
214
+ path.join(homeDir, ".claude"),
215
+ path.join(homeDir, ".claude.json"),
216
+ path.join(homeDir, ".claude.json.lock")
217
+ ],
218
+ agentrixHomeDir,
219
+ env: {
220
+ DEBUG: null,
221
+ AGENTRIX_SERVER_URL: null,
222
+ AGENTRIX_WEBAPP_URL: null,
223
+ AGENTRIX_HOME_DIR: null,
224
+ AGENTRIX_WORKSPACE_HOME_DIR: null,
225
+ AGENTRIX_AGENTS_HOME_DIR: null,
226
+ SRT_DEBUG: null,
227
+ NODE_OPTIONS: `--require ${path.join(projectPath, "dist", "sandbox", "node-proxy-boot.js")}`
228
+ }
229
+ };
230
+ }
231
+ function getDefaultMacOSSettings(projectPath, agentrixHomeDir) {
232
+ const homeDir = require$$0.homedir();
233
+ const common = getCommonConfig(projectPath, agentrixHomeDir);
234
+ return {
235
+ enabled: common.enabled,
236
+ network: common.network,
237
+ filesystem: {
238
+ denyRead: [path.join(homeDir, ".ssh")],
239
+ allowWrite: common.commonWritePaths,
240
+ denyWrite: []
241
+ },
242
+ env: common.env
243
+ };
244
+ }
245
+ function getDefaultLinuxSettings(projectPath, agentrixHomeDir) {
246
+ const common = getCommonConfig(projectPath, agentrixHomeDir);
247
+ return {
248
+ enabled: common.enabled,
249
+ network: common.network,
250
+ filesystem: {
251
+ allowRead: [agentrixHomeDir],
252
+ autoAllowSystemPaths: true,
253
+ allowWrite: common.commonWritePaths,
254
+ denyWrite: []
255
+ },
256
+ env: common.env
257
+ };
258
+ }
259
+ function getDefaultSandboxSettings(platform, projectPath, agentrixHomeDir) {
260
+ return platform === "macos" ? getDefaultMacOSSettings(projectPath, agentrixHomeDir) : getDefaultLinuxSettings(projectPath, agentrixHomeDir);
261
+ }
262
+
263
+ const __dirname$1 = path.dirname(require$$7.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('logger-DzYRcKN1.cjs', document.baseURI).href))));
193
264
  function projectPath() {
194
265
  const path$1 = path.resolve(__dirname$1, "..");
195
266
  return path$1;
@@ -205,6 +276,7 @@ class Machine {
205
276
  disableCaffeinate;
206
277
  statePaths;
207
278
  secretKey;
279
+ sandboxSettings;
208
280
  constructor() {
209
281
  const args = process.argv.slice(2);
210
282
  this.isDaemonProcess = args[0] === "daemon";
@@ -228,6 +300,7 @@ class Machine {
228
300
  daemonStateFile: path$1.join(this.agentrixHomeDir, "daemon.state.json"),
229
301
  daemonLockFile: path$1.join(this.agentrixHomeDir, "daemon.state.json.lock")
230
302
  };
303
+ this.sandboxSettings = this.loadSandboxSettings();
231
304
  }
232
305
  generateMachineId() {
233
306
  return `machine-${node_crypto.randomUUID()}`;
@@ -357,6 +430,10 @@ class Machine {
357
430
  }
358
431
  return target;
359
432
  }
433
+ resolveTaskDir(userId, taskId) {
434
+ const dataDir = path$1.join(this.agentrixWorkspaceHomeDir, "users", userId, taskId);
435
+ return this.ensureDir(dataDir);
436
+ }
360
437
  resolveProjectDir(cwd, userId, taskId) {
361
438
  if (cwd) {
362
439
  return this.ensureDir(cwd.replace(/^~/, os.homedir()));
@@ -438,10 +515,67 @@ class Machine {
438
515
  }
439
516
  return this.secretKey;
440
517
  }
518
+ /**
519
+ * Read settings file, returns null if file doesn't exist
520
+ */
521
+ readSettings() {
522
+ const { settingsFile } = this.statePaths;
523
+ if (!fs.existsSync(settingsFile)) {
524
+ return null;
525
+ }
526
+ try {
527
+ const content = fs.readFileSync(settingsFile, "utf-8");
528
+ return JSON.parse(content);
529
+ } catch (error) {
530
+ throw new Error(`Failed to parse settings file: ${error}`);
531
+ }
532
+ }
533
+ /**
534
+ * Write settings to file, creating parent directories if needed
535
+ */
536
+ writeSettings(settings) {
537
+ const { settingsFile } = this.statePaths;
538
+ this.ensureDir(path.dirname(settingsFile));
539
+ fs.writeFileSync(settingsFile, JSON.stringify(settings, null, 2), "utf-8");
540
+ }
541
+ /**
542
+ * Read or initialize settings with default value
543
+ * If file doesn't exist, writes defaultSettings and returns it
544
+ */
545
+ readOrInitSettings(defaultSettings) {
546
+ let settings = this.readSettings();
547
+ if (!settings) {
548
+ this.writeSettings(defaultSettings);
549
+ settings = defaultSettings;
550
+ }
551
+ return settings;
552
+ }
553
+ loadSandboxSettings() {
554
+ const platform = platform_js.getPlatform();
555
+ const defaultSettings = getDefaultSandboxSettings(platform, projectPath(), this.agentrixHomeDir);
556
+ const defaultFullSettings = {
557
+ sandbox: defaultSettings
558
+ };
559
+ const settings = this.readOrInitSettings(defaultFullSettings);
560
+ if (!settings.sandbox) {
561
+ return defaultSettings;
562
+ }
563
+ return SandboxSettingsSchema.parse(settings.sandbox);
564
+ }
565
+ getSandboxSettings() {
566
+ return this.sandboxSettings;
567
+ }
441
568
  }
442
569
  const machine = new Machine();
443
570
  shared.setAgentContext(machine);
444
571
 
572
+ var machine$1 = /*#__PURE__*/Object.freeze({
573
+ __proto__: null,
574
+ Machine: Machine,
575
+ machine: machine,
576
+ projectPath: projectPath
577
+ });
578
+
445
579
  const consoleFormat = winston.format.printf(({ level, message, timestamp, ...meta }) => {
446
580
  const timeStr = new Date(timestamp).toLocaleTimeString("en-US", {
447
581
  hour12: false,
@@ -543,5 +677,6 @@ exports.getLogPath = getLogPath;
543
677
  exports.logger = logger;
544
678
  exports.logger$1 = logger$1;
545
679
  exports.machine = machine;
680
+ exports.machine$1 = machine$1;
546
681
  exports.packageJson = packageJson;
547
682
  exports.projectPath = projectPath;
@@ -0,0 +1,13 @@
1
+ import 'global-agent/bootstrap.js';
2
+ import { setGlobalDispatcher, ProxyAgent } from 'undici';
3
+ const proxyUrl = process.env.GLOBAL_AGENT_HTTP_PROXY || process.env.HTTP_PROXY;
4
+ if (proxyUrl) {
5
+ const dispatcher = new ProxyAgent({
6
+ uri: proxyUrl,
7
+ connect: {
8
+ timeout: 10000
9
+ }
10
+ });
11
+
12
+ setGlobalDispatcher(dispatcher);
13
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agentrix/cli",
3
- "version": "0.0.11",
3
+ "version": "0.0.13",
4
4
  "description": "Mobile and Web client for Claude Code and Codex",
5
5
  "author": "agentrix.xmz.ai",
6
6
  "type": "module",
@@ -45,7 +45,7 @@
45
45
  "scripts": {
46
46
  "why do we need to build before running tests / dev?": "We need the binary to be built so we run daemon commands which directly run the binary",
47
47
  "typecheck": "tsc --noEmit --skipLibCheck 2>&1 | (grep -v 'node_modules/effect' | grep -v 'Symbol.dispose' || true)",
48
- "build": "shx rm -rf dist && npx tsc --noEmit --skipLibCheck 2>&1 | (grep -v 'node_modules/effect' | grep -v 'Symbol.dispose' || true) && pkgroll",
48
+ "build": "shx rm -rf dist && npx tsc --noEmit --skipLibCheck 2>&1 | (grep -v 'node_modules/effect' | grep -v 'Symbol.dispose' || true) && pkgroll && shx mkdir -p dist/sandbox && shx cp src/sandbox/node-proxy-boot.js dist/sandbox/",
49
49
  "prod": "node --env-file=.env ./bin/agentrix.mjs",
50
50
  "test": "yarn build && tsx --env-file .env.integration-test node_modules/.bin/vitest run",
51
51
  "dev": "yarn build && tsx --env-file .env.dev src/index.ts",
@@ -60,9 +60,9 @@
60
60
  },
61
61
  "dependencies": {
62
62
  "@agentrix/shared": "*",
63
- "@anthropic-ai/claude-agent-sdk": "^0.1.30",
63
+ "@anthropic-ai/claude-agent-sdk": "^0.1.61",
64
64
  "@anthropic-ai/claude-code": "2.0.14",
65
- "@anthropic-ai/sdk": "0.65.0",
65
+ "@anthropic-ai/sdk": "0.71.2",
66
66
  "@modelcontextprotocol/sdk": "^1.15.1",
67
67
  "@openai/codex-sdk": "^0.58.0",
68
68
  "@stablelib/base64": "^2.0.1",
@@ -74,6 +74,7 @@
74
74
  "@types/react": "^19.1.9",
75
75
  "@types/tmp": "^0.2.6",
76
76
  "@types/yargs": "^17.0.33",
77
+ "@xmz-ai/sandbox-runtime": "^0.2.1",
77
78
  "axios": "^1.10.0",
78
79
  "chalk": "^5.4.1",
79
80
  "cross-spawn": "^7.0.6",
@@ -96,6 +97,7 @@
96
97
  "tar": "^7.4.3",
97
98
  "tmp": "^0.2.5",
98
99
  "tweetnacl": "^1.0.3",
100
+ "undici": "^7.16.0",
99
101
  "winston": "^3.18.3",
100
102
  "winston-daily-rotate-file": "^5.0.0",
101
103
  "yargs": "^17.7.2",