@saturn-universe/protocol 0.0.0-stage → 0.1.0

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.
@@ -0,0 +1,102 @@
1
+ import { contextExtensionRefPattern, isEventPosition, normalizeProviderProtocol, providerProtocolInputs, } from '@saturn-universe/core';
2
+ import { z } from 'zod';
3
+ import { modelDisplaySchema, modelPricingSchema } from './wire-shapes.js';
4
+ const strings = z.array(z.string());
5
+ const modelDisplay = {
6
+ ...modelDisplaySchema.partial({ modelId: true }).shape,
7
+ reasoningModel: z.boolean().optional(),
8
+ reasoningEfforts: strings.optional(),
9
+ contextWindow: z.number().optional(),
10
+ };
11
+ const modeSummary = z.object({
12
+ ref: z.string().regex(contextExtensionRefPattern),
13
+ displayName: z.string(),
14
+ description: z.string(),
15
+ });
16
+ const hostStatus = z.object({
17
+ epoch: z.number().int().positive(),
18
+ cursor: z.custom(isEventPosition),
19
+ configSource: z.string().optional(),
20
+ workspaceTools: z.boolean().optional(),
21
+ defaultProfile: z.string().optional(),
22
+ selectedProfile: z.string().optional(),
23
+ taskProfiles: z.record(z.string(), z.string()).optional(),
24
+ ...modelDisplay,
25
+ profiles: z
26
+ .array(z.object({
27
+ name: z.string(),
28
+ providerId: z.string().optional(),
29
+ protocol: z.enum(providerProtocolInputs).transform(normalizeProviderProtocol).optional(),
30
+ ...modelDisplay,
31
+ defaultReasoningEffort: z.string().nullable().optional(),
32
+ pricingSource: z.literal('builtin').optional(),
33
+ pricing: modelPricingSchema.optional(),
34
+ baseURL: z.string().optional(),
35
+ ready: z.boolean().optional(),
36
+ }))
37
+ .optional(),
38
+ activeMode: modeSummary,
39
+ availableModes: z.array(modeSummary),
40
+ sandbox: z
41
+ .object({
42
+ backend: z.enum(['host', 'docker', 'gvisor', 'sysbox']),
43
+ scope: z.enum(['none', 'per_run_and_worker']),
44
+ state: z.enum(['disabled', 'ready', 'fallback_host', 'unavailable']),
45
+ image: z.string().optional(),
46
+ activeContainers: z.number().int().nonnegative(),
47
+ fallbackActive: z.boolean(),
48
+ reason: z.string().optional(),
49
+ })
50
+ .optional(),
51
+ boardUrl: z.string().optional(),
52
+ modes: strings.optional(),
53
+ skills: strings.optional(),
54
+ discoveredSkills: z
55
+ .array(z.object({
56
+ name: z.string(),
57
+ description: z.string(),
58
+ scope: z.enum(['project', 'user', 'mode', 'config']),
59
+ source: z.string(),
60
+ resources: strings,
61
+ ref: z.string().optional(),
62
+ license: z.string().optional(),
63
+ compatibility: z.string().optional(),
64
+ allowedTools: z.string().optional(),
65
+ indexedBySecurityPlugin: z.boolean().optional(),
66
+ }))
67
+ .optional(),
68
+ mcpServers: z
69
+ .array(z.object({
70
+ id: z.string(),
71
+ scope: z.enum(['user', 'project', 'workspace', 'explicit']).optional(),
72
+ transport: z.enum(['stdio', 'http']).optional(),
73
+ discovery: z.enum(['ready', 'unavailable', 'auth_required', 'trust_required', 'pending_trust']),
74
+ toolCount: z.number().int().nonnegative(),
75
+ error: z.string().optional(),
76
+ }))
77
+ .optional(),
78
+ teamPresets: strings.optional(),
79
+ runDefaults: z
80
+ .object({
81
+ permissionMode: z.enum(['strict', 'default', 'full']).optional(),
82
+ reasoningEffort: z.string().optional(),
83
+ workerReasoningEffort: z.string().optional(),
84
+ modeRef: z.string().optional(),
85
+ })
86
+ .optional(),
87
+ });
88
+ export function parseHostStatusResult(value) {
89
+ const parsed = hostStatus.safeParse(value);
90
+ if (!parsed.success)
91
+ return undefined;
92
+ const { activeMode, availableModes } = parsed.data;
93
+ const catalog = new Map(availableModes.map((mode) => [mode.ref, mode]));
94
+ const available = catalog.get(activeMode.ref);
95
+ if (catalog.size !== availableModes.length ||
96
+ !available ||
97
+ available.displayName !== activeMode.displayName ||
98
+ available.description !== activeMode.description)
99
+ return undefined;
100
+ // Retain extension fields for callers that consume the full status object.
101
+ return value;
102
+ }