@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.
Files changed (32) hide show
  1. package/dist/acp/codex/agent.d.ts +2 -1
  2. package/dist/acp/codex/agent.d.ts.map +1 -1
  3. package/dist/acp/codex/agent.js +42 -7
  4. package/dist/acp/codex/agent.js.map +1 -1
  5. package/dist/acp/codex/app-server-client.d.ts +4 -2
  6. package/dist/acp/codex/app-server-client.d.ts.map +1 -1
  7. package/dist/acp/codex/app-server-client.js +50 -31
  8. package/dist/acp/codex/app-server-client.js.map +1 -1
  9. package/dist/acp/in-process/acp-endpoint.d.ts +10 -0
  10. package/dist/acp/in-process/acp-endpoint.d.ts.map +1 -1
  11. package/dist/acp/in-process/acp-endpoint.js +13 -1
  12. package/dist/acp/in-process/acp-endpoint.js.map +1 -1
  13. package/dist/acp/session-manager.d.ts.map +1 -1
  14. package/dist/acp/session-manager.js +17 -8
  15. package/dist/acp/session-manager.js.map +1 -1
  16. package/dist/agent-catalog/acp-readiness-probe.d.ts.map +1 -1
  17. package/dist/agent-catalog/acp-readiness-probe.js +24 -9
  18. package/dist/agent-catalog/acp-readiness-probe.js.map +1 -1
  19. package/dist/agent-catalog/agents/opencode-agent.d.ts +4 -1
  20. package/dist/agent-catalog/agents/opencode-agent.d.ts.map +1 -1
  21. package/dist/agent-catalog/agents/opencode-agent.js +81 -0
  22. package/dist/agent-catalog/agents/opencode-agent.js.map +1 -1
  23. package/dist/cli.js +253 -85
  24. package/dist/cli.js.map +4 -4
  25. package/dist/index.js +252 -84
  26. package/dist/index.js.map +4 -4
  27. package/dist/run-daemon.d.ts.map +1 -1
  28. package/dist/run-daemon.js +9 -22
  29. package/dist/run-daemon.js.map +1 -1
  30. package/dist/runtime.js +252 -84
  31. package/dist/runtime.js.map +4 -4
  32. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -11,7 +11,7 @@ import { mkdir as mkdir6 } from "node:fs/promises";
11
11
  // package.json
12
12
  var package_default = {
13
13
  name: "@moxt-ai/mobius",
14
- version: "0.0.79",
14
+ version: "0.0.81",
15
15
  description: "Mobius CLI for pairing and running local AI agent services.",
16
16
  type: "module",
17
17
  bin: {
@@ -1435,6 +1435,20 @@ var AcpConfigurationValueUnavailableError = class extends AcpExecutionError {
1435
1435
  }
1436
1436
  };
1437
1437
 
1438
+ // src/acp/in-process/acp-endpoint.ts
1439
+ function acpEndpointTerminationError(termination) {
1440
+ switch (termination.kind) {
1441
+ case "failed":
1442
+ return termination.error;
1443
+ case "closed":
1444
+ return new AcpExecutionError("The ACP endpoint is closed", {}, "acp_endpoint_closed");
1445
+ default: {
1446
+ const unreachable = termination;
1447
+ return unreachable;
1448
+ }
1449
+ }
1450
+ }
1451
+
1438
1452
  // src/acp/codex/app-server-client.ts
1439
1453
  import { spawn as spawn2 } from "node:child_process";
1440
1454
 
@@ -21329,11 +21343,9 @@ var threadSettingsUpdatedSchema = external_exports.object({
21329
21343
  // src/acp/codex/app-server-client.ts
21330
21344
  var INITIALIZE_TIMEOUT_MILLISECONDS = 3e4;
21331
21345
  var OUTPUT_LIMIT_BYTES = 32 * 1024 * 1024;
21332
- var CodexAppServerError = class extends Error {
21333
- code;
21346
+ var CodexAppServerError = class extends AcpExecutionError {
21334
21347
  constructor(code, message, options = {}) {
21335
- super(message, options);
21336
- this.code = code;
21348
+ super(message, options, code);
21337
21349
  this.name = "CodexAppServerError";
21338
21350
  }
21339
21351
  };
@@ -21341,12 +21353,14 @@ var CodexAppServerClient = class {
21341
21353
  #child;
21342
21354
  #handlers;
21343
21355
  #pending = /* @__PURE__ */ new Map();
21344
- #processExit;
21345
- #failure = null;
21356
+ #termination = Promise.withResolvers();
21357
+ terminated = this.#termination.promise;
21358
+ #lifecycle = {
21359
+ kind: "open"
21360
+ };
21346
21361
  #nextRequestId = 1;
21347
21362
  #pendingBuffer = "";
21348
21363
  #receivedBytes = 0;
21349
- #closed = false;
21350
21364
  constructor(options) {
21351
21365
  this.#handlers = options.handlers;
21352
21366
  this.#child = spawn2(options.command, ["app-server"], {
@@ -21371,21 +21385,56 @@ var CodexAppServerClient = class {
21371
21385
  stderr.on("data", (chunk) => {
21372
21386
  process.stderr.write(`[codex-app-server] ${chunk}`);
21373
21387
  });
21374
- this.#processExit = new Promise((resolve7) => {
21375
- this.#child.once("error", resolve7);
21376
- this.#child.once("exit", resolve7);
21388
+ this.#child.once("error", (cause) => {
21389
+ this.#fail(
21390
+ new CodexAppServerError("codex_app_server_exited", "The Codex app-server could not run", { cause })
21391
+ );
21392
+ });
21393
+ this.#child.once("exit", (code, signal) => {
21394
+ this.#fail(
21395
+ new CodexAppServerError("codex_app_server_exited", "The Codex app-server stopped", {
21396
+ cause: { code, signal }
21397
+ })
21398
+ );
21399
+ });
21400
+ for (const stream of [stdin, stdout, stderr]) {
21401
+ stream.on("error", (cause) => {
21402
+ this.#fail(
21403
+ new CodexAppServerError("codex_app_server_io_error", "The Codex app-server connection failed", {
21404
+ cause
21405
+ })
21406
+ );
21407
+ });
21408
+ }
21409
+ stdout.once("end", () => {
21410
+ this.#fail(new CodexAppServerError("codex_app_server_exited", "The Codex app-server output closed"));
21377
21411
  });
21378
21412
  }
21379
21413
  child = () => this.#child;
21380
21414
  #fail = (error62) => {
21381
- this.#failure ??= error62;
21415
+ this.#terminate({ kind: "failed", error: error62 });
21416
+ };
21417
+ #terminate = (result) => {
21418
+ if (this.#lifecycle.kind === "terminated") {
21419
+ return;
21420
+ }
21421
+ this.#lifecycle = { kind: "terminated", result };
21422
+ this.#termination.resolve(result);
21423
+ const error62 = acpEndpointTerminationError(result);
21382
21424
  for (const [id, pending] of this.#pending) {
21383
21425
  this.#pending.delete(id);
21384
21426
  pending.completion.reject(error62);
21385
21427
  }
21386
21428
  };
21387
- #exitedFailure = (method) => this.#failure ?? new CodexAppServerError("codex_app_server_exited", `The Codex app-server stopped during ${method}`);
21429
+ #requireOpen = () => {
21430
+ if (this.#lifecycle.kind === "terminated") {
21431
+ throw acpEndpointTerminationError(this.#lifecycle.result);
21432
+ }
21433
+ };
21388
21434
  #consume = (chunk) => {
21435
+ if (this.#lifecycle.kind === "terminated") {
21436
+ return;
21437
+ }
21389
21438
  try {
21390
21439
  this.#receivedBytes += Buffer.byteLength(chunk);
21391
21440
  if (this.#receivedBytes > OUTPUT_LIMIT_BYTES) {
@@ -21414,7 +21463,6 @@ var CodexAppServerClient = class {
21414
21463
  { cause: error62 }
21415
21464
  )
21416
21465
  );
21417
- this.#child.kill("SIGKILL");
21418
21466
  }
21419
21467
  };
21420
21468
  // Handler failures are recorded as the app-server's terminal failure: an ACP client that cannot
@@ -21464,9 +21512,7 @@ var CodexAppServerClient = class {
21464
21512
  /** Sends a request and waits for its response, bounded by the caller's cancellation signal. */
21465
21513
  request = async (method, params, signal) => {
21466
21514
  signal.throwIfAborted();
21467
- if (this.#closed) {
21468
- throw new CodexAppServerError("codex_app_server_closed", "The Codex app-server is closed");
21469
- }
21515
+ this.#requireOpen();
21470
21516
  const id = this.#nextRequestId;
21471
21517
  this.#nextRequestId += 1;
21472
21518
  const completion = Promise.withResolvers();
@@ -21479,7 +21525,7 @@ var CodexAppServerClient = class {
21479
21525
  signal.addEventListener("abort", abort, { once: true });
21480
21526
  try {
21481
21527
  this.#write({ id, method, params });
21482
- return await Promise.race([completion.promise, this.#processExit.then(() => this.#exitedFailure(method))]);
21528
+ return await completion.promise;
21483
21529
  } finally {
21484
21530
  signal.removeEventListener("abort", abort);
21485
21531
  this.#pending.delete(id);
@@ -21495,12 +21541,12 @@ var CodexAppServerClient = class {
21495
21541
  this.#write({ error: { code, message }, id });
21496
21542
  };
21497
21543
  #write = (message) => {
21498
- if (this.#closed) {
21499
- return;
21500
- }
21544
+ this.#requireOpen();
21501
21545
  const stdin = this.#child.stdin;
21502
21546
  if (stdin === null || stdin.destroyed) {
21503
- throw new CodexAppServerError("codex_app_server_closed", "The Codex app-server input is closed");
21547
+ const error62 = new CodexAppServerError("codex_app_server_io_error", "The Codex app-server input is closed");
21548
+ this.#fail(error62);
21549
+ throw error62;
21504
21550
  }
21505
21551
  stdin.write(`${JSON.stringify(message)}
21506
21552
  `);
@@ -21523,15 +21569,7 @@ var CodexAppServerClient = class {
21523
21569
  * app-server and every tool subprocess it started.
21524
21570
  */
21525
21571
  detach = () => {
21526
- if (this.#closed) {
21527
- return;
21528
- }
21529
- this.#closed = true;
21530
- this.#fail(new CodexAppServerError("codex_app_server_closed", "The Codex app-server is closed"));
21531
- const stdin = this.#child.stdin;
21532
- if (stdin !== null && !stdin.destroyed) {
21533
- stdin.end();
21534
- }
21572
+ this.#terminate({ kind: "closed" });
21535
21573
  };
21536
21574
  };
21537
21575
 
@@ -21873,6 +21911,8 @@ function userInputSchema(questions) {
21873
21911
  var CodexAcpAgent = class {
21874
21912
  #app;
21875
21913
  #appServer;
21914
+ terminated;
21915
+ #closePromise = null;
21876
21916
  #connection = null;
21877
21917
  #models = [];
21878
21918
  #nativeSessionId = "";
@@ -21910,6 +21950,15 @@ var CodexAcpAgent = class {
21910
21950
  }
21911
21951
  }
21912
21952
  });
21953
+ this.terminated = this.#appServer.terminated;
21954
+ void this.terminated.then((termination) => {
21955
+ this.#turn?.completion.reject(acpEndpointTerminationError(termination));
21956
+ if (termination.kind === "failed") {
21957
+ void this.close().catch((cause) => {
21958
+ console.error("The failed Codex endpoint could not release its process tree", cause);
21959
+ });
21960
+ }
21961
+ });
21913
21962
  this.#app = createAgentApp({ name: "mobius-codex" }).onConnect((connection) => {
21914
21963
  this.#connection = connection;
21915
21964
  }).onRequest(methods.agent.initialize, async () => ({
@@ -22021,11 +22070,20 @@ var CodexAcpAgent = class {
22021
22070
  * Releases the app-server and every process it started. Mirrors the adapter path's teardown so a
22022
22071
  * cancelled or closed session cannot leak the tool subprocesses running under the app-server.
22023
22072
  */
22024
- close = async () => {
22025
- const child = this.#appServer.child();
22026
- const captured = await captureProcessTree(child);
22027
- this.#appServer.detach();
22028
- await stopProcessTree(child, captured);
22073
+ close = () => {
22074
+ if (this.#closePromise === null) {
22075
+ this.#appServer.detach();
22076
+ this.#closePromise = (async () => {
22077
+ const child = this.#appServer.child();
22078
+ try {
22079
+ const captured = await captureProcessTree(child);
22080
+ await stopProcessTree(child, captured);
22081
+ } finally {
22082
+ this.#connection?.close();
22083
+ }
22084
+ })();
22085
+ }
22086
+ return this.#closePromise;
22029
22087
  };
22030
22088
  /**
22031
22089
  * Reads the model catalog once per app-server. A failure leaves the catalog empty, which costs
@@ -22269,7 +22327,7 @@ var CodexAcpAgent = class {
22269
22327
  if (method === "turn/started") {
22270
22328
  const decoded = turnNotificationSchema.safeParse(params);
22271
22329
  if (decoded.success && decoded.data.threadId === this.#nativeSessionId && this.#turn !== null) {
22272
- this.#turn = { completion: this.#turn.completion, turn: { id: decoded.data.turn.id } };
22330
+ this.#turn.turn.id = decoded.data.turn.id;
22273
22331
  }
22274
22332
  return;
22275
22333
  }
@@ -22458,10 +22516,20 @@ var CodexAcpAgent = class {
22458
22516
  this.#appServer.respond(request.id, { action: response.action, content: content3 });
22459
22517
  };
22460
22518
  #runTurn = async (input2, signal) => {
22519
+ signal.throwIfAborted();
22461
22520
  if (this.#turn !== null) {
22462
22521
  throw new AcpExecutionError("Another prompt is already running in this conversation", {}, "session_busy");
22463
22522
  }
22464
22523
  const completion = Promise.withResolvers();
22524
+ void completion.promise.catch(() => {
22525
+ });
22526
+ const aborted2 = () => {
22527
+ completion.reject(signal.reason);
22528
+ void this.close().catch((cause) => {
22529
+ console.error("The cancelled Codex endpoint could not release its process tree", cause);
22530
+ });
22531
+ };
22532
+ signal.addEventListener("abort", aborted2, { once: true });
22465
22533
  const turn = { completion, turn: { id: "" } };
22466
22534
  this.#turn = turn;
22467
22535
  try {
@@ -22507,6 +22575,7 @@ var CodexAcpAgent = class {
22507
22575
  }
22508
22576
  return await completion.promise;
22509
22577
  } finally {
22578
+ signal.removeEventListener("abort", aborted2);
22510
22579
  if (this.#turn === turn) {
22511
22580
  this.#turn = null;
22512
22581
  }
@@ -22535,7 +22604,6 @@ var CodexAcpAgent = class {
22535
22604
  if (active === null) {
22536
22605
  return;
22537
22606
  }
22538
- this.#turn = null;
22539
22607
  await this.#updateTail;
22540
22608
  if (turn.status === "failed") {
22541
22609
  active.completion.reject(
@@ -23295,6 +23363,97 @@ function openCodeManagedArchive(platform, architecture) {
23295
23363
  }
23296
23364
 
23297
23365
  // src/agent-catalog/agents/opencode-agent.ts
23366
+ var MODEL_DISCOVERY_TIMEOUT_MILLISECONDS = 3e3;
23367
+ var MODEL_DISCOVERY_OUTPUT_LIMIT_BYTES = 1024 * 1024;
23368
+ var MAXIMUM_MODEL_VALUES = 500;
23369
+ function containsControlCharacter(value) {
23370
+ return Array.from(value).some((character) => {
23371
+ const codePoint = character.codePointAt(0) ?? 0;
23372
+ return codePoint <= 31 || codePoint >= 127 && codePoint <= 159;
23373
+ });
23374
+ }
23375
+ async function discoverModelValues(agent, cwd, signal) {
23376
+ if (!await revalidateExecutable(agent.agentIdentity)) {
23377
+ throw new AcpExecutionError(
23378
+ "The local Agent runtime changed; restart Mobius before discovering settings",
23379
+ {},
23380
+ "agent_runtime_changed"
23381
+ );
23382
+ }
23383
+ const acpArgumentIndex = agent.arguments.indexOf("acp");
23384
+ if (acpArgumentIndex < 0) {
23385
+ throw new AcpExecutionError(
23386
+ "OpenCode does not expose its model discovery command",
23387
+ {},
23388
+ "invalid_session_configuration"
23389
+ );
23390
+ }
23391
+ const result = await runBoundedProcess({
23392
+ arguments: [
23393
+ ...agent.arguments.slice(0, acpArgumentIndex),
23394
+ "models",
23395
+ ...agent.arguments.slice(acpArgumentIndex + 1)
23396
+ ],
23397
+ command: agent.command,
23398
+ cwd,
23399
+ environment: { ...process.env, ...agent.environment },
23400
+ outputLimitBytes: MODEL_DISCOVERY_OUTPUT_LIMIT_BYTES,
23401
+ signal,
23402
+ timeoutMilliseconds: MODEL_DISCOVERY_TIMEOUT_MILLISECONDS
23403
+ });
23404
+ const values = [];
23405
+ const identifiers = /* @__PURE__ */ new Set();
23406
+ for (const rawLine of result.stdout.split(/\r?\n/)) {
23407
+ const value = rawLine.trim();
23408
+ if (value.length === 0) {
23409
+ continue;
23410
+ }
23411
+ if (value.length > 512 || !/^[^\s/]+\/\S+$/.test(value) || containsControlCharacter(value)) {
23412
+ throw new AcpExecutionError(
23413
+ "OpenCode returned an invalid model catalog",
23414
+ {},
23415
+ "invalid_session_configuration"
23416
+ );
23417
+ }
23418
+ if (!identifiers.has(value)) {
23419
+ identifiers.add(value);
23420
+ values.push({ description: "", groupId: "", groupName: "", name: value, value });
23421
+ }
23422
+ if (values.length > MAXIMUM_MODEL_VALUES) {
23423
+ throw new AcpExecutionError("OpenCode returned too many models", {}, "invalid_session_configuration");
23424
+ }
23425
+ }
23426
+ return values;
23427
+ }
23428
+ function mergeModelValues(options, discovered) {
23429
+ if (discovered.length === 0) {
23430
+ return options;
23431
+ }
23432
+ return options.map((option) => {
23433
+ if (option.id !== "model" && option.category !== "model" || option.type !== "select") {
23434
+ return option;
23435
+ }
23436
+ const known = new Map(option.values.map((value) => [value.value, value]));
23437
+ const values = discovered.map((value) => known.get(value.value) ?? value);
23438
+ const identifiers = new Set(values.map((value) => value.value));
23439
+ for (const value of option.values) {
23440
+ if (values.length >= MAXIMUM_MODEL_VALUES) {
23441
+ break;
23442
+ }
23443
+ if (!identifiers.has(value.value)) {
23444
+ identifiers.add(value.value);
23445
+ values.push(value);
23446
+ }
23447
+ }
23448
+ return { ...option, values };
23449
+ });
23450
+ }
23451
+ async function discoverOpenCodeModelOptions(agent, cwd, options, signal) {
23452
+ if (agent.id !== "opencode" || agent.kind !== "acp-adapter-process") {
23453
+ return options;
23454
+ }
23455
+ return mergeModelValues(options, await discoverModelValues(agent, cwd, signal));
23456
+ }
23298
23457
  var OpenCodeAgentSpecification = class extends DirectAcpAgentDefinition {
23299
23458
  versionProbeTimeoutMilliseconds = 15e3;
23300
23459
  adapterVersion = OPENCODE_MANAGED_VERSION;
@@ -23657,24 +23816,40 @@ async function probeInProcessReadiness(agent, environment, defaultWorkspace, con
23657
23816
  environment: { ...filterEnvironment(environment), ...agent.environment }
23658
23817
  });
23659
23818
  try {
23660
- await inProcess.initialize(controller.signal);
23661
23819
  const connection = createAcpClient(new DiscoveryAcpHandler()).connect(inProcess.app());
23662
- const initialized = await connection.agent.request(
23663
- methods6.agent.initialize,
23664
- {
23665
- clientCapabilities: {},
23666
- clientInfo: { name: "mobius", version: "0.0.3" },
23667
- protocolVersion: PROTOCOL_VERSION2
23668
- },
23669
- { cancellationSignal: controller.signal }
23670
- );
23671
- if (initialized.protocolVersion !== PROTOCOL_VERSION2) {
23672
- throw new AgentProbeError("acp_incompatible", "ACP agent selected an unsupported protocol version");
23820
+ try {
23821
+ return await Promise.race([
23822
+ (async () => {
23823
+ await inProcess.initialize(controller.signal);
23824
+ const initialized = await connection.agent.request(
23825
+ methods6.agent.initialize,
23826
+ {
23827
+ clientCapabilities: {},
23828
+ clientInfo: { name: "mobius", version: "0.0.3" },
23829
+ protocolVersion: PROTOCOL_VERSION2
23830
+ },
23831
+ { cancellationSignal: controller.signal }
23832
+ );
23833
+ if (initialized.protocolVersion !== PROTOCOL_VERSION2) {
23834
+ throw new AgentProbeError(
23835
+ "acp_incompatible",
23836
+ "ACP agent selected an unsupported protocol version"
23837
+ );
23838
+ }
23839
+ return new VerifiedAcpReadiness(
23840
+ normalizeVersionOutput(initialized.agentInfo?.version ?? ""),
23841
+ normalizeAcpCapabilities(initialized)
23842
+ );
23843
+ })(),
23844
+ inProcess.terminated.then((termination) => {
23845
+ throw new AgentProbeError("acp_incompatible", "The ACP endpoint stopped during initialization", {
23846
+ cause: acpEndpointTerminationError(termination)
23847
+ });
23848
+ })
23849
+ ]);
23850
+ } finally {
23851
+ connection.close();
23673
23852
  }
23674
- return new VerifiedAcpReadiness(
23675
- normalizeVersionOutput(initialized.agentInfo?.version ?? ""),
23676
- normalizeAcpCapabilities(initialized)
23677
- );
23678
23853
  } finally {
23679
23854
  await inProcess.close();
23680
23855
  }
@@ -36491,8 +36666,8 @@ var AcpProcessSession = class _AcpProcessSession {
36491
36666
  #pendingElicitations = /* @__PURE__ */ new Map();
36492
36667
  #pendingPermissions = /* @__PURE__ */ new Map();
36493
36668
  #preSessionUpdates = [];
36494
- // The adapter-process topology only. An in-process agent owns the app-server child itself.
36495
- #processExit;
36669
+ // Both topologies report a terminal outcome, even after a prompt's initial RPC is acknowledged.
36670
+ #termination;
36496
36671
  #runtimeChild;
36497
36672
  #metrics;
36498
36673
  #sessionConfigProtocol;
@@ -36536,8 +36711,7 @@ var AcpProcessSession = class _AcpProcessSession {
36536
36711
  });
36537
36712
  this.#inProcessAgent = inProcess;
36538
36713
  this.#runtimeChild = null;
36539
- this.#processExit = new Promise(() => {
36540
- });
36714
+ this.#termination = inProcess.terminated;
36541
36715
  this.#connection = createAcpClient(this).connect(inProcess.app());
36542
36716
  return;
36543
36717
  }
@@ -36561,9 +36735,16 @@ var AcpProcessSession = class _AcpProcessSession {
36561
36735
  stderr.on("data", (chunk) => {
36562
36736
  process.stderr.write(`[${agent.id}-acp] ${chunk}`);
36563
36737
  });
36564
- this.#processExit = new Promise((resolve7) => {
36565
- child.once("error", resolve7);
36566
- child.once("exit", resolve7);
36738
+ this.#termination = new Promise((resolve7) => {
36739
+ child.once("error", (cause) => {
36740
+ resolve7({ kind: "failed", error: new AcpExecutionError("The ACP process could not run", { cause }) });
36741
+ });
36742
+ child.once("exit", (code, signal) => {
36743
+ resolve7({
36744
+ kind: "failed",
36745
+ error: new AcpExecutionError("The ACP process stopped", { cause: { code, signal } })
36746
+ });
36747
+ });
36567
36748
  });
36568
36749
  const stream = ndJsonStream2(createWritableAcpStream(stdin), readableWebStream(stdout));
36569
36750
  this.#connection = createAcpClient(this).connect(stream);
@@ -37705,8 +37886,9 @@ var AcpProcessSession = class _AcpProcessSession {
37705
37886
  try {
37706
37887
  return await Promise.race([
37707
37888
  operation,
37708
- this.#processExit.then(() => {
37709
- throw new AcpExecutionError(exitMessage);
37889
+ this.#termination.then((termination) => {
37890
+ const cause = acpEndpointTerminationError(termination);
37891
+ throw new AcpExecutionError(exitMessage, { cause }, cause.code);
37710
37892
  }),
37711
37893
  aborted2
37712
37894
  ]);
@@ -42694,39 +42876,26 @@ async function resolveSessionDirectories(directories, bindingId, directoryId2, a
42694
42876
  }
42695
42877
  return new ResolvedSessionDirectories(cwd, additionalDirectories, additionalDirectoryEntries);
42696
42878
  }
42697
- var OPENCODE_PROVIDER_SETTLEMENT_MILLISECONDS = 1e3;
42698
- async function waitForAgentSettingsReadiness(agentId, signal, timer) {
42699
- if (agentId !== "opencode") {
42700
- return;
42701
- }
42702
- signal.throwIfAborted();
42703
- await new Promise((resolve7) => {
42704
- const readiness = timer.schedule(finish, OPENCODE_PROVIDER_SETTLEMENT_MILLISECONDS);
42705
- function finish() {
42706
- readiness.cancel();
42707
- signal.removeEventListener("abort", finish);
42708
- resolve7();
42709
- }
42710
- signal.addEventListener("abort", finish, { once: true });
42711
- });
42712
- signal.throwIfAborted();
42713
- }
42714
42879
  function isUnavailableModel(cause, modelSettingId, requestedModel) {
42715
42880
  return cause instanceof AcpConfigurationValueUnavailableError && cause.configId === modelSettingId && cause.requestedValue === requestedModel;
42716
42881
  }
42717
42882
  function unsupportedModelIds(unsupportedModels) {
42718
42883
  return [...new Set(unsupportedModels.map((item) => item.requestedValue))];
42719
42884
  }
42720
- async function discoverAgentSettings(command, config2, directories, sessions, signal, timer) {
42885
+ async function discoverAgentSettings(command, config2, directories, sessions, signal) {
42721
42886
  const agent = config2.catalog.find(command.agentId);
42722
42887
  const cwd = await directories.resolve(config2.bindingId, "default", signal);
42723
- await waitForAgentSettingsReadiness(agent.id, signal, timer);
42724
- const baseSnapshot = await sessions.inspectAgentSettings({
42888
+ const inspectedBaseSnapshot = await sessions.inspectAgentSettings({
42725
42889
  additionalDirectories: [],
42726
42890
  agent,
42727
42891
  cwd,
42728
42892
  signal
42729
42893
  });
42894
+ const baseSnapshot = {
42895
+ agentName: inspectedBaseSnapshot.agentName,
42896
+ agentVersion: inspectedBaseSnapshot.agentVersion,
42897
+ configOptions: await discoverOpenCodeModelOptions(agent, cwd, inspectedBaseSnapshot.configOptions, signal)
42898
+ };
42730
42899
  const baseModel = modelOption(baseSnapshot.configOptions);
42731
42900
  const unsupportedModels = [];
42732
42901
  let selectedSnapshot = baseSnapshot;
@@ -44177,8 +44346,7 @@ async function runRelayConnection(config2, directories, audit, sessions, install
44177
44346
  config2,
44178
44347
  directories,
44179
44348
  sessions,
44180
- operationSignal,
44181
- timer
44349
+ operationSignal
44182
44350
  );
44183
44351
  for (const diagnostic of result.unsupportedModels) {
44184
44352
  const details = agentSettingsFailureDetails(command2.agentId, diagnostic);