@saturn-universe/runtime-host 0.1.2-dev.2 → 0.1.2-dev.4
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/context-extensions.d.ts +2 -0
- 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 +154 -0
- package/dist/mode-configuration.js +106 -0
- package/dist/provider-catalog.d.ts +3 -2
- package/dist/provider-catalog.js +7 -7
- package/dist/run-budget.d.ts +12 -4
- package/dist/run-budget.js +10 -2
- 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.2-dev.
|
|
174
|
+
version: '0.1.2-dev.4',
|
|
175
175
|
kind: 'saturn-registrar',
|
|
176
176
|
apiVersion: 1,
|
|
177
|
-
sdkVersion: '0.1.2-dev.
|
|
177
|
+
sdkVersion: '0.1.2-dev.4',
|
|
178
178
|
async setup(api, config = {}) {
|
|
179
179
|
const { boardToken, boardPublicHost, ...boardSettings } = settingsFor(config);
|
|
180
180
|
if (boardToken) api.registerSecret?.(boardToken);
|
|
@@ -341,6 +341,7 @@ export declare const modeDefinitionSchema: z.ZodObject<{
|
|
|
341
341
|
coordinator_poll_interval_ms: z.ZodOptional<z.ZodNumber>;
|
|
342
342
|
}, z.core.$strict>>;
|
|
343
343
|
limits: z.ZodOptional<z.ZodObject<{
|
|
344
|
+
tool_timeout_ms: z.ZodOptional<z.ZodNumber>;
|
|
344
345
|
max_model_attempts: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodNumber, z.ZodLiteral<"unlimited">, z.ZodNull]>, z.ZodTransform<number, number | "unlimited" | null>>>;
|
|
345
346
|
max_tool_calls: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodNumber, z.ZodLiteral<"unlimited">, z.ZodNull]>, z.ZodTransform<number, number | "unlimited" | null>>>;
|
|
346
347
|
max_steps: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodNumber, z.ZodLiteral<"unlimited">, z.ZodNull]>, z.ZodTransform<number, number | "unlimited" | null>>>;
|
|
@@ -653,6 +654,7 @@ export declare const modeDefinitionsSchema: z.ZodRecord<z.ZodString, z.ZodObject
|
|
|
653
654
|
coordinator_poll_interval_ms: z.ZodOptional<z.ZodNumber>;
|
|
654
655
|
}, z.core.$strict>>;
|
|
655
656
|
limits: z.ZodOptional<z.ZodObject<{
|
|
657
|
+
tool_timeout_ms: z.ZodOptional<z.ZodNumber>;
|
|
656
658
|
max_model_attempts: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodNumber, z.ZodLiteral<"unlimited">, z.ZodNull]>, z.ZodTransform<number, number | "unlimited" | null>>>;
|
|
657
659
|
max_tool_calls: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodNumber, z.ZodLiteral<"unlimited">, z.ZodNull]>, z.ZodTransform<number, number | "unlimited" | null>>>;
|
|
658
660
|
max_steps: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodNumber, z.ZodLiteral<"unlimited">, z.ZodNull]>, z.ZodTransform<number, number | "unlimited" | null>>>;
|
|
@@ -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,154 @@
|
|
|
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
|
+
tool_timeout_ms?: number | undefined;
|
|
130
|
+
max_model_attempts?: number | undefined;
|
|
131
|
+
max_tool_calls?: number | undefined;
|
|
132
|
+
max_steps?: number | undefined;
|
|
133
|
+
max_total_tokens?: number | undefined;
|
|
134
|
+
subagent_max_model_attempts?: number | undefined;
|
|
135
|
+
wall_time_ms?: number | undefined;
|
|
136
|
+
subagent_wall_time_ms?: number | undefined;
|
|
137
|
+
} | undefined;
|
|
138
|
+
max_active_challenges?: number | undefined;
|
|
139
|
+
max_helpers_per_challenge?: number | undefined;
|
|
140
|
+
per_challenge_wall_time_ms?: number | undefined;
|
|
141
|
+
worker_soft_checkpoint_ms?: number | undefined;
|
|
142
|
+
board_port?: number | undefined;
|
|
143
|
+
board_token?: string | undefined;
|
|
144
|
+
board_public_host?: string | undefined;
|
|
145
|
+
coordinator_poll_interval_ms?: number | undefined;
|
|
146
|
+
auto_submit?: boolean | undefined;
|
|
147
|
+
max_remote_instances?: number | undefined;
|
|
148
|
+
instance_cooldown_ms?: number | undefined;
|
|
149
|
+
auto_stop_on_solve?: boolean | undefined;
|
|
150
|
+
};
|
|
151
|
+
} | undefined;
|
|
152
|
+
modePluginSources: Map<string, Map<string, ModePluginSource>>;
|
|
153
|
+
}>;
|
|
154
|
+
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
|
+
}
|
|
@@ -10,8 +10,8 @@ declare const runDefaults: z.ZodObject<{
|
|
|
10
10
|
model_timeout_ms: z.ZodOptional<z.ZodNumber>;
|
|
11
11
|
model_idle_timeout_ms: z.ZodOptional<z.ZodNumber>;
|
|
12
12
|
model_total_timeout_ms: z.ZodOptional<z.ZodNumber>;
|
|
13
|
-
tool_timeout_ms: z.ZodOptional<z.ZodNumber>;
|
|
14
13
|
max_parallel_tools: z.ZodOptional<z.ZodNumber>;
|
|
14
|
+
tool_timeout_ms: z.ZodOptional<z.ZodNumber>;
|
|
15
15
|
max_model_attempts: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodNumber, z.ZodLiteral<"unlimited">, z.ZodNull]>, z.ZodTransform<number, number | "unlimited" | null>>>;
|
|
16
16
|
max_tool_calls: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodNumber, z.ZodLiteral<"unlimited">, z.ZodNull]>, z.ZodTransform<number, number | "unlimited" | null>>>;
|
|
17
17
|
max_steps: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodNumber, z.ZodLiteral<"unlimited">, z.ZodNull]>, z.ZodTransform<number, number | "unlimited" | null>>>;
|
|
@@ -493,8 +493,8 @@ declare const catalogSchema: z.ZodObject<{
|
|
|
493
493
|
model_timeout_ms: z.ZodOptional<z.ZodNumber>;
|
|
494
494
|
model_idle_timeout_ms: z.ZodOptional<z.ZodNumber>;
|
|
495
495
|
model_total_timeout_ms: z.ZodOptional<z.ZodNumber>;
|
|
496
|
-
tool_timeout_ms: z.ZodOptional<z.ZodNumber>;
|
|
497
496
|
max_parallel_tools: z.ZodOptional<z.ZodNumber>;
|
|
497
|
+
tool_timeout_ms: z.ZodOptional<z.ZodNumber>;
|
|
498
498
|
max_model_attempts: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodNumber, z.ZodLiteral<"unlimited">, z.ZodNull]>, z.ZodTransform<number, number | "unlimited" | null>>>;
|
|
499
499
|
max_tool_calls: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodNumber, z.ZodLiteral<"unlimited">, z.ZodNull]>, z.ZodTransform<number, number | "unlimited" | null>>>;
|
|
500
500
|
max_steps: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodNumber, z.ZodLiteral<"unlimited">, z.ZodNull]>, z.ZodTransform<number, number | "unlimited" | null>>>;
|
|
@@ -851,6 +851,7 @@ declare const catalogSchema: z.ZodObject<{
|
|
|
851
851
|
coordinator_poll_interval_ms: z.ZodOptional<z.ZodNumber>;
|
|
852
852
|
}, z.core.$strict>>;
|
|
853
853
|
limits: z.ZodOptional<z.ZodObject<{
|
|
854
|
+
tool_timeout_ms: z.ZodOptional<z.ZodNumber>;
|
|
854
855
|
max_model_attempts: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodNumber, z.ZodLiteral<"unlimited">, z.ZodNull]>, z.ZodTransform<number, number | "unlimited" | null>>>;
|
|
855
856
|
max_tool_calls: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodNumber, z.ZodLiteral<"unlimited">, z.ZodNull]>, z.ZodTransform<number, number | "unlimited" | null>>>;
|
|
856
857
|
max_steps: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodNumber, z.ZodLiteral<"unlimited">, z.ZodNull]>, z.ZodTransform<number, number | "unlimited" | null>>>;
|
package/dist/provider-catalog.js
CHANGED
|
@@ -3,7 +3,7 @@ import { webSearchConfig } from './user-config.js';
|
|
|
3
3
|
import { parse, stringify } from 'smol-toml';
|
|
4
4
|
import { DEFAULT_MODE_REF, RuntimeError, lookupModelMetadata, openCodeClientHeaders, providerPresets, validateTeamConfig, validateWorkSubpath, } from '@saturn-universe/core';
|
|
5
5
|
import { credentialRefSchema, providerBaseUrlSchema, providerIdSchema, providerModelIdSchema, providerModelRouteSchema, } from '@saturn-universe/protocol';
|
|
6
|
-
import { maxShellTimeoutMs } from '@saturn-universe/tools';
|
|
6
|
+
import { maxPluginTimeoutMs, maxShellTimeoutMs } from '@saturn-universe/tools';
|
|
7
7
|
import { capabilities, defaultCapabilities } from './configuration.js';
|
|
8
8
|
import { mcpServersSchema } from './mcp-configuration.js';
|
|
9
9
|
import { modeDefinitionsSchema, skillDefinitionsSchema } from './context-extensions.js';
|
|
@@ -43,7 +43,7 @@ export const hardLimits = {
|
|
|
43
43
|
modelTimeoutMs: 600000,
|
|
44
44
|
streamIdleTimeoutMs: 600000,
|
|
45
45
|
requestTotalTimeoutMs: 600000,
|
|
46
|
-
toolTimeoutMs:
|
|
46
|
+
toolTimeoutMs: maxPluginTimeoutMs,
|
|
47
47
|
shellTimeoutMs: maxShellTimeoutMs,
|
|
48
48
|
maxParallelTools: 64,
|
|
49
49
|
};
|
|
@@ -61,7 +61,6 @@ const runDefaults = z.strictObject({
|
|
|
61
61
|
model_timeout_ms: positive.max(hardLimits.modelTimeoutMs).optional(),
|
|
62
62
|
model_idle_timeout_ms: positive.max(hardLimits.streamIdleTimeoutMs).optional(),
|
|
63
63
|
model_total_timeout_ms: positive.max(hardLimits.requestTotalTimeoutMs).optional(),
|
|
64
|
-
tool_timeout_ms: positive.max(hardLimits.toolTimeoutMs).optional(),
|
|
65
64
|
max_parallel_tools: positive.max(hardLimits.maxParallelTools).optional(),
|
|
66
65
|
});
|
|
67
66
|
const teamPresetSchema = z.strictObject({
|
|
@@ -177,7 +176,7 @@ export function parseProviderCatalog(value) {
|
|
|
177
176
|
for (const modelId of models)
|
|
178
177
|
profiles.push(expandProfile(providerId, modelId, value));
|
|
179
178
|
}
|
|
180
|
-
if (!data.providers && !data.profiles)
|
|
179
|
+
if (!data.providers && !data.profiles && !data.modes)
|
|
181
180
|
throw invalid();
|
|
182
181
|
const names = new Set();
|
|
183
182
|
const identities = new Set();
|
|
@@ -415,6 +414,7 @@ export function selectProfile(catalog, selection) {
|
|
|
415
414
|
}
|
|
416
415
|
export function resolveRunDefaults(model, defaults, options) {
|
|
417
416
|
const reasoning = resolveDefaultReasoning(defaults, options);
|
|
417
|
+
const { toolTimeoutMs, ...budget } = resolveRunBudget(defaults, options?.modeBudget);
|
|
418
418
|
return {
|
|
419
419
|
model,
|
|
420
420
|
modeRef: defaults?.mode_ref ?? DEFAULT_MODE_REF,
|
|
@@ -428,7 +428,7 @@ export function resolveRunDefaults(model, defaults, options) {
|
|
|
428
428
|
},
|
|
429
429
|
retry: { modelMaxAttemptsPerCall: 3, toolMaxAttemptsPerCall: 1, baseDelayMs: 2000, maxDelayMs: 5000 },
|
|
430
430
|
limits: {
|
|
431
|
-
...
|
|
431
|
+
...budget,
|
|
432
432
|
modelTimeoutMs: defaults?.model_timeout_ms ?? 300000,
|
|
433
433
|
...(defaults?.model_idle_timeout_ms !== undefined
|
|
434
434
|
? { streamIdleTimeoutMs: defaults.model_idle_timeout_ms }
|
|
@@ -436,8 +436,8 @@ export function resolveRunDefaults(model, defaults, options) {
|
|
|
436
436
|
...(defaults?.model_total_timeout_ms !== undefined
|
|
437
437
|
? { requestTotalTimeoutMs: defaults.model_total_timeout_ms }
|
|
438
438
|
: {}),
|
|
439
|
-
toolTimeoutMs:
|
|
440
|
-
...(
|
|
439
|
+
toolTimeoutMs: toolTimeoutMs ?? 30000,
|
|
440
|
+
...(toolTimeoutMs === undefined ? { shellTimeoutMs: maxShellTimeoutMs } : {}),
|
|
441
441
|
maxParallelTools: defaults?.max_parallel_tools ?? 4,
|
|
442
442
|
},
|
|
443
443
|
};
|
package/dist/run-budget.d.ts
CHANGED
|
@@ -11,14 +11,22 @@ declare const budgetFields: {
|
|
|
11
11
|
};
|
|
12
12
|
type BudgetField = keyof typeof budgetFields;
|
|
13
13
|
type ConfiguredBudgetField = (typeof budgetFields)[BudgetField];
|
|
14
|
-
type ConfiguredRunBudget = Partial<Record<ConfiguredBudgetField, number | undefined>>;
|
|
15
|
-
type ConfiguredBudgetShape = Record<ConfiguredBudgetField, z.ZodOptional<ReturnType<typeof unlimitedInt>>>;
|
|
14
|
+
type ConfiguredRunBudget = Partial<Record<ConfiguredBudgetField | 'tool_timeout_ms', number | undefined>>;
|
|
16
15
|
export declare function unlimitedInt(max?: number): z.ZodPipe<z.ZodUnion<readonly [z.ZodNumber, z.ZodLiteral<"unlimited">, z.ZodNull]>, z.ZodTransform<number, number | "unlimited" | null>>;
|
|
17
|
-
export declare function configuredRunBudgetShape(maximums?: Required<ModeLimitsConfig>):
|
|
16
|
+
export declare function configuredRunBudgetShape(maximums?: Required<ModeLimitsConfig>): {
|
|
17
|
+
tool_timeout_ms: z.ZodOptional<z.ZodNumber>;
|
|
18
|
+
max_model_attempts: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodNumber, z.ZodLiteral<"unlimited">, z.ZodNull]>, z.ZodTransform<number, number | "unlimited" | null>>>;
|
|
19
|
+
max_tool_calls: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodNumber, z.ZodLiteral<"unlimited">, z.ZodNull]>, z.ZodTransform<number, number | "unlimited" | null>>>;
|
|
20
|
+
max_steps: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodNumber, z.ZodLiteral<"unlimited">, z.ZodNull]>, z.ZodTransform<number, number | "unlimited" | null>>>;
|
|
21
|
+
max_total_tokens: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodNumber, z.ZodLiteral<"unlimited">, z.ZodNull]>, z.ZodTransform<number, number | "unlimited" | null>>>;
|
|
22
|
+
subagent_max_model_attempts: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodNumber, z.ZodLiteral<"unlimited">, z.ZodNull]>, z.ZodTransform<number, number | "unlimited" | null>>>;
|
|
23
|
+
wall_time_ms: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodNumber, z.ZodLiteral<"unlimited">, z.ZodNull]>, z.ZodTransform<number, number | "unlimited" | null>>>;
|
|
24
|
+
subagent_wall_time_ms: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodNumber, z.ZodLiteral<"unlimited">, z.ZodNull]>, z.ZodTransform<number, number | "unlimited" | null>>>;
|
|
25
|
+
};
|
|
18
26
|
export interface ModeBudgetLayers {
|
|
19
27
|
readonly defaults?: ModeLimitsConfig;
|
|
20
28
|
readonly overrides?: ModeLimitsConfig;
|
|
21
29
|
}
|
|
22
30
|
export declare function readConfiguredRunBudget(raw: ConfiguredRunBudget | undefined): ModeLimitsConfig;
|
|
23
|
-
export declare function resolveRunBudget(rawDefaults: ConfiguredRunBudget | undefined, modeBudget?: ModeBudgetLayers): Pick<RuntimeLimits,
|
|
31
|
+
export declare function resolveRunBudget(rawDefaults: ConfiguredRunBudget | undefined, modeBudget?: ModeBudgetLayers): Pick<RuntimeLimits, BudgetField> & Pick<ModeLimitsConfig, 'toolTimeoutMs'>;
|
|
24
32
|
export {};
|
package/dist/run-budget.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { DEFAULT_SUBAGENT_MAX_MODEL_ATTEMPTS, DEFAULT_SUBAGENT_WALL_TIME_MS, isLimited, } from '@saturn-universe/core';
|
|
2
|
+
import { maxPluginTimeoutMs } from '@saturn-universe/tools';
|
|
2
3
|
import { z } from 'zod';
|
|
3
4
|
const budgetFields = {
|
|
4
5
|
maxModelAttempts: 'max_model_attempts',
|
|
@@ -17,7 +18,11 @@ export function unlimitedInt(max) {
|
|
|
17
18
|
.transform((value) => (value === 'unlimited' || value === null ? 0 : value));
|
|
18
19
|
}
|
|
19
20
|
export function configuredRunBudgetShape(maximums) {
|
|
20
|
-
|
|
21
|
+
const unlimitedFields = Object.fromEntries(budgetKeys.map((field) => [budgetFields[field], unlimitedInt(maximums?.[field]).optional()]));
|
|
22
|
+
return {
|
|
23
|
+
...unlimitedFields,
|
|
24
|
+
tool_timeout_ms: z.number().int().positive().max(maxPluginTimeoutMs).optional(),
|
|
25
|
+
};
|
|
21
26
|
}
|
|
22
27
|
export function readConfiguredRunBudget(raw) {
|
|
23
28
|
const budget = {};
|
|
@@ -26,6 +31,8 @@ export function readConfiguredRunBudget(raw) {
|
|
|
26
31
|
if (value !== undefined)
|
|
27
32
|
budget[field] = value;
|
|
28
33
|
}
|
|
34
|
+
if (raw?.tool_timeout_ms !== undefined)
|
|
35
|
+
budget.toolTimeoutMs = raw.tool_timeout_ms;
|
|
29
36
|
return budget;
|
|
30
37
|
}
|
|
31
38
|
export function resolveRunBudget(rawDefaults, modeBudget) {
|
|
@@ -34,7 +41,7 @@ export function resolveRunBudget(rawDefaults, modeBudget) {
|
|
|
34
41
|
...readConfiguredRunBudget(rawDefaults),
|
|
35
42
|
...modeBudget?.overrides,
|
|
36
43
|
};
|
|
37
|
-
const { wallTimeMs } = budget;
|
|
44
|
+
const { wallTimeMs, toolTimeoutMs } = budget;
|
|
38
45
|
return {
|
|
39
46
|
maxModelAttempts: budget.maxModelAttempts ?? 0,
|
|
40
47
|
maxToolCalls: budget.maxToolCalls ?? 0,
|
|
@@ -43,5 +50,6 @@ export function resolveRunBudget(rawDefaults, modeBudget) {
|
|
|
43
50
|
subagentMaxModelAttempts: budget.subagentMaxModelAttempts ?? DEFAULT_SUBAGENT_MAX_MODEL_ATTEMPTS,
|
|
44
51
|
...(isLimited(wallTimeMs) ? { wallTimeMs } : {}),
|
|
45
52
|
subagentWallTimeMs: budget.subagentWallTimeMs ?? DEFAULT_SUBAGENT_WALL_TIME_MS,
|
|
53
|
+
...(toolTimeoutMs !== undefined ? { toolTimeoutMs } : {}),
|
|
46
54
|
};
|
|
47
55
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@saturn-universe/runtime-host",
|
|
3
|
-
"version": "0.1.2-dev.
|
|
3
|
+
"version": "0.1.2-dev.4",
|
|
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.2-dev.
|
|
12
|
-
"@saturn-universe/core": "0.1.2-dev.
|
|
13
|
-
"@saturn-universe/model": "0.1.2-dev.
|
|
14
|
-
"@saturn-universe/plugin-sdk": "0.1.2-dev.
|
|
15
|
-
"@saturn-universe/protocol": "0.1.2-dev.
|
|
16
|
-
"@saturn-universe/runtime": "0.1.2-dev.
|
|
17
|
-
"@saturn-universe/storage": "0.1.2-dev.
|
|
18
|
-
"@saturn-universe/tools": "0.1.2-dev.
|
|
11
|
+
"@saturn-universe/context": "0.1.2-dev.4",
|
|
12
|
+
"@saturn-universe/core": "0.1.2-dev.4",
|
|
13
|
+
"@saturn-universe/model": "0.1.2-dev.4",
|
|
14
|
+
"@saturn-universe/plugin-sdk": "0.1.2-dev.4",
|
|
15
|
+
"@saturn-universe/protocol": "0.1.2-dev.4",
|
|
16
|
+
"@saturn-universe/runtime": "0.1.2-dev.4",
|
|
17
|
+
"@saturn-universe/storage": "0.1.2-dev.4",
|
|
18
|
+
"@saturn-universe/tools": "0.1.2-dev.4",
|
|
19
19
|
"import-meta-resolve": "4.2.0",
|
|
20
20
|
"pino": "10.4.0",
|
|
21
21
|
"semver": "7.7.4",
|