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