@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/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
- // The adapter-process topology only. An in-process agent owns the app-server child itself.
31881
- #processExit;
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.#processExit = new Promise(() => {
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.#processExit = new Promise((resolve8) => {
31951
- child.once("error", resolve8);
31952
- child.once("exit", resolve8);
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.#processExit.then(() => {
33095
- throw new AcpExecutionError(exitMessage);
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 Error {
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
- #processExit;
35064
- #failure = null;
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.#processExit = new Promise((resolve8) => {
35094
- this.#child.once("error", resolve8);
35095
- this.#child.once("exit", resolve8);
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.#failure ??= error62;
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
- #exitedFailure = (method) => this.#failure ?? new CodexAppServerError("codex_app_server_exited", `The Codex app-server stopped during ${method}`);
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
- if (this.#closed) {
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 Promise.race([completion.promise, this.#processExit.then(() => this.#exitedFailure(method))]);
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
- if (this.#closed) {
35218
- return;
35219
- }
35270
+ this.#requireOpen();
35220
35271
  const stdin = this.#child.stdin;
35221
35272
  if (stdin === null || stdin.destroyed) {
35222
- throw new CodexAppServerError("codex_app_server_closed", "The Codex app-server input is closed");
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
- if (this.#closed) {
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 = async () => {
35744
- const child = this.#appServer.child();
35745
- const captured = await captureProcessTree(child);
35746
- this.#appServer.detach();
35747
- await stopProcessTree(child, captured);
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 = { completion: this.#turn.completion, turn: { id: decoded.data.turn.id } };
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(
@@ -37003,6 +37078,97 @@ function openCodeManagedArchive(platform, architecture) {
37003
37078
  }
37004
37079
 
37005
37080
  // src/agent-catalog/agents/opencode-agent.ts
37081
+ var MODEL_DISCOVERY_TIMEOUT_MILLISECONDS = 3e3;
37082
+ var MODEL_DISCOVERY_OUTPUT_LIMIT_BYTES = 1024 * 1024;
37083
+ var MAXIMUM_MODEL_VALUES = 500;
37084
+ function containsControlCharacter(value) {
37085
+ return Array.from(value).some((character) => {
37086
+ const codePoint = character.codePointAt(0) ?? 0;
37087
+ return codePoint <= 31 || codePoint >= 127 && codePoint <= 159;
37088
+ });
37089
+ }
37090
+ async function discoverModelValues(agent, cwd, signal) {
37091
+ if (!await revalidateExecutable(agent.agentIdentity)) {
37092
+ throw new AcpExecutionError(
37093
+ "The local Agent runtime changed; restart Mobius before discovering settings",
37094
+ {},
37095
+ "agent_runtime_changed"
37096
+ );
37097
+ }
37098
+ const acpArgumentIndex = agent.arguments.indexOf("acp");
37099
+ if (acpArgumentIndex < 0) {
37100
+ throw new AcpExecutionError(
37101
+ "OpenCode does not expose its model discovery command",
37102
+ {},
37103
+ "invalid_session_configuration"
37104
+ );
37105
+ }
37106
+ const result = await runBoundedProcess({
37107
+ arguments: [
37108
+ ...agent.arguments.slice(0, acpArgumentIndex),
37109
+ "models",
37110
+ ...agent.arguments.slice(acpArgumentIndex + 1)
37111
+ ],
37112
+ command: agent.command,
37113
+ cwd,
37114
+ environment: { ...process.env, ...agent.environment },
37115
+ outputLimitBytes: MODEL_DISCOVERY_OUTPUT_LIMIT_BYTES,
37116
+ signal,
37117
+ timeoutMilliseconds: MODEL_DISCOVERY_TIMEOUT_MILLISECONDS
37118
+ });
37119
+ const values = [];
37120
+ const identifiers = /* @__PURE__ */ new Set();
37121
+ for (const rawLine of result.stdout.split(/\r?\n/)) {
37122
+ const value = rawLine.trim();
37123
+ if (value.length === 0) {
37124
+ continue;
37125
+ }
37126
+ if (value.length > 512 || !/^[^\s/]+\/\S+$/.test(value) || containsControlCharacter(value)) {
37127
+ throw new AcpExecutionError(
37128
+ "OpenCode returned an invalid model catalog",
37129
+ {},
37130
+ "invalid_session_configuration"
37131
+ );
37132
+ }
37133
+ if (!identifiers.has(value)) {
37134
+ identifiers.add(value);
37135
+ values.push({ description: "", groupId: "", groupName: "", name: value, value });
37136
+ }
37137
+ if (values.length > MAXIMUM_MODEL_VALUES) {
37138
+ throw new AcpExecutionError("OpenCode returned too many models", {}, "invalid_session_configuration");
37139
+ }
37140
+ }
37141
+ return values;
37142
+ }
37143
+ function mergeModelValues(options, discovered) {
37144
+ if (discovered.length === 0) {
37145
+ return options;
37146
+ }
37147
+ return options.map((option) => {
37148
+ if (option.id !== "model" && option.category !== "model" || option.type !== "select") {
37149
+ return option;
37150
+ }
37151
+ const known = new Map(option.values.map((value) => [value.value, value]));
37152
+ const values = discovered.map((value) => known.get(value.value) ?? value);
37153
+ const identifiers = new Set(values.map((value) => value.value));
37154
+ for (const value of option.values) {
37155
+ if (values.length >= MAXIMUM_MODEL_VALUES) {
37156
+ break;
37157
+ }
37158
+ if (!identifiers.has(value.value)) {
37159
+ identifiers.add(value.value);
37160
+ values.push(value);
37161
+ }
37162
+ }
37163
+ return { ...option, values };
37164
+ });
37165
+ }
37166
+ async function discoverOpenCodeModelOptions(agent, cwd, options, signal) {
37167
+ if (agent.id !== "opencode" || agent.kind !== "acp-adapter-process") {
37168
+ return options;
37169
+ }
37170
+ return mergeModelValues(options, await discoverModelValues(agent, cwd, signal));
37171
+ }
37006
37172
  var OpenCodeAgentSpecification = class extends DirectAcpAgentDefinition {
37007
37173
  versionProbeTimeoutMilliseconds = 15e3;
37008
37174
  adapterVersion = OPENCODE_MANAGED_VERSION;
@@ -37336,24 +37502,40 @@ async function probeInProcessReadiness(agent, environment, defaultWorkspace, con
37336
37502
  environment: { ...filterEnvironment(environment), ...agent.environment }
37337
37503
  });
37338
37504
  try {
37339
- await inProcess.initialize(controller.signal);
37340
37505
  const connection = createAcpClient(new DiscoveryAcpHandler()).connect(inProcess.app());
37341
- const initialized = await connection.agent.request(
37342
- methods8.agent.initialize,
37343
- {
37344
- clientCapabilities: {},
37345
- clientInfo: { name: "mobius", version: "0.0.3" },
37346
- protocolVersion: PROTOCOL_VERSION3
37347
- },
37348
- { cancellationSignal: controller.signal }
37349
- );
37350
- if (initialized.protocolVersion !== PROTOCOL_VERSION3) {
37351
- throw new AgentProbeError("acp_incompatible", "ACP agent selected an unsupported protocol version");
37506
+ try {
37507
+ return await Promise.race([
37508
+ (async () => {
37509
+ await inProcess.initialize(controller.signal);
37510
+ const initialized = await connection.agent.request(
37511
+ methods8.agent.initialize,
37512
+ {
37513
+ clientCapabilities: {},
37514
+ clientInfo: { name: "mobius", version: "0.0.3" },
37515
+ protocolVersion: PROTOCOL_VERSION3
37516
+ },
37517
+ { cancellationSignal: controller.signal }
37518
+ );
37519
+ if (initialized.protocolVersion !== PROTOCOL_VERSION3) {
37520
+ throw new AgentProbeError(
37521
+ "acp_incompatible",
37522
+ "ACP agent selected an unsupported protocol version"
37523
+ );
37524
+ }
37525
+ return new VerifiedAcpReadiness(
37526
+ normalizeVersionOutput(initialized.agentInfo?.version ?? ""),
37527
+ normalizeAcpCapabilities(initialized)
37528
+ );
37529
+ })(),
37530
+ inProcess.terminated.then((termination) => {
37531
+ throw new AgentProbeError("acp_incompatible", "The ACP endpoint stopped during initialization", {
37532
+ cause: acpEndpointTerminationError(termination)
37533
+ });
37534
+ })
37535
+ ]);
37536
+ } finally {
37537
+ connection.close();
37352
37538
  }
37353
- return new VerifiedAcpReadiness(
37354
- normalizeVersionOutput(initialized.agentInfo?.version ?? ""),
37355
- normalizeAcpCapabilities(initialized)
37356
- );
37357
37539
  } finally {
37358
37540
  await inProcess.close();
37359
37541
  }
@@ -42614,39 +42796,26 @@ async function resolveSessionDirectories(directories, bindingId, directoryId2, a
42614
42796
  }
42615
42797
  return new ResolvedSessionDirectories(cwd, additionalDirectories, additionalDirectoryEntries);
42616
42798
  }
42617
- var OPENCODE_PROVIDER_SETTLEMENT_MILLISECONDS = 1e3;
42618
- async function waitForAgentSettingsReadiness(agentId, signal, timer) {
42619
- if (agentId !== "opencode") {
42620
- return;
42621
- }
42622
- signal.throwIfAborted();
42623
- await new Promise((resolve8) => {
42624
- const readiness = timer.schedule(finish, OPENCODE_PROVIDER_SETTLEMENT_MILLISECONDS);
42625
- function finish() {
42626
- readiness.cancel();
42627
- signal.removeEventListener("abort", finish);
42628
- resolve8();
42629
- }
42630
- signal.addEventListener("abort", finish, { once: true });
42631
- });
42632
- signal.throwIfAborted();
42633
- }
42634
42799
  function isUnavailableModel(cause, modelSettingId, requestedModel) {
42635
42800
  return cause instanceof AcpConfigurationValueUnavailableError && cause.configId === modelSettingId && cause.requestedValue === requestedModel;
42636
42801
  }
42637
42802
  function unsupportedModelIds(unsupportedModels) {
42638
42803
  return [...new Set(unsupportedModels.map((item) => item.requestedValue))];
42639
42804
  }
42640
- async function discoverAgentSettings(command, config2, directories, sessions, signal, timer) {
42805
+ async function discoverAgentSettings(command, config2, directories, sessions, signal) {
42641
42806
  const agent = config2.catalog.find(command.agentId);
42642
42807
  const cwd = await directories.resolve(config2.bindingId, "default", signal);
42643
- await waitForAgentSettingsReadiness(agent.id, signal, timer);
42644
- const baseSnapshot = await sessions.inspectAgentSettings({
42808
+ const inspectedBaseSnapshot = await sessions.inspectAgentSettings({
42645
42809
  additionalDirectories: [],
42646
42810
  agent,
42647
42811
  cwd,
42648
42812
  signal
42649
42813
  });
42814
+ const baseSnapshot = {
42815
+ agentName: inspectedBaseSnapshot.agentName,
42816
+ agentVersion: inspectedBaseSnapshot.agentVersion,
42817
+ configOptions: await discoverOpenCodeModelOptions(agent, cwd, inspectedBaseSnapshot.configOptions, signal)
42818
+ };
42650
42819
  const baseModel = modelOption(baseSnapshot.configOptions);
42651
42820
  const unsupportedModels = [];
42652
42821
  let selectedSnapshot = baseSnapshot;
@@ -44097,8 +44266,7 @@ async function runRelayConnection(config2, directories, audit, sessions, install
44097
44266
  config2,
44098
44267
  directories,
44099
44268
  sessions,
44100
- operationSignal,
44101
- timer
44269
+ operationSignal
44102
44270
  );
44103
44271
  for (const diagnostic of result.unsupportedModels) {
44104
44272
  const details = agentSettingsFailureDetails(command2.agentId, diagnostic);