@saturn-universe/runtime-host 0.1.1 → 0.1.2-dev.3
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/builtin-plugins/saturn-plugin-ctf/index.mjs +2 -2
- package/dist/builtin-plugins/saturn-plugin-ctf/package.json +1 -1
- package/dist/composition.d.ts +2 -1
- package/dist/cordis/model-responses-plugin.d.ts +2 -1
- package/dist/cordis/model-responses-plugin.js +16 -11
- package/dist/cordis/plugin-loader.d.ts +1 -1
- package/dist/cordis/plugin-loader.js +45 -10
- package/dist/host-configuration.d.ts +3 -0
- package/dist/host-configuration.js +24 -1
- package/dist/index.js +8 -1
- package/dist/mode-configuration.d.ts +153 -0
- package/dist/mode-configuration.js +106 -0
- package/dist/provider-catalog.d.ts +218 -22
- package/dist/provider-catalog.js +51 -34
- package/package.json +9 -9
|
@@ -171,10 +171,10 @@ function matchesScopeFilters(item, categorySet, idSet) {
|
|
|
171
171
|
|
|
172
172
|
export default {
|
|
173
173
|
id: 'ctf',
|
|
174
|
-
version: '0.1.
|
|
174
|
+
version: '0.1.2-dev.3',
|
|
175
175
|
kind: 'saturn-registrar',
|
|
176
176
|
apiVersion: 1,
|
|
177
|
-
sdkVersion: '0.1.
|
|
177
|
+
sdkVersion: '0.1.2-dev.3',
|
|
178
178
|
async setup(api, config = {}) {
|
|
179
179
|
const { boardToken, boardPublicHost, ...boardSettings } = settingsFor(config);
|
|
180
180
|
if (boardToken) api.registerSecret?.(boardToken);
|
package/dist/composition.d.ts
CHANGED
|
@@ -61,11 +61,12 @@ export declare function composeRuntime(store: SqliteStore, root: string, options
|
|
|
61
61
|
reasoningEfforts: string[];
|
|
62
62
|
modelId: string;
|
|
63
63
|
reasoningEffort?: string;
|
|
64
|
-
protocol?: "openai-responses" | "openai-chat" | "anthropic" | "gemini";
|
|
65
64
|
name: string;
|
|
66
65
|
providerId: string;
|
|
67
66
|
revision: string;
|
|
68
67
|
codecVersion: 1 | 2;
|
|
68
|
+
protocol: "openai-responses" | "openai-chat" | "anthropic" | "gemini";
|
|
69
|
+
baseURL: string;
|
|
69
70
|
}[];
|
|
70
71
|
selectedProfile?: string;
|
|
71
72
|
defaultProfile?: string;
|
|
@@ -67,11 +67,12 @@ declare function createModelService(ctx: Context, options: ModelResponsesOptions
|
|
|
67
67
|
reasoningEfforts: string[];
|
|
68
68
|
modelId: string;
|
|
69
69
|
reasoningEffort?: string;
|
|
70
|
-
protocol?: "openai-responses" | "openai-chat" | "anthropic" | "gemini";
|
|
71
70
|
name: string;
|
|
72
71
|
providerId: string;
|
|
73
72
|
revision: string;
|
|
74
73
|
codecVersion: 1 | 2;
|
|
74
|
+
protocol: "openai-responses" | "openai-chat" | "anthropic" | "gemini";
|
|
75
|
+
baseURL: string;
|
|
75
76
|
}[];
|
|
76
77
|
selectedProfile?: string;
|
|
77
78
|
defaultProfile?: string;
|
|
@@ -190,17 +190,22 @@ function createModelService(ctx, options) {
|
|
|
190
190
|
selectedProfile: catalog.profiles.find((p) => canonicalJson(profileModel(p)) === canonicalJson(defaultModel)).name,
|
|
191
191
|
}
|
|
192
192
|
: {}),
|
|
193
|
-
profiles: catalog.profiles.map((p) =>
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
193
|
+
profiles: catalog.profiles.map((p) => {
|
|
194
|
+
const model = profileModel(p);
|
|
195
|
+
const { profile, binding } = providers.resolve(model);
|
|
196
|
+
return {
|
|
197
|
+
name: p.name,
|
|
198
|
+
providerId: p.providerId,
|
|
199
|
+
revision: p.revision,
|
|
200
|
+
codecVersion: p.codecVersion,
|
|
201
|
+
protocol: profile.protocol,
|
|
202
|
+
baseURL: profile.baseURL,
|
|
203
|
+
...defaultModelDisplay(model, p.defaultReasoningEffort),
|
|
204
|
+
capabilityDigest: binding.capabilityDigest,
|
|
205
|
+
...profilePricing(p),
|
|
206
|
+
ready: Boolean(credential(p.credentialRef)?.trim()),
|
|
207
|
+
};
|
|
208
|
+
}),
|
|
204
209
|
}
|
|
205
210
|
: {}),
|
|
206
211
|
};
|
|
@@ -9,7 +9,7 @@ export interface LoadedHostPlugin {
|
|
|
9
9
|
readonly entryUrl?: string;
|
|
10
10
|
readonly files?: ReadonlyMap<string, string>;
|
|
11
11
|
}
|
|
12
|
-
type PluginConfiguration = Pick<Awaited<ReturnType<typeof loadHostConfiguration>>, 'configSource' | 'configPath' | 'trustedPlugins'>;
|
|
12
|
+
type PluginConfiguration = Pick<Awaited<ReturnType<typeof loadHostConfiguration>>, 'configSource' | 'configPath' | 'trustedPlugins' | 'modePluginSources'>;
|
|
13
13
|
export declare function loadModePlugins(activeMode: ModeDefinition, configuration: PluginConfiguration, logger: LoggerPort, reload?: {
|
|
14
14
|
readonly active: ReadonlyMap<string, LoadedHostPlugin>;
|
|
15
15
|
readonly pluginId?: string;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { createHash, randomUUID } from 'node:crypto';
|
|
2
|
-
import { readFile, realpath, stat } from 'node:fs/promises';
|
|
2
|
+
import { lstat, readFile, realpath, stat } from 'node:fs/promises';
|
|
3
3
|
import { createRequire, findPackageJSON, registerHooks } from 'node:module';
|
|
4
4
|
import path from 'node:path';
|
|
5
5
|
import { fileURLToPath, pathToFileURL } from 'node:url';
|
|
6
6
|
import { Context } from '@deepseek-ai/cordis';
|
|
7
7
|
import { canonicalJson, RuntimeError } from '@saturn-universe/core';
|
|
8
|
+
import { isInsideSkillDir } from '@saturn-universe/protocol';
|
|
8
9
|
import { SATURN_PLUGIN_SDK_VERSION, SUPPORTED_CORDIS_VERSION, validatePluginCompatibility, } from '@saturn-universe/plugin-sdk';
|
|
9
10
|
import { resolve } from 'import-meta-resolve';
|
|
10
11
|
import semver from 'semver';
|
|
@@ -16,13 +17,24 @@ const hostRequire = createRequire(import.meta.url);
|
|
|
16
17
|
// External plugin imports must go through Node's loader, including under the test module runner.
|
|
17
18
|
const nativeImportModule = 'data:text/javascript,export const load = (url) => import(url)';
|
|
18
19
|
export async function loadModePlugins(activeMode, configuration, logger, reload) {
|
|
19
|
-
const { configPath, configSource, trustedPlugins } = configuration;
|
|
20
|
+
const { configPath, configSource, trustedPlugins, modePluginSources } = configuration;
|
|
20
21
|
const isTrusted = Boolean(trustedPlugins && (configSource === 'user' || configSource === 'explicit'));
|
|
22
|
+
const sources = modePluginSources?.get(activeMode.ref);
|
|
21
23
|
const bindings = [...(activeMode.plugins ?? [])].sort((a, b) => a.id.localeCompare(b.id));
|
|
24
|
+
const resolveBinding = (id, entry) => {
|
|
25
|
+
const source = sources?.get(id);
|
|
26
|
+
if (source)
|
|
27
|
+
return resolveEntry(id, source.directory, entry, source.bundled);
|
|
28
|
+
if (!configPath)
|
|
29
|
+
throw new RuntimeError('INVALID_CONFIG', 'Plugin configuration requires a file path');
|
|
30
|
+
return resolveEntry(id, path.dirname(configPath), entry);
|
|
31
|
+
};
|
|
22
32
|
if (!isTrusted) {
|
|
23
33
|
let hasEnabledUntrusted = false;
|
|
24
34
|
for (const binding of bindings) {
|
|
25
35
|
const id = binding.id;
|
|
36
|
+
if (sources?.has(id))
|
|
37
|
+
continue;
|
|
26
38
|
if (binding.builtin) {
|
|
27
39
|
if (binding.enabled === false)
|
|
28
40
|
continue;
|
|
@@ -52,9 +64,7 @@ export async function loadModePlugins(activeMode, configuration, logger, reload)
|
|
|
52
64
|
let filename;
|
|
53
65
|
let directoryManifest;
|
|
54
66
|
if (binding.entry) {
|
|
55
|
-
|
|
56
|
-
throw new RuntimeError('INVALID_CONFIG', 'Plugin configuration requires a file path');
|
|
57
|
-
const resolved = await resolveEntry(id, path.dirname(configPath), binding.entry);
|
|
67
|
+
const resolved = await resolveBinding(id, binding.entry);
|
|
58
68
|
filename = resolved.filename;
|
|
59
69
|
directoryManifest = resolved.directoryManifest;
|
|
60
70
|
}
|
|
@@ -73,9 +83,7 @@ export async function loadModePlugins(activeMode, configuration, logger, reload)
|
|
|
73
83
|
if (!entry) {
|
|
74
84
|
throw new RuntimeError('INVALID_CONFIG', `Mode ${activeMode.ref} plugin ${id} is missing an entry`);
|
|
75
85
|
}
|
|
76
|
-
|
|
77
|
-
throw new RuntimeError('INVALID_CONFIG', 'Plugin configuration requires a file path');
|
|
78
|
-
const resolved = await resolveEntry(id, path.dirname(configPath), entry);
|
|
86
|
+
const resolved = await resolveBinding(id, entry);
|
|
79
87
|
const mergedConfig = binding.config ? { ...binding.config } : undefined;
|
|
80
88
|
loaded.push(await loadPluginFromEntry(id, resolved.filename, resolved.directoryManifest, mergedConfig, reload));
|
|
81
89
|
}
|
|
@@ -170,21 +178,48 @@ async function importPlugin(id, entryUrl, timeoutMs) {
|
|
|
170
178
|
hooks.deregister();
|
|
171
179
|
}
|
|
172
180
|
}
|
|
173
|
-
async function
|
|
181
|
+
async function bundledEntry(directory, entry) {
|
|
182
|
+
const local = path.resolve(directory, entry);
|
|
183
|
+
if (!isInsideSkillDir(directory, local))
|
|
184
|
+
throw new Error('Entry is outside the Mode directory');
|
|
185
|
+
try {
|
|
186
|
+
await lstat(local);
|
|
187
|
+
}
|
|
188
|
+
catch (error) {
|
|
189
|
+
if (error.code !== 'ENOENT' || !entry.startsWith('./modes/'))
|
|
190
|
+
throw error;
|
|
191
|
+
const modes = path.dirname(directory);
|
|
192
|
+
const legacy = path.resolve(path.dirname(modes), entry);
|
|
193
|
+
if (!isInsideSkillDir(modes, legacy))
|
|
194
|
+
throw new Error('Entry is outside the user modes directory');
|
|
195
|
+
return { supplied: legacy, boundary: modes };
|
|
196
|
+
}
|
|
197
|
+
return { supplied: local, boundary: directory };
|
|
198
|
+
}
|
|
199
|
+
async function resolveEntry(id, directory, entry, bundled = false) {
|
|
174
200
|
try {
|
|
175
201
|
// Drive-relative paths would otherwise fall back to that drive's working directory on Windows.
|
|
176
202
|
const root = path.parse(entry).root;
|
|
177
203
|
if (process.platform === 'win32' && root && (!path.isAbsolute(entry) || root.length === 1))
|
|
178
204
|
throw new Error('A Windows absolute path requires a drive or network share');
|
|
179
|
-
const
|
|
205
|
+
const { supplied, boundary } = bundled
|
|
206
|
+
? await bundledEntry(directory, entry)
|
|
207
|
+
: { supplied: path.resolve(directory, entry), boundary: undefined };
|
|
208
|
+
const target = await realpath(supplied);
|
|
209
|
+
if (boundary && !isInsideSkillDir(boundary, target))
|
|
210
|
+
throw new Error('Entry resolves outside its directory');
|
|
180
211
|
if ((await stat(target)).isFile())
|
|
181
212
|
return { filename: target };
|
|
182
213
|
const directoryManifest = path.join(target, 'package.json');
|
|
214
|
+
if (boundary && !isInsideSkillDir(boundary, await realpath(directoryManifest)))
|
|
215
|
+
throw new Error('Package manifest resolves outside its directory');
|
|
183
216
|
const manifest = await readManifest(directoryManifest);
|
|
184
217
|
const entryFile = typeof manifest?.name === 'string' && manifest.exports !== undefined && manifest.exports !== null
|
|
185
218
|
? fileURLToPath(resolve(manifest.name, pathToFileURL(directoryManifest).href))
|
|
186
219
|
: hostRequire.resolve(target);
|
|
187
220
|
const filename = await realpath(entryFile);
|
|
221
|
+
if (boundary && !isInsideSkillDir(boundary, filename))
|
|
222
|
+
throw new Error('Entry resolves outside its directory');
|
|
188
223
|
if ((await stat(filename)).isFile())
|
|
189
224
|
return { filename, directoryManifest };
|
|
190
225
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { ProviderCatalog } from './provider-catalog.js';
|
|
2
|
+
import { loadModeConfiguration } from './mode-configuration.js';
|
|
2
3
|
export type ConfigSource = 'explicit' | 'workspace' | 'user' | 'none';
|
|
3
4
|
export interface McpServerMeta {
|
|
4
5
|
readonly scope: Exclude<ConfigSource, 'none'> | 'project';
|
|
@@ -8,6 +9,7 @@ export interface McpServerMeta {
|
|
|
8
9
|
}
|
|
9
10
|
export declare function parseHostArguments(args: readonly string[]): {
|
|
10
11
|
allowUnsafeSandboxFallback?: boolean;
|
|
12
|
+
inspectModes?: boolean;
|
|
11
13
|
mode?: string;
|
|
12
14
|
taskProfile?: string;
|
|
13
15
|
profile?: string;
|
|
@@ -20,6 +22,7 @@ export declare function loadHostConfiguration(root: string, explicitFile?: strin
|
|
|
20
22
|
configPath: string | undefined;
|
|
21
23
|
trustedMcp: boolean;
|
|
22
24
|
trustedPlugins: boolean;
|
|
25
|
+
modePluginSources?: Awaited<ReturnType<typeof loadModeConfiguration>>['modePluginSources'];
|
|
23
26
|
webSearch?: ProviderCatalog['webSearch'];
|
|
24
27
|
mcpServers?: ProviderCatalog['mcpServers'];
|
|
25
28
|
mcpServerMeta?: Readonly<Record<string, McpServerMeta>>;
|
|
@@ -3,18 +3,23 @@ import { readFile } from 'node:fs/promises';
|
|
|
3
3
|
import { RuntimeError } from '@saturn-universe/core';
|
|
4
4
|
import { normalizeWorkspaceTrustPath, parseProjectMcpJson, projectMcpConfigPath, userConfigPath, workspaceConfigPath, } from '@saturn-universe/protocol';
|
|
5
5
|
import { parseProviderToml } from './provider-catalog.js';
|
|
6
|
+
import { loadModeConfiguration } from './mode-configuration.js';
|
|
6
7
|
export function parseHostArguments(args) {
|
|
7
8
|
let root;
|
|
8
9
|
let configFile;
|
|
9
10
|
let profile;
|
|
10
11
|
let taskProfile;
|
|
11
12
|
let mode;
|
|
13
|
+
let inspectModes = false;
|
|
12
14
|
let allowUnsafeSandboxFallback = false;
|
|
13
15
|
for (let i = 0; i < args.length; i++) {
|
|
14
16
|
const arg = args[i];
|
|
15
17
|
if (arg === '--allow-unsafe-sandbox-fallback') {
|
|
16
18
|
allowUnsafeSandboxFallback = true;
|
|
17
19
|
}
|
|
20
|
+
else if (arg === '--inspect-modes') {
|
|
21
|
+
inspectModes = true;
|
|
22
|
+
}
|
|
18
23
|
else if (['--config', '--profile', '--task-profile', '--mode'].includes(arg)) {
|
|
19
24
|
const value = args[++i];
|
|
20
25
|
if (!value || value.startsWith('--'))
|
|
@@ -55,6 +60,7 @@ export function parseHostArguments(args) {
|
|
|
55
60
|
...(profile ? { profile } : {}),
|
|
56
61
|
...(taskProfile ? { taskProfile } : {}),
|
|
57
62
|
...(mode ? { mode } : {}),
|
|
63
|
+
...(inspectModes ? { inspectModes: true } : {}),
|
|
58
64
|
...(allowUnsafeSandboxFallback ? { allowUnsafeSandboxFallback: true } : {}),
|
|
59
65
|
};
|
|
60
66
|
}
|
|
@@ -123,6 +129,22 @@ export async function loadHostConfiguration(root, explicitFile, env = process.en
|
|
|
123
129
|
break;
|
|
124
130
|
}
|
|
125
131
|
const userCatalog = configSource === 'user' ? resolvedCatalog : await readOptionalUserCatalog(env);
|
|
132
|
+
const { modes, modePluginSources } = await loadModeConfiguration(env, [
|
|
133
|
+
...(configSource !== 'user' && userCatalog?.modes
|
|
134
|
+
? [
|
|
135
|
+
{
|
|
136
|
+
modes: userCatalog.modes,
|
|
137
|
+
pluginSource: { directory: path.dirname(userConfigPath(env)), bundled: false },
|
|
138
|
+
},
|
|
139
|
+
]
|
|
140
|
+
: []),
|
|
141
|
+
{
|
|
142
|
+
modes: resolvedCatalog?.modes,
|
|
143
|
+
...(trusted && configPath
|
|
144
|
+
? { pluginSource: { directory: path.dirname(configPath), bundled: false } }
|
|
145
|
+
: {}),
|
|
146
|
+
},
|
|
147
|
+
]);
|
|
126
148
|
const trustedWorkspaces = new Set((userCatalog?.trustedMcpWorkspaces ?? []).map((entry) => normalizeWorkspaceTrustPath(entry)));
|
|
127
149
|
const workspaceTrustedForMcp = trustedWorkspaces.has(normalizeWorkspaceTrustPath(root));
|
|
128
150
|
const mcpJsonPath = projectMcpConfigPath(root);
|
|
@@ -170,11 +192,12 @@ export async function loadHostConfiguration(root, explicitFile, env = process.en
|
|
|
170
192
|
// A workspace-controlled TOML cannot select which Host secret to send to a remote endpoint.
|
|
171
193
|
const webSearch = trusted ? resolvedCatalog?.webSearch : userCatalog?.webSearch;
|
|
172
194
|
return {
|
|
173
|
-
catalog: resolvedCatalog,
|
|
195
|
+
catalog: modes ? { ...(resolvedCatalog ?? { profiles: [], taskProfiles: {} }), modes } : resolvedCatalog,
|
|
174
196
|
configSource,
|
|
175
197
|
configPath,
|
|
176
198
|
trustedMcp: trusted,
|
|
177
199
|
trustedPlugins: trusted,
|
|
200
|
+
modePluginSources,
|
|
178
201
|
...(webSearch ? { webSearch } : {}),
|
|
179
202
|
...(hasMergedMcp ? { mcpServers: mergedMcpServers, mcpServerMeta } : {}),
|
|
180
203
|
...(projectMcp.error ? { mcpJsonError: projectMcp.error } : {}),
|
package/dist/index.js
CHANGED
|
@@ -11,12 +11,19 @@ import { acquireOwnership } from './ownership.js';
|
|
|
11
11
|
import { composeRuntime } from './composition.js';
|
|
12
12
|
import { ReplyWriter, receiveCommands } from './ipc.js';
|
|
13
13
|
import { createCommandDispatch } from './command-dispatch.js';
|
|
14
|
-
import { parseHostArguments } from './host-configuration.js';
|
|
14
|
+
import { loadHostConfiguration, parseHostArguments } from './host-configuration.js';
|
|
15
15
|
import { createHostLogger, openHostDiagnostics } from './logger.js';
|
|
16
|
+
import { resolveActiveMode } from './modes.js';
|
|
16
17
|
async function main() {
|
|
17
18
|
const startup = performance.now();
|
|
18
19
|
const args = parseHostArguments(process.argv.slice(2));
|
|
19
20
|
const root = await realpath(path.resolve(args.root));
|
|
21
|
+
if (args.inspectModes) {
|
|
22
|
+
const { catalog } = await loadHostConfiguration(root, args.configFile);
|
|
23
|
+
const { availableModes } = resolveActiveMode(catalog, args.mode);
|
|
24
|
+
process.stdout.write(JSON.stringify(availableModes.map(({ ref, displayName, description }) => ({ ref, displayName, description }))) + '\n');
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
20
27
|
const dataDir = path.join(root, '.saturn');
|
|
21
28
|
await mkdir(dataDir, { recursive: true });
|
|
22
29
|
const { key, endpoint } = resolveHostEndpoint(root);
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import type { ProviderCatalog } from './provider-catalog.js';
|
|
2
|
+
interface ModePluginSource {
|
|
3
|
+
readonly directory: string;
|
|
4
|
+
readonly bundled: boolean;
|
|
5
|
+
}
|
|
6
|
+
type ModeLayer = {
|
|
7
|
+
readonly modes: ProviderCatalog['modes'];
|
|
8
|
+
readonly pluginSource?: ModePluginSource;
|
|
9
|
+
};
|
|
10
|
+
export declare function loadModeConfiguration(env: NodeJS.ProcessEnv, configured: readonly ModeLayer[]): Promise<{
|
|
11
|
+
modes: {
|
|
12
|
+
[k: string]: {
|
|
13
|
+
display_name?: string | undefined;
|
|
14
|
+
description?: string | undefined;
|
|
15
|
+
instructions?: string | undefined;
|
|
16
|
+
allowed_tools?: string[] | undefined;
|
|
17
|
+
denied_tools?: string[] | undefined;
|
|
18
|
+
prompts?: {
|
|
19
|
+
instructions?: string | undefined;
|
|
20
|
+
core?: {
|
|
21
|
+
mode: "append" | "replace";
|
|
22
|
+
text: string;
|
|
23
|
+
} | undefined;
|
|
24
|
+
execution_policy?: {
|
|
25
|
+
mode: "append" | "replace";
|
|
26
|
+
text: string;
|
|
27
|
+
} | undefined;
|
|
28
|
+
roles?: {
|
|
29
|
+
main?: {
|
|
30
|
+
text: string;
|
|
31
|
+
id?: string | undefined;
|
|
32
|
+
priority?: number | undefined;
|
|
33
|
+
required?: boolean | undefined;
|
|
34
|
+
mode?: "append" | "replace" | undefined;
|
|
35
|
+
}[] | undefined;
|
|
36
|
+
planner?: {
|
|
37
|
+
text: string;
|
|
38
|
+
id?: string | undefined;
|
|
39
|
+
priority?: number | undefined;
|
|
40
|
+
required?: boolean | undefined;
|
|
41
|
+
mode?: "append" | "replace" | undefined;
|
|
42
|
+
}[] | undefined;
|
|
43
|
+
worker?: {
|
|
44
|
+
text: string;
|
|
45
|
+
id?: string | undefined;
|
|
46
|
+
priority?: number | undefined;
|
|
47
|
+
required?: boolean | undefined;
|
|
48
|
+
mode?: "append" | "replace" | undefined;
|
|
49
|
+
}[] | undefined;
|
|
50
|
+
} | undefined;
|
|
51
|
+
} | undefined;
|
|
52
|
+
tools?: {
|
|
53
|
+
workspace_tools?: boolean | undefined;
|
|
54
|
+
process_manager?: boolean | undefined;
|
|
55
|
+
builtin_agent_tools?: boolean | undefined;
|
|
56
|
+
allowed_tools?: string[] | undefined;
|
|
57
|
+
denied_tools?: string[] | undefined;
|
|
58
|
+
permission_mode?: "default" | "strict" | "full" | undefined;
|
|
59
|
+
} | undefined;
|
|
60
|
+
plugins?: string[] | Record<string, {
|
|
61
|
+
allowed_tools?: string[] | undefined;
|
|
62
|
+
read_only_tools?: string[] | undefined;
|
|
63
|
+
auto_approve_tools?: string[] | undefined;
|
|
64
|
+
enabled?: boolean | undefined;
|
|
65
|
+
entry?: string | undefined;
|
|
66
|
+
config?: Record<string, string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | /*elided*/ any | {
|
|
67
|
+
[key: string]: string | number | boolean | /*elided*/ any | /*elided*/ any;
|
|
68
|
+
})[] | {
|
|
69
|
+
[key: string]: string | number | boolean | (string | number | boolean | /*elided*/ any | /*elided*/ any)[] | /*elided*/ any;
|
|
70
|
+
})[] | {
|
|
71
|
+
[key: string]: string | number | boolean | (string | number | boolean | (string | number | boolean | /*elided*/ any | /*elided*/ any)[] | /*elided*/ any)[] | /*elided*/ any;
|
|
72
|
+
})[] | {
|
|
73
|
+
[key: string]: string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | /*elided*/ any | /*elided*/ any)[] | /*elided*/ any)[] | /*elided*/ any)[] | /*elided*/ any;
|
|
74
|
+
})[] | {
|
|
75
|
+
[key: string]: string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | /*elided*/ any | /*elided*/ any)[] | /*elided*/ any)[] | /*elided*/ any)[] | /*elided*/ any)[] | /*elided*/ any;
|
|
76
|
+
})[] | {
|
|
77
|
+
[key: string]: string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | /*elided*/ any | /*elided*/ any)[] | /*elided*/ any)[] | /*elided*/ any)[] | /*elided*/ any)[] | /*elided*/ any)[] | /*elided*/ any;
|
|
78
|
+
})[] | {
|
|
79
|
+
[key: string]: string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | /*elided*/ any | /*elided*/ any)[] | /*elided*/ any)[] | /*elided*/ any)[] | /*elided*/ any)[] | /*elided*/ any)[] | /*elided*/ any)[] | /*elided*/ any;
|
|
80
|
+
})[] | {
|
|
81
|
+
[key: string]: string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | /*elided*/ any | /*elided*/ any)[] | /*elided*/ any)[] | /*elided*/ any)[] | /*elided*/ any)[] | /*elided*/ any)[] | /*elided*/ any)[] | /*elided*/ any)[] | /*elided*/ any;
|
|
82
|
+
})[] | {
|
|
83
|
+
[key: string]: string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | /*elided*/ any | /*elided*/ any)[] | /*elided*/ any)[] | /*elided*/ any)[] | /*elided*/ any)[] | /*elided*/ any)[] | /*elided*/ any)[] | /*elided*/ any)[] | /*elided*/ any)[] | /*elided*/ any;
|
|
84
|
+
})[] | {
|
|
85
|
+
[key: string]: string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | /*elided*/ any | /*elided*/ any)[] | /*elided*/ any)[] | /*elided*/ any)[] | /*elided*/ any)[] | /*elided*/ any)[] | /*elided*/ any)[] | /*elided*/ any)[] | /*elided*/ any)[] | /*elided*/ any)[] | /*elided*/ any;
|
|
86
|
+
})[] | {
|
|
87
|
+
[key: string]: string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | /*elided*/ any | /*elided*/ any)[] | /*elided*/ any)[] | /*elided*/ any)[] | /*elided*/ any)[] | /*elided*/ any)[] | /*elided*/ any)[] | /*elided*/ any)[] | /*elided*/ any)[] | /*elided*/ any)[] | /*elided*/ any)[] | /*elided*/ any;
|
|
88
|
+
})[] | {
|
|
89
|
+
[key: string]: string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | /*elided*/ any | /*elided*/ any)[] | /*elided*/ any)[] | /*elided*/ any)[] | /*elided*/ any)[] | /*elided*/ any)[] | /*elided*/ any)[] | /*elided*/ any)[] | /*elided*/ any)[] | /*elided*/ any)[] | /*elided*/ any)[] | /*elided*/ any)[] | /*elided*/ any;
|
|
90
|
+
}> | undefined;
|
|
91
|
+
}> | undefined;
|
|
92
|
+
sandbox?: {
|
|
93
|
+
backend?: "host" | "docker" | "gvisor" | "sysbox" | undefined;
|
|
94
|
+
scope?: "none" | "per_run_and_worker" | undefined;
|
|
95
|
+
image?: string | undefined;
|
|
96
|
+
network?: "none" | "internal" | "proxy" | "bridge" | undefined;
|
|
97
|
+
network_name?: string | undefined;
|
|
98
|
+
proxy_url?: string | undefined;
|
|
99
|
+
cap_add?: string[] | undefined;
|
|
100
|
+
readonly_mounts?: {
|
|
101
|
+
host_path: string;
|
|
102
|
+
container_path: string;
|
|
103
|
+
}[] | undefined;
|
|
104
|
+
kvm?: boolean | undefined;
|
|
105
|
+
tmpfs_size_mb?: number | undefined;
|
|
106
|
+
resources?: {
|
|
107
|
+
cpus?: number | undefined;
|
|
108
|
+
memory_mb?: number | undefined;
|
|
109
|
+
pids_limit?: number | undefined;
|
|
110
|
+
disk_soft_limit_mb?: number | undefined;
|
|
111
|
+
} | undefined;
|
|
112
|
+
retention?: {
|
|
113
|
+
mode: "always" | "on_success" | "ttl";
|
|
114
|
+
ttl_hours?: number | undefined;
|
|
115
|
+
} | undefined;
|
|
116
|
+
fallback_policy?: "fail_closed" | "allow_host_fallback" | undefined;
|
|
117
|
+
allow_target_services?: boolean | undefined;
|
|
118
|
+
worker_allow_target_services?: boolean | undefined;
|
|
119
|
+
max_targets_per_run?: number | undefined;
|
|
120
|
+
max_concurrent_containers?: number | undefined;
|
|
121
|
+
allowed_target_capabilities?: string[] | undefined;
|
|
122
|
+
} | undefined;
|
|
123
|
+
team?: {
|
|
124
|
+
max_depth?: number | undefined;
|
|
125
|
+
async_coordinator?: boolean | undefined;
|
|
126
|
+
coordinator_poll_interval_ms?: number | undefined;
|
|
127
|
+
} | undefined;
|
|
128
|
+
limits?: {
|
|
129
|
+
max_model_attempts?: number | undefined;
|
|
130
|
+
max_tool_calls?: number | undefined;
|
|
131
|
+
max_steps?: number | undefined;
|
|
132
|
+
max_total_tokens?: number | undefined;
|
|
133
|
+
subagent_max_model_attempts?: number | undefined;
|
|
134
|
+
wall_time_ms?: number | undefined;
|
|
135
|
+
subagent_wall_time_ms?: number | undefined;
|
|
136
|
+
} | undefined;
|
|
137
|
+
max_active_challenges?: number | undefined;
|
|
138
|
+
max_helpers_per_challenge?: number | undefined;
|
|
139
|
+
per_challenge_wall_time_ms?: number | undefined;
|
|
140
|
+
worker_soft_checkpoint_ms?: number | undefined;
|
|
141
|
+
board_port?: number | undefined;
|
|
142
|
+
board_token?: string | undefined;
|
|
143
|
+
board_public_host?: string | undefined;
|
|
144
|
+
coordinator_poll_interval_ms?: number | undefined;
|
|
145
|
+
auto_submit?: boolean | undefined;
|
|
146
|
+
max_remote_instances?: number | undefined;
|
|
147
|
+
instance_cooldown_ms?: number | undefined;
|
|
148
|
+
auto_stop_on_solve?: boolean | undefined;
|
|
149
|
+
};
|
|
150
|
+
} | undefined;
|
|
151
|
+
modePluginSources: Map<string, Map<string, ModePluginSource>>;
|
|
152
|
+
}>;
|
|
153
|
+
export {};
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { lstat, readFile, realpath } from 'node:fs/promises';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { parse } from 'smol-toml';
|
|
4
|
+
import { RuntimeError } from '@saturn-universe/core';
|
|
5
|
+
import { userModeDirectories } from '@saturn-universe/protocol';
|
|
6
|
+
import { modeDefinitionsSchema } from './context-extensions.js';
|
|
7
|
+
export async function loadModeConfiguration(env, configured) {
|
|
8
|
+
const discovered = new Map();
|
|
9
|
+
for (const directory of await userModeDirectories(env)) {
|
|
10
|
+
const filename = path.join(directory, 'mode.toml');
|
|
11
|
+
try {
|
|
12
|
+
if (path.relative(directory, await realpath(directory)) !== '')
|
|
13
|
+
continue;
|
|
14
|
+
const stat = await lstat(filename);
|
|
15
|
+
if (!stat.isFile() || stat.nlink !== 1)
|
|
16
|
+
continue;
|
|
17
|
+
const modes = modeDefinitionsSchema.parse(parse(await readFile(filename, 'utf8')).modes);
|
|
18
|
+
for (const [ref, mode] of Object.entries(modes)) {
|
|
19
|
+
discovered.set(ref, { modes: { [ref]: mode }, pluginSource: { directory, bundled: true } });
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
catch (error) {
|
|
23
|
+
if (error.code === 'ENOENT')
|
|
24
|
+
continue;
|
|
25
|
+
throw new RuntimeError('INVALID_CONFIG', `Invalid mode.toml in Mode directory ${path.basename(directory)}`);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
const modes = new Map();
|
|
29
|
+
const modePluginSources = new Map();
|
|
30
|
+
for (const layer of [...discovered.values(), ...configured]) {
|
|
31
|
+
for (const [ref, mode] of Object.entries(layer.modes ?? {})) {
|
|
32
|
+
const base = modes.get(ref);
|
|
33
|
+
modes.set(ref, base ? mergeModes(base, mode) : mode);
|
|
34
|
+
const sources = modePluginSources.get(ref) ?? new Map();
|
|
35
|
+
modePluginSources.set(ref, sources);
|
|
36
|
+
if (Array.isArray(mode.plugins)) {
|
|
37
|
+
for (const id of sources.keys())
|
|
38
|
+
if (!mode.plugins.includes(id))
|
|
39
|
+
sources.delete(id);
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
for (const [id, plugin] of Object.entries(mode.plugins ?? {})) {
|
|
43
|
+
// A workspace declaration must never gain trust from an inherited entry.
|
|
44
|
+
if (!layer.pluginSource)
|
|
45
|
+
sources.delete(id);
|
|
46
|
+
else if (plugin.entry !== undefined)
|
|
47
|
+
sources.set(id, layer.pluginSource);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return {
|
|
53
|
+
modes: modes.size ? Object.fromEntries(modes) : undefined,
|
|
54
|
+
modePluginSources,
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
function mergeModes(base, override) {
|
|
58
|
+
const { instructions, allowed_tools, denied_tools, ...rest } = override;
|
|
59
|
+
const normalized = {
|
|
60
|
+
...rest,
|
|
61
|
+
prompts: { ...override.prompts, ...(instructions === undefined ? {} : { instructions }) },
|
|
62
|
+
tools: {
|
|
63
|
+
...override.tools,
|
|
64
|
+
...(allowed_tools === undefined ? {} : { allowed_tools }),
|
|
65
|
+
...(denied_tools === undefined ? {} : { denied_tools }),
|
|
66
|
+
},
|
|
67
|
+
};
|
|
68
|
+
const { instructions: baseInstructions, allowed_tools: baseAllowed, denied_tools: baseDenied, ...baseRest } = base;
|
|
69
|
+
const merged = mergeTables({
|
|
70
|
+
...baseRest,
|
|
71
|
+
prompts: { instructions: baseInstructions, ...base.prompts },
|
|
72
|
+
tools: { allowed_tools: baseAllowed, denied_tools: baseDenied, ...base.tools },
|
|
73
|
+
}, normalized);
|
|
74
|
+
if (Array.isArray(base.plugins) && !Array.isArray(override.plugins) && override.plugins) {
|
|
75
|
+
merged.plugins = { ...Object.fromEntries(base.plugins.map((id) => [id, {}])), ...override.plugins };
|
|
76
|
+
}
|
|
77
|
+
else if (Array.isArray(override.plugins) && base.plugins && !Array.isArray(base.plugins)) {
|
|
78
|
+
const basePlugins = base.plugins;
|
|
79
|
+
merged.plugins = Object.fromEntries(override.plugins.map((id) => [id, Object.hasOwn(basePlugins, id) ? basePlugins[id] : {}]));
|
|
80
|
+
}
|
|
81
|
+
else if (isTable(merged.plugins) && override.plugins && !Array.isArray(override.plugins)) {
|
|
82
|
+
for (const [id, plugin] of Object.entries(override.plugins)) {
|
|
83
|
+
if (plugin.allowed_tools === undefined)
|
|
84
|
+
continue;
|
|
85
|
+
const binding = merged.plugins[id];
|
|
86
|
+
if (!isTable(binding))
|
|
87
|
+
continue;
|
|
88
|
+
if (plugin.read_only_tools === undefined)
|
|
89
|
+
delete binding.read_only_tools;
|
|
90
|
+
if (plugin.auto_approve_tools === undefined)
|
|
91
|
+
delete binding.auto_approve_tools;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
return merged;
|
|
95
|
+
}
|
|
96
|
+
function isTable(value) {
|
|
97
|
+
return value !== null && typeof value === 'object' && !Array.isArray(value);
|
|
98
|
+
}
|
|
99
|
+
function mergeTables(base, override) {
|
|
100
|
+
const fields = new Map(Object.entries(base));
|
|
101
|
+
for (const [key, value] of Object.entries(override)) {
|
|
102
|
+
const previous = fields.get(key);
|
|
103
|
+
fields.set(key, isTable(previous) && isTable(value) ? mergeTables(previous, value) : value);
|
|
104
|
+
}
|
|
105
|
+
return Object.fromEntries(fields);
|
|
106
|
+
}
|
|
@@ -59,16 +59,69 @@ declare const teamPresetSchema: z.ZodObject<{
|
|
|
59
59
|
}, z.core.$strict>;
|
|
60
60
|
declare const provider: z.ZodObject<{
|
|
61
61
|
base_url: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
|
|
62
|
-
protocol: z.ZodOptional<z.ZodPipe<z.ZodEnum<{
|
|
63
|
-
"openai-responses": "openai-responses";
|
|
64
|
-
"openai-chat": "openai-chat";
|
|
65
|
-
anthropic: "anthropic";
|
|
66
|
-
gemini: "gemini";
|
|
67
|
-
"anthropic-messages": "anthropic-messages";
|
|
68
|
-
"google-gemini": "google-gemini";
|
|
69
|
-
}>, z.ZodTransform<"openai-responses" | "openai-chat" | "anthropic" | "gemini" | undefined, "openai-responses" | "openai-chat" | "anthropic" | "gemini" | "anthropic-messages" | "google-gemini">>>;
|
|
70
62
|
credential_ref: z.ZodString;
|
|
71
|
-
models: z.ZodArray<z.ZodString
|
|
63
|
+
models: z.ZodUnion<readonly [z.ZodArray<z.ZodString>, z.ZodPreprocess<z.ZodPipe<z.ZodArray<z.ZodTuple<[z.ZodType<string, unknown, z.core.$ZodTypeInternals<string, unknown>>, z.ZodObject<{
|
|
64
|
+
context_window: z.ZodOptional<z.ZodNumber>;
|
|
65
|
+
max_output_tokens: z.ZodOptional<z.ZodNumber>;
|
|
66
|
+
default_reasoning_effort: z.ZodOptional<z.ZodString>;
|
|
67
|
+
reasoning_model: z.ZodOptional<z.ZodBoolean>;
|
|
68
|
+
reasoning_efforts: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
69
|
+
tools: z.ZodOptional<z.ZodBoolean>;
|
|
70
|
+
parallel_tool_calls: z.ZodOptional<z.ZodBoolean>;
|
|
71
|
+
streaming: z.ZodOptional<z.ZodBoolean>;
|
|
72
|
+
structured_output: z.ZodOptional<z.ZodBoolean>;
|
|
73
|
+
images: z.ZodOptional<z.ZodBoolean>;
|
|
74
|
+
pricing: z.ZodOptional<z.ZodObject<{
|
|
75
|
+
input_per_million: z.ZodOptional<z.ZodNumber>;
|
|
76
|
+
cached_input_per_million: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
|
|
77
|
+
output_per_million: z.ZodOptional<z.ZodNumber>;
|
|
78
|
+
}, z.core.$strict>>;
|
|
79
|
+
protocol: z.ZodOptional<z.ZodPipe<z.ZodEnum<{
|
|
80
|
+
"openai-responses": "openai-responses";
|
|
81
|
+
"openai-chat": "openai-chat";
|
|
82
|
+
anthropic: "anthropic";
|
|
83
|
+
gemini: "gemini";
|
|
84
|
+
"anthropic-messages": "anthropic-messages";
|
|
85
|
+
"google-gemini": "google-gemini";
|
|
86
|
+
}>, z.ZodTransform<"openai-responses" | "openai-chat" | "anthropic" | "gemini" | undefined, "openai-responses" | "openai-chat" | "anthropic" | "gemini" | "anthropic-messages" | "google-gemini">>>;
|
|
87
|
+
base_url: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>;
|
|
88
|
+
}, z.core.$strict>], null>>, z.ZodTransform<Record<string, {
|
|
89
|
+
context_window?: number | undefined;
|
|
90
|
+
max_output_tokens?: number | undefined;
|
|
91
|
+
default_reasoning_effort?: string | undefined;
|
|
92
|
+
reasoning_model?: boolean | undefined;
|
|
93
|
+
reasoning_efforts?: string[] | undefined;
|
|
94
|
+
tools?: boolean | undefined;
|
|
95
|
+
parallel_tool_calls?: boolean | undefined;
|
|
96
|
+
streaming?: boolean | undefined;
|
|
97
|
+
structured_output?: boolean | undefined;
|
|
98
|
+
images?: boolean | undefined;
|
|
99
|
+
pricing?: {
|
|
100
|
+
input_per_million?: number | undefined;
|
|
101
|
+
cached_input_per_million?: number | undefined;
|
|
102
|
+
output_per_million?: number | undefined;
|
|
103
|
+
} | undefined;
|
|
104
|
+
protocol?: "openai-responses" | "openai-chat" | "anthropic" | "gemini" | undefined;
|
|
105
|
+
base_url?: string | undefined;
|
|
106
|
+
}>, [string, {
|
|
107
|
+
context_window?: number | undefined;
|
|
108
|
+
max_output_tokens?: number | undefined;
|
|
109
|
+
default_reasoning_effort?: string | undefined;
|
|
110
|
+
reasoning_model?: boolean | undefined;
|
|
111
|
+
reasoning_efforts?: string[] | undefined;
|
|
112
|
+
tools?: boolean | undefined;
|
|
113
|
+
parallel_tool_calls?: boolean | undefined;
|
|
114
|
+
streaming?: boolean | undefined;
|
|
115
|
+
structured_output?: boolean | undefined;
|
|
116
|
+
images?: boolean | undefined;
|
|
117
|
+
pricing?: {
|
|
118
|
+
input_per_million?: number | undefined;
|
|
119
|
+
cached_input_per_million?: number | undefined;
|
|
120
|
+
output_per_million?: number | undefined;
|
|
121
|
+
} | undefined;
|
|
122
|
+
protocol?: "openai-responses" | "openai-chat" | "anthropic" | "gemini" | undefined;
|
|
123
|
+
base_url?: string | undefined;
|
|
124
|
+
}][]>>, unknown>]>;
|
|
72
125
|
revision: z.ZodOptional<z.ZodString>;
|
|
73
126
|
codec_version: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<1>, z.ZodLiteral<2>]>>;
|
|
74
127
|
default_reasoning_effort: z.ZodOptional<z.ZodString>;
|
|
@@ -81,12 +134,22 @@ declare const provider: z.ZodObject<{
|
|
|
81
134
|
tools: z.ZodOptional<z.ZodBoolean>;
|
|
82
135
|
parallel_tool_calls: z.ZodOptional<z.ZodBoolean>;
|
|
83
136
|
streaming: z.ZodOptional<z.ZodBoolean>;
|
|
137
|
+
structured_output: z.ZodOptional<z.ZodBoolean>;
|
|
84
138
|
images: z.ZodOptional<z.ZodBoolean>;
|
|
85
139
|
pricing: z.ZodOptional<z.ZodObject<{
|
|
86
140
|
input_per_million: z.ZodOptional<z.ZodNumber>;
|
|
87
141
|
cached_input_per_million: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
|
|
88
142
|
output_per_million: z.ZodOptional<z.ZodNumber>;
|
|
89
143
|
}, z.core.$strict>>;
|
|
144
|
+
protocol: z.ZodOptional<z.ZodPipe<z.ZodEnum<{
|
|
145
|
+
"openai-responses": "openai-responses";
|
|
146
|
+
"openai-chat": "openai-chat";
|
|
147
|
+
anthropic: "anthropic";
|
|
148
|
+
gemini: "gemini";
|
|
149
|
+
"anthropic-messages": "anthropic-messages";
|
|
150
|
+
"google-gemini": "google-gemini";
|
|
151
|
+
}>, z.ZodTransform<"openai-responses" | "openai-chat" | "anthropic" | "gemini" | undefined, "openai-responses" | "openai-chat" | "anthropic" | "gemini" | "anthropic-messages" | "google-gemini">>>;
|
|
152
|
+
base_url: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>;
|
|
90
153
|
}, z.core.$strict>], null>>, z.ZodTransform<Record<string, {
|
|
91
154
|
context_window?: number | undefined;
|
|
92
155
|
max_output_tokens?: number | undefined;
|
|
@@ -96,12 +159,15 @@ declare const provider: z.ZodObject<{
|
|
|
96
159
|
tools?: boolean | undefined;
|
|
97
160
|
parallel_tool_calls?: boolean | undefined;
|
|
98
161
|
streaming?: boolean | undefined;
|
|
162
|
+
structured_output?: boolean | undefined;
|
|
99
163
|
images?: boolean | undefined;
|
|
100
164
|
pricing?: {
|
|
101
165
|
input_per_million?: number | undefined;
|
|
102
166
|
cached_input_per_million?: number | undefined;
|
|
103
167
|
output_per_million?: number | undefined;
|
|
104
168
|
} | undefined;
|
|
169
|
+
protocol?: "openai-responses" | "openai-chat" | "anthropic" | "gemini" | undefined;
|
|
170
|
+
base_url?: string | undefined;
|
|
105
171
|
}>, [string, {
|
|
106
172
|
context_window?: number | undefined;
|
|
107
173
|
max_output_tokens?: number | undefined;
|
|
@@ -111,13 +177,24 @@ declare const provider: z.ZodObject<{
|
|
|
111
177
|
tools?: boolean | undefined;
|
|
112
178
|
parallel_tool_calls?: boolean | undefined;
|
|
113
179
|
streaming?: boolean | undefined;
|
|
180
|
+
structured_output?: boolean | undefined;
|
|
114
181
|
images?: boolean | undefined;
|
|
115
182
|
pricing?: {
|
|
116
183
|
input_per_million?: number | undefined;
|
|
117
184
|
cached_input_per_million?: number | undefined;
|
|
118
185
|
output_per_million?: number | undefined;
|
|
119
186
|
} | undefined;
|
|
187
|
+
protocol?: "openai-responses" | "openai-chat" | "anthropic" | "gemini" | undefined;
|
|
188
|
+
base_url?: string | undefined;
|
|
120
189
|
}][]>>, unknown>>;
|
|
190
|
+
protocol: z.ZodOptional<z.ZodPipe<z.ZodEnum<{
|
|
191
|
+
"openai-responses": "openai-responses";
|
|
192
|
+
"openai-chat": "openai-chat";
|
|
193
|
+
anthropic: "anthropic";
|
|
194
|
+
gemini: "gemini";
|
|
195
|
+
"anthropic-messages": "anthropic-messages";
|
|
196
|
+
"google-gemini": "google-gemini";
|
|
197
|
+
}>, z.ZodTransform<"openai-responses" | "openai-chat" | "anthropic" | "gemini" | undefined, "openai-responses" | "openai-chat" | "anthropic" | "gemini" | "anthropic-messages" | "google-gemini">>>;
|
|
121
198
|
}, z.core.$strict>;
|
|
122
199
|
declare const catalogSchema: z.ZodObject<{
|
|
123
200
|
version: z.ZodLiteral<1>;
|
|
@@ -184,16 +261,69 @@ declare const catalogSchema: z.ZodObject<{
|
|
|
184
261
|
}, z.core.$strict>>>;
|
|
185
262
|
providers: z.ZodOptional<z.ZodPreprocess<z.ZodPipe<z.ZodArray<z.ZodTuple<[z.ZodType<string, unknown, z.core.$ZodTypeInternals<string, unknown>>, z.ZodObject<{
|
|
186
263
|
base_url: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
|
|
187
|
-
protocol: z.ZodOptional<z.ZodPipe<z.ZodEnum<{
|
|
188
|
-
"openai-responses": "openai-responses";
|
|
189
|
-
"openai-chat": "openai-chat";
|
|
190
|
-
anthropic: "anthropic";
|
|
191
|
-
gemini: "gemini";
|
|
192
|
-
"anthropic-messages": "anthropic-messages";
|
|
193
|
-
"google-gemini": "google-gemini";
|
|
194
|
-
}>, z.ZodTransform<"openai-responses" | "openai-chat" | "anthropic" | "gemini" | undefined, "openai-responses" | "openai-chat" | "anthropic" | "gemini" | "anthropic-messages" | "google-gemini">>>;
|
|
195
264
|
credential_ref: z.ZodString;
|
|
196
|
-
models: z.ZodArray<z.ZodString
|
|
265
|
+
models: z.ZodUnion<readonly [z.ZodArray<z.ZodString>, z.ZodPreprocess<z.ZodPipe<z.ZodArray<z.ZodTuple<[z.ZodType<string, unknown, z.core.$ZodTypeInternals<string, unknown>>, z.ZodObject<{
|
|
266
|
+
context_window: z.ZodOptional<z.ZodNumber>;
|
|
267
|
+
max_output_tokens: z.ZodOptional<z.ZodNumber>;
|
|
268
|
+
default_reasoning_effort: z.ZodOptional<z.ZodString>;
|
|
269
|
+
reasoning_model: z.ZodOptional<z.ZodBoolean>;
|
|
270
|
+
reasoning_efforts: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
271
|
+
tools: z.ZodOptional<z.ZodBoolean>;
|
|
272
|
+
parallel_tool_calls: z.ZodOptional<z.ZodBoolean>;
|
|
273
|
+
streaming: z.ZodOptional<z.ZodBoolean>;
|
|
274
|
+
structured_output: z.ZodOptional<z.ZodBoolean>;
|
|
275
|
+
images: z.ZodOptional<z.ZodBoolean>;
|
|
276
|
+
pricing: z.ZodOptional<z.ZodObject<{
|
|
277
|
+
input_per_million: z.ZodOptional<z.ZodNumber>;
|
|
278
|
+
cached_input_per_million: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
|
|
279
|
+
output_per_million: z.ZodOptional<z.ZodNumber>;
|
|
280
|
+
}, z.core.$strict>>;
|
|
281
|
+
protocol: z.ZodOptional<z.ZodPipe<z.ZodEnum<{
|
|
282
|
+
"openai-responses": "openai-responses";
|
|
283
|
+
"openai-chat": "openai-chat";
|
|
284
|
+
anthropic: "anthropic";
|
|
285
|
+
gemini: "gemini";
|
|
286
|
+
"anthropic-messages": "anthropic-messages";
|
|
287
|
+
"google-gemini": "google-gemini";
|
|
288
|
+
}>, z.ZodTransform<"openai-responses" | "openai-chat" | "anthropic" | "gemini" | undefined, "openai-responses" | "openai-chat" | "anthropic" | "gemini" | "anthropic-messages" | "google-gemini">>>;
|
|
289
|
+
base_url: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>;
|
|
290
|
+
}, z.core.$strict>], null>>, z.ZodTransform<Record<string, {
|
|
291
|
+
context_window?: number | undefined;
|
|
292
|
+
max_output_tokens?: number | undefined;
|
|
293
|
+
default_reasoning_effort?: string | undefined;
|
|
294
|
+
reasoning_model?: boolean | undefined;
|
|
295
|
+
reasoning_efforts?: string[] | undefined;
|
|
296
|
+
tools?: boolean | undefined;
|
|
297
|
+
parallel_tool_calls?: boolean | undefined;
|
|
298
|
+
streaming?: boolean | undefined;
|
|
299
|
+
structured_output?: boolean | undefined;
|
|
300
|
+
images?: boolean | undefined;
|
|
301
|
+
pricing?: {
|
|
302
|
+
input_per_million?: number | undefined;
|
|
303
|
+
cached_input_per_million?: number | undefined;
|
|
304
|
+
output_per_million?: number | undefined;
|
|
305
|
+
} | undefined;
|
|
306
|
+
protocol?: "openai-responses" | "openai-chat" | "anthropic" | "gemini" | undefined;
|
|
307
|
+
base_url?: string | undefined;
|
|
308
|
+
}>, [string, {
|
|
309
|
+
context_window?: number | undefined;
|
|
310
|
+
max_output_tokens?: number | undefined;
|
|
311
|
+
default_reasoning_effort?: string | undefined;
|
|
312
|
+
reasoning_model?: boolean | undefined;
|
|
313
|
+
reasoning_efforts?: string[] | undefined;
|
|
314
|
+
tools?: boolean | undefined;
|
|
315
|
+
parallel_tool_calls?: boolean | undefined;
|
|
316
|
+
streaming?: boolean | undefined;
|
|
317
|
+
structured_output?: boolean | undefined;
|
|
318
|
+
images?: boolean | undefined;
|
|
319
|
+
pricing?: {
|
|
320
|
+
input_per_million?: number | undefined;
|
|
321
|
+
cached_input_per_million?: number | undefined;
|
|
322
|
+
output_per_million?: number | undefined;
|
|
323
|
+
} | undefined;
|
|
324
|
+
protocol?: "openai-responses" | "openai-chat" | "anthropic" | "gemini" | undefined;
|
|
325
|
+
base_url?: string | undefined;
|
|
326
|
+
}][]>>, unknown>]>;
|
|
197
327
|
revision: z.ZodOptional<z.ZodString>;
|
|
198
328
|
codec_version: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<1>, z.ZodLiteral<2>]>>;
|
|
199
329
|
default_reasoning_effort: z.ZodOptional<z.ZodString>;
|
|
@@ -206,12 +336,22 @@ declare const catalogSchema: z.ZodObject<{
|
|
|
206
336
|
tools: z.ZodOptional<z.ZodBoolean>;
|
|
207
337
|
parallel_tool_calls: z.ZodOptional<z.ZodBoolean>;
|
|
208
338
|
streaming: z.ZodOptional<z.ZodBoolean>;
|
|
339
|
+
structured_output: z.ZodOptional<z.ZodBoolean>;
|
|
209
340
|
images: z.ZodOptional<z.ZodBoolean>;
|
|
210
341
|
pricing: z.ZodOptional<z.ZodObject<{
|
|
211
342
|
input_per_million: z.ZodOptional<z.ZodNumber>;
|
|
212
343
|
cached_input_per_million: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
|
|
213
344
|
output_per_million: z.ZodOptional<z.ZodNumber>;
|
|
214
345
|
}, z.core.$strict>>;
|
|
346
|
+
protocol: z.ZodOptional<z.ZodPipe<z.ZodEnum<{
|
|
347
|
+
"openai-responses": "openai-responses";
|
|
348
|
+
"openai-chat": "openai-chat";
|
|
349
|
+
anthropic: "anthropic";
|
|
350
|
+
gemini: "gemini";
|
|
351
|
+
"anthropic-messages": "anthropic-messages";
|
|
352
|
+
"google-gemini": "google-gemini";
|
|
353
|
+
}>, z.ZodTransform<"openai-responses" | "openai-chat" | "anthropic" | "gemini" | undefined, "openai-responses" | "openai-chat" | "anthropic" | "gemini" | "anthropic-messages" | "google-gemini">>>;
|
|
354
|
+
base_url: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>;
|
|
215
355
|
}, z.core.$strict>], null>>, z.ZodTransform<Record<string, {
|
|
216
356
|
context_window?: number | undefined;
|
|
217
357
|
max_output_tokens?: number | undefined;
|
|
@@ -221,12 +361,15 @@ declare const catalogSchema: z.ZodObject<{
|
|
|
221
361
|
tools?: boolean | undefined;
|
|
222
362
|
parallel_tool_calls?: boolean | undefined;
|
|
223
363
|
streaming?: boolean | undefined;
|
|
364
|
+
structured_output?: boolean | undefined;
|
|
224
365
|
images?: boolean | undefined;
|
|
225
366
|
pricing?: {
|
|
226
367
|
input_per_million?: number | undefined;
|
|
227
368
|
cached_input_per_million?: number | undefined;
|
|
228
369
|
output_per_million?: number | undefined;
|
|
229
370
|
} | undefined;
|
|
371
|
+
protocol?: "openai-responses" | "openai-chat" | "anthropic" | "gemini" | undefined;
|
|
372
|
+
base_url?: string | undefined;
|
|
230
373
|
}>, [string, {
|
|
231
374
|
context_window?: number | undefined;
|
|
232
375
|
max_output_tokens?: number | undefined;
|
|
@@ -236,18 +379,46 @@ declare const catalogSchema: z.ZodObject<{
|
|
|
236
379
|
tools?: boolean | undefined;
|
|
237
380
|
parallel_tool_calls?: boolean | undefined;
|
|
238
381
|
streaming?: boolean | undefined;
|
|
382
|
+
structured_output?: boolean | undefined;
|
|
239
383
|
images?: boolean | undefined;
|
|
240
384
|
pricing?: {
|
|
241
385
|
input_per_million?: number | undefined;
|
|
242
386
|
cached_input_per_million?: number | undefined;
|
|
243
387
|
output_per_million?: number | undefined;
|
|
244
388
|
} | undefined;
|
|
389
|
+
protocol?: "openai-responses" | "openai-chat" | "anthropic" | "gemini" | undefined;
|
|
390
|
+
base_url?: string | undefined;
|
|
245
391
|
}][]>>, unknown>>;
|
|
392
|
+
protocol: z.ZodOptional<z.ZodPipe<z.ZodEnum<{
|
|
393
|
+
"openai-responses": "openai-responses";
|
|
394
|
+
"openai-chat": "openai-chat";
|
|
395
|
+
anthropic: "anthropic";
|
|
396
|
+
gemini: "gemini";
|
|
397
|
+
"anthropic-messages": "anthropic-messages";
|
|
398
|
+
"google-gemini": "google-gemini";
|
|
399
|
+
}>, z.ZodTransform<"openai-responses" | "openai-chat" | "anthropic" | "gemini" | undefined, "openai-responses" | "openai-chat" | "anthropic" | "gemini" | "anthropic-messages" | "google-gemini">>>;
|
|
246
400
|
}, z.core.$strict>], null>>, z.ZodTransform<Record<string, {
|
|
247
401
|
base_url: string;
|
|
248
402
|
credential_ref: string;
|
|
249
|
-
models: string[]
|
|
250
|
-
|
|
403
|
+
models: string[] | Record<string, {
|
|
404
|
+
context_window?: number | undefined;
|
|
405
|
+
max_output_tokens?: number | undefined;
|
|
406
|
+
default_reasoning_effort?: string | undefined;
|
|
407
|
+
reasoning_model?: boolean | undefined;
|
|
408
|
+
reasoning_efforts?: string[] | undefined;
|
|
409
|
+
tools?: boolean | undefined;
|
|
410
|
+
parallel_tool_calls?: boolean | undefined;
|
|
411
|
+
streaming?: boolean | undefined;
|
|
412
|
+
structured_output?: boolean | undefined;
|
|
413
|
+
images?: boolean | undefined;
|
|
414
|
+
pricing?: {
|
|
415
|
+
input_per_million?: number | undefined;
|
|
416
|
+
cached_input_per_million?: number | undefined;
|
|
417
|
+
output_per_million?: number | undefined;
|
|
418
|
+
} | undefined;
|
|
419
|
+
protocol?: "openai-responses" | "openai-chat" | "anthropic" | "gemini" | undefined;
|
|
420
|
+
base_url?: string | undefined;
|
|
421
|
+
}>;
|
|
251
422
|
revision?: string | undefined;
|
|
252
423
|
codec_version?: 1 | 2 | undefined;
|
|
253
424
|
default_reasoning_effort?: string | undefined;
|
|
@@ -260,18 +431,39 @@ declare const catalogSchema: z.ZodObject<{
|
|
|
260
431
|
tools?: boolean | undefined;
|
|
261
432
|
parallel_tool_calls?: boolean | undefined;
|
|
262
433
|
streaming?: boolean | undefined;
|
|
434
|
+
structured_output?: boolean | undefined;
|
|
263
435
|
images?: boolean | undefined;
|
|
264
436
|
pricing?: {
|
|
265
437
|
input_per_million?: number | undefined;
|
|
266
438
|
cached_input_per_million?: number | undefined;
|
|
267
439
|
output_per_million?: number | undefined;
|
|
268
440
|
} | undefined;
|
|
441
|
+
protocol?: "openai-responses" | "openai-chat" | "anthropic" | "gemini" | undefined;
|
|
442
|
+
base_url?: string | undefined;
|
|
269
443
|
}> | undefined;
|
|
444
|
+
protocol?: "openai-responses" | "openai-chat" | "anthropic" | "gemini" | undefined;
|
|
270
445
|
}>, [string, {
|
|
271
446
|
base_url: string;
|
|
272
447
|
credential_ref: string;
|
|
273
|
-
models: string[]
|
|
274
|
-
|
|
448
|
+
models: string[] | Record<string, {
|
|
449
|
+
context_window?: number | undefined;
|
|
450
|
+
max_output_tokens?: number | undefined;
|
|
451
|
+
default_reasoning_effort?: string | undefined;
|
|
452
|
+
reasoning_model?: boolean | undefined;
|
|
453
|
+
reasoning_efforts?: string[] | undefined;
|
|
454
|
+
tools?: boolean | undefined;
|
|
455
|
+
parallel_tool_calls?: boolean | undefined;
|
|
456
|
+
streaming?: boolean | undefined;
|
|
457
|
+
structured_output?: boolean | undefined;
|
|
458
|
+
images?: boolean | undefined;
|
|
459
|
+
pricing?: {
|
|
460
|
+
input_per_million?: number | undefined;
|
|
461
|
+
cached_input_per_million?: number | undefined;
|
|
462
|
+
output_per_million?: number | undefined;
|
|
463
|
+
} | undefined;
|
|
464
|
+
protocol?: "openai-responses" | "openai-chat" | "anthropic" | "gemini" | undefined;
|
|
465
|
+
base_url?: string | undefined;
|
|
466
|
+
}>;
|
|
275
467
|
revision?: string | undefined;
|
|
276
468
|
codec_version?: 1 | 2 | undefined;
|
|
277
469
|
default_reasoning_effort?: string | undefined;
|
|
@@ -284,13 +476,17 @@ declare const catalogSchema: z.ZodObject<{
|
|
|
284
476
|
tools?: boolean | undefined;
|
|
285
477
|
parallel_tool_calls?: boolean | undefined;
|
|
286
478
|
streaming?: boolean | undefined;
|
|
479
|
+
structured_output?: boolean | undefined;
|
|
287
480
|
images?: boolean | undefined;
|
|
288
481
|
pricing?: {
|
|
289
482
|
input_per_million?: number | undefined;
|
|
290
483
|
cached_input_per_million?: number | undefined;
|
|
291
484
|
output_per_million?: number | undefined;
|
|
292
485
|
} | undefined;
|
|
486
|
+
protocol?: "openai-responses" | "openai-chat" | "anthropic" | "gemini" | undefined;
|
|
487
|
+
base_url?: string | undefined;
|
|
293
488
|
}> | undefined;
|
|
489
|
+
protocol?: "openai-responses" | "openai-chat" | "anthropic" | "gemini" | undefined;
|
|
294
490
|
}][]>>, unknown>>;
|
|
295
491
|
task_profiles: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
296
492
|
run_defaults: z.ZodOptional<z.ZodObject<{
|
package/dist/provider-catalog.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { webSearchConfig } from './user-config.js';
|
|
3
3
|
import { parse, stringify } from 'smol-toml';
|
|
4
|
-
import { DEFAULT_MODE_REF, RuntimeError, lookupModelMetadata,
|
|
5
|
-
import { credentialRefSchema, providerIdSchema } from '@saturn-universe/protocol';
|
|
4
|
+
import { DEFAULT_MODE_REF, RuntimeError, lookupModelMetadata, openCodeClientHeaders, providerPresets, validateTeamConfig, validateWorkSubpath, } from '@saturn-universe/core';
|
|
5
|
+
import { credentialRefSchema, providerBaseUrlSchema, providerIdSchema, providerModelIdSchema, providerModelRouteSchema, } from '@saturn-universe/protocol';
|
|
6
6
|
import { maxShellTimeoutMs } from '@saturn-universe/tools';
|
|
7
7
|
import { capabilities, defaultCapabilities } from './configuration.js';
|
|
8
8
|
import { mcpServersSchema } from './mcp-configuration.js';
|
|
@@ -19,19 +19,12 @@ const pricingSchema = z.strictObject({
|
|
|
19
19
|
output_per_million: nonnegativeNumber,
|
|
20
20
|
});
|
|
21
21
|
const codecVersion = z.union([z.literal(1), z.literal(2)]);
|
|
22
|
-
const baseUrl = z.string().transform((value, ctx) => {
|
|
23
|
-
const url = normalizeProviderBaseUrl(value);
|
|
24
|
-
if (url !== undefined)
|
|
25
|
-
return url;
|
|
26
|
-
ctx.addIssue({ code: 'custom', message: 'Invalid endpoint' });
|
|
27
|
-
return z.NEVER;
|
|
28
|
-
});
|
|
29
22
|
const profile = z
|
|
30
23
|
.strictObject({
|
|
31
24
|
provider_id: id,
|
|
32
25
|
revision: id,
|
|
33
26
|
codec_version: codecVersion,
|
|
34
|
-
base_url:
|
|
27
|
+
base_url: providerBaseUrlSchema,
|
|
35
28
|
model_id: id,
|
|
36
29
|
credential_ref: credentialRefSchema,
|
|
37
30
|
default_reasoning_effort: id.optional(),
|
|
@@ -85,6 +78,7 @@ const teamPresetSchema = z.strictObject({
|
|
|
85
78
|
.max(15),
|
|
86
79
|
});
|
|
87
80
|
const modelOverride = z.strictObject({
|
|
81
|
+
...providerModelRouteSchema.shape,
|
|
88
82
|
context_window: positive.optional(),
|
|
89
83
|
max_output_tokens: positive.optional(),
|
|
90
84
|
default_reasoning_effort: id.optional(),
|
|
@@ -93,19 +87,23 @@ const modelOverride = z.strictObject({
|
|
|
93
87
|
tools: z.boolean().optional(),
|
|
94
88
|
parallel_tool_calls: z.boolean().optional(),
|
|
95
89
|
streaming: z.boolean().optional(),
|
|
90
|
+
structured_output: z.boolean().optional(),
|
|
96
91
|
images: z.boolean().optional(),
|
|
97
92
|
pricing: pricingSchema.partial().optional(),
|
|
98
93
|
});
|
|
99
94
|
const provider = z
|
|
100
95
|
.strictObject({
|
|
101
|
-
|
|
102
|
-
|
|
96
|
+
...providerModelRouteSchema.shape,
|
|
97
|
+
base_url: providerBaseUrlSchema,
|
|
103
98
|
credential_ref: credentialRefSchema,
|
|
104
|
-
models: z.
|
|
99
|
+
models: z.union([
|
|
100
|
+
z.array(providerModelIdSchema).min(1),
|
|
101
|
+
configurationTable(providerModelIdSchema, modelOverride).refine((models) => Object.keys(models).length > 0),
|
|
102
|
+
]),
|
|
105
103
|
revision: id.optional(),
|
|
106
104
|
codec_version: codecVersion.optional(),
|
|
107
105
|
default_reasoning_effort: id.optional(),
|
|
108
|
-
model_overrides: configurationTable(
|
|
106
|
+
model_overrides: configurationTable(providerModelIdSchema, modelOverride).optional(),
|
|
109
107
|
})
|
|
110
108
|
.refine((value) => value.codec_version !== 2 || (value.revision ?? '1') !== '1');
|
|
111
109
|
const catalogSchema = z.strictObject({
|
|
@@ -172,13 +170,14 @@ export function parseProviderCatalog(value) {
|
|
|
172
170
|
};
|
|
173
171
|
});
|
|
174
172
|
for (const [providerId, value] of Object.entries(data.providers ?? {})) {
|
|
173
|
+
const models = Array.isArray(value.models) ? value.models : Object.keys(value.models);
|
|
175
174
|
if (`${providerId}@${value.revision ?? '1'}`.length > 200 ||
|
|
176
|
-
Object.keys(value.model_overrides ?? {}).some((model) => !
|
|
175
|
+
Object.keys(value.model_overrides ?? {}).some((model) => !models.includes(model)))
|
|
177
176
|
throw invalid();
|
|
178
|
-
for (const modelId of
|
|
177
|
+
for (const modelId of models)
|
|
179
178
|
profiles.push(expandProfile(providerId, modelId, value));
|
|
180
179
|
}
|
|
181
|
-
if (!data.providers && !data.profiles)
|
|
180
|
+
if (!data.providers && !data.profiles && !data.modes)
|
|
182
181
|
throw invalid();
|
|
183
182
|
const names = new Set();
|
|
184
183
|
const identities = new Set();
|
|
@@ -192,12 +191,8 @@ export function parseProviderCatalog(value) {
|
|
|
192
191
|
throw invalid();
|
|
193
192
|
identities.add(identity);
|
|
194
193
|
const revisionRef = `${p.providerId}@${p.revision}`;
|
|
195
|
-
const
|
|
196
|
-
|
|
197
|
-
p.credentialRef,
|
|
198
|
-
p.codecVersion,
|
|
199
|
-
p.protocol ?? 'openai-responses',
|
|
200
|
-
]);
|
|
194
|
+
const route = providerRoute(p, data.providers);
|
|
195
|
+
const binding = JSON.stringify([route.baseURL, p.credentialRef, p.codecVersion, route.protocol]);
|
|
201
196
|
if (revisions.has(revisionRef) && revisions.get(revisionRef) !== binding)
|
|
202
197
|
throw invalid();
|
|
203
198
|
revisions.set(revisionRef, binding);
|
|
@@ -229,14 +224,17 @@ function expandProfile(providerId, modelId, value) {
|
|
|
229
224
|
if (name.length > 200)
|
|
230
225
|
throw invalid();
|
|
231
226
|
const model = lookupModelMetadata(modelId);
|
|
232
|
-
const
|
|
233
|
-
|
|
234
|
-
|
|
227
|
+
const legacy = value.model_overrides;
|
|
228
|
+
const models = Array.isArray(value.models) ? undefined : value.models;
|
|
229
|
+
const override = {
|
|
230
|
+
...(legacy && Object.hasOwn(legacy, modelId) ? legacy[modelId] : {}),
|
|
231
|
+
...(models && Object.hasOwn(models, modelId) ? models[modelId] : {}),
|
|
232
|
+
};
|
|
235
233
|
const reasoningModel = override?.reasoning_model ?? model?.reasoningModel ?? Boolean(override?.reasoning_efforts?.length);
|
|
236
234
|
const tools = override?.tools ?? model?.tools ?? defaultCapabilities.tools;
|
|
237
235
|
const parallelToolCalls = override?.parallel_tool_calls ??
|
|
238
236
|
(tools && (model?.parallelToolCalls ?? defaultCapabilities.parallelToolCalls));
|
|
239
|
-
const protocol = value.protocol ?? 'openai-responses';
|
|
237
|
+
const protocol = override.protocol ?? value.protocol ?? 'openai-responses';
|
|
240
238
|
const input = override?.pricing?.input_per_million ?? model?.pricing.inputPerMillion;
|
|
241
239
|
const output = override?.pricing?.output_per_million ?? model?.pricing.outputPerMillion;
|
|
242
240
|
const cached = override?.pricing?.cached_input_per_million ?? model?.pricing.cachedInputPerMillion;
|
|
@@ -248,7 +246,7 @@ function expandProfile(providerId, modelId, value) {
|
|
|
248
246
|
providerId,
|
|
249
247
|
revision: value.revision ?? '1',
|
|
250
248
|
codecVersion: value.codec_version ?? 1,
|
|
251
|
-
baseURL: value.base_url,
|
|
249
|
+
baseURL: override.base_url ?? value.base_url,
|
|
252
250
|
modelId,
|
|
253
251
|
credentialRef: value.credential_ref,
|
|
254
252
|
protocol,
|
|
@@ -260,6 +258,7 @@ function expandProfile(providerId, modelId, value) {
|
|
|
260
258
|
tools,
|
|
261
259
|
parallelToolCalls,
|
|
262
260
|
streaming: override?.streaming ?? model?.streaming ?? defaultCapabilities.streaming,
|
|
261
|
+
structuredOutput: override.structured_output ?? defaultCapabilities.structuredOutput,
|
|
263
262
|
images: override?.images ?? model?.images ?? defaultCapabilities.images,
|
|
264
263
|
responses: {
|
|
265
264
|
...defaultCapabilities.responses,
|
|
@@ -343,24 +342,42 @@ export const profileModel = (p) => ({
|
|
|
343
342
|
modelId: p.modelId,
|
|
344
343
|
profileRef: `${p.providerId}@${p.revision}`,
|
|
345
344
|
});
|
|
345
|
+
function providerRoute(p, providers) {
|
|
346
|
+
const layered = p.protocol && providers && Object.hasOwn(providers, p.providerId) ? providers[p.providerId] : undefined;
|
|
347
|
+
return {
|
|
348
|
+
baseURL: layered?.base_url ?? p.baseURL,
|
|
349
|
+
protocol: (layered ? layered.protocol : p.protocol) ?? 'openai-responses',
|
|
350
|
+
};
|
|
351
|
+
}
|
|
346
352
|
export function catalogRegistrations(catalog) {
|
|
347
353
|
const groups = new Map();
|
|
348
354
|
for (const p of catalog.profiles) {
|
|
349
355
|
const ref = profileModel(p).profileRef;
|
|
356
|
+
const route = providerRoute(p, catalog.providers);
|
|
357
|
+
const modelRoute = {
|
|
358
|
+
...(p.protocol && p.protocol !== route.protocol ? { protocol: p.protocol } : {}),
|
|
359
|
+
...(p.baseURL !== route.baseURL ? { baseURL: p.baseURL } : {}),
|
|
360
|
+
};
|
|
361
|
+
const previous = groups.get(ref);
|
|
362
|
+
const modelRoutes = {
|
|
363
|
+
...previous?.modelRoutes,
|
|
364
|
+
...(Object.keys(modelRoute).length ? { [p.modelId]: modelRoute } : {}),
|
|
365
|
+
};
|
|
350
366
|
const entry = {
|
|
351
367
|
id: p.providerId,
|
|
352
368
|
revision: p.revision,
|
|
353
|
-
|
|
354
|
-
baseURL: p.baseURL,
|
|
369
|
+
...route,
|
|
355
370
|
apiKeyRef: p.credentialRef,
|
|
356
|
-
headers:
|
|
371
|
+
headers: providerPresets.some((preset) => preset.id === p.providerId && preset.openCodeModelsUrl)
|
|
372
|
+
? { 'x-opencode-client': { kind: 'literal', value: openCodeClientHeaders['x-opencode-client'] } }
|
|
373
|
+
: {},
|
|
357
374
|
credentialScopeRef: p.credentialRef,
|
|
358
375
|
codecId: 'saturn-responses',
|
|
359
376
|
codecVersion: p.codecVersion,
|
|
360
|
-
models: { [p.modelId]: p.capabilities ?? defaultCapabilities },
|
|
377
|
+
models: { ...previous?.models, [p.modelId]: p.capabilities ?? defaultCapabilities },
|
|
378
|
+
...(Object.keys(modelRoutes).length ? { modelRoutes } : {}),
|
|
361
379
|
};
|
|
362
|
-
|
|
363
|
-
groups.set(ref, previous ? { ...previous, models: { ...previous.models, ...entry.models } } : entry);
|
|
380
|
+
groups.set(ref, entry);
|
|
364
381
|
}
|
|
365
382
|
return [...groups.values()];
|
|
366
383
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@saturn-universe/runtime-host",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2-dev.3",
|
|
4
4
|
"license": "AGPL-3.0-only",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
@@ -8,14 +8,14 @@
|
|
|
8
8
|
],
|
|
9
9
|
"dependencies": {
|
|
10
10
|
"@deepseek-ai/cordis": "4.1.0",
|
|
11
|
-
"@saturn-universe/context": "0.1.
|
|
12
|
-
"@saturn-universe/core": "0.1.
|
|
13
|
-
"@saturn-universe/model": "0.1.
|
|
14
|
-
"@saturn-universe/plugin-sdk": "0.1.
|
|
15
|
-
"@saturn-universe/protocol": "0.1.
|
|
16
|
-
"@saturn-universe/runtime": "0.1.
|
|
17
|
-
"@saturn-universe/storage": "0.1.
|
|
18
|
-
"@saturn-universe/tools": "0.1.
|
|
11
|
+
"@saturn-universe/context": "0.1.2-dev.3",
|
|
12
|
+
"@saturn-universe/core": "0.1.2-dev.3",
|
|
13
|
+
"@saturn-universe/model": "0.1.2-dev.3",
|
|
14
|
+
"@saturn-universe/plugin-sdk": "0.1.2-dev.3",
|
|
15
|
+
"@saturn-universe/protocol": "0.1.2-dev.3",
|
|
16
|
+
"@saturn-universe/runtime": "0.1.2-dev.3",
|
|
17
|
+
"@saturn-universe/storage": "0.1.2-dev.3",
|
|
18
|
+
"@saturn-universe/tools": "0.1.2-dev.3",
|
|
19
19
|
"import-meta-resolve": "4.2.0",
|
|
20
20
|
"pino": "10.4.0",
|
|
21
21
|
"semver": "7.7.4",
|