@moxt-ai/mobius 0.0.79 → 0.0.81
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/agent-catalog/agents/opencode-agent.d.ts +4 -1
- package/dist/agent-catalog/agents/opencode-agent.d.ts.map +1 -1
- package/dist/agent-catalog/agents/opencode-agent.js +81 -0
- package/dist/agent-catalog/agents/opencode-agent.js.map +1 -1
- package/dist/cli.js +253 -85
- package/dist/cli.js.map +4 -4
- package/dist/index.js +252 -84
- package/dist/index.js.map +4 -4
- package/dist/run-daemon.d.ts.map +1 -1
- package/dist/run-daemon.js +9 -22
- package/dist/run-daemon.js.map +1 -1
- package/dist/runtime.js +252 -84
- package/dist/runtime.js.map +4 -4
- package/package.json +1 -1
package/dist/runtime.js
CHANGED
|
@@ -1307,6 +1307,20 @@ var AcpConfigurationValueUnavailableError = class extends AcpExecutionError {
|
|
|
1307
1307
|
}
|
|
1308
1308
|
};
|
|
1309
1309
|
|
|
1310
|
+
// src/acp/in-process/acp-endpoint.ts
|
|
1311
|
+
function acpEndpointTerminationError(termination) {
|
|
1312
|
+
switch (termination.kind) {
|
|
1313
|
+
case "failed":
|
|
1314
|
+
return termination.error;
|
|
1315
|
+
case "closed":
|
|
1316
|
+
return new AcpExecutionError("The ACP endpoint is closed", {}, "acp_endpoint_closed");
|
|
1317
|
+
default: {
|
|
1318
|
+
const unreachable = termination;
|
|
1319
|
+
return unreachable;
|
|
1320
|
+
}
|
|
1321
|
+
}
|
|
1322
|
+
}
|
|
1323
|
+
|
|
1310
1324
|
// src/acp/codex/app-server-client.ts
|
|
1311
1325
|
import { spawn as spawn2 } from "node:child_process";
|
|
1312
1326
|
|
|
@@ -21201,11 +21215,9 @@ var threadSettingsUpdatedSchema = external_exports.object({
|
|
|
21201
21215
|
// src/acp/codex/app-server-client.ts
|
|
21202
21216
|
var INITIALIZE_TIMEOUT_MILLISECONDS = 3e4;
|
|
21203
21217
|
var OUTPUT_LIMIT_BYTES = 32 * 1024 * 1024;
|
|
21204
|
-
var CodexAppServerError = class extends
|
|
21205
|
-
code;
|
|
21218
|
+
var CodexAppServerError = class extends AcpExecutionError {
|
|
21206
21219
|
constructor(code, message, options = {}) {
|
|
21207
|
-
super(message, options);
|
|
21208
|
-
this.code = code;
|
|
21220
|
+
super(message, options, code);
|
|
21209
21221
|
this.name = "CodexAppServerError";
|
|
21210
21222
|
}
|
|
21211
21223
|
};
|
|
@@ -21213,12 +21225,14 @@ var CodexAppServerClient = class {
|
|
|
21213
21225
|
#child;
|
|
21214
21226
|
#handlers;
|
|
21215
21227
|
#pending = /* @__PURE__ */ new Map();
|
|
21216
|
-
#
|
|
21217
|
-
|
|
21228
|
+
#termination = Promise.withResolvers();
|
|
21229
|
+
terminated = this.#termination.promise;
|
|
21230
|
+
#lifecycle = {
|
|
21231
|
+
kind: "open"
|
|
21232
|
+
};
|
|
21218
21233
|
#nextRequestId = 1;
|
|
21219
21234
|
#pendingBuffer = "";
|
|
21220
21235
|
#receivedBytes = 0;
|
|
21221
|
-
#closed = false;
|
|
21222
21236
|
constructor(options) {
|
|
21223
21237
|
this.#handlers = options.handlers;
|
|
21224
21238
|
this.#child = spawn2(options.command, ["app-server"], {
|
|
@@ -21243,21 +21257,56 @@ var CodexAppServerClient = class {
|
|
|
21243
21257
|
stderr.on("data", (chunk) => {
|
|
21244
21258
|
process.stderr.write(`[codex-app-server] ${chunk}`);
|
|
21245
21259
|
});
|
|
21246
|
-
this.#
|
|
21247
|
-
this.#
|
|
21248
|
-
|
|
21260
|
+
this.#child.once("error", (cause) => {
|
|
21261
|
+
this.#fail(
|
|
21262
|
+
new CodexAppServerError("codex_app_server_exited", "The Codex app-server could not run", { cause })
|
|
21263
|
+
);
|
|
21264
|
+
});
|
|
21265
|
+
this.#child.once("exit", (code, signal) => {
|
|
21266
|
+
this.#fail(
|
|
21267
|
+
new CodexAppServerError("codex_app_server_exited", "The Codex app-server stopped", {
|
|
21268
|
+
cause: { code, signal }
|
|
21269
|
+
})
|
|
21270
|
+
);
|
|
21271
|
+
});
|
|
21272
|
+
for (const stream of [stdin, stdout, stderr]) {
|
|
21273
|
+
stream.on("error", (cause) => {
|
|
21274
|
+
this.#fail(
|
|
21275
|
+
new CodexAppServerError("codex_app_server_io_error", "The Codex app-server connection failed", {
|
|
21276
|
+
cause
|
|
21277
|
+
})
|
|
21278
|
+
);
|
|
21279
|
+
});
|
|
21280
|
+
}
|
|
21281
|
+
stdout.once("end", () => {
|
|
21282
|
+
this.#fail(new CodexAppServerError("codex_app_server_exited", "The Codex app-server output closed"));
|
|
21249
21283
|
});
|
|
21250
21284
|
}
|
|
21251
21285
|
child = () => this.#child;
|
|
21252
21286
|
#fail = (error62) => {
|
|
21253
|
-
this.#
|
|
21287
|
+
this.#terminate({ kind: "failed", error: error62 });
|
|
21288
|
+
};
|
|
21289
|
+
#terminate = (result) => {
|
|
21290
|
+
if (this.#lifecycle.kind === "terminated") {
|
|
21291
|
+
return;
|
|
21292
|
+
}
|
|
21293
|
+
this.#lifecycle = { kind: "terminated", result };
|
|
21294
|
+
this.#termination.resolve(result);
|
|
21295
|
+
const error62 = acpEndpointTerminationError(result);
|
|
21254
21296
|
for (const [id, pending] of this.#pending) {
|
|
21255
21297
|
this.#pending.delete(id);
|
|
21256
21298
|
pending.completion.reject(error62);
|
|
21257
21299
|
}
|
|
21258
21300
|
};
|
|
21259
|
-
#
|
|
21301
|
+
#requireOpen = () => {
|
|
21302
|
+
if (this.#lifecycle.kind === "terminated") {
|
|
21303
|
+
throw acpEndpointTerminationError(this.#lifecycle.result);
|
|
21304
|
+
}
|
|
21305
|
+
};
|
|
21260
21306
|
#consume = (chunk) => {
|
|
21307
|
+
if (this.#lifecycle.kind === "terminated") {
|
|
21308
|
+
return;
|
|
21309
|
+
}
|
|
21261
21310
|
try {
|
|
21262
21311
|
this.#receivedBytes += Buffer.byteLength(chunk);
|
|
21263
21312
|
if (this.#receivedBytes > OUTPUT_LIMIT_BYTES) {
|
|
@@ -21286,7 +21335,6 @@ var CodexAppServerClient = class {
|
|
|
21286
21335
|
{ cause: error62 }
|
|
21287
21336
|
)
|
|
21288
21337
|
);
|
|
21289
|
-
this.#child.kill("SIGKILL");
|
|
21290
21338
|
}
|
|
21291
21339
|
};
|
|
21292
21340
|
// Handler failures are recorded as the app-server's terminal failure: an ACP client that cannot
|
|
@@ -21336,9 +21384,7 @@ var CodexAppServerClient = class {
|
|
|
21336
21384
|
/** Sends a request and waits for its response, bounded by the caller's cancellation signal. */
|
|
21337
21385
|
request = async (method, params, signal) => {
|
|
21338
21386
|
signal.throwIfAborted();
|
|
21339
|
-
|
|
21340
|
-
throw new CodexAppServerError("codex_app_server_closed", "The Codex app-server is closed");
|
|
21341
|
-
}
|
|
21387
|
+
this.#requireOpen();
|
|
21342
21388
|
const id = this.#nextRequestId;
|
|
21343
21389
|
this.#nextRequestId += 1;
|
|
21344
21390
|
const completion = Promise.withResolvers();
|
|
@@ -21351,7 +21397,7 @@ var CodexAppServerClient = class {
|
|
|
21351
21397
|
signal.addEventListener("abort", abort, { once: true });
|
|
21352
21398
|
try {
|
|
21353
21399
|
this.#write({ id, method, params });
|
|
21354
|
-
return await
|
|
21400
|
+
return await completion.promise;
|
|
21355
21401
|
} finally {
|
|
21356
21402
|
signal.removeEventListener("abort", abort);
|
|
21357
21403
|
this.#pending.delete(id);
|
|
@@ -21367,12 +21413,12 @@ var CodexAppServerClient = class {
|
|
|
21367
21413
|
this.#write({ error: { code, message }, id });
|
|
21368
21414
|
};
|
|
21369
21415
|
#write = (message) => {
|
|
21370
|
-
|
|
21371
|
-
return;
|
|
21372
|
-
}
|
|
21416
|
+
this.#requireOpen();
|
|
21373
21417
|
const stdin = this.#child.stdin;
|
|
21374
21418
|
if (stdin === null || stdin.destroyed) {
|
|
21375
|
-
|
|
21419
|
+
const error62 = new CodexAppServerError("codex_app_server_io_error", "The Codex app-server input is closed");
|
|
21420
|
+
this.#fail(error62);
|
|
21421
|
+
throw error62;
|
|
21376
21422
|
}
|
|
21377
21423
|
stdin.write(`${JSON.stringify(message)}
|
|
21378
21424
|
`);
|
|
@@ -21395,15 +21441,7 @@ var CodexAppServerClient = class {
|
|
|
21395
21441
|
* app-server and every tool subprocess it started.
|
|
21396
21442
|
*/
|
|
21397
21443
|
detach = () => {
|
|
21398
|
-
|
|
21399
|
-
return;
|
|
21400
|
-
}
|
|
21401
|
-
this.#closed = true;
|
|
21402
|
-
this.#fail(new CodexAppServerError("codex_app_server_closed", "The Codex app-server is closed"));
|
|
21403
|
-
const stdin = this.#child.stdin;
|
|
21404
|
-
if (stdin !== null && !stdin.destroyed) {
|
|
21405
|
-
stdin.end();
|
|
21406
|
-
}
|
|
21444
|
+
this.#terminate({ kind: "closed" });
|
|
21407
21445
|
};
|
|
21408
21446
|
};
|
|
21409
21447
|
|
|
@@ -21745,6 +21783,8 @@ function userInputSchema(questions) {
|
|
|
21745
21783
|
var CodexAcpAgent = class {
|
|
21746
21784
|
#app;
|
|
21747
21785
|
#appServer;
|
|
21786
|
+
terminated;
|
|
21787
|
+
#closePromise = null;
|
|
21748
21788
|
#connection = null;
|
|
21749
21789
|
#models = [];
|
|
21750
21790
|
#nativeSessionId = "";
|
|
@@ -21782,6 +21822,15 @@ var CodexAcpAgent = class {
|
|
|
21782
21822
|
}
|
|
21783
21823
|
}
|
|
21784
21824
|
});
|
|
21825
|
+
this.terminated = this.#appServer.terminated;
|
|
21826
|
+
void this.terminated.then((termination) => {
|
|
21827
|
+
this.#turn?.completion.reject(acpEndpointTerminationError(termination));
|
|
21828
|
+
if (termination.kind === "failed") {
|
|
21829
|
+
void this.close().catch((cause) => {
|
|
21830
|
+
console.error("The failed Codex endpoint could not release its process tree", cause);
|
|
21831
|
+
});
|
|
21832
|
+
}
|
|
21833
|
+
});
|
|
21785
21834
|
this.#app = createAgentApp({ name: "mobius-codex" }).onConnect((connection) => {
|
|
21786
21835
|
this.#connection = connection;
|
|
21787
21836
|
}).onRequest(methods.agent.initialize, async () => ({
|
|
@@ -21893,11 +21942,20 @@ var CodexAcpAgent = class {
|
|
|
21893
21942
|
* Releases the app-server and every process it started. Mirrors the adapter path's teardown so a
|
|
21894
21943
|
* cancelled or closed session cannot leak the tool subprocesses running under the app-server.
|
|
21895
21944
|
*/
|
|
21896
|
-
close =
|
|
21897
|
-
|
|
21898
|
-
|
|
21899
|
-
|
|
21900
|
-
|
|
21945
|
+
close = () => {
|
|
21946
|
+
if (this.#closePromise === null) {
|
|
21947
|
+
this.#appServer.detach();
|
|
21948
|
+
this.#closePromise = (async () => {
|
|
21949
|
+
const child = this.#appServer.child();
|
|
21950
|
+
try {
|
|
21951
|
+
const captured = await captureProcessTree(child);
|
|
21952
|
+
await stopProcessTree(child, captured);
|
|
21953
|
+
} finally {
|
|
21954
|
+
this.#connection?.close();
|
|
21955
|
+
}
|
|
21956
|
+
})();
|
|
21957
|
+
}
|
|
21958
|
+
return this.#closePromise;
|
|
21901
21959
|
};
|
|
21902
21960
|
/**
|
|
21903
21961
|
* Reads the model catalog once per app-server. A failure leaves the catalog empty, which costs
|
|
@@ -22141,7 +22199,7 @@ var CodexAcpAgent = class {
|
|
|
22141
22199
|
if (method === "turn/started") {
|
|
22142
22200
|
const decoded = turnNotificationSchema.safeParse(params);
|
|
22143
22201
|
if (decoded.success && decoded.data.threadId === this.#nativeSessionId && this.#turn !== null) {
|
|
22144
|
-
this.#turn
|
|
22202
|
+
this.#turn.turn.id = decoded.data.turn.id;
|
|
22145
22203
|
}
|
|
22146
22204
|
return;
|
|
22147
22205
|
}
|
|
@@ -22330,10 +22388,20 @@ var CodexAcpAgent = class {
|
|
|
22330
22388
|
this.#appServer.respond(request.id, { action: response.action, content: content3 });
|
|
22331
22389
|
};
|
|
22332
22390
|
#runTurn = async (input2, signal) => {
|
|
22391
|
+
signal.throwIfAborted();
|
|
22333
22392
|
if (this.#turn !== null) {
|
|
22334
22393
|
throw new AcpExecutionError("Another prompt is already running in this conversation", {}, "session_busy");
|
|
22335
22394
|
}
|
|
22336
22395
|
const completion = Promise.withResolvers();
|
|
22396
|
+
void completion.promise.catch(() => {
|
|
22397
|
+
});
|
|
22398
|
+
const aborted2 = () => {
|
|
22399
|
+
completion.reject(signal.reason);
|
|
22400
|
+
void this.close().catch((cause) => {
|
|
22401
|
+
console.error("The cancelled Codex endpoint could not release its process tree", cause);
|
|
22402
|
+
});
|
|
22403
|
+
};
|
|
22404
|
+
signal.addEventListener("abort", aborted2, { once: true });
|
|
22337
22405
|
const turn = { completion, turn: { id: "" } };
|
|
22338
22406
|
this.#turn = turn;
|
|
22339
22407
|
try {
|
|
@@ -22379,6 +22447,7 @@ var CodexAcpAgent = class {
|
|
|
22379
22447
|
}
|
|
22380
22448
|
return await completion.promise;
|
|
22381
22449
|
} finally {
|
|
22450
|
+
signal.removeEventListener("abort", aborted2);
|
|
22382
22451
|
if (this.#turn === turn) {
|
|
22383
22452
|
this.#turn = null;
|
|
22384
22453
|
}
|
|
@@ -22407,7 +22476,6 @@ var CodexAcpAgent = class {
|
|
|
22407
22476
|
if (active === null) {
|
|
22408
22477
|
return;
|
|
22409
22478
|
}
|
|
22410
|
-
this.#turn = null;
|
|
22411
22479
|
await this.#updateTail;
|
|
22412
22480
|
if (turn.status === "failed") {
|
|
22413
22481
|
active.completion.reject(
|
|
@@ -23167,6 +23235,97 @@ function openCodeManagedArchive(platform, architecture) {
|
|
|
23167
23235
|
}
|
|
23168
23236
|
|
|
23169
23237
|
// src/agent-catalog/agents/opencode-agent.ts
|
|
23238
|
+
var MODEL_DISCOVERY_TIMEOUT_MILLISECONDS = 3e3;
|
|
23239
|
+
var MODEL_DISCOVERY_OUTPUT_LIMIT_BYTES = 1024 * 1024;
|
|
23240
|
+
var MAXIMUM_MODEL_VALUES = 500;
|
|
23241
|
+
function containsControlCharacter(value) {
|
|
23242
|
+
return Array.from(value).some((character) => {
|
|
23243
|
+
const codePoint = character.codePointAt(0) ?? 0;
|
|
23244
|
+
return codePoint <= 31 || codePoint >= 127 && codePoint <= 159;
|
|
23245
|
+
});
|
|
23246
|
+
}
|
|
23247
|
+
async function discoverModelValues(agent, cwd, signal) {
|
|
23248
|
+
if (!await revalidateExecutable(agent.agentIdentity)) {
|
|
23249
|
+
throw new AcpExecutionError(
|
|
23250
|
+
"The local Agent runtime changed; restart Mobius before discovering settings",
|
|
23251
|
+
{},
|
|
23252
|
+
"agent_runtime_changed"
|
|
23253
|
+
);
|
|
23254
|
+
}
|
|
23255
|
+
const acpArgumentIndex = agent.arguments.indexOf("acp");
|
|
23256
|
+
if (acpArgumentIndex < 0) {
|
|
23257
|
+
throw new AcpExecutionError(
|
|
23258
|
+
"OpenCode does not expose its model discovery command",
|
|
23259
|
+
{},
|
|
23260
|
+
"invalid_session_configuration"
|
|
23261
|
+
);
|
|
23262
|
+
}
|
|
23263
|
+
const result = await runBoundedProcess({
|
|
23264
|
+
arguments: [
|
|
23265
|
+
...agent.arguments.slice(0, acpArgumentIndex),
|
|
23266
|
+
"models",
|
|
23267
|
+
...agent.arguments.slice(acpArgumentIndex + 1)
|
|
23268
|
+
],
|
|
23269
|
+
command: agent.command,
|
|
23270
|
+
cwd,
|
|
23271
|
+
environment: { ...process.env, ...agent.environment },
|
|
23272
|
+
outputLimitBytes: MODEL_DISCOVERY_OUTPUT_LIMIT_BYTES,
|
|
23273
|
+
signal,
|
|
23274
|
+
timeoutMilliseconds: MODEL_DISCOVERY_TIMEOUT_MILLISECONDS
|
|
23275
|
+
});
|
|
23276
|
+
const values = [];
|
|
23277
|
+
const identifiers = /* @__PURE__ */ new Set();
|
|
23278
|
+
for (const rawLine of result.stdout.split(/\r?\n/)) {
|
|
23279
|
+
const value = rawLine.trim();
|
|
23280
|
+
if (value.length === 0) {
|
|
23281
|
+
continue;
|
|
23282
|
+
}
|
|
23283
|
+
if (value.length > 512 || !/^[^\s/]+\/\S+$/.test(value) || containsControlCharacter(value)) {
|
|
23284
|
+
throw new AcpExecutionError(
|
|
23285
|
+
"OpenCode returned an invalid model catalog",
|
|
23286
|
+
{},
|
|
23287
|
+
"invalid_session_configuration"
|
|
23288
|
+
);
|
|
23289
|
+
}
|
|
23290
|
+
if (!identifiers.has(value)) {
|
|
23291
|
+
identifiers.add(value);
|
|
23292
|
+
values.push({ description: "", groupId: "", groupName: "", name: value, value });
|
|
23293
|
+
}
|
|
23294
|
+
if (values.length > MAXIMUM_MODEL_VALUES) {
|
|
23295
|
+
throw new AcpExecutionError("OpenCode returned too many models", {}, "invalid_session_configuration");
|
|
23296
|
+
}
|
|
23297
|
+
}
|
|
23298
|
+
return values;
|
|
23299
|
+
}
|
|
23300
|
+
function mergeModelValues(options, discovered) {
|
|
23301
|
+
if (discovered.length === 0) {
|
|
23302
|
+
return options;
|
|
23303
|
+
}
|
|
23304
|
+
return options.map((option) => {
|
|
23305
|
+
if (option.id !== "model" && option.category !== "model" || option.type !== "select") {
|
|
23306
|
+
return option;
|
|
23307
|
+
}
|
|
23308
|
+
const known = new Map(option.values.map((value) => [value.value, value]));
|
|
23309
|
+
const values = discovered.map((value) => known.get(value.value) ?? value);
|
|
23310
|
+
const identifiers = new Set(values.map((value) => value.value));
|
|
23311
|
+
for (const value of option.values) {
|
|
23312
|
+
if (values.length >= MAXIMUM_MODEL_VALUES) {
|
|
23313
|
+
break;
|
|
23314
|
+
}
|
|
23315
|
+
if (!identifiers.has(value.value)) {
|
|
23316
|
+
identifiers.add(value.value);
|
|
23317
|
+
values.push(value);
|
|
23318
|
+
}
|
|
23319
|
+
}
|
|
23320
|
+
return { ...option, values };
|
|
23321
|
+
});
|
|
23322
|
+
}
|
|
23323
|
+
async function discoverOpenCodeModelOptions(agent, cwd, options, signal) {
|
|
23324
|
+
if (agent.id !== "opencode" || agent.kind !== "acp-adapter-process") {
|
|
23325
|
+
return options;
|
|
23326
|
+
}
|
|
23327
|
+
return mergeModelValues(options, await discoverModelValues(agent, cwd, signal));
|
|
23328
|
+
}
|
|
23170
23329
|
var OpenCodeAgentSpecification = class extends DirectAcpAgentDefinition {
|
|
23171
23330
|
versionProbeTimeoutMilliseconds = 15e3;
|
|
23172
23331
|
adapterVersion = OPENCODE_MANAGED_VERSION;
|
|
@@ -23529,24 +23688,40 @@ async function probeInProcessReadiness(agent, environment, defaultWorkspace, con
|
|
|
23529
23688
|
environment: { ...filterEnvironment(environment), ...agent.environment }
|
|
23530
23689
|
});
|
|
23531
23690
|
try {
|
|
23532
|
-
await inProcess.initialize(controller.signal);
|
|
23533
23691
|
const connection = createAcpClient(new DiscoveryAcpHandler()).connect(inProcess.app());
|
|
23534
|
-
|
|
23535
|
-
|
|
23536
|
-
|
|
23537
|
-
|
|
23538
|
-
|
|
23539
|
-
|
|
23540
|
-
|
|
23541
|
-
|
|
23542
|
-
|
|
23543
|
-
|
|
23544
|
-
|
|
23692
|
+
try {
|
|
23693
|
+
return await Promise.race([
|
|
23694
|
+
(async () => {
|
|
23695
|
+
await inProcess.initialize(controller.signal);
|
|
23696
|
+
const initialized = await connection.agent.request(
|
|
23697
|
+
methods6.agent.initialize,
|
|
23698
|
+
{
|
|
23699
|
+
clientCapabilities: {},
|
|
23700
|
+
clientInfo: { name: "mobius", version: "0.0.3" },
|
|
23701
|
+
protocolVersion: PROTOCOL_VERSION2
|
|
23702
|
+
},
|
|
23703
|
+
{ cancellationSignal: controller.signal }
|
|
23704
|
+
);
|
|
23705
|
+
if (initialized.protocolVersion !== PROTOCOL_VERSION2) {
|
|
23706
|
+
throw new AgentProbeError(
|
|
23707
|
+
"acp_incompatible",
|
|
23708
|
+
"ACP agent selected an unsupported protocol version"
|
|
23709
|
+
);
|
|
23710
|
+
}
|
|
23711
|
+
return new VerifiedAcpReadiness(
|
|
23712
|
+
normalizeVersionOutput(initialized.agentInfo?.version ?? ""),
|
|
23713
|
+
normalizeAcpCapabilities(initialized)
|
|
23714
|
+
);
|
|
23715
|
+
})(),
|
|
23716
|
+
inProcess.terminated.then((termination) => {
|
|
23717
|
+
throw new AgentProbeError("acp_incompatible", "The ACP endpoint stopped during initialization", {
|
|
23718
|
+
cause: acpEndpointTerminationError(termination)
|
|
23719
|
+
});
|
|
23720
|
+
})
|
|
23721
|
+
]);
|
|
23722
|
+
} finally {
|
|
23723
|
+
connection.close();
|
|
23545
23724
|
}
|
|
23546
|
-
return new VerifiedAcpReadiness(
|
|
23547
|
-
normalizeVersionOutput(initialized.agentInfo?.version ?? ""),
|
|
23548
|
-
normalizeAcpCapabilities(initialized)
|
|
23549
|
-
);
|
|
23550
23725
|
} finally {
|
|
23551
23726
|
await inProcess.close();
|
|
23552
23727
|
}
|
|
@@ -35496,8 +35671,8 @@ var AcpProcessSession = class _AcpProcessSession {
|
|
|
35496
35671
|
#pendingElicitations = /* @__PURE__ */ new Map();
|
|
35497
35672
|
#pendingPermissions = /* @__PURE__ */ new Map();
|
|
35498
35673
|
#preSessionUpdates = [];
|
|
35499
|
-
//
|
|
35500
|
-
#
|
|
35674
|
+
// Both topologies report a terminal outcome, even after a prompt's initial RPC is acknowledged.
|
|
35675
|
+
#termination;
|
|
35501
35676
|
#runtimeChild;
|
|
35502
35677
|
#metrics;
|
|
35503
35678
|
#sessionConfigProtocol;
|
|
@@ -35541,8 +35716,7 @@ var AcpProcessSession = class _AcpProcessSession {
|
|
|
35541
35716
|
});
|
|
35542
35717
|
this.#inProcessAgent = inProcess;
|
|
35543
35718
|
this.#runtimeChild = null;
|
|
35544
|
-
this.#
|
|
35545
|
-
});
|
|
35719
|
+
this.#termination = inProcess.terminated;
|
|
35546
35720
|
this.#connection = createAcpClient(this).connect(inProcess.app());
|
|
35547
35721
|
return;
|
|
35548
35722
|
}
|
|
@@ -35566,9 +35740,16 @@ var AcpProcessSession = class _AcpProcessSession {
|
|
|
35566
35740
|
stderr.on("data", (chunk) => {
|
|
35567
35741
|
process.stderr.write(`[${agent.id}-acp] ${chunk}`);
|
|
35568
35742
|
});
|
|
35569
|
-
this.#
|
|
35570
|
-
child.once("error",
|
|
35571
|
-
|
|
35743
|
+
this.#termination = new Promise((resolve8) => {
|
|
35744
|
+
child.once("error", (cause) => {
|
|
35745
|
+
resolve8({ kind: "failed", error: new AcpExecutionError("The ACP process could not run", { cause }) });
|
|
35746
|
+
});
|
|
35747
|
+
child.once("exit", (code, signal) => {
|
|
35748
|
+
resolve8({
|
|
35749
|
+
kind: "failed",
|
|
35750
|
+
error: new AcpExecutionError("The ACP process stopped", { cause: { code, signal } })
|
|
35751
|
+
});
|
|
35752
|
+
});
|
|
35572
35753
|
});
|
|
35573
35754
|
const stream = ndJsonStream2(createWritableAcpStream(stdin), readableWebStream(stdout));
|
|
35574
35755
|
this.#connection = createAcpClient(this).connect(stream);
|
|
@@ -36710,8 +36891,9 @@ var AcpProcessSession = class _AcpProcessSession {
|
|
|
36710
36891
|
try {
|
|
36711
36892
|
return await Promise.race([
|
|
36712
36893
|
operation,
|
|
36713
|
-
this.#
|
|
36714
|
-
|
|
36894
|
+
this.#termination.then((termination) => {
|
|
36895
|
+
const cause = acpEndpointTerminationError(termination);
|
|
36896
|
+
throw new AcpExecutionError(exitMessage, { cause }, cause.code);
|
|
36715
36897
|
}),
|
|
36716
36898
|
aborted2
|
|
36717
36899
|
]);
|
|
@@ -41699,39 +41881,26 @@ async function resolveSessionDirectories(directories, bindingId, directoryId2, a
|
|
|
41699
41881
|
}
|
|
41700
41882
|
return new ResolvedSessionDirectories(cwd, additionalDirectories, additionalDirectoryEntries);
|
|
41701
41883
|
}
|
|
41702
|
-
var OPENCODE_PROVIDER_SETTLEMENT_MILLISECONDS = 1e3;
|
|
41703
|
-
async function waitForAgentSettingsReadiness(agentId, signal, timer) {
|
|
41704
|
-
if (agentId !== "opencode") {
|
|
41705
|
-
return;
|
|
41706
|
-
}
|
|
41707
|
-
signal.throwIfAborted();
|
|
41708
|
-
await new Promise((resolve8) => {
|
|
41709
|
-
const readiness = timer.schedule(finish, OPENCODE_PROVIDER_SETTLEMENT_MILLISECONDS);
|
|
41710
|
-
function finish() {
|
|
41711
|
-
readiness.cancel();
|
|
41712
|
-
signal.removeEventListener("abort", finish);
|
|
41713
|
-
resolve8();
|
|
41714
|
-
}
|
|
41715
|
-
signal.addEventListener("abort", finish, { once: true });
|
|
41716
|
-
});
|
|
41717
|
-
signal.throwIfAborted();
|
|
41718
|
-
}
|
|
41719
41884
|
function isUnavailableModel(cause, modelSettingId, requestedModel) {
|
|
41720
41885
|
return cause instanceof AcpConfigurationValueUnavailableError && cause.configId === modelSettingId && cause.requestedValue === requestedModel;
|
|
41721
41886
|
}
|
|
41722
41887
|
function unsupportedModelIds(unsupportedModels) {
|
|
41723
41888
|
return [...new Set(unsupportedModels.map((item) => item.requestedValue))];
|
|
41724
41889
|
}
|
|
41725
|
-
async function discoverAgentSettings(command, config2, directories, sessions, signal
|
|
41890
|
+
async function discoverAgentSettings(command, config2, directories, sessions, signal) {
|
|
41726
41891
|
const agent = config2.catalog.find(command.agentId);
|
|
41727
41892
|
const cwd = await directories.resolve(config2.bindingId, "default", signal);
|
|
41728
|
-
await
|
|
41729
|
-
const baseSnapshot = await sessions.inspectAgentSettings({
|
|
41893
|
+
const inspectedBaseSnapshot = await sessions.inspectAgentSettings({
|
|
41730
41894
|
additionalDirectories: [],
|
|
41731
41895
|
agent,
|
|
41732
41896
|
cwd,
|
|
41733
41897
|
signal
|
|
41734
41898
|
});
|
|
41899
|
+
const baseSnapshot = {
|
|
41900
|
+
agentName: inspectedBaseSnapshot.agentName,
|
|
41901
|
+
agentVersion: inspectedBaseSnapshot.agentVersion,
|
|
41902
|
+
configOptions: await discoverOpenCodeModelOptions(agent, cwd, inspectedBaseSnapshot.configOptions, signal)
|
|
41903
|
+
};
|
|
41735
41904
|
const baseModel = modelOption(baseSnapshot.configOptions);
|
|
41736
41905
|
const unsupportedModels = [];
|
|
41737
41906
|
let selectedSnapshot = baseSnapshot;
|
|
@@ -43182,8 +43351,7 @@ async function runRelayConnection(config2, directories, audit, sessions, install
|
|
|
43182
43351
|
config2,
|
|
43183
43352
|
directories,
|
|
43184
43353
|
sessions,
|
|
43185
|
-
operationSignal
|
|
43186
|
-
timer
|
|
43354
|
+
operationSignal
|
|
43187
43355
|
);
|
|
43188
43356
|
for (const diagnostic of result.unsupportedModels) {
|
|
43189
43357
|
const details = agentSettingsFailureDetails(command2.agentId, diagnostic);
|