@moxt-ai/cli 0.9.0-beta.2 → 0.9.0-beta.3
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/README.md +9 -1
- package/dist/index.cjs +592 -339
- package/dist/index.cjs.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -5382,6 +5382,202 @@ var init_execution_cancellation = __esm({
|
|
|
5382
5382
|
}
|
|
5383
5383
|
});
|
|
5384
5384
|
|
|
5385
|
+
// ../machine-connector/dist/runtime/local-ipc.js
|
|
5386
|
+
async function requestRuntimeStatus(store, timeoutMilliseconds = 1e3) {
|
|
5387
|
+
return await requestLocalIpc(store, "status", timeoutMilliseconds);
|
|
5388
|
+
}
|
|
5389
|
+
async function requestEnvironmentRefresh(store, timeoutMilliseconds = 1e4) {
|
|
5390
|
+
return await requestLocalIpc(store, "environment_refresh", timeoutMilliseconds);
|
|
5391
|
+
}
|
|
5392
|
+
async function requestLocalIpc(store, action, timeoutMilliseconds) {
|
|
5393
|
+
return await new Promise((resolvePromise, rejectPromise) => {
|
|
5394
|
+
const socket = (0, import_node_net.createConnection)(store.runtimeSocketPath());
|
|
5395
|
+
let responseText = "";
|
|
5396
|
+
socket.setEncoding("utf8");
|
|
5397
|
+
socket.once("error", rejectPromise);
|
|
5398
|
+
socket.setTimeout(timeoutMilliseconds, () => {
|
|
5399
|
+
socket.destroy(new Error(`Runtime status timed out after ${timeoutMilliseconds}ms`));
|
|
5400
|
+
});
|
|
5401
|
+
socket.on("data", (chunk) => {
|
|
5402
|
+
responseText += chunk;
|
|
5403
|
+
});
|
|
5404
|
+
socket.once("close", () => {
|
|
5405
|
+
try {
|
|
5406
|
+
resolvePromise(JSON.parse(responseText.trim()));
|
|
5407
|
+
} catch (error) {
|
|
5408
|
+
rejectPromise(error);
|
|
5409
|
+
}
|
|
5410
|
+
});
|
|
5411
|
+
socket.once("connect", () => {
|
|
5412
|
+
socket.write(`${JSON.stringify({ action })}
|
|
5413
|
+
`);
|
|
5414
|
+
});
|
|
5415
|
+
});
|
|
5416
|
+
}
|
|
5417
|
+
var import_promises5, import_node_net, import_node_os2, LocalIpcServer;
|
|
5418
|
+
var init_local_ipc = __esm({
|
|
5419
|
+
"../machine-connector/dist/runtime/local-ipc.js"() {
|
|
5420
|
+
"use strict";
|
|
5421
|
+
init_cjs_shims();
|
|
5422
|
+
import_promises5 = require("fs/promises");
|
|
5423
|
+
import_node_net = require("net");
|
|
5424
|
+
import_node_os2 = require("os");
|
|
5425
|
+
LocalIpcServer = class {
|
|
5426
|
+
store;
|
|
5427
|
+
getStatus;
|
|
5428
|
+
refreshEnvironment;
|
|
5429
|
+
server;
|
|
5430
|
+
constructor(store, getStatus, refreshEnvironment) {
|
|
5431
|
+
this.store = store;
|
|
5432
|
+
this.getStatus = getStatus;
|
|
5433
|
+
this.refreshEnvironment = refreshEnvironment;
|
|
5434
|
+
}
|
|
5435
|
+
async start() {
|
|
5436
|
+
const socketPath = this.store.runtimeSocketPath();
|
|
5437
|
+
if ((0, import_node_os2.platform)() !== "win32") {
|
|
5438
|
+
await (0, import_promises5.rm)(socketPath, { force: true });
|
|
5439
|
+
}
|
|
5440
|
+
this.server = (0, import_node_net.createServer)((socket) => {
|
|
5441
|
+
let requestText = "";
|
|
5442
|
+
let handled = false;
|
|
5443
|
+
socket.setEncoding("utf8");
|
|
5444
|
+
socket.on("data", (chunk) => {
|
|
5445
|
+
requestText += chunk;
|
|
5446
|
+
if (handled || !requestText.includes("\n")) {
|
|
5447
|
+
return;
|
|
5448
|
+
}
|
|
5449
|
+
handled = true;
|
|
5450
|
+
void this.handleRequest(requestText).then((response) => {
|
|
5451
|
+
socket.end(`${JSON.stringify(response)}
|
|
5452
|
+
`);
|
|
5453
|
+
});
|
|
5454
|
+
});
|
|
5455
|
+
});
|
|
5456
|
+
await new Promise((resolvePromise, rejectPromise) => {
|
|
5457
|
+
this.server?.once("error", rejectPromise);
|
|
5458
|
+
this.server?.listen(socketPath, resolvePromise);
|
|
5459
|
+
});
|
|
5460
|
+
if ((0, import_node_os2.platform)() !== "win32") {
|
|
5461
|
+
await (0, import_promises5.chmod)(socketPath, 384);
|
|
5462
|
+
}
|
|
5463
|
+
}
|
|
5464
|
+
async close() {
|
|
5465
|
+
if (!this.server) {
|
|
5466
|
+
return;
|
|
5467
|
+
}
|
|
5468
|
+
await new Promise((resolvePromise) => {
|
|
5469
|
+
this.server?.close(() => resolvePromise());
|
|
5470
|
+
});
|
|
5471
|
+
if ((0, import_node_os2.platform)() !== "win32") {
|
|
5472
|
+
await (0, import_promises5.rm)(this.store.runtimeSocketPath(), { force: true });
|
|
5473
|
+
}
|
|
5474
|
+
}
|
|
5475
|
+
async handleRequest(requestText) {
|
|
5476
|
+
try {
|
|
5477
|
+
const request2 = JSON.parse(requestText.trim());
|
|
5478
|
+
if (request2.action === "status") {
|
|
5479
|
+
return { status: this.getStatus() };
|
|
5480
|
+
}
|
|
5481
|
+
if (request2.action === "environment_refresh") {
|
|
5482
|
+
if (!this.refreshEnvironment) {
|
|
5483
|
+
return { error: "Environment refresh is unavailable" };
|
|
5484
|
+
}
|
|
5485
|
+
return {
|
|
5486
|
+
environmentRefresh: await this.refreshEnvironment()
|
|
5487
|
+
};
|
|
5488
|
+
}
|
|
5489
|
+
return { error: `Unsupported IPC action: ${request2.action}` };
|
|
5490
|
+
} catch (error) {
|
|
5491
|
+
return {
|
|
5492
|
+
error: error instanceof Error ? error.message : "Invalid IPC request"
|
|
5493
|
+
};
|
|
5494
|
+
}
|
|
5495
|
+
}
|
|
5496
|
+
};
|
|
5497
|
+
}
|
|
5498
|
+
});
|
|
5499
|
+
|
|
5500
|
+
// ../machine-connector/dist/runtime/execution-context.js
|
|
5501
|
+
function createLocalMachineJobExecutionContext(connectorInstanceId, runtimeDirectory) {
|
|
5502
|
+
if (!connectorInstanceId) {
|
|
5503
|
+
throw new Error("Connector instance ID is required");
|
|
5504
|
+
}
|
|
5505
|
+
return {
|
|
5506
|
+
connectorInstanceId,
|
|
5507
|
+
kind: "local_machine_job",
|
|
5508
|
+
runtimeDirectory: (0, import_node_path4.resolve)(runtimeDirectory)
|
|
5509
|
+
};
|
|
5510
|
+
}
|
|
5511
|
+
function serializeLocalMachineJobExecutionContext(context) {
|
|
5512
|
+
return `${localMachineJobPrefix}${Buffer.from(JSON.stringify(context), "utf8").toString("base64url")}`;
|
|
5513
|
+
}
|
|
5514
|
+
function parseLocalMachineJobExecutionContext(value) {
|
|
5515
|
+
if (!value?.startsWith(localMachineJobPrefix))
|
|
5516
|
+
return void 0;
|
|
5517
|
+
try {
|
|
5518
|
+
const decoded = JSON.parse(Buffer.from(value.slice(localMachineJobPrefix.length), "base64url").toString("utf8"));
|
|
5519
|
+
if (decoded.kind !== "local_machine_job" || typeof decoded.connectorInstanceId !== "string" || decoded.connectorInstanceId.length === 0 || typeof decoded.runtimeDirectory !== "string" || decoded.runtimeDirectory.length === 0 || (0, import_node_path4.resolve)(decoded.runtimeDirectory) !== decoded.runtimeDirectory) {
|
|
5520
|
+
return void 0;
|
|
5521
|
+
}
|
|
5522
|
+
return decoded;
|
|
5523
|
+
} catch {
|
|
5524
|
+
return void 0;
|
|
5525
|
+
}
|
|
5526
|
+
}
|
|
5527
|
+
async function localMachineJobTargetRelationship(store, value = process.env[machineExecutionContextEnvironmentName]) {
|
|
5528
|
+
const context = parseLocalMachineJobExecutionContext(value);
|
|
5529
|
+
if (!context)
|
|
5530
|
+
return void 0;
|
|
5531
|
+
const targetRuntimeDirectory = (0, import_node_path4.resolve)(store.baseDirectory);
|
|
5532
|
+
const carryingRuntimeDirectory = (0, import_node_path4.resolve)(context.runtimeDirectory);
|
|
5533
|
+
if (targetRuntimeDirectory !== carryingRuntimeDirectory) {
|
|
5534
|
+
try {
|
|
5535
|
+
const [canonicalTarget, canonicalCarrying] = await Promise.all([
|
|
5536
|
+
canonicalizePotentialRuntimeDirectory(targetRuntimeDirectory),
|
|
5537
|
+
canonicalizePotentialRuntimeDirectory(carryingRuntimeDirectory)
|
|
5538
|
+
]);
|
|
5539
|
+
if (canonicalTarget !== canonicalCarrying) {
|
|
5540
|
+
return "different_runtime";
|
|
5541
|
+
}
|
|
5542
|
+
} catch {
|
|
5543
|
+
return "same_runtime_stale_or_unreachable";
|
|
5544
|
+
}
|
|
5545
|
+
}
|
|
5546
|
+
try {
|
|
5547
|
+
const status = (await requestRuntimeStatus(store)).status;
|
|
5548
|
+
if (status?.connectorInstanceId === context.connectorInstanceId) {
|
|
5549
|
+
return "matching_instance";
|
|
5550
|
+
}
|
|
5551
|
+
} catch {
|
|
5552
|
+
}
|
|
5553
|
+
return "same_runtime_stale_or_unreachable";
|
|
5554
|
+
}
|
|
5555
|
+
async function canonicalizePotentialRuntimeDirectory(path4) {
|
|
5556
|
+
try {
|
|
5557
|
+
return await (0, import_promises6.realpath)(path4);
|
|
5558
|
+
} catch (error) {
|
|
5559
|
+
if (!(error instanceof Error) || !("code" in error) || error.code !== "ENOENT") {
|
|
5560
|
+
throw error;
|
|
5561
|
+
}
|
|
5562
|
+
const parent = (0, import_node_path4.dirname)(path4);
|
|
5563
|
+
if (parent === path4)
|
|
5564
|
+
return path4;
|
|
5565
|
+
return (0, import_node_path4.join)(await canonicalizePotentialRuntimeDirectory(parent), (0, import_node_path4.basename)(path4));
|
|
5566
|
+
}
|
|
5567
|
+
}
|
|
5568
|
+
var import_promises6, import_node_path4, machineExecutionContextEnvironmentName, localMachineJobPrefix;
|
|
5569
|
+
var init_execution_context = __esm({
|
|
5570
|
+
"../machine-connector/dist/runtime/execution-context.js"() {
|
|
5571
|
+
"use strict";
|
|
5572
|
+
init_cjs_shims();
|
|
5573
|
+
import_promises6 = require("fs/promises");
|
|
5574
|
+
import_node_path4 = require("path");
|
|
5575
|
+
init_local_ipc();
|
|
5576
|
+
machineExecutionContextEnvironmentName = "MOXT_MACHINE_EXECUTION_CONTEXT";
|
|
5577
|
+
localMachineJobPrefix = "local_machine_job:v1:";
|
|
5578
|
+
}
|
|
5579
|
+
});
|
|
5580
|
+
|
|
5385
5581
|
// ../machine-connector/dist/runtime/image-viewer.js
|
|
5386
5582
|
async function viewLocalMachineImage(rootPath, relativeImagePath) {
|
|
5387
5583
|
validateRelativeImagePath(relativeImagePath);
|
|
@@ -5408,41 +5604,41 @@ async function viewLocalMachineImage(rootPath, relativeImagePath) {
|
|
|
5408
5604
|
}
|
|
5409
5605
|
async function resolvePairedRoot(rootPath) {
|
|
5410
5606
|
try {
|
|
5411
|
-
return await (0,
|
|
5607
|
+
return await (0, import_promises7.realpath)(rootPath);
|
|
5412
5608
|
} catch {
|
|
5413
5609
|
throw new Error("Paired Local Machine root is unavailable");
|
|
5414
5610
|
}
|
|
5415
5611
|
}
|
|
5416
5612
|
async function resolveImagePath(canonicalRoot, relativeImagePath) {
|
|
5417
5613
|
try {
|
|
5418
|
-
return await (0,
|
|
5614
|
+
return await (0, import_promises7.realpath)((0, import_node_path5.resolve)(canonicalRoot, relativeImagePath));
|
|
5419
5615
|
} catch {
|
|
5420
5616
|
throw new Error(`Image could not be read: ${relativeImagePath}`);
|
|
5421
5617
|
}
|
|
5422
5618
|
}
|
|
5423
5619
|
async function statImage(canonicalImage, relativeImagePath) {
|
|
5424
5620
|
try {
|
|
5425
|
-
return await (0,
|
|
5621
|
+
return await (0, import_promises7.stat)(canonicalImage);
|
|
5426
5622
|
} catch {
|
|
5427
5623
|
throw new Error(`Image could not be read: ${relativeImagePath}`);
|
|
5428
5624
|
}
|
|
5429
5625
|
}
|
|
5430
5626
|
async function readImageBytes(canonicalImage, relativeImagePath) {
|
|
5431
5627
|
try {
|
|
5432
|
-
return await (0,
|
|
5628
|
+
return await (0, import_promises7.readFile)(canonicalImage);
|
|
5433
5629
|
} catch {
|
|
5434
5630
|
throw new Error(`Image could not be read: ${relativeImagePath}`);
|
|
5435
5631
|
}
|
|
5436
5632
|
}
|
|
5437
5633
|
function validateRelativeImagePath(path4) {
|
|
5438
5634
|
const segments = path4.split(/[\\/]/);
|
|
5439
|
-
if (path4.length === 0 || path4.length > 4096 || path4.includes("\0") || (0,
|
|
5635
|
+
if (path4.length === 0 || path4.length > 4096 || path4.includes("\0") || (0, import_node_path5.isAbsolute)(path4) || import_node_path5.win32.isAbsolute(path4) || segments.some((segment) => segment.length === 0 || segment === "." || segment === "..")) {
|
|
5440
5636
|
throw new Error(`Invalid relative image path: ${path4}`);
|
|
5441
5637
|
}
|
|
5442
5638
|
}
|
|
5443
5639
|
function requireInsideRoot(canonicalRoot, canonicalImage) {
|
|
5444
|
-
const relativePath = (0,
|
|
5445
|
-
if (relativePath === ".." || relativePath.startsWith(`..${
|
|
5640
|
+
const relativePath = (0, import_node_path5.relative)(canonicalRoot, canonicalImage);
|
|
5641
|
+
if (relativePath === ".." || relativePath.startsWith(`..${import_node_path5.sep}`) || (0, import_node_path5.isAbsolute)(relativePath)) {
|
|
5446
5642
|
throw new Error("Image path escapes paired root");
|
|
5447
5643
|
}
|
|
5448
5644
|
}
|
|
@@ -5642,147 +5838,32 @@ function startsWithAscii(bytes, offset, text3) {
|
|
|
5642
5838
|
}
|
|
5643
5839
|
return true;
|
|
5644
5840
|
}
|
|
5645
|
-
var
|
|
5841
|
+
var import_promises7, import_node_path5, maximumLocalMachineImageBytes;
|
|
5646
5842
|
var init_image_viewer = __esm({
|
|
5647
5843
|
"../machine-connector/dist/runtime/image-viewer.js"() {
|
|
5648
5844
|
"use strict";
|
|
5649
5845
|
init_cjs_shims();
|
|
5650
|
-
|
|
5651
|
-
|
|
5846
|
+
import_promises7 = require("fs/promises");
|
|
5847
|
+
import_node_path5 = require("path");
|
|
5652
5848
|
maximumLocalMachineImageBytes = 1e7;
|
|
5653
5849
|
}
|
|
5654
5850
|
});
|
|
5655
5851
|
|
|
5656
|
-
// ../machine-connector/dist/runtime/local-ipc.js
|
|
5657
|
-
async function requestRuntimeStatus(store, timeoutMilliseconds = 1e3) {
|
|
5658
|
-
return await requestLocalIpc(store, "status", timeoutMilliseconds);
|
|
5659
|
-
}
|
|
5660
|
-
async function requestEnvironmentRefresh(store, timeoutMilliseconds = 1e4) {
|
|
5661
|
-
return await requestLocalIpc(store, "environment_refresh", timeoutMilliseconds);
|
|
5662
|
-
}
|
|
5663
|
-
async function requestLocalIpc(store, action, timeoutMilliseconds) {
|
|
5664
|
-
return await new Promise((resolvePromise, rejectPromise) => {
|
|
5665
|
-
const socket = (0, import_node_net.createConnection)(store.runtimeSocketPath());
|
|
5666
|
-
let responseText = "";
|
|
5667
|
-
socket.setEncoding("utf8");
|
|
5668
|
-
socket.once("error", rejectPromise);
|
|
5669
|
-
socket.setTimeout(timeoutMilliseconds, () => {
|
|
5670
|
-
socket.destroy(new Error(`Runtime status timed out after ${timeoutMilliseconds}ms`));
|
|
5671
|
-
});
|
|
5672
|
-
socket.on("data", (chunk) => {
|
|
5673
|
-
responseText += chunk;
|
|
5674
|
-
});
|
|
5675
|
-
socket.once("close", () => {
|
|
5676
|
-
try {
|
|
5677
|
-
resolvePromise(JSON.parse(responseText.trim()));
|
|
5678
|
-
} catch (error) {
|
|
5679
|
-
rejectPromise(error);
|
|
5680
|
-
}
|
|
5681
|
-
});
|
|
5682
|
-
socket.once("connect", () => {
|
|
5683
|
-
socket.write(`${JSON.stringify({ action })}
|
|
5684
|
-
`);
|
|
5685
|
-
});
|
|
5686
|
-
});
|
|
5687
|
-
}
|
|
5688
|
-
var import_promises6, import_node_net, import_node_os2, LocalIpcServer;
|
|
5689
|
-
var init_local_ipc = __esm({
|
|
5690
|
-
"../machine-connector/dist/runtime/local-ipc.js"() {
|
|
5691
|
-
"use strict";
|
|
5692
|
-
init_cjs_shims();
|
|
5693
|
-
import_promises6 = require("fs/promises");
|
|
5694
|
-
import_node_net = require("net");
|
|
5695
|
-
import_node_os2 = require("os");
|
|
5696
|
-
LocalIpcServer = class {
|
|
5697
|
-
store;
|
|
5698
|
-
getStatus;
|
|
5699
|
-
refreshEnvironment;
|
|
5700
|
-
server;
|
|
5701
|
-
constructor(store, getStatus, refreshEnvironment) {
|
|
5702
|
-
this.store = store;
|
|
5703
|
-
this.getStatus = getStatus;
|
|
5704
|
-
this.refreshEnvironment = refreshEnvironment;
|
|
5705
|
-
}
|
|
5706
|
-
async start() {
|
|
5707
|
-
const socketPath = this.store.runtimeSocketPath();
|
|
5708
|
-
if ((0, import_node_os2.platform)() !== "win32") {
|
|
5709
|
-
await (0, import_promises6.rm)(socketPath, { force: true });
|
|
5710
|
-
}
|
|
5711
|
-
this.server = (0, import_node_net.createServer)((socket) => {
|
|
5712
|
-
let requestText = "";
|
|
5713
|
-
let handled = false;
|
|
5714
|
-
socket.setEncoding("utf8");
|
|
5715
|
-
socket.on("data", (chunk) => {
|
|
5716
|
-
requestText += chunk;
|
|
5717
|
-
if (handled || !requestText.includes("\n")) {
|
|
5718
|
-
return;
|
|
5719
|
-
}
|
|
5720
|
-
handled = true;
|
|
5721
|
-
void this.handleRequest(requestText).then((response) => {
|
|
5722
|
-
socket.end(`${JSON.stringify(response)}
|
|
5723
|
-
`);
|
|
5724
|
-
});
|
|
5725
|
-
});
|
|
5726
|
-
});
|
|
5727
|
-
await new Promise((resolvePromise, rejectPromise) => {
|
|
5728
|
-
this.server?.once("error", rejectPromise);
|
|
5729
|
-
this.server?.listen(socketPath, resolvePromise);
|
|
5730
|
-
});
|
|
5731
|
-
if ((0, import_node_os2.platform)() !== "win32") {
|
|
5732
|
-
await (0, import_promises6.chmod)(socketPath, 384);
|
|
5733
|
-
}
|
|
5734
|
-
}
|
|
5735
|
-
async close() {
|
|
5736
|
-
if (!this.server) {
|
|
5737
|
-
return;
|
|
5738
|
-
}
|
|
5739
|
-
await new Promise((resolvePromise) => {
|
|
5740
|
-
this.server?.close(() => resolvePromise());
|
|
5741
|
-
});
|
|
5742
|
-
if ((0, import_node_os2.platform)() !== "win32") {
|
|
5743
|
-
await (0, import_promises6.rm)(this.store.runtimeSocketPath(), { force: true });
|
|
5744
|
-
}
|
|
5745
|
-
}
|
|
5746
|
-
async handleRequest(requestText) {
|
|
5747
|
-
try {
|
|
5748
|
-
const request2 = JSON.parse(requestText.trim());
|
|
5749
|
-
if (request2.action === "status") {
|
|
5750
|
-
return { status: this.getStatus() };
|
|
5751
|
-
}
|
|
5752
|
-
if (request2.action === "environment_refresh") {
|
|
5753
|
-
if (!this.refreshEnvironment) {
|
|
5754
|
-
return { error: "Environment refresh is unavailable" };
|
|
5755
|
-
}
|
|
5756
|
-
return {
|
|
5757
|
-
environmentRefresh: await this.refreshEnvironment()
|
|
5758
|
-
};
|
|
5759
|
-
}
|
|
5760
|
-
return { error: `Unsupported IPC action: ${request2.action}` };
|
|
5761
|
-
} catch (error) {
|
|
5762
|
-
return {
|
|
5763
|
-
error: error instanceof Error ? error.message : "Invalid IPC request"
|
|
5764
|
-
};
|
|
5765
|
-
}
|
|
5766
|
-
}
|
|
5767
|
-
};
|
|
5768
|
-
}
|
|
5769
|
-
});
|
|
5770
|
-
|
|
5771
5852
|
// ../machine-connector/dist/runtime/process-lock.js
|
|
5772
5853
|
async function createCompleteLock(path4, record2) {
|
|
5773
|
-
await (0,
|
|
5854
|
+
await (0, import_promises8.mkdir)(path4, { mode: 448 });
|
|
5774
5855
|
let metadata;
|
|
5775
5856
|
try {
|
|
5776
|
-
metadata = await (0,
|
|
5857
|
+
metadata = await (0, import_promises8.stat)(path4);
|
|
5777
5858
|
} catch (error) {
|
|
5778
5859
|
if (isNodeErrorCode2(error, "ENOENT") || isNodeErrorCode2(error, "ENOTDIR")) {
|
|
5779
5860
|
throw nodeError("EEXIST", "Lock directory changed while publishing");
|
|
5780
5861
|
}
|
|
5781
5862
|
throw error;
|
|
5782
5863
|
}
|
|
5783
|
-
const ownerPath = (0,
|
|
5864
|
+
const ownerPath = (0, import_node_path6.join)(path4, `${metadata.dev}.${metadata.ino}.${record2.pid}.${record2.token}.owner`);
|
|
5784
5865
|
try {
|
|
5785
|
-
await (0,
|
|
5866
|
+
await (0, import_promises8.writeFile)(ownerPath, `${JSON.stringify(record2)}
|
|
5786
5867
|
`, {
|
|
5787
5868
|
encoding: "utf8",
|
|
5788
5869
|
flag: "wx",
|
|
@@ -5790,7 +5871,7 @@ async function createCompleteLock(path4, record2) {
|
|
|
5790
5871
|
});
|
|
5791
5872
|
let current2;
|
|
5792
5873
|
try {
|
|
5793
|
-
current2 = await (0,
|
|
5874
|
+
current2 = await (0, import_promises8.stat)(path4);
|
|
5794
5875
|
} catch (error) {
|
|
5795
5876
|
if (isNodeErrorCode2(error, "ENOENT") || isNodeErrorCode2(error, "ENOTDIR")) {
|
|
5796
5877
|
throw nodeError("EEXIST", "Lock directory changed while publishing");
|
|
@@ -5813,7 +5894,7 @@ async function createCompleteLock(path4, record2) {
|
|
|
5813
5894
|
async function readLockState(path4) {
|
|
5814
5895
|
let metadata;
|
|
5815
5896
|
try {
|
|
5816
|
-
metadata = await (0,
|
|
5897
|
+
metadata = await (0, import_promises8.stat)(path4);
|
|
5817
5898
|
} catch (error) {
|
|
5818
5899
|
if (isNodeErrorCode2(error, "ENOENT"))
|
|
5819
5900
|
return void 0;
|
|
@@ -5828,7 +5909,7 @@ async function readLockState(path4) {
|
|
|
5828
5909
|
const ownerPrefix = `${metadata.dev}.${metadata.ino}.`;
|
|
5829
5910
|
let names;
|
|
5830
5911
|
try {
|
|
5831
|
-
names = await (0,
|
|
5912
|
+
names = await (0, import_promises8.readdir)(path4);
|
|
5832
5913
|
} catch (error) {
|
|
5833
5914
|
if (isNodeErrorCode2(error, "ENOENT") || isNodeErrorCode2(error, "ENOTDIR")) {
|
|
5834
5915
|
return void 0;
|
|
@@ -5838,7 +5919,7 @@ async function readLockState(path4) {
|
|
|
5838
5919
|
const ownerName = names.find((name) => name.startsWith(ownerPrefix) && name.endsWith(".owner"));
|
|
5839
5920
|
if (!ownerName)
|
|
5840
5921
|
return { metadata };
|
|
5841
|
-
const ownerPath = (0,
|
|
5922
|
+
const ownerPath = (0, import_node_path6.join)(path4, ownerName);
|
|
5842
5923
|
return {
|
|
5843
5924
|
metadata,
|
|
5844
5925
|
ownerPath,
|
|
@@ -5847,7 +5928,7 @@ async function readLockState(path4) {
|
|
|
5847
5928
|
}
|
|
5848
5929
|
async function readRecord(path4) {
|
|
5849
5930
|
try {
|
|
5850
|
-
const parsed = JSON.parse(await (0,
|
|
5931
|
+
const parsed = JSON.parse(await (0, import_promises8.readFile)(path4, "utf8"));
|
|
5851
5932
|
if (typeof parsed.createdAt !== "number" || !Number.isFinite(parsed.createdAt) || typeof parsed.pid !== "number" || !Number.isSafeInteger(parsed.pid) || parsed.pid <= 0 || typeof parsed.token !== "string" || parsed.token.length === 0) {
|
|
5852
5933
|
return void 0;
|
|
5853
5934
|
}
|
|
@@ -5869,7 +5950,7 @@ async function removeLockIfTokenMatches(path4, token) {
|
|
|
5869
5950
|
return;
|
|
5870
5951
|
}
|
|
5871
5952
|
try {
|
|
5872
|
-
await (0,
|
|
5953
|
+
await (0, import_promises8.rm)(path4);
|
|
5873
5954
|
} catch (error) {
|
|
5874
5955
|
if (isNodeErrorCode2(error, "ENOENT") || isNodeErrorCode2(error, "EISDIR") || isNodeErrorCode2(error, "ERR_FS_EISDIR") || isNodeErrorCode2(error, "EPERM")) {
|
|
5875
5956
|
return;
|
|
@@ -5893,7 +5974,7 @@ async function removeStaleIncompleteLock(path4, metadata) {
|
|
|
5893
5974
|
}
|
|
5894
5975
|
if (!metadata.isDirectory()) {
|
|
5895
5976
|
try {
|
|
5896
|
-
await (0,
|
|
5977
|
+
await (0, import_promises8.rm)(path4);
|
|
5897
5978
|
return true;
|
|
5898
5979
|
} catch (error) {
|
|
5899
5980
|
if (isNodeErrorCode2(error, "ENOENT") || isNodeErrorCode2(error, "EISDIR") || isNodeErrorCode2(error, "ERR_FS_EISDIR") || isNodeErrorCode2(error, "EPERM")) {
|
|
@@ -5905,7 +5986,7 @@ async function removeStaleIncompleteLock(path4, metadata) {
|
|
|
5905
5986
|
const ownerPrefix = `${metadata.dev}.${metadata.ino}.`;
|
|
5906
5987
|
let names;
|
|
5907
5988
|
try {
|
|
5908
|
-
names = await (0,
|
|
5989
|
+
names = await (0, import_promises8.readdir)(path4);
|
|
5909
5990
|
} catch (error) {
|
|
5910
5991
|
if (isNodeErrorCode2(error, "ENOENT") || isNodeErrorCode2(error, "ENOTDIR")) {
|
|
5911
5992
|
return false;
|
|
@@ -5922,7 +6003,7 @@ async function removeStaleIncompleteLock(path4, metadata) {
|
|
|
5922
6003
|
deadOwnerNames.push(name);
|
|
5923
6004
|
}
|
|
5924
6005
|
for (const name of deadOwnerNames) {
|
|
5925
|
-
await removeFileIfPresent((0,
|
|
6006
|
+
await removeFileIfPresent((0, import_node_path6.join)(path4, name));
|
|
5926
6007
|
}
|
|
5927
6008
|
return await removeEmptyDirectory(path4);
|
|
5928
6009
|
}
|
|
@@ -5939,11 +6020,11 @@ function directoryOwnerProcessId(ownerPrefix, ownerName) {
|
|
|
5939
6020
|
return processId;
|
|
5940
6021
|
}
|
|
5941
6022
|
async function removeStalePendingLockCandidates(path4) {
|
|
5942
|
-
const directory = (0,
|
|
5943
|
-
const lockName = (0,
|
|
6023
|
+
const directory = (0, import_node_path6.dirname)(path4);
|
|
6024
|
+
const lockName = (0, import_node_path6.basename)(path4);
|
|
5944
6025
|
let names;
|
|
5945
6026
|
try {
|
|
5946
|
-
names = await (0,
|
|
6027
|
+
names = await (0, import_promises8.readdir)(directory);
|
|
5947
6028
|
} catch (error) {
|
|
5948
6029
|
if (isNodeErrorCode2(error, "ENOENT"))
|
|
5949
6030
|
return;
|
|
@@ -5952,7 +6033,7 @@ async function removeStalePendingLockCandidates(path4) {
|
|
|
5952
6033
|
for (const name of names) {
|
|
5953
6034
|
if (!isPendingLockCandidateName(lockName, name))
|
|
5954
6035
|
continue;
|
|
5955
|
-
await removeOldUnchangedFile((0,
|
|
6036
|
+
await removeOldUnchangedFile((0, import_node_path6.join)(directory, name));
|
|
5956
6037
|
}
|
|
5957
6038
|
}
|
|
5958
6039
|
function isPendingLockCandidateName(lockName, name) {
|
|
@@ -5972,7 +6053,7 @@ function isPendingLockCandidateName(lockName, name) {
|
|
|
5972
6053
|
async function removeOldUnchangedFile(path4) {
|
|
5973
6054
|
let metadata;
|
|
5974
6055
|
try {
|
|
5975
|
-
metadata = await (0,
|
|
6056
|
+
metadata = await (0, import_promises8.stat)(path4);
|
|
5976
6057
|
} catch (error) {
|
|
5977
6058
|
return isNodeErrorCode2(error, "ENOENT");
|
|
5978
6059
|
}
|
|
@@ -5981,18 +6062,18 @@ async function removeOldUnchangedFile(path4) {
|
|
|
5981
6062
|
}
|
|
5982
6063
|
let current2;
|
|
5983
6064
|
try {
|
|
5984
|
-
current2 = await (0,
|
|
6065
|
+
current2 = await (0, import_promises8.stat)(path4);
|
|
5985
6066
|
} catch (error) {
|
|
5986
6067
|
return isNodeErrorCode2(error, "ENOENT");
|
|
5987
6068
|
}
|
|
5988
6069
|
if (!sameFileMetadata(metadata, current2))
|
|
5989
6070
|
return false;
|
|
5990
|
-
await (0,
|
|
6071
|
+
await (0, import_promises8.rm)(path4, { force: true });
|
|
5991
6072
|
return true;
|
|
5992
6073
|
}
|
|
5993
6074
|
async function removeEmptyDirectory(path4) {
|
|
5994
6075
|
try {
|
|
5995
|
-
await (0,
|
|
6076
|
+
await (0, import_promises8.rmdir)(path4);
|
|
5996
6077
|
return true;
|
|
5997
6078
|
} catch (error) {
|
|
5998
6079
|
if (isNodeErrorCode2(error, "ENOENT") || isNodeErrorCode2(error, "ENOTEMPTY") || isNodeErrorCode2(error, "EEXIST") || isNodeErrorCode2(error, "ENOTDIR")) {
|
|
@@ -6003,7 +6084,7 @@ async function removeEmptyDirectory(path4) {
|
|
|
6003
6084
|
}
|
|
6004
6085
|
async function removeFileIfPresent(path4) {
|
|
6005
6086
|
try {
|
|
6006
|
-
await (0,
|
|
6087
|
+
await (0, import_promises8.rm)(path4, { force: true });
|
|
6007
6088
|
} catch (error) {
|
|
6008
6089
|
if (isNodeErrorCode2(error, "ENOENT") || isNodeErrorCode2(error, "ENOTDIR")) {
|
|
6009
6090
|
return;
|
|
@@ -6034,14 +6115,14 @@ function nodeError(code, message) {
|
|
|
6034
6115
|
function delay3(milliseconds) {
|
|
6035
6116
|
return new Promise((resolvePromise) => setTimeout(resolvePromise, milliseconds));
|
|
6036
6117
|
}
|
|
6037
|
-
var import_node_crypto4,
|
|
6118
|
+
var import_node_crypto4, import_promises8, import_node_path6, incompleteLockStaleMilliseconds, ProcessLock;
|
|
6038
6119
|
var init_process_lock = __esm({
|
|
6039
6120
|
"../machine-connector/dist/runtime/process-lock.js"() {
|
|
6040
6121
|
"use strict";
|
|
6041
6122
|
init_cjs_shims();
|
|
6042
6123
|
import_node_crypto4 = require("crypto");
|
|
6043
|
-
|
|
6044
|
-
|
|
6124
|
+
import_promises8 = require("fs/promises");
|
|
6125
|
+
import_node_path6 = require("path");
|
|
6045
6126
|
incompleteLockStaleMilliseconds = 3e4;
|
|
6046
6127
|
ProcessLock = class _ProcessLock {
|
|
6047
6128
|
path;
|
|
@@ -6096,7 +6177,7 @@ var init_process_lock = __esm({
|
|
|
6096
6177
|
function sanitizeEnvironment(source) {
|
|
6097
6178
|
const environment = createEnvironmentMap();
|
|
6098
6179
|
for (const [name, value] of Object.entries(source)) {
|
|
6099
|
-
if (value === void 0 || isConnectorCredentialName(name)) {
|
|
6180
|
+
if (value === void 0 || direnvSessionStateNames.has(name) || name === machineExecutionContextEnvironmentName || isConnectorCredentialName(name)) {
|
|
6100
6181
|
continue;
|
|
6101
6182
|
}
|
|
6102
6183
|
environment[name] = value;
|
|
@@ -6169,7 +6250,7 @@ function parseDirenvJson(text3) {
|
|
|
6169
6250
|
function sanitizeDirenvExports(source) {
|
|
6170
6251
|
const exports2 = createEnvironmentMap();
|
|
6171
6252
|
for (const [name, value] of Object.entries(source)) {
|
|
6172
|
-
if (!isConnectorCredentialName(name)) {
|
|
6253
|
+
if (name !== machineExecutionContextEnvironmentName && !isConnectorCredentialName(name)) {
|
|
6173
6254
|
exports2[name] = value;
|
|
6174
6255
|
}
|
|
6175
6256
|
}
|
|
@@ -6181,30 +6262,30 @@ function isConnectorCredentialName(name) {
|
|
|
6181
6262
|
return name.startsWith("MOXT_MACHINE_") && /(?:^|_)(?:TOKEN|SECRET|CREDENTIALS?|PASSWORD|PRIVATE_KEY)(?:_|$)/.test(name.slice("MOXT_MACHINE_".length));
|
|
6182
6263
|
}
|
|
6183
6264
|
async function validateShell(shellPath) {
|
|
6184
|
-
if (!(0,
|
|
6265
|
+
if (!(0, import_node_path7.isAbsolute)(shellPath))
|
|
6185
6266
|
throw new Error("default shell is not absolute");
|
|
6186
6267
|
const canonicalPath = await validateExecutable(shellPath);
|
|
6187
|
-
const shellName = (0,
|
|
6268
|
+
const shellName = (0, import_node_path7.basename)(canonicalPath);
|
|
6188
6269
|
if (shellName !== "bash" && shellName !== "zsh") {
|
|
6189
6270
|
throw new Error("default shell is not Bash or Zsh");
|
|
6190
6271
|
}
|
|
6191
6272
|
return canonicalPath;
|
|
6192
6273
|
}
|
|
6193
6274
|
async function validateExecutable(path4) {
|
|
6194
|
-
const canonicalPath = await (0,
|
|
6195
|
-
const metadata = await (0,
|
|
6275
|
+
const canonicalPath = await (0, import_promises9.realpath)(path4);
|
|
6276
|
+
const metadata = await (0, import_promises9.stat)(canonicalPath);
|
|
6196
6277
|
if (!metadata.isFile())
|
|
6197
6278
|
throw new Error("executable is not a regular file");
|
|
6198
|
-
await (0,
|
|
6279
|
+
await (0, import_promises9.access)(canonicalPath, import_promises9.constants.X_OK);
|
|
6199
6280
|
return canonicalPath;
|
|
6200
6281
|
}
|
|
6201
6282
|
async function findExecutable(name, pathValue) {
|
|
6202
|
-
for (const directory of (pathValue ?? "").split(
|
|
6203
|
-
if (!(0,
|
|
6283
|
+
for (const directory of (pathValue ?? "").split(import_node_path7.delimiter)) {
|
|
6284
|
+
if (!(0, import_node_path7.isAbsolute)(directory))
|
|
6204
6285
|
continue;
|
|
6205
6286
|
try {
|
|
6206
|
-
const candidate = await validateExecutable((0,
|
|
6207
|
-
if ((0,
|
|
6287
|
+
const candidate = await validateExecutable((0, import_node_path7.join)(directory, name));
|
|
6288
|
+
if ((0, import_node_path7.basename)(candidate) === name)
|
|
6208
6289
|
return candidate;
|
|
6209
6290
|
} catch {
|
|
6210
6291
|
}
|
|
@@ -6214,9 +6295,9 @@ async function findExecutable(name, pathValue) {
|
|
|
6214
6295
|
async function findNearestEnvrc(canonicalRoot, canonicalWorkingDirectory) {
|
|
6215
6296
|
let directory = canonicalWorkingDirectory;
|
|
6216
6297
|
while (true) {
|
|
6217
|
-
const candidate = (0,
|
|
6298
|
+
const candidate = (0, import_node_path7.join)(directory, ".envrc");
|
|
6218
6299
|
try {
|
|
6219
|
-
const metadata = await (0,
|
|
6300
|
+
const metadata = await (0, import_promises9.stat)(candidate);
|
|
6220
6301
|
if (!metadata.isFile()) {
|
|
6221
6302
|
throw new JobEnvironmentError("direnv_malformed");
|
|
6222
6303
|
}
|
|
@@ -6227,7 +6308,7 @@ async function findNearestEnvrc(canonicalRoot, canonicalWorkingDirectory) {
|
|
|
6227
6308
|
}
|
|
6228
6309
|
if (directory === canonicalRoot)
|
|
6229
6310
|
return void 0;
|
|
6230
|
-
const parent = (0,
|
|
6311
|
+
const parent = (0, import_node_path7.dirname)(directory);
|
|
6231
6312
|
if (parent === directory)
|
|
6232
6313
|
return void 0;
|
|
6233
6314
|
directory = parent;
|
|
@@ -6375,21 +6456,28 @@ function degradedCapture(category) {
|
|
|
6375
6456
|
function isNodeError(error, code) {
|
|
6376
6457
|
return error instanceof Error && "code" in error && error.code === code;
|
|
6377
6458
|
}
|
|
6378
|
-
var import_node_child_process2,
|
|
6459
|
+
var import_node_child_process2, import_promises9, import_node_os3, import_node_path7, defaultCaptureTimeoutMilliseconds, defaultCaptureOutputLimitBytes, defaultDirenvTimeoutMilliseconds, defaultDirenvOutputLimitBytes, shellCaptureScript, environmentNamePattern, direnvSessionStateNames, JobEnvironmentError, JobEnvironmentCancelledError, ShellEnvironmentManager;
|
|
6379
6460
|
var init_shell_environment = __esm({
|
|
6380
6461
|
"../machine-connector/dist/runtime/shell-environment.js"() {
|
|
6381
6462
|
"use strict";
|
|
6382
6463
|
init_cjs_shims();
|
|
6383
6464
|
import_node_child_process2 = require("child_process");
|
|
6384
|
-
|
|
6465
|
+
import_promises9 = require("fs/promises");
|
|
6385
6466
|
import_node_os3 = require("os");
|
|
6386
|
-
|
|
6467
|
+
import_node_path7 = require("path");
|
|
6468
|
+
init_execution_context();
|
|
6387
6469
|
defaultCaptureTimeoutMilliseconds = 5e3;
|
|
6388
6470
|
defaultCaptureOutputLimitBytes = 1048576;
|
|
6389
6471
|
defaultDirenvTimeoutMilliseconds = 5e3;
|
|
6390
6472
|
defaultDirenvOutputLimitBytes = 1048576;
|
|
6391
6473
|
shellCaptureScript = `exec "$1" -e 'for (const [name, value] of Object.entries(process.env)) process.stdout.write(name + "=" + value + "\\0")'`;
|
|
6392
6474
|
environmentNamePattern = /^[A-Za-z_][A-Za-z0-9_]*$/;
|
|
6475
|
+
direnvSessionStateNames = /* @__PURE__ */ new Set([
|
|
6476
|
+
"DIRENV_DIFF",
|
|
6477
|
+
"DIRENV_DIR",
|
|
6478
|
+
"DIRENV_FILE",
|
|
6479
|
+
"DIRENV_WATCHES"
|
|
6480
|
+
]);
|
|
6393
6481
|
JobEnvironmentError = class extends Error {
|
|
6394
6482
|
category;
|
|
6395
6483
|
constructor(category) {
|
|
@@ -6443,19 +6531,24 @@ var init_shell_environment = __esm({
|
|
|
6443
6531
|
status() {
|
|
6444
6532
|
return { ...this.currentStatus };
|
|
6445
6533
|
}
|
|
6446
|
-
async resolveForJob(canonicalRoot, canonicalWorkingDirectory, explicitEnvironment,
|
|
6447
|
-
throwIfCancelled(cancellationSignal);
|
|
6448
|
-
|
|
6449
|
-
|
|
6534
|
+
async resolveForJob(canonicalRoot, canonicalWorkingDirectory, explicitEnvironment, options) {
|
|
6535
|
+
throwIfCancelled(options.cancellationSignal);
|
|
6536
|
+
if (Object.hasOwn(explicitEnvironment, machineExecutionContextEnvironmentName)) {
|
|
6537
|
+
throw new JobEnvironmentError("reserved_environment");
|
|
6538
|
+
}
|
|
6539
|
+
const executionContextValue = serializeLocalMachineJobExecutionContext(options.executionContext);
|
|
6540
|
+
const relativeWorkingDirectory = (0, import_node_path7.relative)(canonicalRoot, canonicalWorkingDirectory);
|
|
6541
|
+
if (relativeWorkingDirectory === ".." || relativeWorkingDirectory.startsWith(`..${import_node_path7.sep}`) || (0, import_node_path7.isAbsolute)(relativeWorkingDirectory)) {
|
|
6450
6542
|
throw new JobEnvironmentError("direnv_malformed");
|
|
6451
6543
|
}
|
|
6452
6544
|
const baseSnapshot = this.currentEnvironment;
|
|
6453
6545
|
const envrcPath = await findNearestEnvrc(canonicalRoot, canonicalWorkingDirectory);
|
|
6454
|
-
throwIfCancelled(cancellationSignal);
|
|
6546
|
+
throwIfCancelled(options.cancellationSignal);
|
|
6455
6547
|
if (!envrcPath) {
|
|
6456
6548
|
return freezeEnvironment({
|
|
6457
6549
|
...baseSnapshot,
|
|
6458
|
-
...explicitEnvironment
|
|
6550
|
+
...explicitEnvironment,
|
|
6551
|
+
[machineExecutionContextEnvironmentName]: executionContextValue
|
|
6459
6552
|
});
|
|
6460
6553
|
}
|
|
6461
6554
|
const direnvExecutable = await findExecutable("direnv", baseSnapshot.PATH);
|
|
@@ -6465,11 +6558,14 @@ var init_shell_environment = __esm({
|
|
|
6465
6558
|
const result = await executeBounded({
|
|
6466
6559
|
argumentsList: ["export", "json"],
|
|
6467
6560
|
cwd: canonicalWorkingDirectory,
|
|
6468
|
-
environment:
|
|
6561
|
+
environment: {
|
|
6562
|
+
...baseSnapshot,
|
|
6563
|
+
[machineExecutionContextEnvironmentName]: executionContextValue
|
|
6564
|
+
},
|
|
6469
6565
|
executable: direnvExecutable,
|
|
6470
6566
|
outputLimitBytes: this.direnvOutputLimitBytes,
|
|
6471
6567
|
timeoutMilliseconds: this.direnvTimeoutMilliseconds,
|
|
6472
|
-
cancellationSignal
|
|
6568
|
+
cancellationSignal: options.cancellationSignal
|
|
6473
6569
|
});
|
|
6474
6570
|
if (result.outcome === "cancelled") {
|
|
6475
6571
|
throw new JobEnvironmentCancelledError();
|
|
@@ -6489,7 +6585,8 @@ var init_shell_environment = __esm({
|
|
|
6489
6585
|
}
|
|
6490
6586
|
let parsedExports;
|
|
6491
6587
|
try {
|
|
6492
|
-
|
|
6588
|
+
const output = decodeUtf8(result.stdout, "direnv_malformed");
|
|
6589
|
+
parsedExports = output.trim().length === 0 ? createEnvironmentMap() : parseDirenvJson(output);
|
|
6493
6590
|
} catch {
|
|
6494
6591
|
throw new JobEnvironmentError("direnv_malformed");
|
|
6495
6592
|
}
|
|
@@ -6504,7 +6601,8 @@ var init_shell_environment = __esm({
|
|
|
6504
6601
|
}
|
|
6505
6602
|
return freezeEnvironment({
|
|
6506
6603
|
...environment,
|
|
6507
|
-
...explicitEnvironment
|
|
6604
|
+
...explicitEnvironment,
|
|
6605
|
+
[machineExecutionContextEnvironmentName]: executionContextValue
|
|
6508
6606
|
});
|
|
6509
6607
|
}
|
|
6510
6608
|
async capture() {
|
|
@@ -6756,12 +6854,12 @@ var init_relay_client = __esm({
|
|
|
6756
6854
|
});
|
|
6757
6855
|
|
|
6758
6856
|
// ../machine-connector/dist/runtime/runtime-logger.js
|
|
6759
|
-
var
|
|
6857
|
+
var import_promises10, RuntimeLogger;
|
|
6760
6858
|
var init_runtime_logger = __esm({
|
|
6761
6859
|
"../machine-connector/dist/runtime/runtime-logger.js"() {
|
|
6762
6860
|
"use strict";
|
|
6763
6861
|
init_cjs_shims();
|
|
6764
|
-
|
|
6862
|
+
import_promises10 = require("fs/promises");
|
|
6765
6863
|
RuntimeLogger = class {
|
|
6766
6864
|
store;
|
|
6767
6865
|
constructor(store) {
|
|
@@ -6775,7 +6873,7 @@ var init_runtime_logger = __esm({
|
|
|
6775
6873
|
await this.write("error", message, metadata, this.store.runtimeErrorLogPath());
|
|
6776
6874
|
}
|
|
6777
6875
|
async write(level, message, metadata, path4) {
|
|
6778
|
-
await (0,
|
|
6876
|
+
await (0, import_promises10.appendFile)(path4, `${JSON.stringify({
|
|
6779
6877
|
level,
|
|
6780
6878
|
message,
|
|
6781
6879
|
metadata,
|
|
@@ -6798,10 +6896,10 @@ function defaultRuntimeDirectory() {
|
|
|
6798
6896
|
}
|
|
6799
6897
|
const homeDirectory = process.env.HOME ?? (0, import_node_os4.homedir)();
|
|
6800
6898
|
if ((0, import_node_os4.platform)() === "darwin") {
|
|
6801
|
-
return (0,
|
|
6899
|
+
return (0, import_node_path8.join)(homeDirectory, "Library", "Application Support", "Moxt", "Machine Connector");
|
|
6802
6900
|
}
|
|
6803
|
-
const stateHome = process.env.XDG_STATE_HOME ?? (0,
|
|
6804
|
-
return (0,
|
|
6901
|
+
const stateHome = process.env.XDG_STATE_HOME ?? (0, import_node_path8.join)(homeDirectory, ".local", "state");
|
|
6902
|
+
return (0, import_node_path8.join)(stateHome, "moxt", "machine-connector");
|
|
6805
6903
|
}
|
|
6806
6904
|
function isNodeErrorCode3(error, expectedCode) {
|
|
6807
6905
|
if (!(error instanceof Error) || !("code" in error)) {
|
|
@@ -6809,14 +6907,14 @@ function isNodeErrorCode3(error, expectedCode) {
|
|
|
6809
6907
|
}
|
|
6810
6908
|
return error.code === expectedCode;
|
|
6811
6909
|
}
|
|
6812
|
-
var
|
|
6910
|
+
var import_promises11, import_node_os4, import_node_path8, privateFileMode, privateDirectoryMode, MachineRuntimeStore;
|
|
6813
6911
|
var init_store = __esm({
|
|
6814
6912
|
"../machine-connector/dist/runtime/store.js"() {
|
|
6815
6913
|
"use strict";
|
|
6816
6914
|
init_cjs_shims();
|
|
6817
|
-
|
|
6915
|
+
import_promises11 = require("fs/promises");
|
|
6818
6916
|
import_node_os4 = require("os");
|
|
6819
|
-
|
|
6917
|
+
import_node_path8 = require("path");
|
|
6820
6918
|
privateFileMode = 384;
|
|
6821
6919
|
privateDirectoryMode = 448;
|
|
6822
6920
|
MachineRuntimeStore = class {
|
|
@@ -6825,20 +6923,20 @@ var init_store = __esm({
|
|
|
6825
6923
|
this.baseDirectory = baseDirectory;
|
|
6826
6924
|
}
|
|
6827
6925
|
async initialize() {
|
|
6828
|
-
await (0,
|
|
6926
|
+
await (0, import_promises11.mkdir)(this.jobsDirectory(), {
|
|
6829
6927
|
mode: privateDirectoryMode,
|
|
6830
6928
|
recursive: true
|
|
6831
6929
|
});
|
|
6832
|
-
await (0,
|
|
6930
|
+
await (0, import_promises11.mkdir)(this.detachedProcessesDirectory(), {
|
|
6833
6931
|
mode: privateDirectoryMode,
|
|
6834
6932
|
recursive: true
|
|
6835
6933
|
});
|
|
6836
|
-
await (0,
|
|
6837
|
-
await (0,
|
|
6838
|
-
await (0,
|
|
6934
|
+
await (0, import_promises11.chmod)(this.baseDirectory, privateDirectoryMode);
|
|
6935
|
+
await (0, import_promises11.chmod)(this.jobsDirectory(), privateDirectoryMode);
|
|
6936
|
+
await (0, import_promises11.chmod)(this.detachedProcessesDirectory(), privateDirectoryMode);
|
|
6839
6937
|
}
|
|
6840
6938
|
async getCanonicalRoot(rootPath) {
|
|
6841
|
-
return await (0,
|
|
6939
|
+
return await (0, import_promises11.realpath)(rootPath);
|
|
6842
6940
|
}
|
|
6843
6941
|
async readIdentity() {
|
|
6844
6942
|
return await this.readOptionalJson(this.identityPath());
|
|
@@ -6881,7 +6979,7 @@ var init_store = __esm({
|
|
|
6881
6979
|
await this.writePrivateJson(this.serviceManagerPath(), serviceManager);
|
|
6882
6980
|
}
|
|
6883
6981
|
async removeServiceManager() {
|
|
6884
|
-
await (0,
|
|
6982
|
+
await (0, import_promises11.rm)(this.serviceManagerPath(), { force: true });
|
|
6885
6983
|
}
|
|
6886
6984
|
async readJob(jobId) {
|
|
6887
6985
|
return await this.readOptionalJson(this.jobPath(jobId));
|
|
@@ -6892,7 +6990,7 @@ var init_store = __esm({
|
|
|
6892
6990
|
async listJobs() {
|
|
6893
6991
|
let names = [];
|
|
6894
6992
|
try {
|
|
6895
|
-
names = await (0,
|
|
6993
|
+
names = await (0, import_promises11.readdir)(this.jobsDirectory());
|
|
6896
6994
|
} catch (error) {
|
|
6897
6995
|
if (isNodeErrorCode3(error, "ENOENT")) {
|
|
6898
6996
|
return [];
|
|
@@ -6901,7 +6999,7 @@ var init_store = __esm({
|
|
|
6901
6999
|
}
|
|
6902
7000
|
const jobs = [];
|
|
6903
7001
|
for (const name of names.filter((entry) => entry.endsWith(".json"))) {
|
|
6904
|
-
const job = await this.readOptionalJson((0,
|
|
7002
|
+
const job = await this.readOptionalJson((0, import_node_path8.join)(this.jobsDirectory(), name));
|
|
6905
7003
|
if (job.value) {
|
|
6906
7004
|
jobs.push(job.value);
|
|
6907
7005
|
}
|
|
@@ -6909,7 +7007,7 @@ var init_store = __esm({
|
|
|
6909
7007
|
return jobs;
|
|
6910
7008
|
}
|
|
6911
7009
|
async deleteJob(jobId) {
|
|
6912
|
-
await (0,
|
|
7010
|
+
await (0, import_promises11.rm)(this.jobPath(jobId), { force: true });
|
|
6913
7011
|
}
|
|
6914
7012
|
async writeDetachedProcess(resource) {
|
|
6915
7013
|
await this.writePrivateJson(this.detachedProcessPath(resource.jobId), resource);
|
|
@@ -6917,7 +7015,7 @@ var init_store = __esm({
|
|
|
6917
7015
|
async listDetachedProcesses() {
|
|
6918
7016
|
let names = [];
|
|
6919
7017
|
try {
|
|
6920
|
-
names = await (0,
|
|
7018
|
+
names = await (0, import_promises11.readdir)(this.detachedProcessesDirectory());
|
|
6921
7019
|
} catch (error) {
|
|
6922
7020
|
if (isNodeErrorCode3(error, "ENOENT")) {
|
|
6923
7021
|
return [];
|
|
@@ -6926,7 +7024,7 @@ var init_store = __esm({
|
|
|
6926
7024
|
}
|
|
6927
7025
|
const resources = [];
|
|
6928
7026
|
for (const name of names.filter((entry) => entry.endsWith(".json"))) {
|
|
6929
|
-
const resource = await this.readOptionalJson((0,
|
|
7027
|
+
const resource = await this.readOptionalJson((0, import_node_path8.join)(this.detachedProcessesDirectory(), name));
|
|
6930
7028
|
if (resource.value) {
|
|
6931
7029
|
resources.push(resource.value);
|
|
6932
7030
|
}
|
|
@@ -6934,52 +7032,52 @@ var init_store = __esm({
|
|
|
6934
7032
|
return resources;
|
|
6935
7033
|
}
|
|
6936
7034
|
async deleteDetachedProcess(jobId) {
|
|
6937
|
-
await (0,
|
|
7035
|
+
await (0, import_promises11.rm)(this.detachedProcessPath(jobId), { force: true });
|
|
6938
7036
|
}
|
|
6939
7037
|
runtimeLogPath() {
|
|
6940
|
-
return (0,
|
|
7038
|
+
return (0, import_node_path8.join)(this.baseDirectory, "machine-connector.log");
|
|
6941
7039
|
}
|
|
6942
7040
|
runtimeErrorLogPath() {
|
|
6943
|
-
return (0,
|
|
7041
|
+
return (0, import_node_path8.join)(this.baseDirectory, "machine-connector.error.log");
|
|
6944
7042
|
}
|
|
6945
7043
|
runtimeStatusPath() {
|
|
6946
|
-
return (0,
|
|
7044
|
+
return (0, import_node_path8.join)(this.baseDirectory, "runtime-status.json");
|
|
6947
7045
|
}
|
|
6948
7046
|
runtimeSocketPath() {
|
|
6949
7047
|
if ((0, import_node_os4.platform)() === "win32") {
|
|
6950
7048
|
return String.raw`\\.\pipe\moxt-machine-connector`;
|
|
6951
7049
|
}
|
|
6952
|
-
return (0,
|
|
7050
|
+
return (0, import_node_path8.join)(this.baseDirectory, "machine-connector.sock");
|
|
6953
7051
|
}
|
|
6954
7052
|
daemonLockPath() {
|
|
6955
|
-
return (0,
|
|
7053
|
+
return (0, import_node_path8.join)(this.baseDirectory, "daemon.lock");
|
|
6956
7054
|
}
|
|
6957
7055
|
reconcileLockPath() {
|
|
6958
|
-
return (0,
|
|
7056
|
+
return (0, import_node_path8.join)(this.baseDirectory, "daemon-reconcile.lock");
|
|
6959
7057
|
}
|
|
6960
7058
|
connectionsPath() {
|
|
6961
|
-
return (0,
|
|
7059
|
+
return (0, import_node_path8.join)(this.baseDirectory, "connections.json");
|
|
6962
7060
|
}
|
|
6963
7061
|
detachedProcessesDirectory() {
|
|
6964
|
-
return (0,
|
|
7062
|
+
return (0, import_node_path8.join)(this.baseDirectory, "detached-processes");
|
|
6965
7063
|
}
|
|
6966
7064
|
detachedProcessPath(jobId) {
|
|
6967
|
-
return (0,
|
|
7065
|
+
return (0, import_node_path8.join)(this.detachedProcessesDirectory(), `${jobId}.json`);
|
|
6968
7066
|
}
|
|
6969
7067
|
identityPath() {
|
|
6970
|
-
return (0,
|
|
7068
|
+
return (0, import_node_path8.join)(this.baseDirectory, "identity.json");
|
|
6971
7069
|
}
|
|
6972
7070
|
serviceManagerPath() {
|
|
6973
|
-
return (0,
|
|
7071
|
+
return (0, import_node_path8.join)(this.baseDirectory, "service-manager.json");
|
|
6974
7072
|
}
|
|
6975
7073
|
privateKeyPath() {
|
|
6976
|
-
return (0,
|
|
7074
|
+
return (0, import_node_path8.join)(this.baseDirectory, "device-private-key.pem");
|
|
6977
7075
|
}
|
|
6978
7076
|
jobsDirectory() {
|
|
6979
|
-
return (0,
|
|
7077
|
+
return (0, import_node_path8.join)(this.baseDirectory, "jobs");
|
|
6980
7078
|
}
|
|
6981
7079
|
jobPath(jobId) {
|
|
6982
|
-
return (0,
|
|
7080
|
+
return (0, import_node_path8.join)(this.jobsDirectory(), `${jobId}.json`);
|
|
6983
7081
|
}
|
|
6984
7082
|
async readOptionalJson(path4) {
|
|
6985
7083
|
const content3 = await this.readOptionalText(path4);
|
|
@@ -6990,7 +7088,7 @@ var init_store = __esm({
|
|
|
6990
7088
|
}
|
|
6991
7089
|
async readOptionalText(path4) {
|
|
6992
7090
|
try {
|
|
6993
|
-
return { value: await (0,
|
|
7091
|
+
return { value: await (0, import_promises11.readFile)(path4, "utf8") };
|
|
6994
7092
|
} catch (error) {
|
|
6995
7093
|
if (isNodeErrorCode3(error, "ENOENT")) {
|
|
6996
7094
|
return {};
|
|
@@ -7003,17 +7101,17 @@ var init_store = __esm({
|
|
|
7003
7101
|
`);
|
|
7004
7102
|
}
|
|
7005
7103
|
async writePrivateText(path4, value) {
|
|
7006
|
-
await (0,
|
|
7104
|
+
await (0, import_promises11.mkdir)((0, import_node_path8.dirname)(path4), {
|
|
7007
7105
|
mode: privateDirectoryMode,
|
|
7008
7106
|
recursive: true
|
|
7009
7107
|
});
|
|
7010
7108
|
const temporaryPath = `${path4}.${process.pid}.tmp`;
|
|
7011
|
-
await (0,
|
|
7109
|
+
await (0, import_promises11.writeFile)(temporaryPath, value, {
|
|
7012
7110
|
encoding: "utf8",
|
|
7013
7111
|
mode: privateFileMode
|
|
7014
7112
|
});
|
|
7015
|
-
await (0,
|
|
7016
|
-
await (0,
|
|
7113
|
+
await (0, import_promises11.chmod)(temporaryPath, privateFileMode);
|
|
7114
|
+
await (0, import_promises11.rename)(temporaryPath, path4);
|
|
7017
7115
|
}
|
|
7018
7116
|
};
|
|
7019
7117
|
}
|
|
@@ -7057,6 +7155,7 @@ var init_daemon = __esm({
|
|
|
7057
7155
|
init_codex_executor();
|
|
7058
7156
|
init_durable_job();
|
|
7059
7157
|
init_execution_cancellation();
|
|
7158
|
+
init_execution_context();
|
|
7060
7159
|
init_image_viewer();
|
|
7061
7160
|
init_local_ipc();
|
|
7062
7161
|
init_process_lock();
|
|
@@ -7448,7 +7547,10 @@ var init_daemon = __esm({
|
|
|
7448
7547
|
const canSpawn = activeJob.cancellation.canSpawn.bind(activeJob.cancellation);
|
|
7449
7548
|
const resolveEnvironment = async (workingDirectory2, explicitEnvironment) => {
|
|
7450
7549
|
try {
|
|
7451
|
-
return await this.shellEnvironmentManager.resolveForJob(activeJob.connection.rootPath, workingDirectory2, explicitEnvironment,
|
|
7550
|
+
return await this.shellEnvironmentManager.resolveForJob(activeJob.connection.rootPath, workingDirectory2, explicitEnvironment, {
|
|
7551
|
+
cancellationSignal: activeJob.cancellation.signal(),
|
|
7552
|
+
executionContext: createLocalMachineJobExecutionContext(this.connectorInstanceId, this.store.baseDirectory)
|
|
7553
|
+
});
|
|
7452
7554
|
} catch (error) {
|
|
7453
7555
|
if (error instanceof JobEnvironmentCancelledError) {
|
|
7454
7556
|
return void 0;
|
|
@@ -7988,6 +8090,7 @@ async function validateServiceManagerPreference(preference, runtime = defaultSer
|
|
|
7988
8090
|
return selectUserServiceManager(preference, capabilities);
|
|
7989
8091
|
}
|
|
7990
8092
|
async function installUserService(store, request2, runtime = defaultServiceManagerRuntime) {
|
|
8093
|
+
await assertManagedServiceProvenance(store, request2.options.entrypointPath);
|
|
7991
8094
|
if (request2.preference === ServiceManagerPreference.None) {
|
|
7992
8095
|
const configuredManager = await readStoredServiceManager(store);
|
|
7993
8096
|
if (configuredManager !== UserServiceManager.None) {
|
|
@@ -8049,12 +8152,12 @@ async function installUserService(store, request2, runtime = defaultServiceManag
|
|
|
8049
8152
|
}
|
|
8050
8153
|
function createServiceEnvironment(options) {
|
|
8051
8154
|
const inheritedPath = options.environment.PATH ?? process.env.PATH ?? "";
|
|
8052
|
-
const nodeDirectory = (0,
|
|
8053
|
-
const pathEntries = [nodeDirectory, ...inheritedPath.split(
|
|
8155
|
+
const nodeDirectory = (0, import_node_path9.dirname)(options.nodePath);
|
|
8156
|
+
const pathEntries = [nodeDirectory, ...inheritedPath.split(import_node_path9.delimiter)].filter((entry, index2, entries) => entry.length > 0 && entries.indexOf(entry) === index2);
|
|
8054
8157
|
return {
|
|
8055
8158
|
...options.environment,
|
|
8056
8159
|
HOME: options.environment.HOME ?? process.env.HOME ?? (0, import_node_os6.homedir)(),
|
|
8057
|
-
PATH: pathEntries.join(
|
|
8160
|
+
PATH: pathEntries.join(import_node_path9.delimiter)
|
|
8058
8161
|
};
|
|
8059
8162
|
}
|
|
8060
8163
|
async function restartUserService(store, runtime = defaultServiceManagerRuntime) {
|
|
@@ -8066,6 +8169,7 @@ async function refreshManagedUserService(store, options, runtime = defaultServic
|
|
|
8066
8169
|
const manager = await readStoredServiceManager(store);
|
|
8067
8170
|
if (manager === UserServiceManager.None)
|
|
8068
8171
|
return void 0;
|
|
8172
|
+
await assertManagedServiceProvenance(store, options.entrypointPath);
|
|
8069
8173
|
const snapshot = await readManagedServiceDefinition(manager, store);
|
|
8070
8174
|
if (snapshot === void 0) {
|
|
8071
8175
|
throw new Error(`The recorded ${manager} service definition does not exist`);
|
|
@@ -8085,7 +8189,7 @@ async function refreshManagedUserService(store, options, runtime = defaultServic
|
|
|
8085
8189
|
if (manager === UserServiceManager.Systemd) {
|
|
8086
8190
|
await restartManager(manager, store, runtime);
|
|
8087
8191
|
}
|
|
8088
|
-
await persistServiceManager(store, manager);
|
|
8192
|
+
await persistServiceManager(store, manager, options.entrypointPath);
|
|
8089
8193
|
} catch (error) {
|
|
8090
8194
|
try {
|
|
8091
8195
|
await rollback();
|
|
@@ -8164,7 +8268,7 @@ async function replaceConfiguredManager(store, manager, options, runtime) {
|
|
|
8164
8268
|
await uninstallManagerIgnoringFailure(configuredManager, store, runtime);
|
|
8165
8269
|
}
|
|
8166
8270
|
await installManager(manager, store, options, runtime);
|
|
8167
|
-
await persistServiceManager(store, manager);
|
|
8271
|
+
await persistServiceManager(store, manager, options.entrypointPath);
|
|
8168
8272
|
}
|
|
8169
8273
|
async function installManager(manager, store, options, runtime) {
|
|
8170
8274
|
if (manager === UserServiceManager.Launchd) {
|
|
@@ -8237,7 +8341,7 @@ async function uninstallManager(manager, store, runtime) {
|
|
|
8237
8341
|
"bootout",
|
|
8238
8342
|
`gui/${process.getuid?.() ?? 0}/${launchAgentLabel}`
|
|
8239
8343
|
]);
|
|
8240
|
-
await (0,
|
|
8344
|
+
await (0, import_promises12.rm)(launchAgentPath(), { force: true });
|
|
8241
8345
|
return;
|
|
8242
8346
|
}
|
|
8243
8347
|
if (manager === UserServiceManager.Systemd) {
|
|
@@ -8247,7 +8351,7 @@ async function uninstallManager(manager, store, runtime) {
|
|
|
8247
8351
|
"--now",
|
|
8248
8352
|
"moxt-machine-connector.service"
|
|
8249
8353
|
]);
|
|
8250
|
-
await (0,
|
|
8354
|
+
await (0, import_promises12.rm)(systemdUnitPath(), { force: true });
|
|
8251
8355
|
await runCommandIgnoringFailure(runtime, "systemctl", [
|
|
8252
8356
|
"--user",
|
|
8253
8357
|
"daemon-reload"
|
|
@@ -8261,7 +8365,7 @@ async function uninstallManager(manager, store, runtime) {
|
|
|
8261
8365
|
supervisorProgramName
|
|
8262
8366
|
]);
|
|
8263
8367
|
await runCommandIgnoringFailure(runtime, "supervisorctl", ["-c", supervisorConfigPath(store), "shutdown"]);
|
|
8264
|
-
await (0,
|
|
8368
|
+
await (0, import_promises12.rm)(supervisorDirectory(store), {
|
|
8265
8369
|
force: true,
|
|
8266
8370
|
recursive: true
|
|
8267
8371
|
});
|
|
@@ -8287,7 +8391,7 @@ async function readStoredServiceManager(store) {
|
|
|
8287
8391
|
}
|
|
8288
8392
|
async function readManagedServiceDefinition(manager, store) {
|
|
8289
8393
|
try {
|
|
8290
|
-
return await (0,
|
|
8394
|
+
return await (0, import_promises12.readFile)(managedServiceDefinitionPath(manager, store), "utf8");
|
|
8291
8395
|
} catch (error) {
|
|
8292
8396
|
if (isNodeErrorCode4(error, "ENOENT"))
|
|
8293
8397
|
return void 0;
|
|
@@ -8296,8 +8400,8 @@ async function readManagedServiceDefinition(manager, store) {
|
|
|
8296
8400
|
}
|
|
8297
8401
|
async function restoreManagedServiceDefinition(manager, store, definition2, runtime) {
|
|
8298
8402
|
const path4 = managedServiceDefinitionPath(manager, store);
|
|
8299
|
-
await (0,
|
|
8300
|
-
await (0,
|
|
8403
|
+
await (0, import_promises12.mkdir)((0, import_node_path9.dirname)(path4), { recursive: true });
|
|
8404
|
+
await (0, import_promises12.writeFile)(path4, definition2, { encoding: "utf8", mode: 384 });
|
|
8301
8405
|
if (manager === UserServiceManager.Launchd) {
|
|
8302
8406
|
const domain = `gui/${process.getuid?.() ?? 0}`;
|
|
8303
8407
|
await runCommandIgnoringFailure(runtime, "launchctl", [
|
|
@@ -8343,12 +8447,44 @@ function parseProcessId(value) {
|
|
|
8343
8447
|
const processId = Number.parseInt(value.trim(), 10);
|
|
8344
8448
|
return Number.isSafeInteger(processId) && processId > 0 ? processId : void 0;
|
|
8345
8449
|
}
|
|
8346
|
-
async function persistServiceManager(store, manager) {
|
|
8450
|
+
async function persistServiceManager(store, manager, managedEntrypointPath) {
|
|
8347
8451
|
await store.writeServiceManager({
|
|
8452
|
+
...managedEntrypointPath ? { managedEntrypointPath: (0, import_node_path9.resolve)(managedEntrypointPath) } : {},
|
|
8348
8453
|
manager,
|
|
8349
8454
|
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
8350
8455
|
});
|
|
8351
8456
|
}
|
|
8457
|
+
async function assertManagedServiceProvenance(store, candidateEntrypointPath) {
|
|
8458
|
+
const stored = (await store.readServiceManager()).value;
|
|
8459
|
+
if (!stored || stored.manager === UserServiceManager.None)
|
|
8460
|
+
return;
|
|
8461
|
+
const candidate = (0, import_node_path9.resolve)(candidateEntrypointPath);
|
|
8462
|
+
if (stored.managedEntrypointPath) {
|
|
8463
|
+
if ((0, import_node_path9.resolve)(stored.managedEntrypointPath) !== candidate) {
|
|
8464
|
+
throw new Error("The managed Connector belongs to a different CLI installation. Run service install from the owning CLI to transfer management.");
|
|
8465
|
+
}
|
|
8466
|
+
return;
|
|
8467
|
+
}
|
|
8468
|
+
if (await isInsideSourceCheckout(candidate)) {
|
|
8469
|
+
throw new Error("A source-checkout CLI cannot replace a legacy managed Connector without recorded installation provenance. Use a separate MOXT_MACHINE_HOME for development.");
|
|
8470
|
+
}
|
|
8471
|
+
}
|
|
8472
|
+
async function isInsideSourceCheckout(path4) {
|
|
8473
|
+
let directory = (0, import_node_path9.dirname)(path4);
|
|
8474
|
+
while (true) {
|
|
8475
|
+
try {
|
|
8476
|
+
await (0, import_promises12.stat)((0, import_node_path9.join)(directory, ".git"));
|
|
8477
|
+
return true;
|
|
8478
|
+
} catch (error) {
|
|
8479
|
+
if (!isNodeErrorCode4(error, "ENOENT"))
|
|
8480
|
+
throw error;
|
|
8481
|
+
}
|
|
8482
|
+
const parent = (0, import_node_path9.dirname)(directory);
|
|
8483
|
+
if (parent === directory)
|
|
8484
|
+
return false;
|
|
8485
|
+
directory = parent;
|
|
8486
|
+
}
|
|
8487
|
+
}
|
|
8352
8488
|
function managerIsAvailable(manager, capabilities) {
|
|
8353
8489
|
if (manager === UserServiceManager.Launchd) {
|
|
8354
8490
|
return capabilities.operatingSystem === "darwin";
|
|
@@ -8372,10 +8508,10 @@ function automaticSelectionDetail(manager) {
|
|
|
8372
8508
|
}
|
|
8373
8509
|
async function installLaunchAgent(store, options, runtime) {
|
|
8374
8510
|
const path4 = launchAgentPath();
|
|
8375
|
-
await (0,
|
|
8511
|
+
await (0, import_promises12.mkdir)((0, import_node_path9.dirname)(path4), { recursive: true });
|
|
8376
8512
|
const programArguments = [
|
|
8377
8513
|
options.nodePath,
|
|
8378
|
-
(0,
|
|
8514
|
+
(0, import_node_path9.resolve)(options.entrypointPath),
|
|
8379
8515
|
...options.commandArguments
|
|
8380
8516
|
];
|
|
8381
8517
|
const plist = `<?xml version="1.0" encoding="UTF-8"?>
|
|
@@ -8406,7 +8542,7 @@ ${Object.entries(options.environment).map(([name, value]) => ` <key>${escapeX
|
|
|
8406
8542
|
</dict>
|
|
8407
8543
|
</plist>
|
|
8408
8544
|
`;
|
|
8409
|
-
await (0,
|
|
8545
|
+
await (0, import_promises12.writeFile)(path4, plist, { encoding: "utf8", mode: 384 });
|
|
8410
8546
|
const domain = `gui/${process.getuid?.() ?? 0}`;
|
|
8411
8547
|
await runCommandIgnoringFailure(runtime, "launchctl", [
|
|
8412
8548
|
"bootout",
|
|
@@ -8422,10 +8558,10 @@ ${Object.entries(options.environment).map(([name, value]) => ` <key>${escapeX
|
|
|
8422
8558
|
}
|
|
8423
8559
|
async function installSystemdUserService(store, options, runtime) {
|
|
8424
8560
|
const path4 = systemdUnitPath();
|
|
8425
|
-
await (0,
|
|
8561
|
+
await (0, import_promises12.mkdir)((0, import_node_path9.dirname)(path4), { recursive: true });
|
|
8426
8562
|
const command = [
|
|
8427
8563
|
options.nodePath,
|
|
8428
|
-
(0,
|
|
8564
|
+
(0, import_node_path9.resolve)(options.entrypointPath),
|
|
8429
8565
|
...options.commandArguments
|
|
8430
8566
|
].map(escapeSystemdArgument).join(" ");
|
|
8431
8567
|
const unit = `[Unit]
|
|
@@ -8444,7 +8580,7 @@ ${Object.entries(options.environment).map(([name, value]) => `Environment=${esca
|
|
|
8444
8580
|
[Install]
|
|
8445
8581
|
WantedBy=default.target
|
|
8446
8582
|
`;
|
|
8447
|
-
await (0,
|
|
8583
|
+
await (0, import_promises12.writeFile)(path4, unit, { encoding: "utf8", mode: 384 });
|
|
8448
8584
|
await runtime.run("systemctl", ["--user", "daemon-reload"]);
|
|
8449
8585
|
await runtime.run("systemctl", [
|
|
8450
8586
|
"--user",
|
|
@@ -8460,17 +8596,14 @@ WantedBy=default.target
|
|
|
8460
8596
|
async function installSupervisorUserService(store, options, runtime) {
|
|
8461
8597
|
const directory = supervisorDirectory(store);
|
|
8462
8598
|
const configPath = supervisorConfigPath(store);
|
|
8463
|
-
await (0,
|
|
8464
|
-
await (0,
|
|
8599
|
+
await (0, import_promises12.mkdir)(directory, { recursive: true, mode: 448 });
|
|
8600
|
+
await (0, import_promises12.writeFile)(configPath, createSupervisorConfiguration(store, options), {
|
|
8465
8601
|
encoding: "utf8",
|
|
8466
8602
|
mode: 384
|
|
8467
8603
|
});
|
|
8468
8604
|
const supervisorWasRunning = await supervisorIsRunning(store, runtime);
|
|
8469
8605
|
if (!supervisorWasRunning) {
|
|
8470
|
-
await (
|
|
8471
|
-
await (0, import_promises11.rm)(supervisorPidPath(store), { force: true });
|
|
8472
|
-
await runtime.run("supervisord", ["-c", configPath]);
|
|
8473
|
-
await waitForSupervisorControl(store, runtime);
|
|
8606
|
+
await startSupervisorUserService(store, runtime);
|
|
8474
8607
|
return;
|
|
8475
8608
|
}
|
|
8476
8609
|
await reloadSupervisorConfiguration(store, runtime);
|
|
@@ -8478,7 +8611,7 @@ async function installSupervisorUserService(store, options, runtime) {
|
|
|
8478
8611
|
function createSupervisorConfiguration(store, options) {
|
|
8479
8612
|
const command = [
|
|
8480
8613
|
options.nodePath,
|
|
8481
|
-
(0,
|
|
8614
|
+
(0, import_node_path9.resolve)(options.entrypointPath),
|
|
8482
8615
|
...options.commandArguments
|
|
8483
8616
|
].map(escapeSupervisorArgument).join(" ");
|
|
8484
8617
|
const environment = Object.entries(options.environment).map(([name, value]) => `${name}="${escapeSupervisorEnvironment(value)}"`).join(",");
|
|
@@ -8502,16 +8635,16 @@ serverurl=unix://${supervisorSocketPath(store)}
|
|
|
8502
8635
|
|
|
8503
8636
|
[program:${supervisorProgramName}]
|
|
8504
8637
|
command=${command}
|
|
8505
|
-
directory=${escapeSupervisorPath((0,
|
|
8638
|
+
directory=${escapeSupervisorPath((0, import_node_path9.dirname)((0, import_node_path9.resolve)(options.entrypointPath)))}
|
|
8506
8639
|
environment=${environment}
|
|
8507
8640
|
autostart=true
|
|
8508
8641
|
autorestart=true
|
|
8509
|
-
startsecs
|
|
8510
|
-
startretries
|
|
8642
|
+
startsecs=${supervisorProgramStartSeconds}
|
|
8643
|
+
startretries=${supervisorProgramStartRetries}
|
|
8511
8644
|
stopsignal=TERM
|
|
8512
8645
|
stopasgroup=true
|
|
8513
8646
|
killasgroup=true
|
|
8514
|
-
stopwaitsecs
|
|
8647
|
+
stopwaitsecs=${supervisorProgramStopWaitSeconds}
|
|
8515
8648
|
stdout_logfile=${escapeSupervisorPath(store.runtimeLogPath())}
|
|
8516
8649
|
stderr_logfile=${escapeSupervisorPath(store.runtimeErrorLogPath())}
|
|
8517
8650
|
stdout_logfile_maxbytes=20MB
|
|
@@ -8522,28 +8655,27 @@ stderr_logfile_backups=3
|
|
|
8522
8655
|
}
|
|
8523
8656
|
async function restartSupervisorUserService(store, runtime) {
|
|
8524
8657
|
const configPath = supervisorConfigPath(store);
|
|
8525
|
-
|
|
8526
|
-
|
|
8527
|
-
|
|
8528
|
-
await runtime.run("supervisord", ["-c", configPath]);
|
|
8529
|
-
await waitForSupervisorControl(store, runtime);
|
|
8530
|
-
return;
|
|
8531
|
-
}
|
|
8532
|
-
try {
|
|
8533
|
-
await runtime.run("supervisorctl", [
|
|
8534
|
-
"-c",
|
|
8535
|
-
configPath,
|
|
8536
|
-
"restart",
|
|
8537
|
-
supervisorProgramName
|
|
8538
|
-
]);
|
|
8539
|
-
} catch {
|
|
8658
|
+
const supervisorProcessId = await currentSupervisorProcessId(store, runtime);
|
|
8659
|
+
const connectorProcessId = await currentSupervisorProgramProcessId(store, runtime);
|
|
8660
|
+
if (supervisorProcessId !== void 0) {
|
|
8540
8661
|
await runtime.run("supervisorctl", [
|
|
8541
8662
|
"-c",
|
|
8542
8663
|
configPath,
|
|
8543
|
-
"
|
|
8544
|
-
supervisorProgramName
|
|
8664
|
+
"shutdown"
|
|
8545
8665
|
]);
|
|
8666
|
+
await waitForSupervisorExit(store, runtime, supervisorProcessId);
|
|
8546
8667
|
}
|
|
8668
|
+
await startSupervisorUserService(store, runtime, supervisorProcessId, connectorProcessId);
|
|
8669
|
+
}
|
|
8670
|
+
async function startSupervisorUserService(store, runtime, previousSupervisorProcessId, previousConnectorProcessId) {
|
|
8671
|
+
await (0, import_promises12.rm)(supervisorSocketPath(store), { force: true });
|
|
8672
|
+
await (0, import_promises12.rm)(supervisorPidPath(store), { force: true });
|
|
8673
|
+
await runtime.run("supervisord", ["-c", supervisorConfigPath(store)], {
|
|
8674
|
+
environment: sanitizeEnvironment(process.env),
|
|
8675
|
+
timeoutMilliseconds: serviceManagerMutationTimeoutMilliseconds
|
|
8676
|
+
});
|
|
8677
|
+
await waitForSupervisorControl(store, runtime, previousSupervisorProcessId);
|
|
8678
|
+
await waitForSupervisorProgram(store, runtime, previousConnectorProcessId);
|
|
8547
8679
|
}
|
|
8548
8680
|
async function reloadSupervisorConfiguration(store, runtime) {
|
|
8549
8681
|
const configPath = supervisorConfigPath(store);
|
|
@@ -8583,43 +8715,109 @@ async function reloadSupervisorConfiguration(store, runtime) {
|
|
|
8583
8715
|
]);
|
|
8584
8716
|
}
|
|
8585
8717
|
async function supervisorIsRunning(store, runtime) {
|
|
8586
|
-
return await
|
|
8587
|
-
"-c",
|
|
8588
|
-
supervisorConfigPath(store),
|
|
8589
|
-
"pid"
|
|
8590
|
-
]);
|
|
8718
|
+
return await currentSupervisorProcessId(store, runtime) !== void 0;
|
|
8591
8719
|
}
|
|
8592
|
-
async function waitForSupervisorControl(store, runtime) {
|
|
8593
|
-
const deadline =
|
|
8594
|
-
while (
|
|
8595
|
-
|
|
8720
|
+
async function waitForSupervisorControl(store, runtime, previousProcessId) {
|
|
8721
|
+
const deadline = serviceManagerCurrentTime(runtime) + supervisorControlTimeoutMilliseconds;
|
|
8722
|
+
while (serviceManagerCurrentTime(runtime) < deadline) {
|
|
8723
|
+
const processId = await currentSupervisorProcessId(store, runtime);
|
|
8724
|
+
if (processId !== void 0 && processId !== previousProcessId) {
|
|
8725
|
+
return;
|
|
8726
|
+
}
|
|
8727
|
+
await serviceManagerDelay(runtime, 100);
|
|
8728
|
+
}
|
|
8729
|
+
throw new Error(`Supervisor did not become ready within ${supervisorControlTimeoutMilliseconds / 1e3} seconds`);
|
|
8730
|
+
}
|
|
8731
|
+
async function waitForSupervisorExit(store, runtime, processId) {
|
|
8732
|
+
const deadline = serviceManagerCurrentTime(runtime) + supervisorExitTimeoutMilliseconds;
|
|
8733
|
+
while (serviceManagerCurrentTime(runtime) < deadline) {
|
|
8734
|
+
if (!await supervisorIsRunning(store, runtime) && !serviceProcessIsRunning(runtime, processId)) {
|
|
8596
8735
|
return;
|
|
8597
8736
|
}
|
|
8598
|
-
await
|
|
8737
|
+
await serviceManagerDelay(runtime, 100);
|
|
8738
|
+
}
|
|
8739
|
+
throw new Error(`Supervisor did not exit within ${supervisorExitTimeoutMilliseconds / 1e3} seconds`);
|
|
8740
|
+
}
|
|
8741
|
+
function serviceProcessIsRunning(runtime, processId) {
|
|
8742
|
+
if (runtime.processIsRunning)
|
|
8743
|
+
return runtime.processIsRunning(processId);
|
|
8744
|
+
return localProcessIsRunning(processId);
|
|
8745
|
+
}
|
|
8746
|
+
function localProcessIsRunning(processId) {
|
|
8747
|
+
try {
|
|
8748
|
+
process.kill(processId, 0);
|
|
8749
|
+
return true;
|
|
8750
|
+
} catch (error) {
|
|
8751
|
+
if (isNodeErrorCode4(error, "ESRCH"))
|
|
8752
|
+
return false;
|
|
8753
|
+
throw error;
|
|
8754
|
+
}
|
|
8755
|
+
}
|
|
8756
|
+
async function waitForSupervisorProgram(store, runtime, previousProcessId) {
|
|
8757
|
+
const deadline = serviceManagerCurrentTime(runtime) + supervisorProgramStartTimeoutMilliseconds;
|
|
8758
|
+
while (serviceManagerCurrentTime(runtime) < deadline) {
|
|
8759
|
+
const processId = await currentSupervisorProgramProcessId(store, runtime);
|
|
8760
|
+
if (processId !== void 0 && processId !== previousProcessId)
|
|
8761
|
+
return;
|
|
8762
|
+
await serviceManagerDelay(runtime, 100);
|
|
8763
|
+
}
|
|
8764
|
+
throw new Error(`Moxt Machine Connector did not become ready under Supervisor within ${supervisorProgramStartTimeoutMilliseconds / 1e3} seconds`);
|
|
8765
|
+
}
|
|
8766
|
+
async function currentSupervisorProcessId(store, runtime) {
|
|
8767
|
+
try {
|
|
8768
|
+
const result = await runServiceProbe(runtime, "supervisorctl", [
|
|
8769
|
+
"-c",
|
|
8770
|
+
supervisorConfigPath(store),
|
|
8771
|
+
"pid"
|
|
8772
|
+
]);
|
|
8773
|
+
const processId = parseProcessId(result.stdout);
|
|
8774
|
+
if (processId !== void 0)
|
|
8775
|
+
return processId;
|
|
8776
|
+
} catch {
|
|
8777
|
+
}
|
|
8778
|
+
try {
|
|
8779
|
+
const processId = parseProcessId(await (0, import_promises12.readFile)(supervisorPidPath(store), "utf8"));
|
|
8780
|
+
return processId !== void 0 && serviceProcessIsRunning(runtime, processId) ? processId : void 0;
|
|
8781
|
+
} catch (error) {
|
|
8782
|
+
if (isNodeErrorCode4(error, "ENOENT"))
|
|
8783
|
+
return void 0;
|
|
8784
|
+
throw error;
|
|
8785
|
+
}
|
|
8786
|
+
}
|
|
8787
|
+
async function currentSupervisorProgramProcessId(store, runtime) {
|
|
8788
|
+
try {
|
|
8789
|
+
const result = await runServiceProbe(runtime, "supervisorctl", [
|
|
8790
|
+
"-c",
|
|
8791
|
+
supervisorConfigPath(store),
|
|
8792
|
+
"pid",
|
|
8793
|
+
supervisorProgramName
|
|
8794
|
+
]);
|
|
8795
|
+
return parseProcessId(result.stdout);
|
|
8796
|
+
} catch {
|
|
8797
|
+
return void 0;
|
|
8599
8798
|
}
|
|
8600
|
-
throw new Error("Supervisor did not become ready within 5 seconds");
|
|
8601
8799
|
}
|
|
8602
8800
|
function launchAgentPath() {
|
|
8603
|
-
return (0,
|
|
8801
|
+
return (0, import_node_path9.join)(process.env.HOME ?? (0, import_node_os6.homedir)(), "Library", "LaunchAgents", `${launchAgentLabel}.plist`);
|
|
8604
8802
|
}
|
|
8605
8803
|
function systemdUnitPath() {
|
|
8606
|
-
const configHome = process.env.XDG_CONFIG_HOME ?? (0,
|
|
8607
|
-
return (0,
|
|
8804
|
+
const configHome = process.env.XDG_CONFIG_HOME ?? (0, import_node_path9.join)(process.env.HOME ?? (0, import_node_os6.homedir)(), ".config");
|
|
8805
|
+
return (0, import_node_path9.join)(configHome, "systemd", "user", "moxt-machine-connector.service");
|
|
8608
8806
|
}
|
|
8609
8807
|
function supervisorDirectory(store) {
|
|
8610
|
-
return (0,
|
|
8808
|
+
return (0, import_node_path9.join)(store.baseDirectory, "supervisor");
|
|
8611
8809
|
}
|
|
8612
8810
|
function supervisorConfigPath(store) {
|
|
8613
|
-
return (0,
|
|
8811
|
+
return (0, import_node_path9.join)(supervisorDirectory(store), "supervisord.conf");
|
|
8614
8812
|
}
|
|
8615
8813
|
function supervisorSocketPath(store) {
|
|
8616
|
-
return (0,
|
|
8814
|
+
return (0, import_node_path9.join)(supervisorDirectory(store), "supervisor.sock");
|
|
8617
8815
|
}
|
|
8618
8816
|
function supervisorPidPath(store) {
|
|
8619
|
-
return (0,
|
|
8817
|
+
return (0, import_node_path9.join)(supervisorDirectory(store), "supervisord.pid");
|
|
8620
8818
|
}
|
|
8621
8819
|
function supervisorLogPath(store) {
|
|
8622
|
-
return (0,
|
|
8820
|
+
return (0, import_node_path9.join)(supervisorDirectory(store), "supervisord.log");
|
|
8623
8821
|
}
|
|
8624
8822
|
async function commandSucceeds(runtime, command, argumentsList) {
|
|
8625
8823
|
try {
|
|
@@ -8680,21 +8878,35 @@ function delay5(milliseconds) {
|
|
|
8680
8878
|
setTimeout(resolvePromise, milliseconds);
|
|
8681
8879
|
});
|
|
8682
8880
|
}
|
|
8683
|
-
|
|
8881
|
+
function serviceManagerCurrentTime(runtime) {
|
|
8882
|
+
return runtime.currentTimeMilliseconds?.() ?? Date.now();
|
|
8883
|
+
}
|
|
8884
|
+
async function serviceManagerDelay(runtime, milliseconds) {
|
|
8885
|
+
await (runtime.delay?.(milliseconds) ?? delay5(milliseconds));
|
|
8886
|
+
}
|
|
8887
|
+
var import_node_child_process3, import_promises12, import_node_os6, import_node_path9, import_node_util2, execFileAsync, launchAgentLabel, serviceManagerProbeTimeoutMilliseconds, serviceManagerMutationTimeoutMilliseconds, supervisorProgramName, supervisorControlTimeoutMilliseconds, supervisorProgramStartSeconds, supervisorProgramStartRetries, supervisorProgramStopWaitSeconds, supervisorLifecycleBufferMilliseconds, supervisorExitTimeoutMilliseconds, supervisorProgramStartTimeoutMilliseconds, ServiceManagerPreference, UserServiceManager, defaultServiceManagerRuntime;
|
|
8684
8888
|
var init_service_manager = __esm({
|
|
8685
8889
|
"../machine-connector/dist/runtime/service-manager.js"() {
|
|
8686
8890
|
"use strict";
|
|
8687
8891
|
init_cjs_shims();
|
|
8688
8892
|
import_node_child_process3 = require("child_process");
|
|
8689
|
-
|
|
8893
|
+
import_promises12 = require("fs/promises");
|
|
8690
8894
|
import_node_os6 = require("os");
|
|
8691
|
-
|
|
8895
|
+
import_node_path9 = require("path");
|
|
8692
8896
|
import_node_util2 = require("util");
|
|
8897
|
+
init_shell_environment();
|
|
8693
8898
|
execFileAsync = (0, import_node_util2.promisify)(import_node_child_process3.execFile);
|
|
8694
8899
|
launchAgentLabel = "ai.moxt.machine-connector";
|
|
8695
8900
|
serviceManagerProbeTimeoutMilliseconds = 5e3;
|
|
8696
8901
|
serviceManagerMutationTimeoutMilliseconds = 3e4;
|
|
8697
8902
|
supervisorProgramName = "moxt-machine-connector";
|
|
8903
|
+
supervisorControlTimeoutMilliseconds = 5e3;
|
|
8904
|
+
supervisorProgramStartSeconds = 3;
|
|
8905
|
+
supervisorProgramStartRetries = 10;
|
|
8906
|
+
supervisorProgramStopWaitSeconds = 20;
|
|
8907
|
+
supervisorLifecycleBufferMilliseconds = 5e3;
|
|
8908
|
+
supervisorExitTimeoutMilliseconds = supervisorProgramStopWaitSeconds * 1e3 + supervisorLifecycleBufferMilliseconds;
|
|
8909
|
+
supervisorProgramStartTimeoutMilliseconds = supervisorProgramStartSeconds * supervisorProgramStartRetries * 1e3 + supervisorLifecycleBufferMilliseconds;
|
|
8698
8910
|
(function(ServiceManagerPreference2) {
|
|
8699
8911
|
ServiceManagerPreference2["Auto"] = "auto";
|
|
8700
8912
|
ServiceManagerPreference2["None"] = "none";
|
|
@@ -8709,9 +8921,13 @@ var init_service_manager = __esm({
|
|
|
8709
8921
|
})(UserServiceManager || (UserServiceManager = {}));
|
|
8710
8922
|
defaultServiceManagerRuntime = {
|
|
8711
8923
|
operatingSystem: (0, import_node_os6.platform)(),
|
|
8924
|
+
processIsRunning(processId) {
|
|
8925
|
+
return localProcessIsRunning(processId);
|
|
8926
|
+
},
|
|
8712
8927
|
async run(command, argumentsList, options) {
|
|
8713
8928
|
const result = await execFileAsync(command, argumentsList, {
|
|
8714
8929
|
encoding: "utf8",
|
|
8930
|
+
env: options?.environment,
|
|
8715
8931
|
killSignal: "SIGKILL",
|
|
8716
8932
|
timeout: options?.timeoutMilliseconds ?? serviceManagerMutationTimeoutMilliseconds
|
|
8717
8933
|
});
|
|
@@ -8766,9 +8982,9 @@ async function reconcileManagedDaemon(options, store = new MachineRuntimeStore()
|
|
|
8766
8982
|
try {
|
|
8767
8983
|
refresh = await refreshManagedUserService(store, {
|
|
8768
8984
|
commandArguments: [...options.commandArguments],
|
|
8769
|
-
entrypointPath: (0,
|
|
8985
|
+
entrypointPath: (0, import_node_path10.resolve)(options.entrypointPath),
|
|
8770
8986
|
environment: { ...options.environment },
|
|
8771
|
-
nodePath: (0,
|
|
8987
|
+
nodePath: (0, import_node_path10.resolve)(options.nodePath)
|
|
8772
8988
|
});
|
|
8773
8989
|
if (!refresh) {
|
|
8774
8990
|
throw new Error("The Connector service is no longer managed by Moxt");
|
|
@@ -8796,13 +9012,14 @@ async function reconcileManagedDaemon(options, store = new MachineRuntimeStore()
|
|
|
8796
9012
|
}
|
|
8797
9013
|
}
|
|
8798
9014
|
async function validateCliEntrypoint(options, store) {
|
|
9015
|
+
await assertManagedServiceProvenance(store, options.entrypointPath);
|
|
8799
9016
|
if (options.commandArguments.length !== 2 || options.commandArguments[0] !== "machine" || options.commandArguments[1] !== "daemon") {
|
|
8800
9017
|
throw new Error("The managed daemon command must be `machine daemon`");
|
|
8801
9018
|
}
|
|
8802
|
-
const nodePath = await (0,
|
|
8803
|
-
const entrypointPath = await (0,
|
|
8804
|
-
await (0,
|
|
8805
|
-
await (0,
|
|
9019
|
+
const nodePath = await (0, import_promises13.realpath)((0, import_node_path10.resolve)(options.nodePath));
|
|
9020
|
+
const entrypointPath = await (0, import_promises13.realpath)((0, import_node_path10.resolve)(options.entrypointPath));
|
|
9021
|
+
await (0, import_promises13.access)(nodePath, import_promises13.constants.X_OK);
|
|
9022
|
+
await (0, import_promises13.access)(entrypointPath, import_promises13.constants.R_OK);
|
|
8806
9023
|
const probe = await execFileAsync2(nodePath, [entrypointPath, "--version"], {
|
|
8807
9024
|
encoding: "utf8",
|
|
8808
9025
|
env: {
|
|
@@ -8835,14 +9052,14 @@ function delay6(milliseconds) {
|
|
|
8835
9052
|
function errorMessage3(error) {
|
|
8836
9053
|
return error instanceof Error ? error.message : String(error);
|
|
8837
9054
|
}
|
|
8838
|
-
var import_node_child_process4,
|
|
9055
|
+
var import_node_child_process4, import_promises13, import_node_path10, import_node_util3, reconcileTimeoutMilliseconds, execFileAsync2, DaemonReconcileOutcome, DaemonRefreshError;
|
|
8839
9056
|
var init_daemon_reconcile = __esm({
|
|
8840
9057
|
"../machine-connector/dist/runtime/daemon-reconcile.js"() {
|
|
8841
9058
|
"use strict";
|
|
8842
9059
|
init_cjs_shims();
|
|
8843
9060
|
import_node_child_process4 = require("child_process");
|
|
8844
|
-
|
|
8845
|
-
|
|
9061
|
+
import_promises13 = require("fs/promises");
|
|
9062
|
+
import_node_path10 = require("path");
|
|
8846
9063
|
import_node_util3 = require("util");
|
|
8847
9064
|
init_local_ipc();
|
|
8848
9065
|
init_process_lock();
|
|
@@ -8898,7 +9115,7 @@ async function runMachineDoctor(store) {
|
|
|
8898
9115
|
}
|
|
8899
9116
|
for (const connection of connections) {
|
|
8900
9117
|
try {
|
|
8901
|
-
await (0,
|
|
9118
|
+
await (0, import_promises14.access)(connection.rootPath, import_node_fs.constants.R_OK | import_node_fs.constants.X_OK);
|
|
8902
9119
|
checks.push({
|
|
8903
9120
|
detail: connection.rootPath,
|
|
8904
9121
|
name: `root:${connection.connectionId}`,
|
|
@@ -8913,7 +9130,7 @@ async function runMachineDoctor(store) {
|
|
|
8913
9130
|
}
|
|
8914
9131
|
const relayUrl = new URL(connection.relayOrigin);
|
|
8915
9132
|
try {
|
|
8916
|
-
const address = await (0,
|
|
9133
|
+
const address = await (0, import_promises15.lookup)(relayUrl.hostname);
|
|
8917
9134
|
checks.push({
|
|
8918
9135
|
detail: `${relayUrl.hostname} resolves to ${address.address}`,
|
|
8919
9136
|
name: `dns:${connection.connectionId}`,
|
|
@@ -8995,15 +9212,15 @@ async function runMachineDoctor(store) {
|
|
|
8995
9212
|
function errorMessage4(error) {
|
|
8996
9213
|
return error instanceof Error ? error.message : String(error);
|
|
8997
9214
|
}
|
|
8998
|
-
var import_node_child_process5,
|
|
9215
|
+
var import_node_child_process5, import_promises14, import_node_fs, import_promises15, import_node_util4, execFileAsync3, DoctorCheckStatus;
|
|
8999
9216
|
var init_doctor = __esm({
|
|
9000
9217
|
"../machine-connector/dist/runtime/doctor.js"() {
|
|
9001
9218
|
"use strict";
|
|
9002
9219
|
init_cjs_shims();
|
|
9003
9220
|
import_node_child_process5 = require("child_process");
|
|
9004
|
-
|
|
9221
|
+
import_promises14 = require("fs/promises");
|
|
9005
9222
|
import_node_fs = require("fs");
|
|
9006
|
-
|
|
9223
|
+
import_promises15 = require("dns/promises");
|
|
9007
9224
|
import_node_util4 = require("util");
|
|
9008
9225
|
init_local_ipc();
|
|
9009
9226
|
execFileAsync3 = (0, import_node_util4.promisify)(import_node_child_process5.execFile);
|
|
@@ -9272,7 +9489,7 @@ async function readRecentLogLines(store) {
|
|
|
9272
9489
|
}
|
|
9273
9490
|
async function readOptionalFile(path4) {
|
|
9274
9491
|
try {
|
|
9275
|
-
return await (0,
|
|
9492
|
+
return await (0, import_promises16.readFile)(path4, "utf8");
|
|
9276
9493
|
} catch (error) {
|
|
9277
9494
|
if (isMissingFile(error)) {
|
|
9278
9495
|
return "";
|
|
@@ -9331,13 +9548,13 @@ function isMissingFile(error) {
|
|
|
9331
9548
|
function errorMessage5(error) {
|
|
9332
9549
|
return error instanceof Error ? error.message : String(error);
|
|
9333
9550
|
}
|
|
9334
|
-
var
|
|
9551
|
+
var import_promises16, import_promises17, import_node_readline, alternateScreenEnter, alternateScreenExit, clearScreen, cursorHide, cursorShow, styleReset, styleHeader, styleSelected, refreshIntervalMilliseconds, maximumLogLines, MachineManagerView, MachineManagerAction, MachineManagerSnapshotDepth, InteractiveMachineManager;
|
|
9335
9552
|
var init_machine_manager = __esm({
|
|
9336
9553
|
"../machine-connector/dist/runtime/machine-manager.js"() {
|
|
9337
9554
|
"use strict";
|
|
9338
9555
|
init_cjs_shims();
|
|
9339
|
-
|
|
9340
|
-
|
|
9556
|
+
import_promises16 = require("fs/promises");
|
|
9557
|
+
import_promises17 = require("readline/promises");
|
|
9341
9558
|
import_node_readline = require("readline");
|
|
9342
9559
|
init_doctor();
|
|
9343
9560
|
init_local_ipc();
|
|
@@ -9571,7 +9788,7 @@ var init_machine_manager = __esm({
|
|
|
9571
9788
|
}
|
|
9572
9789
|
async runCommandAction(action) {
|
|
9573
9790
|
this.suspendTerminal();
|
|
9574
|
-
const reader = (0,
|
|
9791
|
+
const reader = (0, import_promises17.createInterface)({
|
|
9575
9792
|
input: process.stdin,
|
|
9576
9793
|
output: process.stdout
|
|
9577
9794
|
});
|
|
@@ -9761,7 +9978,7 @@ async function pairMachine(store, options) {
|
|
|
9761
9978
|
machineName,
|
|
9762
9979
|
operatingSystem,
|
|
9763
9980
|
protocolVersion: machineProtocolVersion,
|
|
9764
|
-
rootDisplayName: (0,
|
|
9981
|
+
rootDisplayName: (0, import_node_path11.basename)(canonicalRoot),
|
|
9765
9982
|
rootHandle
|
|
9766
9983
|
});
|
|
9767
9984
|
options.onConfirmation?.(proposal.confirmationUrl);
|
|
@@ -9789,7 +10006,7 @@ async function pairMachine(store, options) {
|
|
|
9789
10006
|
operatingSystem,
|
|
9790
10007
|
refreshToken: credentials.refreshToken,
|
|
9791
10008
|
relayOrigin: options.relayOrigin.replace(/\/+$/, ""),
|
|
9792
|
-
rootDisplayName: (0,
|
|
10009
|
+
rootDisplayName: (0, import_node_path11.basename)(canonicalRoot),
|
|
9793
10010
|
rootHandle,
|
|
9794
10011
|
rootPath: canonicalRoot,
|
|
9795
10012
|
targetId: credentials.targetId,
|
|
@@ -9828,7 +10045,7 @@ function delay7(milliseconds) {
|
|
|
9828
10045
|
setTimeout(resolvePromise, milliseconds);
|
|
9829
10046
|
});
|
|
9830
10047
|
}
|
|
9831
|
-
var import_node_child_process6, import_node_crypto7, import_node_os7,
|
|
10048
|
+
var import_node_child_process6, import_node_crypto7, import_node_os7, import_node_path11, connectedPairingStatus, rejectedPairingStatus, expiredPairingStatus, pairingPollMilliseconds;
|
|
9832
10049
|
var init_pairing = __esm({
|
|
9833
10050
|
"../machine-connector/dist/runtime/pairing.js"() {
|
|
9834
10051
|
"use strict";
|
|
@@ -9836,7 +10053,7 @@ var init_pairing = __esm({
|
|
|
9836
10053
|
import_node_child_process6 = require("child_process");
|
|
9837
10054
|
import_node_crypto7 = require("crypto");
|
|
9838
10055
|
import_node_os7 = require("os");
|
|
9839
|
-
|
|
10056
|
+
import_node_path11 = require("path");
|
|
9840
10057
|
init_contracts();
|
|
9841
10058
|
init_version();
|
|
9842
10059
|
init_enums();
|
|
@@ -9854,6 +10071,7 @@ async function runMachineCli(argumentsList, entrypoint) {
|
|
|
9854
10071
|
const command = argumentsList[0] ?? "help";
|
|
9855
10072
|
const commandArguments = argumentsList.slice(1);
|
|
9856
10073
|
const store = new MachineRuntimeStore();
|
|
10074
|
+
await rejectCarryingConnectorMutation(store, command, commandArguments);
|
|
9857
10075
|
await store.initialize();
|
|
9858
10076
|
if (command === "connect") {
|
|
9859
10077
|
await connectCommand(store, commandArguments, entrypoint);
|
|
@@ -9901,10 +10119,29 @@ async function runMachineCli(argumentsList, entrypoint) {
|
|
|
9901
10119
|
}
|
|
9902
10120
|
writeHelp();
|
|
9903
10121
|
}
|
|
10122
|
+
async function rejectCarryingConnectorMutation(store, command, commandArguments) {
|
|
10123
|
+
if (!isMachineLifecycleMutation(command, commandArguments))
|
|
10124
|
+
return;
|
|
10125
|
+
const relationship = await localMachineJobTargetRelationship(store);
|
|
10126
|
+
if (relationship === void 0 || relationship === "different_runtime") {
|
|
10127
|
+
return;
|
|
10128
|
+
}
|
|
10129
|
+
throw new Error("A Local Machine Job cannot mutate the Connector carrying it. Set MOXT_MACHINE_HOME to a separate isolated runtime to manage a development Connector.");
|
|
10130
|
+
}
|
|
10131
|
+
function isMachineLifecycleMutation(command, commandArguments) {
|
|
10132
|
+
if (command === "daemon" || command === "daemon-reconcile")
|
|
10133
|
+
return true;
|
|
10134
|
+
if (command === "connect" || command === "disconnect")
|
|
10135
|
+
return true;
|
|
10136
|
+
if (command !== "service")
|
|
10137
|
+
return false;
|
|
10138
|
+
const action = commandArguments[0] ?? "install";
|
|
10139
|
+
return ["install", "restart", "stop", "uninstall"].includes(action);
|
|
10140
|
+
}
|
|
9904
10141
|
async function connectCommand(store, argumentsList, entrypoint) {
|
|
9905
10142
|
const options = parseOptions(argumentsList);
|
|
9906
10143
|
const connectionCode = requiredOption(options, "code");
|
|
9907
|
-
const rootPath = (0,
|
|
10144
|
+
const rootPath = (0, import_node_path12.resolve)(options.root ?? process.cwd());
|
|
9908
10145
|
const serviceManagerPreference = requestedServiceManagerPreference(options);
|
|
9909
10146
|
await validateExplicitServiceManagerPreference(serviceManagerPreference);
|
|
9910
10147
|
writeLine("Internal Full Host Access: enabled");
|
|
@@ -10189,7 +10426,7 @@ async function waitForDaemonOnline(store) {
|
|
|
10189
10426
|
}
|
|
10190
10427
|
async function readOptionalFile2(path4) {
|
|
10191
10428
|
try {
|
|
10192
|
-
return await (0,
|
|
10429
|
+
return await (0, import_promises18.readFile)(path4, "utf8");
|
|
10193
10430
|
} catch {
|
|
10194
10431
|
return "";
|
|
10195
10432
|
}
|
|
@@ -10218,16 +10455,17 @@ function delay8(milliseconds) {
|
|
|
10218
10455
|
setTimeout(resolvePromise, milliseconds);
|
|
10219
10456
|
});
|
|
10220
10457
|
}
|
|
10221
|
-
var
|
|
10458
|
+
var import_promises18, import_node_path12, defaultRelayOrigin;
|
|
10222
10459
|
var init_cli = __esm({
|
|
10223
10460
|
"../machine-connector/dist/cli.js"() {
|
|
10224
10461
|
"use strict";
|
|
10225
10462
|
init_cjs_shims();
|
|
10226
|
-
|
|
10227
|
-
|
|
10463
|
+
import_promises18 = require("fs/promises");
|
|
10464
|
+
import_node_path12 = require("path");
|
|
10228
10465
|
init_daemon();
|
|
10229
10466
|
init_daemon_reconcile();
|
|
10230
10467
|
init_doctor();
|
|
10468
|
+
init_execution_context();
|
|
10231
10469
|
init_local_ipc();
|
|
10232
10470
|
init_machine_manager();
|
|
10233
10471
|
init_pairing();
|
|
@@ -10274,12 +10512,14 @@ __export(dist_exports, {
|
|
|
10274
10512
|
UserServiceManager: () => UserServiceManager,
|
|
10275
10513
|
assertClientRequestId: () => assertClientRequestId,
|
|
10276
10514
|
assertContiguousJobEvents: () => assertContiguousJobEvents,
|
|
10515
|
+
assertManagedServiceProvenance: () => assertManagedServiceProvenance,
|
|
10277
10516
|
assertPositiveGeneration: () => assertPositiveGeneration,
|
|
10278
10517
|
assertProtocolVersion: () => assertProtocolVersion,
|
|
10279
10518
|
assertRelativeWorkingDirectory: () => assertRelativeWorkingDirectory,
|
|
10280
10519
|
assertValidJobTransition: () => assertValidJobTransition,
|
|
10281
10520
|
assertWaitTimeout: () => assertWaitTimeout,
|
|
10282
10521
|
collectMachineManagerSnapshot: () => collectMachineManagerSnapshot,
|
|
10522
|
+
createLocalMachineJobExecutionContext: () => createLocalMachineJobExecutionContext,
|
|
10283
10523
|
createServiceEnvironment: () => createServiceEnvironment,
|
|
10284
10524
|
createSupervisorConfiguration: () => createSupervisorConfiguration,
|
|
10285
10525
|
defaultRuntimeDirectory: () => defaultRuntimeDirectory,
|
|
@@ -10289,10 +10529,13 @@ __export(dist_exports, {
|
|
|
10289
10529
|
executeClaudeStart: () => executeClaudeStart,
|
|
10290
10530
|
installUserService: () => installUserService,
|
|
10291
10531
|
isTerminalJobStatus: () => isTerminalJobStatus,
|
|
10532
|
+
localMachineJobTargetRelationship: () => localMachineJobTargetRelationship,
|
|
10533
|
+
machineExecutionContextEnvironmentName: () => machineExecutionContextEnvironmentName,
|
|
10292
10534
|
machineManagerActions: () => machineManagerActions,
|
|
10293
10535
|
machineProtocolVersion: () => machineProtocolVersion,
|
|
10294
10536
|
managedServiceOwnsProcess: () => managedServiceOwnsProcess,
|
|
10295
10537
|
pairMachine: () => pairMachine,
|
|
10538
|
+
parseLocalMachineJobExecutionContext: () => parseLocalMachineJobExecutionContext,
|
|
10296
10539
|
parseServiceManagerPreference: () => parseServiceManagerPreference,
|
|
10297
10540
|
reconcileManagedDaemon: () => reconcileManagedDaemon,
|
|
10298
10541
|
recordedServiceManager: () => recordedServiceManager,
|
|
@@ -10306,6 +10549,7 @@ __export(dist_exports, {
|
|
|
10306
10549
|
runMachineDoctor: () => runMachineDoctor,
|
|
10307
10550
|
runMachineManager: () => runMachineManager,
|
|
10308
10551
|
selectUserServiceManager: () => selectUserServiceManager,
|
|
10552
|
+
serializeLocalMachineJobExecutionContext: () => serializeLocalMachineJobExecutionContext,
|
|
10309
10553
|
stopUserService: () => stopUserService,
|
|
10310
10554
|
uninstallUserService: () => uninstallUserService,
|
|
10311
10555
|
validateServiceManagerPreference: () => validateServiceManagerPreference
|
|
@@ -10320,6 +10564,7 @@ var init_dist = __esm({
|
|
|
10320
10564
|
init_daemon_reconcile();
|
|
10321
10565
|
init_claude_executor();
|
|
10322
10566
|
init_doctor();
|
|
10567
|
+
init_execution_context();
|
|
10323
10568
|
init_local_ipc();
|
|
10324
10569
|
init_machine_manager();
|
|
10325
10570
|
init_pairing();
|
|
@@ -10506,7 +10751,7 @@ function getApiKeyOrUndefined() {
|
|
|
10506
10751
|
|
|
10507
10752
|
// src/utils/http.ts
|
|
10508
10753
|
function getUserAgent() {
|
|
10509
|
-
return `moxt-cli/${"0.9.0-beta.
|
|
10754
|
+
return `moxt-cli/${"0.9.0-beta.3"} (${(0, import_os.platform)()}/${(0, import_os.arch)()}) node/${process.versions.node}`;
|
|
10510
10755
|
}
|
|
10511
10756
|
async function sendRequest(method, path4, init) {
|
|
10512
10757
|
return await fetch(`${getApiBaseUrl()}${path4}`, {
|
|
@@ -10693,8 +10938,8 @@ function readCommentContentFile(path4) {
|
|
|
10693
10938
|
if (!fs.existsSync(path4)) {
|
|
10694
10939
|
throw new FileCommentOptionsError(`Error: comment content file not found: ${path4}`);
|
|
10695
10940
|
}
|
|
10696
|
-
const
|
|
10697
|
-
if (!
|
|
10941
|
+
const stat5 = fs.statSync(path4);
|
|
10942
|
+
if (!stat5.isFile()) {
|
|
10698
10943
|
throw new FileCommentOptionsError(`Error: comment content path is not a file: ${path4}`);
|
|
10699
10944
|
}
|
|
10700
10945
|
const buffer2 = fs.readFileSync(path4);
|
|
@@ -11368,8 +11613,8 @@ var FileTokenizer = class _FileTokenizer extends AbstractTokenizer {
|
|
|
11368
11613
|
*/
|
|
11369
11614
|
static async fromFile(sourceFilePath) {
|
|
11370
11615
|
const fileHandle = await (0, import_promises.open)(sourceFilePath, "r");
|
|
11371
|
-
const
|
|
11372
|
-
return new _FileTokenizer(fileHandle, { fileInfo: { path: sourceFilePath, size:
|
|
11616
|
+
const stat5 = await fileHandle.stat();
|
|
11617
|
+
return new _FileTokenizer(fileHandle, { fileInfo: { path: sourceFilePath, size: stat5.size } });
|
|
11373
11618
|
}
|
|
11374
11619
|
constructor(fileHandle, options) {
|
|
11375
11620
|
super(options);
|
|
@@ -16915,10 +17160,10 @@ function resolveAll(constructs2, events, context) {
|
|
|
16915
17160
|
const called = [];
|
|
16916
17161
|
let index2 = -1;
|
|
16917
17162
|
while (++index2 < constructs2.length) {
|
|
16918
|
-
const
|
|
16919
|
-
if (
|
|
16920
|
-
events =
|
|
16921
|
-
called.push(
|
|
17163
|
+
const resolve9 = constructs2[index2].resolveAll;
|
|
17164
|
+
if (resolve9 && !called.includes(resolve9)) {
|
|
17165
|
+
events = resolve9(events, context);
|
|
17166
|
+
called.push(resolve9);
|
|
16922
17167
|
}
|
|
16923
17168
|
}
|
|
16924
17169
|
return events;
|
|
@@ -23127,8 +23372,8 @@ function readDescFile(path4) {
|
|
|
23127
23372
|
if (!fs5.existsSync(path4)) {
|
|
23128
23373
|
throw new WorkflowOptionsError(`Error: desc file not found: ${path4}`);
|
|
23129
23374
|
}
|
|
23130
|
-
const
|
|
23131
|
-
if (!
|
|
23375
|
+
const stat5 = fs5.statSync(path4);
|
|
23376
|
+
if (!stat5.isFile()) {
|
|
23132
23377
|
throw new WorkflowOptionsError(`Error: desc file is not a file: ${path4}`);
|
|
23133
23378
|
}
|
|
23134
23379
|
const buffer2 = fs5.readFileSync(path4);
|
|
@@ -23145,11 +23390,11 @@ function readCommentContentFile2(path4) {
|
|
|
23145
23390
|
if (!fs5.existsSync(path4)) {
|
|
23146
23391
|
throw new WorkflowOptionsError(`Error: comment content file not found: ${path4}`);
|
|
23147
23392
|
}
|
|
23148
|
-
const
|
|
23149
|
-
if (!
|
|
23393
|
+
const stat5 = fs5.statSync(path4);
|
|
23394
|
+
if (!stat5.isFile()) {
|
|
23150
23395
|
throw new WorkflowOptionsError(`Error: comment content path is not a file: ${path4}`);
|
|
23151
23396
|
}
|
|
23152
|
-
if (
|
|
23397
|
+
if (stat5.size > MAX_COMMENT_CONTENT_BYTES) {
|
|
23153
23398
|
throw new WorkflowOptionsError(
|
|
23154
23399
|
`Error: comment content file must be at most ${MAX_COMMENT_CONTENT_LENGTH} characters.`
|
|
23155
23400
|
);
|
|
@@ -24089,7 +24334,7 @@ var FLUSH_TIMEOUT_MS = 3e3;
|
|
|
24089
24334
|
var MAX_BATCH_SIZE = 100;
|
|
24090
24335
|
function commonLabels() {
|
|
24091
24336
|
return {
|
|
24092
|
-
cli_version: "0.9.0-beta.
|
|
24337
|
+
cli_version: "0.9.0-beta.3",
|
|
24093
24338
|
node_version: process.versions.node,
|
|
24094
24339
|
os: (0, import_node_os8.platform)(),
|
|
24095
24340
|
arch: (0, import_node_os8.arch)(),
|
|
@@ -24135,7 +24380,7 @@ async function flush() {
|
|
|
24135
24380
|
}
|
|
24136
24381
|
const batch = buffer.splice(0, MAX_BATCH_SIZE);
|
|
24137
24382
|
const payload = {
|
|
24138
|
-
release_id: "0.9.0-beta.
|
|
24383
|
+
release_id: "0.9.0-beta.3",
|
|
24139
24384
|
client_type: "cli",
|
|
24140
24385
|
metric_data_list: batch.map((m) => ({
|
|
24141
24386
|
profile: "cli",
|
|
@@ -24336,7 +24581,7 @@ function registryWorker() {
|
|
|
24336
24581
|
|
|
24337
24582
|
// src/update/prompt.ts
|
|
24338
24583
|
init_cjs_shims();
|
|
24339
|
-
var
|
|
24584
|
+
var import_promises19 = require("readline/promises");
|
|
24340
24585
|
async function promptForUpdate(input, output, currentVersion, latestVersion, timeoutMs) {
|
|
24341
24586
|
output.write(`
|
|
24342
24587
|
A new version of Moxt CLI is available: ${currentVersion} \u2192 ${latestVersion}
|
|
@@ -24349,7 +24594,7 @@ A new version of Moxt CLI is available: ${currentVersion} \u2192 ${latestVersion
|
|
|
24349
24594
|
const controller = new AbortController();
|
|
24350
24595
|
const timeout = setTimeout(() => controller.abort(), timeoutMs);
|
|
24351
24596
|
timeout.unref();
|
|
24352
|
-
const readline = (0,
|
|
24597
|
+
const readline = (0, import_promises19.createInterface)({ input, output, terminal: true });
|
|
24353
24598
|
try {
|
|
24354
24599
|
const answer = await readline.question("", { signal: controller.signal });
|
|
24355
24600
|
if (answer.trim() === "1") return "update";
|
|
@@ -24452,7 +24697,7 @@ function commandPath2(command) {
|
|
|
24452
24697
|
|
|
24453
24698
|
// src/update/daemon-reconcile-hook.ts
|
|
24454
24699
|
init_cjs_shims();
|
|
24455
|
-
var
|
|
24700
|
+
var import_node_path13 = require("path");
|
|
24456
24701
|
function installDaemonReconcileHook(program3, cliVersion) {
|
|
24457
24702
|
program3.hook("preAction", async (_thisCommand, actionCommand) => {
|
|
24458
24703
|
if (!isEligible2(actionCommand)) return;
|
|
@@ -24460,15 +24705,23 @@ function installDaemonReconcileHook(program3, cliVersion) {
|
|
|
24460
24705
|
if (!entrypointPath) return;
|
|
24461
24706
|
const {
|
|
24462
24707
|
DaemonRefreshError: DaemonRefreshError2,
|
|
24708
|
+
localMachineJobTargetRelationship: localMachineJobTargetRelationship2,
|
|
24709
|
+
MachineRuntimeStore: MachineRuntimeStore2,
|
|
24463
24710
|
reconcileManagedDaemon: reconcileManagedDaemon2
|
|
24464
24711
|
} = await Promise.resolve().then(() => (init_dist(), dist_exports));
|
|
24712
|
+
const relationship = await localMachineJobTargetRelationship2(
|
|
24713
|
+
new MachineRuntimeStore2()
|
|
24714
|
+
);
|
|
24715
|
+
if (relationship === "matching_instance" || relationship === "same_runtime_stale_or_unreachable") {
|
|
24716
|
+
return;
|
|
24717
|
+
}
|
|
24465
24718
|
try {
|
|
24466
24719
|
await reconcileManagedDaemon2({
|
|
24467
24720
|
cliVersion,
|
|
24468
24721
|
commandArguments: ["machine", "daemon"],
|
|
24469
|
-
entrypointPath: (0,
|
|
24722
|
+
entrypointPath: (0, import_node_path13.resolve)(entrypointPath),
|
|
24470
24723
|
environment: {},
|
|
24471
|
-
nodePath: (0,
|
|
24724
|
+
nodePath: (0, import_node_path13.resolve)(process.execPath),
|
|
24472
24725
|
onActiveJobs: (count) => {
|
|
24473
24726
|
process.stderr.write(
|
|
24474
24727
|
`Warning: restarting the managed Connector will interrupt ${count} active ${count === 1 ? "Job" : "Jobs"}.
|
|
@@ -24510,9 +24763,9 @@ function commandPath3(command) {
|
|
|
24510
24763
|
}
|
|
24511
24764
|
|
|
24512
24765
|
// src/index.ts
|
|
24513
|
-
var program2 = createProgram("0.9.0-beta.
|
|
24514
|
-
installDaemonReconcileHook(program2, "0.9.0-beta.
|
|
24515
|
-
installUpdateHook(program2, "0.9.0-beta.
|
|
24766
|
+
var program2 = createProgram("0.9.0-beta.3");
|
|
24767
|
+
installDaemonReconcileHook(program2, "0.9.0-beta.3");
|
|
24768
|
+
installUpdateHook(program2, "0.9.0-beta.3");
|
|
24516
24769
|
instrumentProgram(program2);
|
|
24517
24770
|
installExitHandler();
|
|
24518
24771
|
program2.parseAsync(process.argv).then(async () => {
|