Open History to see the last commit
1import * as Effect from "effect/Effect";
2import * as Schema from "effect/Schema";
3import { ExecutionEnvironmentDescriptor } from "./environment.ts";
4import { ServerAuthDescriptor } from "./auth.ts";
5import {
6 IsoDateTime,
7 NonNegativeInt,
8 PositiveInt,
9 ProjectId,
10 ThreadId,
11 TrimmedNonEmptyString,
12} from "./baseSchemas.ts";
13import {
14 KeybindingCommand,
15 KeybindingValue,
16 KeybindingWhen,
17 ResolvedKeybindingsConfig,
18} from "./keybindings.ts";
19import { EditorId } from "./editor.ts";
20import { ModelCapabilities } from "./model.ts";
21import { ProviderDriverKind, ProviderInstanceId } from "./providerInstance.ts";
22import { ServerSettings } from "./settings.ts";
23
24const KeybindingsMalformedConfigIssue = Schema.Struct({
25 kind: Schema.Literal("keybindings.malformed-config"),
26 message: TrimmedNonEmptyString,
27});
28
29const KeybindingsInvalidEntryIssue = Schema.Struct({
30 kind: Schema.Literal("keybindings.invalid-entry"),
31 message: TrimmedNonEmptyString,
32 index: Schema.Number,
33});
34
35export const ServerConfigIssue = Schema.Union([
36 KeybindingsMalformedConfigIssue,
37 KeybindingsInvalidEntryIssue,
38]);
39export type ServerConfigIssue = typeof ServerConfigIssue.Type;
40
41const ServerConfigIssues = Schema.Array(ServerConfigIssue);
42
43export const ServerProviderState = Schema.Literals(["ready", "warning", "error", "disabled"]);
44export type ServerProviderState = typeof ServerProviderState.Type;
45
46export const ServerProviderAuthStatus = Schema.Literals([
47 "authenticated",
48 "unauthenticated",
49 "unknown",
50]);
51export type ServerProviderAuthStatus = typeof ServerProviderAuthStatus.Type;
52
53export const ServerProviderAuth = Schema.Struct({
54 status: ServerProviderAuthStatus,
55 type: Schema.optional(TrimmedNonEmptyString),
56 label: Schema.optional(TrimmedNonEmptyString),
57 email: Schema.optional(TrimmedNonEmptyString),
58});
59export type ServerProviderAuth = typeof ServerProviderAuth.Type;
60
61export const ServerProviderModel = Schema.Struct({
62 slug: TrimmedNonEmptyString,
63 name: TrimmedNonEmptyString,
64 shortName: Schema.optional(TrimmedNonEmptyString),
65 subProvider: Schema.optional(TrimmedNonEmptyString),
66 isCustom: Schema.Boolean,
67 capabilities: Schema.NullOr(ModelCapabilities),
68});
69export type ServerProviderModel = typeof ServerProviderModel.Type;
70
71export const ServerProviderSlashCommandInput = Schema.Struct({
72 hint: TrimmedNonEmptyString,
73});
74export type ServerProviderSlashCommandInput = typeof ServerProviderSlashCommandInput.Type;
75
76export const ServerProviderSlashCommand = Schema.Struct({
77 name: TrimmedNonEmptyString,
78 description: Schema.optional(TrimmedNonEmptyString),
79 input: Schema.optional(ServerProviderSlashCommandInput),
80});
81export type ServerProviderSlashCommand = typeof ServerProviderSlashCommand.Type;
82
83export const ServerProviderSkill = Schema.Struct({
84 name: TrimmedNonEmptyString,
85 description: Schema.optional(TrimmedNonEmptyString),
86 path: TrimmedNonEmptyString,
87 scope: Schema.optional(TrimmedNonEmptyString),
88 enabled: Schema.Boolean,
89 displayName: Schema.optional(TrimmedNonEmptyString),
90 shortDescription: Schema.optional(TrimmedNonEmptyString),
91});
92export type ServerProviderSkill = typeof ServerProviderSkill.Type;
93
94/**
95 * Availability of a configured provider instance from the runtime's POV.
96 *
97 * - `available` — the build ships this driver and an instance is wired
98 * up. Default for legacy snapshots produced from the closed
99 * `ServerSettings.providers` map.
100 * - `unavailable` — the user's `ServerSettings.providerInstances` (or a
101 * persisted thread / session binding) references a driver this build
102 * doesn't ship. Common after rolling back from a fork or PR branch
103 * that introduced a new driver. The snapshot is preserved so the UI
104 * can render "missing driver" affordances and so the data round-trips
105 * when the user moves back to the fork.
106 *
107 * Snapshots with `availability: "unavailable"` MUST set
108 * `installed: false` and `enabled: false`; the runtime refuses turn
109 * starts against them with a structured error.
110 */
111export const ServerProviderAvailability = Schema.Literals(["available", "unavailable"]);
112export type ServerProviderAvailability = typeof ServerProviderAvailability.Type;
113
114export const ServerProviderContinuation = Schema.Struct({
115 groupKey: TrimmedNonEmptyString,
116});
117export type ServerProviderContinuation = typeof ServerProviderContinuation.Type;
118
119export const ServerProviderVersionAdvisoryStatus = Schema.Literals([
120 "unknown",
121 "current",
122 "behind_latest",
123]);
124export type ServerProviderVersionAdvisoryStatus = typeof ServerProviderVersionAdvisoryStatus.Type;
125
126export const ServerProviderVersionAdvisory = Schema.Struct({
127 status: ServerProviderVersionAdvisoryStatus,
128 currentVersion: Schema.NullOr(TrimmedNonEmptyString),
129 latestVersion: Schema.NullOr(TrimmedNonEmptyString),
130 updateCommand: Schema.NullOr(TrimmedNonEmptyString),
131 canUpdate: Schema.Boolean.pipe(Schema.withDecodingDefault(Effect.succeed(false))),
132 checkedAt: Schema.NullOr(IsoDateTime),
133 message: Schema.NullOr(TrimmedNonEmptyString),
134});
135export type ServerProviderVersionAdvisory = typeof ServerProviderVersionAdvisory.Type;
136
137export const ServerProviderUpdateStatus = Schema.Literals([
138 "idle",
139 "queued",
140 "running",
141 "succeeded",
142 "failed",
143 "unchanged",
144]);
145export type ServerProviderUpdateStatus = typeof ServerProviderUpdateStatus.Type;
146
147export const ServerProviderUpdateState = Schema.Struct({
148 status: ServerProviderUpdateStatus,
149 startedAt: Schema.NullOr(IsoDateTime),
150 finishedAt: Schema.NullOr(IsoDateTime),
151 message: Schema.NullOr(TrimmedNonEmptyString),
152 output: Schema.NullOr(Schema.String.check(Schema.isMaxLength(10_000))),
153});
154export type ServerProviderUpdateState = typeof ServerProviderUpdateState.Type;
155
156export const ServerProvider = Schema.Struct({
157 // Routing key for the configured instance this snapshot represents. This
158 // is the only stable identity consumers may use for provider routing.
159 instanceId: ProviderInstanceId,
160 // Open driver kind slug that selects the implementation handling this
161 // instance. It is metadata/capability context, not a routing key.
162 driver: ProviderDriverKind,
163 displayName: Schema.optional(TrimmedNonEmptyString),
164 accentColor: Schema.optional(TrimmedNonEmptyString),
165 badgeLabel: Schema.optional(TrimmedNonEmptyString),
166 continuation: Schema.optional(ServerProviderContinuation),
167 showInteractionModeToggle: Schema.optional(Schema.Boolean),
168 requiresNewThreadForModelChange: Schema.optional(Schema.Boolean),
169 enabled: Schema.Boolean,
170 installed: Schema.Boolean,
171 version: Schema.NullOr(TrimmedNonEmptyString),
172 status: ServerProviderState,
173 auth: ServerProviderAuth,
174 checkedAt: IsoDateTime,
175 message: Schema.optional(TrimmedNonEmptyString),
176 // Optional for back-compat: every legacy producer omits this field and
177 // an absent value is interpreted as `"available"` by consumers (see
178 // `isProviderAvailable`). New `ProviderInstanceRegistry` outputs set it
179 // explicitly so the UI can render unavailable shadows from
180 // `ServerSettings.providerInstances`.
181 availability: Schema.optional(ServerProviderAvailability),
182 // Human-readable reason populated when `availability === "unavailable"`.
183 // Surfaces in the UI alongside the missing-driver affordance.
184 unavailableReason: Schema.optional(TrimmedNonEmptyString),
185 models: Schema.Array(ServerProviderModel),
186 slashCommands: Schema.Array(ServerProviderSlashCommand).pipe(
187 Schema.withDecodingDefault(Effect.succeed([])),
188 ),
189 skills: Schema.Array(ServerProviderSkill).pipe(Schema.withDecodingDefault(Effect.succeed([]))),
190 versionAdvisory: Schema.optionalKey(ServerProviderVersionAdvisory),
191 updateState: Schema.optionalKey(ServerProviderUpdateState),
192});
193export type ServerProvider = typeof ServerProvider.Type;
194
195export const ServerProviders = Schema.Array(ServerProvider);
196export type ServerProviders = typeof ServerProviders.Type;
197
198/**
199 * Treat the optional `availability` as "available" when absent. This is
200 * the rule legacy producers (which omit the field) and new producers
201 * (which set it explicitly) agree on so consumers never have to thread
202 * `?? "available"` defaults through their code paths.
203 */
204export const isProviderAvailable = (snapshot: ServerProvider): boolean =>
205 snapshot.availability !== "unavailable";
206
207export const ServerObservability = Schema.Struct({
208 logsDirectoryPath: TrimmedNonEmptyString,
209 localTracingEnabled: Schema.Boolean,
210 otlpTracesUrl: Schema.optional(TrimmedNonEmptyString),
211 otlpTracesEnabled: Schema.Boolean,
212 otlpMetricsUrl: Schema.optional(TrimmedNonEmptyString),
213 otlpMetricsEnabled: Schema.Boolean,
214});
215export type ServerObservability = typeof ServerObservability.Type;
216
217export const ServerTraceDiagnosticsErrorKind = Schema.Literals([
218 "trace-file-not-found",
219 "trace-file-read-failed",
220]);
221export type ServerTraceDiagnosticsErrorKind = typeof ServerTraceDiagnosticsErrorKind.Type;
222
223export const ServerTraceDiagnosticsSpanSummary = Schema.Struct({
224 name: TrimmedNonEmptyString,
225 count: NonNegativeInt,
226 failureCount: NonNegativeInt,
227 totalDurationMs: Schema.Number,
228 averageDurationMs: Schema.Number,
229 maxDurationMs: Schema.Number,
230});
231export type ServerTraceDiagnosticsSpanSummary = typeof ServerTraceDiagnosticsSpanSummary.Type;
232
233export const ServerTraceDiagnosticsFailureSummary = Schema.Struct({
234 name: TrimmedNonEmptyString,
235 cause: TrimmedNonEmptyString,
236 count: NonNegativeInt,
237 lastSeenAt: Schema.DateTimeUtc,
238 traceId: TrimmedNonEmptyString,
239 spanId: TrimmedNonEmptyString,
240});
241export type ServerTraceDiagnosticsFailureSummary = typeof ServerTraceDiagnosticsFailureSummary.Type;
242
243export const ServerTraceDiagnosticsRecentFailure = Schema.Struct({
244 name: TrimmedNonEmptyString,
245 cause: TrimmedNonEmptyString,
246 durationMs: Schema.Number,
247 endedAt: Schema.DateTimeUtc,
248 traceId: TrimmedNonEmptyString,
249 spanId: TrimmedNonEmptyString,
250});
251export type ServerTraceDiagnosticsRecentFailure = typeof ServerTraceDiagnosticsRecentFailure.Type;
252
253export const ServerTraceDiagnosticsSpanOccurrence = Schema.Struct({
254 name: TrimmedNonEmptyString,
255 durationMs: Schema.Number,
256 endedAt: Schema.DateTimeUtc,
257 traceId: TrimmedNonEmptyString,
258 spanId: TrimmedNonEmptyString,
259});
260export type ServerTraceDiagnosticsSpanOccurrence = typeof ServerTraceDiagnosticsSpanOccurrence.Type;
261
262export const ServerTraceDiagnosticsLogEvent = Schema.Struct({
263 spanName: TrimmedNonEmptyString,
264 level: TrimmedNonEmptyString,
265 message: TrimmedNonEmptyString,
266 seenAt: Schema.DateTimeUtc,
267 traceId: TrimmedNonEmptyString,
268 spanId: TrimmedNonEmptyString,
269});
270export type ServerTraceDiagnosticsLogEvent = typeof ServerTraceDiagnosticsLogEvent.Type;
271
272export const ServerTraceDiagnosticsResult = Schema.Struct({
273 traceFilePath: TrimmedNonEmptyString,
274 scannedFilePaths: Schema.Array(TrimmedNonEmptyString),
275 readAt: Schema.DateTimeUtc,
276 recordCount: NonNegativeInt,
277 parseErrorCount: NonNegativeInt,
278 firstSpanAt: Schema.Option(Schema.DateTimeUtc),
279 lastSpanAt: Schema.Option(Schema.DateTimeUtc),
280 failureCount: NonNegativeInt,
281 interruptionCount: NonNegativeInt,
282 slowSpanThresholdMs: NonNegativeInt,
283 slowSpanCount: NonNegativeInt,
284 logLevelCounts: Schema.Record(TrimmedNonEmptyString, NonNegativeInt),
285 topSpansByCount: Schema.Array(ServerTraceDiagnosticsSpanSummary),
286 slowestSpans: Schema.Array(ServerTraceDiagnosticsSpanOccurrence),
287 commonFailures: Schema.Array(ServerTraceDiagnosticsFailureSummary),
288 latestFailures: Schema.Array(ServerTraceDiagnosticsRecentFailure),
289 latestWarningAndErrorLogs: Schema.Array(ServerTraceDiagnosticsLogEvent),
290 partialFailure: Schema.Option(Schema.Boolean),
291 error: Schema.Option(
292 Schema.Struct({
293 kind: ServerTraceDiagnosticsErrorKind,
294 message: TrimmedNonEmptyString,
295 }),
296 ),
297});
298export type ServerTraceDiagnosticsResult = typeof ServerTraceDiagnosticsResult.Type;
299
300export const ServerProcessSignal = Schema.Literals(["SIGINT", "SIGKILL"]);
301export type ServerProcessSignal = typeof ServerProcessSignal.Type;
302
303export const ServerProcessDiagnosticsEntry = Schema.Struct({
304 pid: PositiveInt,
305 ppid: NonNegativeInt,
306 pgid: Schema.Option(Schema.Int),
307 status: TrimmedNonEmptyString,
308 cpuPercent: Schema.Number,
309 rssBytes: NonNegativeInt,
310 elapsed: TrimmedNonEmptyString,
311 command: TrimmedNonEmptyString,
312 depth: NonNegativeInt,
313 childPids: Schema.Array(PositiveInt),
314});
315export type ServerProcessDiagnosticsEntry = typeof ServerProcessDiagnosticsEntry.Type;
316
317export const ServerProcessDiagnosticsResult = Schema.Struct({
318 serverPid: PositiveInt,
319 readAt: Schema.DateTimeUtc,
320 processCount: NonNegativeInt,
321 totalRssBytes: NonNegativeInt,
322 totalCpuPercent: Schema.Number,
323 processes: Schema.Array(ServerProcessDiagnosticsEntry),
324 error: Schema.Option(
325 Schema.Struct({
326 message: TrimmedNonEmptyString,
327 }),
328 ),
329});
330export type ServerProcessDiagnosticsResult = typeof ServerProcessDiagnosticsResult.Type;
331
332export const ServerProcessResourceHistoryInput = Schema.Struct({
333 windowMs: NonNegativeInt,
334 bucketMs: NonNegativeInt,
335});
336export type ServerProcessResourceHistoryInput = typeof ServerProcessResourceHistoryInput.Type;
337
338export const ServerProcessResourceHistoryBucket = Schema.Struct({
339 startedAt: Schema.DateTimeUtc,
340 endedAt: Schema.DateTimeUtc,
341 avgCpuPercent: Schema.Number,
342 maxCpuPercent: Schema.Number,
343 maxRssBytes: NonNegativeInt,
344 maxProcessCount: NonNegativeInt,
345});
346export type ServerProcessResourceHistoryBucket = typeof ServerProcessResourceHistoryBucket.Type;
347
348export const ServerProcessResourceHistorySummary = Schema.Struct({
349 processKey: TrimmedNonEmptyString,
350 pid: PositiveInt,
351 ppid: NonNegativeInt,
352 command: TrimmedNonEmptyString,
353 depth: NonNegativeInt,
354 isServerRoot: Schema.Boolean,
355 firstSeenAt: Schema.DateTimeUtc,
356 lastSeenAt: Schema.DateTimeUtc,
357 currentCpuPercent: Schema.Number,
358 avgCpuPercent: Schema.Number,
359 maxCpuPercent: Schema.Number,
360 cpuSecondsApprox: Schema.Number,
361 currentRssBytes: NonNegativeInt,
362 maxRssBytes: NonNegativeInt,
363 sampleCount: NonNegativeInt,
364});
365export type ServerProcessResourceHistorySummary = typeof ServerProcessResourceHistorySummary.Type;
366
367export const ServerProcessResourceHistoryFailureTag = Schema.Literals([
368 "ProcessDiagnosticsQueryTimeoutError",
369 "ProcessDiagnosticsQueryFailedError",
370 "ProcessDiagnosticsServerProcessSignalError",
371 "ProcessDiagnosticsNotDescendantError",
372 "ProcessDiagnosticsSignalFailedError",
373]);
374export type ServerProcessResourceHistoryFailureTag =
375 typeof ServerProcessResourceHistoryFailureTag.Type;
376
377export const ServerProcessResourceHistoryResult = Schema.Struct({
378 readAt: Schema.DateTimeUtc,
379 windowMs: NonNegativeInt,
380 bucketMs: NonNegativeInt,
381 sampleIntervalMs: NonNegativeInt,
382 retainedSampleCount: NonNegativeInt,
383 totalCpuSecondsApprox: Schema.Number,
384 buckets: Schema.Array(ServerProcessResourceHistoryBucket),
385 topProcesses: Schema.Array(ServerProcessResourceHistorySummary),
386 error: Schema.Option(
387 Schema.Struct({
388 failureTag: ServerProcessResourceHistoryFailureTag,
389 message: TrimmedNonEmptyString,
390 }),
391 ),
392});
393export type ServerProcessResourceHistoryResult = typeof ServerProcessResourceHistoryResult.Type;
394
395export const ServerSignalProcessInput = Schema.Struct({
396 pid: PositiveInt,
397 signal: ServerProcessSignal,
398});
399export type ServerSignalProcessInput = typeof ServerSignalProcessInput.Type;
400
401export const ServerSignalProcessResult = Schema.Struct({
402 pid: PositiveInt,
403 signal: ServerProcessSignal,
404 signaled: Schema.Boolean,
405 message: Schema.Option(TrimmedNonEmptyString),
406});
407export type ServerSignalProcessResult = typeof ServerSignalProcessResult.Type;
408
409export const ServerConfig = Schema.Struct({
410 environment: ExecutionEnvironmentDescriptor,
411 auth: ServerAuthDescriptor,
412 cwd: TrimmedNonEmptyString,
413 keybindingsConfigPath: TrimmedNonEmptyString,
414 keybindings: ResolvedKeybindingsConfig,
415 issues: ServerConfigIssues,
416 providers: ServerProviders,
417 availableEditors: Schema.Array(EditorId),
418 observability: ServerObservability,
419 settings: ServerSettings,
420 /** Whether shell subscriptions can emit an opt-in catch-up completion marker. */
421 shellResumeCompletionMarker: Schema.optionalKey(Schema.Boolean),
422 /** Whether thread subscriptions can emit an opt-in catch-up completion marker. */
423 threadResumeCompletionMarker: Schema.optionalKey(Schema.Boolean),
424});
425export type ServerConfig = typeof ServerConfig.Type;
426
427const ServerUpsertKeybindingReplaceTarget = Schema.Struct({
428 key: KeybindingValue,
429 command: KeybindingCommand,
430 when: Schema.optional(KeybindingWhen),
431});
432
433export const ServerUpsertKeybindingInput = Schema.Struct({
434 key: KeybindingValue,
435 command: KeybindingCommand,
436 when: Schema.optional(KeybindingWhen),
437 replace: Schema.optional(ServerUpsertKeybindingReplaceTarget),
438});
439export type ServerUpsertKeybindingInput = typeof ServerUpsertKeybindingInput.Type;
440
441export const ServerRemoveKeybindingInput = ServerUpsertKeybindingReplaceTarget;
442export type ServerRemoveKeybindingInput = typeof ServerRemoveKeybindingInput.Type;
443
444export const ServerUpsertKeybindingResult = Schema.Struct({
445 keybindings: ResolvedKeybindingsConfig,
446 issues: ServerConfigIssues,
447});
448export type ServerUpsertKeybindingResult = typeof ServerUpsertKeybindingResult.Type;
449
450export const ServerRemoveKeybindingResult = ServerUpsertKeybindingResult;
451export type ServerRemoveKeybindingResult = typeof ServerRemoveKeybindingResult.Type;
452
453export const ServerConfigUpdatedPayload = Schema.Struct({
454 issues: ServerConfigIssues,
455 providers: ServerProviders,
456 settings: Schema.optional(ServerSettings),
457});
458export type ServerConfigUpdatedPayload = typeof ServerConfigUpdatedPayload.Type;
459
460export const ServerConfigKeybindingsUpdatedPayload = Schema.Struct({
461 keybindings: ResolvedKeybindingsConfig,
462 issues: ServerConfigIssues,
463});
464export type ServerConfigKeybindingsUpdatedPayload =
465 typeof ServerConfigKeybindingsUpdatedPayload.Type;
466
467export const ServerConfigProviderStatusesPayload = Schema.Struct({
468 providers: ServerProviders,
469});
470export type ServerConfigProviderStatusesPayload = typeof ServerConfigProviderStatusesPayload.Type;
471
472export const ServerConfigSettingsUpdatedPayload = Schema.Struct({
473 settings: ServerSettings,
474});
475export type ServerConfigSettingsUpdatedPayload = typeof ServerConfigSettingsUpdatedPayload.Type;
476
477export const ServerConfigStreamSnapshotEvent = Schema.Struct({
478 version: Schema.Literal(1),
479 type: Schema.Literal("snapshot"),
480 config: ServerConfig,
481});
482export type ServerConfigStreamSnapshotEvent = typeof ServerConfigStreamSnapshotEvent.Type;
483
484export const ServerConfigStreamKeybindingsUpdatedEvent = Schema.Struct({
485 version: Schema.Literal(1),
486 type: Schema.Literal("keybindingsUpdated"),
487 payload: ServerConfigKeybindingsUpdatedPayload,
488});
489export type ServerConfigStreamKeybindingsUpdatedEvent =
490 typeof ServerConfigStreamKeybindingsUpdatedEvent.Type;
491
492export const ServerConfigStreamProviderStatusesEvent = Schema.Struct({
493 version: Schema.Literal(1),
494 type: Schema.Literal("providerStatuses"),
495 payload: ServerConfigProviderStatusesPayload,
496});
497export type ServerConfigStreamProviderStatusesEvent =
498 typeof ServerConfigStreamProviderStatusesEvent.Type;
499
500export const ServerConfigStreamSettingsUpdatedEvent = Schema.Struct({
501 version: Schema.Literal(1),
502 type: Schema.Literal("settingsUpdated"),
503 payload: ServerConfigSettingsUpdatedPayload,
504});
505export type ServerConfigStreamSettingsUpdatedEvent =
506 typeof ServerConfigStreamSettingsUpdatedEvent.Type;
507
508export const ServerConfigStreamEvent = Schema.Union([
509 ServerConfigStreamSnapshotEvent,
510 ServerConfigStreamKeybindingsUpdatedEvent,
511 ServerConfigStreamProviderStatusesEvent,
512 ServerConfigStreamSettingsUpdatedEvent,
513]);
514export type ServerConfigStreamEvent = typeof ServerConfigStreamEvent.Type;
515
516export const ServerLifecycleReadyPayload = Schema.Struct({
517 at: IsoDateTime,
518 environment: ExecutionEnvironmentDescriptor,
519});
520export type ServerLifecycleReadyPayload = typeof ServerLifecycleReadyPayload.Type;
521
522export const ServerLifecycleWelcomePayload = Schema.Struct({
523 environment: ExecutionEnvironmentDescriptor,
524 cwd: TrimmedNonEmptyString,
525 projectName: TrimmedNonEmptyString,
526 bootstrapProjectId: Schema.optional(ProjectId),
527 bootstrapThreadId: Schema.optional(ThreadId),
528});
529export type ServerLifecycleWelcomePayload = typeof ServerLifecycleWelcomePayload.Type;
530
531export const ServerLifecycleStreamWelcomeEvent = Schema.Struct({
532 version: Schema.Literal(1),
533 sequence: NonNegativeInt,
534 type: Schema.Literal("welcome"),
535 payload: ServerLifecycleWelcomePayload,
536});
537export type ServerLifecycleStreamWelcomeEvent = typeof ServerLifecycleStreamWelcomeEvent.Type;
538
539export const ServerLifecycleStreamReadyEvent = Schema.Struct({
540 version: Schema.Literal(1),
541 sequence: NonNegativeInt,
542 type: Schema.Literal("ready"),
543 payload: ServerLifecycleReadyPayload,
544});
545export type ServerLifecycleStreamReadyEvent = typeof ServerLifecycleStreamReadyEvent.Type;
546
547export const ServerLifecycleStreamEvent = Schema.Union([
548 ServerLifecycleStreamWelcomeEvent,
549 ServerLifecycleStreamReadyEvent,
550]);
551export type ServerLifecycleStreamEvent = typeof ServerLifecycleStreamEvent.Type;
552
553export const ServerProviderUpdatedPayload = Schema.Struct({
554 providers: ServerProviders,
555});
556export type ServerProviderUpdatedPayload = typeof ServerProviderUpdatedPayload.Type;
557
558export const ServerProviderUpdateInput = Schema.Struct({
559 provider: ProviderDriverKind,
560 instanceId: Schema.optionalKey(ProviderInstanceId),
561});
562export type ServerProviderUpdateInput = typeof ServerProviderUpdateInput.Type;
563
564export class ServerProviderUpdateError extends Schema.TaggedErrorClass<ServerProviderUpdateError>()(
565 "ServerProviderUpdateError",
566 {
567 provider: ProviderDriverKind,
568 reason: TrimmedNonEmptyString,
569 cause: Schema.optional(Schema.Defect()),
570 },
571) {
572 override get message(): string {
573 return `Provider update failed for ${this.provider}: ${this.reason}`;
574 }
575}