@treeport/treeport 0.5.0 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/bin/treeport.mjs +26 -1
- package/dist/dist-BsLn2Gbc.js +1630 -0
- package/dist/node/cli/index.js +226 -73
- package/dist/node/server/core/launcher.js +13 -22
- package/dist/node/server/index.js +10440 -5957
- package/dist/node/server/terminal-host-entry.js +962 -0
- package/dist/{shell-integration-Be_c91lw.js → shell-integration-CPmrVa3B.js} +46 -46
- package/dist/terminal-host-protocol-DZkQRAUF.js +378 -0
- package/dist/{update-BW-a6Bd-.js → update-UYS2lMdD.js} +86 -447
- package/dist/web/assets/index-BWYDUD7N.css +2 -0
- package/dist/web/assets/index-C5cx0N4G.js +84 -0
- package/dist/web/index.html +2 -2
- package/drizzle/0010_browser_panels_and_permissions.sql +21 -0
- package/drizzle/0011_free_magdalene.sql +1 -0
- package/drizzle/0012_terminal_host_cutover.sql +41 -0
- package/drizzle/0013_workspace_item_order.sql +13 -0
- package/drizzle/meta/0010_snapshot.json +923 -0
- package/drizzle/meta/0011_snapshot.json +931 -0
- package/drizzle/meta/0012_snapshot.json +919 -0
- package/drizzle/meta/0013_snapshot.json +987 -0
- package/drizzle/meta/_journal.json +28 -0
- package/package.json +21 -13
- package/skills/treeport/SKILL.md +62 -6
- package/dist/web/assets/index-Cr4UkmRD.js +0 -146
- package/dist/web/assets/index-he-SubzL.css +0 -2
|
@@ -0,0 +1,1630 @@
|
|
|
1
|
+
import { Rpc, RpcClient, RpcGroup, RpcSerialization } from "@effect/rpc";
|
|
2
|
+
import * as Schema from "effect/Schema";
|
|
3
|
+
import * as Either from "effect/Either";
|
|
4
|
+
import * as FetchHttpClient from "@effect/platform/FetchHttpClient";
|
|
5
|
+
import * as Layer from "effect/Layer";
|
|
6
|
+
import "effect/Effect";
|
|
7
|
+
import "effect/FiberId";
|
|
8
|
+
import "effect/Queue";
|
|
9
|
+
import "@effect/platform/Socket";
|
|
10
|
+
const BROWSER_MAX_FRAME_BYTES = 8 * 1024 * 1024;
|
|
11
|
+
const BROWSER_MAX_MESSAGE_BYTES = 128 * 1024;
|
|
12
|
+
const opaqueTokenSchema = Schema.String.pipe(Schema.minLength(32), Schema.maxLength(256));
|
|
13
|
+
const browserPanelIdSchema = Schema.String.pipe(Schema.minLength(1), Schema.maxLength(128));
|
|
14
|
+
const browserRequestIdSchema = Schema.String.pipe(Schema.minLength(1), Schema.maxLength(128));
|
|
15
|
+
const browserGenerationSchema = Schema.Int.pipe(Schema.positive());
|
|
16
|
+
const browserRevisionSchema = Schema.NonNegativeInt;
|
|
17
|
+
const browserUrlSchema = Schema.String.pipe(Schema.minLength(1), Schema.maxLength(4096), Schema.filter((value) => {
|
|
18
|
+
if (!URL.canParse(value)) return false;
|
|
19
|
+
const url = new URL(value);
|
|
20
|
+
return (url.protocol === "http:" || url.protocol === "https:") && url.username === "" && url.password === "";
|
|
21
|
+
}, { message: () => "Expected an absolute HTTP or HTTPS URL without credentials" }));
|
|
22
|
+
const browserClientMessageSchema = Schema.Union(Schema.Struct({
|
|
23
|
+
type: Schema.Literal("navigate"),
|
|
24
|
+
url: browserUrlSchema
|
|
25
|
+
}), Schema.Struct({ type: Schema.Literal("back") }), Schema.Struct({ type: Schema.Literal("forward") }), Schema.Struct({ type: Schema.Literal("reload") }), Schema.Struct({ type: Schema.Literal("stop") }), Schema.Struct({
|
|
26
|
+
type: Schema.Literal("resize"),
|
|
27
|
+
width: Schema.Int.pipe(Schema.between(320, 3840)),
|
|
28
|
+
height: Schema.Int.pipe(Schema.between(200, 2160))
|
|
29
|
+
}), Schema.Struct({
|
|
30
|
+
type: Schema.Literal("pointer"),
|
|
31
|
+
phase: Schema.Literal("move", "down", "up"),
|
|
32
|
+
x: Schema.Finite.pipe(Schema.between(0, 3840)),
|
|
33
|
+
y: Schema.Finite.pipe(Schema.between(0, 2160)),
|
|
34
|
+
button: Schema.optional(Schema.Literal("left", "right", "middle"))
|
|
35
|
+
}), Schema.Struct({
|
|
36
|
+
type: Schema.Literal("wheel"),
|
|
37
|
+
deltaX: Schema.Finite.pipe(Schema.between(-1e4, 1e4)),
|
|
38
|
+
deltaY: Schema.Finite.pipe(Schema.between(-1e4, 1e4))
|
|
39
|
+
}), Schema.Struct({
|
|
40
|
+
type: Schema.Literal("key"),
|
|
41
|
+
phase: Schema.Literal("down", "up"),
|
|
42
|
+
key: Schema.String.pipe(Schema.minLength(1), Schema.maxLength(128))
|
|
43
|
+
}), Schema.Struct({
|
|
44
|
+
type: Schema.Literal("insertText"),
|
|
45
|
+
text: Schema.String.pipe(Schema.maxLength(64 * 1024))
|
|
46
|
+
}), Schema.Struct({
|
|
47
|
+
type: Schema.Literal("find"),
|
|
48
|
+
text: Schema.String.pipe(Schema.minLength(1), Schema.maxLength(4096)),
|
|
49
|
+
forward: Schema.Boolean,
|
|
50
|
+
findNext: Schema.Boolean
|
|
51
|
+
}), Schema.Struct({ type: Schema.Literal("stopFind") }), Schema.Struct({ type: Schema.Literal("takeControl") }), Schema.Struct({
|
|
52
|
+
type: Schema.Literal("setVisible"),
|
|
53
|
+
visible: Schema.Boolean
|
|
54
|
+
}), Schema.Struct({ type: Schema.Literal("requestVideoKeyframe") }), Schema.Struct({
|
|
55
|
+
type: Schema.Literal("frameAck"),
|
|
56
|
+
sequence: Schema.Int.pipe(Schema.positive())
|
|
57
|
+
}));
|
|
58
|
+
const browserRuntimeStateSchema = Schema.Struct({
|
|
59
|
+
url: Schema.Union(Schema.Literal("about:blank"), browserUrlSchema),
|
|
60
|
+
title: Schema.String.pipe(Schema.maxLength(256)),
|
|
61
|
+
loading: Schema.Boolean,
|
|
62
|
+
canGoBack: Schema.Boolean,
|
|
63
|
+
canGoForward: Schema.Boolean,
|
|
64
|
+
viewport: Schema.Struct({
|
|
65
|
+
width: Schema.Finite.pipe(Schema.between(0, 3840)),
|
|
66
|
+
height: Schema.Finite.pipe(Schema.between(0, 2160))
|
|
67
|
+
})
|
|
68
|
+
});
|
|
69
|
+
const browserSessionStateSchema = Schema.Struct({
|
|
70
|
+
...browserRuntimeStateSchema.fields,
|
|
71
|
+
controlled: Schema.Boolean,
|
|
72
|
+
hasController: Schema.Boolean,
|
|
73
|
+
controller: Schema.Literal("you", "agent", "other", "none")
|
|
74
|
+
});
|
|
75
|
+
Schema.Union(Schema.Struct({
|
|
76
|
+
type: Schema.Literal("ready"),
|
|
77
|
+
state: browserSessionStateSchema
|
|
78
|
+
}), Schema.Struct({
|
|
79
|
+
type: Schema.Literal("state"),
|
|
80
|
+
state: browserSessionStateSchema
|
|
81
|
+
}), Schema.Struct({
|
|
82
|
+
type: Schema.Literal("controlChanged"),
|
|
83
|
+
state: browserSessionStateSchema
|
|
84
|
+
}), Schema.Struct({
|
|
85
|
+
type: Schema.Literal("navigationError"),
|
|
86
|
+
message: Schema.String
|
|
87
|
+
}), Schema.Struct({
|
|
88
|
+
type: Schema.Literal("browserUnavailable"),
|
|
89
|
+
message: Schema.String,
|
|
90
|
+
installCommand: Schema.NullOr(Schema.String)
|
|
91
|
+
}), Schema.Struct({
|
|
92
|
+
type: Schema.Literal("videoUnavailable"),
|
|
93
|
+
message: Schema.String
|
|
94
|
+
}), Schema.Struct({
|
|
95
|
+
type: Schema.Literal("browserCrashed"),
|
|
96
|
+
message: Schema.String
|
|
97
|
+
}), Schema.Struct({
|
|
98
|
+
type: Schema.Literal("closed"),
|
|
99
|
+
reason: Schema.String
|
|
100
|
+
}));
|
|
101
|
+
const browserVideoFields = {
|
|
102
|
+
mimeType: Schema.Literal("video/vp8"),
|
|
103
|
+
keyframe: Schema.Boolean,
|
|
104
|
+
timestamp: Schema.NonNegativeInt,
|
|
105
|
+
width: Schema.Int.pipe(Schema.between(1, 3840)),
|
|
106
|
+
height: Schema.Int.pipe(Schema.between(1, 2160))
|
|
107
|
+
};
|
|
108
|
+
const browserCaptureMessageSchema = Schema.Struct({
|
|
109
|
+
frame: Schema.NullOr(Schema.Struct({
|
|
110
|
+
...browserVideoFields,
|
|
111
|
+
data: Schema.String.pipe(Schema.maxLength(Math.ceil(BROWSER_MAX_FRAME_BYTES / 3) * 4))
|
|
112
|
+
})),
|
|
113
|
+
error: Schema.NullOr(Schema.String.pipe(Schema.maxLength(4096)))
|
|
114
|
+
});
|
|
115
|
+
Schema.Struct({
|
|
116
|
+
sequence: Schema.Int.pipe(Schema.positive()),
|
|
117
|
+
...browserVideoFields,
|
|
118
|
+
byteLength: Schema.Int.pipe(Schema.between(0, BROWSER_MAX_FRAME_BYTES))
|
|
119
|
+
});
|
|
120
|
+
const browserFrameDataSchema = Schema.Union(Schema.Uint8ArrayFromSelf, Schema.declare((value) => value instanceof ArrayBuffer, { identifier: "ArrayBufferFromSelf" })).pipe(Schema.transform(Schema.Uint8ArrayFromSelf, {
|
|
121
|
+
strict: true,
|
|
122
|
+
decode: (value) => value instanceof Uint8Array ? value : new Uint8Array(value),
|
|
123
|
+
encode: (value) => value
|
|
124
|
+
}), Schema.filter((value) => value.byteLength <= BROWSER_MAX_FRAME_BYTES, { message: () => `Browser frames cannot exceed ${BROWSER_MAX_FRAME_BYTES} bytes` }));
|
|
125
|
+
Schema.Struct({
|
|
126
|
+
sequence: Schema.Int.pipe(Schema.positive()),
|
|
127
|
+
...browserVideoFields,
|
|
128
|
+
data: browserFrameDataSchema
|
|
129
|
+
});
|
|
130
|
+
const browserTicketRequestSchema = Schema.Struct({
|
|
131
|
+
clientId: Schema.String.pipe(Schema.minLength(1), Schema.maxLength(128)),
|
|
132
|
+
visible: Schema.Boolean
|
|
133
|
+
});
|
|
134
|
+
const browserOwnerTicketRequestSchema = Schema.Struct({ clientId: Schema.String.pipe(Schema.minLength(1), Schema.maxLength(128)) });
|
|
135
|
+
const browserTicketResponseSchema = Schema.Struct({ ticket: opaqueTokenSchema });
|
|
136
|
+
const browserOwnerTicketResponseSchema = Schema.Struct({
|
|
137
|
+
ticket: opaqueTokenSchema,
|
|
138
|
+
challenge: opaqueTokenSchema
|
|
139
|
+
});
|
|
140
|
+
const browserOwnerIdentitySchema = Schema.Struct({
|
|
141
|
+
panelId: browserPanelIdSchema,
|
|
142
|
+
challenge: opaqueTokenSchema
|
|
143
|
+
});
|
|
144
|
+
const browserOwnerEndpointSchema = Schema.String.pipe(Schema.maxLength(1024), Schema.filter((value) => {
|
|
145
|
+
if (!URL.canParse(value)) return false;
|
|
146
|
+
const url = new URL(value);
|
|
147
|
+
return url.protocol === "http:" && url.hostname === "127.0.0.1" && url.username === "" && url.password === "" && url.search === "" && url.hash === "" && url.pathname !== "/";
|
|
148
|
+
}, { message: () => "Expected a private loopback Browser endpoint" }));
|
|
149
|
+
const browserAgentArgumentSchema = Schema.String.pipe(Schema.maxLength(4096));
|
|
150
|
+
const browserAgentCommandSchema = Schema.Union(Schema.Struct({
|
|
151
|
+
command: Schema.Literal("snapshot"),
|
|
152
|
+
args: Schema.Tuple()
|
|
153
|
+
}), Schema.Struct({
|
|
154
|
+
command: Schema.Literal("click"),
|
|
155
|
+
args: Schema.Tuple(browserAgentArgumentSchema)
|
|
156
|
+
}), Schema.Struct({
|
|
157
|
+
command: Schema.Literal("fill"),
|
|
158
|
+
args: Schema.Tuple(browserAgentArgumentSchema, browserAgentArgumentSchema)
|
|
159
|
+
}), Schema.Struct({
|
|
160
|
+
command: Schema.Literal("press"),
|
|
161
|
+
args: Schema.Tuple(browserAgentArgumentSchema)
|
|
162
|
+
}), Schema.Struct({
|
|
163
|
+
command: Schema.Literal("console"),
|
|
164
|
+
args: Schema.Union(Schema.Tuple(), Schema.Tuple(browserAgentArgumentSchema.pipe(Schema.maxLength(32))))
|
|
165
|
+
}), Schema.Struct({
|
|
166
|
+
command: Schema.Literal("requests"),
|
|
167
|
+
args: Schema.Tuple()
|
|
168
|
+
}), Schema.Struct({
|
|
169
|
+
command: Schema.Literal("screenshot"),
|
|
170
|
+
args: Schema.Tuple()
|
|
171
|
+
}), Schema.Struct({
|
|
172
|
+
command: Schema.Literal("goto"),
|
|
173
|
+
args: Schema.Tuple(browserUrlSchema)
|
|
174
|
+
}), Schema.Struct({
|
|
175
|
+
command: Schema.Literal("go-back"),
|
|
176
|
+
args: Schema.Tuple()
|
|
177
|
+
}), Schema.Struct({
|
|
178
|
+
command: Schema.Literal("go-forward"),
|
|
179
|
+
args: Schema.Tuple()
|
|
180
|
+
}), Schema.Struct({
|
|
181
|
+
command: Schema.Literal("reload"),
|
|
182
|
+
args: Schema.Tuple()
|
|
183
|
+
}));
|
|
184
|
+
const browserAuthSchema = Schema.Struct({
|
|
185
|
+
ticket: opaqueTokenSchema,
|
|
186
|
+
protocolVersion: Schema.Literal(6)
|
|
187
|
+
});
|
|
188
|
+
const browserOwnerAuthSchema = Schema.Struct({
|
|
189
|
+
ticket: opaqueTokenSchema,
|
|
190
|
+
protocolVersion: Schema.Literal(6),
|
|
191
|
+
endpoint: browserOwnerEndpointSchema,
|
|
192
|
+
challenge: opaqueTokenSchema
|
|
193
|
+
});
|
|
194
|
+
const browserOwnerClientMessageSchema = Schema.Union(Schema.Struct({
|
|
195
|
+
type: Schema.Literal("ready"),
|
|
196
|
+
generation: browserGenerationSchema,
|
|
197
|
+
revision: browserRevisionSchema,
|
|
198
|
+
state: browserRuntimeStateSchema
|
|
199
|
+
}), Schema.Struct({
|
|
200
|
+
type: Schema.Literal("state"),
|
|
201
|
+
generation: browserGenerationSchema,
|
|
202
|
+
revision: browserRevisionSchema,
|
|
203
|
+
state: browserRuntimeStateSchema
|
|
204
|
+
}), Schema.Struct({
|
|
205
|
+
type: Schema.Literal("popup"),
|
|
206
|
+
generation: browserGenerationSchema,
|
|
207
|
+
url: browserUrlSchema
|
|
208
|
+
}), Schema.Struct({
|
|
209
|
+
type: Schema.Literal("crashed"),
|
|
210
|
+
generation: browserGenerationSchema,
|
|
211
|
+
message: Schema.String.pipe(Schema.minLength(1), Schema.maxLength(1024))
|
|
212
|
+
}), Schema.Struct({
|
|
213
|
+
type: Schema.Literal("runtimeControlResult"),
|
|
214
|
+
generation: browserGenerationSchema,
|
|
215
|
+
requestId: browserRequestIdSchema,
|
|
216
|
+
accepted: Schema.Boolean
|
|
217
|
+
}), Schema.Struct({
|
|
218
|
+
type: Schema.Literal("takeControl"),
|
|
219
|
+
generation: browserGenerationSchema
|
|
220
|
+
}), Schema.Struct({
|
|
221
|
+
type: Schema.Literal("released"),
|
|
222
|
+
generation: browserGenerationSchema
|
|
223
|
+
}), Schema.Struct({
|
|
224
|
+
type: Schema.Literal("closeResult"),
|
|
225
|
+
generation: browserGenerationSchema,
|
|
226
|
+
requestId: browserRequestIdSchema,
|
|
227
|
+
canClose: Schema.Boolean
|
|
228
|
+
}));
|
|
229
|
+
Schema.Union(Schema.Struct({
|
|
230
|
+
type: Schema.Literal("claimGranted"),
|
|
231
|
+
panelId: browserPanelIdSchema,
|
|
232
|
+
generation: browserGenerationSchema,
|
|
233
|
+
resumed: Schema.Boolean,
|
|
234
|
+
state: browserRuntimeStateSchema
|
|
235
|
+
}), Schema.Struct({
|
|
236
|
+
type: Schema.Literal("claimRejected"),
|
|
237
|
+
message: Schema.String.pipe(Schema.minLength(1), Schema.maxLength(1024))
|
|
238
|
+
}), Schema.Struct({
|
|
239
|
+
type: Schema.Literal("runtimeControl"),
|
|
240
|
+
generation: browserGenerationSchema,
|
|
241
|
+
requestId: browserRequestIdSchema,
|
|
242
|
+
controller: Schema.Literal("agent", "other", "none"),
|
|
243
|
+
retainPaint: Schema.Boolean
|
|
244
|
+
}), Schema.Struct({
|
|
245
|
+
type: Schema.Literal("closeRequest"),
|
|
246
|
+
generation: browserGenerationSchema,
|
|
247
|
+
requestId: browserRequestIdSchema,
|
|
248
|
+
force: Schema.Boolean
|
|
249
|
+
}), Schema.Struct({
|
|
250
|
+
type: Schema.Literal("closed"),
|
|
251
|
+
reason: Schema.String.pipe(Schema.maxLength(1024))
|
|
252
|
+
}));
|
|
253
|
+
function decodeOrNull$2(schema, value) {
|
|
254
|
+
const result = Schema.decodeUnknownEither(schema, { onExcessProperty: "error" })(value);
|
|
255
|
+
return Either.isRight(result) ? result.right : null;
|
|
256
|
+
}
|
|
257
|
+
function parseBrowserCaptureMessage(payload) {
|
|
258
|
+
if (payload.length > 11748147.2) return null;
|
|
259
|
+
try {
|
|
260
|
+
return decodeOrNull$2(browserCaptureMessageSchema, JSON.parse(payload));
|
|
261
|
+
} catch {
|
|
262
|
+
return null;
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
function parseBrowserAuth(value) {
|
|
266
|
+
return decodeOrNull$2(browserAuthSchema, value);
|
|
267
|
+
}
|
|
268
|
+
function parseBrowserOwnerAuth(value) {
|
|
269
|
+
return decodeOrNull$2(browserOwnerAuthSchema, value);
|
|
270
|
+
}
|
|
271
|
+
function parseBrowserClientMessage(value) {
|
|
272
|
+
return decodeOrNull$2(browserClientMessageSchema, value);
|
|
273
|
+
}
|
|
274
|
+
function parseBrowserOwnerClientMessage(value) {
|
|
275
|
+
return decodeOrNull$2(browserOwnerClientMessageSchema, value);
|
|
276
|
+
}
|
|
277
|
+
function encodeBrowserFrame(frame) {
|
|
278
|
+
const metadata = new TextEncoder().encode(JSON.stringify({
|
|
279
|
+
sequence: frame.sequence,
|
|
280
|
+
mimeType: frame.mimeType,
|
|
281
|
+
keyframe: frame.keyframe,
|
|
282
|
+
timestamp: frame.timestamp,
|
|
283
|
+
width: frame.width,
|
|
284
|
+
height: frame.height,
|
|
285
|
+
byteLength: frame.data.byteLength
|
|
286
|
+
}));
|
|
287
|
+
const encoded = new Uint8Array(4 + metadata.byteLength + frame.data.byteLength);
|
|
288
|
+
new DataView(encoded.buffer).setUint32(0, metadata.byteLength);
|
|
289
|
+
encoded.set(metadata, 4);
|
|
290
|
+
encoded.set(frame.data, 4 + metadata.byteLength);
|
|
291
|
+
return encoded;
|
|
292
|
+
}
|
|
293
|
+
//#endregion
|
|
294
|
+
//#region ../../packages/shared/dist/json-schema.js
|
|
295
|
+
const jsonValueSchema = Schema.suspend(() => Schema.Union(Schema.Null, Schema.String, Schema.Number, Schema.Boolean, Schema.mutable(Schema.Array(jsonValueSchema)), Schema.Record({
|
|
296
|
+
key: Schema.String,
|
|
297
|
+
value: jsonValueSchema
|
|
298
|
+
})));
|
|
299
|
+
//#endregion
|
|
300
|
+
//#region ../../packages/shared/dist/web-panel-protocol.js
|
|
301
|
+
const webPanelPermissionSchema = Schema.Literal("same-origin", "tree-files");
|
|
302
|
+
const panelMessageSourceSchema = Schema.Literal("treeport-panel-v1");
|
|
303
|
+
Schema.Struct({
|
|
304
|
+
source: panelMessageSourceSchema,
|
|
305
|
+
method: Schema.Literal("panel.title.set"),
|
|
306
|
+
title: Schema.NullOr(Schema.String)
|
|
307
|
+
});
|
|
308
|
+
Schema.Struct({
|
|
309
|
+
source: panelMessageSourceSchema,
|
|
310
|
+
method: Schema.Literal("workspace.select"),
|
|
311
|
+
index: Schema.Int.pipe(Schema.between(0, 8))
|
|
312
|
+
});
|
|
313
|
+
Schema.Struct({
|
|
314
|
+
source: panelMessageSourceSchema,
|
|
315
|
+
method: Schema.Literal("panel.dirty.set"),
|
|
316
|
+
dirty: Schema.Boolean
|
|
317
|
+
});
|
|
318
|
+
const panelRequestFields = {
|
|
319
|
+
source: panelMessageSourceSchema,
|
|
320
|
+
id: Schema.String
|
|
321
|
+
};
|
|
322
|
+
const gitDiffImageRequestSchema = Schema.Struct({
|
|
323
|
+
path: Schema.String,
|
|
324
|
+
commit: Schema.NullOr(Schema.String.pipe(Schema.pattern(/^(?:[a-f0-9]{40}|[a-f0-9]{64})$/)))
|
|
325
|
+
});
|
|
326
|
+
Schema.Union(Schema.Struct({
|
|
327
|
+
...panelRequestFields,
|
|
328
|
+
method: Schema.Literal("context")
|
|
329
|
+
}), Schema.Struct({
|
|
330
|
+
...panelRequestFields,
|
|
331
|
+
method: Schema.Literal("diff")
|
|
332
|
+
}), Schema.Struct({
|
|
333
|
+
...panelRequestFields,
|
|
334
|
+
method: Schema.Literal("diff.image"),
|
|
335
|
+
...gitDiffImageRequestSchema.fields
|
|
336
|
+
}), Schema.Struct({
|
|
337
|
+
...panelRequestFields,
|
|
338
|
+
method: Schema.Literal("network.listeners")
|
|
339
|
+
}), Schema.Struct({
|
|
340
|
+
...panelRequestFields,
|
|
341
|
+
method: Schema.Literal("files.list")
|
|
342
|
+
}), Schema.Struct({
|
|
343
|
+
...panelRequestFields,
|
|
344
|
+
method: Schema.Literal("files.search"),
|
|
345
|
+
query: Schema.String
|
|
346
|
+
}), Schema.Struct({
|
|
347
|
+
...panelRequestFields,
|
|
348
|
+
method: Schema.Literal("files.read"),
|
|
349
|
+
path: Schema.String
|
|
350
|
+
}), Schema.Struct({
|
|
351
|
+
...panelRequestFields,
|
|
352
|
+
method: Schema.Literal("files.write"),
|
|
353
|
+
path: Schema.String,
|
|
354
|
+
content: Schema.String,
|
|
355
|
+
expectedRevision: Schema.String
|
|
356
|
+
}), Schema.Struct({
|
|
357
|
+
...panelRequestFields,
|
|
358
|
+
method: Schema.Literal("storage.get"),
|
|
359
|
+
key: Schema.String
|
|
360
|
+
}), Schema.Struct({
|
|
361
|
+
...panelRequestFields,
|
|
362
|
+
method: Schema.Literal("storage.set"),
|
|
363
|
+
key: Schema.String,
|
|
364
|
+
value: jsonValueSchema
|
|
365
|
+
}), Schema.Struct({
|
|
366
|
+
...panelRequestFields,
|
|
367
|
+
method: Schema.Literal("storage.delete"),
|
|
368
|
+
key: Schema.String
|
|
369
|
+
}));
|
|
370
|
+
//#endregion
|
|
371
|
+
//#region ../../packages/shared/dist/terminal-protocol.js
|
|
372
|
+
const SOCKET_PATH = "/api/socket";
|
|
373
|
+
const TERMINAL_CONTROLLER_GRACE_MS = 1e4;
|
|
374
|
+
const TERMINAL_OUTPUT_HIGH_WATERMARK = 256 * 1024;
|
|
375
|
+
const TERMINAL_OUTPUT_LOW_WATERMARK = 64 * 1024;
|
|
376
|
+
const TERMINAL_OUTPUT_MAX_UNACKNOWLEDGED_BYTES = 4 * 1024 * 1024;
|
|
377
|
+
const TERMINAL_MAX_CLIENT_MESSAGE_BYTES = 128 * 1024;
|
|
378
|
+
const TERMINAL_MAX_INPUT_BYTES = 64 * 1024;
|
|
379
|
+
const terminalId = Schema.String.pipe(Schema.minLength(1), Schema.maxLength(128));
|
|
380
|
+
const clientId = Schema.String.pipe(Schema.minLength(1), Schema.maxLength(128));
|
|
381
|
+
const streamId = Schema.String.pipe(Schema.minLength(1), Schema.maxLength(128));
|
|
382
|
+
const generation = Schema.NonNegativeInt;
|
|
383
|
+
const positiveInt = Schema.Int.pipe(Schema.positive());
|
|
384
|
+
const dimensions = {
|
|
385
|
+
cols: Schema.Int.pipe(Schema.between(2, 1e3)),
|
|
386
|
+
rows: Schema.Int.pipe(Schema.between(2, 500))
|
|
387
|
+
};
|
|
388
|
+
const dateTimeString$1 = Schema.String.pipe(Schema.filter((value) => !Number.isNaN(Date.parse(value)), { message: () => "Expected an ISO date and time" }));
|
|
389
|
+
const terminalSizeSchema = Schema.Struct(dimensions);
|
|
390
|
+
const terminalProgressSchema = Schema.Struct({
|
|
391
|
+
state: Schema.Literal("normal", "error", "indeterminate", "paused"),
|
|
392
|
+
value: Schema.NullOr(Schema.Int.pipe(Schema.between(0, 100)))
|
|
393
|
+
});
|
|
394
|
+
const terminalProgramSchema = Schema.Literal("pi", "claude", "codex");
|
|
395
|
+
const terminalRuntimeMetadataFields = {
|
|
396
|
+
terminalId: Schema.String.pipe(Schema.minLength(1)),
|
|
397
|
+
title: Schema.NullOr(Schema.String.pipe(Schema.maxLength(256))),
|
|
398
|
+
program: Schema.optionalWith(Schema.NullOr(terminalProgramSchema), { default: () => null }),
|
|
399
|
+
hasForegroundProcess: Schema.optional(Schema.NullOr(Schema.Boolean)),
|
|
400
|
+
progress: Schema.NullOr(terminalProgressSchema),
|
|
401
|
+
progressStartedAt: Schema.optionalWith(Schema.NullOr(dateTimeString$1), { default: () => null }),
|
|
402
|
+
progressClearedAt: Schema.optionalWith(Schema.NullOr(dateTimeString$1), { default: () => null }),
|
|
403
|
+
bell: Schema.optionalWith(Schema.NullOr(Schema.Struct({
|
|
404
|
+
sequence: positiveInt,
|
|
405
|
+
at: dateTimeString$1,
|
|
406
|
+
unread: Schema.Boolean
|
|
407
|
+
})), { default: () => null })
|
|
408
|
+
};
|
|
409
|
+
const terminalRuntimeMetadataSchema = Schema.mutable(Schema.Struct(terminalRuntimeMetadataFields));
|
|
410
|
+
const terminalBellAcknowledgementSchema = Schema.Struct({ sequence: positiveInt });
|
|
411
|
+
function decodeOrNull$1(schema, value) {
|
|
412
|
+
const parsed = Schema.decodeUnknownEither(schema, { onExcessProperty: "error" })(value);
|
|
413
|
+
return Either.isRight(parsed) ? parsed.right : null;
|
|
414
|
+
}
|
|
415
|
+
function parseTerminalProgress(data) {
|
|
416
|
+
const [command, rawState, rawValue, ...extra] = data.split(";");
|
|
417
|
+
if (command !== "4" || extra.length > 0 || !/^[0-4]$/.test(rawState ?? "")) return;
|
|
418
|
+
const state = Number(rawState);
|
|
419
|
+
if (state === 0) return null;
|
|
420
|
+
if (rawValue !== void 0 && rawValue !== "" && !/^\d{1,3}$/.test(rawValue)) return;
|
|
421
|
+
const value = rawValue === void 0 || rawValue === "" ? null : Number(rawValue);
|
|
422
|
+
if (value !== null && value > 100) return;
|
|
423
|
+
return {
|
|
424
|
+
state: [
|
|
425
|
+
void 0,
|
|
426
|
+
"normal",
|
|
427
|
+
"error",
|
|
428
|
+
"indeterminate",
|
|
429
|
+
"paused"
|
|
430
|
+
][state],
|
|
431
|
+
value
|
|
432
|
+
};
|
|
433
|
+
}
|
|
434
|
+
const terminalAuthSchema = Schema.Struct({
|
|
435
|
+
terminalId,
|
|
436
|
+
clientId,
|
|
437
|
+
...dimensions
|
|
438
|
+
});
|
|
439
|
+
const terminalInputSchema = Schema.Struct({
|
|
440
|
+
generation,
|
|
441
|
+
data: Schema.String.pipe(Schema.maxLength(TERMINAL_MAX_INPUT_BYTES))
|
|
442
|
+
});
|
|
443
|
+
const terminalBinarySchema = Schema.Struct({
|
|
444
|
+
generation,
|
|
445
|
+
data: Schema.String.pipe(Schema.maxLength(TERMINAL_MAX_INPUT_BYTES))
|
|
446
|
+
});
|
|
447
|
+
const terminalResizeSchema = Schema.Struct({
|
|
448
|
+
generation,
|
|
449
|
+
...dimensions
|
|
450
|
+
});
|
|
451
|
+
const terminalTakeControlSchema = Schema.Struct({
|
|
452
|
+
generation,
|
|
453
|
+
...dimensions
|
|
454
|
+
});
|
|
455
|
+
const terminalOutputAckSchema = Schema.Struct({
|
|
456
|
+
streamId,
|
|
457
|
+
sequence: Schema.NonNegativeInt
|
|
458
|
+
});
|
|
459
|
+
const terminalQueryAuthorityRequestSchema = Schema.Struct({
|
|
460
|
+
generation,
|
|
461
|
+
transitionId: Schema.NullOr(Schema.String.pipe(Schema.minLength(1), Schema.maxLength(128)))
|
|
462
|
+
});
|
|
463
|
+
const terminalReadyBase = {
|
|
464
|
+
connectionId: Schema.String.pipe(Schema.minLength(1), Schema.maxLength(128)),
|
|
465
|
+
streamId,
|
|
466
|
+
generation,
|
|
467
|
+
controller: Schema.Boolean,
|
|
468
|
+
reset: Schema.Literal("full")
|
|
469
|
+
};
|
|
470
|
+
const terminalSnapshotLinkSchema = Schema.Struct({
|
|
471
|
+
buffer: Schema.Literal("normal", "alternate"),
|
|
472
|
+
uri: Schema.String.pipe(Schema.minLength(1), Schema.maxLength(4096)),
|
|
473
|
+
line: Schema.NonNegativeInt,
|
|
474
|
+
startColumn: Schema.NonNegativeInt,
|
|
475
|
+
endColumn: positiveInt
|
|
476
|
+
});
|
|
477
|
+
Schema.Struct({
|
|
478
|
+
...terminalReadyBase,
|
|
479
|
+
...dimensions,
|
|
480
|
+
revision: positiveInt,
|
|
481
|
+
snapshot: Schema.String,
|
|
482
|
+
snapshotLinks: Schema.optionalWith(Schema.Array(terminalSnapshotLinkSchema).pipe(Schema.maxItems(1e4)), { default: () => [] })
|
|
483
|
+
});
|
|
484
|
+
Schema.Struct({
|
|
485
|
+
...dimensions,
|
|
486
|
+
revision: positiveInt
|
|
487
|
+
});
|
|
488
|
+
Schema.Struct({
|
|
489
|
+
streamId,
|
|
490
|
+
sequence: positiveInt,
|
|
491
|
+
data: Schema.String
|
|
492
|
+
});
|
|
493
|
+
Schema.Struct({ title: Schema.String.pipe(Schema.maxLength(256)) });
|
|
494
|
+
Schema.Struct({ progress: Schema.NullOr(terminalProgressSchema) });
|
|
495
|
+
Schema.Struct({
|
|
496
|
+
generation,
|
|
497
|
+
controller: Schema.Boolean
|
|
498
|
+
});
|
|
499
|
+
Schema.Struct({ exitCode: Schema.NullOr(Schema.Int) });
|
|
500
|
+
Schema.Struct({
|
|
501
|
+
generation,
|
|
502
|
+
transitionId: Schema.NullOr(Schema.String.pipe(Schema.minLength(1), Schema.maxLength(128))),
|
|
503
|
+
active: Schema.Boolean
|
|
504
|
+
});
|
|
505
|
+
Schema.Struct({
|
|
506
|
+
code: Schema.String.pipe(Schema.minLength(1), Schema.maxLength(80)),
|
|
507
|
+
message: Schema.String.pipe(Schema.minLength(1), Schema.maxLength(1e3)),
|
|
508
|
+
retryable: Schema.Boolean
|
|
509
|
+
});
|
|
510
|
+
function parseTerminalAuth(value) {
|
|
511
|
+
return decodeOrNull$1(terminalAuthSchema, value);
|
|
512
|
+
}
|
|
513
|
+
function parseTerminalClientEvent(event, value) {
|
|
514
|
+
const selected = {
|
|
515
|
+
input: terminalInputSchema,
|
|
516
|
+
binary: terminalBinarySchema,
|
|
517
|
+
resize: terminalResizeSchema,
|
|
518
|
+
take_control: terminalTakeControlSchema,
|
|
519
|
+
output_ack: terminalOutputAckSchema,
|
|
520
|
+
query_authority: terminalQueryAuthorityRequestSchema
|
|
521
|
+
}[event];
|
|
522
|
+
const parsed = Schema.decodeUnknownEither(selected, { onExcessProperty: "error" })(value);
|
|
523
|
+
return Either.isRight(parsed) ? parsed.right : null;
|
|
524
|
+
}
|
|
525
|
+
//#endregion
|
|
526
|
+
//#region ../../packages/shared/dist/browser-video.js
|
|
527
|
+
async function captureBrowserVideo(sourceId, width, height, publish) {
|
|
528
|
+
if (typeof VideoEncoder === "undefined") throw new Error("This browser does not support native video encoding.");
|
|
529
|
+
const track = (await navigator.mediaDevices.getUserMedia({
|
|
530
|
+
audio: false,
|
|
531
|
+
video: { mandatory: {
|
|
532
|
+
chromeMediaSource: "tab",
|
|
533
|
+
chromeMediaSourceId: sourceId,
|
|
534
|
+
maxWidth: width,
|
|
535
|
+
maxHeight: height,
|
|
536
|
+
maxFrameRate: 30
|
|
537
|
+
} }
|
|
538
|
+
})).getVideoTracks()[0];
|
|
539
|
+
track.contentHint = "detail";
|
|
540
|
+
const Processor = globalThis.MediaStreamTrackProcessor;
|
|
541
|
+
let stopped = false;
|
|
542
|
+
let lastFrame = null;
|
|
543
|
+
let encodedWidth = 0;
|
|
544
|
+
let encodedHeight = 0;
|
|
545
|
+
let frames = 0;
|
|
546
|
+
let keyframe = true;
|
|
547
|
+
let outstanding = 0;
|
|
548
|
+
let lastTimestamp = 0;
|
|
549
|
+
const dimensions = /* @__PURE__ */ new Map();
|
|
550
|
+
const reader = new Processor({ track }).readable.getReader();
|
|
551
|
+
const fail = (error) => {
|
|
552
|
+
if (!stopped) {
|
|
553
|
+
publish(JSON.stringify({
|
|
554
|
+
frame: null,
|
|
555
|
+
error: error.message.slice(0, 4096)
|
|
556
|
+
}));
|
|
557
|
+
stop();
|
|
558
|
+
}
|
|
559
|
+
};
|
|
560
|
+
const encoder = new VideoEncoder({
|
|
561
|
+
output(chunk) {
|
|
562
|
+
if (stopped) return;
|
|
563
|
+
const size = dimensions.get(chunk.timestamp);
|
|
564
|
+
dimensions.delete(chunk.timestamp);
|
|
565
|
+
if (!size || chunk.byteLength > 8 * 1024 * 1024) {
|
|
566
|
+
fail(/* @__PURE__ */ new Error("Browser video frame exceeds the capture limit."));
|
|
567
|
+
return;
|
|
568
|
+
}
|
|
569
|
+
const bytes = new Uint8Array(chunk.byteLength);
|
|
570
|
+
chunk.copyTo(bytes);
|
|
571
|
+
let binary = "";
|
|
572
|
+
for (let offset = 0; offset < bytes.length; offset += 16384) binary += String.fromCharCode(...bytes.subarray(offset, offset + 16384));
|
|
573
|
+
publish(JSON.stringify({
|
|
574
|
+
error: null,
|
|
575
|
+
frame: {
|
|
576
|
+
mimeType: "video/vp8",
|
|
577
|
+
keyframe: chunk.type === "key",
|
|
578
|
+
timestamp: chunk.timestamp,
|
|
579
|
+
...size,
|
|
580
|
+
data: btoa(binary)
|
|
581
|
+
}
|
|
582
|
+
}));
|
|
583
|
+
},
|
|
584
|
+
error: fail
|
|
585
|
+
});
|
|
586
|
+
const encode = (frame, force) => {
|
|
587
|
+
if (stopped || encoder.encodeQueueSize >= 2 || outstanding >= 4) {
|
|
588
|
+
keyframe = true;
|
|
589
|
+
return;
|
|
590
|
+
}
|
|
591
|
+
if (encodedWidth !== frame.displayWidth || encodedHeight !== frame.displayHeight) {
|
|
592
|
+
encodedWidth = frame.displayWidth;
|
|
593
|
+
encodedHeight = frame.displayHeight;
|
|
594
|
+
encoder.configure({
|
|
595
|
+
codec: "vp8",
|
|
596
|
+
width: encodedWidth,
|
|
597
|
+
height: encodedHeight,
|
|
598
|
+
framerate: 30,
|
|
599
|
+
bitrate: 3e6,
|
|
600
|
+
latencyMode: "realtime"
|
|
601
|
+
});
|
|
602
|
+
keyframe = true;
|
|
603
|
+
}
|
|
604
|
+
lastTimestamp = Math.max(lastTimestamp + 1, Math.round(performance.now() * 1e3));
|
|
605
|
+
const input = new VideoFrame(frame, { timestamp: lastTimestamp });
|
|
606
|
+
outstanding++;
|
|
607
|
+
dimensions.set(lastTimestamp, {
|
|
608
|
+
width: encodedWidth,
|
|
609
|
+
height: encodedHeight
|
|
610
|
+
});
|
|
611
|
+
encoder.encode(input, { keyFrame: force || keyframe || frames++ % 30 === 0 });
|
|
612
|
+
input.close();
|
|
613
|
+
keyframe = false;
|
|
614
|
+
};
|
|
615
|
+
const stop = () => {
|
|
616
|
+
if (stopped) return;
|
|
617
|
+
stopped = true;
|
|
618
|
+
track.stop();
|
|
619
|
+
reader.cancel().catch(() => void 0);
|
|
620
|
+
lastFrame?.close();
|
|
621
|
+
lastFrame = null;
|
|
622
|
+
dimensions.clear();
|
|
623
|
+
if (encoder.state !== "closed") encoder.close();
|
|
624
|
+
};
|
|
625
|
+
track.addEventListener("ended", () => fail(/* @__PURE__ */ new Error("Browser video capture ended.")));
|
|
626
|
+
(async () => {
|
|
627
|
+
while (!stopped) {
|
|
628
|
+
const { value: frame, done } = await reader.read();
|
|
629
|
+
if (done) break;
|
|
630
|
+
lastFrame?.close();
|
|
631
|
+
lastFrame = frame;
|
|
632
|
+
encode(frame, false);
|
|
633
|
+
}
|
|
634
|
+
})().catch(fail);
|
|
635
|
+
return {
|
|
636
|
+
stop,
|
|
637
|
+
acknowledge() {
|
|
638
|
+
outstanding = Math.max(0, outstanding - 1);
|
|
639
|
+
if (keyframe && lastFrame && outstanding === 0) encode(lastFrame, true);
|
|
640
|
+
},
|
|
641
|
+
requestKeyframe() {
|
|
642
|
+
keyframe = true;
|
|
643
|
+
if (lastFrame) encode(lastFrame, true);
|
|
644
|
+
}
|
|
645
|
+
};
|
|
646
|
+
}
|
|
647
|
+
const BROWSER_VIDEO_CAPTURE_SOURCE = `(${captureBrowserVideo.toString()})`;
|
|
648
|
+
//#endregion
|
|
649
|
+
//#region ../../packages/shared/dist/http-protocol.js
|
|
650
|
+
const projectColorSchema = Schema.Literal("rose", "orange", "amber", "emerald", "cyan", "blue", "violet", "pink");
|
|
651
|
+
const stringArraySchema = Schema.Array(Schema.String);
|
|
652
|
+
const nullableStringSchema = Schema.NullOr(Schema.String);
|
|
653
|
+
const jsonObjectSchema = Schema.Record({
|
|
654
|
+
key: Schema.String,
|
|
655
|
+
value: jsonValueSchema
|
|
656
|
+
});
|
|
657
|
+
const terminalPresetDefinitionsQuerySchema = Schema.Struct({
|
|
658
|
+
projectId: Schema.optional(Schema.String),
|
|
659
|
+
worktreeId: Schema.optional(Schema.String)
|
|
660
|
+
});
|
|
661
|
+
const treeContextFieldsQuerySchema = Schema.Struct({ projectId: Schema.String.pipe(Schema.minLength(1)) });
|
|
662
|
+
const operationQuerySchema = Schema.Struct({
|
|
663
|
+
kind: Schema.optional(Schema.Literal("create", "finish", "discard", "project_cleanup", "remove", "external_remove")),
|
|
664
|
+
projectId: Schema.optional(Schema.String)
|
|
665
|
+
});
|
|
666
|
+
const deletePanelQuerySchema = Schema.Struct({
|
|
667
|
+
discardStoredData: Schema.optional(Schema.String),
|
|
668
|
+
force: Schema.optional(Schema.String)
|
|
669
|
+
});
|
|
670
|
+
const okResponseSchema = Schema.Struct({ ok: Schema.Literal(true) });
|
|
671
|
+
const terminalRecordSchema$1 = Schema.Struct({
|
|
672
|
+
id: Schema.String,
|
|
673
|
+
worktreeId: Schema.String,
|
|
674
|
+
name: Schema.String,
|
|
675
|
+
argv: stringArraySchema,
|
|
676
|
+
shellCommand: nullableStringSchema,
|
|
677
|
+
interactiveShell: Schema.Boolean,
|
|
678
|
+
status: Schema.Literal("running", "exited", "missing"),
|
|
679
|
+
exitCode: Schema.NullOr(Schema.Int),
|
|
680
|
+
createdAt: Schema.String,
|
|
681
|
+
updatedAt: Schema.String
|
|
682
|
+
});
|
|
683
|
+
const terminalPresetSchema = Schema.Struct({
|
|
684
|
+
id: Schema.String,
|
|
685
|
+
name: Schema.String,
|
|
686
|
+
executable: Schema.String,
|
|
687
|
+
args: stringArraySchema,
|
|
688
|
+
closeOnSuccess: Schema.Boolean,
|
|
689
|
+
createdAt: Schema.String,
|
|
690
|
+
updatedAt: Schema.String
|
|
691
|
+
});
|
|
692
|
+
const webPanelLaunchSchema = Schema.Struct({
|
|
693
|
+
input: Schema.NullOr(jsonObjectSchema),
|
|
694
|
+
cwd: nullableStringSchema
|
|
695
|
+
});
|
|
696
|
+
const webPanelSandboxSchema = Schema.Struct({ allowSameOrigin: Schema.Boolean });
|
|
697
|
+
const webPanelSchema = Schema.Struct({
|
|
698
|
+
id: Schema.String,
|
|
699
|
+
kind: Schema.Literal("web"),
|
|
700
|
+
worktreeId: Schema.String,
|
|
701
|
+
definitionId: Schema.String,
|
|
702
|
+
title: Schema.String,
|
|
703
|
+
launch: webPanelLaunchSchema,
|
|
704
|
+
permissions: Schema.Array(webPanelPermissionSchema),
|
|
705
|
+
sandbox: webPanelSandboxSchema,
|
|
706
|
+
createdAt: Schema.String,
|
|
707
|
+
updatedAt: Schema.String
|
|
708
|
+
});
|
|
709
|
+
const browserPanelSchema = Schema.Struct({
|
|
710
|
+
id: Schema.String,
|
|
711
|
+
kind: Schema.Literal("browser"),
|
|
712
|
+
worktreeId: Schema.String,
|
|
713
|
+
title: Schema.String,
|
|
714
|
+
url: Schema.Union(Schema.Literal("about:blank"), browserUrlSchema),
|
|
715
|
+
createdAt: Schema.String,
|
|
716
|
+
updatedAt: Schema.String
|
|
717
|
+
});
|
|
718
|
+
const terminalPanelSchema = Schema.Struct({
|
|
719
|
+
id: Schema.String,
|
|
720
|
+
kind: Schema.Literal("terminal"),
|
|
721
|
+
worktreeId: Schema.String,
|
|
722
|
+
terminalId: Schema.String,
|
|
723
|
+
title: Schema.String,
|
|
724
|
+
createdAt: Schema.String,
|
|
725
|
+
updatedAt: Schema.String
|
|
726
|
+
});
|
|
727
|
+
const panelSchema = Schema.Union(terminalPanelSchema, webPanelSchema, browserPanelSchema);
|
|
728
|
+
const prInfoSchema = Schema.Struct({
|
|
729
|
+
state: Schema.Literal("no_pr", "open", "merged", "closed", "unknown"),
|
|
730
|
+
number: Schema.NullOr(Schema.Int),
|
|
731
|
+
url: nullableStringSchema,
|
|
732
|
+
baseBranch: nullableStringSchema,
|
|
733
|
+
headBranch: nullableStringSchema,
|
|
734
|
+
mergedAt: nullableStringSchema,
|
|
735
|
+
refreshedAt: nullableStringSchema
|
|
736
|
+
});
|
|
737
|
+
const dirtyStateSchema = Schema.Struct({
|
|
738
|
+
dirty: Schema.Boolean,
|
|
739
|
+
staged: Schema.NonNegativeInt,
|
|
740
|
+
unstaged: Schema.NonNegativeInt,
|
|
741
|
+
untracked: Schema.NonNegativeInt,
|
|
742
|
+
conflicts: Schema.NonNegativeInt,
|
|
743
|
+
total: Schema.NonNegativeInt
|
|
744
|
+
});
|
|
745
|
+
const worktreeRecordSchema = Schema.Struct({
|
|
746
|
+
id: Schema.String,
|
|
747
|
+
projectId: Schema.String,
|
|
748
|
+
name: Schema.String,
|
|
749
|
+
path: Schema.String,
|
|
750
|
+
head: Schema.String,
|
|
751
|
+
branch: nullableStringSchema,
|
|
752
|
+
detached: Schema.Boolean,
|
|
753
|
+
locked: Schema.Boolean,
|
|
754
|
+
lockReason: nullableStringSchema,
|
|
755
|
+
prunable: Schema.Boolean,
|
|
756
|
+
kind: Schema.Literal("main", "linked", "folder"),
|
|
757
|
+
managedWrapperPath: nullableStringSchema,
|
|
758
|
+
pr: prInfoSchema,
|
|
759
|
+
dirty: Schema.NullOr(dirtyStateSchema),
|
|
760
|
+
terminals: Schema.Array(terminalRecordSchema$1),
|
|
761
|
+
panels: Schema.Array(panelSchema),
|
|
762
|
+
createdAt: Schema.String,
|
|
763
|
+
updatedAt: Schema.String
|
|
764
|
+
});
|
|
765
|
+
const projectRecordSchema = Schema.Struct({
|
|
766
|
+
id: Schema.String,
|
|
767
|
+
name: Schema.String,
|
|
768
|
+
kind: Schema.Literal("repository", "folder"),
|
|
769
|
+
rootPath: Schema.String,
|
|
770
|
+
repositoryPath: Schema.String,
|
|
771
|
+
mainWorktreePath: Schema.String,
|
|
772
|
+
defaultBranch: Schema.String,
|
|
773
|
+
color: Schema.NullOr(projectColorSchema),
|
|
774
|
+
availability: Schema.Struct({
|
|
775
|
+
state: Schema.Literal("available", "unavailable"),
|
|
776
|
+
message: nullableStringSchema
|
|
777
|
+
}),
|
|
778
|
+
worktrees: Schema.Array(worktreeRecordSchema),
|
|
779
|
+
createdAt: Schema.String,
|
|
780
|
+
updatedAt: Schema.String
|
|
781
|
+
});
|
|
782
|
+
const recentProjectRecordSchema = Schema.Struct({
|
|
783
|
+
id: Schema.String,
|
|
784
|
+
name: Schema.String,
|
|
785
|
+
kind: Schema.Literal("repository", "folder"),
|
|
786
|
+
rootPath: Schema.String,
|
|
787
|
+
repositoryPath: Schema.String,
|
|
788
|
+
lastOpenedAt: Schema.String
|
|
789
|
+
});
|
|
790
|
+
const cleanupCommandProgressSchema = Schema.Struct({
|
|
791
|
+
name: Schema.String,
|
|
792
|
+
status: Schema.Literal("pending", "running", "completed", "failed"),
|
|
793
|
+
stdout: Schema.String,
|
|
794
|
+
stderr: Schema.String,
|
|
795
|
+
exitCode: Schema.NullOr(Schema.Int),
|
|
796
|
+
error: nullableStringSchema,
|
|
797
|
+
outputTruncated: Schema.Boolean
|
|
798
|
+
});
|
|
799
|
+
const removeCleanupProgressSchema = Schema.Struct({
|
|
800
|
+
status: Schema.Literal("pending", "running", "completed", "failed", "skipped"),
|
|
801
|
+
definitionHash: nullableStringSchema,
|
|
802
|
+
skippedReason: nullableStringSchema,
|
|
803
|
+
commands: Schema.Array(cleanupCommandProgressSchema)
|
|
804
|
+
});
|
|
805
|
+
const removePreviewSchema = Schema.Struct({
|
|
806
|
+
worktreeId: Schema.String,
|
|
807
|
+
name: Schema.String,
|
|
808
|
+
path: Schema.String,
|
|
809
|
+
head: Schema.String,
|
|
810
|
+
branch: nullableStringSchema,
|
|
811
|
+
detached: Schema.Boolean,
|
|
812
|
+
locked: Schema.Boolean,
|
|
813
|
+
lockReason: nullableStringSchema,
|
|
814
|
+
dirty: dirtyStateSchema,
|
|
815
|
+
detachedHeadReachable: Schema.NullOr(Schema.Boolean),
|
|
816
|
+
forceRequired: Schema.Boolean,
|
|
817
|
+
eligible: Schema.Boolean,
|
|
818
|
+
reasons: stringArraySchema,
|
|
819
|
+
warnings: stringArraySchema,
|
|
820
|
+
cleanup: Schema.Struct({
|
|
821
|
+
commands: stringArraySchema,
|
|
822
|
+
available: Schema.Boolean,
|
|
823
|
+
unavailableReason: nullableStringSchema
|
|
824
|
+
}),
|
|
825
|
+
terminals: Schema.Array(Schema.Struct({
|
|
826
|
+
id: Schema.String,
|
|
827
|
+
name: Schema.String,
|
|
828
|
+
status: Schema.Literal("running", "exited", "missing")
|
|
829
|
+
})),
|
|
830
|
+
confirmationToken: Schema.String
|
|
831
|
+
});
|
|
832
|
+
const operationBaseFields = {
|
|
833
|
+
id: Schema.String,
|
|
834
|
+
projectId: nullableStringSchema,
|
|
835
|
+
worktreeId: nullableStringSchema,
|
|
836
|
+
status: Schema.Literal("pending", "running", "completed", "failed"),
|
|
837
|
+
error: nullableStringSchema,
|
|
838
|
+
createdAt: Schema.String,
|
|
839
|
+
updatedAt: Schema.String
|
|
840
|
+
};
|
|
841
|
+
const createOperationRequestSchema = Schema.Struct({
|
|
842
|
+
name: Schema.String,
|
|
843
|
+
base: Schema.Literal("default", "current"),
|
|
844
|
+
context: Schema.optional(Schema.Record({
|
|
845
|
+
key: Schema.String,
|
|
846
|
+
value: Schema.String
|
|
847
|
+
})),
|
|
848
|
+
initialTerminal: Schema.optional(Schema.Struct({
|
|
849
|
+
name: Schema.String,
|
|
850
|
+
initialTitle: Schema.optional(Schema.String),
|
|
851
|
+
argv: Schema.optional(stringArraySchema),
|
|
852
|
+
returnToShell: Schema.optional(Schema.Boolean),
|
|
853
|
+
initialSize: Schema.optional(Schema.Struct({
|
|
854
|
+
cols: Schema.Int,
|
|
855
|
+
rows: Schema.Int
|
|
856
|
+
}))
|
|
857
|
+
})),
|
|
858
|
+
sourceWorktreeId: Schema.optional(Schema.String)
|
|
859
|
+
});
|
|
860
|
+
const createOperationResultSchema = Schema.Struct({
|
|
861
|
+
worktreeId: Schema.String,
|
|
862
|
+
terminalId: nullableStringSchema,
|
|
863
|
+
terminalError: nullableStringSchema,
|
|
864
|
+
setupError: nullableStringSchema
|
|
865
|
+
});
|
|
866
|
+
const removalCheckoutIdentitySchema = Schema.Struct({
|
|
867
|
+
path: Schema.String,
|
|
868
|
+
device: Schema.String,
|
|
869
|
+
inode: Schema.String,
|
|
870
|
+
gitWorktreeKey: Schema.String,
|
|
871
|
+
gitMarker: Schema.String,
|
|
872
|
+
repositoryIdentity: nullableStringSchema,
|
|
873
|
+
managedWrapperPath: nullableStringSchema,
|
|
874
|
+
quarantinePath: Schema.String
|
|
875
|
+
});
|
|
876
|
+
const removeOperationRequestSchema = Schema.Struct({
|
|
877
|
+
confirmation: Schema.NullOr(Schema.Boolean),
|
|
878
|
+
confirmationToken: nullableStringSchema,
|
|
879
|
+
confirmDestructive: Schema.NullOr(Schema.Boolean),
|
|
880
|
+
skipCleanup: Schema.Boolean,
|
|
881
|
+
preview: Schema.NullOr(removePreviewSchema),
|
|
882
|
+
checkoutIdentity: Schema.NullOr(removalCheckoutIdentitySchema),
|
|
883
|
+
prunable: Schema.NullOr(Schema.Boolean),
|
|
884
|
+
gitWorktreeKey: nullableStringSchema,
|
|
885
|
+
repositoryIdentity: nullableStringSchema,
|
|
886
|
+
phase: Schema.NullOr(Schema.Literal("accepted", "terminals_stopped", "cleanup_commands_completed", "git_removed", "cleanup_pending")),
|
|
887
|
+
managedWrapperPath: nullableStringSchema,
|
|
888
|
+
cleanupCommands: removeCleanupProgressSchema
|
|
889
|
+
});
|
|
890
|
+
const removeOperationResultSchema = Schema.Struct({
|
|
891
|
+
removed: Schema.Literal(true),
|
|
892
|
+
worktreeId: Schema.String,
|
|
893
|
+
name: Schema.String,
|
|
894
|
+
branchPreserved: nullableStringSchema,
|
|
895
|
+
path: Schema.String,
|
|
896
|
+
recovered: Schema.Boolean,
|
|
897
|
+
cleanup: Schema.Struct({
|
|
898
|
+
status: Schema.Literal("completed", "preserved"),
|
|
899
|
+
residualPath: nullableStringSchema,
|
|
900
|
+
warning: nullableStringSchema,
|
|
901
|
+
commands: Schema.Array(cleanupCommandProgressSchema)
|
|
902
|
+
})
|
|
903
|
+
});
|
|
904
|
+
const externalRemoveResultSchema = Schema.Struct({
|
|
905
|
+
removed: Schema.Literal(true),
|
|
906
|
+
external: Schema.Literal(true),
|
|
907
|
+
worktreeId: Schema.String,
|
|
908
|
+
path: Schema.String,
|
|
909
|
+
head: Schema.String,
|
|
910
|
+
branch: nullableStringSchema,
|
|
911
|
+
cleanup: Schema.Struct({
|
|
912
|
+
status: Schema.Literal("skipped"),
|
|
913
|
+
skippedReason: Schema.String
|
|
914
|
+
})
|
|
915
|
+
});
|
|
916
|
+
const operationRecordSchema = Schema.Union(Schema.Struct({
|
|
917
|
+
...operationBaseFields,
|
|
918
|
+
kind: Schema.Literal("create"),
|
|
919
|
+
request: createOperationRequestSchema,
|
|
920
|
+
result: Schema.NullOr(createOperationResultSchema)
|
|
921
|
+
}), Schema.Struct({
|
|
922
|
+
...operationBaseFields,
|
|
923
|
+
kind: Schema.Literal("remove"),
|
|
924
|
+
request: removeOperationRequestSchema,
|
|
925
|
+
result: Schema.NullOr(removeOperationResultSchema)
|
|
926
|
+
}), Schema.Struct({
|
|
927
|
+
...operationBaseFields,
|
|
928
|
+
kind: Schema.Literal("external_remove"),
|
|
929
|
+
request: Schema.Struct({ source: Schema.Literal("git") }),
|
|
930
|
+
result: Schema.NullOr(externalRemoveResultSchema)
|
|
931
|
+
}), Schema.Struct({
|
|
932
|
+
...operationBaseFields,
|
|
933
|
+
kind: Schema.Literal("finish", "discard", "project_cleanup"),
|
|
934
|
+
request: jsonObjectSchema,
|
|
935
|
+
result: Schema.NullOr(jsonObjectSchema)
|
|
936
|
+
}));
|
|
937
|
+
const directoryBrowseResponseSchema = Schema.Struct({
|
|
938
|
+
input: Schema.String,
|
|
939
|
+
exact: Schema.Boolean,
|
|
940
|
+
directory: Schema.Struct({
|
|
941
|
+
path: Schema.String,
|
|
942
|
+
parentPath: nullableStringSchema,
|
|
943
|
+
homePath: Schema.String,
|
|
944
|
+
rootPath: Schema.String,
|
|
945
|
+
breadcrumbs: Schema.Array(Schema.Struct({
|
|
946
|
+
name: Schema.String,
|
|
947
|
+
path: Schema.String
|
|
948
|
+
})),
|
|
949
|
+
entries: Schema.Array(Schema.Struct({
|
|
950
|
+
name: Schema.String,
|
|
951
|
+
path: Schema.String
|
|
952
|
+
})),
|
|
953
|
+
truncated: Schema.Boolean
|
|
954
|
+
}),
|
|
955
|
+
project: Schema.Union(Schema.Struct({
|
|
956
|
+
state: Schema.Literal("valid"),
|
|
957
|
+
kind: Schema.Literal("repository", "folder"),
|
|
958
|
+
path: Schema.String
|
|
959
|
+
}), Schema.Struct({
|
|
960
|
+
state: Schema.Literal("incomplete"),
|
|
961
|
+
message: Schema.String
|
|
962
|
+
})),
|
|
963
|
+
repository: Schema.Union(Schema.Struct({
|
|
964
|
+
state: Schema.Literal("valid"),
|
|
965
|
+
repositoryPath: Schema.String
|
|
966
|
+
}), Schema.Struct({
|
|
967
|
+
state: Schema.Literal("incomplete"),
|
|
968
|
+
message: Schema.String
|
|
969
|
+
}), Schema.Struct({
|
|
970
|
+
state: Schema.Literal("not-repository"),
|
|
971
|
+
message: Schema.String
|
|
972
|
+
}))
|
|
973
|
+
});
|
|
974
|
+
const packageDefinitionSourceSchema = Schema.Union(Schema.Struct({ type: Schema.Literal("user") }), Schema.Struct({
|
|
975
|
+
type: Schema.Literal("repository"),
|
|
976
|
+
format: Schema.Literal("treeport", "zed")
|
|
977
|
+
}), Schema.Struct({
|
|
978
|
+
type: Schema.Literal("package"),
|
|
979
|
+
packageId: Schema.String,
|
|
980
|
+
source: Schema.String,
|
|
981
|
+
scope: Schema.Literal("global", "project")
|
|
982
|
+
}));
|
|
983
|
+
const terminalPresetDefinitionListingSchema = Schema.Struct({
|
|
984
|
+
definitions: Schema.Array(Schema.Struct({
|
|
985
|
+
id: Schema.String,
|
|
986
|
+
name: Schema.String,
|
|
987
|
+
executable: nullableStringSchema,
|
|
988
|
+
args: stringArraySchema,
|
|
989
|
+
shellCommand: nullableStringSchema,
|
|
990
|
+
cwd: nullableStringSchema,
|
|
991
|
+
env: Schema.Record({
|
|
992
|
+
key: Schema.String,
|
|
993
|
+
value: Schema.String
|
|
994
|
+
}),
|
|
995
|
+
closeOnSuccess: Schema.Boolean,
|
|
996
|
+
source: packageDefinitionSourceSchema
|
|
997
|
+
})),
|
|
998
|
+
diagnostics: Schema.Array(Schema.Struct({
|
|
999
|
+
path: Schema.String,
|
|
1000
|
+
itemId: nullableStringSchema,
|
|
1001
|
+
message: Schema.String
|
|
1002
|
+
}))
|
|
1003
|
+
});
|
|
1004
|
+
const treeContextFieldListingSchema = Schema.Struct({
|
|
1005
|
+
fields: Schema.Array(Schema.Struct({
|
|
1006
|
+
id: Schema.String,
|
|
1007
|
+
label: Schema.String,
|
|
1008
|
+
input: Schema.Literal("text", "textarea")
|
|
1009
|
+
})),
|
|
1010
|
+
diagnostics: Schema.Array(Schema.Struct({
|
|
1011
|
+
scope: Schema.Literal("global", "project"),
|
|
1012
|
+
path: Schema.String,
|
|
1013
|
+
message: Schema.String
|
|
1014
|
+
}))
|
|
1015
|
+
});
|
|
1016
|
+
const webPanelDefinitionSchema = Schema.Struct({
|
|
1017
|
+
id: Schema.String,
|
|
1018
|
+
title: Schema.String,
|
|
1019
|
+
icon: nullableStringSchema,
|
|
1020
|
+
source: Schema.Union(Schema.Struct({ type: Schema.Literal("project") }), Schema.Struct({
|
|
1021
|
+
type: Schema.Literal("package"),
|
|
1022
|
+
packageId: Schema.String,
|
|
1023
|
+
source: Schema.String,
|
|
1024
|
+
scope: Schema.Literal("global", "project")
|
|
1025
|
+
})),
|
|
1026
|
+
permissions: Schema.Array(webPanelPermissionSchema),
|
|
1027
|
+
permissionsGranted: Schema.Boolean,
|
|
1028
|
+
sandbox: webPanelSandboxSchema
|
|
1029
|
+
});
|
|
1030
|
+
const webPanelContextSchema = Schema.Struct({
|
|
1031
|
+
apiVersion: Schema.Literal(1),
|
|
1032
|
+
panel: webPanelSchema,
|
|
1033
|
+
launch: webPanelLaunchSchema,
|
|
1034
|
+
project: Schema.Struct({
|
|
1035
|
+
id: Schema.String,
|
|
1036
|
+
name: Schema.String,
|
|
1037
|
+
kind: Schema.Literal("repository", "folder"),
|
|
1038
|
+
defaultBranch: nullableStringSchema
|
|
1039
|
+
}),
|
|
1040
|
+
worktree: Schema.Struct({
|
|
1041
|
+
id: Schema.String,
|
|
1042
|
+
name: Schema.String,
|
|
1043
|
+
kind: Schema.Literal("main", "linked", "folder"),
|
|
1044
|
+
branch: nullableStringSchema,
|
|
1045
|
+
head: nullableStringSchema
|
|
1046
|
+
})
|
|
1047
|
+
});
|
|
1048
|
+
const gitDiffImageSchema = Schema.Struct({
|
|
1049
|
+
dataUrl: Schema.String,
|
|
1050
|
+
byteLength: Schema.Number
|
|
1051
|
+
});
|
|
1052
|
+
const gitDiffSchema = Schema.Struct({
|
|
1053
|
+
baseRef: Schema.String,
|
|
1054
|
+
baseCommit: Schema.String,
|
|
1055
|
+
headCommit: Schema.String,
|
|
1056
|
+
generatedAt: Schema.String,
|
|
1057
|
+
unified: Schema.String,
|
|
1058
|
+
changeSets: Schema.Struct({
|
|
1059
|
+
branch: stringArraySchema,
|
|
1060
|
+
staged: stringArraySchema,
|
|
1061
|
+
unstaged: stringArraySchema,
|
|
1062
|
+
untracked: stringArraySchema
|
|
1063
|
+
})
|
|
1064
|
+
});
|
|
1065
|
+
const worktreeListenerDiscoverySchema = Schema.Struct({
|
|
1066
|
+
supported: Schema.Boolean,
|
|
1067
|
+
message: nullableStringSchema,
|
|
1068
|
+
listeners: Schema.Array(Schema.Struct({
|
|
1069
|
+
pid: Schema.Int,
|
|
1070
|
+
command: Schema.String,
|
|
1071
|
+
host: Schema.String,
|
|
1072
|
+
port: Schema.Int,
|
|
1073
|
+
terminalId: nullableStringSchema
|
|
1074
|
+
}))
|
|
1075
|
+
});
|
|
1076
|
+
const treeFileListingSchema = Schema.Struct({
|
|
1077
|
+
paths: stringArraySchema,
|
|
1078
|
+
truncated: Schema.Boolean
|
|
1079
|
+
});
|
|
1080
|
+
const treeFileSchema = Schema.Struct({
|
|
1081
|
+
path: Schema.String,
|
|
1082
|
+
content: Schema.String,
|
|
1083
|
+
revision: Schema.String
|
|
1084
|
+
});
|
|
1085
|
+
const treeFileSearchResultSchema = Schema.Struct({
|
|
1086
|
+
files: Schema.Array(Schema.Struct({
|
|
1087
|
+
path: Schema.String,
|
|
1088
|
+
matches: Schema.Array(Schema.Struct({
|
|
1089
|
+
lineNumber: Schema.Int,
|
|
1090
|
+
column: Schema.NonNegativeInt,
|
|
1091
|
+
length: Schema.NonNegativeInt,
|
|
1092
|
+
preview: Schema.String,
|
|
1093
|
+
previewStart: Schema.NonNegativeInt,
|
|
1094
|
+
lineLength: Schema.NonNegativeInt
|
|
1095
|
+
}))
|
|
1096
|
+
})),
|
|
1097
|
+
truncated: Schema.Boolean
|
|
1098
|
+
});
|
|
1099
|
+
const treeFileWriteResultSchema = Schema.Struct({
|
|
1100
|
+
path: Schema.String,
|
|
1101
|
+
revision: Schema.String
|
|
1102
|
+
});
|
|
1103
|
+
const packageResourceDiagnosticSchema = Schema.Struct({
|
|
1104
|
+
severity: Schema.Literal("warning", "error"),
|
|
1105
|
+
message: Schema.String,
|
|
1106
|
+
scope: Schema.Literal("global", "project"),
|
|
1107
|
+
source: Schema.optional(Schema.String),
|
|
1108
|
+
projectId: Schema.optional(Schema.String),
|
|
1109
|
+
resourceType: Schema.optional(Schema.Literal("web-panel", "terminal-preset")),
|
|
1110
|
+
path: Schema.optional(Schema.String)
|
|
1111
|
+
});
|
|
1112
|
+
const packageListingSchema = Schema.Struct({
|
|
1113
|
+
source: Schema.String,
|
|
1114
|
+
identity: Schema.String,
|
|
1115
|
+
scope: Schema.Literal("global", "project"),
|
|
1116
|
+
projectId: nullableStringSchema,
|
|
1117
|
+
projectName: nullableStringSchema,
|
|
1118
|
+
installedPath: nullableStringSchema,
|
|
1119
|
+
resources: Schema.Struct({
|
|
1120
|
+
webPanels: Schema.NonNegativeInt,
|
|
1121
|
+
terminalPresets: Schema.NonNegativeInt
|
|
1122
|
+
}),
|
|
1123
|
+
diagnostics: Schema.Array(packageResourceDiagnosticSchema)
|
|
1124
|
+
});
|
|
1125
|
+
const packageOperationResultSchema = Schema.Struct({
|
|
1126
|
+
action: Schema.Literal("install", "remove", "update", "reload"),
|
|
1127
|
+
source: nullableStringSchema,
|
|
1128
|
+
scope: Schema.Literal("global", "project"),
|
|
1129
|
+
projectId: nullableStringSchema,
|
|
1130
|
+
status: Schema.Literal("installed", "removed", "updated", "reloaded", "skipped"),
|
|
1131
|
+
reason: Schema.optional(Schema.String)
|
|
1132
|
+
});
|
|
1133
|
+
const healthResponseSchema = Schema.Struct({
|
|
1134
|
+
ok: Schema.Literal(true),
|
|
1135
|
+
version: Schema.String,
|
|
1136
|
+
protocolVersion: Schema.Int,
|
|
1137
|
+
hostname: Schema.String,
|
|
1138
|
+
pid: Schema.Int,
|
|
1139
|
+
instanceId: nullableStringSchema,
|
|
1140
|
+
installationMethod: Schema.String,
|
|
1141
|
+
daemonLifecycle: Schema.Literal("treeport", "service", "external"),
|
|
1142
|
+
url: Schema.String
|
|
1143
|
+
});
|
|
1144
|
+
Schema.Struct({
|
|
1145
|
+
ok: Schema.Literal(true),
|
|
1146
|
+
version: Schema.optionalWith(Schema.NullOr(Schema.String), { default: () => null }),
|
|
1147
|
+
protocolVersion: Schema.optional(Schema.Int),
|
|
1148
|
+
hostname: Schema.optional(Schema.String),
|
|
1149
|
+
pid: Schema.optional(Schema.Int),
|
|
1150
|
+
instanceId: Schema.optional(nullableStringSchema),
|
|
1151
|
+
installationMethod: Schema.optional(Schema.String),
|
|
1152
|
+
daemonLifecycle: Schema.optional(Schema.Literal("treeport", "service", "external")),
|
|
1153
|
+
url: Schema.optional(Schema.String)
|
|
1154
|
+
});
|
|
1155
|
+
const browserInstallStatusSchema = Schema.Struct({
|
|
1156
|
+
installed: Schema.Boolean,
|
|
1157
|
+
executablePath: Schema.String,
|
|
1158
|
+
playwrightVersion: Schema.String,
|
|
1159
|
+
browserRevision: Schema.String,
|
|
1160
|
+
channel: Schema.Literal("chromium"),
|
|
1161
|
+
launchReady: Schema.Boolean,
|
|
1162
|
+
launchError: nullableStringSchema
|
|
1163
|
+
});
|
|
1164
|
+
const browserInstallResponseSchema = Schema.Struct({ message: Schema.String });
|
|
1165
|
+
const browserAgentResponseSchema = Schema.Struct({ output: Schema.String });
|
|
1166
|
+
const packageListingResponseSchema = Schema.Struct({
|
|
1167
|
+
packages: Schema.Array(packageListingSchema),
|
|
1168
|
+
diagnostics: Schema.Array(packageResourceDiagnosticSchema)
|
|
1169
|
+
});
|
|
1170
|
+
const packageOperationResponseSchema = Schema.Struct({ result: packageOperationResultSchema });
|
|
1171
|
+
const packageOperationsResponseSchema = Schema.Struct({ results: Schema.Array(packageOperationResultSchema) });
|
|
1172
|
+
const packageReloadResponseSchema = Schema.Struct({
|
|
1173
|
+
results: Schema.Array(packageOperationResultSchema),
|
|
1174
|
+
diagnostics: Schema.Array(packageResourceDiagnosticSchema)
|
|
1175
|
+
});
|
|
1176
|
+
const packageProjectResponseSchema = Schema.Struct({ project: projectRecordSchema });
|
|
1177
|
+
const projectsResponseSchema = Schema.Struct({ projects: Schema.Array(projectRecordSchema) });
|
|
1178
|
+
const recentProjectsResponseSchema = Schema.Struct({ projects: Schema.Array(recentProjectRecordSchema) });
|
|
1179
|
+
const projectResponseSchema = Schema.Struct({ project: projectRecordSchema });
|
|
1180
|
+
const worktreeResponseSchema = Schema.Struct({ worktree: worktreeRecordSchema });
|
|
1181
|
+
const worktreesResponseSchema = Schema.Struct({ worktrees: Schema.Array(worktreeRecordSchema) });
|
|
1182
|
+
const treeContextResponseSchema = Schema.Struct({ context: Schema.Record({
|
|
1183
|
+
key: Schema.String,
|
|
1184
|
+
value: Schema.String
|
|
1185
|
+
}) });
|
|
1186
|
+
const operationResponseSchema = Schema.Struct({ operation: operationRecordSchema });
|
|
1187
|
+
const operationsResponseSchema = Schema.Struct({ operations: Schema.Array(operationRecordSchema) });
|
|
1188
|
+
const terminalPresetsResponseSchema = Schema.Struct({ presets: Schema.Array(terminalPresetSchema) });
|
|
1189
|
+
const terminalPresetResponseSchema = Schema.Struct({ preset: terminalPresetSchema });
|
|
1190
|
+
const webPanelDefinitionsResponseSchema = Schema.Struct({ definitions: Schema.Array(webPanelDefinitionSchema) });
|
|
1191
|
+
const openWebPanelResponseSchema = Schema.Struct({
|
|
1192
|
+
panel: webPanelSchema,
|
|
1193
|
+
created: Schema.Boolean,
|
|
1194
|
+
reused: Schema.Boolean
|
|
1195
|
+
});
|
|
1196
|
+
const openBrowserPanelResponseSchema = Schema.Struct({ panel: browserPanelSchema });
|
|
1197
|
+
const terminalResponseSchema = Schema.Struct({ terminal: terminalRecordSchema$1 });
|
|
1198
|
+
const terminalObservationResponseSchema = Schema.Struct({
|
|
1199
|
+
terminal: terminalRecordSchema$1,
|
|
1200
|
+
metadata: terminalRuntimeMetadataSchema
|
|
1201
|
+
});
|
|
1202
|
+
const terminalCaptureResponseSchema = Schema.Struct({
|
|
1203
|
+
terminalId: Schema.String,
|
|
1204
|
+
capturedAt: Schema.String,
|
|
1205
|
+
lineLimit: Schema.Int.pipe(Schema.positive()),
|
|
1206
|
+
content: Schema.String
|
|
1207
|
+
});
|
|
1208
|
+
const removePreviewResponseSchema = Schema.Struct({ preview: removePreviewSchema });
|
|
1209
|
+
const webPanelContextResponseSchema = Schema.Struct({ context: webPanelContextSchema });
|
|
1210
|
+
const gitDiffResponseSchema = Schema.Struct({ diff: gitDiffSchema });
|
|
1211
|
+
const listenerDiscoveryResponseSchema = Schema.Struct({ discovery: worktreeListenerDiscoverySchema });
|
|
1212
|
+
const webPanelResponseSchema = Schema.Struct({ panel: webPanelSchema });
|
|
1213
|
+
const webPanelDefinitionResponseSchema = Schema.Struct({ definition: webPanelDefinitionSchema });
|
|
1214
|
+
const prResponseSchema = Schema.Struct({ pr: prInfoSchema });
|
|
1215
|
+
const terminatedTerminalsResponseSchema = Schema.Struct({ terminated: Schema.NonNegativeInt });
|
|
1216
|
+
const hasDataResponseSchema = Schema.Struct({ hasData: Schema.Boolean });
|
|
1217
|
+
const storageValueResponseSchema = Schema.Struct({
|
|
1218
|
+
found: Schema.Boolean,
|
|
1219
|
+
value: jsonValueSchema
|
|
1220
|
+
});
|
|
1221
|
+
const uploadedFileResponseSchema = Schema.Struct({ file: Schema.Struct({ path: Schema.String }) });
|
|
1222
|
+
const applicationUpdateStatusSchema = Schema.Struct({
|
|
1223
|
+
currentVersion: Schema.String,
|
|
1224
|
+
latestVersion: nullableStringSchema,
|
|
1225
|
+
updateAvailable: Schema.Boolean,
|
|
1226
|
+
checkedAt: nullableStringSchema,
|
|
1227
|
+
canUpdate: Schema.Boolean,
|
|
1228
|
+
blockedReason: nullableStringSchema,
|
|
1229
|
+
phase: Schema.Literal("idle", "checking", "starting", "inspect", "resolve", "stage", "verify", "stop", "activate", "restart", "health_check", "rollback", "complete", "recovery_required", "failed"),
|
|
1230
|
+
operationId: nullableStringSchema,
|
|
1231
|
+
targetVersion: nullableStringSchema,
|
|
1232
|
+
error: nullableStringSchema
|
|
1233
|
+
});
|
|
1234
|
+
//#endregion
|
|
1235
|
+
//#region ../../packages/shared/dist/presence-protocol.js
|
|
1236
|
+
const identifier = Schema.String.pipe(Schema.minLength(1), Schema.maxLength(128));
|
|
1237
|
+
const viewerIdentitySchema = Schema.Struct({
|
|
1238
|
+
source: Schema.Literal("local", "tailscale"),
|
|
1239
|
+
login: Schema.NullOr(Schema.String),
|
|
1240
|
+
name: Schema.NullOr(Schema.String),
|
|
1241
|
+
profilePicture: Schema.NullOr(Schema.String)
|
|
1242
|
+
});
|
|
1243
|
+
const presenceUpdateSchema = Schema.Struct({
|
|
1244
|
+
sessionId: Schema.UUID,
|
|
1245
|
+
worktreeId: Schema.NullOr(identifier),
|
|
1246
|
+
focusedPanelId: Schema.NullOr(identifier),
|
|
1247
|
+
visible: Schema.Boolean,
|
|
1248
|
+
focused: Schema.Boolean
|
|
1249
|
+
});
|
|
1250
|
+
const workspacePresenceSchema = Schema.Struct({
|
|
1251
|
+
...presenceUpdateSchema.fields,
|
|
1252
|
+
identity: viewerIdentitySchema
|
|
1253
|
+
});
|
|
1254
|
+
const presenceResponseSchema = Schema.Struct({ identity: viewerIdentitySchema });
|
|
1255
|
+
const PRESENCE_TIMEOUT_MS = 45e3;
|
|
1256
|
+
//#endregion
|
|
1257
|
+
//#region ../../packages/shared/dist/socket-protocol.js
|
|
1258
|
+
const identifierSchema = Schema.String.pipe(Schema.minLength(1), Schema.maxLength(128));
|
|
1259
|
+
const dateTimeString = Schema.String.pipe(Schema.filter((value) => !Number.isNaN(Date.parse(value))));
|
|
1260
|
+
const eventEnvelope = (type, data) => Schema.Struct({
|
|
1261
|
+
id: identifierSchema,
|
|
1262
|
+
type: Schema.Literal(type),
|
|
1263
|
+
at: dateTimeString,
|
|
1264
|
+
data
|
|
1265
|
+
});
|
|
1266
|
+
const projectEventDataSchema = Schema.Struct({
|
|
1267
|
+
projectId: identifierSchema,
|
|
1268
|
+
worktreeId: Schema.Null
|
|
1269
|
+
});
|
|
1270
|
+
const worktreeEventDataSchema = Schema.Struct({ worktreeId: identifierSchema });
|
|
1271
|
+
const projectWorktreeEventDataSchema = Schema.Struct({
|
|
1272
|
+
projectId: identifierSchema,
|
|
1273
|
+
worktreeId: identifierSchema
|
|
1274
|
+
});
|
|
1275
|
+
const operationEventDataSchema = Schema.Struct({
|
|
1276
|
+
operationId: identifierSchema,
|
|
1277
|
+
worktreeId: identifierSchema
|
|
1278
|
+
});
|
|
1279
|
+
const webPanelSnapshotSchema = Schema.Struct({
|
|
1280
|
+
id: identifierSchema,
|
|
1281
|
+
kind: Schema.Literal("web"),
|
|
1282
|
+
worktreeId: identifierSchema,
|
|
1283
|
+
definitionId: identifierSchema,
|
|
1284
|
+
title: nonEmptyString(),
|
|
1285
|
+
launch: Schema.Struct({
|
|
1286
|
+
input: Schema.NullOr(Schema.mutable(Schema.Record({
|
|
1287
|
+
key: Schema.String,
|
|
1288
|
+
value: jsonValueSchema
|
|
1289
|
+
}))),
|
|
1290
|
+
cwd: Schema.NullOr(Schema.String)
|
|
1291
|
+
}),
|
|
1292
|
+
permissions: Schema.mutable(Schema.Array(webPanelPermissionSchema)),
|
|
1293
|
+
sandbox: Schema.Struct({ allowSameOrigin: Schema.Boolean }),
|
|
1294
|
+
createdAt: Schema.String,
|
|
1295
|
+
updatedAt: Schema.String
|
|
1296
|
+
});
|
|
1297
|
+
const browserPanelSnapshotSchema = Schema.Struct({
|
|
1298
|
+
id: identifierSchema,
|
|
1299
|
+
kind: Schema.Literal("browser"),
|
|
1300
|
+
worktreeId: identifierSchema,
|
|
1301
|
+
title: Schema.String.pipe(Schema.minLength(1), Schema.maxLength(256)),
|
|
1302
|
+
url: Schema.Union(Schema.Literal("about:blank"), browserUrlSchema),
|
|
1303
|
+
createdAt: Schema.String,
|
|
1304
|
+
updatedAt: Schema.String
|
|
1305
|
+
});
|
|
1306
|
+
const openPanelSnapshotSchema = Schema.Union(webPanelSnapshotSchema, browserPanelSnapshotSchema);
|
|
1307
|
+
const terminalRecordSchema = Schema.Struct({
|
|
1308
|
+
id: identifierSchema,
|
|
1309
|
+
worktreeId: identifierSchema,
|
|
1310
|
+
name: nonEmptyString(),
|
|
1311
|
+
argv: Schema.mutable(Schema.Array(Schema.String)),
|
|
1312
|
+
shellCommand: Schema.NullOr(Schema.String),
|
|
1313
|
+
interactiveShell: Schema.Boolean,
|
|
1314
|
+
status: Schema.Literal("running", "exited", "missing"),
|
|
1315
|
+
exitCode: Schema.NullOr(Schema.Int),
|
|
1316
|
+
createdAt: Schema.String,
|
|
1317
|
+
updatedAt: Schema.String
|
|
1318
|
+
});
|
|
1319
|
+
function nonEmptyString() {
|
|
1320
|
+
return Schema.String.pipe(Schema.minLength(1));
|
|
1321
|
+
}
|
|
1322
|
+
const productEventSchema = Schema.Union(eventEnvelope("presence.changed", Schema.Struct({
|
|
1323
|
+
viewers: Schema.Array(workspacePresenceSchema),
|
|
1324
|
+
worktreeId: Schema.Null
|
|
1325
|
+
})), eventEnvelope("project.created", projectEventDataSchema), eventEnvelope("project.updated", projectEventDataSchema), eventEnvelope("project.removed", projectEventDataSchema), eventEnvelope("worktree.created", projectWorktreeEventDataSchema), eventEnvelope("worktree.updated", worktreeEventDataSchema), eventEnvelope("worktree.removed", projectWorktreeEventDataSchema), eventEnvelope("create.started", Schema.Struct({
|
|
1326
|
+
projectId: identifierSchema,
|
|
1327
|
+
operationId: identifierSchema,
|
|
1328
|
+
worktreeId: Schema.Null
|
|
1329
|
+
})), eventEnvelope("create.completed", Schema.Struct({
|
|
1330
|
+
projectId: identifierSchema,
|
|
1331
|
+
operationId: identifierSchema,
|
|
1332
|
+
worktreeId: identifierSchema
|
|
1333
|
+
})), eventEnvelope("create.failed", Schema.Struct({
|
|
1334
|
+
projectId: identifierSchema,
|
|
1335
|
+
operationId: identifierSchema,
|
|
1336
|
+
worktreeId: Schema.Null
|
|
1337
|
+
})), eventEnvelope("terminal.created", Schema.Struct({
|
|
1338
|
+
projectId: Schema.optional(identifierSchema),
|
|
1339
|
+
worktreeId: identifierSchema,
|
|
1340
|
+
terminalId: identifierSchema,
|
|
1341
|
+
terminal: terminalRecordSchema
|
|
1342
|
+
})), eventEnvelope("terminal.updated", Schema.Struct({
|
|
1343
|
+
worktreeId: identifierSchema,
|
|
1344
|
+
terminalId: identifierSchema
|
|
1345
|
+
})), eventEnvelope("terminal.removed", Schema.Struct({
|
|
1346
|
+
worktreeId: identifierSchema,
|
|
1347
|
+
terminalId: identifierSchema
|
|
1348
|
+
})), eventEnvelope("terminal.metadata", Schema.Struct({
|
|
1349
|
+
...terminalRuntimeMetadataFields,
|
|
1350
|
+
worktreeId: Schema.Null
|
|
1351
|
+
})), eventEnvelope("terminal.controller_changed", Schema.Struct({
|
|
1352
|
+
terminalId: identifierSchema,
|
|
1353
|
+
controlled: Schema.Boolean,
|
|
1354
|
+
worktreeId: Schema.Null
|
|
1355
|
+
})), eventEnvelope("panel.created", Schema.Struct({
|
|
1356
|
+
worktreeId: identifierSchema,
|
|
1357
|
+
panelId: identifierSchema
|
|
1358
|
+
})), eventEnvelope("panel.updated", Schema.Struct({
|
|
1359
|
+
worktreeId: identifierSchema,
|
|
1360
|
+
panelId: identifierSchema
|
|
1361
|
+
})), eventEnvelope("panel.open_requested", Schema.Struct({
|
|
1362
|
+
worktreeId: identifierSchema,
|
|
1363
|
+
panelId: identifierSchema,
|
|
1364
|
+
panel: openPanelSnapshotSchema,
|
|
1365
|
+
sourceTerminalId: Schema.NullOr(identifierSchema),
|
|
1366
|
+
sourcePanelId: Schema.NullOr(identifierSchema)
|
|
1367
|
+
})), eventEnvelope("panel.removed", Schema.Struct({
|
|
1368
|
+
worktreeId: identifierSchema,
|
|
1369
|
+
panelId: identifierSchema
|
|
1370
|
+
})), eventEnvelope("workspace.open_requested", Schema.Struct({
|
|
1371
|
+
worktreeId: identifierSchema,
|
|
1372
|
+
sourceTerminalId: identifierSchema
|
|
1373
|
+
})), eventEnvelope("remove.started", Schema.Struct({
|
|
1374
|
+
...operationEventDataSchema.fields,
|
|
1375
|
+
kind: Schema.Literal("remove")
|
|
1376
|
+
})), eventEnvelope("remove.completed", operationEventDataSchema), eventEnvelope("remove.failed", Schema.Struct({
|
|
1377
|
+
...operationEventDataSchema.fields,
|
|
1378
|
+
error: Schema.String
|
|
1379
|
+
})));
|
|
1380
|
+
const eventsSnapshotSchema = Schema.Struct({
|
|
1381
|
+
at: dateTimeString,
|
|
1382
|
+
terminalMetadata: Schema.Array(terminalRuntimeMetadataSchema),
|
|
1383
|
+
webPanels: Schema.Array(webPanelSnapshotSchema),
|
|
1384
|
+
browserPanels: Schema.Array(browserPanelSnapshotSchema),
|
|
1385
|
+
presence: Schema.Array(workspacePresenceSchema)
|
|
1386
|
+
});
|
|
1387
|
+
const socketHandshakeSchema = Schema.Struct({
|
|
1388
|
+
type: Schema.Literal("handshake"),
|
|
1389
|
+
auth: jsonValueSchema,
|
|
1390
|
+
query: Schema.Record({
|
|
1391
|
+
key: Schema.String,
|
|
1392
|
+
value: Schema.String
|
|
1393
|
+
})
|
|
1394
|
+
});
|
|
1395
|
+
const socketMessageSchema = Schema.Struct({
|
|
1396
|
+
event: Schema.String.pipe(Schema.minLength(1), Schema.maxLength(80)),
|
|
1397
|
+
payload: jsonValueSchema
|
|
1398
|
+
});
|
|
1399
|
+
function decodeOrNull(schema, value) {
|
|
1400
|
+
const parsed = Schema.decodeUnknownEither(schema, { onExcessProperty: "error" })(value);
|
|
1401
|
+
return Either.isRight(parsed) ? parsed.right : null;
|
|
1402
|
+
}
|
|
1403
|
+
function parseProductEvent(value) {
|
|
1404
|
+
return decodeOrNull(productEventSchema, value);
|
|
1405
|
+
}
|
|
1406
|
+
function parseSocketHandshake(value) {
|
|
1407
|
+
return decodeOrNull(socketHandshakeSchema, value);
|
|
1408
|
+
}
|
|
1409
|
+
function parseSocketMessage(value) {
|
|
1410
|
+
return decodeOrNull(socketMessageSchema, value);
|
|
1411
|
+
}
|
|
1412
|
+
//#endregion
|
|
1413
|
+
//#region ../../packages/shared/dist/network-rpc.js
|
|
1414
|
+
const projectEventsItemSchema = Schema.Union(Schema.Struct({
|
|
1415
|
+
_tag: Schema.Literal("Snapshot"),
|
|
1416
|
+
snapshot: eventsSnapshotSchema
|
|
1417
|
+
}), Schema.Struct({
|
|
1418
|
+
_tag: Schema.Literal("ProductEvent"),
|
|
1419
|
+
event: productEventSchema
|
|
1420
|
+
}));
|
|
1421
|
+
const projectEventsFailureSchema = Schema.Struct({
|
|
1422
|
+
_tag: Schema.Literal("ProjectEventsFailure"),
|
|
1423
|
+
message: Schema.String
|
|
1424
|
+
});
|
|
1425
|
+
const WatchProjectEvents = Rpc.make("WatchProjectEvents", {
|
|
1426
|
+
payload: { protocol: Schema.Literal(3) },
|
|
1427
|
+
success: projectEventsItemSchema,
|
|
1428
|
+
error: projectEventsFailureSchema,
|
|
1429
|
+
stream: true
|
|
1430
|
+
});
|
|
1431
|
+
var TreeportRpcs = class extends RpcGroup.make(WatchProjectEvents) {};
|
|
1432
|
+
//#endregion
|
|
1433
|
+
//#region ../../packages/shared/dist/network-rpc-client.js
|
|
1434
|
+
function treeportRpcClientLayer(url) {
|
|
1435
|
+
return RpcClient.layerProtocolHttp({ url }).pipe(Layer.provide([FetchHttpClient.layer, RpcSerialization.layerNdjson]));
|
|
1436
|
+
}
|
|
1437
|
+
//#endregion
|
|
1438
|
+
//#region ../../packages/shared/dist/schema.js
|
|
1439
|
+
function decodeUnknownOrNull(schema, value) {
|
|
1440
|
+
const result = Schema.decodeUnknownEither(schema, { onExcessProperty: "error" })(value);
|
|
1441
|
+
return Either.isRight(result) ? result.right : null;
|
|
1442
|
+
}
|
|
1443
|
+
function isSchemaValue(schema, value) {
|
|
1444
|
+
return Schema.is(schema, { onExcessProperty: "error" })(value);
|
|
1445
|
+
}
|
|
1446
|
+
Schema.Struct({ message: Schema.String });
|
|
1447
|
+
//#endregion
|
|
1448
|
+
//#region ../../packages/shared/dist/index.js
|
|
1449
|
+
const TERMINAL_MAX_UPLOAD_BYTES = 50 * 1024 * 1024;
|
|
1450
|
+
const TERMINAL_EXECUTABLE_MAX_LENGTH = 4096;
|
|
1451
|
+
const TERMINAL_ARGUMENT_MAX_LENGTH = 4096;
|
|
1452
|
+
const TERMINAL_CAPTURE_MAX_LINES = 5e3;
|
|
1453
|
+
const WEB_PANEL_INPUT_MAX_BYTES = 64 * 1024;
|
|
1454
|
+
const TREE_CONTEXT_VALUE_MAX_LENGTH = 16 * 1024;
|
|
1455
|
+
const TREE_FILE_MAX_BYTES = 2 * 1024 * 1024;
|
|
1456
|
+
const TREE_FILE_LIST_MAX_ENTRIES = 5e4;
|
|
1457
|
+
function formatCommandLine(argv) {
|
|
1458
|
+
return argv.map((value) => {
|
|
1459
|
+
if (value === "") return "\"\"";
|
|
1460
|
+
if (!/[\s"'\\]/.test(value)) return value;
|
|
1461
|
+
return `"${value.replace(/["\\]/g, "\\$&")}"`;
|
|
1462
|
+
}).join(" ");
|
|
1463
|
+
}
|
|
1464
|
+
const PROJECT_COLORS = [
|
|
1465
|
+
"rose",
|
|
1466
|
+
"orange",
|
|
1467
|
+
"amber",
|
|
1468
|
+
"emerald",
|
|
1469
|
+
"cyan",
|
|
1470
|
+
"blue",
|
|
1471
|
+
"violet",
|
|
1472
|
+
"pink"
|
|
1473
|
+
];
|
|
1474
|
+
const apiErrorBodySchema = Schema.Struct({ error: Schema.Struct({
|
|
1475
|
+
code: Schema.String,
|
|
1476
|
+
message: Schema.String,
|
|
1477
|
+
details: Schema.optional(Schema.Unknown)
|
|
1478
|
+
}) });
|
|
1479
|
+
const browseDirectoryQuerySchema = Schema.Struct({
|
|
1480
|
+
input: Schema.Trim.pipe(Schema.minLength(1), Schema.maxLength(4096)),
|
|
1481
|
+
hidden: Schema.optionalWith(Schema.Literal("true", "false").pipe(Schema.transform(Schema.Boolean, {
|
|
1482
|
+
strict: true,
|
|
1483
|
+
decode: (value) => value === "true",
|
|
1484
|
+
encode: (value) => value ? "true" : "false"
|
|
1485
|
+
})), { default: () => false })
|
|
1486
|
+
});
|
|
1487
|
+
const terminalCaptureQuerySchema = Schema.Struct({ lines: Schema.optionalWith(Schema.NumberFromString.pipe(Schema.int(), Schema.between(1, TERMINAL_CAPTURE_MAX_LINES)), { default: () => 200 }) });
|
|
1488
|
+
const registerProjectSchema = Schema.Struct({
|
|
1489
|
+
path: Schema.Trim.pipe(Schema.minLength(1)),
|
|
1490
|
+
name: Schema.optional(Schema.Trim.pipe(Schema.minLength(1), Schema.maxLength(120)))
|
|
1491
|
+
});
|
|
1492
|
+
const updateProjectSchema = Schema.Struct({ color: Schema.NullOr(Schema.Literal(...PROJECT_COLORS)) });
|
|
1493
|
+
const terminalNameSchema = Schema.Trim.pipe(Schema.minLength(1), Schema.maxLength(120));
|
|
1494
|
+
const terminalArgvSchema = Schema.Array(Schema.String).pipe(Schema.minItems(1), Schema.maxItems(128));
|
|
1495
|
+
const terminalPresetArgumentSchema = Schema.String.pipe(Schema.maxLength(TERMINAL_ARGUMENT_MAX_LENGTH));
|
|
1496
|
+
const terminalPresetFields = {
|
|
1497
|
+
name: terminalNameSchema,
|
|
1498
|
+
executable: Schema.String.pipe(Schema.minLength(1), Schema.maxLength(TERMINAL_EXECUTABLE_MAX_LENGTH), Schema.filter((value) => value.trim().length > 0, { message: () => "Executable cannot be blank" })),
|
|
1499
|
+
args: Schema.Array(terminalPresetArgumentSchema).pipe(Schema.maxItems(127)),
|
|
1500
|
+
closeOnSuccess: Schema.optionalWith(Schema.Boolean, { default: () => false })
|
|
1501
|
+
};
|
|
1502
|
+
const repositoryTerminalPresetSchema = Schema.Struct(terminalPresetFields);
|
|
1503
|
+
const repositoryTerminalPresetIdSchema = Schema.String.pipe(Schema.pattern(/^[a-z0-9][a-z0-9._-]{0,119}$/, { message: () => "Preset IDs must contain only lowercase letters, numbers, dots, underscores, and hyphens" }));
|
|
1504
|
+
const repositoryTerminalPresetsFileSchema = Schema.Struct({
|
|
1505
|
+
version: Schema.Literal(1),
|
|
1506
|
+
presets: Schema.Record({
|
|
1507
|
+
key: repositoryTerminalPresetIdSchema,
|
|
1508
|
+
value: Schema.Unknown
|
|
1509
|
+
})
|
|
1510
|
+
});
|
|
1511
|
+
const terminalPresetRevisionSchema = Schema.String.pipe(Schema.minLength(1), Schema.maxLength(64));
|
|
1512
|
+
const treeContextFieldIdSchema = Schema.String.pipe(Schema.pattern(/^[a-z0-9][a-z0-9._-]{0,119}$/, { message: () => "Field IDs must contain only lowercase letters, numbers, dots, underscores, and hyphens" }));
|
|
1513
|
+
const treeContextFieldDefinitionSchema = Schema.Struct({
|
|
1514
|
+
id: treeContextFieldIdSchema,
|
|
1515
|
+
label: Schema.Trim.pipe(Schema.minLength(1), Schema.maxLength(120), Schema.filter((value) => !value.includes("\0"), { message: () => "Field labels cannot contain NUL" })),
|
|
1516
|
+
input: Schema.Literal("text", "textarea")
|
|
1517
|
+
});
|
|
1518
|
+
const treeContextValuesSchema = Schema.Record({
|
|
1519
|
+
key: treeContextFieldIdSchema,
|
|
1520
|
+
value: Schema.Trim.pipe(Schema.minLength(1), Schema.maxLength(TREE_CONTEXT_VALUE_MAX_LENGTH), Schema.filter((value) => !value.includes("\0"), { message: () => "Tree context values cannot contain NUL" }))
|
|
1521
|
+
}).pipe(Schema.filter((values) => {
|
|
1522
|
+
const entries = Object.entries(values);
|
|
1523
|
+
return entries.length <= 64 && entries.reduce((length, [key, value]) => length + key.length + value.length, 0) <= 65536;
|
|
1524
|
+
}, { message: () => "Tree context exceeds its size limit" }));
|
|
1525
|
+
const initialTerminalSchema = Schema.Struct({
|
|
1526
|
+
name: terminalNameSchema,
|
|
1527
|
+
initialTitle: Schema.optional(terminalNameSchema),
|
|
1528
|
+
argv: Schema.optional(terminalArgvSchema),
|
|
1529
|
+
returnToShell: Schema.optional(Schema.Boolean),
|
|
1530
|
+
initialSize: Schema.optional(terminalSizeSchema)
|
|
1531
|
+
});
|
|
1532
|
+
const createWorktreeSchema = Schema.Struct({
|
|
1533
|
+
name: Schema.Trim.pipe(Schema.minLength(1), Schema.maxLength(120)),
|
|
1534
|
+
base: Schema.optionalWith(Schema.Literal("default", "current"), { default: () => "default" }),
|
|
1535
|
+
context: Schema.optional(treeContextValuesSchema),
|
|
1536
|
+
sourceWorktreeId: Schema.optional(Schema.String.pipe(Schema.minLength(1))),
|
|
1537
|
+
initialTerminal: Schema.optional(initialTerminalSchema)
|
|
1538
|
+
}).pipe(Schema.filter((value) => value.base !== "current" || Boolean(value.sourceWorktreeId), { message: () => "A source tree is required when starting from current" }));
|
|
1539
|
+
const terminalCwdSchema = Schema.String.pipe(Schema.minLength(1), Schema.maxLength(4096), Schema.filter((value) => value.trim().length > 0 && !value.includes("\0"), { message: () => "Working directory cannot be blank or contain NUL" }));
|
|
1540
|
+
const terminalEnvironmentKeySchema = Schema.String.pipe(Schema.minLength(1), Schema.maxLength(256), Schema.filter((value) => !value.includes("=") && !value.includes("\0"), { message: () => "Environment keys cannot contain equals or NUL" }));
|
|
1541
|
+
const terminalShellCommandSchema = Schema.String.pipe(Schema.minLength(1), Schema.maxLength(TERMINAL_ARGUMENT_MAX_LENGTH), Schema.filter((value) => value.trim().length > 0 && !value.includes("\0"), { message: () => "Shell command cannot be blank or contain NUL" }));
|
|
1542
|
+
const terminalEnvironmentSchema = Schema.Record({
|
|
1543
|
+
key: terminalEnvironmentKeySchema,
|
|
1544
|
+
value: Schema.String.pipe(Schema.maxLength(TERMINAL_ARGUMENT_MAX_LENGTH), Schema.filter((value) => !value.includes("\0"), { message: () => "Environment values cannot contain NUL" }))
|
|
1545
|
+
}).pipe(Schema.filter((value) => Object.keys(value).length <= 128, { message: () => "Environment cannot contain more than 128 variables" }));
|
|
1546
|
+
const createTerminalSchema = Schema.Struct({
|
|
1547
|
+
name: terminalNameSchema,
|
|
1548
|
+
initialTitle: Schema.optional(terminalNameSchema),
|
|
1549
|
+
argv: Schema.optional(terminalArgvSchema),
|
|
1550
|
+
shellCommand: Schema.optional(terminalShellCommandSchema),
|
|
1551
|
+
cwd: Schema.optional(terminalCwdSchema),
|
|
1552
|
+
env: Schema.optional(terminalEnvironmentSchema),
|
|
1553
|
+
returnToShell: Schema.optional(Schema.Boolean),
|
|
1554
|
+
closeOnSuccess: Schema.optional(Schema.Boolean),
|
|
1555
|
+
initialSize: Schema.optional(terminalSizeSchema)
|
|
1556
|
+
}).pipe(Schema.filter((value) => !(value.argv && value.shellCommand), { message: () => "A terminal cannot have both argv and a shell command" }), Schema.filter((value) => !(value.returnToShell && value.closeOnSuccess), { message: () => "A terminal cannot return to a shell and close on success" }));
|
|
1557
|
+
const updateTerminalSchema = Schema.Struct({ name: terminalNameSchema });
|
|
1558
|
+
const reorderWorkspaceItemsSchema = Schema.Struct({ itemIds: Schema.Array(Schema.String.pipe(Schema.minLength(1), Schema.maxLength(128))).pipe(Schema.minItems(1), Schema.filter((itemIds) => new Set(itemIds).size === itemIds.length, { message: () => "Item order cannot contain duplicates" })) });
|
|
1559
|
+
const webPanelInputSchema = Schema.Record({
|
|
1560
|
+
key: Schema.String,
|
|
1561
|
+
value: jsonValueSchema
|
|
1562
|
+
});
|
|
1563
|
+
const createWebPanelSchema = Schema.Struct({
|
|
1564
|
+
definitionId: Schema.String.pipe(Schema.minLength(1), Schema.maxLength(256)),
|
|
1565
|
+
input: Schema.optional(Schema.NullOr(webPanelInputSchema)),
|
|
1566
|
+
launchCwd: Schema.optional(Schema.NullOr(Schema.String.pipe(Schema.maxLength(4096))))
|
|
1567
|
+
});
|
|
1568
|
+
const updateWebPanelPermissionGrantSchema = Schema.Struct({
|
|
1569
|
+
granted: Schema.Boolean,
|
|
1570
|
+
permissions: Schema.Array(webPanelPermissionSchema)
|
|
1571
|
+
});
|
|
1572
|
+
const createBrowserPanelSchema = Schema.Struct({
|
|
1573
|
+
url: Schema.optional(browserUrlSchema),
|
|
1574
|
+
sourceTerminalId: Schema.optional(Schema.NullOr(Schema.String.pipe(Schema.minLength(1), Schema.maxLength(128))))
|
|
1575
|
+
});
|
|
1576
|
+
const openBrowserPanelFromTerminalSchema = Schema.Struct({ url: browserUrlSchema });
|
|
1577
|
+
const openWebPanelSchema = Schema.Struct({
|
|
1578
|
+
...createWebPanelSchema.fields,
|
|
1579
|
+
newInstance: Schema.optional(Schema.Boolean),
|
|
1580
|
+
sourceTerminalId: Schema.optional(Schema.NullOr(Schema.String.pipe(Schema.minLength(1), Schema.maxLength(128))))
|
|
1581
|
+
});
|
|
1582
|
+
const requestWorkspaceOpenSchema = Schema.Struct({ sourceTerminalId: Schema.String.pipe(Schema.minLength(1), Schema.maxLength(128)) });
|
|
1583
|
+
const webPanelStorageKeySchema = Schema.String.pipe(Schema.minLength(1), Schema.maxLength(128));
|
|
1584
|
+
const getWebPanelStorageSchema = Schema.Struct({ key: webPanelStorageKeySchema });
|
|
1585
|
+
const setWebPanelStorageSchema = Schema.Struct({
|
|
1586
|
+
key: webPanelStorageKeySchema,
|
|
1587
|
+
value: jsonValueSchema
|
|
1588
|
+
});
|
|
1589
|
+
const deleteWebPanelStorageSchema = Schema.Struct({ key: webPanelStorageKeySchema });
|
|
1590
|
+
const treeFilePathSchema = Schema.String.pipe(Schema.minLength(1), Schema.maxLength(4096), Schema.filter((value) => !value.includes("\0") && !value.startsWith("/") && value.split("/").every((segment) => segment !== "" && segment !== ".."), { message: () => "File path must be a relative path inside the tree" }));
|
|
1591
|
+
const readTreeFileSchema = Schema.Struct({ path: treeFilePathSchema });
|
|
1592
|
+
const searchTreeFilesSchema = Schema.Struct({ query: Schema.String.pipe(Schema.minLength(1), Schema.maxLength(256), Schema.filter((value) => !/[\0\r\n]/.test(value), { message: () => "Search query must be one line and cannot contain NUL" })) });
|
|
1593
|
+
const writeTreeFileSchema = Schema.Struct({
|
|
1594
|
+
path: treeFilePathSchema,
|
|
1595
|
+
content: Schema.String,
|
|
1596
|
+
expectedRevision: Schema.String.pipe(Schema.minLength(1), Schema.maxLength(128))
|
|
1597
|
+
});
|
|
1598
|
+
const createTerminalPresetSchema = Schema.Struct(terminalPresetFields);
|
|
1599
|
+
const updateTerminalPresetSchema = Schema.Struct({
|
|
1600
|
+
...terminalPresetFields,
|
|
1601
|
+
closeOnSuccess: Schema.optional(Schema.Boolean),
|
|
1602
|
+
expectedUpdatedAt: terminalPresetRevisionSchema
|
|
1603
|
+
});
|
|
1604
|
+
const deleteTerminalPresetSchema = Schema.Struct({ expectedUpdatedAt: terminalPresetRevisionSchema });
|
|
1605
|
+
const packageProjectQuerySchema = Schema.Struct({ path: Schema.Trim.pipe(Schema.minLength(1), Schema.maxLength(4096)) });
|
|
1606
|
+
const packageInstallSchema = Schema.Struct({
|
|
1607
|
+
source: Schema.Trim.pipe(Schema.minLength(1), Schema.maxLength(4096)),
|
|
1608
|
+
projectId: Schema.optional(Schema.String.pipe(Schema.minLength(1)))
|
|
1609
|
+
});
|
|
1610
|
+
const packageRemoveSchema = Schema.Struct({
|
|
1611
|
+
source: Schema.String.pipe(Schema.minLength(1)),
|
|
1612
|
+
projectId: Schema.optional(Schema.String.pipe(Schema.minLength(1)))
|
|
1613
|
+
});
|
|
1614
|
+
const packageUpdateSchema = Schema.Struct({ source: Schema.optional(Schema.Trim.pipe(Schema.minLength(1), Schema.maxLength(4096))) });
|
|
1615
|
+
const packageReloadSchema = Schema.Struct({ projectId: Schema.optional(Schema.String.pipe(Schema.minLength(1))) });
|
|
1616
|
+
const removeWorktreeSchema = Schema.Struct({
|
|
1617
|
+
confirmationToken: Schema.String.pipe(Schema.length(64)),
|
|
1618
|
+
confirmDestructive: Schema.Boolean,
|
|
1619
|
+
skipCleanup: Schema.optionalWith(Schema.Boolean, { default: () => false })
|
|
1620
|
+
});
|
|
1621
|
+
Schema.Struct({
|
|
1622
|
+
project: Schema.String.pipe(Schema.minLength(1)),
|
|
1623
|
+
worktreeName: Schema.Trim.pipe(Schema.minLength(1), Schema.maxLength(120)),
|
|
1624
|
+
name: terminalNameSchema,
|
|
1625
|
+
argv: Schema.optional(terminalArgvSchema),
|
|
1626
|
+
base: Schema.optionalWith(Schema.Literal("default", "current"), { default: () => "default" }),
|
|
1627
|
+
sourceWorktreeId: Schema.optional(Schema.String.pipe(Schema.minLength(1)))
|
|
1628
|
+
}).pipe(Schema.filter((value) => value.base !== "current" || Boolean(value.sourceWorktreeId), { message: () => "A source tree is required when starting from current" }));
|
|
1629
|
+
//#endregion
|
|
1630
|
+
export { applicationUpdateStatusSchema as $, TERMINAL_MAX_INPUT_BYTES as $t, requestWorkspaceOpenSchema as A, parseBrowserOwnerAuth as An, terminalPresetDefinitionsQuerySchema as At, updateWebPanelPermissionGrantSchema as B, treeFileSearchResultSchema as Bt, packageUpdateSchema as C, browserTicketRequestSchema as Cn, projectsResponseSchema as Ct, reorderWorkspaceItemsSchema as D, parseBrowserAuth as Dn, terminalCaptureResponseSchema as Dt, removeWorktreeSchema as E, encodeBrowserFrame as En, storageValueResponseSchema as Et, treeContextValuesSchema as F, treeContextFieldListingSchema as Ft, treeportRpcClientLayer as G, webPanelDefinitionsResponseSchema as Gt, writeTreeFileSchema as H, uploadedFileResponseSchema as Ht, treeFilePathSchema as I, treeContextFieldsQuerySchema as It, parseSocketHandshake as J, worktreesResponseSchema as Jt, TreeportRpcs as K, webPanelResponseSchema as Kt, updateProjectSchema as L, treeContextResponseSchema as Lt, setWebPanelStorageSchema as M, terminalPresetsResponseSchema as Mt, terminalCaptureQuerySchema as N, terminalResponseSchema as Nt, repositoryTerminalPresetSchema as O, parseBrowserCaptureMessage as On, terminalObservationResponseSchema as Ot, treeContextFieldDefinitionSchema as P, terminatedTerminalsResponseSchema as Pt, presenceUpdateSchema as Q, TERMINAL_MAX_CLIENT_MESSAGE_BYTES as Qt, updateTerminalPresetSchema as R, treeFileListingSchema as Rt, packageRemoveSchema as S, browserOwnerTicketResponseSchema as Sn, projectResponseSchema as St, registerProjectSchema as T, browserUrlSchema as Tn, removePreviewResponseSchema as Tt, decodeUnknownOrNull as U, webPanelContextResponseSchema as Ut, webPanelInputSchema as V, treeFileWriteResultSchema as Vt, isSchemaValue as W, webPanelDefinitionResponseSchema as Wt, PRESENCE_TIMEOUT_MS as X, SOCKET_PATH as Xt, parseSocketMessage as Y, BROWSER_VIDEO_CAPTURE_SOURCE as Yt, presenceResponseSchema as Z, TERMINAL_CONTROLLER_GRACE_MS as Zt, openBrowserPanelFromTerminalSchema as _, BROWSER_MAX_MESSAGE_BYTES as _n, packageOperationResponseSchema as _t, WEB_PANEL_INPUT_MAX_BYTES as a, parseTerminalProgress as an, gitDiffImageSchema as at, packageProjectQuerySchema as b, browserOwnerIdentitySchema as bn, packageReloadResponseSchema as bt, createBrowserPanelSchema as c, terminalInputSchema as cn, healthResponseSchema as ct, createWebPanelSchema as d, terminalResizeSchema as dn, openBrowserPanelResponseSchema as dt, TERMINAL_OUTPUT_HIGH_WATERMARK as en, browserAgentResponseSchema as et, createWorktreeSchema as f, terminalSizeSchema as fn, openWebPanelResponseSchema as ft, getWebPanelStorageSchema as g, BROWSER_MAX_FRAME_BYTES as gn, packageListingResponseSchema as gt, formatCommandLine as h, webPanelPermissionSchema as hn, operationsResponseSchema as ht, TREE_FILE_MAX_BYTES as i, parseTerminalClientEvent as in, directoryBrowseResponseSchema as it, searchTreeFilesSchema as j, parseBrowserOwnerClientMessage as jn, terminalPresetResponseSchema as jt, repositoryTerminalPresetsFileSchema as k, parseBrowserClientMessage as kn, terminalPresetDefinitionListingSchema as kt, createTerminalPresetSchema as l, terminalOutputAckSchema as ln, listenerDiscoveryResponseSchema as lt, deleteWebPanelStorageSchema as m, gitDiffImageRequestSchema as mn, operationResponseSchema as mt, TERMINAL_MAX_UPLOAD_BYTES as n, TERMINAL_OUTPUT_MAX_UNACKNOWLEDGED_BYTES as nn, browserInstallStatusSchema as nt, apiErrorBodySchema as o, terminalBellAcknowledgementSchema as on, gitDiffResponseSchema as ot, deleteTerminalPresetSchema as p, terminalTakeControlSchema as pn, operationQuerySchema as pt, parseProductEvent as q, worktreeResponseSchema as qt, TREE_FILE_LIST_MAX_ENTRIES as r, parseTerminalAuth as rn, deletePanelQuerySchema as rt, browseDirectoryQuerySchema as s, terminalBinarySchema as sn, hasDataResponseSchema as st, TERMINAL_CAPTURE_MAX_LINES as t, TERMINAL_OUTPUT_LOW_WATERMARK as tn, browserInstallResponseSchema as tt, createTerminalSchema as u, terminalQueryAuthorityRequestSchema as un, okResponseSchema as ut, openWebPanelSchema as v, browserAgentCommandSchema as vn, packageOperationsResponseSchema as vt, readTreeFileSchema as w, browserTicketResponseSchema as wn, recentProjectsResponseSchema as wt, packageReloadSchema as x, browserOwnerTicketRequestSchema as xn, prResponseSchema as xt, packageInstallSchema as y, browserOwnerEndpointSchema as yn, packageProjectResponseSchema as yt, updateTerminalSchema as z, treeFileSchema as zt };
|