Open History to see the last commit
1import * as Effect from "effect/Effect";
2import * as Schema from "effect/Schema";
3
4import { EnvironmentId, ProjectId, ThreadId, TrimmedNonEmptyString } from "./baseSchemas.ts";
5
6export const ExecutionEnvironmentPlatformOs = Schema.Literals([
7 "darwin",
8 "linux",
9 "windows",
10 "unknown",
11]);
12export type ExecutionEnvironmentPlatformOs = typeof ExecutionEnvironmentPlatformOs.Type;
13
14export const ExecutionEnvironmentPlatformArch = Schema.Literals(["arm64", "x64", "other"]);
15export type ExecutionEnvironmentPlatformArch = typeof ExecutionEnvironmentPlatformArch.Type;
16
17export const ExecutionEnvironmentPlatform = Schema.Struct({
18 os: ExecutionEnvironmentPlatformOs,
19 arch: ExecutionEnvironmentPlatformArch,
20});
21export type ExecutionEnvironmentPlatform = typeof ExecutionEnvironmentPlatform.Type;
22
23/** How a server can replace itself with another version when asked over RPC:
24 "boot-service" rewrites the systemd user unit and restarts it; "respawn"
25 installs the target version and respawns the foreground process. */
26export const ServerSelfUpdateMethod = Schema.Literals(["boot-service", "respawn"]);
27export type ServerSelfUpdateMethod = typeof ServerSelfUpdateMethod.Type;
28
29/** What update path a client should offer for a server: one of the RPC
30 self-update methods above, or "desktop-managed" when the backend's
31 version belongs to the T3 Code desktop app supervising it — updating the
32 app on that machine is the only way to update the server. */
33export const ServerSelfUpdateCapability = Schema.Literals([
34 "boot-service",
35 "respawn",
36 "desktop-managed",
37]);
38export type ServerSelfUpdateCapability = typeof ServerSelfUpdateCapability.Type;
39
40export const ExecutionEnvironmentCapabilities = Schema.Struct({
41 repositoryIdentity: Schema.Boolean.pipe(Schema.withDecodingDefault(Effect.succeed(false))),
42 connectionProbe: Schema.optionalKey(Schema.Boolean),
43 /** Server understands thread.settle / thread.unsettle commands. Absent on
44 pre-settlement servers, so clients treat missing as unsupported and
45 never send the commands under version skew. */
46 threadSettlement: Schema.optionalKey(Schema.Boolean),
47 /** Server understands thread.snooze / thread.unsnooze commands. Same
48 version-skew contract as threadSettlement. */
49 threadSnooze: Schema.optionalKey(Schema.Boolean),
50 /** Server understands regenerateTitle on thread.meta.update. Absent on
51 older servers, so clients hide the action instead of sending it. */
52 threadTitleRegeneration: Schema.optionalKey(Schema.Boolean),
53 /** The update path clients should offer for this server. Absent on
54 servers that must be relaunched manually (dev checkouts, Windows
55 foreground runs, pre-update servers). */
56 serverSelfUpdate: Schema.optionalKey(ServerSelfUpdateCapability),
57 /** Server can stream self-update progress before acknowledging the
58 restart. Clients fall back to server.updateServer when absent. */
59 serverSelfUpdateProgress: Schema.optionalKey(Schema.Boolean),
60});
61export type ExecutionEnvironmentCapabilities = typeof ExecutionEnvironmentCapabilities.Type;
62
63export const ExecutionEnvironmentDescriptor = Schema.Struct({
64 environmentId: EnvironmentId,
65 label: TrimmedNonEmptyString,
66 platform: ExecutionEnvironmentPlatform,
67 serverVersion: TrimmedNonEmptyString,
68 capabilities: ExecutionEnvironmentCapabilities,
69});
70export type ExecutionEnvironmentDescriptor = typeof ExecutionEnvironmentDescriptor.Type;
71
72export const EnvironmentConnectionState = Schema.Literals([
73 "connecting",
74 "connected",
75 "disconnected",
76 "error",
77]);
78export type EnvironmentConnectionState = typeof EnvironmentConnectionState.Type;
79
80export const RepositoryIdentityLocator = Schema.Struct({
81 source: Schema.Literal("git-remote"),
82 remoteName: TrimmedNonEmptyString,
83 remoteUrl: TrimmedNonEmptyString,
84});
85export type RepositoryIdentityLocator = typeof RepositoryIdentityLocator.Type;
86
87export const RepositoryIdentity = Schema.Struct({
88 canonicalKey: TrimmedNonEmptyString,
89 locator: RepositoryIdentityLocator,
90 rootPath: Schema.optionalKey(TrimmedNonEmptyString),
91 displayName: Schema.optionalKey(TrimmedNonEmptyString),
92 provider: Schema.optionalKey(TrimmedNonEmptyString),
93 owner: Schema.optionalKey(TrimmedNonEmptyString),
94 name: Schema.optionalKey(TrimmedNonEmptyString),
95});
96export type RepositoryIdentity = typeof RepositoryIdentity.Type;
97
98export const ScopedProjectRef = Schema.Struct({
99 environmentId: EnvironmentId,
100 projectId: ProjectId,
101});
102export type ScopedProjectRef = typeof ScopedProjectRef.Type;
103
104export const ScopedThreadRef = Schema.Struct({
105 environmentId: EnvironmentId,
106 threadId: ThreadId,
107});
108export type ScopedThreadRef = typeof ScopedThreadRef.Type;
109
110export const ScopedThreadSessionRef = Schema.Struct({
111 environmentId: EnvironmentId,
112 threadId: ThreadId,
113});
114export type ScopedThreadSessionRef = typeof ScopedThreadSessionRef.Type;