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 thread.visit / thread.mark-unread commands and
51 projects lastVisitedAt on thread shells. Same version-skew contract as
52 threadSettlement: clients keep their local visited state against
53 servers that lack this. */
54 threadVisitedTracking: Schema.optionalKey(Schema.Boolean),
55 /** Server understands regenerateTitle on thread.meta.update. Absent on
56 older servers, so clients hide the action instead of sending it. */
57 threadTitleRegeneration: Schema.optionalKey(Schema.Boolean),
58 /** The update path clients should offer for this server. Absent on
59 servers that must be relaunched manually (dev checkouts, Windows
60 foreground runs, pre-update servers). */
61 serverSelfUpdate: Schema.optionalKey(ServerSelfUpdateCapability),
62 /** Server can stream self-update progress before acknowledging the
63 restart. Clients fall back to server.updateServer when absent. */
64 serverSelfUpdateProgress: Schema.optionalKey(Schema.Boolean),
65});
66export type ExecutionEnvironmentCapabilities = typeof ExecutionEnvironmentCapabilities.Type;
67
68export const ExecutionEnvironmentDescriptor = Schema.Struct({
69 environmentId: EnvironmentId,
70 label: TrimmedNonEmptyString,
71 platform: ExecutionEnvironmentPlatform,
72 serverVersion: TrimmedNonEmptyString,
73 capabilities: ExecutionEnvironmentCapabilities,
74});
75export type ExecutionEnvironmentDescriptor = typeof ExecutionEnvironmentDescriptor.Type;
76
77export const EnvironmentConnectionState = Schema.Literals([
78 "connecting",
79 "connected",
80 "disconnected",
81 "error",
82]);
83export type EnvironmentConnectionState = typeof EnvironmentConnectionState.Type;
84
85export const RepositoryIdentityLocator = Schema.Struct({
86 source: Schema.Literal("git-remote"),
87 remoteName: TrimmedNonEmptyString,
88 remoteUrl: TrimmedNonEmptyString,
89});
90export type RepositoryIdentityLocator = typeof RepositoryIdentityLocator.Type;
91
92export const RepositoryIdentity = Schema.Struct({
93 canonicalKey: TrimmedNonEmptyString,
94 locator: RepositoryIdentityLocator,
95 rootPath: Schema.optionalKey(TrimmedNonEmptyString),
96 displayName: Schema.optionalKey(TrimmedNonEmptyString),
97 provider: Schema.optionalKey(TrimmedNonEmptyString),
98 owner: Schema.optionalKey(TrimmedNonEmptyString),
99 name: Schema.optionalKey(TrimmedNonEmptyString),
100});
101export type RepositoryIdentity = typeof RepositoryIdentity.Type;
102
103export const ScopedProjectRef = Schema.Struct({
104 environmentId: EnvironmentId,
105 projectId: ProjectId,
106});
107export type ScopedProjectRef = typeof ScopedProjectRef.Type;
108
109export const ScopedThreadRef = Schema.Struct({
110 environmentId: EnvironmentId,
111 threadId: ThreadId,
112});
113export type ScopedThreadRef = typeof ScopedThreadRef.Type;
114
115export const ScopedThreadSessionRef = Schema.Struct({
116 environmentId: EnvironmentId,
117 threadId: ThreadId,
118});
119export type ScopedThreadSessionRef = typeof ScopedThreadSessionRef.Type;