@moxt-ai/cli 0.9.1 → 0.10.0-beta.1
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 +70 -22
- package/dist/index.cjs.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -7321,6 +7321,12 @@ var init_contracts2 = __esm({
|
|
|
7321
7321
|
});
|
|
7322
7322
|
|
|
7323
7323
|
// ../machine-connector/dist/runtime/local-codex-runtime/app-server-client.js
|
|
7324
|
+
function appServerResponseMessage(response) {
|
|
7325
|
+
if (typeof response === "object" && response !== null && "message" in response && typeof response.message === "string") {
|
|
7326
|
+
return response.message;
|
|
7327
|
+
}
|
|
7328
|
+
return "";
|
|
7329
|
+
}
|
|
7324
7330
|
function rpcIdentifier(value) {
|
|
7325
7331
|
if (typeof value === "string") {
|
|
7326
7332
|
return { value };
|
|
@@ -7383,7 +7389,7 @@ function killAppServerProcess(child) {
|
|
|
7383
7389
|
child.kill("SIGKILL");
|
|
7384
7390
|
}
|
|
7385
7391
|
}
|
|
7386
|
-
var import_node_child_process3, import_node_crypto6, import_node_os5, maximumFrameBytes, requestTimeoutMilliseconds2, AppServerProcessLostError, AppServerProtocolError, AppServerRequestTimeoutError, AppServerClient, LocalCodexAppServerSupervisor;
|
|
7392
|
+
var import_node_child_process3, import_node_crypto6, import_node_os5, maximumFrameBytes, requestTimeoutMilliseconds2, AppServerProcessLostError, AppServerProtocolError, AppServerRequestTimeoutError, AppServerResponseError, AppServerClient, LocalCodexAppServerSupervisor;
|
|
7387
7393
|
var init_app_server_client = __esm({
|
|
7388
7394
|
"../machine-connector/dist/runtime/local-codex-runtime/app-server-client.js"() {
|
|
7389
7395
|
"use strict";
|
|
@@ -7415,6 +7421,15 @@ var init_app_server_client = __esm({
|
|
|
7415
7421
|
this.name = "AppServerRequestTimeoutError";
|
|
7416
7422
|
}
|
|
7417
7423
|
};
|
|
7424
|
+
AppServerResponseError = class extends AppServerProtocolError {
|
|
7425
|
+
responseMessage;
|
|
7426
|
+
constructor(response) {
|
|
7427
|
+
const responseMessage = appServerResponseMessage(response);
|
|
7428
|
+
super(`Codex App Server rejected request: ${JSON.stringify(response)}`);
|
|
7429
|
+
this.name = "AppServerResponseError";
|
|
7430
|
+
this.responseMessage = responseMessage;
|
|
7431
|
+
}
|
|
7432
|
+
};
|
|
7418
7433
|
AppServerClient = class _AppServerClient {
|
|
7419
7434
|
child;
|
|
7420
7435
|
handlers;
|
|
@@ -7574,7 +7589,7 @@ var init_app_server_client = __esm({
|
|
|
7574
7589
|
this.pending.delete(responseId);
|
|
7575
7590
|
clearTimeout(pending.timeout);
|
|
7576
7591
|
if (message.error !== void 0) {
|
|
7577
|
-
pending.reject(new
|
|
7592
|
+
pending.reject(new AppServerResponseError(message.error));
|
|
7578
7593
|
} else {
|
|
7579
7594
|
pending.resolve(message.result);
|
|
7580
7595
|
}
|
|
@@ -8256,6 +8271,9 @@ var init_event_normalizer = __esm({
|
|
|
8256
8271
|
});
|
|
8257
8272
|
|
|
8258
8273
|
// ../machine-connector/dist/runtime/local-codex-runtime/runtime-worker.js
|
|
8274
|
+
function isMissingThreadResponse(message, threadId) {
|
|
8275
|
+
return message === `thread not found: ${threadId}` || message === `no rollout found for thread id ${threadId}` || message === `no rollout found for conversation id ${threadId}`;
|
|
8276
|
+
}
|
|
8259
8277
|
function createActiveAttempt(claim, durable, workingDirectory) {
|
|
8260
8278
|
let resolveTerminal = (_value) => void 0;
|
|
8261
8279
|
const terminal = new Promise((resolve9) => {
|
|
@@ -8780,9 +8798,19 @@ var init_runtime_worker = __esm({
|
|
|
8780
8798
|
const controlLoop = this.runControlLoop(active);
|
|
8781
8799
|
try {
|
|
8782
8800
|
active.workingDirectory = await resolveCanonicalWorkingDirectory(this.connection.rootPath, claim.relativeWorkingDirectory);
|
|
8783
|
-
|
|
8801
|
+
let client = await this.processPool.ensureStarted();
|
|
8784
8802
|
const isNewThread = active.nativeThreadId === void 0;
|
|
8785
|
-
|
|
8803
|
+
let nativeThreadId;
|
|
8804
|
+
try {
|
|
8805
|
+
nativeThreadId = await this.prepareThread(client, active);
|
|
8806
|
+
} catch (error) {
|
|
8807
|
+
if (!(error instanceof AppServerRequestTimeoutError) || error.method !== "thread/resume") {
|
|
8808
|
+
throw error;
|
|
8809
|
+
}
|
|
8810
|
+
await this.processPool.quarantineCurrentProcess();
|
|
8811
|
+
client = await this.processPool.ensureStarted();
|
|
8812
|
+
nativeThreadId = await this.prepareThread(client, active);
|
|
8813
|
+
}
|
|
8786
8814
|
active.nativeThreadId = nativeThreadId;
|
|
8787
8815
|
await durable.markThreadPrepared(nativeThreadId);
|
|
8788
8816
|
await active.spoolQueue;
|
|
@@ -8840,7 +8868,6 @@ var init_runtime_worker = __esm({
|
|
|
8840
8868
|
});
|
|
8841
8869
|
await durable.markUploaded();
|
|
8842
8870
|
await this.store.deleteLocalCodexAttempt(claim.attemptId);
|
|
8843
|
-
await this.unsubscribe(client, nativeThreadId);
|
|
8844
8871
|
} catch (error) {
|
|
8845
8872
|
if (error instanceof LeaseLostError) {
|
|
8846
8873
|
await this.logger.error(`Local Codex attempt ${claim.attemptId} stopped after losing its execution lease`, error);
|
|
@@ -8872,7 +8899,12 @@ var init_runtime_worker = __esm({
|
|
|
8872
8899
|
};
|
|
8873
8900
|
const preparedThreadId = active.nativeThreadId;
|
|
8874
8901
|
if (preparedThreadId === void 0) {
|
|
8875
|
-
|
|
8902
|
+
const startedThreadId = requireThreadId(await client.request("thread/start", parameters));
|
|
8903
|
+
this.processPool.rememberThreadLoaded(startedThreadId);
|
|
8904
|
+
return startedThreadId;
|
|
8905
|
+
}
|
|
8906
|
+
if (this.processPool.isThreadLoaded(preparedThreadId)) {
|
|
8907
|
+
return preparedThreadId;
|
|
8876
8908
|
}
|
|
8877
8909
|
try {
|
|
8878
8910
|
const resumed = await client.request("thread/resume", {
|
|
@@ -8883,12 +8915,16 @@ var init_runtime_worker = __esm({
|
|
|
8883
8915
|
if (resumedId !== preparedThreadId) {
|
|
8884
8916
|
throw new AppServerProtocolError("thread/resume returned another native thread");
|
|
8885
8917
|
}
|
|
8918
|
+
this.processPool.rememberThreadLoaded(resumedId);
|
|
8886
8919
|
return resumedId;
|
|
8887
8920
|
} catch (error) {
|
|
8888
|
-
if (error instanceof AppServerProcessLostError) {
|
|
8921
|
+
if (error instanceof AppServerProcessLostError || error instanceof AppServerRequestTimeoutError) {
|
|
8889
8922
|
throw error;
|
|
8890
8923
|
}
|
|
8891
|
-
|
|
8924
|
+
if (error instanceof AppServerResponseError && isMissingThreadResponse(error.responseMessage, preparedThreadId)) {
|
|
8925
|
+
throw new ThreadUnavailableError(errorMessage2(error));
|
|
8926
|
+
}
|
|
8927
|
+
throw error;
|
|
8892
8928
|
}
|
|
8893
8929
|
}
|
|
8894
8930
|
async failAttempt(active, error) {
|
|
@@ -9243,7 +9279,9 @@ var init_runtime_worker = __esm({
|
|
|
9243
9279
|
await action();
|
|
9244
9280
|
});
|
|
9245
9281
|
active.spoolQueue = operation.catch((error) => {
|
|
9246
|
-
const failure = new SpoolPersistenceError(`Durable Local Codex spool failed: ${errorMessage2(error)}`, {
|
|
9282
|
+
const failure = new SpoolPersistenceError(`Durable Local Codex spool failed: ${errorMessage2(error)}`, {
|
|
9283
|
+
cause: error
|
|
9284
|
+
});
|
|
9247
9285
|
this.signalFatal(active, failure);
|
|
9248
9286
|
});
|
|
9249
9287
|
return operation;
|
|
@@ -9302,13 +9340,6 @@ var init_runtime_worker = __esm({
|
|
|
9302
9340
|
await this.logger.error(`Failed to name Local Codex thread ${threadId}`, error);
|
|
9303
9341
|
}
|
|
9304
9342
|
}
|
|
9305
|
-
async unsubscribe(client, threadId) {
|
|
9306
|
-
try {
|
|
9307
|
-
await client.request("thread/unsubscribe", { threadId });
|
|
9308
|
-
} catch {
|
|
9309
|
-
return;
|
|
9310
|
-
}
|
|
9311
|
-
}
|
|
9312
9343
|
unregisterRoute() {
|
|
9313
9344
|
if (!this.registered) {
|
|
9314
9345
|
return;
|
|
@@ -9343,6 +9374,7 @@ var init_process_pool = __esm({
|
|
|
9343
9374
|
poolKey;
|
|
9344
9375
|
logger;
|
|
9345
9376
|
activeOwner = {};
|
|
9377
|
+
loadedThreadIds = /* @__PURE__ */ new Set();
|
|
9346
9378
|
routes = /* @__PURE__ */ new Map();
|
|
9347
9379
|
retiredTurnIds = /* @__PURE__ */ new Set();
|
|
9348
9380
|
supervisor;
|
|
@@ -9358,6 +9390,7 @@ var init_process_pool = __esm({
|
|
|
9358
9390
|
if (!this.supervisor.markProcessLost(processGeneration)) {
|
|
9359
9391
|
return;
|
|
9360
9392
|
}
|
|
9393
|
+
this.loadedThreadIds.clear();
|
|
9361
9394
|
await this.logger.error(`Shared Codex App Server generation ${processGeneration} exited`, error);
|
|
9362
9395
|
await this.activeRoute().value?.onProcessExit(error);
|
|
9363
9396
|
},
|
|
@@ -9432,6 +9465,19 @@ var init_process_pool = __esm({
|
|
|
9432
9465
|
isRetiredTurn(nativeTurnId) {
|
|
9433
9466
|
return this.retiredTurnIds.has(nativeTurnId);
|
|
9434
9467
|
}
|
|
9468
|
+
isThreadLoaded(nativeThreadId) {
|
|
9469
|
+
return this.loadedThreadIds.has(nativeThreadId);
|
|
9470
|
+
}
|
|
9471
|
+
rememberThreadLoaded(nativeThreadId) {
|
|
9472
|
+
this.loadedThreadIds.add(nativeThreadId);
|
|
9473
|
+
if (this.loadedThreadIds.size <= 4096) {
|
|
9474
|
+
return;
|
|
9475
|
+
}
|
|
9476
|
+
const oldest = this.loadedThreadIds.values().next().value;
|
|
9477
|
+
if (typeof oldest === "string") {
|
|
9478
|
+
this.loadedThreadIds.delete(oldest);
|
|
9479
|
+
}
|
|
9480
|
+
}
|
|
9435
9481
|
status() {
|
|
9436
9482
|
return this.supervisor.status();
|
|
9437
9483
|
}
|
|
@@ -9442,9 +9488,11 @@ var init_process_pool = __esm({
|
|
|
9442
9488
|
return await this.supervisor.ensureStarted();
|
|
9443
9489
|
}
|
|
9444
9490
|
async quarantineCurrentProcess() {
|
|
9491
|
+
this.loadedThreadIds.clear();
|
|
9445
9492
|
await this.supervisor.quarantineCurrentProcess();
|
|
9446
9493
|
}
|
|
9447
9494
|
async stop() {
|
|
9495
|
+
this.loadedThreadIds.clear();
|
|
9448
9496
|
await this.supervisor.stop();
|
|
9449
9497
|
}
|
|
9450
9498
|
activeRoute() {
|
|
@@ -13141,7 +13189,7 @@ function getApiKeyOrUndefined() {
|
|
|
13141
13189
|
|
|
13142
13190
|
// src/utils/http.ts
|
|
13143
13191
|
function getUserAgent() {
|
|
13144
|
-
return `moxt-cli/${"0.
|
|
13192
|
+
return `moxt-cli/${"0.10.0-beta.1"} (${(0, import_os.platform)()}/${(0, import_os.arch)()}) node/${process.versions.node}`;
|
|
13145
13193
|
}
|
|
13146
13194
|
async function sendRequest(method, path4, init) {
|
|
13147
13195
|
return await fetch(`${getApiBaseUrl()}${path4}`, {
|
|
@@ -26724,7 +26772,7 @@ var FLUSH_TIMEOUT_MS = 3e3;
|
|
|
26724
26772
|
var MAX_BATCH_SIZE = 100;
|
|
26725
26773
|
function commonLabels() {
|
|
26726
26774
|
return {
|
|
26727
|
-
cli_version: "0.
|
|
26775
|
+
cli_version: "0.10.0-beta.1",
|
|
26728
26776
|
node_version: process.versions.node,
|
|
26729
26777
|
os: (0, import_node_os9.platform)(),
|
|
26730
26778
|
arch: (0, import_node_os9.arch)(),
|
|
@@ -26770,7 +26818,7 @@ async function flush() {
|
|
|
26770
26818
|
}
|
|
26771
26819
|
const batch = buffer.splice(0, MAX_BATCH_SIZE);
|
|
26772
26820
|
const payload = {
|
|
26773
|
-
release_id: "0.
|
|
26821
|
+
release_id: "0.10.0-beta.1",
|
|
26774
26822
|
client_type: "cli",
|
|
26775
26823
|
metric_data_list: batch.map((m) => ({
|
|
26776
26824
|
profile: "cli",
|
|
@@ -27153,9 +27201,9 @@ function commandPath3(command) {
|
|
|
27153
27201
|
}
|
|
27154
27202
|
|
|
27155
27203
|
// src/index.ts
|
|
27156
|
-
var program2 = createProgram("0.
|
|
27157
|
-
installDaemonReconcileHook(program2, "0.
|
|
27158
|
-
installUpdateHook(program2, "0.
|
|
27204
|
+
var program2 = createProgram("0.10.0-beta.1");
|
|
27205
|
+
installDaemonReconcileHook(program2, "0.10.0-beta.1");
|
|
27206
|
+
installUpdateHook(program2, "0.10.0-beta.1");
|
|
27159
27207
|
instrumentProgram(program2);
|
|
27160
27208
|
installExitHandler();
|
|
27161
27209
|
program2.parseAsync(process.argv).then(async () => {
|