@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
@@ -107,16 +107,48 @@ export declare const modeDefinitionSchema: z.ZodObject<{
107
107
  }, z.core.$strict>>;
108
108
  }, z.core.$strict>>;
109
109
  tools: z.ZodOptional<z.ZodObject<{
110
- workspace_tools: z.ZodOptional<z.ZodBoolean>;
111
- process_manager: z.ZodOptional<z.ZodBoolean>;
112
- builtin_agent_tools: z.ZodOptional<z.ZodBoolean>;
113
- allowed_tools: z.ZodOptional<z.ZodArray<z.ZodString>>;
114
- denied_tools: z.ZodOptional<z.ZodArray<z.ZodString>>;
110
+ roles: z.ZodOptional<z.ZodObject<{
111
+ main: z.ZodOptional<z.ZodObject<{
112
+ allowed_tools: z.ZodOptional<z.ZodArray<z.ZodString>>;
113
+ denied_tools: z.ZodOptional<z.ZodArray<z.ZodString>>;
114
+ }, z.core.$strict>>;
115
+ worker: z.ZodOptional<z.ZodObject<{
116
+ allowed_tools: z.ZodOptional<z.ZodArray<z.ZodString>>;
117
+ denied_tools: z.ZodOptional<z.ZodArray<z.ZodString>>;
118
+ }, z.core.$strict>>;
119
+ }, z.core.$strict>>;
115
120
  permission_mode: z.ZodOptional<z.ZodEnum<{
116
121
  default: "default";
117
122
  strict: "strict";
118
123
  full: "full";
119
124
  }>>;
125
+ allowed_tools: z.ZodOptional<z.ZodArray<z.ZodString>>;
126
+ denied_tools: z.ZodOptional<z.ZodArray<z.ZodString>>;
127
+ workspace_tools: z.ZodOptional<z.ZodBoolean>;
128
+ process_manager: z.ZodOptional<z.ZodBoolean>;
129
+ builtin_agent_tools: z.ZodOptional<z.ZodBoolean>;
130
+ }, z.core.$strict>>;
131
+ reasoning: z.ZodOptional<z.ZodObject<{
132
+ main_effort: z.ZodOptional<z.ZodEnum<{
133
+ low: "low";
134
+ off: "off";
135
+ none: "none";
136
+ minimal: "minimal";
137
+ medium: "medium";
138
+ high: "high";
139
+ xhigh: "xhigh";
140
+ max: "max";
141
+ }>>;
142
+ worker_effort: z.ZodOptional<z.ZodEnum<{
143
+ low: "low";
144
+ off: "off";
145
+ none: "none";
146
+ minimal: "minimal";
147
+ medium: "medium";
148
+ high: "high";
149
+ xhigh: "xhigh";
150
+ max: "max";
151
+ }>>;
120
152
  }, z.core.$strict>>;
121
153
  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<{
122
154
  allowed_tools: z.ZodOptional<z.ZodType<string[], unknown, z.core.$ZodTypeInternals<string[], unknown>>>;
@@ -337,10 +369,21 @@ export declare const modeDefinitionSchema: z.ZodObject<{
337
369
  }, z.core.$strict>>;
338
370
  team: z.ZodOptional<z.ZodObject<{
339
371
  max_depth: z.ZodOptional<z.ZodNumber>;
372
+ default_concurrency: z.ZodOptional<z.ZodNumber>;
373
+ default_preset: z.ZodOptional<z.ZodString>;
374
+ max_concurrency: z.ZodOptional<z.ZodNumber>;
375
+ max_active_depth1: z.ZodOptional<z.ZodNumber>;
376
+ worker_soft_checkpoint_ms: z.ZodOptional<z.ZodNumber>;
340
377
  async_coordinator: z.ZodOptional<z.ZodBoolean>;
341
378
  coordinator_poll_interval_ms: z.ZodOptional<z.ZodNumber>;
342
379
  }, z.core.$strict>>;
343
380
  limits: z.ZodOptional<z.ZodObject<{
381
+ model_timeout_ms: z.ZodOptional<z.ZodNumber>;
382
+ stream_idle_timeout_ms: z.ZodOptional<z.ZodNumber>;
383
+ request_total_timeout_ms: z.ZodOptional<z.ZodNumber>;
384
+ tool_timeout_ms: z.ZodOptional<z.ZodNumber>;
385
+ shell_timeout_ms: z.ZodOptional<z.ZodNumber>;
386
+ max_parallel_tools: z.ZodOptional<z.ZodNumber>;
344
387
  max_model_attempts: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodNumber, z.ZodLiteral<"unlimited">, z.ZodNull]>, z.ZodTransform<number, number | "unlimited" | null>>>;
345
388
  max_tool_calls: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodNumber, z.ZodLiteral<"unlimited">, z.ZodNull]>, z.ZodTransform<number, number | "unlimited" | null>>>;
346
389
  max_steps: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodNumber, z.ZodLiteral<"unlimited">, z.ZodNull]>, z.ZodTransform<number, number | "unlimited" | null>>>;
@@ -349,6 +392,24 @@ export declare const modeDefinitionSchema: z.ZodObject<{
349
392
  wall_time_ms: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodNumber, z.ZodLiteral<"unlimited">, z.ZodNull]>, z.ZodTransform<number, number | "unlimited" | null>>>;
350
393
  subagent_wall_time_ms: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodNumber, z.ZodLiteral<"unlimited">, z.ZodNull]>, z.ZodTransform<number, number | "unlimited" | null>>>;
351
394
  }, z.core.$strict>>;
395
+ retry: z.ZodOptional<z.ZodObject<{
396
+ model_max_attempts_per_call: z.ZodOptional<z.ZodNumber>;
397
+ tool_max_attempts_per_call: z.ZodOptional<z.ZodNumber>;
398
+ base_delay_ms: z.ZodOptional<z.ZodNumber>;
399
+ max_delay_ms: z.ZodOptional<z.ZodNumber>;
400
+ }, z.core.$strict>>;
401
+ compaction: z.ZodOptional<z.ZodObject<{
402
+ enabled: z.ZodOptional<z.ZodBoolean>;
403
+ threshold_ratio: z.ZodOptional<z.ZodNumber>;
404
+ max_headroom_tokens: z.ZodOptional<z.ZodNumber>;
405
+ headroom_ratio: z.ZodOptional<z.ZodNumber>;
406
+ min_recent_steps: z.ZodOptional<z.ZodNumber>;
407
+ tail_window_ratio: z.ZodOptional<z.ZodNumber>;
408
+ preflight_window_ratio: z.ZodOptional<z.ZodNumber>;
409
+ max_halvings: z.ZodOptional<z.ZodNumber>;
410
+ min_prefix_chars: z.ZodOptional<z.ZodNumber>;
411
+ summary_timeout_ms: z.ZodOptional<z.ZodNumber>;
412
+ }, z.core.$strict>>;
352
413
  max_active_challenges: z.ZodOptional<z.ZodNumber>;
353
414
  max_helpers_per_challenge: z.ZodOptional<z.ZodNumber>;
354
415
  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>>>;
@@ -419,16 +480,48 @@ export declare const modeDefinitionsSchema: z.ZodRecord<z.ZodString, z.ZodObject
419
480
  }, z.core.$strict>>;
420
481
  }, z.core.$strict>>;
421
482
  tools: z.ZodOptional<z.ZodObject<{
422
- workspace_tools: z.ZodOptional<z.ZodBoolean>;
423
- process_manager: z.ZodOptional<z.ZodBoolean>;
424
- builtin_agent_tools: z.ZodOptional<z.ZodBoolean>;
425
- allowed_tools: z.ZodOptional<z.ZodArray<z.ZodString>>;
426
- denied_tools: z.ZodOptional<z.ZodArray<z.ZodString>>;
483
+ roles: z.ZodOptional<z.ZodObject<{
484
+ main: z.ZodOptional<z.ZodObject<{
485
+ allowed_tools: z.ZodOptional<z.ZodArray<z.ZodString>>;
486
+ denied_tools: z.ZodOptional<z.ZodArray<z.ZodString>>;
487
+ }, z.core.$strict>>;
488
+ worker: z.ZodOptional<z.ZodObject<{
489
+ allowed_tools: z.ZodOptional<z.ZodArray<z.ZodString>>;
490
+ denied_tools: z.ZodOptional<z.ZodArray<z.ZodString>>;
491
+ }, z.core.$strict>>;
492
+ }, z.core.$strict>>;
427
493
  permission_mode: z.ZodOptional<z.ZodEnum<{
428
494
  default: "default";
429
495
  strict: "strict";
430
496
  full: "full";
431
497
  }>>;
498
+ allowed_tools: z.ZodOptional<z.ZodArray<z.ZodString>>;
499
+ denied_tools: z.ZodOptional<z.ZodArray<z.ZodString>>;
500
+ workspace_tools: z.ZodOptional<z.ZodBoolean>;
501
+ process_manager: z.ZodOptional<z.ZodBoolean>;
502
+ builtin_agent_tools: z.ZodOptional<z.ZodBoolean>;
503
+ }, z.core.$strict>>;
504
+ reasoning: z.ZodOptional<z.ZodObject<{
505
+ main_effort: z.ZodOptional<z.ZodEnum<{
506
+ low: "low";
507
+ off: "off";
508
+ none: "none";
509
+ minimal: "minimal";
510
+ medium: "medium";
511
+ high: "high";
512
+ xhigh: "xhigh";
513
+ max: "max";
514
+ }>>;
515
+ worker_effort: z.ZodOptional<z.ZodEnum<{
516
+ low: "low";
517
+ off: "off";
518
+ none: "none";
519
+ minimal: "minimal";
520
+ medium: "medium";
521
+ high: "high";
522
+ xhigh: "xhigh";
523
+ max: "max";
524
+ }>>;
432
525
  }, z.core.$strict>>;
433
526
  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<{
434
527
  allowed_tools: z.ZodOptional<z.ZodType<string[], unknown, z.core.$ZodTypeInternals<string[], unknown>>>;
@@ -649,10 +742,21 @@ export declare const modeDefinitionsSchema: z.ZodRecord<z.ZodString, z.ZodObject
649
742
  }, z.core.$strict>>;
650
743
  team: z.ZodOptional<z.ZodObject<{
651
744
  max_depth: z.ZodOptional<z.ZodNumber>;
745
+ default_concurrency: z.ZodOptional<z.ZodNumber>;
746
+ default_preset: z.ZodOptional<z.ZodString>;
747
+ max_concurrency: z.ZodOptional<z.ZodNumber>;
748
+ max_active_depth1: z.ZodOptional<z.ZodNumber>;
749
+ worker_soft_checkpoint_ms: z.ZodOptional<z.ZodNumber>;
652
750
  async_coordinator: z.ZodOptional<z.ZodBoolean>;
653
751
  coordinator_poll_interval_ms: z.ZodOptional<z.ZodNumber>;
654
752
  }, z.core.$strict>>;
655
753
  limits: z.ZodOptional<z.ZodObject<{
754
+ model_timeout_ms: z.ZodOptional<z.ZodNumber>;
755
+ stream_idle_timeout_ms: z.ZodOptional<z.ZodNumber>;
756
+ request_total_timeout_ms: z.ZodOptional<z.ZodNumber>;
757
+ tool_timeout_ms: z.ZodOptional<z.ZodNumber>;
758
+ shell_timeout_ms: z.ZodOptional<z.ZodNumber>;
759
+ max_parallel_tools: z.ZodOptional<z.ZodNumber>;
656
760
  max_model_attempts: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodNumber, z.ZodLiteral<"unlimited">, z.ZodNull]>, z.ZodTransform<number, number | "unlimited" | null>>>;
657
761
  max_tool_calls: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodNumber, z.ZodLiteral<"unlimited">, z.ZodNull]>, z.ZodTransform<number, number | "unlimited" | null>>>;
658
762
  max_steps: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodNumber, z.ZodLiteral<"unlimited">, z.ZodNull]>, z.ZodTransform<number, number | "unlimited" | null>>>;
@@ -661,6 +765,24 @@ export declare const modeDefinitionsSchema: z.ZodRecord<z.ZodString, z.ZodObject
661
765
  wall_time_ms: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodNumber, z.ZodLiteral<"unlimited">, z.ZodNull]>, z.ZodTransform<number, number | "unlimited" | null>>>;
662
766
  subagent_wall_time_ms: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodNumber, z.ZodLiteral<"unlimited">, z.ZodNull]>, z.ZodTransform<number, number | "unlimited" | null>>>;
663
767
  }, z.core.$strict>>;
768
+ retry: z.ZodOptional<z.ZodObject<{
769
+ model_max_attempts_per_call: z.ZodOptional<z.ZodNumber>;
770
+ tool_max_attempts_per_call: z.ZodOptional<z.ZodNumber>;
771
+ base_delay_ms: z.ZodOptional<z.ZodNumber>;
772
+ max_delay_ms: z.ZodOptional<z.ZodNumber>;
773
+ }, z.core.$strict>>;
774
+ compaction: z.ZodOptional<z.ZodObject<{
775
+ enabled: z.ZodOptional<z.ZodBoolean>;
776
+ threshold_ratio: z.ZodOptional<z.ZodNumber>;
777
+ max_headroom_tokens: z.ZodOptional<z.ZodNumber>;
778
+ headroom_ratio: z.ZodOptional<z.ZodNumber>;
779
+ min_recent_steps: z.ZodOptional<z.ZodNumber>;
780
+ tail_window_ratio: z.ZodOptional<z.ZodNumber>;
781
+ preflight_window_ratio: z.ZodOptional<z.ZodNumber>;
782
+ max_halvings: z.ZodOptional<z.ZodNumber>;
783
+ min_prefix_chars: z.ZodOptional<z.ZodNumber>;
784
+ summary_timeout_ms: z.ZodOptional<z.ZodNumber>;
785
+ }, z.core.$strict>>;
664
786
  max_active_challenges: z.ZodOptional<z.ZodNumber>;
665
787
  max_helpers_per_challenge: z.ZodOptional<z.ZodNumber>;
666
788
  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>>>;
@@ -6,6 +6,7 @@ import { readFileWindow, relativePathWithin } from '@saturn-universe/tools';
6
6
  import { configurationTable, pluginConfigSchema, pluginEntrySchema, pluginIdSchema, } from './plugin-configuration.js';
7
7
  import { configuredPluginGrantFields, validConfiguredPluginGrant } from './plugin-tool-grants.js';
8
8
  import { configuredRunBudgetShape, unlimitedInt } from './run-budget.js';
9
+ import { modeCompactionSchema, modeRetrySchema } from './runtime-tuning.js';
9
10
  const maxFileBytes = 64 * 1024;
10
11
  const maxSnapshotBytes = 256 * 1024;
11
12
  const ref = z.string().regex(contextExtensionRefPattern);
@@ -42,12 +43,20 @@ const modePromptsSchema = z.strictObject({
42
43
  })
43
44
  .optional(),
44
45
  });
46
+ const modeToolFilterShape = {
47
+ allowed_tools: toolNames.optional(),
48
+ denied_tools: toolNames.optional(),
49
+ };
50
+ const modeRoleToolFilter = z.strictObject(modeToolFilterShape);
51
+ const modeReasoningEffort = z.enum(['off', 'none', 'minimal', 'low', 'medium', 'high', 'xhigh', 'max']);
45
52
  const modeToolsSchema = z.strictObject({
46
53
  workspace_tools: z.boolean().optional(),
47
54
  process_manager: z.boolean().optional(),
48
55
  builtin_agent_tools: z.boolean().optional(),
49
- allowed_tools: toolNames.optional(),
50
- denied_tools: toolNames.optional(),
56
+ ...modeToolFilterShape,
57
+ roles: z
58
+ .strictObject({ main: modeRoleToolFilter.optional(), worker: modeRoleToolFilter.optional() })
59
+ .optional(),
51
60
  permission_mode: z.enum(['strict', 'default', 'full']).optional(),
52
61
  });
53
62
  const modePluginEntrySchema = z
@@ -132,6 +141,11 @@ export const modeSandboxSchema = z.strictObject({
132
141
  });
133
142
  const modeTeamSchema = z.strictObject({
134
143
  max_depth: z.number().int().min(1).max(2).optional(),
144
+ default_concurrency: z.number().int().positive().optional(),
145
+ default_preset: identifier.optional(),
146
+ max_concurrency: z.number().int().positive().optional(),
147
+ max_active_depth1: z.number().int().positive().optional(),
148
+ worker_soft_checkpoint_ms: z.number().int().nonnegative().optional(),
135
149
  async_coordinator: z.boolean().optional(),
136
150
  coordinator_poll_interval_ms: z.number().int().min(0).optional(),
137
151
  });
@@ -145,10 +159,18 @@ export const modeDefinitionSchema = z
145
159
  denied_tools: toolNames.optional(),
146
160
  prompts: modePromptsSchema.optional(),
147
161
  tools: modeToolsSchema.optional(),
162
+ reasoning: z
163
+ .strictObject({
164
+ main_effort: modeReasoningEffort.optional(),
165
+ worker_effort: modeReasoningEffort.optional(),
166
+ })
167
+ .optional(),
148
168
  plugins: modePluginsSchema.optional(),
149
169
  sandbox: modeSandboxSchema.optional(),
150
170
  team: modeTeamSchema.optional(),
151
171
  limits: modeLimitsSchema.optional(),
172
+ retry: modeRetrySchema.optional(),
173
+ compaction: modeCompactionSchema.optional(),
152
174
  max_active_challenges: z.number().int().min(1).optional(),
153
175
  max_helpers_per_challenge: z.number().int().min(0).optional(),
154
176
  per_challenge_wall_time_ms: unlimitedInt().optional(),
@@ -171,8 +193,11 @@ export async function freezeContextExtensions(root, mode, availableSkills, skill
171
193
  if (skillRefs.length > 16)
172
194
  throw invalid();
173
195
  const modeInstructions = mode.prompts?.instructions ?? '';
174
- const { allowedTools, deniedTools } = mode.tools ?? {};
175
- const hasFrozenMode = Boolean(modeInstructions.trim()) || allowedTools !== undefined || deniedTools !== undefined;
196
+ const { allowedTools, deniedTools, roles } = mode.tools ?? {};
197
+ const hasFrozenMode = Boolean(modeInstructions.trim()) ||
198
+ allowedTools !== undefined ||
199
+ deniedTools !== undefined ||
200
+ roles !== undefined;
176
201
  if (!hasFrozenMode && !skillRefs.length)
177
202
  return {};
178
203
  if (new Set(skillRefs.map((value) => value.split('@')[0])).size !== skillRefs.length)
@@ -210,6 +235,7 @@ export async function freezeContextExtensions(root, mode, availableSkills, skill
210
235
  instructions: modeInstructions,
211
236
  ...(allowedTools !== undefined ? { allowedTools: [...allowedTools] } : {}),
212
237
  ...(deniedTools !== undefined ? { deniedTools: [...deniedTools] } : {}),
238
+ ...(roles !== undefined ? { toolRoles: structuredClone(roles) } : {}),
213
239
  },
214
240
  }
215
241
  : {}),
@@ -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
- name: p.name,
195
- providerId: p.providerId,
196
- revision: p.revision,
197
- codecVersion: p.codecVersion,
198
- ...(p.protocol ? { protocol: p.protocol } : {}),
199
- ...defaultModelDisplay(profileModel(p), p.defaultReasoningEffort),
200
- capabilityDigest: providers.resolve(profileModel(p)).binding.capabilityDigest,
201
- ...profilePricing(p),
202
- ready: Boolean(credential(p.credentialRef)?.trim()),
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
  };
@@ -25,6 +25,7 @@ export declare class PluginLifecycle {
25
25
  kind: "saturn-registrar" | "cordis";
26
26
  status: "active" | "draining";
27
27
  }[];
28
+ activePlugins(): LoadedHostPlugin[];
28
29
  withAdmission<T>(work: () => Promise<T>): Promise<T>;
29
30
  trackRun(runId: RunId): () => void;
30
31
  replace(load: (active: ReadonlyMap<string, LoadedHostPlugin>) => Promise<readonly LoadedHostPlugin[]>, pluginId?: string): Promise<{
@@ -51,6 +51,9 @@ export class PluginLifecycle {
51
51
  ...[...this.draining].map((generation) => summary(generation, 'draining')),
52
52
  ].sort((a, b) => a.id.localeCompare(b.id));
53
53
  }
54
+ activePlugins() {
55
+ return [...this.active.values()].map(({ plugin }) => plugin);
56
+ }
54
57
  withAdmission(work) {
55
58
  return this.enqueue(work);
56
59
  }
@@ -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
- if (!configPath)
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
- if (!configPath)
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 resolveEntry(id, directory, entry) {
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 target = await realpath(path.resolve(directory, entry));
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
  }
@@ -10,6 +10,7 @@ declare module '@deepseek-ai/cordis' {
10
10
  export interface SandboxPluginOptions {
11
11
  readonly allowUnsafeFallback?: boolean;
12
12
  readonly runner?: ContainerRunner;
13
+ readonly cleanupOrphans?: (cleanup: () => Promise<void>) => Promise<void>;
13
14
  }
14
15
  export declare function createSandboxPlugin(root: string, activeMode: ModeDefinition, options?: SandboxPluginOptions): {
15
16
  name: string;
@@ -10,6 +10,7 @@ export function createSandboxPlugin(root, activeMode, options = {}) {
10
10
  logger: ctx.saturnPluginHost.logger,
11
11
  ...(options.allowUnsafeFallback ? { allowUnsafeFallback: true } : {}),
12
12
  ...(options.runner ? { runner: options.runner } : {}),
13
+ ...(options.cleanupOrphans ? { cleanupOrphans: options.cleanupOrphans } : {}),
13
14
  });
14
15
  await manager.activate(startupSignal);
15
16
  ctx.effect(() => async () => {
@@ -1,10 +1,10 @@
1
1
  import type { Context } from '@deepseek-ai/cordis';
2
2
  import type { PromptSection, RunConfig, RunId, ToolBinding, ToolSpec } from '@saturn-universe/core';
3
- import { type TeamNotifyParentDelivery } from '@saturn-universe/tools';
3
+ import { type TeamMemberAction, type TeamNotifyParentDelivery } from '@saturn-universe/tools';
4
4
  import type { ToolConfiguration } from './tools-core-plugin.js';
5
5
  import { type SkillRegistryService } from '../../skills-runtime.js';
6
6
  export declare function teamHintSections(hint: RunConfig['teamHint'], tools: readonly ToolSpec[]): PromptSection[];
7
- export declare function createBuiltinAgentToolsPlugin(root: string, settings: ToolConfiguration['counter'], resultReader?: ToolBinding, previousDataReview?: (runId: RunId) => Promise<boolean>, suppressedGuidanceRoles?: ReadonlySet<'main' | 'worker'>, skillService?: SkillRegistryService, notifyParent?: (delivery: TeamNotifyParentDelivery) => Promise<void>): {
7
+ export declare function createBuiltinAgentToolsPlugin(root: string, settings: ToolConfiguration['counter'], resultReader?: ToolBinding, previousDataReview?: (runId: RunId) => Promise<boolean>, suppressedGuidanceRoles?: ReadonlySet<'main' | 'worker'>, skillService?: SkillRegistryService, notifyParent?: (delivery: TeamNotifyParentDelivery) => Promise<void>, steerMember?: TeamMemberAction, stopMember?: TeamMemberAction, resolveWorkerModeRef?: (selector: string) => string | undefined): {
8
8
  name: string;
9
9
  inject: string[];
10
10
  apply(ctx: Context, startupSignal: AbortSignal): Promise<void>;
@@ -1,6 +1,6 @@
1
1
  import path from 'node:path';
2
2
  import { buildTeamHintPrompt } from '@saturn-universe/context';
3
- import { createCounterTool, createDataReviewTool, createPlannerTool, createSpawnTeamTool, createTeamNotifyParentTool, createTodoWriteTool, dataReviewToolSet, teamNotifyParentToolName, } from '@saturn-universe/tools';
3
+ import { createCounterTool, createDataReviewTool, createPlannerTool, createSpawnTeamTool, createTeamNotifyParentTool, createTeamSteerMemberTool, createTeamStopMemberTool, createTodoWriteTool, dataReviewToolSet, teamNotifyParentToolName, } from '@saturn-universe/tools';
4
4
  import { sharedToolPriority } from './tools-core-plugin.js';
5
5
  import { registerToolGuidance } from './tool-guidance.js';
6
6
  import { createNativeSkillTool, skillToolName } from '../../skills-runtime.js';
@@ -19,7 +19,7 @@ export function teamHintSections(hint, tools) {
19
19
  },
20
20
  ];
21
21
  }
22
- export function createBuiltinAgentToolsPlugin(root, settings, resultReader, previousDataReview, suppressedGuidanceRoles, skillService, notifyParent) {
22
+ export function createBuiltinAgentToolsPlugin(root, settings, resultReader, previousDataReview, suppressedGuidanceRoles, skillService, notifyParent, steerMember, stopMember, resolveWorkerModeRef) {
23
23
  return {
24
24
  name: 'builtin-agent-tools',
25
25
  inject: ['saturnTools'],
@@ -52,7 +52,7 @@ export function createBuiltinAgentToolsPlugin(root, settings, resultReader, prev
52
52
  if (depth === 0 && env.config.teamMaxActiveDepth1 !== undefined) {
53
53
  const team = await store.stateReader.team?.(toolCtx.runId);
54
54
  activeDepth1Count = (team?.members ?? []).filter((member) => member.parent === 'main' &&
55
- !['completed', 'failed', 'interrupted'].includes(member.status)).length;
55
+ !['completed', 'failed', 'interrupted', 'stopped'].includes(member.status)).length;
56
56
  }
57
57
  return {
58
58
  memberId,
@@ -90,6 +90,20 @@ export function createBuiltinAgentToolsPlugin(root, settings, resultReader, prev
90
90
  versions: sets.spawnTeamV2Versions,
91
91
  priority: 0,
92
92
  },
93
+ ...(resolveWorkerModeRef
94
+ ? [
95
+ {
96
+ binding: createSpawnTeamTool({
97
+ includeSandboxProfile: true,
98
+ includeWorkSubpath: true,
99
+ resolveModeRef: resolveWorkerModeRef,
100
+ ...(resolveCaller ? { resolveCaller } : {}),
101
+ }),
102
+ versions: [],
103
+ priority: 0,
104
+ },
105
+ ]
106
+ : []),
93
107
  {
94
108
  binding: createTodoWriteTool(),
95
109
  versions: [...sets.defaultVersions, dataReviewToolSet],
@@ -127,6 +141,16 @@ export function createBuiltinAgentToolsPlugin(root, settings, resultReader, prev
127
141
  scope: { kind: 'role', roles: ['worker'] },
128
142
  order: { tier: 'tail', priority: 5 },
129
143
  }));
144
+ const memberControls = [
145
+ ...(steerMember ? [createTeamSteerMemberTool(steerMember)] : []),
146
+ ...(stopMember ? [createTeamStopMemberTool(stopMember)] : []),
147
+ ];
148
+ for (const { definition, handler } of memberControls) {
149
+ ctx.effect(() => tools.registerTool(definition, handler, sets.defaultVersions, {
150
+ scope: { kind: 'role', roles: ['main'] },
151
+ order: { tier: 'tail', priority: 6 },
152
+ }));
153
+ }
130
154
  registerToolGuidance(ctx, 'agent-tool-guidance', -30, (visible, config) => {
131
155
  const lines = [];
132
156
  if (visible.has('read_tool_result'))
@@ -1,5 +1,5 @@
1
1
  import type { RunId, ToolBinding } from '@saturn-universe/core';
2
- import type { ProcessManagerOptions, TeamNotifyParentDelivery } from '@saturn-universe/tools';
2
+ import type { ProcessManager, ProcessManagerOptions, TeamMemberAction, TeamNotifyParentDelivery } from '@saturn-universe/tools';
3
3
  import type { SkillRegistryService } from '../../skills-runtime.js';
4
4
  import type { RequiredHostPlugin } from '../required-host-plugin.js';
5
5
  import type { ToolConfiguration } from './tools-core-plugin.js';
@@ -9,9 +9,13 @@ export interface HostToolOptions {
9
9
  hash: (value: unknown) => string;
10
10
  resultReader?: ToolBinding;
11
11
  processManager?: Omit<ProcessManagerOptions, 'directory'>;
12
+ sharedProcessManager?: ProcessManager;
12
13
  previousDataReview?: (runId: RunId) => Promise<boolean>;
13
14
  suppressedGuidanceRoles?: ReadonlySet<'main' | 'worker'>;
14
15
  skillService?: SkillRegistryService;
16
+ steerMember?: TeamMemberAction;
17
+ stopMember?: TeamMemberAction;
15
18
  notifyParent?: (delivery: TeamNotifyParentDelivery) => Promise<void>;
19
+ resolveWorkerModeRef?: (selector: string) => string | undefined;
16
20
  }
17
21
  export declare function createToolPlugins(root: string, options: HostToolOptions, startupDependencies?: string[], withContext?: boolean): RequiredHostPlugin[];
@@ -4,7 +4,7 @@ import { createProcessManagerPlugin } from './process-manager-plugin.js';
4
4
  import { createToolsCorePlugin } from './tools-core-plugin.js';
5
5
  import { createWorkspaceToolsPlugin } from './workspace-tools-plugin.js';
6
6
  export function createToolPlugins(root, options, startupDependencies = [], withContext = false) {
7
- const { config, trustedConfig, hash, resultReader, processManager, previousDataReview, suppressedGuidanceRoles, skillService, notifyParent, } = options;
7
+ const { config, trustedConfig, hash, resultReader, processManager, sharedProcessManager, previousDataReview, suppressedGuidanceRoles, skillService, notifyParent, steerMember, stopMember, resolveWorkerModeRef, } = options;
8
8
  const effectiveWorkspaceTools = Boolean(config.workspaceTools);
9
9
  const effectiveProcessManager = config.processManager ?? effectiveWorkspaceTools;
10
10
  const effectiveBuiltinAgentTools = config.builtinAgentTools !== false;
@@ -16,7 +16,7 @@ export function createToolPlugins(root, options, startupDependencies = [], withC
16
16
  ...(effectiveProcessManager
17
17
  ? [
18
18
  guidanceOwner({
19
- ...createProcessManagerPlugin(root, processManager ?? {}),
19
+ ...createProcessManagerPlugin(root, processManager ?? {}, sharedProcessManager),
20
20
  inject: [...startupDependencies, 'saturnTools'],
21
21
  }),
22
22
  ]
@@ -30,7 +30,7 @@ export function createToolPlugins(root, options, startupDependencies = [], withC
30
30
  : []),
31
31
  ...(effectiveBuiltinAgentTools
32
32
  ? [
33
- guidanceOwner(createBuiltinAgentToolsPlugin(root, config.counter, resultReader, previousDataReview, suppressedGuidanceRoles, skillService, notifyParent)),
33
+ guidanceOwner(createBuiltinAgentToolsPlugin(root, config.counter, resultReader, previousDataReview, suppressedGuidanceRoles, skillService, notifyParent, steerMember, stopMember, resolveWorkerModeRef)),
34
34
  ]
35
35
  : []),
36
36
  ...(Object.keys(config.mcpServers ?? {}).length
@@ -5,7 +5,7 @@ declare module '@deepseek-ai/cordis' {
5
5
  saturnProcessManager?: ProcessManager;
6
6
  }
7
7
  }
8
- export declare function createProcessManagerPlugin(root: string, options: Omit<ProcessManagerOptions, 'directory'>): {
8
+ export declare function createProcessManagerPlugin(root: string, options: Omit<ProcessManagerOptions, 'directory'>, shared?: ProcessManager): {
9
9
  name: string;
10
10
  apply(ctx: Context): void;
11
11
  };