@moxt-ai/mobius 0.0.80 → 0.0.82

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/runtime.js CHANGED
@@ -21175,11 +21175,12 @@ var threadLifecycleResponseSchema = external_exports.object({
21175
21175
  });
21176
21176
  var threadResumeResponseSchema = threadLifecycleResponseSchema;
21177
21177
  var threadForkResponseSchema = threadLifecycleResponseSchema;
21178
+ var threadTitleSchema = external_exports.string().transform((value) => value.slice(0, 500));
21178
21179
  var threadSummarySchema = external_exports.object({
21179
21180
  cwd: boundedText(2048),
21180
21181
  id: boundedText(256),
21181
- name: boundedText(500).nullish(),
21182
- preview: boundedText(500).nullish(),
21182
+ name: threadTitleSchema.nullish(),
21183
+ preview: threadTitleSchema.nullish(),
21183
21184
  updatedAt: external_exports.number().int().nonnegative()
21184
21185
  });
21185
21186
  var threadListResponseSchema = external_exports.object({
@@ -23235,6 +23236,97 @@ function openCodeManagedArchive(platform, architecture) {
23235
23236
  }
23236
23237
 
23237
23238
  // src/agent-catalog/agents/opencode-agent.ts
23239
+ var MODEL_DISCOVERY_TIMEOUT_MILLISECONDS = 3e3;
23240
+ var MODEL_DISCOVERY_OUTPUT_LIMIT_BYTES = 1024 * 1024;
23241
+ var MAXIMUM_MODEL_VALUES = 500;
23242
+ function containsControlCharacter(value) {
23243
+ return Array.from(value).some((character) => {
23244
+ const codePoint = character.codePointAt(0) ?? 0;
23245
+ return codePoint <= 31 || codePoint >= 127 && codePoint <= 159;
23246
+ });
23247
+ }
23248
+ async function discoverModelValues(agent, cwd, signal) {
23249
+ if (!await revalidateExecutable(agent.agentIdentity)) {
23250
+ throw new AcpExecutionError(
23251
+ "The local Agent runtime changed; restart Mobius before discovering settings",
23252
+ {},
23253
+ "agent_runtime_changed"
23254
+ );
23255
+ }
23256
+ const acpArgumentIndex = agent.arguments.indexOf("acp");
23257
+ if (acpArgumentIndex < 0) {
23258
+ throw new AcpExecutionError(
23259
+ "OpenCode does not expose its model discovery command",
23260
+ {},
23261
+ "invalid_session_configuration"
23262
+ );
23263
+ }
23264
+ const result = await runBoundedProcess({
23265
+ arguments: [
23266
+ ...agent.arguments.slice(0, acpArgumentIndex),
23267
+ "models",
23268
+ ...agent.arguments.slice(acpArgumentIndex + 1)
23269
+ ],
23270
+ command: agent.command,
23271
+ cwd,
23272
+ environment: { ...process.env, ...agent.environment },
23273
+ outputLimitBytes: MODEL_DISCOVERY_OUTPUT_LIMIT_BYTES,
23274
+ signal,
23275
+ timeoutMilliseconds: MODEL_DISCOVERY_TIMEOUT_MILLISECONDS
23276
+ });
23277
+ const values = [];
23278
+ const identifiers = /* @__PURE__ */ new Set();
23279
+ for (const rawLine of result.stdout.split(/\r?\n/)) {
23280
+ const value = rawLine.trim();
23281
+ if (value.length === 0) {
23282
+ continue;
23283
+ }
23284
+ if (value.length > 512 || !/^[^\s/]+\/\S+$/.test(value) || containsControlCharacter(value)) {
23285
+ throw new AcpExecutionError(
23286
+ "OpenCode returned an invalid model catalog",
23287
+ {},
23288
+ "invalid_session_configuration"
23289
+ );
23290
+ }
23291
+ if (!identifiers.has(value)) {
23292
+ identifiers.add(value);
23293
+ values.push({ description: "", groupId: "", groupName: "", name: value, value });
23294
+ }
23295
+ if (values.length > MAXIMUM_MODEL_VALUES) {
23296
+ throw new AcpExecutionError("OpenCode returned too many models", {}, "invalid_session_configuration");
23297
+ }
23298
+ }
23299
+ return values;
23300
+ }
23301
+ function mergeModelValues(options, discovered) {
23302
+ if (discovered.length === 0) {
23303
+ return options;
23304
+ }
23305
+ return options.map((option) => {
23306
+ if (option.id !== "model" && option.category !== "model" || option.type !== "select") {
23307
+ return option;
23308
+ }
23309
+ const known = new Map(option.values.map((value) => [value.value, value]));
23310
+ const values = discovered.map((value) => known.get(value.value) ?? value);
23311
+ const identifiers = new Set(values.map((value) => value.value));
23312
+ for (const value of option.values) {
23313
+ if (values.length >= MAXIMUM_MODEL_VALUES) {
23314
+ break;
23315
+ }
23316
+ if (!identifiers.has(value.value)) {
23317
+ identifiers.add(value.value);
23318
+ values.push(value);
23319
+ }
23320
+ }
23321
+ return { ...option, values };
23322
+ });
23323
+ }
23324
+ async function discoverOpenCodeModelOptions(agent, cwd, options, signal) {
23325
+ if (agent.id !== "opencode" || agent.kind !== "acp-adapter-process") {
23326
+ return options;
23327
+ }
23328
+ return mergeModelValues(options, await discoverModelValues(agent, cwd, signal));
23329
+ }
23238
23330
  var OpenCodeAgentSpecification = class extends DirectAcpAgentDefinition {
23239
23331
  versionProbeTimeoutMilliseconds = 15e3;
23240
23332
  adapterVersion = OPENCODE_MANAGED_VERSION;
@@ -41790,39 +41882,26 @@ async function resolveSessionDirectories(directories, bindingId, directoryId2, a
41790
41882
  }
41791
41883
  return new ResolvedSessionDirectories(cwd, additionalDirectories, additionalDirectoryEntries);
41792
41884
  }
41793
- var OPENCODE_PROVIDER_SETTLEMENT_MILLISECONDS = 1e3;
41794
- async function waitForAgentSettingsReadiness(agentId, signal, timer) {
41795
- if (agentId !== "opencode") {
41796
- return;
41797
- }
41798
- signal.throwIfAborted();
41799
- await new Promise((resolve8) => {
41800
- const readiness = timer.schedule(finish, OPENCODE_PROVIDER_SETTLEMENT_MILLISECONDS);
41801
- function finish() {
41802
- readiness.cancel();
41803
- signal.removeEventListener("abort", finish);
41804
- resolve8();
41805
- }
41806
- signal.addEventListener("abort", finish, { once: true });
41807
- });
41808
- signal.throwIfAborted();
41809
- }
41810
41885
  function isUnavailableModel(cause, modelSettingId, requestedModel) {
41811
41886
  return cause instanceof AcpConfigurationValueUnavailableError && cause.configId === modelSettingId && cause.requestedValue === requestedModel;
41812
41887
  }
41813
41888
  function unsupportedModelIds(unsupportedModels) {
41814
41889
  return [...new Set(unsupportedModels.map((item) => item.requestedValue))];
41815
41890
  }
41816
- async function discoverAgentSettings(command, config2, directories, sessions, signal, timer) {
41891
+ async function discoverAgentSettings(command, config2, directories, sessions, signal) {
41817
41892
  const agent = config2.catalog.find(command.agentId);
41818
41893
  const cwd = await directories.resolve(config2.bindingId, "default", signal);
41819
- await waitForAgentSettingsReadiness(agent.id, signal, timer);
41820
- const baseSnapshot = await sessions.inspectAgentSettings({
41894
+ const inspectedBaseSnapshot = await sessions.inspectAgentSettings({
41821
41895
  additionalDirectories: [],
41822
41896
  agent,
41823
41897
  cwd,
41824
41898
  signal
41825
41899
  });
41900
+ const baseSnapshot = {
41901
+ agentName: inspectedBaseSnapshot.agentName,
41902
+ agentVersion: inspectedBaseSnapshot.agentVersion,
41903
+ configOptions: await discoverOpenCodeModelOptions(agent, cwd, inspectedBaseSnapshot.configOptions, signal)
41904
+ };
41826
41905
  const baseModel = modelOption(baseSnapshot.configOptions);
41827
41906
  const unsupportedModels = [];
41828
41907
  let selectedSnapshot = baseSnapshot;
@@ -43273,8 +43352,7 @@ async function runRelayConnection(config2, directories, audit, sessions, install
43273
43352
  config2,
43274
43353
  directories,
43275
43354
  sessions,
43276
- operationSignal,
43277
- timer
43355
+ operationSignal
43278
43356
  );
43279
43357
  for (const diagnostic of result.unsupportedModels) {
43280
43358
  const details = agentSettingsFailureDetails(command2.agentId, diagnostic);