Open History to see the last commit
1import * as Effect from "effect/Effect";
2import * as Schema from "effect/Schema";
3import { AcpRegistryUrlAuthAction } from "./acpRegistry.ts";
4import {
5 type EnvironmentMachineKind,
6 ExecutionEnvironmentDescriptor,
7 ServerSelfUpdateMethod,
8} from "./environment.ts";
9import { AuthClientPresentationMetadata, ServerAuthDescriptor } from "./auth.ts";
10import {
11 ForwardCompatibleArray,
12 IsoDateTime,
13 NonNegativeInt,
14 PositiveInt,
15 ProjectId,
16 ThreadId,
17 TrimmedNonEmptyString,
18} from "./baseSchemas.ts";
19import {
20 KeybindingCommand,
21 KeybindingValue,
22 KeybindingWhen,
23 ResolvedKeybindingsConfig,
24} from "./keybindings.ts";
25import { EditorId, FileManagerRevealKind, RemoteOpenTarget } from "./editor.ts";
26import { ManagedPolicySummary } from "./managedPolicy.ts";
27import { ModelCapabilities, ProviderOptionDescriptor } from "./model.ts";
28import { RuntimeMode } from "./providerPolicy.ts";
29import { ProviderDriverKind, ProviderInstanceId } from "./providerInstance.ts";
30import { ServerProviderUsageLimits, UsageLimitSourceSnapshots } from "./providerUsageLimits.ts";
31import { ServerSettings } from "./settings.ts";
32import { DesktopUpdateChannelSchema } from "./ipc.ts";
33
34const KeybindingsMalformedConfigIssue = Schema.Struct({
35 kind: Schema.Literal("keybindings.malformed-config"),
36 message: TrimmedNonEmptyString,
37});
38
39const KeybindingsInvalidEntryIssue = Schema.Struct({
40 kind: Schema.Literal("keybindings.invalid-entry"),
41 message: TrimmedNonEmptyString,
42 index: Schema.Number,
43});
44
45export const ServerConfigIssue = Schema.Union([
46 KeybindingsMalformedConfigIssue,
47 KeybindingsInvalidEntryIssue,
48]);
49export type ServerConfigIssue = typeof ServerConfigIssue.Type;
50
51const ServerConfigIssues = ForwardCompatibleArray(ServerConfigIssue);
52
53export const ServerProviderState = Schema.Literals(["ready", "warning", "error", "disabled"]);
54export type ServerProviderState = typeof ServerProviderState.Type;
55
56export const ServerProviderAuthStatus = Schema.Literals([
57 "authenticated",
58 "unauthenticated",
59 "unknown",
60]);
61export type ServerProviderAuthStatus = typeof ServerProviderAuthStatus.Type;
62
63export const ServerProviderAuth = Schema.Struct({
64 status: ServerProviderAuthStatus,
65 type: Schema.optional(TrimmedNonEmptyString),
66 label: Schema.optional(TrimmedNonEmptyString),
67 email: Schema.optional(TrimmedNonEmptyString),
68 action: Schema.optional(AcpRegistryUrlAuthAction),
69 canLogout: Schema.optional(Schema.Boolean),
70 subscriptionSharing: Schema.optional(Schema.Boolean),
71 profileId: Schema.optional(TrimmedNonEmptyString),
72 workspaceId: Schema.optional(TrimmedNonEmptyString),
73 /** Origin of the custom endpoint the instance sends its requests to. */
74 endpoint: Schema.optional(TrimmedNonEmptyString),
75});
76export type ServerProviderAuth = typeof ServerProviderAuth.Type;
77
78export const ServerProviderModel = Schema.Struct({
79 slug: TrimmedNonEmptyString,
80 name: TrimmedNonEmptyString,
81 shortName: Schema.optional(TrimmedNonEmptyString),
82 subProvider: Schema.optional(TrimmedNonEmptyString),
83 aliases: Schema.optional(Schema.Array(TrimmedNonEmptyString)),
84 badge: Schema.optional(Schema.Literal("new")),
85 isCustom: Schema.Boolean,
86 isDefault: Schema.optional(Schema.Boolean),
87 isLegacy: Schema.optional(Schema.Boolean),
88 // False when the provider can run this model in sessions but not for
89 // application text generation. Absent means supported.
90 supportsTextGeneration: Schema.optional(Schema.Boolean),
91 capabilities: Schema.NullOr(ModelCapabilities),
92});
93export type ServerProviderModel = typeof ServerProviderModel.Type;
94
95export const ServerProviderUpdateRequiredModel = Schema.Struct({
96 slug: TrimmedNonEmptyString,
97 name: TrimmedNonEmptyString,
98 badge: Schema.optional(Schema.Literal("new")),
99 minVersion: TrimmedNonEmptyString,
100});
101export type ServerProviderUpdateRequiredModel = typeof ServerProviderUpdateRequiredModel.Type;
102
103export const ServerProviderSlashCommandInput = Schema.Struct({
104 hint: TrimmedNonEmptyString,
105});
106export type ServerProviderSlashCommandInput = typeof ServerProviderSlashCommandInput.Type;
107
108export const ServerProviderSlashCommand = Schema.Struct({
109 name: TrimmedNonEmptyString,
110 description: Schema.optional(TrimmedNonEmptyString),
111 input: Schema.optional(ServerProviderSlashCommandInput),
112});
113export type ServerProviderSlashCommand = typeof ServerProviderSlashCommand.Type;
114
115export const ServerProviderSkill = Schema.Struct({
116 name: TrimmedNonEmptyString,
117 description: Schema.optional(TrimmedNonEmptyString),
118 path: TrimmedNonEmptyString,
119 scope: Schema.optional(TrimmedNonEmptyString),
120 enabled: Schema.Boolean,
121 displayName: Schema.optional(TrimmedNonEmptyString),
122 shortDescription: Schema.optional(TrimmedNonEmptyString),
123 /** Claude disable-model-invocation: only users can invoke; composers must offer a slash command. */
124 userInvocationOnly: Schema.optional(Schema.Boolean),
125 /** Claude user-invocable:false: only agents can invoke; composers must hide the slash command. */
126 userInvocable: Schema.optional(Schema.Boolean),
127});
128export type ServerProviderSkill = typeof ServerProviderSkill.Type;
129
130export const ServerProviderWorkspaceSnapshot = Schema.Struct({
131 cwd: TrimmedNonEmptyString,
132 checkedAt: IsoDateTime,
133 slashCommands: Schema.Array(ServerProviderSlashCommand),
134 slashCommandsPending: Schema.optional(Schema.Boolean),
135 skills: Schema.Array(ServerProviderSkill),
136 optionDescriptors: Schema.optional(Schema.Array(ProviderOptionDescriptor)),
137 // Absent means the provider's machine `models`, which keeps most snapshots small.
138 models: Schema.optional(Schema.Array(ServerProviderModel)),
139 modelsPending: Schema.optional(Schema.Boolean),
140});
141export type ServerProviderWorkspaceSnapshot = typeof ServerProviderWorkspaceSnapshot.Type;
142
143export const PROVIDER_WORKSPACE_SNAPSHOT_TTL_MS = 5 * 60_000;
144
145export function isProviderWorkspaceSnapshotCurrent(
146 snapshot: Pick<ServerProviderWorkspaceSnapshot, "checkedAt">,
147 nowMs: number,
148): boolean {
149 return nowMs - Date.parse(snapshot.checkedAt) < PROVIDER_WORKSPACE_SNAPSHOT_TTL_MS;
150}
151
152/** A pending snapshot keeps what it found before and is rescanned before its TTL. */
153export function isProviderWorkspaceSnapshotPending(
154 snapshot: Pick<ServerProviderWorkspaceSnapshot, "slashCommandsPending" | "modelsPending">,
155): boolean {
156 return snapshot.slashCommandsPending === true || snapshot.modelsPending === true;
157}
158
159/** Unavailable snapshots must set installed and enabled false. */
160export const ServerProviderAvailability = Schema.Literals(["available", "unavailable"]);
161export type ServerProviderAvailability = typeof ServerProviderAvailability.Type;
162
163export const ServerProviderContinuation = Schema.Struct({
164 groupKey: TrimmedNonEmptyString,
165});
166export type ServerProviderContinuation = typeof ServerProviderContinuation.Type;
167
168export const ServerProviderCompatibilityStatus = Schema.Literals([
169 "unknown",
170 "supported",
171 "graceful",
172 "unsupported",
173 "broken",
174]);
175export const ServerProviderCompatibilityAdvisory = Schema.Struct({
176 status: ServerProviderCompatibilityStatus,
177 latestVersionStatus: Schema.optionalKey(ServerProviderCompatibilityStatus),
178 message: Schema.NullOr(TrimmedNonEmptyString),
179 recommendedVersion: Schema.NullOr(TrimmedNonEmptyString),
180 recommendedRange: Schema.NullOr(TrimmedNonEmptyString),
181});
182export type ServerProviderCompatibilityAdvisory = typeof ServerProviderCompatibilityAdvisory.Type;
183
184export const ServerProviderVersionAdvisoryStatus = Schema.Literals([
185 "unknown",
186 "current",
187 "behind_latest",
188]);
189export type ServerProviderVersionAdvisoryStatus = typeof ServerProviderVersionAdvisoryStatus.Type;
190
191export const ServerProviderVersionAdvisory = Schema.Struct({
192 status: ServerProviderVersionAdvisoryStatus,
193 currentVersion: Schema.NullOr(TrimmedNonEmptyString),
194 latestVersion: Schema.NullOr(TrimmedNonEmptyString),
195 updateCommand: Schema.NullOr(TrimmedNonEmptyString),
196 canUpdate: Schema.Boolean.pipe(Schema.withDecodingDefault(Effect.succeed(false))),
197 canInstallVersion: Schema.optionalKey(Schema.Boolean),
198 checkedAt: Schema.NullOr(IsoDateTime),
199 message: Schema.NullOr(TrimmedNonEmptyString),
200});
201export type ServerProviderVersionAdvisory = typeof ServerProviderVersionAdvisory.Type;
202
203export const ServerProviderUpdateStatus = Schema.Literals([
204 "idle",
205 "queued",
206 "running",
207 "succeeded",
208 "failed",
209 "unchanged",
210]);
211export type ServerProviderUpdateStatus = typeof ServerProviderUpdateStatus.Type;
212
213export const ServerProviderUpdateState = Schema.Struct({
214 status: ServerProviderUpdateStatus,
215 startedAt: Schema.NullOr(IsoDateTime),
216 finishedAt: Schema.NullOr(IsoDateTime),
217 message: Schema.NullOr(TrimmedNonEmptyString),
218 output: Schema.NullOr(Schema.String.check(Schema.isMaxLength(10_000))),
219});
220export type ServerProviderUpdateState = typeof ServerProviderUpdateState.Type;
221
222export const ServerProvider = Schema.Struct({
223 // Only instanceId is stable enough for provider routing.
224 instanceId: ProviderInstanceId,
225 driver: ProviderDriverKind,
226 displayName: Schema.optional(TrimmedNonEmptyString),
227 accentColor: Schema.optional(TrimmedNonEmptyString),
228 // Validate driver-supplied remote icons against the driver's trusted origin.
229 iconUrl: Schema.optional(TrimmedNonEmptyString.check(Schema.isMaxLength(2_048))),
230 badgeLabel: Schema.optional(TrimmedNonEmptyString),
231 continuation: Schema.optional(ServerProviderContinuation),
232 showInteractionModeToggle: Schema.optional(Schema.Boolean),
233 reportsContextWindow: Schema.optional(Schema.Boolean),
234 supportedRuntimeModes: Schema.optional(ForwardCompatibleArray(RuntimeMode)),
235 supportsConversationRollback: Schema.optional(Schema.Boolean),
236 supportsTextGeneration: Schema.optional(Schema.Boolean),
237 setup: Schema.optional(
238 Schema.Struct({
239 canAuthenticate: Schema.Boolean,
240 canInstall: Schema.Boolean,
241 documentationUrl: Schema.optionalKey(TrimmedNonEmptyString.check(Schema.isMaxLength(2_048))),
242 }),
243 ),
244 nativeSessions: Schema.optional(
245 Schema.Struct({
246 canList: Schema.Boolean,
247 canLoad: Schema.Boolean,
248 canResume: Schema.Boolean,
249 canDelete: Schema.optional(Schema.Boolean),
250 }),
251 ),
252 configurableProviders: Schema.optional(Schema.Boolean),
253 runtimePaths: Schema.optionalKey(
254 Schema.Struct({
255 homePath: TrimmedNonEmptyString,
256 shadowHomePath: Schema.NullOr(TrimmedNonEmptyString),
257 }),
258 ),
259 enabled: Schema.Boolean,
260 installed: Schema.Boolean,
261 version: Schema.NullOr(TrimmedNonEmptyString),
262 // Version reported by the installed CLI for a local provider with a separate
263 // server. Null means unknown; absence keeps legacy snapshots on `version`.
264 installedVersion: Schema.optionalKey(Schema.NullOr(TrimmedNonEmptyString)),
265 status: ServerProviderState,
266 auth: ServerProviderAuth,
267 checkedAt: IsoDateTime,
268 message: Schema.optional(TrimmedNonEmptyString),
269 availability: Schema.optional(ServerProviderAvailability),
270 unavailableReason: Schema.optional(TrimmedNonEmptyString),
271 models: Schema.Array(ServerProviderModel),
272 // Kept apart from `models` so clients that predate it never offer them.
273 updateRequiredModels: Schema.optionalKey(Schema.Array(ServerProviderUpdateRequiredModel)),
274 slashCommands: Schema.Array(ServerProviderSlashCommand).pipe(
275 Schema.withDecodingDefault(Effect.succeed([])),
276 ),
277 skills: Schema.Array(ServerProviderSkill).pipe(Schema.withDecodingDefault(Effect.succeed([]))),
278 workspaceSnapshots: Schema.optionalKey(Schema.Array(ServerProviderWorkspaceSnapshot)),
279 usageLimits: Schema.optional(ServerProviderUsageLimits),
280 versionAdvisory: Schema.optionalKey(ServerProviderVersionAdvisory),
281 compatibilityAdvisory: Schema.optionalKey(ServerProviderCompatibilityAdvisory),
282 updateState: Schema.optionalKey(ServerProviderUpdateState),
283 /**
284 * Stands for the machine slash commands and skills, which are then left out. Sent to clients
285 * that ask for catalog digests; they load both lists with their next cwd snapshot.
286 */
287 catalogDigest: Schema.optionalKey(TrimmedNonEmptyString),
288 /** Set by the client, never sent: the `catalogDigest` its slash commands and skills belong to. */
289 loadedCatalogDigest: Schema.optionalKey(TrimmedNonEmptyString),
290});
291export type ServerProvider = typeof ServerProvider.Type;
292
293/** A provider without the lists that equal the ones its reader already holds. */
294export const ServerProviderDelta = ServerProvider.mapFields((fields) => ({
295 ...fields,
296 models: Schema.optionalKey(fields.models),
297 // Declared again without the decoding default, which would read as a change to an empty list.
298 slashCommands: Schema.optionalKey(Schema.Array(ServerProviderSlashCommand)),
299 skills: Schema.optionalKey(Schema.Array(ServerProviderSkill)),
300}));
301export type ServerProviderDelta = typeof ServerProviderDelta.Type;
302
303const sameJson = (left: unknown, right: unknown) =>
304 left === right || JSON.stringify(left) === JSON.stringify(right);
305
306/** Leaves each provider's models, slash commands, and skills out when `previous` has the same. */
307export function serverProviderDeltas(
308 previous: ReadonlyArray<ServerProvider>,
309 next: ReadonlyArray<ServerProvider>,
310): ServerProviderDelta[] {
311 const held = new Map(previous.map((provider) => [provider.instanceId, provider]));
312 return next.map((provider) => {
313 const base = held.get(provider.instanceId);
314 if (base === undefined) return provider;
315 const { models, slashCommands, skills, ...rest } = provider;
316 return {
317 ...rest,
318 ...(sameJson(base.models, models) ? {} : { models }),
319 ...(sameJson(base.slashCommands, slashCommands) ? {} : { slashCommands }),
320 ...(sameJson(base.skills, skills) ? {} : { skills }),
321 };
322 });
323}
324
325/** Rebuilds the provider list `serverProviderDeltas` was made from. */
326export function applyServerProviderDeltas(
327 previous: ReadonlyArray<ServerProvider>,
328 deltas: ReadonlyArray<ServerProviderDelta>,
329): ServerProvider[] {
330 const held = new Map(previous.map((provider) => [provider.instanceId, provider]));
331 return deltas.flatMap((delta) => {
332 const base = held.get(delta.instanceId);
333 const models = delta.models ?? base?.models;
334 const slashCommands = delta.slashCommands ?? base?.slashCommands;
335 const skills = delta.skills ?? base?.skills;
336 // A list this reader never held cannot be rebuilt; drop the provider like an unreadable one.
337 return models && slashCommands && skills ? [{ ...delta, models, slashCommands, skills }] : [];
338 });
339}
340
341export const ServerProviders = ForwardCompatibleArray(ServerProvider);
342export type ServerProviders = typeof ServerProviders.Type;
343
344export const isProviderAvailable = (snapshot: ServerProvider): boolean =>
345 snapshot.availability !== "unavailable";
346
347/** Legacy producers omit this field and support text generation. */
348export const isProviderTextGenerationCapable = (snapshot: ServerProvider): boolean =>
349 snapshot.supportsTextGeneration !== false;
350
351export const OtlpEndpointSource = Schema.Literals(["environment", "bootstrap", "settings"]);
352export type OtlpEndpointSource = typeof OtlpEndpointSource.Type;
353
354export const ServerObservability = Schema.Struct({
355 logsDirectoryPath: TrimmedNonEmptyString,
356 localTracingEnabled: Schema.Boolean,
357 otlpTracesUrl: Schema.optional(TrimmedNonEmptyString),
358 otlpTracesSource: Schema.optional(OtlpEndpointSource),
359 otlpTracesVariable: Schema.optional(TrimmedNonEmptyString),
360 otlpTracesEnabled: Schema.Boolean,
361 otlpMetricsUrl: Schema.optional(TrimmedNonEmptyString),
362 otlpMetricsSource: Schema.optional(OtlpEndpointSource),
363 otlpMetricsVariable: Schema.optional(TrimmedNonEmptyString),
364 otlpMetricsEnabled: Schema.Boolean,
365 otlpLogsUrl: Schema.optional(TrimmedNonEmptyString),
366 otlpLogsSource: Schema.optional(OtlpEndpointSource),
367 otlpLogsVariable: Schema.optional(TrimmedNonEmptyString),
368 otlpLogsEnabled: Schema.Boolean.pipe(Schema.withDecodingDefault(Effect.succeed(false))),
369});
370export type ServerObservability = typeof ServerObservability.Type;
371
372export const OtlpSignal = Schema.Literals(["traces", "metrics", "logs"]);
373export type OtlpSignal = typeof OtlpSignal.Type;
374
375export const OtlpEndpointCheckInput = Schema.Struct({
376 signal: OtlpSignal,
377 url: TrimmedNonEmptyString.check(Schema.isPattern(/^https?:\/\/./i)),
378});
379export type OtlpEndpointCheckInput = typeof OtlpEndpointCheckInput.Type;
380
381export const OtlpEndpointCheckResult = Schema.Union([
382 Schema.TaggedStruct("Accepted", { latencyMs: Schema.Number }),
383 Schema.TaggedStruct("Rejected", { status: Schema.Number }),
384 Schema.TaggedStruct("Unreachable", { timedOut: Schema.Boolean }),
385]);
386export type OtlpEndpointCheckResult = typeof OtlpEndpointCheckResult.Type;
387
388/** The client tells the server what it is, so the triage context can name it. */
389export const ServerPrepareTriageInput = Schema.Struct({
390 client: AuthClientPresentationMetadata,
391});
392export type ServerPrepareTriageInput = typeof ServerPrepareTriageInput.Type;
393
394export const ServerPrepareTriageResult = Schema.Struct({
395 /** Composer text that links the session's prompt file. */
396 prompt: Schema.String,
397});
398export type ServerPrepareTriageResult = typeof ServerPrepareTriageResult.Type;
399
400/**
401 * The prompt file links as a chip in the user's message; clients spot a triage
402 * draft by it.
403 */
404export const TRIAGE_PROMPT_FILE_NAME = "triage-playbook.md";
405
406export class ServerPrepareTriageError extends Schema.TaggedError<ServerPrepareTriageError>()(
407 "ServerPrepareTriageError",
408 { cause: Schema.optional(Schema.Defect()) },
409) {
410 override get message(): string {
411 return "Could not write the triage session files.";
412 }
413}
414
415export const ServerTraceDiagnosticsErrorKind = Schema.Literals([
416 "trace-file-not-found",
417 "trace-file-read-failed",
418]);
419export type ServerTraceDiagnosticsErrorKind = typeof ServerTraceDiagnosticsErrorKind.Type;
420
421export const ServerTraceDiagnosticsSpanSummary = Schema.Struct({
422 name: TrimmedNonEmptyString,
423 count: NonNegativeInt,
424 failureCount: NonNegativeInt,
425 totalDurationMs: Schema.Number,
426 averageDurationMs: Schema.Number,
427 maxDurationMs: Schema.Number,
428});
429export type ServerTraceDiagnosticsSpanSummary = typeof ServerTraceDiagnosticsSpanSummary.Type;
430
431export const ServerTraceDiagnosticsFailureSummary = Schema.Struct({
432 name: TrimmedNonEmptyString,
433 cause: TrimmedNonEmptyString,
434 count: NonNegativeInt,
435 lastSeenAt: Schema.DateTimeUtc,
436 traceId: TrimmedNonEmptyString,
437 spanId: TrimmedNonEmptyString,
438});
439export type ServerTraceDiagnosticsFailureSummary = typeof ServerTraceDiagnosticsFailureSummary.Type;
440
441export const ServerTraceDiagnosticsRecentFailure = Schema.Struct({
442 name: TrimmedNonEmptyString,
443 cause: TrimmedNonEmptyString,
444 durationMs: Schema.Number,
445 endedAt: Schema.DateTimeUtc,
446 traceId: TrimmedNonEmptyString,
447 spanId: TrimmedNonEmptyString,
448});
449export type ServerTraceDiagnosticsRecentFailure = typeof ServerTraceDiagnosticsRecentFailure.Type;
450
451export const ServerTraceDiagnosticsSpanOccurrence = Schema.Struct({
452 name: TrimmedNonEmptyString,
453 durationMs: Schema.Number,
454 endedAt: Schema.DateTimeUtc,
455 traceId: TrimmedNonEmptyString,
456 spanId: TrimmedNonEmptyString,
457});
458export type ServerTraceDiagnosticsSpanOccurrence = typeof ServerTraceDiagnosticsSpanOccurrence.Type;
459
460export const ServerTraceDiagnosticsLogEvent = Schema.Struct({
461 spanName: TrimmedNonEmptyString,
462 level: TrimmedNonEmptyString,
463 message: TrimmedNonEmptyString,
464 seenAt: Schema.DateTimeUtc,
465 traceId: TrimmedNonEmptyString,
466 spanId: TrimmedNonEmptyString,
467});
468export type ServerTraceDiagnosticsLogEvent = typeof ServerTraceDiagnosticsLogEvent.Type;
469
470export const ServerTraceDiagnosticsResult = Schema.Struct({
471 traceFilePath: TrimmedNonEmptyString,
472 scannedFilePaths: Schema.Array(TrimmedNonEmptyString),
473 readAt: Schema.DateTimeUtc,
474 recordCount: NonNegativeInt,
475 parseErrorCount: NonNegativeInt,
476 firstSpanAt: Schema.Option(Schema.DateTimeUtc),
477 lastSpanAt: Schema.Option(Schema.DateTimeUtc),
478 failureCount: NonNegativeInt,
479 interruptionCount: NonNegativeInt,
480 slowSpanThresholdMs: NonNegativeInt,
481 slowSpanCount: NonNegativeInt,
482 logLevelCounts: Schema.Record(TrimmedNonEmptyString, NonNegativeInt),
483 topSpansByCount: Schema.Array(ServerTraceDiagnosticsSpanSummary),
484 slowestSpans: Schema.Array(ServerTraceDiagnosticsSpanOccurrence),
485 commonFailures: Schema.Array(ServerTraceDiagnosticsFailureSummary),
486 latestFailures: Schema.Array(ServerTraceDiagnosticsRecentFailure),
487 latestWarningAndErrorLogs: Schema.Array(ServerTraceDiagnosticsLogEvent),
488 partialFailure: Schema.Option(Schema.Boolean),
489 error: Schema.Option(
490 Schema.Struct({
491 kind: ServerTraceDiagnosticsErrorKind,
492 message: TrimmedNonEmptyString,
493 }),
494 ),
495});
496export type ServerTraceDiagnosticsResult = typeof ServerTraceDiagnosticsResult.Type;
497
498export const ServerProcessSignal = Schema.Literals(["SIGINT", "SIGKILL"]);
499export type ServerProcessSignal = typeof ServerProcessSignal.Type;
500
501export const ServerProcessDiagnosticsEntry = Schema.Struct({
502 pid: PositiveInt,
503 startTimeMs: NonNegativeInt,
504 ppid: NonNegativeInt,
505 pgid: Schema.Option(Schema.Int),
506 status: TrimmedNonEmptyString,
507 cpuPercent: Schema.Number,
508 rssBytes: NonNegativeInt,
509 elapsed: TrimmedNonEmptyString,
510 command: TrimmedNonEmptyString,
511 depth: NonNegativeInt,
512 childPids: Schema.Array(PositiveInt),
513});
514export type ServerProcessDiagnosticsEntry = typeof ServerProcessDiagnosticsEntry.Type;
515
516export const ServerProcessDiagnosticsResult = Schema.Struct({
517 serverPid: PositiveInt,
518 readAt: Schema.DateTimeUtc,
519 processCount: NonNegativeInt,
520 totalRssBytes: NonNegativeInt,
521 totalCpuPercent: Schema.Number,
522 processes: Schema.Array(ServerProcessDiagnosticsEntry),
523 error: Schema.Option(
524 Schema.Struct({
525 message: TrimmedNonEmptyString,
526 }),
527 ),
528});
529export type ServerProcessDiagnosticsResult = typeof ServerProcessDiagnosticsResult.Type;
530
531export const ServerProcessResourceHistoryInput = Schema.Struct({
532 windowMs: NonNegativeInt,
533 bucketMs: NonNegativeInt,
534});
535export type ServerProcessResourceHistoryInput = typeof ServerProcessResourceHistoryInput.Type;
536
537export const ServerProcessResourceHistoryBucket = Schema.Struct({
538 startedAt: Schema.DateTimeUtc,
539 endedAt: Schema.DateTimeUtc,
540 avgCpuPercent: Schema.Number,
541 maxCpuPercent: Schema.Number,
542 maxRssBytes: NonNegativeInt,
543 maxProcessCount: NonNegativeInt,
544});
545export type ServerProcessResourceHistoryBucket = typeof ServerProcessResourceHistoryBucket.Type;
546
547export const ServerProcessResourceHistorySummary = Schema.Struct({
548 processKey: TrimmedNonEmptyString,
549 pid: PositiveInt,
550 ppid: NonNegativeInt,
551 command: TrimmedNonEmptyString,
552 depth: NonNegativeInt,
553 isServerRoot: Schema.Boolean,
554 firstSeenAt: Schema.DateTimeUtc,
555 lastSeenAt: Schema.DateTimeUtc,
556 currentCpuPercent: Schema.Number,
557 avgCpuPercent: Schema.Number,
558 maxCpuPercent: Schema.Number,
559 cpuSecondsApprox: Schema.Number,
560 currentRssBytes: NonNegativeInt,
561 maxRssBytes: NonNegativeInt,
562 sampleCount: NonNegativeInt,
563});
564export type ServerProcessResourceHistorySummary = typeof ServerProcessResourceHistorySummary.Type;
565
566export const ServerProcessResourceHistoryFailureTag = Schema.Literals([
567 "ProcessDiagnosticsQueryTimeoutError",
568 "ProcessDiagnosticsQueryFailedError",
569 "ProcessDiagnosticsServerProcessSignalError",
570 "ProcessDiagnosticsNotDescendantError",
571 "ProcessDiagnosticsSignalFailedError",
572]);
573export type ServerProcessResourceHistoryFailureTag =
574 typeof ServerProcessResourceHistoryFailureTag.Type;
575
576export const ServerProcessResourceHistoryResult = Schema.Struct({
577 readAt: Schema.DateTimeUtc,
578 windowMs: NonNegativeInt,
579 bucketMs: NonNegativeInt,
580 sampleIntervalMs: NonNegativeInt,
581 retainedSampleCount: NonNegativeInt,
582 totalCpuSecondsApprox: Schema.Number,
583 buckets: Schema.Array(ServerProcessResourceHistoryBucket),
584 topProcesses: Schema.Array(ServerProcessResourceHistorySummary),
585 error: Schema.Option(
586 Schema.Struct({
587 failureTag: ServerProcessResourceHistoryFailureTag,
588 message: TrimmedNonEmptyString,
589 }),
590 ),
591});
592export type ServerProcessResourceHistoryResult = typeof ServerProcessResourceHistoryResult.Type;
593
594export const ServerSignalProcessInput = Schema.Struct({
595 pid: PositiveInt,
596 startTimeMs: NonNegativeInt,
597 signal: ServerProcessSignal,
598});
599export type ServerSignalProcessInput = typeof ServerSignalProcessInput.Type;
600
601export const ServerSignalProcessResult = Schema.Struct({
602 pid: PositiveInt,
603 signal: ServerProcessSignal,
604 signaled: Schema.Boolean,
605 message: Schema.Option(TrimmedNonEmptyString),
606});
607export type ServerSignalProcessResult = typeof ServerSignalProcessResult.Type;
608
609export const EnvironmentThemeColor = Schema.String.check(
610 Schema.isPattern(/^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/),
611);
612export type EnvironmentThemeColor = typeof EnvironmentThemeColor.Type;
613
614/** Reserve appearance keywords so published themes cannot replace stock preferences. */
615export const EnvironmentThemeId = Schema.String.check(
616 Schema.isPattern(/^(?!(?:system|light|dark)$)[a-z0-9](?:[a-z0-9-]{0,47})$/),
617);
618export type EnvironmentThemeId = typeof EnvironmentThemeId.Type;
619
620const EnvironmentThemeColors = Schema.Record(
621 Schema.String.check(Schema.isPattern(/^[a-zA-Z][a-zA-Z0-9]{0,63}$/)),
622 TrimmedNonEmptyString.check(Schema.isMaxLength(64)),
623);
624
625const environmentThemeFields = {
626 version: Schema.optional(Schema.Literal(1)),
627 name: TrimmedNonEmptyString.check(Schema.isMaxLength(48)),
628 appearance: Schema.Literals(["light", "dark"]),
629 /** Derive the palette from canvas/accent, then overlay colors; without them, colors is the palette. */
630 canvas: Schema.optional(EnvironmentThemeColor),
631 accent: Schema.optional(EnvironmentThemeColor),
632 colors: Schema.optional(EnvironmentThemeColors),
633 variants: Schema.optional(
634 Schema.Struct({
635 light: Schema.optional(EnvironmentThemeColors),
636 dark: Schema.optional(EnvironmentThemeColors),
637 }),
638 ),
639};
640
641export const EnvironmentThemeFile = Schema.Struct(environmentThemeFields);
642export type EnvironmentThemeFile = typeof EnvironmentThemeFile.Type;
643
644export const EnvironmentTheme = Schema.Struct({
645 id: EnvironmentThemeId,
646 ...environmentThemeFields,
647});
648export type EnvironmentTheme = typeof EnvironmentTheme.Type;
649
650export function environmentThemeFileHasColors(file: EnvironmentThemeFile): boolean {
651 return (
652 (file.canvas !== undefined && file.accent !== undefined) ||
653 (file.colors !== undefined && Object.keys(file.colors).length > 0)
654 );
655}
656
657/** tailnet means this machine's Tailscale interface; other private addresses are lan. */
658export const ServerDirectEndpointKind = Schema.Literals(["lan", "tailnet"]);
659export type ServerDirectEndpointKind = typeof ServerDirectEndpointKind.Type;
660
661export const ServerDirectEndpoint = Schema.Struct({
662 kind: ServerDirectEndpointKind,
663 httpBaseUrl: TrimmedNonEmptyString,
664});
665export type ServerDirectEndpoint = typeof ServerDirectEndpoint.Type;
666
667/**
668 * A stretch where the server's event loop could not run, so it answered
669 * nothing and clients may have dropped the connection.
670 */
671export const ServerEventLoopStall = Schema.Struct({
672 detectedAt: IsoDateTime,
673 durationMs: NonNegativeInt,
674 /** One-minute load average when the stall was seen. Absent on Windows, which has none. */
675 loadAverage: Schema.optionalKey(Schema.Number),
676 cpuCount: PositiveInt,
677});
678export type ServerEventLoopStall = typeof ServerEventLoopStall.Type;
679
680export const ServerConfig = Schema.Struct({
681 environment: ExecutionEnvironmentDescriptor,
682 auth: ServerAuthDescriptor,
683 cwd: TrimmedNonEmptyString,
684 keybindingsConfigPath: TrimmedNonEmptyString,
685 keybindings: ResolvedKeybindingsConfig,
686 issues: ServerConfigIssues,
687 providers: ServerProviders,
688 availableEditors: ForwardCompatibleArray(EditorId),
689 remoteOpenTargets: Schema.optionalKey(ForwardCompatibleArray(RemoteOpenTarget)),
690 /** Hints only; verify each address answers as this environment. */
691 directEndpoints: Schema.optionalKey(ForwardCompatibleArray(ServerDirectEndpoint)),
692 observability: ServerObservability,
693 settings: ServerSettings,
694 /** Present when an administrator's policy file manages this environment. */
695 managedPolicy: Schema.optionalKey(ManagedPolicySummary),
696 shellResumeCompletionMarker: Schema.optionalKey(Schema.Boolean),
697 /**
698 * The shell can leave idle subagent children out of snapshots (`omitIdleSubagents`), and
699 * `getThreadFamily` and `getWorktreeThreadIds` serve the rows it leaves out.
700 */
701 shellThreadFamilies: Schema.optionalKey(Schema.Boolean),
702 threadLinkMetadata: Schema.optionalKey(Schema.Boolean),
703 /**
704 * The shell can leave older settled threads out of snapshots (`omitOlderSettled`), and
705 * `getOlderSettledThreads` serves them. Only servers that also advertise `shellThreadFamilies`.
706 */
707 shellOlderSettled: Schema.optionalKey(Schema.Boolean),
708 shellRevealInFileManager: Schema.optionalKey(Schema.Boolean),
709 shellRevealInFileManagerKind: Schema.optionalKey(FileManagerRevealKind),
710 threadResumeCompletionMarker: Schema.optionalKey(Schema.Boolean),
711 /** Send window fields only when advertised. */
712 threadSnapshotPagination: Schema.optionalKey(Schema.Boolean),
713 threadFind: Schema.optionalKey(Schema.Boolean),
714 threadFindProgressive: Schema.optionalKey(Schema.Boolean),
715 /** Settings patches may carry `secretProviders`; older servers drop the key without an error. */
716 secretProviderSettings: Schema.optionalKey(Schema.Boolean),
717 /** Secret settings may point at a secret provider; older servers drop the reference. */
718 secretReferences: Schema.optionalKey(Schema.Boolean),
719 /** A secret request card may be answered with a secret provider reference. */
720 secretRequestReferences: Schema.optionalKey(Schema.Boolean),
721 scratchWorkspaceRoot: Schema.optionalKey(TrimmedNonEmptyString),
722 newProjectsRoot: Schema.optionalKey(TrimmedNonEmptyString),
723 /**
724 * The latest stall long enough to notice, sent only for a few minutes after
725 * it. A client that reconnects reads it to say why the host stopped
726 * answering. Clients do not cache it, since it describes the host at connect.
727 */
728 lastEventLoopStall: Schema.optionalKey(ServerEventLoopStall),
729 /**
730 * Never sent in a config snapshot: the theme stream emits the current set
731 * before any change, so a snapshot carrying it too would hand every
732 * subscriber the same array twice per connect.
733 */
734 environmentThemes: Schema.optional(Schema.Array(EnvironmentTheme)),
735 /** Stream-only and opt-in; the source stream emits the current set on subscribe. */
736 usageLimitSources: Schema.optional(UsageLimitSourceSnapshots),
737});
738export type ServerConfig = typeof ServerConfig.Type;
739
740export function resolveEnvironmentMachineKind(
741 config: {
742 readonly environment: Pick<ExecutionEnvironmentDescriptor, "platform">;
743 readonly settings?: Pick<ServerSettings, "environmentIcon">;
744 } | null,
745): EnvironmentMachineKind {
746 return config?.settings?.environmentIcon ?? config?.environment.platform.machine ?? "server";
747}
748
749const ServerUpsertKeybindingReplaceTarget = Schema.Struct({
750 key: KeybindingValue,
751 command: KeybindingCommand,
752 when: Schema.optional(KeybindingWhen),
753});
754
755export const ServerUpsertKeybindingInput = Schema.Struct({
756 key: KeybindingValue,
757 command: KeybindingCommand,
758 when: Schema.optional(KeybindingWhen),
759 replace: Schema.optional(ServerUpsertKeybindingReplaceTarget),
760});
761export type ServerUpsertKeybindingInput = typeof ServerUpsertKeybindingInput.Type;
762
763export const ServerRemoveKeybindingInput = ServerUpsertKeybindingReplaceTarget;
764export type ServerRemoveKeybindingInput = typeof ServerRemoveKeybindingInput.Type;
765
766export const ServerUpsertKeybindingResult = Schema.Struct({
767 keybindings: ResolvedKeybindingsConfig,
768 issues: ServerConfigIssues,
769});
770export type ServerUpsertKeybindingResult = typeof ServerUpsertKeybindingResult.Type;
771
772export const ServerRemoveKeybindingResult = ServerUpsertKeybindingResult;
773export type ServerRemoveKeybindingResult = typeof ServerRemoveKeybindingResult.Type;
774
775export const ServerConfigUpdatedPayload = Schema.Struct({
776 issues: ServerConfigIssues,
777 providers: ServerProviders,
778 settings: Schema.optional(ServerSettings),
779});
780export type ServerConfigUpdatedPayload = typeof ServerConfigUpdatedPayload.Type;
781
782export const ServerConfigKeybindingsUpdatedPayload = Schema.Struct({
783 keybindings: ResolvedKeybindingsConfig,
784 issues: ServerConfigIssues,
785});
786export type ServerConfigKeybindingsUpdatedPayload =
787 typeof ServerConfigKeybindingsUpdatedPayload.Type;
788
789export const ServerConfigProviderStatusesPayload = Schema.Struct({
790 providers: ServerProviders,
791});
792export type ServerConfigProviderStatusesPayload = typeof ServerConfigProviderStatusesPayload.Type;
793
794export const ServerConfigProviderStatusDeltasPayload = Schema.Struct({
795 /** Every provider in order, as `serverProviderDeltas` from the list this client last received. */
796 providers: ForwardCompatibleArray(ServerProviderDelta),
797});
798export type ServerConfigProviderStatusDeltasPayload =
799 typeof ServerConfigProviderStatusDeltasPayload.Type;
800
801export const ServerConfigSettingsUpdatedPayload = Schema.Struct({
802 settings: ServerSettings,
803});
804export type ServerConfigSettingsUpdatedPayload = typeof ServerConfigSettingsUpdatedPayload.Type;
805
806export const ServerConfigStreamSnapshotEvent = Schema.Struct({
807 version: Schema.Literal(1),
808 type: Schema.Literal("snapshot"),
809 config: ServerConfig,
810});
811export type ServerConfigStreamSnapshotEvent = typeof ServerConfigStreamSnapshotEvent.Type;
812
813export const ServerConfigStreamKeybindingsUpdatedEvent = Schema.Struct({
814 version: Schema.Literal(1),
815 type: Schema.Literal("keybindingsUpdated"),
816 payload: ServerConfigKeybindingsUpdatedPayload,
817});
818export type ServerConfigStreamKeybindingsUpdatedEvent =
819 typeof ServerConfigStreamKeybindingsUpdatedEvent.Type;
820
821export const ServerConfigStreamProviderStatusesEvent = Schema.Struct({
822 version: Schema.Literal(1),
823 type: Schema.Literal("providerStatuses"),
824 payload: ServerConfigProviderStatusesPayload,
825});
826export type ServerConfigStreamProviderStatusesEvent =
827 typeof ServerConfigStreamProviderStatusesEvent.Type;
828
829export const ServerConfigStreamProviderStatusDeltasEvent = Schema.Struct({
830 version: Schema.Literal(1),
831 type: Schema.Literal("providerStatusDeltas"),
832 payload: ServerConfigProviderStatusDeltasPayload,
833});
834export type ServerConfigStreamProviderStatusDeltasEvent =
835 typeof ServerConfigStreamProviderStatusDeltasEvent.Type;
836
837export const ServerConfigStreamSettingsUpdatedEvent = Schema.Struct({
838 version: Schema.Literal(1),
839 type: Schema.Literal("settingsUpdated"),
840 payload: ServerConfigSettingsUpdatedPayload,
841});
842export type ServerConfigStreamSettingsUpdatedEvent =
843 typeof ServerConfigStreamSettingsUpdatedEvent.Type;
844
845export const ServerConfigEnvironmentThemesUpdatedPayload = Schema.Struct({
846 themes: Schema.Array(EnvironmentTheme),
847});
848export type ServerConfigEnvironmentThemesUpdatedPayload =
849 typeof ServerConfigEnvironmentThemesUpdatedPayload.Type;
850
851export const ServerConfigStreamEnvironmentThemesUpdatedEvent = Schema.Struct({
852 version: Schema.Literal(1),
853 type: Schema.Literal("environmentThemesUpdated"),
854 payload: ServerConfigEnvironmentThemesUpdatedPayload,
855});
856export type ServerConfigStreamEnvironmentThemesUpdatedEvent =
857 typeof ServerConfigStreamEnvironmentThemesUpdatedEvent.Type;
858
859export const ServerConfigUsageLimitSourcesUpdatedPayload = Schema.Struct({
860 sources: UsageLimitSourceSnapshots,
861});
862export type ServerConfigUsageLimitSourcesUpdatedPayload =
863 typeof ServerConfigUsageLimitSourcesUpdatedPayload.Type;
864
865export const ServerConfigStreamUsageLimitSourcesUpdatedEvent = Schema.Struct({
866 version: Schema.Literal(1),
867 type: Schema.Literal("usageLimitSourcesUpdated"),
868 payload: ServerConfigUsageLimitSourcesUpdatedPayload,
869});
870export type ServerConfigStreamUsageLimitSourcesUpdatedEvent =
871 typeof ServerConfigStreamUsageLimitSourcesUpdatedEvent.Type;
872
873export const ServerConfigStreamEvent = Schema.Union([
874 ServerConfigStreamSnapshotEvent,
875 ServerConfigStreamKeybindingsUpdatedEvent,
876 ServerConfigStreamProviderStatusesEvent,
877 ServerConfigStreamProviderStatusDeltasEvent,
878 ServerConfigStreamSettingsUpdatedEvent,
879 ServerConfigStreamEnvironmentThemesUpdatedEvent,
880 ServerConfigStreamUsageLimitSourcesUpdatedEvent,
881]);
882export type ServerConfigStreamEvent = typeof ServerConfigStreamEvent.Type;
883
884export const ServerSelfUpdateOutcome = Schema.Struct({
885 id: TrimmedNonEmptyString,
886 fromVersion: TrimmedNonEmptyString,
887 targetVersion: TrimmedNonEmptyString,
888 status: Schema.Literals(["committed", "rolled-back", "failed"]),
889 reason: Schema.optionalKey(TrimmedNonEmptyString),
890});
891export type ServerSelfUpdateOutcome = typeof ServerSelfUpdateOutcome.Type;
892
893export const ServerLifecycleReadyPayload = Schema.Struct({
894 at: IsoDateTime,
895 environment: ExecutionEnvironmentDescriptor,
896 updateOutcome: Schema.optionalKey(ServerSelfUpdateOutcome),
897});
898export type ServerLifecycleReadyPayload = typeof ServerLifecycleReadyPayload.Type;
899
900export const ServerLifecycleWelcomePayload = Schema.Struct({
901 environment: ExecutionEnvironmentDescriptor,
902 cwd: TrimmedNonEmptyString,
903 projectName: TrimmedNonEmptyString,
904 bootstrapStatus: Schema.optional(Schema.Literals(["pending", "complete"])),
905 bootstrapProjectId: Schema.optional(ProjectId),
906 bootstrapThreadId: Schema.optional(ThreadId),
907 bootstrapProjectCreated: Schema.optional(Schema.Boolean),
908 bootstrapThreadCreated: Schema.optional(Schema.Boolean),
909});
910export type ServerLifecycleWelcomePayload = typeof ServerLifecycleWelcomePayload.Type;
911
912export const ServerLifecycleLegacyThreadMigrationPayload = Schema.Struct({
913 status: Schema.Union([Schema.Literal("running"), Schema.Literal("complete")]),
914 totalThreadCount: NonNegativeInt,
915});
916export type ServerLifecycleLegacyThreadMigrationPayload =
917 typeof ServerLifecycleLegacyThreadMigrationPayload.Type;
918
919export const ServerLifecycleStreamWelcomeEvent = Schema.Struct({
920 version: Schema.Literal(1),
921 sequence: NonNegativeInt,
922 type: Schema.Literal("welcome"),
923 payload: ServerLifecycleWelcomePayload,
924});
925export type ServerLifecycleStreamWelcomeEvent = typeof ServerLifecycleStreamWelcomeEvent.Type;
926
927export const ServerLifecycleStreamReadyEvent = Schema.Struct({
928 version: Schema.Literal(1),
929 sequence: NonNegativeInt,
930 type: Schema.Literal("ready"),
931 payload: ServerLifecycleReadyPayload,
932});
933export type ServerLifecycleStreamReadyEvent = typeof ServerLifecycleStreamReadyEvent.Type;
934
935export const ServerLifecycleStreamLegacyThreadMigrationEvent = Schema.Struct({
936 version: Schema.Literal(1),
937 sequence: NonNegativeInt,
938 type: Schema.Literal("legacyThreadMigration"),
939 payload: ServerLifecycleLegacyThreadMigrationPayload,
940});
941export type ServerLifecycleStreamLegacyThreadMigrationEvent =
942 typeof ServerLifecycleStreamLegacyThreadMigrationEvent.Type;
943
944export const ServerLifecycleStreamEvent = Schema.Union([
945 ServerLifecycleStreamWelcomeEvent,
946 ServerLifecycleStreamReadyEvent,
947 ServerLifecycleStreamLegacyThreadMigrationEvent,
948]);
949export type ServerLifecycleStreamEvent = typeof ServerLifecycleStreamEvent.Type;
950
951export const ServerProviderUpdatedPayload = Schema.Struct({
952 providers: ServerProviders,
953});
954export type ServerProviderUpdatedPayload = typeof ServerProviderUpdatedPayload.Type;
955
956export const ServerProviderUpdateInput = Schema.Struct({
957 provider: ProviderDriverKind,
958 targetVersion: Schema.optionalKey(TrimmedNonEmptyString),
959 instanceId: Schema.optionalKey(ProviderInstanceId),
960});
961export type ServerProviderUpdateInput = typeof ServerProviderUpdateInput.Type;
962
963export class ServerProviderUpdateError extends Schema.TaggedError<ServerProviderUpdateError>()(
964 "ServerProviderUpdateError",
965 {
966 provider: ProviderDriverKind,
967 reason: TrimmedNonEmptyString,
968 cause: Schema.optional(Schema.Defect()),
969 },
970) {
971 override get message(): string {
972 return `Provider update failed for ${this.provider}: ${this.reason}`;
973 }
974}
975
976export const ServerNpmReleaseInput = Schema.Struct({
977 spec: Schema.String.check(
978 Schema.isMaxLength(64),
979 Schema.isPattern(/^(?:latest|nightly|\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?)$/),
980 ),
981});
982export type ServerNpmReleaseInput = typeof ServerNpmReleaseInput.Type;
983
984export const ServerNpmRelease = Schema.Struct({
985 version: Schema.String,
986 databaseMigration: Schema.optionalKey(Schema.Int),
987});
988export type ServerNpmRelease = typeof ServerNpmRelease.Type;
989
990export class ServerNpmReleaseError extends Schema.TaggedError<ServerNpmReleaseError>()(
991 "ServerNpmReleaseError",
992 { reason: Schema.String },
993) {
994 override get message(): string {
995 return `Could not check the configured npm registry: ${this.reason}`;
996 }
997}
998
999export const ServerSelfUpdateInput = Schema.Struct({
1000 /** Exact npm version, never a dist-tag, so server and client agree on the request. */
1001 targetVersion: TrimmedNonEmptyString,
1002 /** Desktop-managed hosts move their app to this update track first. Sent only for a track switch. */
1003 channel: Schema.optionalKey(DesktopUpdateChannelSchema),
1004 /** The target release's highest migration; the host refuses to leave Nightly without it. */
1005 targetDatabaseMigration: Schema.optionalKey(Schema.Int),
1006});
1007export type ServerSelfUpdateInput = typeof ServerSelfUpdateInput.Type;
1008
1009export const ServerSelfUpdateResult = Schema.Struct({
1010 targetVersion: TrimmedNonEmptyString,
1011 method: ServerSelfUpdateMethod,
1012 updateId: Schema.optionalKey(TrimmedNonEmptyString),
1013 desktopUpdateToken: Schema.optionalKey(TrimmedNonEmptyString),
1014});
1015export type ServerSelfUpdateResult = typeof ServerSelfUpdateResult.Type;
1016
1017export const DesktopUpdateCommitInput = Schema.Struct({
1018 requestId: TrimmedNonEmptyString,
1019});
1020export type DesktopUpdateCommitInput = typeof DesktopUpdateCommitInput.Type;
1021
1022export const ServerSelfUpdateProgressStage = Schema.Literals(["downloading", "installing"]);
1023export type ServerSelfUpdateProgressStage = typeof ServerSelfUpdateProgressStage.Type;
1024
1025export const ServerSelfUpdateProgressEvent = Schema.Union([
1026 Schema.Struct({
1027 type: Schema.Literal("progress"),
1028 stage: ServerSelfUpdateProgressStage,
1029 }),
1030 Schema.Struct({
1031 type: Schema.Literal("complete"),
1032 result: ServerSelfUpdateResult,
1033 }),
1034]);
1035export type ServerSelfUpdateProgressEvent = typeof ServerSelfUpdateProgressEvent.Type;
1036
1037export class ServerSelfUpdateError extends Schema.TaggedError<ServerSelfUpdateError>()(
1038 "ServerSelfUpdateError",
1039 {
1040 reason: TrimmedNonEmptyString,
1041 cause: Schema.optional(Schema.Defect()),
1042 },
1043) {
1044 override get message(): string {
1045 return `Server update failed: ${this.reason}`;
1046 }
1047}