@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/index.js CHANGED
@@ -35029,11 +35029,12 @@ var threadLifecycleResponseSchema = external_exports.object({
35029
35029
  });
35030
35030
  var threadResumeResponseSchema = threadLifecycleResponseSchema;
35031
35031
  var threadForkResponseSchema = threadLifecycleResponseSchema;
35032
+ var threadTitleSchema = external_exports.string().transform((value) => value.slice(0, 500));
35032
35033
  var threadSummarySchema = external_exports.object({
35033
35034
  cwd: boundedText(2048),
35034
35035
  id: boundedText(256),
35035
- name: boundedText(500).nullish(),
35036
- preview: boundedText(500).nullish(),
35036
+ name: threadTitleSchema.nullish(),
35037
+ preview: threadTitleSchema.nullish(),
35037
35038
  updatedAt: external_exports.number().int().nonnegative()
35038
35039
  });
35039
35040
  var threadListResponseSchema = external_exports.object({
@@ -37078,6 +37079,97 @@ function openCodeManagedArchive(platform, architecture) {
37078
37079
  }
37079
37080
 
37080
37081
  // src/agent-catalog/agents/opencode-agent.ts
37082
+ var MODEL_DISCOVERY_TIMEOUT_MILLISECONDS = 3e3;
37083
+ var MODEL_DISCOVERY_OUTPUT_LIMIT_BYTES = 1024 * 1024;
37084
+ var MAXIMUM_MODEL_VALUES = 500;
37085
+ function containsControlCharacter(value) {
37086
+ return Array.from(value).some((character) => {
37087
+ const codePoint = character.codePointAt(0) ?? 0;
37088
+ return codePoint <= 31 || codePoint >= 127 && codePoint <= 159;
37089
+ });
37090
+ }
37091
+ async function discoverModelValues(agent, cwd, signal) {
37092
+ if (!await revalidateExecutable(agent.agentIdentity)) {
37093
+ throw new AcpExecutionError(
37094
+ "The local Agent runtime changed; restart Mobius before discovering settings",
37095
+ {},
37096
+ "agent_runtime_changed"
37097
+ );
37098
+ }
37099
+ const acpArgumentIndex = agent.arguments.indexOf("acp");
37100
+ if (acpArgumentIndex < 0) {
37101
+ throw new AcpExecutionError(
37102
+ "OpenCode does not expose its model discovery command",
37103
+ {},
37104
+ "invalid_session_configuration"
37105
+ );
37106
+ }
37107
+ const result = await runBoundedProcess({
37108
+ arguments: [
37109
+ ...agent.arguments.slice(0, acpArgumentIndex),
37110
+ "models",
37111
+ ...agent.arguments.slice(acpArgumentIndex + 1)
37112
+ ],
37113
+ command: agent.command,
37114
+ cwd,
37115
+ environment: { ...process.env, ...agent.environment },
37116
+ outputLimitBytes: MODEL_DISCOVERY_OUTPUT_LIMIT_BYTES,
37117
+ signal,
37118
+ timeoutMilliseconds: MODEL_DISCOVERY_TIMEOUT_MILLISECONDS
37119
+ });
37120
+ const values = [];
37121
+ const identifiers = /* @__PURE__ */ new Set();
37122
+ for (const rawLine of result.stdout.split(/\r?\n/)) {
37123
+ const value = rawLine.trim();
37124
+ if (value.length === 0) {
37125
+ continue;
37126
+ }
37127
+ if (value.length > 512 || !/^[^\s/]+\/\S+$/.test(value) || containsControlCharacter(value)) {
37128
+ throw new AcpExecutionError(
37129
+ "OpenCode returned an invalid model catalog",
37130
+ {},
37131
+ "invalid_session_configuration"
37132
+ );
37133
+ }
37134
+ if (!identifiers.has(value)) {
37135
+ identifiers.add(value);
37136
+ values.push({ description: "", groupId: "", groupName: "", name: value, value });
37137
+ }
37138
+ if (values.length > MAXIMUM_MODEL_VALUES) {
37139
+ throw new AcpExecutionError("OpenCode returned too many models", {}, "invalid_session_configuration");
37140
+ }
37141
+ }
37142
+ return values;
37143
+ }
37144
+ function mergeModelValues(options, discovered) {
37145
+ if (discovered.length === 0) {
37146
+ return options;
37147
+ }
37148
+ return options.map((option) => {
37149
+ if (option.id !== "model" && option.category !== "model" || option.type !== "select") {
37150
+ return option;
37151
+ }
37152
+ const known = new Map(option.values.map((value) => [value.value, value]));
37153
+ const values = discovered.map((value) => known.get(value.value) ?? value);
37154
+ const identifiers = new Set(values.map((value) => value.value));
37155
+ for (const value of option.values) {
37156
+ if (values.length >= MAXIMUM_MODEL_VALUES) {
37157
+ break;
37158
+ }
37159
+ if (!identifiers.has(value.value)) {
37160
+ identifiers.add(value.value);
37161
+ values.push(value);
37162
+ }
37163
+ }
37164
+ return { ...option, values };
37165
+ });
37166
+ }
37167
+ async function discoverOpenCodeModelOptions(agent, cwd, options, signal) {
37168
+ if (agent.id !== "opencode" || agent.kind !== "acp-adapter-process") {
37169
+ return options;
37170
+ }
37171
+ return mergeModelValues(options, await discoverModelValues(agent, cwd, signal));
37172
+ }
37081
37173
  var OpenCodeAgentSpecification = class extends DirectAcpAgentDefinition {
37082
37174
  versionProbeTimeoutMilliseconds = 15e3;
37083
37175
  adapterVersion = OPENCODE_MANAGED_VERSION;
@@ -42705,39 +42797,26 @@ async function resolveSessionDirectories(directories, bindingId, directoryId2, a
42705
42797
  }
42706
42798
  return new ResolvedSessionDirectories(cwd, additionalDirectories, additionalDirectoryEntries);
42707
42799
  }
42708
- var OPENCODE_PROVIDER_SETTLEMENT_MILLISECONDS = 1e3;
42709
- async function waitForAgentSettingsReadiness(agentId, signal, timer) {
42710
- if (agentId !== "opencode") {
42711
- return;
42712
- }
42713
- signal.throwIfAborted();
42714
- await new Promise((resolve8) => {
42715
- const readiness = timer.schedule(finish, OPENCODE_PROVIDER_SETTLEMENT_MILLISECONDS);
42716
- function finish() {
42717
- readiness.cancel();
42718
- signal.removeEventListener("abort", finish);
42719
- resolve8();
42720
- }
42721
- signal.addEventListener("abort", finish, { once: true });
42722
- });
42723
- signal.throwIfAborted();
42724
- }
42725
42800
  function isUnavailableModel(cause, modelSettingId, requestedModel) {
42726
42801
  return cause instanceof AcpConfigurationValueUnavailableError && cause.configId === modelSettingId && cause.requestedValue === requestedModel;
42727
42802
  }
42728
42803
  function unsupportedModelIds(unsupportedModels) {
42729
42804
  return [...new Set(unsupportedModels.map((item) => item.requestedValue))];
42730
42805
  }
42731
- async function discoverAgentSettings(command, config2, directories, sessions, signal, timer) {
42806
+ async function discoverAgentSettings(command, config2, directories, sessions, signal) {
42732
42807
  const agent = config2.catalog.find(command.agentId);
42733
42808
  const cwd = await directories.resolve(config2.bindingId, "default", signal);
42734
- await waitForAgentSettingsReadiness(agent.id, signal, timer);
42735
- const baseSnapshot = await sessions.inspectAgentSettings({
42809
+ const inspectedBaseSnapshot = await sessions.inspectAgentSettings({
42736
42810
  additionalDirectories: [],
42737
42811
  agent,
42738
42812
  cwd,
42739
42813
  signal
42740
42814
  });
42815
+ const baseSnapshot = {
42816
+ agentName: inspectedBaseSnapshot.agentName,
42817
+ agentVersion: inspectedBaseSnapshot.agentVersion,
42818
+ configOptions: await discoverOpenCodeModelOptions(agent, cwd, inspectedBaseSnapshot.configOptions, signal)
42819
+ };
42741
42820
  const baseModel = modelOption(baseSnapshot.configOptions);
42742
42821
  const unsupportedModels = [];
42743
42822
  let selectedSnapshot = baseSnapshot;
@@ -44188,8 +44267,7 @@ async function runRelayConnection(config2, directories, audit, sessions, install
44188
44267
  config2,
44189
44268
  directories,
44190
44269
  sessions,
44191
- operationSignal,
44192
- timer
44270
+ operationSignal
44193
44271
  );
44194
44272
  for (const diagnostic of result.unsupportedModels) {
44195
44273
  const details = agentSettingsFailureDetails(command2.agentId, diagnostic);