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});
21
22/**
23 * Where a new thread runs: the project's current checkout ("local") or a
24 * fresh git worktree ("worktree"). Lives here (not settings.ts) so
25 * orchestration contracts can reference it without an import cycle.
26 */
27export const ThreadEnvMode = Schema.Literals(["local", "worktree"]);
28export type ThreadEnvMode = typeof ThreadEnvMode.Type;
29export type ExecutionEnvironmentPlatform = typeof ExecutionEnvironmentPlatform.Type;
30
31/** How a server can replace itself with another version when asked over RPC.
32 New servers only advertise the stable launcher-backed "boot-service" path;
33 "respawn" remains decodable for compatibility with older servers. */
34export const ServerSelfUpdateMethod = Schema.Literals(["boot-service", "respawn"]);
35export type ServerSelfUpdateMethod = typeof ServerSelfUpdateMethod.Type;
36
37/** What update path a client should offer for a server: one of the RPC
38 self-update methods above, or "desktop-managed" when the backend's
39 version belongs to the T3 Code desktop app supervising it — updating the
40 app on that machine is the only way to update the server. */
41export const ServerSelfUpdateCapability = Schema.Literals([
42 "boot-service",
43 "respawn",
44 "desktop-managed",
45]);
46export type ServerSelfUpdateCapability = typeof ServerSelfUpdateCapability.Type;
47
48export const ExecutionEnvironmentCapabilities = Schema.Struct({
49 repositoryIdentity: Schema.Boolean.pipe(Schema.withDecodingDefault(Effect.succeed(false))),
50 connectionProbe: Schema.optionalKey(Schema.Boolean),
51 /** Missing on older servers, which still accept inline image attachments. */
52 attachmentUploads: Schema.optionalKey(Schema.Boolean),
53 /** Missing on servers that only accept image attachments. */
54 fileAttachments: Schema.optionalKey(
55 Schema.Struct({
56 maxUploadBytes: Schema.Int.check(Schema.isGreaterThanOrEqualTo(1)),
57 }),
58 ),
59 /** Server exposes the pull-request list, detail, activity, diff, and mutation APIs. Absent on
60 servers from before the pull-request workspace shipped, so clients must not probe them. */
61 pullRequests: Schema.optionalKey(Schema.Boolean),
62 /** Server understands thread.settle / thread.unsettle commands. Absent on
63 pre-settlement servers, so clients treat missing as unsupported and
64 never send the commands under version skew. */
65 threadSettlement: Schema.optionalKey(Schema.Boolean),
66 /** Server understands thread.snooze / thread.unsnooze commands. Same
67 version-skew contract as threadSettlement. */
68 threadSnooze: Schema.optionalKey(Schema.Boolean),
69 /** Server streams themes an environment publishes. Absent on servers from
70 before environment themes shipped, which never emit the events -- so a
71 client reconnecting to one must drop published themes rather than keep
72 showing a set nothing will ever update. */
73 environmentThemes: Schema.optionalKey(Schema.Boolean),
74 /** Server understands thread.pin / thread.unpin commands. Same
75 version-skew contract as threadSettlement. */
76 threadPinning: Schema.optionalKey(Schema.Boolean),
77 /** Server understands thread.pin.reorder (and orderKey on thread.pin).
78 Same version-skew contract as threadSettlement. */
79 threadPinReorder: Schema.optionalKey(Schema.Boolean),
80 /** Server understands regenerateTitle on thread.meta.update. Absent on
81 older servers, so clients hide the action instead of sending it. */
82 threadTitleRegeneration: Schema.optionalKey(Schema.Boolean),
83 /** Server persists a pull request reference on thread.meta.update. */
84 threadPullRequestLinking: Schema.optionalKey(Schema.Boolean),
85 /** The update path clients should offer for this server. Absent on
86 servers that must be relaunched manually (dev checkouts, Windows
87 foreground runs, pre-update servers). */
88 serverSelfUpdate: Schema.optionalKey(ServerSelfUpdateCapability),
89 /** Server can stream self-update progress before acknowledging the
90 restart. Clients fall back to server.updateServer when absent. */
91 serverSelfUpdateProgress: Schema.optionalKey(Schema.Boolean),
92 /** Agent-activity publishes (push notifications and Live Activities)
93 currently leave this environment: the publish opt-in is enabled and the
94 relay link credentials exist. Clients skip seeding a Live Activity when
95 this is false — no update would ever repaint it. Absent on older
96 servers, which may still publish, so only an explicit false skips. */
97 agentActivityPublishing: Schema.optionalKey(Schema.Boolean),
98});
99export type ExecutionEnvironmentCapabilities = typeof ExecutionEnvironmentCapabilities.Type;
100
101export const ExecutionEnvironmentDescriptor = Schema.Struct({
102 environmentId: EnvironmentId,
103 label: TrimmedNonEmptyString,
104 platform: ExecutionEnvironmentPlatform,
105 serverVersion: TrimmedNonEmptyString,
106 capabilities: ExecutionEnvironmentCapabilities,
107});
108export type ExecutionEnvironmentDescriptor = typeof ExecutionEnvironmentDescriptor.Type;
109
110export const EnvironmentConnectionState = Schema.Literals([
111 "connecting",
112 "connected",
113 "disconnected",
114 "error",
115]);
116export type EnvironmentConnectionState = typeof EnvironmentConnectionState.Type;
117
118export const RepositoryIdentityLocator = Schema.Struct({
119 source: Schema.Literal("git-remote"),
120 remoteName: TrimmedNonEmptyString,
121 remoteUrl: TrimmedNonEmptyString,
122});
123export type RepositoryIdentityLocator = typeof RepositoryIdentityLocator.Type;
124
125export const RepositoryIdentity = Schema.Struct({
126 canonicalKey: TrimmedNonEmptyString,
127 locator: RepositoryIdentityLocator,
128 rootPath: Schema.optionalKey(TrimmedNonEmptyString),
129 displayName: Schema.optionalKey(TrimmedNonEmptyString),
130 provider: Schema.optionalKey(TrimmedNonEmptyString),
131 owner: Schema.optionalKey(TrimmedNonEmptyString),
132 name: Schema.optionalKey(TrimmedNonEmptyString),
133});
134export type RepositoryIdentity = typeof RepositoryIdentity.Type;
135
136export const ScopedProjectRef = Schema.Struct({
137 environmentId: EnvironmentId,
138 projectId: ProjectId,
139});
140export type ScopedProjectRef = typeof ScopedProjectRef.Type;
141
142export const ScopedThreadRef = Schema.Struct({
143 environmentId: EnvironmentId,
144 threadId: ThreadId,
145});
146export type ScopedThreadRef = typeof ScopedThreadRef.Type;
147
148export const ScopedThreadSessionRef = Schema.Struct({
149 environmentId: EnvironmentId,
150 threadId: ThreadId,
151});
152export type ScopedThreadSessionRef = typeof ScopedThreadSessionRef.Type;