@moxt-ai/cli 0.8.0-beta.1 → 0.8.0-beta.2

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.
package/dist/index.cjs CHANGED
@@ -551,8 +551,8 @@ var require_graceful_fs = __commonJS({
551
551
  fs10.createReadStream = createReadStream;
552
552
  fs10.createWriteStream = createWriteStream2;
553
553
  var fs$readFile = fs10.readFile;
554
- fs10.readFile = readFile5;
555
- function readFile5(path10, options, cb) {
554
+ fs10.readFile = readFile6;
555
+ function readFile6(path10, options, cb) {
556
556
  if (typeof options === "function")
557
557
  cb = options, options = null;
558
558
  return go$readFile(path10, options, cb);
@@ -2550,8 +2550,8 @@ var require_graceful_fs2 = __commonJS({
2550
2550
  fs10.createReadStream = createReadStream;
2551
2551
  fs10.createWriteStream = createWriteStream2;
2552
2552
  var fs$readFile = fs10.readFile;
2553
- fs10.readFile = readFile5;
2554
- function readFile5(path10, options, cb) {
2553
+ fs10.readFile = readFile6;
2554
+ function readFile6(path10, options, cb) {
2555
2555
  if (typeof options === "function")
2556
2556
  cb = options, options = null;
2557
2557
  return go$readFile(path10, options, cb);
@@ -9457,6 +9457,7 @@ var init_enums = __esm({
9457
9457
  MachineJobKind2["CodexReply"] = "codex_reply";
9458
9458
  MachineJobKind2["CodexStart"] = "codex_start";
9459
9459
  MachineJobKind2["Command"] = "command";
9460
+ MachineJobKind2["ViewImage"] = "view_image";
9460
9461
  })(MachineJobKind || (MachineJobKind = {}));
9461
9462
  (function(MachineJobStatus2) {
9462
9463
  MachineJobStatus2["Cancelled"] = "cancelled";
@@ -10354,6 +10355,277 @@ var init_execution_cancellation = __esm({
10354
10355
  }
10355
10356
  });
10356
10357
 
10358
+ // ../machine-connector/dist/runtime/image-viewer.js
10359
+ async function viewLocalMachineImage(rootPath, relativeImagePath) {
10360
+ validateRelativeImagePath(relativeImagePath);
10361
+ const canonicalRoot = await resolvePairedRoot(rootPath);
10362
+ const canonicalImage = await resolveImagePath(canonicalRoot, relativeImagePath);
10363
+ requireInsideRoot(canonicalRoot, canonicalImage);
10364
+ const imageStat = await statImage(canonicalImage, relativeImagePath);
10365
+ if (!imageStat.isFile()) {
10366
+ throw new Error(`Path is not a regular file: ${relativeImagePath}`);
10367
+ }
10368
+ if (imageStat.size > maximumLocalMachineImageBytes) {
10369
+ throw new Error(`Image exceeds the ${maximumLocalMachineImageBytes}-byte Local Machine view limit`);
10370
+ }
10371
+ const bytes = await readImageBytes(canonicalImage, relativeImagePath);
10372
+ if (bytes.length > maximumLocalMachineImageBytes) {
10373
+ throw new Error(`Image exceeds the ${maximumLocalMachineImageBytes}-byte Local Machine view limit`);
10374
+ }
10375
+ const mimeType = detectSupportedImageType(bytes);
10376
+ return {
10377
+ data: bytes.toString("base64"),
10378
+ mimeType,
10379
+ type: "image"
10380
+ };
10381
+ }
10382
+ async function resolvePairedRoot(rootPath) {
10383
+ try {
10384
+ return await (0, import_promises3.realpath)(rootPath);
10385
+ } catch {
10386
+ throw new Error("Paired Local Machine root is unavailable");
10387
+ }
10388
+ }
10389
+ async function resolveImagePath(canonicalRoot, relativeImagePath) {
10390
+ try {
10391
+ return await (0, import_promises3.realpath)((0, import_node_path11.resolve)(canonicalRoot, relativeImagePath));
10392
+ } catch {
10393
+ throw new Error(`Image could not be read: ${relativeImagePath}`);
10394
+ }
10395
+ }
10396
+ async function statImage(canonicalImage, relativeImagePath) {
10397
+ try {
10398
+ return await (0, import_promises3.stat)(canonicalImage);
10399
+ } catch {
10400
+ throw new Error(`Image could not be read: ${relativeImagePath}`);
10401
+ }
10402
+ }
10403
+ async function readImageBytes(canonicalImage, relativeImagePath) {
10404
+ try {
10405
+ return await (0, import_promises3.readFile)(canonicalImage);
10406
+ } catch {
10407
+ throw new Error(`Image could not be read: ${relativeImagePath}`);
10408
+ }
10409
+ }
10410
+ function validateRelativeImagePath(path10) {
10411
+ const segments = path10.split(/[\\/]/);
10412
+ if (path10.length === 0 || path10.length > 4096 || path10.includes("\0") || (0, import_node_path11.isAbsolute)(path10) || import_node_path11.win32.isAbsolute(path10) || segments.some((segment) => segment.length === 0 || segment === "." || segment === "..")) {
10413
+ throw new Error(`Invalid relative image path: ${path10}`);
10414
+ }
10415
+ }
10416
+ function requireInsideRoot(canonicalRoot, canonicalImage) {
10417
+ const relativePath = (0, import_node_path11.relative)(canonicalRoot, canonicalImage);
10418
+ if (relativePath === ".." || relativePath.startsWith(`..${import_node_path11.sep}`) || (0, import_node_path11.isAbsolute)(relativePath)) {
10419
+ throw new Error("Image path escapes paired root");
10420
+ }
10421
+ }
10422
+ function detectSupportedImageType(bytes) {
10423
+ if (startsWith(bytes, [255, 10]) || startsWith(bytes, [
10424
+ 0,
10425
+ 0,
10426
+ 0,
10427
+ 12,
10428
+ 74,
10429
+ 88,
10430
+ 76,
10431
+ 32,
10432
+ 13,
10433
+ 10,
10434
+ 135,
10435
+ 10
10436
+ ])) {
10437
+ throw new Error("Unsupported image type: image/jxl");
10438
+ }
10439
+ if (startsWith(bytes, [255, 216, 255])) {
10440
+ if (bytes[3] === 247) {
10441
+ throw new Error("Unsupported image type: image/jls");
10442
+ }
10443
+ if (!isStructurallyValidJpeg(bytes)) {
10444
+ throw new Error("Corrupt image content: image/jpeg");
10445
+ }
10446
+ return "image/jpeg";
10447
+ }
10448
+ if (startsWith(bytes, [137, 80, 78, 71, 13, 10, 26, 10])) {
10449
+ const png = inspectPng(bytes);
10450
+ if (!png.valid) {
10451
+ throw new Error("Corrupt image content: image/png");
10452
+ }
10453
+ if (png.animated) {
10454
+ throw new Error("Unsupported image type: image/apng");
10455
+ }
10456
+ return "image/png";
10457
+ }
10458
+ if (startsWithAscii(bytes, 0, "GIF87a") || startsWithAscii(bytes, 0, "GIF89a")) {
10459
+ if (!isStructurallyValidGif(bytes)) {
10460
+ throw new Error("Corrupt image content: image/gif");
10461
+ }
10462
+ return "image/gif";
10463
+ }
10464
+ if (startsWithAscii(bytes, 0, "RIFF") && startsWithAscii(bytes, 8, "WEBP")) {
10465
+ const supportedChunk = startsWithAscii(bytes, 12, "VP8 ") || startsWithAscii(bytes, 12, "VP8L") || startsWithAscii(bytes, 12, "VP8X");
10466
+ const chunkSize = readUint32LE(bytes, 16);
10467
+ const expectedLength = 20 + chunkSize + chunkSize % 2;
10468
+ if (bytes.length < 20 || readUint32LE(bytes, 4) + 8 !== bytes.length || expectedLength !== bytes.length || startsWithAscii(bytes, 12, "VP8L") && (chunkSize < 1 || bytes[20] !== 47) || !supportedChunk) {
10469
+ throw new Error("Corrupt image content: image/webp");
10470
+ }
10471
+ return "image/webp";
10472
+ }
10473
+ if (startsWithAscii(bytes, 0, "BM")) {
10474
+ throw new Error("Unsupported image type: image/bmp");
10475
+ }
10476
+ throw new Error("Unsupported or unrecognized image content");
10477
+ }
10478
+ function inspectPng(bytes) {
10479
+ let offset = 8;
10480
+ let animated = false;
10481
+ let firstChunk = true;
10482
+ let hasImageData = false;
10483
+ while (offset + 12 <= bytes.length) {
10484
+ const chunkLength = readUint32BE(bytes, offset);
10485
+ const chunkTypeOffset = offset + 4;
10486
+ const nextOffset = offset + 12 + chunkLength;
10487
+ if (nextOffset <= offset || nextOffset > bytes.length) {
10488
+ return { animated, valid: false };
10489
+ }
10490
+ if (firstChunk && (!startsWithAscii(bytes, chunkTypeOffset, "IHDR") || chunkLength !== 13)) {
10491
+ return { animated, valid: false };
10492
+ }
10493
+ if (startsWithAscii(bytes, chunkTypeOffset, "acTL")) {
10494
+ animated = true;
10495
+ }
10496
+ if (startsWithAscii(bytes, chunkTypeOffset, "IDAT")) {
10497
+ hasImageData = true;
10498
+ }
10499
+ if (startsWithAscii(bytes, chunkTypeOffset, "IEND")) {
10500
+ return {
10501
+ animated,
10502
+ valid: chunkLength === 0 && hasImageData && nextOffset === bytes.length
10503
+ };
10504
+ }
10505
+ firstChunk = false;
10506
+ offset = nextOffset;
10507
+ }
10508
+ return { animated, valid: false };
10509
+ }
10510
+ function isStructurallyValidJpeg(bytes) {
10511
+ let offset = 2;
10512
+ let hasFrame = false;
10513
+ while (offset + 4 <= bytes.length) {
10514
+ if (bytes[offset] !== 255) {
10515
+ return false;
10516
+ }
10517
+ while (bytes[offset] === 255) {
10518
+ offset += 1;
10519
+ }
10520
+ const marker = bytes[offset];
10521
+ offset += 1;
10522
+ if (marker === void 0 || marker === 0 || marker === 217) {
10523
+ return false;
10524
+ }
10525
+ const segmentLength = readUint16BE(bytes, offset);
10526
+ if (segmentLength < 2 || offset + segmentLength > bytes.length) {
10527
+ return false;
10528
+ }
10529
+ if (marker >= 192 && marker <= 195 || marker >= 197 && marker <= 199 || marker >= 201 && marker <= 203 || marker >= 205 && marker <= 207) {
10530
+ hasFrame = segmentLength >= 8;
10531
+ }
10532
+ if (marker === 218) {
10533
+ return hasFrame && endsWith(bytes, [255, 217]);
10534
+ }
10535
+ offset += segmentLength;
10536
+ }
10537
+ return false;
10538
+ }
10539
+ function isStructurallyValidGif(bytes) {
10540
+ if (bytes.length < 14 || readUint16LE(bytes, 6) === 0 || readUint16LE(bytes, 8) === 0) {
10541
+ return false;
10542
+ }
10543
+ let offset = 13;
10544
+ const packedFields = bytes[10] ?? 0;
10545
+ if ((packedFields & 128) !== 0) {
10546
+ offset += 3 * (1 << (packedFields & 7) + 1);
10547
+ }
10548
+ let hasImage = false;
10549
+ while (offset < bytes.length) {
10550
+ const introducer = bytes[offset];
10551
+ offset += 1;
10552
+ if (introducer === 59) {
10553
+ return hasImage && offset === bytes.length;
10554
+ }
10555
+ if (introducer === 33) {
10556
+ offset += 1;
10557
+ } else if (introducer === 44) {
10558
+ if (offset + 9 > bytes.length) {
10559
+ return false;
10560
+ }
10561
+ const imagePackedFields = bytes[offset + 8] ?? 0;
10562
+ offset += 9;
10563
+ if ((imagePackedFields & 128) !== 0) {
10564
+ offset += 3 * (1 << (imagePackedFields & 7) + 1);
10565
+ }
10566
+ if (offset >= bytes.length) {
10567
+ return false;
10568
+ }
10569
+ offset += 1;
10570
+ hasImage = true;
10571
+ } else {
10572
+ return false;
10573
+ }
10574
+ while (offset < bytes.length) {
10575
+ const blockLength = bytes[offset] ?? 0;
10576
+ offset += 1;
10577
+ if (blockLength === 0) {
10578
+ break;
10579
+ }
10580
+ offset += blockLength;
10581
+ if (offset > bytes.length) {
10582
+ return false;
10583
+ }
10584
+ }
10585
+ }
10586
+ return false;
10587
+ }
10588
+ function readUint32BE(bytes, offset) {
10589
+ return (bytes[offset] ?? 0) * 16777216 + ((bytes[offset + 1] ?? 0) << 16) + ((bytes[offset + 2] ?? 0) << 8) + (bytes[offset + 3] ?? 0);
10590
+ }
10591
+ function readUint16BE(bytes, offset) {
10592
+ return ((bytes[offset] ?? 0) << 8) + (bytes[offset + 1] ?? 0);
10593
+ }
10594
+ function readUint16LE(bytes, offset) {
10595
+ return (bytes[offset] ?? 0) + ((bytes[offset + 1] ?? 0) << 8);
10596
+ }
10597
+ function readUint32LE(bytes, offset) {
10598
+ return (bytes[offset] ?? 0) + ((bytes[offset + 1] ?? 0) << 8) + ((bytes[offset + 2] ?? 0) << 16) + (bytes[offset + 3] ?? 0) * 16777216;
10599
+ }
10600
+ function startsWith(bytes, expected) {
10601
+ return bytes.length >= expected.length && expected.every((byte, index) => bytes[index] === byte);
10602
+ }
10603
+ function endsWith(bytes, expected) {
10604
+ const offset = bytes.length - expected.length;
10605
+ return offset >= 0 && expected.every((byte, index) => bytes[offset + index] === byte);
10606
+ }
10607
+ function startsWithAscii(bytes, offset, text) {
10608
+ if (bytes.length < offset + text.length) {
10609
+ return false;
10610
+ }
10611
+ for (let index = 0; index < text.length; index += 1) {
10612
+ if (bytes[offset + index] !== text.charCodeAt(index)) {
10613
+ return false;
10614
+ }
10615
+ }
10616
+ return true;
10617
+ }
10618
+ var import_promises3, import_node_path11, maximumLocalMachineImageBytes;
10619
+ var init_image_viewer = __esm({
10620
+ "../machine-connector/dist/runtime/image-viewer.js"() {
10621
+ "use strict";
10622
+ init_cjs_shims();
10623
+ import_promises3 = require("fs/promises");
10624
+ import_node_path11 = require("path");
10625
+ maximumLocalMachineImageBytes = 1e7;
10626
+ }
10627
+ });
10628
+
10357
10629
  // ../machine-connector/dist/runtime/local-ipc.js
10358
10630
  async function requestRuntimeStatus(store) {
10359
10631
  return await new Promise((resolvePromise, rejectPromise) => {
@@ -10377,12 +10649,12 @@ async function requestRuntimeStatus(store) {
10377
10649
  });
10378
10650
  });
10379
10651
  }
10380
- var import_promises3, import_node_net, import_node_os5, LocalIpcServer;
10652
+ var import_promises4, import_node_net, import_node_os5, LocalIpcServer;
10381
10653
  var init_local_ipc = __esm({
10382
10654
  "../machine-connector/dist/runtime/local-ipc.js"() {
10383
10655
  "use strict";
10384
10656
  init_cjs_shims();
10385
- import_promises3 = require("fs/promises");
10657
+ import_promises4 = require("fs/promises");
10386
10658
  import_node_net = require("net");
10387
10659
  import_node_os5 = require("os");
10388
10660
  LocalIpcServer = class {
@@ -10396,7 +10668,7 @@ var init_local_ipc = __esm({
10396
10668
  async start() {
10397
10669
  const socketPath = this.store.runtimeSocketPath();
10398
10670
  if ((0, import_node_os5.platform)() !== "win32") {
10399
- await (0, import_promises3.rm)(socketPath, { force: true });
10671
+ await (0, import_promises4.rm)(socketPath, { force: true });
10400
10672
  }
10401
10673
  this.server = (0, import_node_net.createServer)((socket) => {
10402
10674
  let requestText = "";
@@ -10416,7 +10688,7 @@ var init_local_ipc = __esm({
10416
10688
  this.server?.listen(socketPath, resolvePromise);
10417
10689
  });
10418
10690
  if ((0, import_node_os5.platform)() !== "win32") {
10419
- await (0, import_promises3.chmod)(socketPath, 384);
10691
+ await (0, import_promises4.chmod)(socketPath, 384);
10420
10692
  }
10421
10693
  }
10422
10694
  async close() {
@@ -10427,7 +10699,7 @@ var init_local_ipc = __esm({
10427
10699
  this.server?.close(() => resolvePromise());
10428
10700
  });
10429
10701
  if ((0, import_node_os5.platform)() !== "win32") {
10430
- await (0, import_promises3.rm)(this.store.runtimeSocketPath(), { force: true });
10702
+ await (0, import_promises4.rm)(this.store.runtimeSocketPath(), { force: true });
10431
10703
  }
10432
10704
  }
10433
10705
  handleRequest(requestText) {
@@ -10606,12 +10878,12 @@ var init_relay_client = __esm({
10606
10878
  });
10607
10879
 
10608
10880
  // ../machine-connector/dist/runtime/runtime-logger.js
10609
- var import_promises4, RuntimeLogger;
10881
+ var import_promises5, RuntimeLogger;
10610
10882
  var init_runtime_logger = __esm({
10611
10883
  "../machine-connector/dist/runtime/runtime-logger.js"() {
10612
10884
  "use strict";
10613
10885
  init_cjs_shims();
10614
- import_promises4 = require("fs/promises");
10886
+ import_promises5 = require("fs/promises");
10615
10887
  RuntimeLogger = class {
10616
10888
  store;
10617
10889
  constructor(store) {
@@ -10625,7 +10897,7 @@ var init_runtime_logger = __esm({
10625
10897
  await this.write("error", message, metadata, this.store.runtimeErrorLogPath());
10626
10898
  }
10627
10899
  async write(level, message, metadata, path10) {
10628
- await (0, import_promises4.appendFile)(path10, `${JSON.stringify({
10900
+ await (0, import_promises5.appendFile)(path10, `${JSON.stringify({
10629
10901
  level,
10630
10902
  message,
10631
10903
  metadata,
@@ -10647,10 +10919,10 @@ function defaultRuntimeDirectory() {
10647
10919
  return override;
10648
10920
  }
10649
10921
  if ((0, import_node_os6.platform)() === "darwin") {
10650
- return (0, import_node_path11.join)((0, import_node_os6.homedir)(), "Library", "Application Support", "Moxt", "Machine Connector");
10922
+ return (0, import_node_path12.join)((0, import_node_os6.homedir)(), "Library", "Application Support", "Moxt", "Machine Connector");
10651
10923
  }
10652
- const stateHome = process.env.XDG_STATE_HOME ?? (0, import_node_path11.join)((0, import_node_os6.homedir)(), ".local", "state");
10653
- return (0, import_node_path11.join)(stateHome, "moxt", "machine-connector");
10924
+ const stateHome = process.env.XDG_STATE_HOME ?? (0, import_node_path12.join)((0, import_node_os6.homedir)(), ".local", "state");
10925
+ return (0, import_node_path12.join)(stateHome, "moxt", "machine-connector");
10654
10926
  }
10655
10927
  function isNodeErrorCode2(error, expectedCode) {
10656
10928
  if (!(error instanceof Error) || !("code" in error)) {
@@ -10658,14 +10930,14 @@ function isNodeErrorCode2(error, expectedCode) {
10658
10930
  }
10659
10931
  return error.code === expectedCode;
10660
10932
  }
10661
- var import_promises5, import_node_os6, import_node_path11, privateFileMode, privateDirectoryMode, MachineRuntimeStore;
10933
+ var import_promises6, import_node_os6, import_node_path12, privateFileMode, privateDirectoryMode, MachineRuntimeStore;
10662
10934
  var init_store = __esm({
10663
10935
  "../machine-connector/dist/runtime/store.js"() {
10664
10936
  "use strict";
10665
10937
  init_cjs_shims();
10666
- import_promises5 = require("fs/promises");
10938
+ import_promises6 = require("fs/promises");
10667
10939
  import_node_os6 = require("os");
10668
- import_node_path11 = require("path");
10940
+ import_node_path12 = require("path");
10669
10941
  privateFileMode = 384;
10670
10942
  privateDirectoryMode = 448;
10671
10943
  MachineRuntimeStore = class {
@@ -10674,15 +10946,15 @@ var init_store = __esm({
10674
10946
  this.baseDirectory = baseDirectory;
10675
10947
  }
10676
10948
  async initialize() {
10677
- await (0, import_promises5.mkdir)(this.jobsDirectory(), {
10949
+ await (0, import_promises6.mkdir)(this.jobsDirectory(), {
10678
10950
  mode: privateDirectoryMode,
10679
10951
  recursive: true
10680
10952
  });
10681
- await (0, import_promises5.chmod)(this.baseDirectory, privateDirectoryMode);
10682
- await (0, import_promises5.chmod)(this.jobsDirectory(), privateDirectoryMode);
10953
+ await (0, import_promises6.chmod)(this.baseDirectory, privateDirectoryMode);
10954
+ await (0, import_promises6.chmod)(this.jobsDirectory(), privateDirectoryMode);
10683
10955
  }
10684
10956
  async getCanonicalRoot(rootPath) {
10685
- return await (0, import_promises5.realpath)(rootPath);
10957
+ return await (0, import_promises6.realpath)(rootPath);
10686
10958
  }
10687
10959
  async readIdentity() {
10688
10960
  return await this.readOptionalJson(this.identityPath());
@@ -10725,7 +10997,7 @@ var init_store = __esm({
10725
10997
  await this.writePrivateJson(this.serviceManagerPath(), serviceManager);
10726
10998
  }
10727
10999
  async removeServiceManager() {
10728
- await (0, import_promises5.rm)(this.serviceManagerPath(), { force: true });
11000
+ await (0, import_promises6.rm)(this.serviceManagerPath(), { force: true });
10729
11001
  }
10730
11002
  async readJob(jobId) {
10731
11003
  return await this.readOptionalJson(this.jobPath(jobId));
@@ -10736,7 +11008,7 @@ var init_store = __esm({
10736
11008
  async listJobs() {
10737
11009
  let names = [];
10738
11010
  try {
10739
- names = await (0, import_promises5.readdir)(this.jobsDirectory());
11011
+ names = await (0, import_promises6.readdir)(this.jobsDirectory());
10740
11012
  } catch (error) {
10741
11013
  if (isNodeErrorCode2(error, "ENOENT")) {
10742
11014
  return [];
@@ -10745,7 +11017,7 @@ var init_store = __esm({
10745
11017
  }
10746
11018
  const jobs = [];
10747
11019
  for (const name of names.filter((entry) => entry.endsWith(".json"))) {
10748
- const job = await this.readOptionalJson((0, import_node_path11.join)(this.jobsDirectory(), name));
11020
+ const job = await this.readOptionalJson((0, import_node_path12.join)(this.jobsDirectory(), name));
10749
11021
  if (job.value) {
10750
11022
  jobs.push(job.value);
10751
11023
  }
@@ -10753,40 +11025,40 @@ var init_store = __esm({
10753
11025
  return jobs;
10754
11026
  }
10755
11027
  async deleteJob(jobId) {
10756
- await (0, import_promises5.rm)(this.jobPath(jobId), { force: true });
11028
+ await (0, import_promises6.rm)(this.jobPath(jobId), { force: true });
10757
11029
  }
10758
11030
  runtimeLogPath() {
10759
- return (0, import_node_path11.join)(this.baseDirectory, "machine-connector.log");
11031
+ return (0, import_node_path12.join)(this.baseDirectory, "machine-connector.log");
10760
11032
  }
10761
11033
  runtimeErrorLogPath() {
10762
- return (0, import_node_path11.join)(this.baseDirectory, "machine-connector.error.log");
11034
+ return (0, import_node_path12.join)(this.baseDirectory, "machine-connector.error.log");
10763
11035
  }
10764
11036
  runtimeStatusPath() {
10765
- return (0, import_node_path11.join)(this.baseDirectory, "runtime-status.json");
11037
+ return (0, import_node_path12.join)(this.baseDirectory, "runtime-status.json");
10766
11038
  }
10767
11039
  runtimeSocketPath() {
10768
11040
  if ((0, import_node_os6.platform)() === "win32") {
10769
11041
  return String.raw`\\.\pipe\moxt-machine-connector`;
10770
11042
  }
10771
- return (0, import_node_path11.join)(this.baseDirectory, "machine-connector.sock");
11043
+ return (0, import_node_path12.join)(this.baseDirectory, "machine-connector.sock");
10772
11044
  }
10773
11045
  connectionsPath() {
10774
- return (0, import_node_path11.join)(this.baseDirectory, "connections.json");
11046
+ return (0, import_node_path12.join)(this.baseDirectory, "connections.json");
10775
11047
  }
10776
11048
  identityPath() {
10777
- return (0, import_node_path11.join)(this.baseDirectory, "identity.json");
11049
+ return (0, import_node_path12.join)(this.baseDirectory, "identity.json");
10778
11050
  }
10779
11051
  serviceManagerPath() {
10780
- return (0, import_node_path11.join)(this.baseDirectory, "service-manager.json");
11052
+ return (0, import_node_path12.join)(this.baseDirectory, "service-manager.json");
10781
11053
  }
10782
11054
  privateKeyPath() {
10783
- return (0, import_node_path11.join)(this.baseDirectory, "device-private-key.pem");
11055
+ return (0, import_node_path12.join)(this.baseDirectory, "device-private-key.pem");
10784
11056
  }
10785
11057
  jobsDirectory() {
10786
- return (0, import_node_path11.join)(this.baseDirectory, "jobs");
11058
+ return (0, import_node_path12.join)(this.baseDirectory, "jobs");
10787
11059
  }
10788
11060
  jobPath(jobId) {
10789
- return (0, import_node_path11.join)(this.jobsDirectory(), `${jobId}.json`);
11061
+ return (0, import_node_path12.join)(this.jobsDirectory(), `${jobId}.json`);
10790
11062
  }
10791
11063
  async readOptionalJson(path10) {
10792
11064
  const content = await this.readOptionalText(path10);
@@ -10797,7 +11069,7 @@ var init_store = __esm({
10797
11069
  }
10798
11070
  async readOptionalText(path10) {
10799
11071
  try {
10800
- return { value: await (0, import_promises5.readFile)(path10, "utf8") };
11072
+ return { value: await (0, import_promises6.readFile)(path10, "utf8") };
10801
11073
  } catch (error) {
10802
11074
  if (isNodeErrorCode2(error, "ENOENT")) {
10803
11075
  return {};
@@ -10810,17 +11082,17 @@ var init_store = __esm({
10810
11082
  `);
10811
11083
  }
10812
11084
  async writePrivateText(path10, value) {
10813
- await (0, import_promises5.mkdir)((0, import_node_path11.dirname)(path10), {
11085
+ await (0, import_promises6.mkdir)((0, import_node_path12.dirname)(path10), {
10814
11086
  mode: privateDirectoryMode,
10815
11087
  recursive: true
10816
11088
  });
10817
11089
  const temporaryPath = `${path10}.${process.pid}.tmp`;
10818
- await (0, import_promises5.writeFile)(temporaryPath, value, {
11090
+ await (0, import_promises6.writeFile)(temporaryPath, value, {
10819
11091
  encoding: "utf8",
10820
11092
  mode: privateFileMode
10821
11093
  });
10822
- await (0, import_promises5.chmod)(temporaryPath, privateFileMode);
10823
- await (0, import_promises5.rename)(temporaryPath, path10);
11094
+ await (0, import_promises6.chmod)(temporaryPath, privateFileMode);
11095
+ await (0, import_promises6.rename)(temporaryPath, path10);
10824
11096
  }
10825
11097
  };
10826
11098
  }
@@ -10863,6 +11135,7 @@ var init_daemon = __esm({
10863
11135
  init_codex_executor();
10864
11136
  init_durable_job();
10865
11137
  init_execution_cancellation();
11138
+ init_image_viewer();
10866
11139
  init_local_ipc();
10867
11140
  init_process_executor();
10868
11141
  init_relay_client();
@@ -10888,6 +11161,7 @@ var init_daemon = __esm({
10888
11161
  store;
10889
11162
  activeJobs = /* @__PURE__ */ new Map();
10890
11163
  connectorInstanceId = (0, import_node_crypto4.randomUUID)();
11164
+ executionTasks = /* @__PURE__ */ new Set();
10891
11165
  logger;
10892
11166
  startedAt = (/* @__PURE__ */ new Date()).toISOString();
10893
11167
  connections = [];
@@ -10927,6 +11201,7 @@ var init_daemon = __esm({
10927
11201
  await Promise.all(this.connections.map(async (connection) => {
10928
11202
  await this.runConnection(connection);
10929
11203
  }));
11204
+ await this.waitForExecutionTasks();
10930
11205
  }
10931
11206
  async stop() {
10932
11207
  this.stopping = true;
@@ -10984,10 +11259,6 @@ var init_daemon = __esm({
10984
11259
  }
10985
11260
  async runClaimLoop(connection, relay) {
10986
11261
  while (!this.stopping) {
10987
- if (this.hasActiveJobForConnection(connection.connectionId)) {
10988
- await this.waitUntilStop(500);
10989
- continue;
10990
- }
10991
11262
  try {
10992
11263
  const response = await relay.claim({
10993
11264
  connectorInstanceId: this.connectorInstanceId,
@@ -10997,7 +11268,10 @@ var init_daemon = __esm({
10997
11268
  });
10998
11269
  if (response.job) {
10999
11270
  const activeJob = this.reserveClaim(connection, relay, response.job);
11000
- await this.executeClaim(activeJob);
11271
+ if (this.stopping) {
11272
+ await activeJob.cancellation.request(ExecutionCancellationReason.Stopping);
11273
+ }
11274
+ this.startClaimExecution(activeJob);
11001
11275
  }
11002
11276
  } catch (error) {
11003
11277
  await this.logger.error(`Job claim failed for connection ${connection.connectionId}`, error);
@@ -11039,6 +11313,20 @@ var init_daemon = __esm({
11039
11313
  this.activeJobs.set(claim.jobId, activeJob);
11040
11314
  return activeJob;
11041
11315
  }
11316
+ startClaimExecution(activeJob) {
11317
+ const jobId = activeJob.claim.jobId;
11318
+ const executionTask = this.executeClaim(activeJob);
11319
+ this.executionTasks.add(executionTask);
11320
+ void executionTask.then(() => {
11321
+ this.executionTasks.delete(executionTask);
11322
+ }, (error) => {
11323
+ this.executionTasks.delete(executionTask);
11324
+ void this.logger.error(`Local Machine Job ${jobId} escaped its execution boundary`, error).catch((loggingError) => {
11325
+ process.stderr.write(`Failed to record Local Machine Job ${jobId} execution error: ${String(loggingError)}
11326
+ `);
11327
+ });
11328
+ });
11329
+ }
11042
11330
  async executeClaim(activeJob) {
11043
11331
  const { claim } = activeJob;
11044
11332
  try {
@@ -11110,6 +11398,14 @@ var init_daemon = __esm({
11110
11398
  result: { exitCode: result.exitCode }
11111
11399
  };
11112
11400
  }
11401
+ if (claim.kind === MachineJobKind.ViewImage) {
11402
+ const request2 = claim.requestPayload;
11403
+ return {
11404
+ exitCode: 0,
11405
+ result: await viewLocalMachineImage(activeJob.connection.rootPath, request2.path),
11406
+ status: MachineJobStatus.Succeeded
11407
+ };
11408
+ }
11113
11409
  const workingDirectory = await resolveCanonicalWorkingDirectory(activeJob.connection.rootPath, claim.relativeWorkingDirectory);
11114
11410
  if (!canSpawn()) {
11115
11411
  return this.cancellationResult(activeJob);
@@ -11383,8 +11679,12 @@ var init_daemon = __esm({
11383
11679
  protocolVersion: machineProtocolVersion
11384
11680
  });
11385
11681
  }
11386
- hasActiveJobForConnection(connectionId) {
11387
- return [...this.activeJobs.values()].some((activeJob) => activeJob.connection.connectionId === connectionId);
11682
+ async waitForExecutionTasks() {
11683
+ while (this.executionTasks.size > 0) {
11684
+ await Promise.all([...this.executionTasks].map(async (executionTask) => {
11685
+ await executionTask.catch(() => void 0);
11686
+ }));
11687
+ }
11388
11688
  }
11389
11689
  async waitUntilStop(milliseconds) {
11390
11690
  const deadline = Date.now() + milliseconds;
@@ -11477,7 +11777,7 @@ async function runMachineDoctor(store) {
11477
11777
  }
11478
11778
  for (const connection of connections) {
11479
11779
  try {
11480
- await (0, import_promises6.access)(connection.rootPath, import_node_fs5.constants.R_OK | import_node_fs5.constants.X_OK);
11780
+ await (0, import_promises7.access)(connection.rootPath, import_node_fs5.constants.R_OK | import_node_fs5.constants.X_OK);
11481
11781
  checks.push({
11482
11782
  detail: connection.rootPath,
11483
11783
  name: `root:${connection.connectionId}`,
@@ -11492,7 +11792,7 @@ async function runMachineDoctor(store) {
11492
11792
  }
11493
11793
  const relayUrl = new URL(connection.relayOrigin);
11494
11794
  try {
11495
- const address = await (0, import_promises7.lookup)(relayUrl.hostname);
11795
+ const address = await (0, import_promises8.lookup)(relayUrl.hostname);
11496
11796
  checks.push({
11497
11797
  detail: `${relayUrl.hostname} resolves to ${address.address}`,
11498
11798
  name: `dns:${connection.connectionId}`,
@@ -11574,15 +11874,15 @@ async function runMachineDoctor(store) {
11574
11874
  function errorMessage(error) {
11575
11875
  return error instanceof Error ? error.message : String(error);
11576
11876
  }
11577
- var import_node_child_process3, import_promises6, import_node_fs5, import_promises7, import_node_util4, execFileAsync, DoctorCheckStatus;
11877
+ var import_node_child_process3, import_promises7, import_node_fs5, import_promises8, import_node_util4, execFileAsync, DoctorCheckStatus;
11578
11878
  var init_doctor = __esm({
11579
11879
  "../machine-connector/dist/runtime/doctor.js"() {
11580
11880
  "use strict";
11581
11881
  init_cjs_shims();
11582
11882
  import_node_child_process3 = require("child_process");
11583
- import_promises6 = require("fs/promises");
11883
+ import_promises7 = require("fs/promises");
11584
11884
  import_node_fs5 = require("fs");
11585
- import_promises7 = require("dns/promises");
11885
+ import_promises8 = require("dns/promises");
11586
11886
  import_node_util4 = require("util");
11587
11887
  init_local_ipc();
11588
11888
  execFileAsync = (0, import_node_util4.promisify)(import_node_child_process3.execFile);
@@ -11851,7 +12151,7 @@ async function readRecentLogLines(store) {
11851
12151
  }
11852
12152
  async function readOptionalFile(path10) {
11853
12153
  try {
11854
- return await (0, import_promises8.readFile)(path10, "utf8");
12154
+ return await (0, import_promises9.readFile)(path10, "utf8");
11855
12155
  } catch (error) {
11856
12156
  if (isMissingFile(error)) {
11857
12157
  return "";
@@ -11910,13 +12210,13 @@ function isMissingFile(error) {
11910
12210
  function errorMessage2(error) {
11911
12211
  return error instanceof Error ? error.message : String(error);
11912
12212
  }
11913
- var import_promises8, import_promises9, import_node_readline, alternateScreenEnter, alternateScreenExit, clearScreen, cursorHide, cursorShow, styleReset, styleHeader, styleSelected, refreshIntervalMilliseconds, maximumLogLines, MachineManagerView, MachineManagerAction, MachineManagerSnapshotDepth, InteractiveMachineManager;
12213
+ var import_promises9, import_promises10, import_node_readline, alternateScreenEnter, alternateScreenExit, clearScreen, cursorHide, cursorShow, styleReset, styleHeader, styleSelected, refreshIntervalMilliseconds, maximumLogLines, MachineManagerView, MachineManagerAction, MachineManagerSnapshotDepth, InteractiveMachineManager;
11914
12214
  var init_machine_manager = __esm({
11915
12215
  "../machine-connector/dist/runtime/machine-manager.js"() {
11916
12216
  "use strict";
11917
12217
  init_cjs_shims();
11918
- import_promises8 = require("fs/promises");
11919
- import_promises9 = require("readline/promises");
12218
+ import_promises9 = require("fs/promises");
12219
+ import_promises10 = require("readline/promises");
11920
12220
  import_node_readline = require("readline");
11921
12221
  init_doctor();
11922
12222
  init_local_ipc();
@@ -12150,7 +12450,7 @@ var init_machine_manager = __esm({
12150
12450
  }
12151
12451
  async runCommandAction(action) {
12152
12452
  this.suspendTerminal();
12153
- const reader = (0, import_promises9.createInterface)({
12453
+ const reader = (0, import_promises10.createInterface)({
12154
12454
  input: process.stdin,
12155
12455
  output: process.stdout
12156
12456
  });
@@ -12340,7 +12640,7 @@ async function pairMachine(store, options) {
12340
12640
  machineName,
12341
12641
  operatingSystem,
12342
12642
  protocolVersion: machineProtocolVersion,
12343
- rootDisplayName: (0, import_node_path12.basename)(canonicalRoot),
12643
+ rootDisplayName: (0, import_node_path13.basename)(canonicalRoot),
12344
12644
  rootHandle
12345
12645
  });
12346
12646
  options.onConfirmation?.(proposal.confirmationUrl);
@@ -12368,7 +12668,7 @@ async function pairMachine(store, options) {
12368
12668
  operatingSystem,
12369
12669
  refreshToken: credentials.refreshToken,
12370
12670
  relayOrigin: options.relayOrigin.replace(/\/+$/, ""),
12371
- rootDisplayName: (0, import_node_path12.basename)(canonicalRoot),
12671
+ rootDisplayName: (0, import_node_path13.basename)(canonicalRoot),
12372
12672
  rootHandle,
12373
12673
  rootPath: canonicalRoot,
12374
12674
  targetId: credentials.targetId,
@@ -12407,7 +12707,7 @@ function delay4(milliseconds) {
12407
12707
  setTimeout(resolvePromise, milliseconds);
12408
12708
  });
12409
12709
  }
12410
- var import_node_child_process4, import_node_crypto6, import_node_os8, import_node_path12, connectedPairingStatus, rejectedPairingStatus, expiredPairingStatus, pairingPollMilliseconds;
12710
+ var import_node_child_process4, import_node_crypto6, import_node_os8, import_node_path13, connectedPairingStatus, rejectedPairingStatus, expiredPairingStatus, pairingPollMilliseconds;
12411
12711
  var init_pairing = __esm({
12412
12712
  "../machine-connector/dist/runtime/pairing.js"() {
12413
12713
  "use strict";
@@ -12415,7 +12715,7 @@ var init_pairing = __esm({
12415
12715
  import_node_child_process4 = require("child_process");
12416
12716
  import_node_crypto6 = require("crypto");
12417
12717
  import_node_os8 = require("os");
12418
- import_node_path12 = require("path");
12718
+ import_node_path13 = require("path");
12419
12719
  init_contracts();
12420
12720
  init_version();
12421
12721
  init_enums();
@@ -12594,12 +12894,12 @@ async function installUserService(store, request2, runtime = defaultServiceManag
12594
12894
  }
12595
12895
  function createServiceEnvironment(options) {
12596
12896
  const inheritedPath = options.environment.PATH ?? process.env.PATH ?? "";
12597
- const nodeDirectory = (0, import_node_path13.dirname)(options.nodePath);
12598
- const pathEntries = [nodeDirectory, ...inheritedPath.split(import_node_path13.delimiter)].filter((entry, index, entries) => entry.length > 0 && entries.indexOf(entry) === index);
12897
+ const nodeDirectory = (0, import_node_path14.dirname)(options.nodePath);
12898
+ const pathEntries = [nodeDirectory, ...inheritedPath.split(import_node_path14.delimiter)].filter((entry, index, entries) => entry.length > 0 && entries.indexOf(entry) === index);
12599
12899
  return {
12600
12900
  ...options.environment,
12601
12901
  HOME: options.environment.HOME ?? process.env.HOME ?? (0, import_node_os9.homedir)(),
12602
- PATH: pathEntries.join(import_node_path13.delimiter)
12902
+ PATH: pathEntries.join(import_node_path14.delimiter)
12603
12903
  };
12604
12904
  }
12605
12905
  async function restartUserService(store, runtime = defaultServiceManagerRuntime) {
@@ -12714,7 +13014,7 @@ async function uninstallManager(manager, store, runtime) {
12714
13014
  "bootout",
12715
13015
  `gui/${process.getuid?.() ?? 0}/${launchAgentLabel}`
12716
13016
  ]);
12717
- await (0, import_promises10.rm)(launchAgentPath(), { force: true });
13017
+ await (0, import_promises11.rm)(launchAgentPath(), { force: true });
12718
13018
  return;
12719
13019
  }
12720
13020
  if (manager === UserServiceManager.Systemd) {
@@ -12724,7 +13024,7 @@ async function uninstallManager(manager, store, runtime) {
12724
13024
  "--now",
12725
13025
  "moxt-machine-connector.service"
12726
13026
  ]);
12727
- await (0, import_promises10.rm)(systemdUnitPath(), { force: true });
13027
+ await (0, import_promises11.rm)(systemdUnitPath(), { force: true });
12728
13028
  await runCommandIgnoringFailure(runtime, "systemctl", [
12729
13029
  "--user",
12730
13030
  "daemon-reload"
@@ -12738,7 +13038,7 @@ async function uninstallManager(manager, store, runtime) {
12738
13038
  supervisorProgramName
12739
13039
  ]);
12740
13040
  await runCommandIgnoringFailure(runtime, "supervisorctl", ["-c", supervisorConfigPath(store), "shutdown"]);
12741
- await (0, import_promises10.rm)(supervisorDirectory(store), {
13041
+ await (0, import_promises11.rm)(supervisorDirectory(store), {
12742
13042
  force: true,
12743
13043
  recursive: true
12744
13044
  });
@@ -12806,10 +13106,10 @@ function automaticSelectionDetail(manager) {
12806
13106
  }
12807
13107
  async function installLaunchAgent(store, options, runtime) {
12808
13108
  const path10 = launchAgentPath();
12809
- await (0, import_promises10.mkdir)((0, import_node_path13.dirname)(path10), { recursive: true });
13109
+ await (0, import_promises11.mkdir)((0, import_node_path14.dirname)(path10), { recursive: true });
12810
13110
  const programArguments = [
12811
13111
  options.nodePath,
12812
- (0, import_node_path13.resolve)(options.entrypointPath),
13112
+ (0, import_node_path14.resolve)(options.entrypointPath),
12813
13113
  ...options.commandArguments
12814
13114
  ];
12815
13115
  const plist = `<?xml version="1.0" encoding="UTF-8"?>
@@ -12840,7 +13140,7 @@ ${Object.entries(options.environment).map(([name, value]) => ` <key>${escapeX
12840
13140
  </dict>
12841
13141
  </plist>
12842
13142
  `;
12843
- await (0, import_promises10.writeFile)(path10, plist, { encoding: "utf8", mode: 384 });
13143
+ await (0, import_promises11.writeFile)(path10, plist, { encoding: "utf8", mode: 384 });
12844
13144
  const domain = `gui/${process.getuid?.() ?? 0}`;
12845
13145
  await runCommandIgnoringFailure(runtime, "launchctl", [
12846
13146
  "bootout",
@@ -12856,10 +13156,10 @@ ${Object.entries(options.environment).map(([name, value]) => ` <key>${escapeX
12856
13156
  }
12857
13157
  async function installSystemdUserService(store, options, runtime) {
12858
13158
  const path10 = systemdUnitPath();
12859
- await (0, import_promises10.mkdir)((0, import_node_path13.dirname)(path10), { recursive: true });
13159
+ await (0, import_promises11.mkdir)((0, import_node_path14.dirname)(path10), { recursive: true });
12860
13160
  const command = [
12861
13161
  options.nodePath,
12862
- (0, import_node_path13.resolve)(options.entrypointPath),
13162
+ (0, import_node_path14.resolve)(options.entrypointPath),
12863
13163
  ...options.commandArguments
12864
13164
  ].map(escapeSystemdArgument).join(" ");
12865
13165
  const unit = `[Unit]
@@ -12878,7 +13178,7 @@ ${Object.entries(options.environment).map(([name, value]) => `Environment=${esca
12878
13178
  [Install]
12879
13179
  WantedBy=default.target
12880
13180
  `;
12881
- await (0, import_promises10.writeFile)(path10, unit, { encoding: "utf8", mode: 384 });
13181
+ await (0, import_promises11.writeFile)(path10, unit, { encoding: "utf8", mode: 384 });
12882
13182
  await runtime.run("systemctl", ["--user", "daemon-reload"]);
12883
13183
  await runtime.run("systemctl", [
12884
13184
  "--user",
@@ -12894,15 +13194,15 @@ WantedBy=default.target
12894
13194
  async function installSupervisorUserService(store, options, runtime) {
12895
13195
  const directory = supervisorDirectory(store);
12896
13196
  const configPath = supervisorConfigPath(store);
12897
- await (0, import_promises10.mkdir)(directory, { recursive: true, mode: 448 });
12898
- await (0, import_promises10.writeFile)(configPath, createSupervisorConfiguration(store, options), {
13197
+ await (0, import_promises11.mkdir)(directory, { recursive: true, mode: 448 });
13198
+ await (0, import_promises11.writeFile)(configPath, createSupervisorConfiguration(store, options), {
12899
13199
  encoding: "utf8",
12900
13200
  mode: 384
12901
13201
  });
12902
13202
  const supervisorWasRunning = await supervisorIsRunning(store, runtime);
12903
13203
  if (!supervisorWasRunning) {
12904
- await (0, import_promises10.rm)(supervisorSocketPath(store), { force: true });
12905
- await (0, import_promises10.rm)(supervisorPidPath(store), { force: true });
13204
+ await (0, import_promises11.rm)(supervisorSocketPath(store), { force: true });
13205
+ await (0, import_promises11.rm)(supervisorPidPath(store), { force: true });
12906
13206
  await runtime.run("supervisord", ["-c", configPath]);
12907
13207
  await waitForSupervisorControl(store, runtime);
12908
13208
  return;
@@ -12914,7 +13214,7 @@ async function installSupervisorUserService(store, options, runtime) {
12914
13214
  function createSupervisorConfiguration(store, options) {
12915
13215
  const command = [
12916
13216
  options.nodePath,
12917
- (0, import_node_path13.resolve)(options.entrypointPath),
13217
+ (0, import_node_path14.resolve)(options.entrypointPath),
12918
13218
  ...options.commandArguments
12919
13219
  ].map(escapeSupervisorArgument).join(" ");
12920
13220
  const environment = Object.entries(options.environment).map(([name, value]) => `${name}="${escapeSupervisorEnvironment(value)}"`).join(",");
@@ -12938,7 +13238,7 @@ serverurl=unix://${supervisorSocketPath(store)}
12938
13238
 
12939
13239
  [program:${supervisorProgramName}]
12940
13240
  command=${command}
12941
- directory=${escapeSupervisorPath((0, import_node_path13.dirname)((0, import_node_path13.resolve)(options.entrypointPath)))}
13241
+ directory=${escapeSupervisorPath((0, import_node_path14.dirname)((0, import_node_path14.resolve)(options.entrypointPath)))}
12942
13242
  environment=${environment}
12943
13243
  autostart=true
12944
13244
  autorestart=true
@@ -12959,8 +13259,8 @@ stderr_logfile_backups=3
12959
13259
  async function restartSupervisorUserService(store, runtime) {
12960
13260
  const configPath = supervisorConfigPath(store);
12961
13261
  if (!await supervisorIsRunning(store, runtime)) {
12962
- await (0, import_promises10.rm)(supervisorSocketPath(store), { force: true });
12963
- await (0, import_promises10.rm)(supervisorPidPath(store), { force: true });
13262
+ await (0, import_promises11.rm)(supervisorSocketPath(store), { force: true });
13263
+ await (0, import_promises11.rm)(supervisorPidPath(store), { force: true });
12964
13264
  await runtime.run("supervisord", ["-c", configPath]);
12965
13265
  await waitForSupervisorControl(store, runtime);
12966
13266
  return;
@@ -12999,26 +13299,26 @@ async function waitForSupervisorControl(store, runtime) {
12999
13299
  throw new Error("Supervisor did not become ready within 5 seconds");
13000
13300
  }
13001
13301
  function launchAgentPath() {
13002
- return (0, import_node_path13.join)((0, import_node_os9.homedir)(), "Library", "LaunchAgents", `${launchAgentLabel}.plist`);
13302
+ return (0, import_node_path14.join)((0, import_node_os9.homedir)(), "Library", "LaunchAgents", `${launchAgentLabel}.plist`);
13003
13303
  }
13004
13304
  function systemdUnitPath() {
13005
- const configHome = process.env.XDG_CONFIG_HOME ?? (0, import_node_path13.join)((0, import_node_os9.homedir)(), ".config");
13006
- return (0, import_node_path13.join)(configHome, "systemd", "user", "moxt-machine-connector.service");
13305
+ const configHome = process.env.XDG_CONFIG_HOME ?? (0, import_node_path14.join)((0, import_node_os9.homedir)(), ".config");
13306
+ return (0, import_node_path14.join)(configHome, "systemd", "user", "moxt-machine-connector.service");
13007
13307
  }
13008
13308
  function supervisorDirectory(store) {
13009
- return (0, import_node_path13.join)(store.baseDirectory, "supervisor");
13309
+ return (0, import_node_path14.join)(store.baseDirectory, "supervisor");
13010
13310
  }
13011
13311
  function supervisorConfigPath(store) {
13012
- return (0, import_node_path13.join)(supervisorDirectory(store), "supervisord.conf");
13312
+ return (0, import_node_path14.join)(supervisorDirectory(store), "supervisord.conf");
13013
13313
  }
13014
13314
  function supervisorSocketPath(store) {
13015
- return (0, import_node_path13.join)(supervisorDirectory(store), "supervisor.sock");
13315
+ return (0, import_node_path14.join)(supervisorDirectory(store), "supervisor.sock");
13016
13316
  }
13017
13317
  function supervisorPidPath(store) {
13018
- return (0, import_node_path13.join)(supervisorDirectory(store), "supervisord.pid");
13318
+ return (0, import_node_path14.join)(supervisorDirectory(store), "supervisord.pid");
13019
13319
  }
13020
13320
  function supervisorLogPath(store) {
13021
- return (0, import_node_path13.join)(supervisorDirectory(store), "supervisord.log");
13321
+ return (0, import_node_path14.join)(supervisorDirectory(store), "supervisord.log");
13022
13322
  }
13023
13323
  async function commandSucceeds(runtime, command, argumentsList) {
13024
13324
  try {
@@ -13068,15 +13368,15 @@ function delay5(milliseconds) {
13068
13368
  setTimeout(resolvePromise, milliseconds);
13069
13369
  });
13070
13370
  }
13071
- var import_node_child_process5, import_promises10, import_node_os9, import_node_path13, import_node_util6, execFileAsync2, launchAgentLabel, supervisorProgramName, ServiceManagerPreference, UserServiceManager, defaultServiceManagerRuntime;
13371
+ var import_node_child_process5, import_promises11, import_node_os9, import_node_path14, import_node_util6, execFileAsync2, launchAgentLabel, supervisorProgramName, ServiceManagerPreference, UserServiceManager, defaultServiceManagerRuntime;
13072
13372
  var init_service_manager = __esm({
13073
13373
  "../machine-connector/dist/runtime/service-manager.js"() {
13074
13374
  "use strict";
13075
13375
  init_cjs_shims();
13076
13376
  import_node_child_process5 = require("child_process");
13077
- import_promises10 = require("fs/promises");
13377
+ import_promises11 = require("fs/promises");
13078
13378
  import_node_os9 = require("os");
13079
- import_node_path13 = require("path");
13379
+ import_node_path14 = require("path");
13080
13380
  import_node_util6 = require("util");
13081
13381
  execFileAsync2 = (0, import_node_util6.promisify)(import_node_child_process5.execFile);
13082
13382
  launchAgentLabel = "ai.moxt.machine-connector";
@@ -13155,7 +13455,7 @@ async function runMachineCli(argumentsList, entrypoint) {
13155
13455
  async function connectCommand(store, argumentsList, entrypoint) {
13156
13456
  const options = parseOptions(argumentsList);
13157
13457
  const connectionCode = requiredOption(options, "code");
13158
- const rootPath = (0, import_node_path14.resolve)(options.root ?? process.cwd());
13458
+ const rootPath = (0, import_node_path15.resolve)(options.root ?? process.cwd());
13159
13459
  const serviceManagerPreference = requestedServiceManagerPreference(options);
13160
13460
  await validateExplicitServiceManagerPreference(serviceManagerPreference);
13161
13461
  writeLine("Internal Full Host Access: enabled");
@@ -13391,7 +13691,7 @@ async function waitForDaemonOnline(store) {
13391
13691
  }
13392
13692
  async function readOptionalFile2(path10) {
13393
13693
  try {
13394
- return await (0, import_promises11.readFile)(path10, "utf8");
13694
+ return await (0, import_promises12.readFile)(path10, "utf8");
13395
13695
  } catch {
13396
13696
  return "";
13397
13697
  }
@@ -13419,13 +13719,13 @@ function delay6(milliseconds) {
13419
13719
  setTimeout(resolvePromise, milliseconds);
13420
13720
  });
13421
13721
  }
13422
- var import_promises11, import_node_path14, defaultRelayOrigin;
13722
+ var import_promises12, import_node_path15, defaultRelayOrigin;
13423
13723
  var init_cli = __esm({
13424
13724
  "../machine-connector/dist/cli.js"() {
13425
13725
  "use strict";
13426
13726
  init_cjs_shims();
13427
- import_promises11 = require("fs/promises");
13428
- import_node_path14 = require("path");
13727
+ import_promises12 = require("fs/promises");
13728
+ import_node_path15 = require("path");
13429
13729
  init_daemon();
13430
13730
  init_doctor();
13431
13731
  init_local_ipc();
@@ -13622,7 +13922,7 @@ var retryifyAsync = (fn, options) => {
13622
13922
  throw error;
13623
13923
  const delay7 = Math.round(interval * Math.random());
13624
13924
  if (delay7 > 0) {
13625
- const delayPromise = new Promise((resolve4) => setTimeout(resolve4, delay7));
13925
+ const delayPromise = new Promise((resolve5) => setTimeout(resolve5, delay7));
13626
13926
  return delayPromise.then(() => attempt.apply(void 0, args));
13627
13927
  } else {
13628
13928
  return attempt.apply(void 0, args);
@@ -15238,14 +15538,14 @@ var TimeoutError = class extends Error {
15238
15538
 
15239
15539
  // node_modules/.pnpm/ky@1.14.3/node_modules/ky/distribution/utils/timeout.js
15240
15540
  async function timeout(request2, init, abortController, options) {
15241
- return new Promise((resolve4, reject) => {
15541
+ return new Promise((resolve5, reject) => {
15242
15542
  const timeoutId = setTimeout(() => {
15243
15543
  if (abortController) {
15244
15544
  abortController.abort();
15245
15545
  }
15246
15546
  reject(new TimeoutError(request2));
15247
15547
  }, options.timeout);
15248
- void options.fetch(request2, init).then(resolve4).catch(reject).then(() => {
15548
+ void options.fetch(request2, init).then(resolve5).catch(reject).then(() => {
15249
15549
  clearTimeout(timeoutId);
15250
15550
  });
15251
15551
  });
@@ -15254,7 +15554,7 @@ async function timeout(request2, init, abortController, options) {
15254
15554
  // node_modules/.pnpm/ky@1.14.3/node_modules/ky/distribution/utils/delay.js
15255
15555
  init_cjs_shims();
15256
15556
  async function delay(ms, { signal }) {
15257
- return new Promise((resolve4, reject) => {
15557
+ return new Promise((resolve5, reject) => {
15258
15558
  if (signal) {
15259
15559
  signal.throwIfAborted();
15260
15560
  signal.addEventListener("abort", abortHandler, { once: true });
@@ -15265,7 +15565,7 @@ async function delay(ms, { signal }) {
15265
15565
  }
15266
15566
  const timeoutId = setTimeout(() => {
15267
15567
  signal?.removeEventListener("abort", abortHandler);
15268
- resolve4();
15568
+ resolve5();
15269
15569
  }, ms);
15270
15570
  });
15271
15571
  }
@@ -17173,7 +17473,7 @@ function getApiKeyOrUndefined() {
17173
17473
 
17174
17474
  // src/utils/http.ts
17175
17475
  function getUserAgent() {
17176
- return `moxt-cli/${"0.8.0-beta.1"} (${(0, import_os2.platform)()}/${(0, import_os2.arch)()}) node/${process.versions.node}`;
17476
+ return `moxt-cli/${"0.8.0-beta.2"} (${(0, import_os2.platform)()}/${(0, import_os2.arch)()}) node/${process.versions.node}`;
17177
17477
  }
17178
17478
  async function fetchApi(method, path10, body) {
17179
17479
  const apiKey = getApiKey();
@@ -17340,8 +17640,8 @@ function readCommentContentFile(path10) {
17340
17640
  if (!fs5.existsSync(path10)) {
17341
17641
  throw new FileCommentOptionsError(`Error: comment content file not found: ${path10}`);
17342
17642
  }
17343
- const stat = fs5.statSync(path10);
17344
- if (!stat.isFile()) {
17643
+ const stat2 = fs5.statSync(path10);
17644
+ if (!stat2.isFile()) {
17345
17645
  throw new FileCommentOptionsError(`Error: comment content path is not a file: ${path10}`);
17346
17646
  }
17347
17647
  const buffer2 = fs5.readFileSync(path10);
@@ -18400,8 +18700,8 @@ function readDescFile(path10) {
18400
18700
  if (!fs8.existsSync(path10)) {
18401
18701
  throw new WorkflowOptionsError(`Error: desc file not found: ${path10}`);
18402
18702
  }
18403
- const stat = fs8.statSync(path10);
18404
- if (!stat.isFile()) {
18703
+ const stat2 = fs8.statSync(path10);
18704
+ if (!stat2.isFile()) {
18405
18705
  throw new WorkflowOptionsError(`Error: desc file is not a file: ${path10}`);
18406
18706
  }
18407
18707
  const buffer2 = fs8.readFileSync(path10);
@@ -18418,11 +18718,11 @@ function readCommentContentFile2(path10) {
18418
18718
  if (!fs8.existsSync(path10)) {
18419
18719
  throw new WorkflowOptionsError(`Error: comment content file not found: ${path10}`);
18420
18720
  }
18421
- const stat = fs8.statSync(path10);
18422
- if (!stat.isFile()) {
18721
+ const stat2 = fs8.statSync(path10);
18722
+ if (!stat2.isFile()) {
18423
18723
  throw new WorkflowOptionsError(`Error: comment content path is not a file: ${path10}`);
18424
18724
  }
18425
- if (stat.size > MAX_COMMENT_CONTENT_BYTES) {
18725
+ if (stat2.size > MAX_COMMENT_CONTENT_BYTES) {
18426
18726
  throw new WorkflowOptionsError(
18427
18727
  `Error: comment content file must be at most ${MAX_COMMENT_CONTENT_LENGTH} characters.`
18428
18728
  );
@@ -19334,7 +19634,7 @@ var FLUSH_TIMEOUT_MS = 3e3;
19334
19634
  var MAX_BATCH_SIZE = 100;
19335
19635
  function commonLabels() {
19336
19636
  return {
19337
- cli_version: "0.8.0-beta.1",
19637
+ cli_version: "0.8.0-beta.2",
19338
19638
  node_version: process.versions.node,
19339
19639
  os: (0, import_node_os10.platform)(),
19340
19640
  arch: (0, import_node_os10.arch)(),
@@ -19380,7 +19680,7 @@ async function flush() {
19380
19680
  }
19381
19681
  const batch = buffer.splice(0, MAX_BATCH_SIZE);
19382
19682
  const payload = {
19383
- release_id: "0.8.0-beta.1",
19683
+ release_id: "0.8.0-beta.2",
19384
19684
  client_type: "cli",
19385
19685
  metric_data_list: batch.map((m) => ({
19386
19686
  profile: "cli",
@@ -19525,9 +19825,9 @@ function installExitHandler() {
19525
19825
 
19526
19826
  // src/index.ts
19527
19827
  updateNotifier({
19528
- pkg: { name: "@moxt-ai/cli", version: "0.8.0-beta.1" }
19828
+ pkg: { name: "@moxt-ai/cli", version: "0.8.0-beta.2" }
19529
19829
  }).notify();
19530
- var program2 = createProgram("0.8.0-beta.1");
19830
+ var program2 = createProgram("0.8.0-beta.2");
19531
19831
  instrumentProgram(program2);
19532
19832
  installExitHandler();
19533
19833
  program2.parseAsync(process.argv).then(async () => {