@saturn-universe/runtime-host 0.1.1 → 0.1.2-dev.10

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 (42) 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 +2 -1
  4. package/dist/composition.d.ts +20 -55
  5. package/dist/composition.js +316 -89
  6. package/dist/context-extensions.d.ts +132 -10
  7. package/dist/context-extensions.js +30 -4
  8. package/dist/cordis/model-responses-plugin.d.ts +2 -1
  9. package/dist/cordis/model-responses-plugin.js +16 -11
  10. package/dist/cordis/plugin-lifecycle.d.ts +1 -0
  11. package/dist/cordis/plugin-lifecycle.js +3 -0
  12. package/dist/cordis/plugin-loader.d.ts +1 -1
  13. package/dist/cordis/plugin-loader.js +45 -10
  14. package/dist/cordis/sandbox-plugin.d.ts +1 -0
  15. package/dist/cordis/sandbox-plugin.js +1 -0
  16. package/dist/cordis/tools/builtin-agent-tools-plugin.d.ts +2 -2
  17. package/dist/cordis/tools/builtin-agent-tools-plugin.js +27 -3
  18. package/dist/cordis/tools/index.d.ts +5 -1
  19. package/dist/cordis/tools/index.js +3 -3
  20. package/dist/cordis/tools/process-manager-plugin.d.ts +1 -1
  21. package/dist/cordis/tools/process-manager-plugin.js +8 -8
  22. package/dist/cordis/tools/tools-core-plugin.js +54 -11
  23. package/dist/env-probe.js +33 -20
  24. package/dist/host-configuration.d.ts +4 -0
  25. package/dist/host-configuration.js +25 -1
  26. package/dist/index.js +9 -2
  27. package/dist/mode-configuration.d.ts +197 -0
  28. package/dist/mode-configuration.js +109 -0
  29. package/dist/modes.js +52 -10
  30. package/dist/provider-catalog.d.ts +301 -34
  31. package/dist/provider-catalog.js +80 -79
  32. package/dist/run-budget.d.ts +30 -7
  33. package/dist/run-budget.js +49 -5
  34. package/dist/runtime-tuning.d.ts +23 -0
  35. package/dist/runtime-tuning.js +68 -0
  36. package/dist/sandbox-manager.d.ts +2 -0
  37. package/dist/sandbox-manager.js +18 -12
  38. package/dist/session-mode-runtime.d.ts +99 -0
  39. package/dist/session-mode-runtime.js +306 -0
  40. package/dist/skills-runtime.d.ts +5 -2
  41. package/dist/skills-runtime.js +8 -5
  42. package/package.json +9 -9
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
  }