@saturn-universe/protocol 0.1.2-dev.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.
@@ -23,6 +23,7 @@ export interface HostCommandResults {
23
23
  readonly 'team.query': TeamQueryResult;
24
24
  readonly 'team.inbox': TeamInboxResult;
25
25
  readonly 'session.query': SessionSummary;
26
+ readonly 'session.mode.select': Readonly<z.output<typeof sessionModeSelection>>;
26
27
  readonly 'session.btw': Readonly<z.output<typeof sideQuestion>>;
27
28
  readonly 'session.usage': SessionUsageResult;
28
29
  readonly 'session.history': SessionHistoryPage;
@@ -56,6 +57,15 @@ declare const sessionCreation: z.ZodObject<{
56
57
  sessionId: z.ZodCustom<import("@saturn-universe/core").SessionId, import("@saturn-universe/core").SessionId>;
57
58
  cursor: z.ZodOptional<z.ZodPipe<z.ZodCustom<string, string>, z.ZodTransform<EventPosition, string>>>;
58
59
  }, z.core.$strip>;
60
+ declare const sessionModeSelection: z.ZodObject<{
61
+ sessionId: z.ZodCustom<import("@saturn-universe/core").SessionId, import("@saturn-universe/core").SessionId>;
62
+ mode: z.ZodObject<{
63
+ ref: z.ZodString;
64
+ displayName: z.ZodString;
65
+ description: z.ZodString;
66
+ }, z.core.$strip>;
67
+ cursor: z.ZodPipe<z.ZodCustom<string, string>, z.ZodTransform<EventPosition, string>>;
68
+ }, z.core.$strip>;
59
69
  declare const runSubmission: z.ZodObject<{
60
70
  runId: z.ZodCustom<RunId, RunId>;
61
71
  turnId: z.ZodCustom<TurnId, TurnId>;
@@ -1,7 +1,7 @@
1
1
  import { DEFAULT_SESSION_LIST_LIMIT } from '@saturn-universe/core';
2
2
  import { z } from 'zod';
3
3
  import { validContextQueryResult, validSurfaceQueryResult } from './diagnostic-results.js';
4
- import { parseHostStatusResult } from './host-status.js';
4
+ import { modeSummary, parseHostStatusResult } from './host-status.js';
5
5
  import { parseRunProgressResult, validRunTimelineResult } from './run-event-results.js';
6
6
  import { validRunQueryResult } from './run-query-result.js';
7
7
  import { parseSessionExportResult, parseSessionListResult, parseSessionSummaryResult, parseSessionUsageResult, validSessionHistoryResult, } from './session-results.js';
@@ -14,6 +14,7 @@ const workspaceList = z.array(z.object({ id: workspaceId }));
14
14
  const cursor = eventPosition.optional();
15
15
  const workspaceCreation = z.object({ workspaceId, cursor });
16
16
  const sessionCreation = z.object({ sessionId: z.custom(hasIdentifier), cursor });
17
+ const sessionModeSelection = sessionCreation.extend({ mode: modeSummary, cursor: eventPosition });
17
18
  const runId = z.custom(hasIdentifier);
18
19
  const runSubmission = z.object({ runId, turnId: z.custom(hasIdentifier), cursor });
19
20
  const runResume = z.object({ runId, cursor: eventPosition });
@@ -67,6 +68,10 @@ export function validHostCommandResult(command, result) {
67
68
  return validTeamInboxResult(command, result);
68
69
  case 'session.query':
69
70
  return parseSessionSummaryResult(result, command.sessionId) !== undefined;
71
+ case 'session.mode.select': {
72
+ const receipt = sessionModeSelection.safeParse(result);
73
+ return receipt.success && receipt.data.sessionId === command.sessionId;
74
+ }
70
75
  case 'session.btw':
71
76
  return sideQuestion.safeParse(result).success;
72
77
  case 'session.usage':
@@ -25,7 +25,7 @@ export interface HostMcpServerSummary {
25
25
  readonly toolCount: number;
26
26
  readonly error?: string;
27
27
  }
28
- interface HostStatusFields extends HostModelDisplay {
28
+ export interface HostStatusFields extends HostModelDisplay {
29
29
  readonly epoch: number;
30
30
  readonly cursor: string;
31
31
  readonly configSource?: string;
@@ -51,6 +51,11 @@ interface HostStatusFields extends HostModelDisplay {
51
51
  };
52
52
  }
53
53
  export type HostStatusSnapshot = HostStatusFields & Readonly<Record<string, unknown>>;
54
+ export declare const modeSummary: z.ZodObject<{
55
+ ref: z.ZodString;
56
+ displayName: z.ZodString;
57
+ description: z.ZodString;
58
+ }, z.core.$strip>;
54
59
  declare const hostStatus: z.ZodObject<{
55
60
  profiles: z.ZodOptional<z.ZodArray<z.ZodObject<{
56
61
  defaultReasoningEffort: z.ZodOptional<z.ZodNullable<z.ZodString>>;
@@ -8,7 +8,7 @@ const modelDisplay = {
8
8
  reasoningEfforts: strings.optional(),
9
9
  contextWindow: z.number().optional(),
10
10
  };
11
- const modeSummary = z.object({
11
+ export const modeSummary = z.object({
12
12
  ref: z.string().regex(contextExtensionRefPattern),
13
13
  displayName: z.string(),
14
14
  description: z.string(),
package/dist/index.d.ts CHANGED
@@ -9,7 +9,7 @@ export type { RunQueryResult } from './run-query-result.js';
9
9
  export { parseHostStatusResult } from './host-status.js';
10
10
  export { validHostCommandResult, type HostCommandResults } from './host-results.js';
11
11
  export type { TeamInboxResult, TeamQueryResult } from './team-results.js';
12
- export type { HostMcpServerSummary, HostProfileSummary, HostStatusSnapshot } from './host-status.js';
12
+ export type { HostMcpServerSummary, HostProfileSummary, HostStatusFields, HostStatusSnapshot, } from './host-status.js';
13
13
  export type { ModelDisplay } from './wire-shapes.js';
14
14
  export * from './endpoint.js';
15
15
  export type { AgentContextMetrics, BranchWorkspaceHandleLike, HostSandboxStatus, LiveAgentTelemetry, ModeSummary, PermissionMode, PlannerConfig, ProtocolReply, ProtocolRequest, RunCompletionContext, RunCompletionDecision, RunCompletionDecisionKind, RunContinuationConfig, RunProgressApproval, RunProgressLiveAgent, RunProgressPage, RunTimelinePage, RuntimeCommand, SandboxBackendKind, SandboxConfig, SandboxFallbackPolicy, SandboxNetworkMode, SandboxReadonlyMount, SandboxResourceLimits, SandboxRetentionMode, SandboxRetentionPolicy, SandboxScopeKind, SearchBranchState, SearchHypothesisSeed, SearchTreeState, SearchWorkspaceKind, SessionDetails, SessionExportPage, SessionExportRecord, SessionHistoryMessage, SessionHistoryPage, SessionListItem, SessionUsageBucket, SessionUsageCounts, TeamHintConfig, TeamPlanState, TeamState, TerminalRunStatus, TodoItem, TodoStatus, TreeSearchConfig, TreeSearchTrigger, WorkerSandboxProfile, WorkspaceSnapshotPort, } from '@saturn-universe/core';
@@ -89,6 +89,10 @@ declare const commandSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
89
89
  }, z.core.$strict>, z.ZodObject<{
90
90
  type: z.ZodLiteral<"session.query">;
91
91
  sessionId: z.ZodPipe<z.ZodString, z.ZodTransform<Id<"session">, string>>;
92
+ }, z.core.$strict>, z.ZodObject<{
93
+ type: z.ZodLiteral<"session.mode.select">;
94
+ sessionId: z.ZodPipe<z.ZodString, z.ZodTransform<Id<"session">, string>>;
95
+ modeRef: z.ZodString;
92
96
  }, z.core.$strict>, z.ZodObject<{
93
97
  type: z.ZodLiteral<"session.btw">;
94
98
  sessionId: z.ZodPipe<z.ZodString, z.ZodTransform<Id<"session">, string>>;
@@ -174,26 +178,38 @@ declare const commandSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
174
178
  workerReasoningEffort: z.ZodOptional<z.ZodOptional<z.ZodString>>;
175
179
  disabledSkills: z.ZodOptional<z.ZodOptional<z.ZodArray<z.ZodString>>>;
176
180
  limits: z.ZodOptional<z.ZodObject<{
177
- maxModelAttempts: z.ZodNumber;
178
- maxToolCalls: z.ZodNumber;
179
- maxSteps: z.ZodNumber;
180
- maxTotalTokens: z.ZodNumber;
181
- subagentMaxModelAttempts: z.ZodOptional<z.ZodNumber>;
182
- wallTimeMs: z.ZodOptional<z.ZodNumber>;
183
- subagentWallTimeMs: z.ZodOptional<z.ZodNumber>;
184
- modelTimeoutMs: z.ZodNumber;
185
- streamIdleTimeoutMs: z.ZodOptional<z.ZodNumber>;
186
- requestTotalTimeoutMs: z.ZodOptional<z.ZodNumber>;
187
- toolTimeoutMs: z.ZodNumber;
188
- shellTimeoutMs: z.ZodOptional<z.ZodNumber>;
189
- maxParallelTools: z.ZodNumber;
181
+ maxModelAttempts: z.ZodOptional<z.ZodNumber>;
182
+ maxToolCalls: z.ZodOptional<z.ZodNumber>;
183
+ maxSteps: z.ZodOptional<z.ZodNumber>;
184
+ maxTotalTokens: z.ZodOptional<z.ZodNumber>;
185
+ subagentMaxModelAttempts: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
186
+ wallTimeMs: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
187
+ subagentWallTimeMs: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
188
+ modelTimeoutMs: z.ZodOptional<z.ZodNumber>;
189
+ streamIdleTimeoutMs: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
190
+ requestTotalTimeoutMs: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
191
+ toolTimeoutMs: z.ZodOptional<z.ZodNumber>;
192
+ shellTimeoutMs: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
193
+ maxParallelTools: z.ZodOptional<z.ZodNumber>;
190
194
  }, z.core.$strict>>;
191
195
  retry: z.ZodOptional<z.ZodObject<{
192
- modelMaxAttemptsPerCall: z.ZodNumber;
193
- toolMaxAttemptsPerCall: z.ZodNumber;
194
- baseDelayMs: z.ZodNumber;
195
- maxDelayMs: z.ZodNumber;
196
+ modelMaxAttemptsPerCall: z.ZodOptional<z.ZodNumber>;
197
+ toolMaxAttemptsPerCall: z.ZodOptional<z.ZodNumber>;
198
+ baseDelayMs: z.ZodOptional<z.ZodNumber>;
199
+ maxDelayMs: z.ZodOptional<z.ZodNumber>;
196
200
  }, z.core.$strict>>;
201
+ compaction: z.ZodOptional<z.ZodOptional<z.ZodObject<{
202
+ enabled: z.ZodOptional<z.ZodBoolean>;
203
+ thresholdRatio: z.ZodOptional<z.ZodNumber>;
204
+ maxHeadroomTokens: z.ZodOptional<z.ZodNumber>;
205
+ headroomRatio: z.ZodOptional<z.ZodNumber>;
206
+ minRecentSteps: z.ZodOptional<z.ZodNumber>;
207
+ tailWindowRatio: z.ZodOptional<z.ZodNumber>;
208
+ preflightWindowRatio: z.ZodOptional<z.ZodNumber>;
209
+ maxHalvings: z.ZodOptional<z.ZodNumber>;
210
+ minPrefixChars: z.ZodOptional<z.ZodNumber>;
211
+ summaryTimeoutMs: z.ZodOptional<z.ZodNumber>;
212
+ }, z.core.$strict>>>;
197
213
  responses: z.ZodOptional<z.ZodObject<{
198
214
  storage: z.ZodLiteral<"local_stateless">;
199
215
  reasoning: z.ZodOptional<z.ZodObject<{
@@ -217,6 +233,7 @@ declare const commandSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
217
233
  build: "build";
218
234
  }>>;
219
235
  workSubpath: z.ZodOptional<z.ZodString>;
236
+ modeRef: z.ZodOptional<z.ZodString>;
220
237
  }, z.core.$strict>>;
221
238
  concurrency: z.ZodOptional<z.ZodNumber>;
222
239
  }, z.core.$strict>>>;
@@ -226,6 +243,7 @@ declare const commandSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
226
243
  coordinatorPollIntervalMs: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
227
244
  workerSoftCheckpointMs: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
228
245
  teamMaxActiveDepth1: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
246
+ teamDefaultConcurrency: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
229
247
  teamMaxConcurrency: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
230
248
  teamHint: z.ZodOptional<z.ZodOptional<z.ZodObject<{
231
249
  force: z.ZodOptional<z.ZodBoolean>;
@@ -469,6 +487,10 @@ declare const requestSchema: z.ZodObject<{
469
487
  }, z.core.$strict>, z.ZodObject<{
470
488
  type: z.ZodLiteral<"session.query">;
471
489
  sessionId: z.ZodPipe<z.ZodString, z.ZodTransform<Id<"session">, string>>;
490
+ }, z.core.$strict>, z.ZodObject<{
491
+ type: z.ZodLiteral<"session.mode.select">;
492
+ sessionId: z.ZodPipe<z.ZodString, z.ZodTransform<Id<"session">, string>>;
493
+ modeRef: z.ZodString;
472
494
  }, z.core.$strict>, z.ZodObject<{
473
495
  type: z.ZodLiteral<"session.btw">;
474
496
  sessionId: z.ZodPipe<z.ZodString, z.ZodTransform<Id<"session">, string>>;
@@ -554,26 +576,38 @@ declare const requestSchema: z.ZodObject<{
554
576
  workerReasoningEffort: z.ZodOptional<z.ZodOptional<z.ZodString>>;
555
577
  disabledSkills: z.ZodOptional<z.ZodOptional<z.ZodArray<z.ZodString>>>;
556
578
  limits: z.ZodOptional<z.ZodObject<{
557
- maxModelAttempts: z.ZodNumber;
558
- maxToolCalls: z.ZodNumber;
559
- maxSteps: z.ZodNumber;
560
- maxTotalTokens: z.ZodNumber;
561
- subagentMaxModelAttempts: z.ZodOptional<z.ZodNumber>;
562
- wallTimeMs: z.ZodOptional<z.ZodNumber>;
563
- subagentWallTimeMs: z.ZodOptional<z.ZodNumber>;
564
- modelTimeoutMs: z.ZodNumber;
565
- streamIdleTimeoutMs: z.ZodOptional<z.ZodNumber>;
566
- requestTotalTimeoutMs: z.ZodOptional<z.ZodNumber>;
567
- toolTimeoutMs: z.ZodNumber;
568
- shellTimeoutMs: z.ZodOptional<z.ZodNumber>;
569
- maxParallelTools: z.ZodNumber;
579
+ maxModelAttempts: z.ZodOptional<z.ZodNumber>;
580
+ maxToolCalls: z.ZodOptional<z.ZodNumber>;
581
+ maxSteps: z.ZodOptional<z.ZodNumber>;
582
+ maxTotalTokens: z.ZodOptional<z.ZodNumber>;
583
+ subagentMaxModelAttempts: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
584
+ wallTimeMs: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
585
+ subagentWallTimeMs: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
586
+ modelTimeoutMs: z.ZodOptional<z.ZodNumber>;
587
+ streamIdleTimeoutMs: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
588
+ requestTotalTimeoutMs: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
589
+ toolTimeoutMs: z.ZodOptional<z.ZodNumber>;
590
+ shellTimeoutMs: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
591
+ maxParallelTools: z.ZodOptional<z.ZodNumber>;
570
592
  }, z.core.$strict>>;
571
593
  retry: z.ZodOptional<z.ZodObject<{
572
- modelMaxAttemptsPerCall: z.ZodNumber;
573
- toolMaxAttemptsPerCall: z.ZodNumber;
574
- baseDelayMs: z.ZodNumber;
575
- maxDelayMs: z.ZodNumber;
594
+ modelMaxAttemptsPerCall: z.ZodOptional<z.ZodNumber>;
595
+ toolMaxAttemptsPerCall: z.ZodOptional<z.ZodNumber>;
596
+ baseDelayMs: z.ZodOptional<z.ZodNumber>;
597
+ maxDelayMs: z.ZodOptional<z.ZodNumber>;
576
598
  }, z.core.$strict>>;
599
+ compaction: z.ZodOptional<z.ZodOptional<z.ZodObject<{
600
+ enabled: z.ZodOptional<z.ZodBoolean>;
601
+ thresholdRatio: z.ZodOptional<z.ZodNumber>;
602
+ maxHeadroomTokens: z.ZodOptional<z.ZodNumber>;
603
+ headroomRatio: z.ZodOptional<z.ZodNumber>;
604
+ minRecentSteps: z.ZodOptional<z.ZodNumber>;
605
+ tailWindowRatio: z.ZodOptional<z.ZodNumber>;
606
+ preflightWindowRatio: z.ZodOptional<z.ZodNumber>;
607
+ maxHalvings: z.ZodOptional<z.ZodNumber>;
608
+ minPrefixChars: z.ZodOptional<z.ZodNumber>;
609
+ summaryTimeoutMs: z.ZodOptional<z.ZodNumber>;
610
+ }, z.core.$strict>>>;
577
611
  responses: z.ZodOptional<z.ZodObject<{
578
612
  storage: z.ZodLiteral<"local_stateless">;
579
613
  reasoning: z.ZodOptional<z.ZodObject<{
@@ -597,6 +631,7 @@ declare const requestSchema: z.ZodObject<{
597
631
  build: "build";
598
632
  }>>;
599
633
  workSubpath: z.ZodOptional<z.ZodString>;
634
+ modeRef: z.ZodOptional<z.ZodString>;
600
635
  }, z.core.$strict>>;
601
636
  concurrency: z.ZodOptional<z.ZodNumber>;
602
637
  }, z.core.$strict>>>;
@@ -606,6 +641,7 @@ declare const requestSchema: z.ZodObject<{
606
641
  coordinatorPollIntervalMs: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
607
642
  workerSoftCheckpointMs: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
608
643
  teamMaxActiveDepth1: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
644
+ teamDefaultConcurrency: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
609
645
  teamMaxConcurrency: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
610
646
  teamHint: z.ZodOptional<z.ZodOptional<z.ZodObject<{
611
647
  force: z.ZodOptional<z.ZodBoolean>;
package/dist/index.js CHANGED
@@ -36,6 +36,7 @@ const team = z.strictObject({
36
36
  task: z.string(),
37
37
  sandboxProfile: z.enum(['default', 'readonly', 'build']).optional(),
38
38
  workSubpath: z.string().optional(),
39
+ modeRef: id.optional(),
39
40
  })),
40
41
  concurrency: positive.optional(),
41
42
  });
@@ -67,6 +68,20 @@ const continuation = z.strictObject({
67
68
  enabled: z.boolean().optional(),
68
69
  maxTurns: z.number().int().nonnegative().safe().optional(),
69
70
  });
71
+ const ratio = z.number().gt(0).lte(1);
72
+ const emptyRatio = z.number().gte(0).lte(1);
73
+ const compaction = z.strictObject({
74
+ enabled: z.boolean().optional(),
75
+ thresholdRatio: ratio.optional(),
76
+ maxHeadroomTokens: nonnegative.optional(),
77
+ headroomRatio: emptyRatio.optional(),
78
+ minRecentSteps: nonnegative.optional(),
79
+ tailWindowRatio: emptyRatio.optional(),
80
+ preflightWindowRatio: ratio.optional(),
81
+ maxHalvings: nonnegative.optional(),
82
+ minPrefixChars: nonnegative.optional(),
83
+ summaryTimeoutMs: positive.optional(),
84
+ });
70
85
  const config = z.strictObject({
71
86
  modeRef: id,
72
87
  model: model.optional(),
@@ -75,7 +90,8 @@ const config = z.strictObject({
75
90
  streamText: z.boolean().optional(),
76
91
  workerReasoningEffort: id.optional(),
77
92
  disabledSkills: z.array(z.string().trim().min(1).max(128)).max(64).optional(),
78
- limits: z.strictObject({
93
+ limits: z
94
+ .strictObject({
79
95
  maxModelAttempts: nonnegative,
80
96
  maxToolCalls: nonnegative,
81
97
  maxSteps: nonnegative,
@@ -89,13 +105,18 @@ const config = z.strictObject({
89
105
  toolTimeoutMs: positive,
90
106
  shellTimeoutMs: positive.optional(),
91
107
  maxParallelTools: positive,
92
- }),
93
- retry: z.strictObject({
108
+ })
109
+ .partial(),
110
+ retry: z
111
+ .strictObject({
94
112
  modelMaxAttemptsPerCall: positive,
95
113
  toolMaxAttemptsPerCall: positive,
96
114
  baseDelayMs: positive,
97
115
  maxDelayMs: positive,
98
- }),
116
+ })
117
+ .partial()
118
+ .refine(({ baseDelayMs, maxDelayMs }) => baseDelayMs === undefined || maxDelayMs === undefined || baseDelayMs <= maxDelayMs),
119
+ compaction: compaction.optional(),
99
120
  responses,
100
121
  team: team.optional(),
101
122
  teamMaxDepth: positive.optional(),
@@ -104,6 +125,7 @@ const config = z.strictObject({
104
125
  coordinatorPollIntervalMs: nonnegative.optional(),
105
126
  workerSoftCheckpointMs: nonnegative.optional(),
106
127
  teamMaxActiveDepth1: positive.optional(),
128
+ teamDefaultConcurrency: positive.optional(),
107
129
  teamMaxConcurrency: positive.optional(),
108
130
  teamHint: teamHint.optional(),
109
131
  planner: planner.optional(),
@@ -181,6 +203,11 @@ const commandSchema = z.discriminatedUnion('type', [
181
203
  }),
182
204
  z.strictObject({ type: z.literal('workspace.query') }),
183
205
  z.strictObject({ type: z.literal('session.query'), sessionId: brandedId() }),
206
+ z.strictObject({
207
+ type: z.literal('session.mode.select'),
208
+ sessionId: brandedId(),
209
+ modeRef: z.string().trim().min(1).max(129),
210
+ }),
184
211
  z.strictObject({
185
212
  type: z.literal('session.btw'),
186
213
  sessionId: brandedId(),
@@ -8,7 +8,7 @@ export type SessionSummary = {
8
8
  readonly ordinal: number;
9
9
  readonly status: string;
10
10
  };
11
- } & Partial<Pick<SessionDetails, 'member' | 'runCount' | 'turnCount' | 'stepCount' | 'cursor' | 'latestRun' | 'todos'>>;
11
+ } & Partial<Pick<SessionDetails, 'member' | 'runCount' | 'turnCount' | 'stepCount' | 'cursor' | 'latestRun' | 'todos' | 'modeRef'>>;
12
12
  export interface SessionUsageReport extends SessionUsageSummary {
13
13
  readonly modelId?: string;
14
14
  readonly contextWindow?: number;
@@ -73,6 +73,7 @@ export declare function parseSessionUsageResult(value: unknown): SessionUsageRes
73
73
  declare const sessionSummary: z.ZodObject<{
74
74
  id: z.ZodString;
75
75
  workspaceId: z.ZodOptional<z.ZodString>;
76
+ modeRef: z.ZodOptional<z.ZodString>;
76
77
  member: z.ZodOptional<z.ZodObject<{
77
78
  id: z.ZodString;
78
79
  agentSessionId: z.ZodString;
@@ -33,6 +33,7 @@ export function parseSessionUsageResult(value) {
33
33
  const sessionSummary = z.object({
34
34
  id,
35
35
  workspaceId: id.optional(),
36
+ modeRef: id.optional(),
36
37
  member: z.object({ id, agentSessionId: id, parentSessionId: id }).optional(),
37
38
  runCount: count.optional(),
38
39
  turnCount: count.optional(),
package/dist/skills.d.ts CHANGED
@@ -18,6 +18,7 @@ export interface DiscoveredSkill extends DiscoveredSkillSummary {
18
18
  export interface ModeSkillDirectory {
19
19
  readonly dir: string;
20
20
  readonly source: string;
21
+ readonly packageRoot?: string;
21
22
  readonly indexedBySecurityPlugin?: boolean;
22
23
  readonly allowedSkills?: readonly string[];
23
24
  }
@@ -38,6 +39,7 @@ export declare function localSkillSearchDirectories(workspaceRoot: string, env?:
38
39
  readonly scope: 'project' | 'user';
39
40
  })[];
40
41
  export declare function isInsideSkillDir(rootDir: string, targetPath: string): boolean;
42
+ export declare function userModeDirectories(env?: NodeJS.ProcessEnv): Promise<string[]>;
41
43
  export declare function validateRelativeSkillResourcePath(rawPath: unknown): {
42
44
  readonly ok: true;
43
45
  readonly normalized: string;
@@ -59,6 +61,7 @@ export declare function inspectSkillDirectory(skillDir: string): Promise<{
59
61
  export declare function discoverAgentSkills(workspaceRoot: string, options?: {
60
62
  readonly env?: NodeJS.ProcessEnv;
61
63
  readonly modeSkillDirs?: readonly ModeSkillDirectory[];
64
+ readonly scopeModePackages?: boolean;
62
65
  readonly explicitSkills?: Readonly<Record<string, ExplicitSkillEntry>>;
63
66
  }): Promise<DiscoveredSkill[]>;
64
67
  export declare function formatCompactSkillIndex(skills: readonly DiscoveredSkillSummary[], options?: {
package/dist/skills.js CHANGED
@@ -1,4 +1,4 @@
1
- import { readdir, readFile, realpath, stat } from 'node:fs/promises';
1
+ import { lstat, readdir, readFile, realpath, stat } from 'node:fs/promises';
2
2
  import os from 'node:os';
3
3
  import path from 'node:path';
4
4
  import { saturnHomeDir } from './provider-credentials.js';
@@ -37,6 +37,25 @@ export function isInsideSkillDir(rootDir, targetPath) {
37
37
  return false;
38
38
  return rel !== '..' && !rel.startsWith(`..${path.sep}`) && !rel.startsWith('../');
39
39
  }
40
+ export async function userModeDirectories(env = process.env) {
41
+ try {
42
+ const home = await realpath(saturnHomeDir(env));
43
+ const modes = path.join(home, 'modes');
44
+ if (path.relative(modes, await realpath(modes)) !== '')
45
+ return [];
46
+ const entries = await readdir(modes, { withFileTypes: true });
47
+ return entries
48
+ .filter((entry) => entry.isDirectory())
49
+ .map((entry) => entry.name)
50
+ .sort()
51
+ .map((name) => path.join(modes, name));
52
+ }
53
+ catch (error) {
54
+ if (['ENOENT', 'ENOTDIR'].includes(error.code ?? ''))
55
+ return [];
56
+ throw error;
57
+ }
58
+ }
40
59
  export function validateRelativeSkillResourcePath(rawPath) {
41
60
  if (typeof rawPath !== 'string' || !rawPath.trim()) {
42
61
  return { ok: false, code: 'INVALID_PATH', message: 'Resource path must be a non-empty relative path.' };
@@ -330,7 +349,7 @@ export async function discoverAgentSkills(workspaceRoot, options = {}) {
330
349
  const env = options.env ?? process.env;
331
350
  const byName = new Map();
332
351
  const scannedDirs = new Map();
333
- const registerFromDir = async (dir, scope, source, indexedBySecurityPlugin, allowedSkills) => {
352
+ const registerFromDir = async (dir, scope, source, indexedBySecurityPlugin, allowedSkills, packageRoot) => {
334
353
  let resolvedDir;
335
354
  try {
336
355
  resolvedDir = await realpath(dir);
@@ -338,6 +357,8 @@ export async function discoverAgentSkills(workspaceRoot, options = {}) {
338
357
  catch {
339
358
  return;
340
359
  }
360
+ if (packageRoot && !isInsideSkillDir(packageRoot, resolvedDir))
361
+ return;
341
362
  const dirKey = process.platform === 'win32' ? resolvedDir.toLowerCase() : resolvedDir;
342
363
  const previous = scannedDirs.get(dirKey);
343
364
  if (previous && !indexedBySecurityPlugin)
@@ -347,6 +368,8 @@ export async function discoverAgentSkills(workspaceRoot, options = {}) {
347
368
  scannedDirs.set(dirKey, candidates);
348
369
  const allowSet = allowedSkills ? new Set(allowedSkills) : undefined;
349
370
  for (const skill of candidates) {
371
+ if (packageRoot && !isInsideSkillDir(resolvedDir, skill.rootDir))
372
+ continue;
350
373
  if (allowSet && !allowSet.has(skill.name) && !allowSet.has(path.basename(skill.rootDir))) {
351
374
  continue;
352
375
  }
@@ -370,8 +393,16 @@ export async function discoverAgentSkills(workspaceRoot, options = {}) {
370
393
  for (const { dir, scope, source } of localSkillSearchDirectories(workspaceRoot, env)) {
371
394
  await registerFromDir(dir, scope, source);
372
395
  }
396
+ for (const dir of await userModeDirectories(env)) {
397
+ if (options.scopeModePackages) {
398
+ const unbundled = await lstat(path.join(dir, 'mode.toml')).then(() => false, (error) => error.code === 'ENOENT');
399
+ if (!unbundled)
400
+ continue;
401
+ }
402
+ await registerFromDir(path.join(dir, 'skills'), 'user', `user:.saturn/modes/${path.basename(dir)}/skills`, undefined, undefined, dir);
403
+ }
373
404
  for (const modeDir of options.modeSkillDirs ?? []) {
374
- await registerFromDir(modeDir.dir, 'mode', modeDir.source, modeDir.indexedBySecurityPlugin, modeDir.allowedSkills);
405
+ await registerFromDir(modeDir.dir, 'mode', modeDir.source, modeDir.indexedBySecurityPlugin, modeDir.allowedSkills, modeDir.packageRoot);
375
406
  }
376
407
  for (const [ref, entry] of Object.entries(options.explicitSkills ?? {}).sort(([a], [b]) => a.localeCompare(b))) {
377
408
  const skillName = ref.split('@')[0];
@@ -27,12 +27,17 @@ declare const teamQuery: z.ZodObject<{
27
27
  status: z.ZodEnum<{
28
28
  completed: "completed";
29
29
  waiting: "waiting";
30
+ stopped: "stopped";
30
31
  queued: "queued";
31
32
  running: "running";
32
33
  paused: "paused";
33
34
  failed: "failed";
34
35
  interrupted: "interrupted";
35
36
  }>;
37
+ stopRequest: z.ZodOptional<z.ZodObject<{
38
+ requestedBy: z.ZodLiteral<"main">;
39
+ reason: z.ZodString;
40
+ }, z.core.$strip>>;
36
41
  }, z.core.$strip>>;
37
42
  tasks: z.ZodArray<z.ZodObject<{
38
43
  memberId: z.ZodString;
@@ -41,6 +46,7 @@ declare const teamQuery: z.ZodObject<{
41
46
  status: z.ZodEnum<{
42
47
  completed: "completed";
43
48
  waiting: "waiting";
49
+ stopped: "stopped";
44
50
  queued: "queued";
45
51
  running: "running";
46
52
  paused: "paused";
@@ -3,13 +3,14 @@ import { z } from 'zod';
3
3
  const id = z.string().min(1);
4
4
  const brandedId = () => id.transform((value) => value);
5
5
  const runId = brandedId();
6
- const workStatus = z.enum(['waiting', ...turnStatuses]);
6
+ const workStatus = z.enum(['waiting', 'stopped', ...turnStatuses]);
7
7
  const member = z.object({
8
8
  id,
9
9
  parent: id.nullable(),
10
10
  agentSessionId: brandedId(),
11
11
  turnId: brandedId().optional(),
12
12
  status: workStatus,
13
+ stopRequest: z.object({ requestedBy: z.literal('main'), reason: z.string() }).optional(),
13
14
  });
14
15
  const task = z.object({
15
16
  memberId: id,
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@saturn-universe/protocol",
3
- "version": "0.1.2-dev.1",
3
+ "version": "0.1.2-dev.10",
4
4
  "license": "AGPL-3.0-only",
5
5
  "type": "module",
6
6
  "files": [
7
7
  "dist"
8
8
  ],
9
9
  "dependencies": {
10
- "@saturn-universe/core": "0.1.2-dev.1",
10
+ "@saturn-universe/core": "0.1.2-dev.10",
11
11
  "smol-toml": "1.9.1",
12
12
  "zod": "4.6.0"
13
13
  },