@moxt-ai/cli 0.10.0-beta.3 → 0.10.0-beta.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +282 -126
- package/dist/index.cjs.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -6685,6 +6685,62 @@ var init_version = __esm({
|
|
|
6685
6685
|
}
|
|
6686
6686
|
});
|
|
6687
6687
|
|
|
6688
|
+
// ../machine-connector/dist/runtime/local-codex-runtime/contracts.js
|
|
6689
|
+
var localCodexRuntimeProtocolVersion, localCodexRuntimeEventSchemaVersion, localCodexRuntimeEventRedactionVersion, LocalCodexComponentStatusWire, LocalCodexTurnStatusWire, LocalCodexControlKindWire, LocalCodexControlOutcomeWire, LocalCodexDiscoveryKindWire, LocalCodexDiscoveryStatusWire, LocalCodexAttemptPhase, LocalCodexControlApplyPhase;
|
|
6690
|
+
var init_contracts2 = __esm({
|
|
6691
|
+
"../machine-connector/dist/runtime/local-codex-runtime/contracts.js"() {
|
|
6692
|
+
"use strict";
|
|
6693
|
+
init_cjs_shims();
|
|
6694
|
+
localCodexRuntimeProtocolVersion = "1.0";
|
|
6695
|
+
localCodexRuntimeEventSchemaVersion = 1;
|
|
6696
|
+
localCodexRuntimeEventRedactionVersion = 1;
|
|
6697
|
+
(function(LocalCodexComponentStatusWire2) {
|
|
6698
|
+
LocalCodexComponentStatusWire2["AuthenticationRequired"] = "authentication_required";
|
|
6699
|
+
LocalCodexComponentStatusWire2["Error"] = "error";
|
|
6700
|
+
LocalCodexComponentStatusWire2["Incompatible"] = "incompatible";
|
|
6701
|
+
LocalCodexComponentStatusWire2["Missing"] = "missing";
|
|
6702
|
+
LocalCodexComponentStatusWire2["Ready"] = "ready";
|
|
6703
|
+
LocalCodexComponentStatusWire2["Unknown"] = "unknown";
|
|
6704
|
+
})(LocalCodexComponentStatusWire || (LocalCodexComponentStatusWire = {}));
|
|
6705
|
+
(function(LocalCodexTurnStatusWire2) {
|
|
6706
|
+
LocalCodexTurnStatusWire2["Cancelled"] = "cancelled";
|
|
6707
|
+
LocalCodexTurnStatusWire2["Failed"] = "failed";
|
|
6708
|
+
LocalCodexTurnStatusWire2["Interrupted"] = "interrupted";
|
|
6709
|
+
LocalCodexTurnStatusWire2["Running"] = "running";
|
|
6710
|
+
LocalCodexTurnStatusWire2["RuntimeLost"] = "runtime_lost";
|
|
6711
|
+
LocalCodexTurnStatusWire2["Succeeded"] = "succeeded";
|
|
6712
|
+
})(LocalCodexTurnStatusWire || (LocalCodexTurnStatusWire = {}));
|
|
6713
|
+
(function(LocalCodexControlKindWire2) {
|
|
6714
|
+
LocalCodexControlKindWire2["Abort"] = "abort";
|
|
6715
|
+
LocalCodexControlKindWire2["InteractionResponse"] = "interaction_response";
|
|
6716
|
+
LocalCodexControlKindWire2["Steer"] = "steer";
|
|
6717
|
+
})(LocalCodexControlKindWire || (LocalCodexControlKindWire = {}));
|
|
6718
|
+
(function(LocalCodexControlOutcomeWire2) {
|
|
6719
|
+
LocalCodexControlOutcomeWire2["Applied"] = "applied";
|
|
6720
|
+
LocalCodexControlOutcomeWire2["Rejected"] = "rejected";
|
|
6721
|
+
LocalCodexControlOutcomeWire2["Stale"] = "stale";
|
|
6722
|
+
})(LocalCodexControlOutcomeWire || (LocalCodexControlOutcomeWire = {}));
|
|
6723
|
+
(function(LocalCodexDiscoveryKindWire2) {
|
|
6724
|
+
LocalCodexDiscoveryKindWire2["DirectoryList"] = "directory_list";
|
|
6725
|
+
LocalCodexDiscoveryKindWire2["ModelList"] = "model_list";
|
|
6726
|
+
})(LocalCodexDiscoveryKindWire || (LocalCodexDiscoveryKindWire = {}));
|
|
6727
|
+
(function(LocalCodexDiscoveryStatusWire2) {
|
|
6728
|
+
LocalCodexDiscoveryStatusWire2["Failed"] = "failed";
|
|
6729
|
+
LocalCodexDiscoveryStatusWire2["Succeeded"] = "succeeded";
|
|
6730
|
+
})(LocalCodexDiscoveryStatusWire || (LocalCodexDiscoveryStatusWire = {}));
|
|
6731
|
+
(function(LocalCodexAttemptPhase2) {
|
|
6732
|
+
LocalCodexAttemptPhase2["Claimed"] = "claimed";
|
|
6733
|
+
LocalCodexAttemptPhase2["Running"] = "running";
|
|
6734
|
+
LocalCodexAttemptPhase2["TerminalPendingUpload"] = "terminal_pending_upload";
|
|
6735
|
+
LocalCodexAttemptPhase2["Uploaded"] = "uploaded";
|
|
6736
|
+
})(LocalCodexAttemptPhase || (LocalCodexAttemptPhase = {}));
|
|
6737
|
+
(function(LocalCodexControlApplyPhase2) {
|
|
6738
|
+
LocalCodexControlApplyPhase2["Applied"] = "applied";
|
|
6739
|
+
LocalCodexControlApplyPhase2["Recorded"] = "recorded";
|
|
6740
|
+
})(LocalCodexControlApplyPhase || (LocalCodexControlApplyPhase = {}));
|
|
6741
|
+
}
|
|
6742
|
+
});
|
|
6743
|
+
|
|
6688
6744
|
// ../machine-connector/dist/runtime/relay-client.js
|
|
6689
6745
|
function localCodexRuntimeEventsRequestBody(fence, firstSequence, events) {
|
|
6690
6746
|
return { ...fence, events, firstSequence };
|
|
@@ -6769,6 +6825,7 @@ var init_relay_client = __esm({
|
|
|
6769
6825
|
"use strict";
|
|
6770
6826
|
init_cjs_shims();
|
|
6771
6827
|
init_version();
|
|
6828
|
+
init_contracts2();
|
|
6772
6829
|
requestTimeoutMilliseconds = 65e3;
|
|
6773
6830
|
RelayHttpError = class extends Error {
|
|
6774
6831
|
responseBody;
|
|
@@ -6851,6 +6908,16 @@ var init_relay_client = __esm({
|
|
|
6851
6908
|
async claimCodexRuntime(request2, signal) {
|
|
6852
6909
|
return await this.authenticatedPost("codex-runtime/turns/claim", request2, signal);
|
|
6853
6910
|
}
|
|
6911
|
+
async claimCodexRuntimeDiscovery(request2, signal) {
|
|
6912
|
+
return await this.authenticatedPost("codex-runtime/discovery/claim", request2, signal);
|
|
6913
|
+
}
|
|
6914
|
+
async completeCodexRuntimeDiscovery(requestId, connectorInstanceId, result) {
|
|
6915
|
+
return await this.authenticatedPost(`codex-runtime/discovery/requests/${encodeURIComponent(requestId)}/result`, {
|
|
6916
|
+
...result,
|
|
6917
|
+
connectorInstanceId,
|
|
6918
|
+
protocolVersion: localCodexRuntimeProtocolVersion
|
|
6919
|
+
});
|
|
6920
|
+
}
|
|
6854
6921
|
async renewCodexRuntimeLease(attemptId, fence, signal) {
|
|
6855
6922
|
return await this.authenticatedPost(`codex-runtime/attempts/${encodeURIComponent(attemptId)}/lease`, fence, signal);
|
|
6856
6923
|
}
|
|
@@ -7282,54 +7349,6 @@ var init_store = __esm({
|
|
|
7282
7349
|
}
|
|
7283
7350
|
});
|
|
7284
7351
|
|
|
7285
|
-
// ../machine-connector/dist/runtime/local-codex-runtime/contracts.js
|
|
7286
|
-
var localCodexRuntimeProtocolVersion, localCodexRuntimeEventSchemaVersion, localCodexRuntimeEventRedactionVersion, LocalCodexComponentStatusWire, LocalCodexTurnStatusWire, LocalCodexControlKindWire, LocalCodexControlOutcomeWire, LocalCodexAttemptPhase, LocalCodexControlApplyPhase;
|
|
7287
|
-
var init_contracts2 = __esm({
|
|
7288
|
-
"../machine-connector/dist/runtime/local-codex-runtime/contracts.js"() {
|
|
7289
|
-
"use strict";
|
|
7290
|
-
init_cjs_shims();
|
|
7291
|
-
localCodexRuntimeProtocolVersion = "1.0";
|
|
7292
|
-
localCodexRuntimeEventSchemaVersion = 1;
|
|
7293
|
-
localCodexRuntimeEventRedactionVersion = 1;
|
|
7294
|
-
(function(LocalCodexComponentStatusWire2) {
|
|
7295
|
-
LocalCodexComponentStatusWire2["AuthenticationRequired"] = "authentication_required";
|
|
7296
|
-
LocalCodexComponentStatusWire2["Error"] = "error";
|
|
7297
|
-
LocalCodexComponentStatusWire2["Incompatible"] = "incompatible";
|
|
7298
|
-
LocalCodexComponentStatusWire2["Missing"] = "missing";
|
|
7299
|
-
LocalCodexComponentStatusWire2["Ready"] = "ready";
|
|
7300
|
-
LocalCodexComponentStatusWire2["Unknown"] = "unknown";
|
|
7301
|
-
})(LocalCodexComponentStatusWire || (LocalCodexComponentStatusWire = {}));
|
|
7302
|
-
(function(LocalCodexTurnStatusWire2) {
|
|
7303
|
-
LocalCodexTurnStatusWire2["Cancelled"] = "cancelled";
|
|
7304
|
-
LocalCodexTurnStatusWire2["Failed"] = "failed";
|
|
7305
|
-
LocalCodexTurnStatusWire2["Interrupted"] = "interrupted";
|
|
7306
|
-
LocalCodexTurnStatusWire2["Running"] = "running";
|
|
7307
|
-
LocalCodexTurnStatusWire2["RuntimeLost"] = "runtime_lost";
|
|
7308
|
-
LocalCodexTurnStatusWire2["Succeeded"] = "succeeded";
|
|
7309
|
-
})(LocalCodexTurnStatusWire || (LocalCodexTurnStatusWire = {}));
|
|
7310
|
-
(function(LocalCodexControlKindWire2) {
|
|
7311
|
-
LocalCodexControlKindWire2["Abort"] = "abort";
|
|
7312
|
-
LocalCodexControlKindWire2["InteractionResponse"] = "interaction_response";
|
|
7313
|
-
LocalCodexControlKindWire2["Steer"] = "steer";
|
|
7314
|
-
})(LocalCodexControlKindWire || (LocalCodexControlKindWire = {}));
|
|
7315
|
-
(function(LocalCodexControlOutcomeWire2) {
|
|
7316
|
-
LocalCodexControlOutcomeWire2["Applied"] = "applied";
|
|
7317
|
-
LocalCodexControlOutcomeWire2["Rejected"] = "rejected";
|
|
7318
|
-
LocalCodexControlOutcomeWire2["Stale"] = "stale";
|
|
7319
|
-
})(LocalCodexControlOutcomeWire || (LocalCodexControlOutcomeWire = {}));
|
|
7320
|
-
(function(LocalCodexAttemptPhase2) {
|
|
7321
|
-
LocalCodexAttemptPhase2["Claimed"] = "claimed";
|
|
7322
|
-
LocalCodexAttemptPhase2["Running"] = "running";
|
|
7323
|
-
LocalCodexAttemptPhase2["TerminalPendingUpload"] = "terminal_pending_upload";
|
|
7324
|
-
LocalCodexAttemptPhase2["Uploaded"] = "uploaded";
|
|
7325
|
-
})(LocalCodexAttemptPhase || (LocalCodexAttemptPhase = {}));
|
|
7326
|
-
(function(LocalCodexControlApplyPhase2) {
|
|
7327
|
-
LocalCodexControlApplyPhase2["Applied"] = "applied";
|
|
7328
|
-
LocalCodexControlApplyPhase2["Recorded"] = "recorded";
|
|
7329
|
-
})(LocalCodexControlApplyPhase || (LocalCodexControlApplyPhase = {}));
|
|
7330
|
-
}
|
|
7331
|
-
});
|
|
7332
|
-
|
|
7333
7352
|
// ../machine-connector/dist/runtime/local-codex-runtime/app-server-client.js
|
|
7334
7353
|
function appServerResponseMessage(response) {
|
|
7335
7354
|
if (typeof response === "object" && response !== null && "message" in response && typeof response.message === "string") {
|
|
@@ -8513,6 +8532,36 @@ function terminalErrorMessage(payload) {
|
|
|
8513
8532
|
const message = safeRecord(payload.error).message;
|
|
8514
8533
|
return typeof message === "string" ? { value: message } : {};
|
|
8515
8534
|
}
|
|
8535
|
+
function parseModelListResponse(value) {
|
|
8536
|
+
const response = safeRecord(value);
|
|
8537
|
+
if (!Array.isArray(response.data)) {
|
|
8538
|
+
throw new AppServerProtocolError("Codex App Server model/list returned no data array");
|
|
8539
|
+
}
|
|
8540
|
+
const models = [];
|
|
8541
|
+
for (const candidate of response.data) {
|
|
8542
|
+
const model = safeRecord(candidate);
|
|
8543
|
+
if (typeof model.model !== "string" || model.model.length === 0 || model.model.length > 128 || typeof model.displayName !== "string" || model.displayName.length === 0 || model.displayName.length > 255 || typeof model.description !== "string" || model.description.length > 2e3 || typeof model.isDefault !== "boolean") {
|
|
8544
|
+
throw new AppServerProtocolError("Codex App Server model/list returned an invalid model");
|
|
8545
|
+
}
|
|
8546
|
+
models.push({
|
|
8547
|
+
description: model.description,
|
|
8548
|
+
displayName: model.displayName,
|
|
8549
|
+
isDefault: model.isDefault,
|
|
8550
|
+
model: model.model
|
|
8551
|
+
});
|
|
8552
|
+
}
|
|
8553
|
+
const nextCursor = response.nextCursor;
|
|
8554
|
+
if (nextCursor === null || nextCursor === void 0) {
|
|
8555
|
+
return { models };
|
|
8556
|
+
}
|
|
8557
|
+
if (typeof nextCursor !== "string" || nextCursor.length === 0) {
|
|
8558
|
+
throw new AppServerProtocolError("Codex App Server model/list returned an invalid cursor");
|
|
8559
|
+
}
|
|
8560
|
+
return { models, nextCursor };
|
|
8561
|
+
}
|
|
8562
|
+
function portableRelativeDirectory(value) {
|
|
8563
|
+
return value === "" ? "." : value.replaceAll("\\", "/");
|
|
8564
|
+
}
|
|
8516
8565
|
function safeRecord(value) {
|
|
8517
8566
|
return typeof value === "object" && value !== null && !Array.isArray(value) ? value : {};
|
|
8518
8567
|
}
|
|
@@ -8592,12 +8641,14 @@ function parseLeaseDeadline(value) {
|
|
|
8592
8641
|
}
|
|
8593
8642
|
return parsed;
|
|
8594
8643
|
}
|
|
8595
|
-
var import_node_child_process4, heartbeatIntervalMilliseconds, claimRetryMilliseconds, claimWaitSeconds, eventUploadCoalesceMilliseconds, eventUploadRetryMilliseconds, maximumEventUploadCount, preferredEventUploadRequestBytes, leaseRenewIntervalMilliseconds, leaseRenewRetryMilliseconds, interactionTimeoutMilliseconds, executableProbeTimeoutMilliseconds, recoveryRetryMilliseconds, initialThreadNameRetryMilliseconds, maximumThreadNameRetryMilliseconds, maximumInitialThreadNameAttempts, ThreadUnavailableError, LeaseLostError, SpoolPersistenceError, UnknownTurnStartResultError, LocalCodexRuntimeConnectionWorker;
|
|
8644
|
+
var import_node_child_process4, import_promises12, import_node_path10, heartbeatIntervalMilliseconds, claimRetryMilliseconds, claimWaitSeconds, discoveryWaitSeconds, discoveryRetryMilliseconds, maximumDiscoveryDirectories, maximumDiscoveryModels, maximumModelListPages, eventUploadCoalesceMilliseconds, eventUploadRetryMilliseconds, maximumEventUploadCount, preferredEventUploadRequestBytes, leaseRenewIntervalMilliseconds, leaseRenewRetryMilliseconds, interactionTimeoutMilliseconds, executableProbeTimeoutMilliseconds, recoveryRetryMilliseconds, initialThreadNameRetryMilliseconds, maximumThreadNameRetryMilliseconds, maximumInitialThreadNameAttempts, ThreadUnavailableError, LeaseLostError, SpoolPersistenceError, UnknownTurnStartResultError, LocalCodexRuntimeConnectionWorker;
|
|
8596
8645
|
var init_runtime_worker = __esm({
|
|
8597
8646
|
"../machine-connector/dist/runtime/local-codex-runtime/runtime-worker.js"() {
|
|
8598
8647
|
"use strict";
|
|
8599
8648
|
init_cjs_shims();
|
|
8600
8649
|
import_node_child_process4 = require("child_process");
|
|
8650
|
+
import_promises12 = require("fs/promises");
|
|
8651
|
+
import_node_path10 = require("path");
|
|
8601
8652
|
init_process_executor();
|
|
8602
8653
|
init_relay_client();
|
|
8603
8654
|
init_app_server_client();
|
|
@@ -8607,6 +8658,11 @@ var init_runtime_worker = __esm({
|
|
|
8607
8658
|
heartbeatIntervalMilliseconds = 2e4;
|
|
8608
8659
|
claimRetryMilliseconds = 250;
|
|
8609
8660
|
claimWaitSeconds = 25;
|
|
8661
|
+
discoveryWaitSeconds = 25;
|
|
8662
|
+
discoveryRetryMilliseconds = 1e3;
|
|
8663
|
+
maximumDiscoveryDirectories = 1e3;
|
|
8664
|
+
maximumDiscoveryModels = 100;
|
|
8665
|
+
maximumModelListPages = 10;
|
|
8610
8666
|
eventUploadCoalesceMilliseconds = 500;
|
|
8611
8667
|
eventUploadRetryMilliseconds = 1e3;
|
|
8612
8668
|
maximumEventUploadCount = 500;
|
|
@@ -8805,6 +8861,7 @@ var init_runtime_worker = __esm({
|
|
|
8805
8861
|
await Promise.all([
|
|
8806
8862
|
this.runHeartbeatLoop(),
|
|
8807
8863
|
this.runClaimLoop(),
|
|
8864
|
+
this.runDiscoveryLoop(),
|
|
8808
8865
|
this.runRecoveryLoop()
|
|
8809
8866
|
]);
|
|
8810
8867
|
} finally {
|
|
@@ -8861,6 +8918,105 @@ var init_runtime_worker = __esm({
|
|
|
8861
8918
|
}
|
|
8862
8919
|
}
|
|
8863
8920
|
}
|
|
8921
|
+
async runDiscoveryLoop() {
|
|
8922
|
+
while (!this.lifetimeAbort.signal.aborted && !this.relay.isRevoked()) {
|
|
8923
|
+
try {
|
|
8924
|
+
const response = await this.relay.claimCodexRuntimeDiscovery({
|
|
8925
|
+
connectorInstanceId: this.connectorInstanceId,
|
|
8926
|
+
protocolVersion: localCodexRuntimeProtocolVersion,
|
|
8927
|
+
waitSeconds: discoveryWaitSeconds
|
|
8928
|
+
}, this.lifetimeAbort.signal);
|
|
8929
|
+
if (response.request === void 0) {
|
|
8930
|
+
continue;
|
|
8931
|
+
}
|
|
8932
|
+
await this.completeDiscovery(response.request);
|
|
8933
|
+
} catch (error) {
|
|
8934
|
+
if (!this.lifetimeAbort.signal.aborted) {
|
|
8935
|
+
await this.logger.error(`Local Codex discovery loop failed for connection ${this.connection.connectionId}`, error);
|
|
8936
|
+
await waitForAbort(this.lifetimeAbort.signal, discoveryRetryMilliseconds);
|
|
8937
|
+
}
|
|
8938
|
+
}
|
|
8939
|
+
}
|
|
8940
|
+
}
|
|
8941
|
+
async completeDiscovery(request2) {
|
|
8942
|
+
let result;
|
|
8943
|
+
try {
|
|
8944
|
+
result = await this.executeDiscovery(request2);
|
|
8945
|
+
} catch (error) {
|
|
8946
|
+
await this.logger.error(`Local Codex ${request2.kind} discovery failed for connection ${this.connection.connectionId}`, error);
|
|
8947
|
+
result = {
|
|
8948
|
+
errorCode: request2.kind === LocalCodexDiscoveryKindWire.ModelList ? "model_discovery_failed" : "directory_unavailable",
|
|
8949
|
+
requestId: request2.requestId,
|
|
8950
|
+
status: LocalCodexDiscoveryStatusWire.Failed
|
|
8951
|
+
};
|
|
8952
|
+
}
|
|
8953
|
+
const completion = await this.relay.completeCodexRuntimeDiscovery(request2.requestId, this.connectorInstanceId, result);
|
|
8954
|
+
if (!completion.accepted) {
|
|
8955
|
+
await this.logger.info(`Local Codex discovery request ${request2.requestId} expired before completion`);
|
|
8956
|
+
}
|
|
8957
|
+
}
|
|
8958
|
+
async executeDiscovery(request2) {
|
|
8959
|
+
if (request2.kind === LocalCodexDiscoveryKindWire.ModelList) {
|
|
8960
|
+
return {
|
|
8961
|
+
models: await this.discoverModels(),
|
|
8962
|
+
requestId: request2.requestId,
|
|
8963
|
+
status: LocalCodexDiscoveryStatusWire.Succeeded
|
|
8964
|
+
};
|
|
8965
|
+
}
|
|
8966
|
+
if (request2.kind === LocalCodexDiscoveryKindWire.DirectoryList) {
|
|
8967
|
+
const listing = await this.discoverDirectories(request2.relativeDirectory ?? ".");
|
|
8968
|
+
return {
|
|
8969
|
+
...listing,
|
|
8970
|
+
requestId: request2.requestId,
|
|
8971
|
+
status: LocalCodexDiscoveryStatusWire.Succeeded
|
|
8972
|
+
};
|
|
8973
|
+
}
|
|
8974
|
+
throw new Error("Unsupported Local Codex discovery kind");
|
|
8975
|
+
}
|
|
8976
|
+
async discoverModels() {
|
|
8977
|
+
const client = await this.processPool.ensureStarted();
|
|
8978
|
+
const models = /* @__PURE__ */ new Map();
|
|
8979
|
+
const cursor = {};
|
|
8980
|
+
for (let page = 0; page < maximumModelListPages; page += 1) {
|
|
8981
|
+
const response = await client.request("model/list", {
|
|
8982
|
+
cursor: cursor.value ?? null,
|
|
8983
|
+
includeHidden: false,
|
|
8984
|
+
limit: maximumDiscoveryModels
|
|
8985
|
+
});
|
|
8986
|
+
const parsed = parseModelListResponse(response);
|
|
8987
|
+
for (const model of parsed.models) {
|
|
8988
|
+
models.set(model.model, model);
|
|
8989
|
+
if (models.size >= maximumDiscoveryModels) {
|
|
8990
|
+
return [...models.values()];
|
|
8991
|
+
}
|
|
8992
|
+
}
|
|
8993
|
+
if (parsed.nextCursor === void 0) {
|
|
8994
|
+
return [...models.values()];
|
|
8995
|
+
}
|
|
8996
|
+
cursor.value = parsed.nextCursor;
|
|
8997
|
+
}
|
|
8998
|
+
throw new AppServerProtocolError("Codex App Server model/list pagination did not converge");
|
|
8999
|
+
}
|
|
9000
|
+
async discoverDirectories(relativeDirectory) {
|
|
9001
|
+
const canonicalRoot = await resolveCanonicalWorkingDirectory(this.connection.rootPath, ".");
|
|
9002
|
+
const canonicalDirectory = await resolveCanonicalWorkingDirectory(canonicalRoot, relativeDirectory);
|
|
9003
|
+
const entries = (await (0, import_promises12.readdir)(canonicalDirectory, {
|
|
9004
|
+
withFileTypes: true
|
|
9005
|
+
})).filter((entry) => entry.isDirectory()).filter((entry) => !entry.name.includes("\\")).sort((left, right) => left.name.localeCompare(right.name, void 0, {
|
|
9006
|
+
numeric: true,
|
|
9007
|
+
sensitivity: "base"
|
|
9008
|
+
}));
|
|
9009
|
+
const eligibleDirectories = entries.map((entry) => ({
|
|
9010
|
+
name: entry.name,
|
|
9011
|
+
relativePath: portableRelativeDirectory((0, import_node_path10.relative)(canonicalRoot, (0, import_node_path10.join)(canonicalDirectory, entry.name)))
|
|
9012
|
+
})).filter((entry) => entry.name.length <= 255 && entry.relativePath.length <= 1024);
|
|
9013
|
+
const directories = eligibleDirectories.slice(0, maximumDiscoveryDirectories);
|
|
9014
|
+
return {
|
|
9015
|
+
currentRelativeDirectory: portableRelativeDirectory((0, import_node_path10.relative)(canonicalRoot, canonicalDirectory)),
|
|
9016
|
+
directories,
|
|
9017
|
+
truncated: eligibleDirectories.length > maximumDiscoveryDirectories
|
|
9018
|
+
};
|
|
9019
|
+
}
|
|
8864
9020
|
async executeAttempt(claim) {
|
|
8865
9021
|
const durable = await DurableLocalCodexAttempt.create(this.store, this.connection.connectionId, this.connectorInstanceId, claim);
|
|
8866
9022
|
const active = createActiveAttempt(claim, durable, this.connection.rootPath);
|
|
@@ -10729,12 +10885,12 @@ async function installUserService(store, request2, runtime = defaultServiceManag
|
|
|
10729
10885
|
}
|
|
10730
10886
|
function createServiceEnvironment(options) {
|
|
10731
10887
|
const inheritedPath = options.environment.PATH ?? process.env.PATH ?? "";
|
|
10732
|
-
const nodeDirectory = (0,
|
|
10733
|
-
const pathEntries = [nodeDirectory, ...inheritedPath.split(
|
|
10888
|
+
const nodeDirectory = (0, import_node_path11.dirname)(options.nodePath);
|
|
10889
|
+
const pathEntries = [nodeDirectory, ...inheritedPath.split(import_node_path11.delimiter)].filter((entry, index2, entries) => entry.length > 0 && entries.indexOf(entry) === index2);
|
|
10734
10890
|
return {
|
|
10735
10891
|
...options.environment,
|
|
10736
10892
|
HOME: options.environment.HOME ?? process.env.HOME ?? (0, import_node_os7.homedir)(),
|
|
10737
|
-
PATH: pathEntries.join(
|
|
10893
|
+
PATH: pathEntries.join(import_node_path11.delimiter)
|
|
10738
10894
|
};
|
|
10739
10895
|
}
|
|
10740
10896
|
async function restartUserService(store, runtime = defaultServiceManagerRuntime) {
|
|
@@ -10936,7 +11092,7 @@ async function uninstallManager(manager, store, runtime) {
|
|
|
10936
11092
|
"bootout",
|
|
10937
11093
|
`gui/${process.getuid?.() ?? 0}/${launchAgentLabel}`
|
|
10938
11094
|
]);
|
|
10939
|
-
await (0,
|
|
11095
|
+
await (0, import_promises13.rm)(launchAgentPath(), { force: true });
|
|
10940
11096
|
return;
|
|
10941
11097
|
}
|
|
10942
11098
|
if (manager === UserServiceManager.Systemd) {
|
|
@@ -10946,7 +11102,7 @@ async function uninstallManager(manager, store, runtime) {
|
|
|
10946
11102
|
"--now",
|
|
10947
11103
|
"moxt-machine-connector.service"
|
|
10948
11104
|
]);
|
|
10949
|
-
await (0,
|
|
11105
|
+
await (0, import_promises13.rm)(systemdUnitPath(), { force: true });
|
|
10950
11106
|
await runCommandIgnoringFailure(runtime, "systemctl", [
|
|
10951
11107
|
"--user",
|
|
10952
11108
|
"daemon-reload"
|
|
@@ -10960,7 +11116,7 @@ async function uninstallManager(manager, store, runtime) {
|
|
|
10960
11116
|
supervisorProgramName
|
|
10961
11117
|
]);
|
|
10962
11118
|
await runCommandIgnoringFailure(runtime, "supervisorctl", ["-c", supervisorConfigPath(store), "shutdown"]);
|
|
10963
|
-
await (0,
|
|
11119
|
+
await (0, import_promises13.rm)(supervisorDirectory(store), {
|
|
10964
11120
|
force: true,
|
|
10965
11121
|
recursive: true
|
|
10966
11122
|
});
|
|
@@ -10986,7 +11142,7 @@ async function readStoredServiceManager(store) {
|
|
|
10986
11142
|
}
|
|
10987
11143
|
async function readManagedServiceDefinition(manager, store) {
|
|
10988
11144
|
try {
|
|
10989
|
-
return await (0,
|
|
11145
|
+
return await (0, import_promises13.readFile)(managedServiceDefinitionPath(manager, store), "utf8");
|
|
10990
11146
|
} catch (error) {
|
|
10991
11147
|
if (isNodeErrorCode4(error, "ENOENT"))
|
|
10992
11148
|
return void 0;
|
|
@@ -10995,8 +11151,8 @@ async function readManagedServiceDefinition(manager, store) {
|
|
|
10995
11151
|
}
|
|
10996
11152
|
async function restoreManagedServiceDefinition(manager, store, definition2, runtime) {
|
|
10997
11153
|
const path4 = managedServiceDefinitionPath(manager, store);
|
|
10998
|
-
await (0,
|
|
10999
|
-
await (0,
|
|
11154
|
+
await (0, import_promises13.mkdir)((0, import_node_path11.dirname)(path4), { recursive: true });
|
|
11155
|
+
await (0, import_promises13.writeFile)(path4, definition2, { encoding: "utf8", mode: 384 });
|
|
11000
11156
|
if (manager === UserServiceManager.Launchd) {
|
|
11001
11157
|
const domain = `gui/${process.getuid?.() ?? 0}`;
|
|
11002
11158
|
await runCommandIgnoringFailure(runtime, "launchctl", [
|
|
@@ -11045,7 +11201,7 @@ function parseProcessId(value) {
|
|
|
11045
11201
|
async function persistServiceManager(store, manager, managedEntrypointPath, desiredState = ManagedServiceDesiredState.Running) {
|
|
11046
11202
|
await store.writeServiceManager({
|
|
11047
11203
|
desiredState,
|
|
11048
|
-
...managedEntrypointPath ? { managedEntrypointPath: (0,
|
|
11204
|
+
...managedEntrypointPath ? { managedEntrypointPath: (0, import_node_path11.resolve)(managedEntrypointPath) } : {},
|
|
11049
11205
|
manager,
|
|
11050
11206
|
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
11051
11207
|
});
|
|
@@ -11058,9 +11214,9 @@ async function assertManagedServiceProvenance(store, candidateEntrypointPath) {
|
|
|
11058
11214
|
const stored = (await store.readServiceManager()).value;
|
|
11059
11215
|
if (!stored || stored.manager === UserServiceManager.None)
|
|
11060
11216
|
return;
|
|
11061
|
-
const candidate = (0,
|
|
11217
|
+
const candidate = (0, import_node_path11.resolve)(candidateEntrypointPath);
|
|
11062
11218
|
if (stored.managedEntrypointPath) {
|
|
11063
|
-
if ((0,
|
|
11219
|
+
if ((0, import_node_path11.resolve)(stored.managedEntrypointPath) !== candidate) {
|
|
11064
11220
|
throw new Error("The managed Connector belongs to a different CLI installation. Run service install from the owning CLI to transfer management.");
|
|
11065
11221
|
}
|
|
11066
11222
|
return;
|
|
@@ -11070,16 +11226,16 @@ async function assertManagedServiceProvenance(store, candidateEntrypointPath) {
|
|
|
11070
11226
|
}
|
|
11071
11227
|
}
|
|
11072
11228
|
async function isInsideSourceCheckout(path4) {
|
|
11073
|
-
let directory = (0,
|
|
11229
|
+
let directory = (0, import_node_path11.dirname)(path4);
|
|
11074
11230
|
while (true) {
|
|
11075
11231
|
try {
|
|
11076
|
-
await (0,
|
|
11232
|
+
await (0, import_promises13.stat)((0, import_node_path11.join)(directory, ".git"));
|
|
11077
11233
|
return true;
|
|
11078
11234
|
} catch (error) {
|
|
11079
11235
|
if (!isNodeErrorCode4(error, "ENOENT"))
|
|
11080
11236
|
throw error;
|
|
11081
11237
|
}
|
|
11082
|
-
const parent = (0,
|
|
11238
|
+
const parent = (0, import_node_path11.dirname)(directory);
|
|
11083
11239
|
if (parent === directory)
|
|
11084
11240
|
return false;
|
|
11085
11241
|
directory = parent;
|
|
@@ -11108,10 +11264,10 @@ function automaticSelectionDetail(manager) {
|
|
|
11108
11264
|
}
|
|
11109
11265
|
async function installLaunchAgent(store, options, runtime) {
|
|
11110
11266
|
const path4 = launchAgentPath();
|
|
11111
|
-
await (0,
|
|
11267
|
+
await (0, import_promises13.mkdir)((0, import_node_path11.dirname)(path4), { recursive: true });
|
|
11112
11268
|
const programArguments = [
|
|
11113
11269
|
options.nodePath,
|
|
11114
|
-
(0,
|
|
11270
|
+
(0, import_node_path11.resolve)(options.entrypointPath),
|
|
11115
11271
|
...options.commandArguments
|
|
11116
11272
|
];
|
|
11117
11273
|
const plist = `<?xml version="1.0" encoding="UTF-8"?>
|
|
@@ -11142,7 +11298,7 @@ ${Object.entries(options.environment).map(([name, value]) => ` <key>${escapeX
|
|
|
11142
11298
|
</dict>
|
|
11143
11299
|
</plist>
|
|
11144
11300
|
`;
|
|
11145
|
-
await (0,
|
|
11301
|
+
await (0, import_promises13.writeFile)(path4, plist, { encoding: "utf8", mode: 384 });
|
|
11146
11302
|
const domain = `gui/${process.getuid?.() ?? 0}`;
|
|
11147
11303
|
await runCommandIgnoringFailure(runtime, "launchctl", [
|
|
11148
11304
|
"bootout",
|
|
@@ -11158,10 +11314,10 @@ ${Object.entries(options.environment).map(([name, value]) => ` <key>${escapeX
|
|
|
11158
11314
|
}
|
|
11159
11315
|
async function installSystemdUserService(store, options, runtime) {
|
|
11160
11316
|
const path4 = systemdUnitPath();
|
|
11161
|
-
await (0,
|
|
11317
|
+
await (0, import_promises13.mkdir)((0, import_node_path11.dirname)(path4), { recursive: true });
|
|
11162
11318
|
const command = [
|
|
11163
11319
|
options.nodePath,
|
|
11164
|
-
(0,
|
|
11320
|
+
(0, import_node_path11.resolve)(options.entrypointPath),
|
|
11165
11321
|
...options.commandArguments
|
|
11166
11322
|
].map(escapeSystemdArgument).join(" ");
|
|
11167
11323
|
const unit = `[Unit]
|
|
@@ -11180,7 +11336,7 @@ ${Object.entries(options.environment).map(([name, value]) => `Environment=${esca
|
|
|
11180
11336
|
[Install]
|
|
11181
11337
|
WantedBy=default.target
|
|
11182
11338
|
`;
|
|
11183
|
-
await (0,
|
|
11339
|
+
await (0, import_promises13.writeFile)(path4, unit, { encoding: "utf8", mode: 384 });
|
|
11184
11340
|
await runtime.run("systemctl", ["--user", "daemon-reload"]);
|
|
11185
11341
|
await runtime.run("systemctl", [
|
|
11186
11342
|
"--user",
|
|
@@ -11196,8 +11352,8 @@ WantedBy=default.target
|
|
|
11196
11352
|
async function installSupervisorUserService(store, options, runtime) {
|
|
11197
11353
|
const directory = supervisorDirectory(store);
|
|
11198
11354
|
const configPath = supervisorConfigPath(store);
|
|
11199
|
-
await (0,
|
|
11200
|
-
await (0,
|
|
11355
|
+
await (0, import_promises13.mkdir)(directory, { recursive: true, mode: 448 });
|
|
11356
|
+
await (0, import_promises13.writeFile)(configPath, createSupervisorConfiguration(store, options), {
|
|
11201
11357
|
encoding: "utf8",
|
|
11202
11358
|
mode: 384
|
|
11203
11359
|
});
|
|
@@ -11211,7 +11367,7 @@ async function installSupervisorUserService(store, options, runtime) {
|
|
|
11211
11367
|
function createSupervisorConfiguration(store, options) {
|
|
11212
11368
|
const command = [
|
|
11213
11369
|
options.nodePath,
|
|
11214
|
-
(0,
|
|
11370
|
+
(0, import_node_path11.resolve)(options.entrypointPath),
|
|
11215
11371
|
...options.commandArguments
|
|
11216
11372
|
].map(escapeSupervisorArgument).join(" ");
|
|
11217
11373
|
const environment = Object.entries(options.environment).map(([name, value]) => `${name}="${escapeSupervisorEnvironment(value)}"`).join(",");
|
|
@@ -11235,7 +11391,7 @@ serverurl=unix://${supervisorSocketPath(store)}
|
|
|
11235
11391
|
|
|
11236
11392
|
[program:${supervisorProgramName}]
|
|
11237
11393
|
command=${command}
|
|
11238
|
-
directory=${escapeSupervisorPath((0,
|
|
11394
|
+
directory=${escapeSupervisorPath((0, import_node_path11.dirname)((0, import_node_path11.resolve)(options.entrypointPath)))}
|
|
11239
11395
|
environment=${environment}
|
|
11240
11396
|
autostart=true
|
|
11241
11397
|
autorestart=true
|
|
@@ -11268,8 +11424,8 @@ async function restartSupervisorUserService(store, runtime) {
|
|
|
11268
11424
|
await startSupervisorUserService(store, runtime, supervisorProcessId, connectorProcessId);
|
|
11269
11425
|
}
|
|
11270
11426
|
async function startSupervisorUserService(store, runtime, previousSupervisorProcessId, previousConnectorProcessId) {
|
|
11271
|
-
await (0,
|
|
11272
|
-
await (0,
|
|
11427
|
+
await (0, import_promises13.rm)(supervisorSocketPath(store), { force: true });
|
|
11428
|
+
await (0, import_promises13.rm)(supervisorPidPath(store), { force: true });
|
|
11273
11429
|
await runtime.run("supervisord", ["-c", supervisorConfigPath(store)], {
|
|
11274
11430
|
environment: sanitizeEnvironment(process.env),
|
|
11275
11431
|
timeoutMilliseconds: serviceManagerMutationTimeoutMilliseconds
|
|
@@ -11366,7 +11522,7 @@ async function currentSupervisorProcessId(store, runtime) {
|
|
|
11366
11522
|
} catch {
|
|
11367
11523
|
}
|
|
11368
11524
|
try {
|
|
11369
|
-
const processId = parseProcessId(await (0,
|
|
11525
|
+
const processId = parseProcessId(await (0, import_promises13.readFile)(supervisorPidPath(store), "utf8"));
|
|
11370
11526
|
return processId !== void 0 && serviceProcessIsRunning(runtime, processId) ? processId : void 0;
|
|
11371
11527
|
} catch (error) {
|
|
11372
11528
|
if (isNodeErrorCode4(error, "ENOENT"))
|
|
@@ -11388,26 +11544,26 @@ async function currentSupervisorProgramProcessId(store, runtime) {
|
|
|
11388
11544
|
}
|
|
11389
11545
|
}
|
|
11390
11546
|
function launchAgentPath() {
|
|
11391
|
-
return (0,
|
|
11547
|
+
return (0, import_node_path11.join)(process.env.HOME ?? (0, import_node_os7.homedir)(), "Library", "LaunchAgents", `${launchAgentLabel}.plist`);
|
|
11392
11548
|
}
|
|
11393
11549
|
function systemdUnitPath() {
|
|
11394
|
-
const configHome = process.env.XDG_CONFIG_HOME ?? (0,
|
|
11395
|
-
return (0,
|
|
11550
|
+
const configHome = process.env.XDG_CONFIG_HOME ?? (0, import_node_path11.join)(process.env.HOME ?? (0, import_node_os7.homedir)(), ".config");
|
|
11551
|
+
return (0, import_node_path11.join)(configHome, "systemd", "user", "moxt-machine-connector.service");
|
|
11396
11552
|
}
|
|
11397
11553
|
function supervisorDirectory(store) {
|
|
11398
|
-
return (0,
|
|
11554
|
+
return (0, import_node_path11.join)(store.baseDirectory, "supervisor");
|
|
11399
11555
|
}
|
|
11400
11556
|
function supervisorConfigPath(store) {
|
|
11401
|
-
return (0,
|
|
11557
|
+
return (0, import_node_path11.join)(supervisorDirectory(store), "supervisord.conf");
|
|
11402
11558
|
}
|
|
11403
11559
|
function supervisorSocketPath(store) {
|
|
11404
|
-
return (0,
|
|
11560
|
+
return (0, import_node_path11.join)(supervisorDirectory(store), "supervisor.sock");
|
|
11405
11561
|
}
|
|
11406
11562
|
function supervisorPidPath(store) {
|
|
11407
|
-
return (0,
|
|
11563
|
+
return (0, import_node_path11.join)(supervisorDirectory(store), "supervisord.pid");
|
|
11408
11564
|
}
|
|
11409
11565
|
function supervisorLogPath(store) {
|
|
11410
|
-
return (0,
|
|
11566
|
+
return (0, import_node_path11.join)(supervisorDirectory(store), "supervisord.log");
|
|
11411
11567
|
}
|
|
11412
11568
|
async function commandSucceeds(runtime, command, argumentsList) {
|
|
11413
11569
|
try {
|
|
@@ -11474,15 +11630,15 @@ function serviceManagerCurrentTime(runtime) {
|
|
|
11474
11630
|
async function serviceManagerDelay(runtime, milliseconds) {
|
|
11475
11631
|
await (runtime.delay?.(milliseconds) ?? delay5(milliseconds));
|
|
11476
11632
|
}
|
|
11477
|
-
var import_node_child_process5,
|
|
11633
|
+
var import_node_child_process5, import_promises13, import_node_os7, import_node_path11, import_node_util2, execFileAsync, launchAgentLabel, serviceManagerProbeTimeoutMilliseconds, serviceManagerMutationTimeoutMilliseconds, supervisorProgramName, supervisorControlTimeoutMilliseconds, supervisorProgramStartSeconds, supervisorProgramStartRetries, supervisorProgramStopWaitSeconds, supervisorLifecycleBufferMilliseconds, supervisorExitTimeoutMilliseconds, supervisorProgramStartTimeoutMilliseconds, ServiceManagerPreference, UserServiceManager, defaultServiceManagerRuntime;
|
|
11478
11634
|
var init_service_manager = __esm({
|
|
11479
11635
|
"../machine-connector/dist/runtime/service-manager.js"() {
|
|
11480
11636
|
"use strict";
|
|
11481
11637
|
init_cjs_shims();
|
|
11482
11638
|
import_node_child_process5 = require("child_process");
|
|
11483
|
-
|
|
11639
|
+
import_promises13 = require("fs/promises");
|
|
11484
11640
|
import_node_os7 = require("os");
|
|
11485
|
-
|
|
11641
|
+
import_node_path11 = require("path");
|
|
11486
11642
|
import_node_util2 = require("util");
|
|
11487
11643
|
init_runtime_types();
|
|
11488
11644
|
init_shell_environment();
|
|
@@ -11576,9 +11732,9 @@ async function reconcileManagedDaemon(options, store = new MachineRuntimeStore()
|
|
|
11576
11732
|
try {
|
|
11577
11733
|
refresh = await refreshManagedUserService(store, {
|
|
11578
11734
|
commandArguments: [...options.commandArguments],
|
|
11579
|
-
entrypointPath: (0,
|
|
11735
|
+
entrypointPath: (0, import_node_path12.resolve)(options.entrypointPath),
|
|
11580
11736
|
environment: { ...options.environment },
|
|
11581
|
-
nodePath: (0,
|
|
11737
|
+
nodePath: (0, import_node_path12.resolve)(options.nodePath)
|
|
11582
11738
|
});
|
|
11583
11739
|
if (!refresh) {
|
|
11584
11740
|
throw new Error("The Connector service is no longer managed by Moxt");
|
|
@@ -11610,10 +11766,10 @@ async function validateCliEntrypoint(options, store) {
|
|
|
11610
11766
|
if (options.commandArguments.length !== 2 || options.commandArguments[0] !== "machine" || options.commandArguments[1] !== "daemon") {
|
|
11611
11767
|
throw new Error("The managed daemon command must be `machine daemon`");
|
|
11612
11768
|
}
|
|
11613
|
-
const nodePath = await (0,
|
|
11614
|
-
const entrypointPath = await (0,
|
|
11615
|
-
await (0,
|
|
11616
|
-
await (0,
|
|
11769
|
+
const nodePath = await (0, import_promises14.realpath)((0, import_node_path12.resolve)(options.nodePath));
|
|
11770
|
+
const entrypointPath = await (0, import_promises14.realpath)((0, import_node_path12.resolve)(options.entrypointPath));
|
|
11771
|
+
await (0, import_promises14.access)(nodePath, import_promises14.constants.X_OK);
|
|
11772
|
+
await (0, import_promises14.access)(entrypointPath, import_promises14.constants.R_OK);
|
|
11617
11773
|
const probe = await execFileAsync2(nodePath, [entrypointPath, "--version"], {
|
|
11618
11774
|
encoding: "utf8",
|
|
11619
11775
|
env: {
|
|
@@ -11646,14 +11802,14 @@ function delay6(milliseconds) {
|
|
|
11646
11802
|
function errorMessage4(error) {
|
|
11647
11803
|
return error instanceof Error ? error.message : String(error);
|
|
11648
11804
|
}
|
|
11649
|
-
var import_node_child_process6,
|
|
11805
|
+
var import_node_child_process6, import_promises14, import_node_path12, import_node_util3, reconcileTimeoutMilliseconds, execFileAsync2, DaemonReconcileOutcome, DaemonRefreshError;
|
|
11650
11806
|
var init_daemon_reconcile = __esm({
|
|
11651
11807
|
"../machine-connector/dist/runtime/daemon-reconcile.js"() {
|
|
11652
11808
|
"use strict";
|
|
11653
11809
|
init_cjs_shims();
|
|
11654
11810
|
import_node_child_process6 = require("child_process");
|
|
11655
|
-
|
|
11656
|
-
|
|
11811
|
+
import_promises14 = require("fs/promises");
|
|
11812
|
+
import_node_path12 = require("path");
|
|
11657
11813
|
import_node_util3 = require("util");
|
|
11658
11814
|
init_local_ipc();
|
|
11659
11815
|
init_process_lock();
|
|
@@ -11710,7 +11866,7 @@ async function runMachineDoctor(store) {
|
|
|
11710
11866
|
}
|
|
11711
11867
|
for (const connection of connections) {
|
|
11712
11868
|
try {
|
|
11713
|
-
await (0,
|
|
11869
|
+
await (0, import_promises15.access)(connection.rootPath, import_node_fs.constants.R_OK | import_node_fs.constants.X_OK);
|
|
11714
11870
|
checks.push({
|
|
11715
11871
|
detail: connection.rootPath,
|
|
11716
11872
|
name: `root:${connection.connectionId}`,
|
|
@@ -11725,7 +11881,7 @@ async function runMachineDoctor(store) {
|
|
|
11725
11881
|
}
|
|
11726
11882
|
const relayUrl = new URL(connection.relayOrigin);
|
|
11727
11883
|
try {
|
|
11728
|
-
const address = await (0,
|
|
11884
|
+
const address = await (0, import_promises16.lookup)(relayUrl.hostname);
|
|
11729
11885
|
checks.push({
|
|
11730
11886
|
detail: `${relayUrl.hostname} resolves to ${address.address}`,
|
|
11731
11887
|
name: `dns:${connection.connectionId}`,
|
|
@@ -11807,15 +11963,15 @@ async function runMachineDoctor(store) {
|
|
|
11807
11963
|
function errorMessage5(error) {
|
|
11808
11964
|
return error instanceof Error ? error.message : String(error);
|
|
11809
11965
|
}
|
|
11810
|
-
var import_node_child_process7,
|
|
11966
|
+
var import_node_child_process7, import_promises15, import_node_fs, import_promises16, import_node_util4, execFileAsync3, DoctorCheckStatus;
|
|
11811
11967
|
var init_doctor = __esm({
|
|
11812
11968
|
"../machine-connector/dist/runtime/doctor.js"() {
|
|
11813
11969
|
"use strict";
|
|
11814
11970
|
init_cjs_shims();
|
|
11815
11971
|
import_node_child_process7 = require("child_process");
|
|
11816
|
-
|
|
11972
|
+
import_promises15 = require("fs/promises");
|
|
11817
11973
|
import_node_fs = require("fs");
|
|
11818
|
-
|
|
11974
|
+
import_promises16 = require("dns/promises");
|
|
11819
11975
|
import_node_util4 = require("util");
|
|
11820
11976
|
init_local_ipc();
|
|
11821
11977
|
execFileAsync3 = (0, import_node_util4.promisify)(import_node_child_process7.execFile);
|
|
@@ -12085,7 +12241,7 @@ async function readRecentLogLines(store) {
|
|
|
12085
12241
|
}
|
|
12086
12242
|
async function readOptionalFile(path4) {
|
|
12087
12243
|
try {
|
|
12088
|
-
return await (0,
|
|
12244
|
+
return await (0, import_promises17.readFile)(path4, "utf8");
|
|
12089
12245
|
} catch (error) {
|
|
12090
12246
|
if (isMissingFile(error)) {
|
|
12091
12247
|
return "";
|
|
@@ -12144,13 +12300,13 @@ function isMissingFile(error) {
|
|
|
12144
12300
|
function errorMessage6(error) {
|
|
12145
12301
|
return error instanceof Error ? error.message : String(error);
|
|
12146
12302
|
}
|
|
12147
|
-
var
|
|
12303
|
+
var import_promises17, import_promises18, import_node_readline, alternateScreenEnter, alternateScreenExit, clearScreen, cursorHide, cursorShow, styleReset, styleHeader, styleSelected, refreshIntervalMilliseconds, maximumLogLines, MachineManagerView, MachineManagerAction, MachineManagerSnapshotDepth, InteractiveMachineManager;
|
|
12148
12304
|
var init_machine_manager = __esm({
|
|
12149
12305
|
"../machine-connector/dist/runtime/machine-manager.js"() {
|
|
12150
12306
|
"use strict";
|
|
12151
12307
|
init_cjs_shims();
|
|
12152
|
-
|
|
12153
|
-
|
|
12308
|
+
import_promises17 = require("fs/promises");
|
|
12309
|
+
import_promises18 = require("readline/promises");
|
|
12154
12310
|
import_node_readline = require("readline");
|
|
12155
12311
|
init_doctor();
|
|
12156
12312
|
init_local_ipc();
|
|
@@ -12384,7 +12540,7 @@ var init_machine_manager = __esm({
|
|
|
12384
12540
|
}
|
|
12385
12541
|
async runCommandAction(action) {
|
|
12386
12542
|
this.suspendTerminal();
|
|
12387
|
-
const reader = (0,
|
|
12543
|
+
const reader = (0, import_promises18.createInterface)({
|
|
12388
12544
|
input: process.stdin,
|
|
12389
12545
|
output: process.stdout
|
|
12390
12546
|
});
|
|
@@ -12625,7 +12781,7 @@ async function pairMachine(store, options) {
|
|
|
12625
12781
|
throw new Error("Local Machine pairing expired");
|
|
12626
12782
|
}
|
|
12627
12783
|
function displayNameForRoot(canonicalRoot) {
|
|
12628
|
-
const name = (0,
|
|
12784
|
+
const name = (0, import_node_path13.basename)(canonicalRoot);
|
|
12629
12785
|
return name.length > 0 ? name : canonicalRoot;
|
|
12630
12786
|
}
|
|
12631
12787
|
function getOperatingSystem() {
|
|
@@ -12647,7 +12803,7 @@ function delay7(milliseconds) {
|
|
|
12647
12803
|
setTimeout(resolvePromise, milliseconds);
|
|
12648
12804
|
});
|
|
12649
12805
|
}
|
|
12650
|
-
var import_node_child_process8, import_node_crypto11, import_node_os8,
|
|
12806
|
+
var import_node_child_process8, import_node_crypto11, import_node_os8, import_node_path13, connectedPairingStatus, rejectedPairingStatus, expiredPairingStatus, pairingPollMilliseconds;
|
|
12651
12807
|
var init_pairing = __esm({
|
|
12652
12808
|
"../machine-connector/dist/runtime/pairing.js"() {
|
|
12653
12809
|
"use strict";
|
|
@@ -12655,7 +12811,7 @@ var init_pairing = __esm({
|
|
|
12655
12811
|
import_node_child_process8 = require("child_process");
|
|
12656
12812
|
import_node_crypto11 = require("crypto");
|
|
12657
12813
|
import_node_os8 = require("os");
|
|
12658
|
-
|
|
12814
|
+
import_node_path13 = require("path");
|
|
12659
12815
|
init_contracts();
|
|
12660
12816
|
init_version();
|
|
12661
12817
|
init_enums();
|
|
@@ -12743,7 +12899,7 @@ function isMachineLifecycleMutation(command, commandArguments) {
|
|
|
12743
12899
|
async function connectCommand(store, argumentsList, entrypoint) {
|
|
12744
12900
|
const options = parseOptions(argumentsList);
|
|
12745
12901
|
const connectionCode = requiredOption(options, "code");
|
|
12746
|
-
const rootPath = (0,
|
|
12902
|
+
const rootPath = (0, import_node_path14.resolve)(options.root ?? process.cwd());
|
|
12747
12903
|
const serviceManagerPreference = requestedServiceManagerPreference(options);
|
|
12748
12904
|
await validateExplicitServiceManagerPreference(serviceManagerPreference);
|
|
12749
12905
|
writeLine("Internal Full Host Access: enabled");
|
|
@@ -13029,7 +13185,7 @@ async function waitForDaemonOnline(store) {
|
|
|
13029
13185
|
}
|
|
13030
13186
|
async function readOptionalFile2(path4) {
|
|
13031
13187
|
try {
|
|
13032
|
-
return await (0,
|
|
13188
|
+
return await (0, import_promises19.readFile)(path4, "utf8");
|
|
13033
13189
|
} catch {
|
|
13034
13190
|
return "";
|
|
13035
13191
|
}
|
|
@@ -13058,13 +13214,13 @@ function delay8(milliseconds) {
|
|
|
13058
13214
|
setTimeout(resolvePromise, milliseconds);
|
|
13059
13215
|
});
|
|
13060
13216
|
}
|
|
13061
|
-
var
|
|
13217
|
+
var import_promises19, import_node_path14, defaultRelayOrigin;
|
|
13062
13218
|
var init_cli = __esm({
|
|
13063
13219
|
"../machine-connector/dist/cli.js"() {
|
|
13064
13220
|
"use strict";
|
|
13065
13221
|
init_cjs_shims();
|
|
13066
|
-
|
|
13067
|
-
|
|
13222
|
+
import_promises19 = require("fs/promises");
|
|
13223
|
+
import_node_path14 = require("path");
|
|
13068
13224
|
init_daemon();
|
|
13069
13225
|
init_daemon_reconcile();
|
|
13070
13226
|
init_doctor();
|
|
@@ -13358,7 +13514,7 @@ function getApiKeyOrUndefined() {
|
|
|
13358
13514
|
|
|
13359
13515
|
// src/utils/http.ts
|
|
13360
13516
|
function getUserAgent() {
|
|
13361
|
-
return `moxt-cli/${"0.10.0-beta.
|
|
13517
|
+
return `moxt-cli/${"0.10.0-beta.4"} (${(0, import_os.platform)()}/${(0, import_os.arch)()}) node/${process.versions.node}`;
|
|
13362
13518
|
}
|
|
13363
13519
|
async function sendRequest(method, path4, init) {
|
|
13364
13520
|
return await fetch(`${getApiBaseUrl()}${path4}`, {
|
|
@@ -26941,7 +27097,7 @@ var FLUSH_TIMEOUT_MS = 3e3;
|
|
|
26941
27097
|
var MAX_BATCH_SIZE = 100;
|
|
26942
27098
|
function commonLabels() {
|
|
26943
27099
|
return {
|
|
26944
|
-
cli_version: "0.10.0-beta.
|
|
27100
|
+
cli_version: "0.10.0-beta.4",
|
|
26945
27101
|
node_version: process.versions.node,
|
|
26946
27102
|
os: (0, import_node_os9.platform)(),
|
|
26947
27103
|
arch: (0, import_node_os9.arch)(),
|
|
@@ -26987,7 +27143,7 @@ async function flush() {
|
|
|
26987
27143
|
}
|
|
26988
27144
|
const batch = buffer.splice(0, MAX_BATCH_SIZE);
|
|
26989
27145
|
const payload = {
|
|
26990
|
-
release_id: "0.10.0-beta.
|
|
27146
|
+
release_id: "0.10.0-beta.4",
|
|
26991
27147
|
client_type: "cli",
|
|
26992
27148
|
metric_data_list: batch.map((m) => ({
|
|
26993
27149
|
profile: "cli",
|
|
@@ -27188,7 +27344,7 @@ function registryWorker() {
|
|
|
27188
27344
|
|
|
27189
27345
|
// src/update/prompt.ts
|
|
27190
27346
|
init_cjs_shims();
|
|
27191
|
-
var
|
|
27347
|
+
var import_promises20 = require("readline/promises");
|
|
27192
27348
|
async function promptForUpdate(input, output, currentVersion, latestVersion, timeoutMs) {
|
|
27193
27349
|
output.write(`
|
|
27194
27350
|
A new version of Moxt CLI is available: ${currentVersion} \u2192 ${latestVersion}
|
|
@@ -27201,7 +27357,7 @@ A new version of Moxt CLI is available: ${currentVersion} \u2192 ${latestVersion
|
|
|
27201
27357
|
const controller = new AbortController();
|
|
27202
27358
|
const timeout = setTimeout(() => controller.abort(), timeoutMs);
|
|
27203
27359
|
timeout.unref();
|
|
27204
|
-
const readline = (0,
|
|
27360
|
+
const readline = (0, import_promises20.createInterface)({ input, output, terminal: true });
|
|
27205
27361
|
try {
|
|
27206
27362
|
const answer = await readline.question("", { signal: controller.signal });
|
|
27207
27363
|
if (answer.trim() === "1") return "update";
|
|
@@ -27304,7 +27460,7 @@ function commandPath2(command) {
|
|
|
27304
27460
|
|
|
27305
27461
|
// src/update/daemon-reconcile-hook.ts
|
|
27306
27462
|
init_cjs_shims();
|
|
27307
|
-
var
|
|
27463
|
+
var import_node_path15 = require("path");
|
|
27308
27464
|
function installDaemonReconcileHook(program3, cliVersion) {
|
|
27309
27465
|
program3.hook("preAction", async (_thisCommand, actionCommand) => {
|
|
27310
27466
|
if (!isEligible2(actionCommand)) return;
|
|
@@ -27326,9 +27482,9 @@ function installDaemonReconcileHook(program3, cliVersion) {
|
|
|
27326
27482
|
await reconcileManagedDaemon2({
|
|
27327
27483
|
cliVersion,
|
|
27328
27484
|
commandArguments: ["machine", "daemon"],
|
|
27329
|
-
entrypointPath: (0,
|
|
27485
|
+
entrypointPath: (0, import_node_path15.resolve)(entrypointPath),
|
|
27330
27486
|
environment: {},
|
|
27331
|
-
nodePath: (0,
|
|
27487
|
+
nodePath: (0, import_node_path15.resolve)(process.execPath),
|
|
27332
27488
|
onActiveJobs: (count) => {
|
|
27333
27489
|
process.stderr.write(
|
|
27334
27490
|
`Warning: restarting the managed Connector will interrupt ${count} active ${count === 1 ? "Job" : "Jobs"}.
|
|
@@ -27370,9 +27526,9 @@ function commandPath3(command) {
|
|
|
27370
27526
|
}
|
|
27371
27527
|
|
|
27372
27528
|
// src/index.ts
|
|
27373
|
-
var program2 = createProgram("0.10.0-beta.
|
|
27374
|
-
installDaemonReconcileHook(program2, "0.10.0-beta.
|
|
27375
|
-
installUpdateHook(program2, "0.10.0-beta.
|
|
27529
|
+
var program2 = createProgram("0.10.0-beta.4");
|
|
27530
|
+
installDaemonReconcileHook(program2, "0.10.0-beta.4");
|
|
27531
|
+
installUpdateHook(program2, "0.10.0-beta.4");
|
|
27376
27532
|
instrumentProgram(program2);
|
|
27377
27533
|
installExitHandler();
|
|
27378
27534
|
program2.parseAsync(process.argv).then(async () => {
|