@saturn-universe/runtime-host 0.1.2-dev.6 → 0.1.2-dev.9

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.
Files changed (37) hide show
  1. package/dist/builtin-plugins/saturn-plugin-ctf/index.mjs +2 -2
  2. package/dist/builtin-plugins/saturn-plugin-ctf/package.json +1 -1
  3. package/dist/command-dispatch.js +1 -0
  4. package/dist/composition.d.ts +20 -56
  5. package/dist/composition.js +302 -89
  6. package/dist/context-extensions.d.ts +130 -10
  7. package/dist/context-extensions.js +30 -4
  8. package/dist/cordis/plugin-lifecycle.d.ts +1 -0
  9. package/dist/cordis/plugin-lifecycle.js +3 -0
  10. package/dist/cordis/sandbox-plugin.d.ts +1 -0
  11. package/dist/cordis/sandbox-plugin.js +1 -0
  12. package/dist/cordis/tools/builtin-agent-tools-plugin.d.ts +1 -1
  13. package/dist/cordis/tools/builtin-agent-tools-plugin.js +15 -1
  14. package/dist/cordis/tools/index.d.ts +3 -1
  15. package/dist/cordis/tools/index.js +3 -3
  16. package/dist/cordis/tools/process-manager-plugin.d.ts +1 -1
  17. package/dist/cordis/tools/process-manager-plugin.js +8 -8
  18. package/dist/cordis/tools/tools-core-plugin.js +46 -5
  19. package/dist/host-configuration.d.ts +1 -0
  20. package/dist/host-configuration.js +2 -1
  21. package/dist/index.js +1 -1
  22. package/dist/mode-configuration.d.ts +46 -3
  23. package/dist/mode-configuration.js +3 -0
  24. package/dist/modes.js +52 -10
  25. package/dist/provider-catalog.d.ts +84 -14
  26. package/dist/provider-catalog.js +29 -45
  27. package/dist/run-budget.d.ts +21 -6
  28. package/dist/run-budget.js +48 -12
  29. package/dist/runtime-tuning.d.ts +23 -0
  30. package/dist/runtime-tuning.js +68 -0
  31. package/dist/sandbox-manager.d.ts +2 -0
  32. package/dist/sandbox-manager.js +18 -12
  33. package/dist/session-mode-runtime.d.ts +99 -0
  34. package/dist/session-mode-runtime.js +306 -0
  35. package/dist/skills-runtime.d.ts +5 -2
  36. package/dist/skills-runtime.js +8 -5
  37. package/package.json +9 -9
@@ -50,12 +50,26 @@ export declare function loadModeConfiguration(env: NodeJS.ProcessEnv, configured
50
50
  } | undefined;
51
51
  } | undefined;
52
52
  tools?: {
53
+ roles?: {
54
+ main?: {
55
+ allowed_tools?: string[] | undefined;
56
+ denied_tools?: string[] | undefined;
57
+ } | undefined;
58
+ worker?: {
59
+ allowed_tools?: string[] | undefined;
60
+ denied_tools?: string[] | undefined;
61
+ } | undefined;
62
+ } | undefined;
63
+ permission_mode?: "default" | "strict" | "full" | undefined;
64
+ allowed_tools?: string[] | undefined;
65
+ denied_tools?: string[] | undefined;
53
66
  workspace_tools?: boolean | undefined;
54
67
  process_manager?: boolean | undefined;
55
68
  builtin_agent_tools?: boolean | undefined;
56
- allowed_tools?: string[] | undefined;
57
- denied_tools?: string[] | undefined;
58
- permission_mode?: "default" | "strict" | "full" | undefined;
69
+ } | undefined;
70
+ reasoning?: {
71
+ main_effort?: "low" | "off" | "none" | "minimal" | "medium" | "high" | "xhigh" | "max" | undefined;
72
+ worker_effort?: "low" | "off" | "none" | "minimal" | "medium" | "high" | "xhigh" | "max" | undefined;
59
73
  } | undefined;
60
74
  plugins?: string[] | Record<string, {
61
75
  allowed_tools?: string[] | undefined;
@@ -122,11 +136,21 @@ export declare function loadModeConfiguration(env: NodeJS.ProcessEnv, configured
122
136
  } | undefined;
123
137
  team?: {
124
138
  max_depth?: number | undefined;
139
+ default_concurrency?: number | undefined;
140
+ default_preset?: string | undefined;
141
+ max_concurrency?: number | undefined;
142
+ max_active_depth1?: number | undefined;
143
+ worker_soft_checkpoint_ms?: number | undefined;
125
144
  async_coordinator?: boolean | undefined;
126
145
  coordinator_poll_interval_ms?: number | undefined;
127
146
  } | undefined;
128
147
  limits?: {
148
+ model_timeout_ms?: number | undefined;
149
+ stream_idle_timeout_ms?: number | undefined;
150
+ request_total_timeout_ms?: number | undefined;
129
151
  tool_timeout_ms?: number | undefined;
152
+ shell_timeout_ms?: number | undefined;
153
+ max_parallel_tools?: number | undefined;
130
154
  max_model_attempts?: number | undefined;
131
155
  max_tool_calls?: number | undefined;
132
156
  max_steps?: number | undefined;
@@ -135,6 +159,24 @@ export declare function loadModeConfiguration(env: NodeJS.ProcessEnv, configured
135
159
  wall_time_ms?: number | undefined;
136
160
  subagent_wall_time_ms?: number | undefined;
137
161
  } | undefined;
162
+ retry?: {
163
+ model_max_attempts_per_call?: number | undefined;
164
+ tool_max_attempts_per_call?: number | undefined;
165
+ base_delay_ms?: number | undefined;
166
+ max_delay_ms?: number | undefined;
167
+ } | undefined;
168
+ compaction?: {
169
+ enabled?: boolean | undefined;
170
+ threshold_ratio?: number | undefined;
171
+ max_headroom_tokens?: number | undefined;
172
+ headroom_ratio?: number | undefined;
173
+ min_recent_steps?: number | undefined;
174
+ tail_window_ratio?: number | undefined;
175
+ preflight_window_ratio?: number | undefined;
176
+ max_halvings?: number | undefined;
177
+ min_prefix_chars?: number | undefined;
178
+ summary_timeout_ms?: number | undefined;
179
+ } | undefined;
138
180
  max_active_challenges?: number | undefined;
139
181
  max_helpers_per_challenge?: number | undefined;
140
182
  per_challenge_wall_time_ms?: number | undefined;
@@ -150,5 +192,6 @@ export declare function loadModeConfiguration(env: NodeJS.ProcessEnv, configured
150
192
  };
151
193
  } | undefined;
152
194
  modePluginSources: Map<string, Map<string, ModePluginSource>>;
195
+ modePackageDirectories: Map<string, string>;
153
196
  }>;
154
197
  export {};
@@ -6,6 +6,7 @@ import { userModeDirectories } from '@saturn-universe/protocol';
6
6
  import { modeDefinitionsSchema } from './context-extensions.js';
7
7
  export async function loadModeConfiguration(env, configured) {
8
8
  const discovered = new Map();
9
+ const modePackageDirectories = new Map();
9
10
  for (const directory of await userModeDirectories(env)) {
10
11
  const filename = path.join(directory, 'mode.toml');
11
12
  try {
@@ -17,6 +18,7 @@ export async function loadModeConfiguration(env, configured) {
17
18
  const modes = modeDefinitionsSchema.parse(parse(await readFile(filename, 'utf8')).modes);
18
19
  for (const [ref, mode] of Object.entries(modes)) {
19
20
  discovered.set(ref, { modes: { [ref]: mode }, pluginSource: { directory, bundled: true } });
21
+ modePackageDirectories.set(ref, directory);
20
22
  }
21
23
  }
22
24
  catch (error) {
@@ -52,6 +54,7 @@ export async function loadModeConfiguration(env, configured) {
52
54
  return {
53
55
  modes: modes.size ? Object.fromEntries(modes) : undefined,
54
56
  modePluginSources,
57
+ modePackageDirectories,
55
58
  };
56
59
  }
57
60
  function mergeModes(base, override) {
package/dist/modes.js CHANGED
@@ -4,6 +4,7 @@ import { fileURLToPath } from 'node:url';
4
4
  import { DEFAULT_MODE_REF, resolveModeSelector, RuntimeError } from '@saturn-universe/core';
5
5
  import { readConfiguredPluginGrant } from './plugin-tool-grants.js';
6
6
  import { readConfiguredRunBudget } from './run-budget.js';
7
+ import { readModeCompaction, readModeRetry, resolveRetryPolicy } from './runtime-tuning.js';
7
8
  const CTF_READ_TOOLS = ['ctf_board_status', 'ctf_query_ledger'];
8
9
  const CTF_WRITE_TOOLS = [
9
10
  'ctf_scan_workspace',
@@ -224,12 +225,25 @@ function mergeTools(base, raw) {
224
225
  ? [...baseDenied]
225
226
  : undefined;
226
227
  const permissionMode = raw.tools?.permission_mode ?? base?.permissionMode;
228
+ const roles = { ...base?.roles };
229
+ for (const role of ['main', 'worker']) {
230
+ const filter = raw.tools?.roles?.[role];
231
+ if (!filter)
232
+ continue;
233
+ roles[role] = {
234
+ ...roles[role],
235
+ ...(filter.allowed_tools !== undefined ? { allowedTools: [...filter.allowed_tools] } : {}),
236
+ ...(filter.denied_tools !== undefined ? { deniedTools: [...filter.denied_tools] } : {}),
237
+ };
238
+ }
239
+ const hasRoles = Object.keys(roles).length > 0;
227
240
  if (workspaceTools === undefined &&
228
241
  processManager === undefined &&
229
242
  builtinAgentTools === undefined &&
230
243
  allowedTools === undefined &&
231
244
  deniedTools === undefined &&
232
- permissionMode === undefined)
245
+ permissionMode === undefined &&
246
+ !hasRoles)
233
247
  return undefined;
234
248
  return {
235
249
  ...(workspaceTools !== undefined ? { workspaceTools } : {}),
@@ -238,6 +252,7 @@ function mergeTools(base, raw) {
238
252
  ...(allowedTools !== undefined ? { allowedTools: [...allowedTools] } : {}),
239
253
  ...(deniedTools !== undefined ? { deniedTools: [...deniedTools] } : {}),
240
254
  ...(permissionMode !== undefined ? { permissionMode } : {}),
255
+ ...(hasRoles ? { roles } : {}),
241
256
  };
242
257
  }
243
258
  function mergePlugins(base, raw) {
@@ -345,13 +360,14 @@ function configureMode(ref, raw, builtin) {
345
360
  const base = builtin?.definition;
346
361
  const prompts = mergePrompts(base?.prompts, raw);
347
362
  const tools = mergeTools(base?.tools, raw);
363
+ const mainEffort = raw.reasoning?.main_effort ?? base?.reasoning?.mainEffort;
364
+ const workerEffort = raw.reasoning?.worker_effort ?? base?.reasoning?.workerEffort;
348
365
  const { bindings, toolGrantOverrides } = mergePlugins(base?.plugins, raw.plugins);
349
366
  let plugins = bindings;
350
367
  const ctfOptions = Object.fromEntries([
351
368
  'max_active_challenges',
352
369
  'max_helpers_per_challenge',
353
370
  'per_challenge_wall_time_ms',
354
- 'worker_soft_checkpoint_ms',
355
371
  'board_port',
356
372
  'board_token',
357
373
  'board_public_host',
@@ -363,6 +379,8 @@ function configureMode(ref, raw, builtin) {
363
379
  ]
364
380
  .filter((key) => raw[key] !== undefined)
365
381
  .map((key) => [key, raw[key]]));
382
+ if (ref === 'ctf@1' && raw.worker_soft_checkpoint_ms !== undefined)
383
+ ctfOptions.worker_soft_checkpoint_ms = raw.worker_soft_checkpoint_ms;
366
384
  if (Object.keys(ctfOptions).length) {
367
385
  if (ref !== 'ctf@1')
368
386
  throw new RuntimeError('INVALID_CONFIG', 'CTF settings require ctf@1');
@@ -374,35 +392,54 @@ function configureMode(ref, raw, builtin) {
374
392
  const coordinatorPollIntervalMs = raw.coordinator_poll_interval_ms ??
375
393
  raw.team?.coordinator_poll_interval_ms ??
376
394
  base?.team?.coordinatorPollIntervalMs;
377
- const workerSoftCheckpointMs = raw.worker_soft_checkpoint_ms ?? base?.team?.workerSoftCheckpointMs;
395
+ const workerSoftCheckpointMs = raw.team?.worker_soft_checkpoint_ms ??
396
+ raw.worker_soft_checkpoint_ms ??
397
+ base?.team?.workerSoftCheckpointMs;
378
398
  const ctfPlugin = ref === 'ctf@1' ? plugins?.find((plugin) => plugin.builtin === 'ctf' || plugin.id === 'ctf') : undefined;
379
399
  const rawMaxActive = ctfPlugin?.config?.max_active_challenges;
380
- const maxActiveDepth1 = typeof rawMaxActive === 'number' && Number.isSafeInteger(rawMaxActive) && rawMaxActive >= 1
381
- ? rawMaxActive
382
- : base?.team?.maxActiveDepth1;
400
+ const maxActiveDepth1 = raw.team?.max_active_depth1 ??
401
+ (typeof rawMaxActive === 'number' && Number.isSafeInteger(rawMaxActive) && rawMaxActive >= 1
402
+ ? rawMaxActive
403
+ : base?.team?.maxActiveDepth1);
383
404
  const isContainerSandbox = Boolean(sandbox && sandbox.backend !== 'host' && sandbox.scope !== 'none');
384
- const maxConcurrency = isContainerSandbox
405
+ const sandboxConcurrency = isContainerSandbox
385
406
  ? sandbox?.maxConcurrentContainers !== undefined
386
407
  ? Math.max(1, sandbox.maxConcurrentContainers - 1)
387
408
  : base?.team?.maxConcurrency
388
409
  : undefined;
389
- const team = maxDepth !== undefined ||
410
+ const maxConcurrency = raw.team?.max_concurrency ?? (isContainerSandbox ? base?.team?.maxConcurrency : undefined);
411
+ const defaultConcurrency = raw.team?.default_concurrency ?? base?.team?.defaultConcurrency;
412
+ if (defaultConcurrency !== undefined && maxConcurrency !== undefined && defaultConcurrency > maxConcurrency)
413
+ throw new RuntimeError('INVALID_CONFIG', `Mode ${ref}: team.default_concurrency exceeds team.max_concurrency`);
414
+ const effectiveMaxConcurrency = sandboxConcurrency === undefined
415
+ ? maxConcurrency
416
+ : Math.min(sandboxConcurrency, raw.team?.max_concurrency ?? sandboxConcurrency);
417
+ const defaultPreset = raw.team?.default_preset ?? base?.team?.defaultPreset;
418
+ const team = defaultPreset !== undefined ||
419
+ maxDepth !== undefined ||
390
420
  asyncCoordinator !== undefined ||
391
421
  coordinatorPollIntervalMs !== undefined ||
392
422
  workerSoftCheckpointMs !== undefined ||
393
423
  maxActiveDepth1 !== undefined ||
394
- maxConcurrency !== undefined
424
+ defaultConcurrency !== undefined ||
425
+ effectiveMaxConcurrency !== undefined
395
426
  ? {
396
427
  ...(maxDepth !== undefined ? { maxDepth } : {}),
428
+ ...(defaultPreset !== undefined ? { defaultPreset } : {}),
397
429
  ...(asyncCoordinator !== undefined ? { asyncCoordinator } : {}),
398
430
  ...(coordinatorPollIntervalMs !== undefined ? { coordinatorPollIntervalMs } : {}),
399
431
  ...(workerSoftCheckpointMs !== undefined ? { workerSoftCheckpointMs } : {}),
400
432
  ...(maxActiveDepth1 !== undefined ? { maxActiveDepth1 } : {}),
401
- ...(maxConcurrency !== undefined ? { maxConcurrency } : {}),
433
+ ...(defaultConcurrency !== undefined ? { defaultConcurrency } : {}),
434
+ ...(effectiveMaxConcurrency !== undefined ? { maxConcurrency: effectiveMaxConcurrency } : {}),
402
435
  }
403
436
  : undefined;
404
437
  const budget = { ...builtin?.budget, overrides: readConfiguredRunBudget(raw.limits) };
405
438
  const limits = { ...budget.defaults, ...budget.overrides };
439
+ const retry = raw.retry ? readModeRetry(raw.retry) : base?.retry;
440
+ if (retry)
441
+ resolveRetryPolicy(retry);
442
+ const compaction = raw.compaction ? readModeCompaction(raw.compaction) : base?.compaction;
406
443
  const definition = {
407
444
  ref,
408
445
  displayName: raw.display_name ?? base?.displayName ?? ref,
@@ -414,10 +451,15 @@ function configureMode(ref, raw, builtin) {
414
451
  ...(base?.builtin ? { builtin: true } : {}),
415
452
  ...(prompts ? { prompts } : {}),
416
453
  ...(tools ? { tools } : {}),
454
+ ...(mainEffort || workerEffort
455
+ ? { reasoning: { ...(mainEffort ? { mainEffort } : {}), ...(workerEffort ? { workerEffort } : {}) } }
456
+ : {}),
417
457
  ...(plugins ? { plugins } : {}),
418
458
  ...(sandbox ? { sandbox } : {}),
419
459
  ...(team ? { team } : {}),
420
460
  ...(Object.keys(limits).length ? { limits } : {}),
461
+ ...(retry ? { retry } : {}),
462
+ ...(compaction ? { compaction } : {}),
421
463
  };
422
464
  return { definition, budget, ...(toolGrantOverrides?.size ? { toolGrantOverrides } : {}) };
423
465
  }
@@ -1,17 +1,20 @@
1
1
  import { z } from 'zod';
2
2
  import type { WebSearchConfig } from './user-config.js';
3
- import type { ModelCapabilities, ModelPricing, ModelRef, ProviderProfile, ProviderProtocol, RunConfig, RuntimeLimits } from '@saturn-universe/core';
3
+ import type { HostSubmitInput, ModeDefinition, ModelCapabilities, ModelPricing, ModelRef, ProviderProfile, ProviderProtocol, RunConfig } from '@saturn-universe/core';
4
4
  import { mcpServersSchema } from './mcp-configuration.js';
5
5
  import { modeDefinitionsSchema, skillDefinitionsSchema } from './context-extensions.js';
6
6
  import { type ModeBudgetLayers } from './run-budget.js';
7
+ export { hardLimits } from './run-budget.js';
7
8
  export type ModelPricingConfig = ModelPricing;
8
- export declare const hardLimits: Required<RuntimeLimits>;
9
9
  declare const runDefaults: z.ZodObject<{
10
- model_timeout_ms: z.ZodOptional<z.ZodNumber>;
11
10
  model_idle_timeout_ms: z.ZodOptional<z.ZodNumber>;
12
11
  model_total_timeout_ms: z.ZodOptional<z.ZodNumber>;
13
- max_parallel_tools: z.ZodOptional<z.ZodNumber>;
12
+ model_timeout_ms: z.ZodOptional<z.ZodNumber>;
13
+ stream_idle_timeout_ms: z.ZodOptional<z.ZodNumber>;
14
+ request_total_timeout_ms: z.ZodOptional<z.ZodNumber>;
14
15
  tool_timeout_ms: z.ZodOptional<z.ZodNumber>;
16
+ shell_timeout_ms: z.ZodOptional<z.ZodNumber>;
17
+ max_parallel_tools: z.ZodOptional<z.ZodNumber>;
15
18
  max_model_attempts: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodNumber, z.ZodLiteral<"unlimited">, z.ZodNull]>, z.ZodTransform<number, number | "unlimited" | null>>>;
16
19
  max_tool_calls: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodNumber, z.ZodLiteral<"unlimited">, z.ZodNull]>, z.ZodTransform<number, number | "unlimited" | null>>>;
17
20
  max_steps: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodNumber, z.ZodLiteral<"unlimited">, z.ZodNull]>, z.ZodTransform<number, number | "unlimited" | null>>>;
@@ -28,8 +31,8 @@ declare const runDefaults: z.ZodObject<{
28
31
  policy_version: z.ZodOptional<z.ZodString>;
29
32
  tool_set_version: z.ZodOptional<z.ZodString>;
30
33
  planner: z.ZodOptional<z.ZodEnum<{
31
- auto: "auto";
32
34
  off: "off";
35
+ auto: "auto";
33
36
  }>>;
34
37
  search: z.ZodOptional<z.ZodEnum<{
35
38
  off: "off";
@@ -490,11 +493,14 @@ declare const catalogSchema: z.ZodObject<{
490
493
  }][]>>, unknown>>;
491
494
  task_profiles: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
492
495
  run_defaults: z.ZodOptional<z.ZodObject<{
493
- model_timeout_ms: z.ZodOptional<z.ZodNumber>;
494
496
  model_idle_timeout_ms: z.ZodOptional<z.ZodNumber>;
495
497
  model_total_timeout_ms: z.ZodOptional<z.ZodNumber>;
496
- max_parallel_tools: z.ZodOptional<z.ZodNumber>;
498
+ model_timeout_ms: z.ZodOptional<z.ZodNumber>;
499
+ stream_idle_timeout_ms: z.ZodOptional<z.ZodNumber>;
500
+ request_total_timeout_ms: z.ZodOptional<z.ZodNumber>;
497
501
  tool_timeout_ms: z.ZodOptional<z.ZodNumber>;
502
+ shell_timeout_ms: z.ZodOptional<z.ZodNumber>;
503
+ max_parallel_tools: z.ZodOptional<z.ZodNumber>;
498
504
  max_model_attempts: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodNumber, z.ZodLiteral<"unlimited">, z.ZodNull]>, z.ZodTransform<number, number | "unlimited" | null>>>;
499
505
  max_tool_calls: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodNumber, z.ZodLiteral<"unlimited">, z.ZodNull]>, z.ZodTransform<number, number | "unlimited" | null>>>;
500
506
  max_steps: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodNumber, z.ZodLiteral<"unlimited">, z.ZodNull]>, z.ZodTransform<number, number | "unlimited" | null>>>;
@@ -511,8 +517,8 @@ declare const catalogSchema: z.ZodObject<{
511
517
  policy_version: z.ZodOptional<z.ZodString>;
512
518
  tool_set_version: z.ZodOptional<z.ZodString>;
513
519
  planner: z.ZodOptional<z.ZodEnum<{
514
- auto: "auto";
515
520
  off: "off";
521
+ auto: "auto";
516
522
  }>>;
517
523
  search: z.ZodOptional<z.ZodEnum<{
518
524
  off: "off";
@@ -617,16 +623,48 @@ declare const catalogSchema: z.ZodObject<{
617
623
  }, z.core.$strict>>;
618
624
  }, z.core.$strict>>;
619
625
  tools: z.ZodOptional<z.ZodObject<{
620
- workspace_tools: z.ZodOptional<z.ZodBoolean>;
621
- process_manager: z.ZodOptional<z.ZodBoolean>;
622
- builtin_agent_tools: z.ZodOptional<z.ZodBoolean>;
623
- allowed_tools: z.ZodOptional<z.ZodArray<z.ZodString>>;
624
- denied_tools: z.ZodOptional<z.ZodArray<z.ZodString>>;
626
+ roles: z.ZodOptional<z.ZodObject<{
627
+ main: z.ZodOptional<z.ZodObject<{
628
+ allowed_tools: z.ZodOptional<z.ZodArray<z.ZodString>>;
629
+ denied_tools: z.ZodOptional<z.ZodArray<z.ZodString>>;
630
+ }, z.core.$strict>>;
631
+ worker: z.ZodOptional<z.ZodObject<{
632
+ allowed_tools: z.ZodOptional<z.ZodArray<z.ZodString>>;
633
+ denied_tools: z.ZodOptional<z.ZodArray<z.ZodString>>;
634
+ }, z.core.$strict>>;
635
+ }, z.core.$strict>>;
625
636
  permission_mode: z.ZodOptional<z.ZodEnum<{
626
637
  default: "default";
627
638
  strict: "strict";
628
639
  full: "full";
629
640
  }>>;
641
+ allowed_tools: z.ZodOptional<z.ZodArray<z.ZodString>>;
642
+ denied_tools: z.ZodOptional<z.ZodArray<z.ZodString>>;
643
+ workspace_tools: z.ZodOptional<z.ZodBoolean>;
644
+ process_manager: z.ZodOptional<z.ZodBoolean>;
645
+ builtin_agent_tools: z.ZodOptional<z.ZodBoolean>;
646
+ }, z.core.$strict>>;
647
+ reasoning: z.ZodOptional<z.ZodObject<{
648
+ main_effort: z.ZodOptional<z.ZodEnum<{
649
+ low: "low";
650
+ off: "off";
651
+ none: "none";
652
+ minimal: "minimal";
653
+ medium: "medium";
654
+ high: "high";
655
+ xhigh: "xhigh";
656
+ max: "max";
657
+ }>>;
658
+ worker_effort: z.ZodOptional<z.ZodEnum<{
659
+ low: "low";
660
+ off: "off";
661
+ none: "none";
662
+ minimal: "minimal";
663
+ medium: "medium";
664
+ high: "high";
665
+ xhigh: "xhigh";
666
+ max: "max";
667
+ }>>;
630
668
  }, z.core.$strict>>;
631
669
  plugins: z.ZodOptional<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<{
632
670
  allowed_tools: z.ZodOptional<z.ZodType<string[], unknown, z.core.$ZodTypeInternals<string[], unknown>>>;
@@ -847,11 +885,21 @@ declare const catalogSchema: z.ZodObject<{
847
885
  }, z.core.$strict>>;
848
886
  team: z.ZodOptional<z.ZodObject<{
849
887
  max_depth: z.ZodOptional<z.ZodNumber>;
888
+ default_concurrency: z.ZodOptional<z.ZodNumber>;
889
+ default_preset: z.ZodOptional<z.ZodString>;
890
+ max_concurrency: z.ZodOptional<z.ZodNumber>;
891
+ max_active_depth1: z.ZodOptional<z.ZodNumber>;
892
+ worker_soft_checkpoint_ms: z.ZodOptional<z.ZodNumber>;
850
893
  async_coordinator: z.ZodOptional<z.ZodBoolean>;
851
894
  coordinator_poll_interval_ms: z.ZodOptional<z.ZodNumber>;
852
895
  }, z.core.$strict>>;
853
896
  limits: z.ZodOptional<z.ZodObject<{
897
+ model_timeout_ms: z.ZodOptional<z.ZodNumber>;
898
+ stream_idle_timeout_ms: z.ZodOptional<z.ZodNumber>;
899
+ request_total_timeout_ms: z.ZodOptional<z.ZodNumber>;
854
900
  tool_timeout_ms: z.ZodOptional<z.ZodNumber>;
901
+ shell_timeout_ms: z.ZodOptional<z.ZodNumber>;
902
+ max_parallel_tools: z.ZodOptional<z.ZodNumber>;
855
903
  max_model_attempts: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodNumber, z.ZodLiteral<"unlimited">, z.ZodNull]>, z.ZodTransform<number, number | "unlimited" | null>>>;
856
904
  max_tool_calls: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodNumber, z.ZodLiteral<"unlimited">, z.ZodNull]>, z.ZodTransform<number, number | "unlimited" | null>>>;
857
905
  max_steps: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodNumber, z.ZodLiteral<"unlimited">, z.ZodNull]>, z.ZodTransform<number, number | "unlimited" | null>>>;
@@ -860,6 +908,24 @@ declare const catalogSchema: z.ZodObject<{
860
908
  wall_time_ms: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodNumber, z.ZodLiteral<"unlimited">, z.ZodNull]>, z.ZodTransform<number, number | "unlimited" | null>>>;
861
909
  subagent_wall_time_ms: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodNumber, z.ZodLiteral<"unlimited">, z.ZodNull]>, z.ZodTransform<number, number | "unlimited" | null>>>;
862
910
  }, z.core.$strict>>;
911
+ retry: z.ZodOptional<z.ZodObject<{
912
+ model_max_attempts_per_call: z.ZodOptional<z.ZodNumber>;
913
+ tool_max_attempts_per_call: z.ZodOptional<z.ZodNumber>;
914
+ base_delay_ms: z.ZodOptional<z.ZodNumber>;
915
+ max_delay_ms: z.ZodOptional<z.ZodNumber>;
916
+ }, z.core.$strict>>;
917
+ compaction: z.ZodOptional<z.ZodObject<{
918
+ enabled: z.ZodOptional<z.ZodBoolean>;
919
+ threshold_ratio: z.ZodOptional<z.ZodNumber>;
920
+ max_headroom_tokens: z.ZodOptional<z.ZodNumber>;
921
+ headroom_ratio: z.ZodOptional<z.ZodNumber>;
922
+ min_recent_steps: z.ZodOptional<z.ZodNumber>;
923
+ tail_window_ratio: z.ZodOptional<z.ZodNumber>;
924
+ preflight_window_ratio: z.ZodOptional<z.ZodNumber>;
925
+ max_halvings: z.ZodOptional<z.ZodNumber>;
926
+ min_prefix_chars: z.ZodOptional<z.ZodNumber>;
927
+ summary_timeout_ms: z.ZodOptional<z.ZodNumber>;
928
+ }, z.core.$strict>>;
863
929
  max_active_challenges: z.ZodOptional<z.ZodNumber>;
864
930
  max_helpers_per_challenge: z.ZodOptional<z.ZodNumber>;
865
931
  per_challenge_wall_time_ms: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodNumber, z.ZodLiteral<"unlimited">, z.ZodNull]>, z.ZodTransform<number, number | "unlimited" | null>>>;
@@ -945,7 +1011,11 @@ export interface ResolveRunDefaultsOptions {
945
1011
  readonly capabilities?: ModelCapabilities;
946
1012
  readonly profileReasoningEffort?: string;
947
1013
  readonly modeBudget?: ModeBudgetLayers;
1014
+ readonly modeRuntime?: Pick<ModeDefinition, 'retry' | 'compaction'>;
1015
+ readonly overrides?: Pick<NonNullable<HostSubmitInput['config']>, 'limits' | 'retry' | 'compaction'>;
948
1016
  }
949
1017
  export declare function resolveRunDefaults(model: ModelRef, defaults?: ProviderCatalog['runDefaults'], options?: ResolveRunDefaultsOptions): RunConfig;
950
1018
  export declare function resolveWorkerReasoning(config: RunConfig, capabilities?: ModelCapabilities): RunConfig;
951
- export {};
1019
+ export declare function resolveDefaultReasoning(defaults?: ProviderCatalog['runDefaults'], options?: Pick<ResolveRunDefaultsOptions, 'capabilities' | 'profileReasoningEffort'> & {
1020
+ readonly modeMainReasoningEffort?: string;
1021
+ }): RunConfig['responses']['reasoning'] | undefined;
@@ -3,12 +3,13 @@ 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 { maxPluginTimeoutMs, maxShellTimeoutMs } from '@saturn-universe/tools';
7
6
  import { capabilities, defaultCapabilities } from './configuration.js';
8
7
  import { mcpServersSchema } from './mcp-configuration.js';
9
8
  import { modeDefinitionsSchema, skillDefinitionsSchema } from './context-extensions.js';
10
9
  import { configurationTable } from './plugin-configuration.js';
11
- import { configuredRunBudgetShape, resolveRunBudget } from './run-budget.js';
10
+ import { configuredRunBudgetShape, hardLimits, resolveRunBudget, } from './run-budget.js';
11
+ import { resolveRetryPolicy } from './runtime-tuning.js';
12
+ export { hardLimits } from './run-budget.js';
12
13
  const id = z.string().trim().min(1).max(200);
13
14
  const positive = z.number().int().positive().safe();
14
15
  const nonnegativeNumber = z.number().nonnegative().finite();
@@ -32,21 +33,6 @@ const profile = z
32
33
  pricing: pricingSchema.optional(),
33
34
  })
34
35
  .refine((value) => value.codec_version !== 2 || value.revision !== '1');
35
- export const hardLimits = {
36
- maxModelAttempts: 10000,
37
- maxToolCalls: 10000,
38
- maxSteps: 20000,
39
- maxTotalTokens: 10000000,
40
- subagentMaxModelAttempts: 10000,
41
- wallTimeMs: 86400000,
42
- subagentWallTimeMs: 86400000,
43
- modelTimeoutMs: 600000,
44
- streamIdleTimeoutMs: 600000,
45
- requestTotalTimeoutMs: 600000,
46
- toolTimeoutMs: maxPluginTimeoutMs,
47
- shellTimeoutMs: maxShellTimeoutMs,
48
- maxParallelTools: 64,
49
- };
50
36
  const runDefaults = z.strictObject({
51
37
  mode_ref: id.optional(),
52
38
  permission_mode: z.enum(['strict', 'default', 'full']).optional(),
@@ -58,10 +44,8 @@ const runDefaults = z.strictObject({
58
44
  worker_reasoning_effort: id.optional(),
59
45
  reasoning_summary: z.enum(['auto', 'concise', 'detailed']).optional(),
60
46
  ...configuredRunBudgetShape(hardLimits),
61
- model_timeout_ms: positive.max(hardLimits.modelTimeoutMs).optional(),
62
47
  model_idle_timeout_ms: positive.max(hardLimits.streamIdleTimeoutMs).optional(),
63
48
  model_total_timeout_ms: positive.max(hardLimits.requestTotalTimeoutMs).optional(),
64
- max_parallel_tools: positive.max(hardLimits.maxParallelTools).optional(),
65
49
  });
66
50
  const teamPresetSchema = z.strictObject({
67
51
  concurrency: positive.max(16).optional(),
@@ -414,7 +398,13 @@ export function selectProfile(catalog, selection) {
414
398
  }
415
399
  export function resolveRunDefaults(model, defaults, options) {
416
400
  const reasoning = resolveDefaultReasoning(defaults, options);
417
- const { toolTimeoutMs, ...budget } = resolveRunBudget(defaults, options?.modeBudget);
401
+ const limits = resolveRunBudget(defaults && {
402
+ ...defaults,
403
+ stream_idle_timeout_ms: defaults.stream_idle_timeout_ms ?? defaults.model_idle_timeout_ms,
404
+ request_total_timeout_ms: defaults.request_total_timeout_ms ?? defaults.model_total_timeout_ms,
405
+ }, options?.modeBudget, options?.overrides?.limits);
406
+ const modeCompaction = options?.modeRuntime?.compaction;
407
+ const explicitCompaction = options?.overrides?.compaction;
418
408
  return {
419
409
  model,
420
410
  modeRef: defaults?.mode_ref ?? DEFAULT_MODE_REF,
@@ -426,45 +416,39 @@ export function resolveRunDefaults(model, defaults, options) {
426
416
  storage: 'local_stateless',
427
417
  ...(reasoning ? { reasoning } : {}),
428
418
  },
429
- retry: { modelMaxAttemptsPerCall: 3, toolMaxAttemptsPerCall: 1, baseDelayMs: 2000, maxDelayMs: 5000 },
430
- limits: {
431
- ...budget,
432
- modelTimeoutMs: defaults?.model_timeout_ms ?? 300000,
433
- ...(defaults?.model_idle_timeout_ms !== undefined
434
- ? { streamIdleTimeoutMs: defaults.model_idle_timeout_ms }
435
- : {}),
436
- ...(defaults?.model_total_timeout_ms !== undefined
437
- ? { requestTotalTimeoutMs: defaults.model_total_timeout_ms }
438
- : {}),
439
- toolTimeoutMs: toolTimeoutMs ?? 30000,
440
- ...(toolTimeoutMs === undefined ? { shellTimeoutMs: maxShellTimeoutMs } : {}),
441
- maxParallelTools: defaults?.max_parallel_tools ?? 4,
442
- },
419
+ limits,
420
+ retry: resolveRetryPolicy(options?.modeRuntime?.retry, options?.overrides?.retry),
421
+ ...(modeCompaction || explicitCompaction
422
+ ? { compaction: { ...modeCompaction, ...explicitCompaction } }
423
+ : {}),
443
424
  };
444
425
  }
445
426
  export function resolveWorkerReasoning(config, capabilities) {
446
- const effort = config.workerReasoningEffort;
447
- const responses = capabilities?.responses;
448
- if (!effort)
427
+ const defaults = config.workerReasoningDefaults;
428
+ const effort = (defaults?.explicitEffort ? undefined : defaults?.modeEffort) ?? config.workerReasoningEffort;
429
+ if (!effort && !defaults)
449
430
  return config;
450
- if (effort === 'off' || effort === 'none') {
451
- const { reasoning: _removed, ...restResponses } = config.responses;
431
+ const { reasoning, ...restResponses } = config.responses;
432
+ const fallback = defaults ? defaults.reasoning : reasoning;
433
+ const baseResponses = { ...restResponses, ...(fallback ? { reasoning: fallback } : {}) };
434
+ const responses = capabilities?.responses;
435
+ if (effort === 'off' || effort === 'none')
452
436
  return { ...config, responses: restResponses };
453
- }
454
- if (!responses?.reasoningModel ||
437
+ if (!effort ||
438
+ !responses?.reasoningModel ||
455
439
  (responses.reasoningEfforts.length > 0 && !responses.reasoningEfforts.includes(effort)))
456
- return config;
440
+ return { ...config, responses: baseResponses };
457
441
  return {
458
442
  ...config,
459
- responses: { ...config.responses, reasoning: { ...config.responses.reasoning, effort } },
443
+ responses: { ...baseResponses, reasoning: { ...fallback, effort } },
460
444
  };
461
445
  }
462
- function resolveDefaultReasoning(defaults, options) {
446
+ export function resolveDefaultReasoning(defaults, options) {
463
447
  const caps = options?.capabilities?.responses;
464
448
  if (!caps?.reasoningModel)
465
449
  return undefined;
466
450
  const supportedEfforts = caps.reasoningEfforts;
467
- const requestedEffort = defaults?.reasoning_effort ?? options?.profileReasoningEffort;
451
+ const requestedEffort = options?.modeMainReasoningEffort ?? defaults?.reasoning_effort ?? options?.profileReasoningEffort;
468
452
  if (requestedEffort === 'off' || requestedEffort === 'none')
469
453
  return undefined;
470
454
  const effort = requestedEffort && (!supportedEfforts.length || supportedEfforts.includes(requestedEffort))
@@ -1,5 +1,6 @@
1
- import type { ModeLimitsConfig, RuntimeLimits } from '@saturn-universe/core';
1
+ import type { ModeLimitsConfig, RuntimeLimits, RuntimeTimingLimits } from '@saturn-universe/core';
2
2
  import { z } from 'zod';
3
+ export declare const hardLimits: Required<RuntimeLimits>;
3
4
  declare const budgetFields: {
4
5
  readonly maxModelAttempts: "max_model_attempts";
5
6
  readonly maxToolCalls: "max_tool_calls";
@@ -9,12 +10,25 @@ declare const budgetFields: {
9
10
  readonly wallTimeMs: "wall_time_ms";
10
11
  readonly subagentWallTimeMs: "subagent_wall_time_ms";
11
12
  };
12
- type BudgetField = keyof typeof budgetFields;
13
- type ConfiguredBudgetField = (typeof budgetFields)[BudgetField];
14
- type ConfiguredRunBudget = Partial<Record<ConfiguredBudgetField | 'tool_timeout_ms', number | undefined>>;
13
+ declare const timingFields: {
14
+ readonly modelTimeoutMs: "model_timeout_ms";
15
+ readonly streamIdleTimeoutMs: "stream_idle_timeout_ms";
16
+ readonly requestTotalTimeoutMs: "request_total_timeout_ms";
17
+ readonly toolTimeoutMs: "tool_timeout_ms";
18
+ readonly shellTimeoutMs: "shell_timeout_ms";
19
+ readonly maxParallelTools: "max_parallel_tools";
20
+ };
21
+ type ConfiguredBudgetField = (typeof budgetFields)[keyof typeof budgetFields];
22
+ type ConfiguredTimingField = (typeof timingFields)[keyof typeof timingFields];
23
+ type ConfiguredRunBudget = Partial<Record<ConfiguredBudgetField | ConfiguredTimingField, number | undefined>>;
15
24
  export declare function unlimitedInt(max?: number): z.ZodPipe<z.ZodUnion<readonly [z.ZodNumber, z.ZodLiteral<"unlimited">, z.ZodNull]>, z.ZodTransform<number, number | "unlimited" | null>>;
16
- export declare function configuredRunBudgetShape(maximums?: Required<ModeLimitsConfig>): {
25
+ export declare function configuredRunBudgetShape(maximums?: Required<RuntimeLimits>): {
26
+ model_timeout_ms: z.ZodOptional<z.ZodNumber>;
27
+ stream_idle_timeout_ms: z.ZodOptional<z.ZodNumber>;
28
+ request_total_timeout_ms: z.ZodOptional<z.ZodNumber>;
17
29
  tool_timeout_ms: z.ZodOptional<z.ZodNumber>;
30
+ shell_timeout_ms: z.ZodOptional<z.ZodNumber>;
31
+ max_parallel_tools: z.ZodOptional<z.ZodNumber>;
18
32
  max_model_attempts: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodNumber, z.ZodLiteral<"unlimited">, z.ZodNull]>, z.ZodTransform<number, number | "unlimited" | null>>>;
19
33
  max_tool_calls: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodNumber, z.ZodLiteral<"unlimited">, z.ZodNull]>, z.ZodTransform<number, number | "unlimited" | null>>>;
20
34
  max_steps: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodNumber, z.ZodLiteral<"unlimited">, z.ZodNull]>, z.ZodTransform<number, number | "unlimited" | null>>>;
@@ -28,5 +42,6 @@ export interface ModeBudgetLayers {
28
42
  readonly overrides?: ModeLimitsConfig;
29
43
  }
30
44
  export declare function readConfiguredRunBudget(raw: ConfiguredRunBudget | undefined): ModeLimitsConfig;
31
- export declare function resolveRunBudget(rawDefaults: ConfiguredRunBudget | undefined, modeBudget?: ModeBudgetLayers): Pick<RuntimeLimits, BudgetField> & Pick<ModeLimitsConfig, 'toolTimeoutMs'>;
45
+ export declare function explicitTimingLimits(limits: Partial<RuntimeLimits> | undefined): Partial<RuntimeTimingLimits> | undefined;
46
+ export declare function resolveRunBudget(rawDefaults: ConfiguredRunBudget | undefined, modeBudget?: ModeBudgetLayers, explicitLimits?: Partial<RuntimeLimits>): RuntimeLimits;
32
47
  export {};