@moxt-ai/mobius 0.0.79 → 0.0.80
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/acp/codex/agent.d.ts +2 -1
- package/dist/acp/codex/agent.d.ts.map +1 -1
- package/dist/acp/codex/agent.js +42 -7
- package/dist/acp/codex/agent.js.map +1 -1
- package/dist/acp/codex/app-server-client.d.ts +4 -2
- package/dist/acp/codex/app-server-client.d.ts.map +1 -1
- package/dist/acp/codex/app-server-client.js +50 -31
- package/dist/acp/codex/app-server-client.js.map +1 -1
- package/dist/acp/in-process/acp-endpoint.d.ts +10 -0
- package/dist/acp/in-process/acp-endpoint.d.ts.map +1 -1
- package/dist/acp/in-process/acp-endpoint.js +13 -1
- package/dist/acp/in-process/acp-endpoint.js.map +1 -1
- package/dist/acp/session-manager.d.ts.map +1 -1
- package/dist/acp/session-manager.js +17 -8
- package/dist/acp/session-manager.js.map +1 -1
- package/dist/agent-catalog/acp-readiness-probe.d.ts.map +1 -1
- package/dist/agent-catalog/acp-readiness-probe.js +24 -9
- package/dist/agent-catalog/acp-readiness-probe.js.map +1 -1
- package/dist/cli.js +154 -63
- package/dist/cli.js.map +4 -4
- package/dist/index.js +153 -62
- package/dist/index.js.map +4 -4
- package/dist/runtime.js +153 -62
- package/dist/runtime.js.map +4 -4
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -23304,6 +23304,20 @@ var AcpActivityTracker = class {
|
|
|
23304
23304
|
};
|
|
23305
23305
|
};
|
|
23306
23306
|
|
|
23307
|
+
// src/acp/in-process/acp-endpoint.ts
|
|
23308
|
+
function acpEndpointTerminationError(termination) {
|
|
23309
|
+
switch (termination.kind) {
|
|
23310
|
+
case "failed":
|
|
23311
|
+
return termination.error;
|
|
23312
|
+
case "closed":
|
|
23313
|
+
return new AcpExecutionError("The ACP endpoint is closed", {}, "acp_endpoint_closed");
|
|
23314
|
+
default: {
|
|
23315
|
+
const unreachable = termination;
|
|
23316
|
+
return unreachable;
|
|
23317
|
+
}
|
|
23318
|
+
}
|
|
23319
|
+
}
|
|
23320
|
+
|
|
23307
23321
|
// ../../node_modules/.pnpm/mdast-util-to-string@4.0.0/node_modules/mdast-util-to-string/lib/index.js
|
|
23308
23322
|
var emptyOptions = {};
|
|
23309
23323
|
function toString(value, options) {
|
|
@@ -31877,8 +31891,8 @@ var AcpProcessSession = class _AcpProcessSession {
|
|
|
31877
31891
|
#pendingElicitations = /* @__PURE__ */ new Map();
|
|
31878
31892
|
#pendingPermissions = /* @__PURE__ */ new Map();
|
|
31879
31893
|
#preSessionUpdates = [];
|
|
31880
|
-
//
|
|
31881
|
-
#
|
|
31894
|
+
// Both topologies report a terminal outcome, even after a prompt's initial RPC is acknowledged.
|
|
31895
|
+
#termination;
|
|
31882
31896
|
#runtimeChild;
|
|
31883
31897
|
#metrics;
|
|
31884
31898
|
#sessionConfigProtocol;
|
|
@@ -31922,8 +31936,7 @@ var AcpProcessSession = class _AcpProcessSession {
|
|
|
31922
31936
|
});
|
|
31923
31937
|
this.#inProcessAgent = inProcess;
|
|
31924
31938
|
this.#runtimeChild = null;
|
|
31925
|
-
this.#
|
|
31926
|
-
});
|
|
31939
|
+
this.#termination = inProcess.terminated;
|
|
31927
31940
|
this.#connection = createAcpClient(this).connect(inProcess.app());
|
|
31928
31941
|
return;
|
|
31929
31942
|
}
|
|
@@ -31947,9 +31960,16 @@ var AcpProcessSession = class _AcpProcessSession {
|
|
|
31947
31960
|
stderr.on("data", (chunk) => {
|
|
31948
31961
|
process.stderr.write(`[${agent.id}-acp] ${chunk}`);
|
|
31949
31962
|
});
|
|
31950
|
-
this.#
|
|
31951
|
-
child.once("error",
|
|
31952
|
-
|
|
31963
|
+
this.#termination = new Promise((resolve8) => {
|
|
31964
|
+
child.once("error", (cause) => {
|
|
31965
|
+
resolve8({ kind: "failed", error: new AcpExecutionError("The ACP process could not run", { cause }) });
|
|
31966
|
+
});
|
|
31967
|
+
child.once("exit", (code, signal) => {
|
|
31968
|
+
resolve8({
|
|
31969
|
+
kind: "failed",
|
|
31970
|
+
error: new AcpExecutionError("The ACP process stopped", { cause: { code, signal } })
|
|
31971
|
+
});
|
|
31972
|
+
});
|
|
31953
31973
|
});
|
|
31954
31974
|
const stream = ndJsonStream(createWritableAcpStream(stdin), readableWebStream(stdout));
|
|
31955
31975
|
this.#connection = createAcpClient(this).connect(stream);
|
|
@@ -33091,8 +33111,9 @@ var AcpProcessSession = class _AcpProcessSession {
|
|
|
33091
33111
|
try {
|
|
33092
33112
|
return await Promise.race([
|
|
33093
33113
|
operation,
|
|
33094
|
-
this.#
|
|
33095
|
-
|
|
33114
|
+
this.#termination.then((termination) => {
|
|
33115
|
+
const cause = acpEndpointTerminationError(termination);
|
|
33116
|
+
throw new AcpExecutionError(exitMessage, { cause }, cause.code);
|
|
33096
33117
|
}),
|
|
33097
33118
|
aborted2
|
|
33098
33119
|
]);
|
|
@@ -35048,11 +35069,9 @@ var threadSettingsUpdatedSchema = external_exports.object({
|
|
|
35048
35069
|
// src/acp/codex/app-server-client.ts
|
|
35049
35070
|
var INITIALIZE_TIMEOUT_MILLISECONDS = 3e4;
|
|
35050
35071
|
var OUTPUT_LIMIT_BYTES = 32 * 1024 * 1024;
|
|
35051
|
-
var CodexAppServerError = class extends
|
|
35052
|
-
code;
|
|
35072
|
+
var CodexAppServerError = class extends AcpExecutionError {
|
|
35053
35073
|
constructor(code, message, options = {}) {
|
|
35054
|
-
super(message, options);
|
|
35055
|
-
this.code = code;
|
|
35074
|
+
super(message, options, code);
|
|
35056
35075
|
this.name = "CodexAppServerError";
|
|
35057
35076
|
}
|
|
35058
35077
|
};
|
|
@@ -35060,12 +35079,14 @@ var CodexAppServerClient = class {
|
|
|
35060
35079
|
#child;
|
|
35061
35080
|
#handlers;
|
|
35062
35081
|
#pending = /* @__PURE__ */ new Map();
|
|
35063
|
-
#
|
|
35064
|
-
|
|
35082
|
+
#termination = Promise.withResolvers();
|
|
35083
|
+
terminated = this.#termination.promise;
|
|
35084
|
+
#lifecycle = {
|
|
35085
|
+
kind: "open"
|
|
35086
|
+
};
|
|
35065
35087
|
#nextRequestId = 1;
|
|
35066
35088
|
#pendingBuffer = "";
|
|
35067
35089
|
#receivedBytes = 0;
|
|
35068
|
-
#closed = false;
|
|
35069
35090
|
constructor(options) {
|
|
35070
35091
|
this.#handlers = options.handlers;
|
|
35071
35092
|
this.#child = spawn3(options.command, ["app-server"], {
|
|
@@ -35090,21 +35111,56 @@ var CodexAppServerClient = class {
|
|
|
35090
35111
|
stderr.on("data", (chunk) => {
|
|
35091
35112
|
process.stderr.write(`[codex-app-server] ${chunk}`);
|
|
35092
35113
|
});
|
|
35093
|
-
this.#
|
|
35094
|
-
this.#
|
|
35095
|
-
|
|
35114
|
+
this.#child.once("error", (cause) => {
|
|
35115
|
+
this.#fail(
|
|
35116
|
+
new CodexAppServerError("codex_app_server_exited", "The Codex app-server could not run", { cause })
|
|
35117
|
+
);
|
|
35118
|
+
});
|
|
35119
|
+
this.#child.once("exit", (code, signal) => {
|
|
35120
|
+
this.#fail(
|
|
35121
|
+
new CodexAppServerError("codex_app_server_exited", "The Codex app-server stopped", {
|
|
35122
|
+
cause: { code, signal }
|
|
35123
|
+
})
|
|
35124
|
+
);
|
|
35125
|
+
});
|
|
35126
|
+
for (const stream of [stdin, stdout, stderr]) {
|
|
35127
|
+
stream.on("error", (cause) => {
|
|
35128
|
+
this.#fail(
|
|
35129
|
+
new CodexAppServerError("codex_app_server_io_error", "The Codex app-server connection failed", {
|
|
35130
|
+
cause
|
|
35131
|
+
})
|
|
35132
|
+
);
|
|
35133
|
+
});
|
|
35134
|
+
}
|
|
35135
|
+
stdout.once("end", () => {
|
|
35136
|
+
this.#fail(new CodexAppServerError("codex_app_server_exited", "The Codex app-server output closed"));
|
|
35096
35137
|
});
|
|
35097
35138
|
}
|
|
35098
35139
|
child = () => this.#child;
|
|
35099
35140
|
#fail = (error62) => {
|
|
35100
|
-
this.#
|
|
35141
|
+
this.#terminate({ kind: "failed", error: error62 });
|
|
35142
|
+
};
|
|
35143
|
+
#terminate = (result) => {
|
|
35144
|
+
if (this.#lifecycle.kind === "terminated") {
|
|
35145
|
+
return;
|
|
35146
|
+
}
|
|
35147
|
+
this.#lifecycle = { kind: "terminated", result };
|
|
35148
|
+
this.#termination.resolve(result);
|
|
35149
|
+
const error62 = acpEndpointTerminationError(result);
|
|
35101
35150
|
for (const [id, pending] of this.#pending) {
|
|
35102
35151
|
this.#pending.delete(id);
|
|
35103
35152
|
pending.completion.reject(error62);
|
|
35104
35153
|
}
|
|
35105
35154
|
};
|
|
35106
|
-
#
|
|
35155
|
+
#requireOpen = () => {
|
|
35156
|
+
if (this.#lifecycle.kind === "terminated") {
|
|
35157
|
+
throw acpEndpointTerminationError(this.#lifecycle.result);
|
|
35158
|
+
}
|
|
35159
|
+
};
|
|
35107
35160
|
#consume = (chunk) => {
|
|
35161
|
+
if (this.#lifecycle.kind === "terminated") {
|
|
35162
|
+
return;
|
|
35163
|
+
}
|
|
35108
35164
|
try {
|
|
35109
35165
|
this.#receivedBytes += Buffer.byteLength(chunk);
|
|
35110
35166
|
if (this.#receivedBytes > OUTPUT_LIMIT_BYTES) {
|
|
@@ -35133,7 +35189,6 @@ var CodexAppServerClient = class {
|
|
|
35133
35189
|
{ cause: error62 }
|
|
35134
35190
|
)
|
|
35135
35191
|
);
|
|
35136
|
-
this.#child.kill("SIGKILL");
|
|
35137
35192
|
}
|
|
35138
35193
|
};
|
|
35139
35194
|
// Handler failures are recorded as the app-server's terminal failure: an ACP client that cannot
|
|
@@ -35183,9 +35238,7 @@ var CodexAppServerClient = class {
|
|
|
35183
35238
|
/** Sends a request and waits for its response, bounded by the caller's cancellation signal. */
|
|
35184
35239
|
request = async (method, params, signal) => {
|
|
35185
35240
|
signal.throwIfAborted();
|
|
35186
|
-
|
|
35187
|
-
throw new CodexAppServerError("codex_app_server_closed", "The Codex app-server is closed");
|
|
35188
|
-
}
|
|
35241
|
+
this.#requireOpen();
|
|
35189
35242
|
const id = this.#nextRequestId;
|
|
35190
35243
|
this.#nextRequestId += 1;
|
|
35191
35244
|
const completion = Promise.withResolvers();
|
|
@@ -35198,7 +35251,7 @@ var CodexAppServerClient = class {
|
|
|
35198
35251
|
signal.addEventListener("abort", abort, { once: true });
|
|
35199
35252
|
try {
|
|
35200
35253
|
this.#write({ id, method, params });
|
|
35201
|
-
return await
|
|
35254
|
+
return await completion.promise;
|
|
35202
35255
|
} finally {
|
|
35203
35256
|
signal.removeEventListener("abort", abort);
|
|
35204
35257
|
this.#pending.delete(id);
|
|
@@ -35214,12 +35267,12 @@ var CodexAppServerClient = class {
|
|
|
35214
35267
|
this.#write({ error: { code, message }, id });
|
|
35215
35268
|
};
|
|
35216
35269
|
#write = (message) => {
|
|
35217
|
-
|
|
35218
|
-
return;
|
|
35219
|
-
}
|
|
35270
|
+
this.#requireOpen();
|
|
35220
35271
|
const stdin = this.#child.stdin;
|
|
35221
35272
|
if (stdin === null || stdin.destroyed) {
|
|
35222
|
-
|
|
35273
|
+
const error62 = new CodexAppServerError("codex_app_server_io_error", "The Codex app-server input is closed");
|
|
35274
|
+
this.#fail(error62);
|
|
35275
|
+
throw error62;
|
|
35223
35276
|
}
|
|
35224
35277
|
stdin.write(`${JSON.stringify(message)}
|
|
35225
35278
|
`);
|
|
@@ -35242,15 +35295,7 @@ var CodexAppServerClient = class {
|
|
|
35242
35295
|
* app-server and every tool subprocess it started.
|
|
35243
35296
|
*/
|
|
35244
35297
|
detach = () => {
|
|
35245
|
-
|
|
35246
|
-
return;
|
|
35247
|
-
}
|
|
35248
|
-
this.#closed = true;
|
|
35249
|
-
this.#fail(new CodexAppServerError("codex_app_server_closed", "The Codex app-server is closed"));
|
|
35250
|
-
const stdin = this.#child.stdin;
|
|
35251
|
-
if (stdin !== null && !stdin.destroyed) {
|
|
35252
|
-
stdin.end();
|
|
35253
|
-
}
|
|
35298
|
+
this.#terminate({ kind: "closed" });
|
|
35254
35299
|
};
|
|
35255
35300
|
};
|
|
35256
35301
|
|
|
@@ -35592,6 +35637,8 @@ function userInputSchema(questions) {
|
|
|
35592
35637
|
var CodexAcpAgent = class {
|
|
35593
35638
|
#app;
|
|
35594
35639
|
#appServer;
|
|
35640
|
+
terminated;
|
|
35641
|
+
#closePromise = null;
|
|
35595
35642
|
#connection = null;
|
|
35596
35643
|
#models = [];
|
|
35597
35644
|
#nativeSessionId = "";
|
|
@@ -35629,6 +35676,15 @@ var CodexAcpAgent = class {
|
|
|
35629
35676
|
}
|
|
35630
35677
|
}
|
|
35631
35678
|
});
|
|
35679
|
+
this.terminated = this.#appServer.terminated;
|
|
35680
|
+
void this.terminated.then((termination) => {
|
|
35681
|
+
this.#turn?.completion.reject(acpEndpointTerminationError(termination));
|
|
35682
|
+
if (termination.kind === "failed") {
|
|
35683
|
+
void this.close().catch((cause) => {
|
|
35684
|
+
console.error("The failed Codex endpoint could not release its process tree", cause);
|
|
35685
|
+
});
|
|
35686
|
+
}
|
|
35687
|
+
});
|
|
35632
35688
|
this.#app = createAgentApp({ name: "mobius-codex" }).onConnect((connection) => {
|
|
35633
35689
|
this.#connection = connection;
|
|
35634
35690
|
}).onRequest(methods4.agent.initialize, async () => ({
|
|
@@ -35740,11 +35796,20 @@ var CodexAcpAgent = class {
|
|
|
35740
35796
|
* Releases the app-server and every process it started. Mirrors the adapter path's teardown so a
|
|
35741
35797
|
* cancelled or closed session cannot leak the tool subprocesses running under the app-server.
|
|
35742
35798
|
*/
|
|
35743
|
-
close =
|
|
35744
|
-
|
|
35745
|
-
|
|
35746
|
-
|
|
35747
|
-
|
|
35799
|
+
close = () => {
|
|
35800
|
+
if (this.#closePromise === null) {
|
|
35801
|
+
this.#appServer.detach();
|
|
35802
|
+
this.#closePromise = (async () => {
|
|
35803
|
+
const child = this.#appServer.child();
|
|
35804
|
+
try {
|
|
35805
|
+
const captured = await captureProcessTree(child);
|
|
35806
|
+
await stopProcessTree(child, captured);
|
|
35807
|
+
} finally {
|
|
35808
|
+
this.#connection?.close();
|
|
35809
|
+
}
|
|
35810
|
+
})();
|
|
35811
|
+
}
|
|
35812
|
+
return this.#closePromise;
|
|
35748
35813
|
};
|
|
35749
35814
|
/**
|
|
35750
35815
|
* Reads the model catalog once per app-server. A failure leaves the catalog empty, which costs
|
|
@@ -35988,7 +36053,7 @@ var CodexAcpAgent = class {
|
|
|
35988
36053
|
if (method === "turn/started") {
|
|
35989
36054
|
const decoded = turnNotificationSchema.safeParse(params);
|
|
35990
36055
|
if (decoded.success && decoded.data.threadId === this.#nativeSessionId && this.#turn !== null) {
|
|
35991
|
-
this.#turn
|
|
36056
|
+
this.#turn.turn.id = decoded.data.turn.id;
|
|
35992
36057
|
}
|
|
35993
36058
|
return;
|
|
35994
36059
|
}
|
|
@@ -36177,10 +36242,20 @@ var CodexAcpAgent = class {
|
|
|
36177
36242
|
this.#appServer.respond(request.id, { action: response.action, content: content3 });
|
|
36178
36243
|
};
|
|
36179
36244
|
#runTurn = async (input2, signal) => {
|
|
36245
|
+
signal.throwIfAborted();
|
|
36180
36246
|
if (this.#turn !== null) {
|
|
36181
36247
|
throw new AcpExecutionError("Another prompt is already running in this conversation", {}, "session_busy");
|
|
36182
36248
|
}
|
|
36183
36249
|
const completion = Promise.withResolvers();
|
|
36250
|
+
void completion.promise.catch(() => {
|
|
36251
|
+
});
|
|
36252
|
+
const aborted2 = () => {
|
|
36253
|
+
completion.reject(signal.reason);
|
|
36254
|
+
void this.close().catch((cause) => {
|
|
36255
|
+
console.error("The cancelled Codex endpoint could not release its process tree", cause);
|
|
36256
|
+
});
|
|
36257
|
+
};
|
|
36258
|
+
signal.addEventListener("abort", aborted2, { once: true });
|
|
36184
36259
|
const turn = { completion, turn: { id: "" } };
|
|
36185
36260
|
this.#turn = turn;
|
|
36186
36261
|
try {
|
|
@@ -36226,6 +36301,7 @@ var CodexAcpAgent = class {
|
|
|
36226
36301
|
}
|
|
36227
36302
|
return await completion.promise;
|
|
36228
36303
|
} finally {
|
|
36304
|
+
signal.removeEventListener("abort", aborted2);
|
|
36229
36305
|
if (this.#turn === turn) {
|
|
36230
36306
|
this.#turn = null;
|
|
36231
36307
|
}
|
|
@@ -36254,7 +36330,6 @@ var CodexAcpAgent = class {
|
|
|
36254
36330
|
if (active === null) {
|
|
36255
36331
|
return;
|
|
36256
36332
|
}
|
|
36257
|
-
this.#turn = null;
|
|
36258
36333
|
await this.#updateTail;
|
|
36259
36334
|
if (turn.status === "failed") {
|
|
36260
36335
|
active.completion.reject(
|
|
@@ -37336,24 +37411,40 @@ async function probeInProcessReadiness(agent, environment, defaultWorkspace, con
|
|
|
37336
37411
|
environment: { ...filterEnvironment(environment), ...agent.environment }
|
|
37337
37412
|
});
|
|
37338
37413
|
try {
|
|
37339
|
-
await inProcess.initialize(controller.signal);
|
|
37340
37414
|
const connection = createAcpClient(new DiscoveryAcpHandler()).connect(inProcess.app());
|
|
37341
|
-
|
|
37342
|
-
|
|
37343
|
-
|
|
37344
|
-
|
|
37345
|
-
|
|
37346
|
-
|
|
37347
|
-
|
|
37348
|
-
|
|
37349
|
-
|
|
37350
|
-
|
|
37351
|
-
|
|
37415
|
+
try {
|
|
37416
|
+
return await Promise.race([
|
|
37417
|
+
(async () => {
|
|
37418
|
+
await inProcess.initialize(controller.signal);
|
|
37419
|
+
const initialized = await connection.agent.request(
|
|
37420
|
+
methods8.agent.initialize,
|
|
37421
|
+
{
|
|
37422
|
+
clientCapabilities: {},
|
|
37423
|
+
clientInfo: { name: "mobius", version: "0.0.3" },
|
|
37424
|
+
protocolVersion: PROTOCOL_VERSION3
|
|
37425
|
+
},
|
|
37426
|
+
{ cancellationSignal: controller.signal }
|
|
37427
|
+
);
|
|
37428
|
+
if (initialized.protocolVersion !== PROTOCOL_VERSION3) {
|
|
37429
|
+
throw new AgentProbeError(
|
|
37430
|
+
"acp_incompatible",
|
|
37431
|
+
"ACP agent selected an unsupported protocol version"
|
|
37432
|
+
);
|
|
37433
|
+
}
|
|
37434
|
+
return new VerifiedAcpReadiness(
|
|
37435
|
+
normalizeVersionOutput(initialized.agentInfo?.version ?? ""),
|
|
37436
|
+
normalizeAcpCapabilities(initialized)
|
|
37437
|
+
);
|
|
37438
|
+
})(),
|
|
37439
|
+
inProcess.terminated.then((termination) => {
|
|
37440
|
+
throw new AgentProbeError("acp_incompatible", "The ACP endpoint stopped during initialization", {
|
|
37441
|
+
cause: acpEndpointTerminationError(termination)
|
|
37442
|
+
});
|
|
37443
|
+
})
|
|
37444
|
+
]);
|
|
37445
|
+
} finally {
|
|
37446
|
+
connection.close();
|
|
37352
37447
|
}
|
|
37353
|
-
return new VerifiedAcpReadiness(
|
|
37354
|
-
normalizeVersionOutput(initialized.agentInfo?.version ?? ""),
|
|
37355
|
-
normalizeAcpCapabilities(initialized)
|
|
37356
|
-
);
|
|
37357
37448
|
} finally {
|
|
37358
37449
|
await inProcess.close();
|
|
37359
37450
|
}
|