@moxt-ai/mobius 0.0.80 → 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/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 +100 -23
- package/dist/cli.js.map +3 -3
- package/dist/index.js +99 -22
- package/dist/index.js.map +3 -3
- 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 +99 -22
- package/dist/runtime.js.map +3 -3
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -37078,6 +37078,97 @@ function openCodeManagedArchive(platform, architecture) {
|
|
|
37078
37078
|
}
|
|
37079
37079
|
|
|
37080
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
|
+
}
|
|
37081
37172
|
var OpenCodeAgentSpecification = class extends DirectAcpAgentDefinition {
|
|
37082
37173
|
versionProbeTimeoutMilliseconds = 15e3;
|
|
37083
37174
|
adapterVersion = OPENCODE_MANAGED_VERSION;
|
|
@@ -42705,39 +42796,26 @@ async function resolveSessionDirectories(directories, bindingId, directoryId2, a
|
|
|
42705
42796
|
}
|
|
42706
42797
|
return new ResolvedSessionDirectories(cwd, additionalDirectories, additionalDirectoryEntries);
|
|
42707
42798
|
}
|
|
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
42799
|
function isUnavailableModel(cause, modelSettingId, requestedModel) {
|
|
42726
42800
|
return cause instanceof AcpConfigurationValueUnavailableError && cause.configId === modelSettingId && cause.requestedValue === requestedModel;
|
|
42727
42801
|
}
|
|
42728
42802
|
function unsupportedModelIds(unsupportedModels) {
|
|
42729
42803
|
return [...new Set(unsupportedModels.map((item) => item.requestedValue))];
|
|
42730
42804
|
}
|
|
42731
|
-
async function discoverAgentSettings(command, config2, directories, sessions, signal
|
|
42805
|
+
async function discoverAgentSettings(command, config2, directories, sessions, signal) {
|
|
42732
42806
|
const agent = config2.catalog.find(command.agentId);
|
|
42733
42807
|
const cwd = await directories.resolve(config2.bindingId, "default", signal);
|
|
42734
|
-
await
|
|
42735
|
-
const baseSnapshot = await sessions.inspectAgentSettings({
|
|
42808
|
+
const inspectedBaseSnapshot = await sessions.inspectAgentSettings({
|
|
42736
42809
|
additionalDirectories: [],
|
|
42737
42810
|
agent,
|
|
42738
42811
|
cwd,
|
|
42739
42812
|
signal
|
|
42740
42813
|
});
|
|
42814
|
+
const baseSnapshot = {
|
|
42815
|
+
agentName: inspectedBaseSnapshot.agentName,
|
|
42816
|
+
agentVersion: inspectedBaseSnapshot.agentVersion,
|
|
42817
|
+
configOptions: await discoverOpenCodeModelOptions(agent, cwd, inspectedBaseSnapshot.configOptions, signal)
|
|
42818
|
+
};
|
|
42741
42819
|
const baseModel = modelOption(baseSnapshot.configOptions);
|
|
42742
42820
|
const unsupportedModels = [];
|
|
42743
42821
|
let selectedSnapshot = baseSnapshot;
|
|
@@ -44188,8 +44266,7 @@ async function runRelayConnection(config2, directories, audit, sessions, install
|
|
|
44188
44266
|
config2,
|
|
44189
44267
|
directories,
|
|
44190
44268
|
sessions,
|
|
44191
|
-
operationSignal
|
|
44192
|
-
timer
|
|
44269
|
+
operationSignal
|
|
44193
44270
|
);
|
|
44194
44271
|
for (const diagnostic of result.unsupportedModels) {
|
|
44195
44272
|
const details = agentSettingsFailureDetails(command2.agentId, diagnostic);
|