glimmervoid 0.0.0-stage → 0.30.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.
Files changed (59) hide show
  1. package/LICENSE +48 -0
  2. package/README.md +195 -2
  3. package/dist/bin/glimmervoid.js +275 -0
  4. package/dist/chunks/adapters-Dho1VSY5.js +2 -0
  5. package/dist/chunks/adapters-zPDx1Xox.js +575 -0
  6. package/dist/chunks/agent-api-cli-D0MmtEdz.js +71 -0
  7. package/dist/chunks/agent-api-core-Dz0r21y9.js +103 -0
  8. package/dist/chunks/agent-setup-cli-B5Atxr3F.js +139 -0
  9. package/dist/chunks/ascii-figure-core-pDAwtlKO.js +45 -0
  10. package/dist/chunks/child-process-safe-DRGsp0TE.js +69 -0
  11. package/dist/chunks/child-process-safe-DvQjXsgz.js +2 -0
  12. package/dist/chunks/config-path-core-DFt-TemS.js +38 -0
  13. package/dist/chunks/config-store-CC8T3okC.js +2 -0
  14. package/dist/chunks/config-store-mm7MgzoL.js +1412 -0
  15. package/dist/chunks/contracts-DGkKNh9W.js +3020 -0
  16. package/dist/chunks/grok-DuU8xVLZ.js +436 -0
  17. package/dist/chunks/hook-command-core-DclEoE9e.js +14 -0
  18. package/dist/chunks/hook-relay-core-BHfYFnYV.js +88 -0
  19. package/dist/chunks/hook-tools-pSJia7ks.js +74 -0
  20. package/dist/chunks/ingest-core-DWI1Mbu4.js +342 -0
  21. package/dist/chunks/ingest-editor-core-BuI1gMF_.js +445 -0
  22. package/dist/chunks/loopback-post-C7C22eYi.js +79 -0
  23. package/dist/chunks/main-CuIZQPhZ.js +43559 -0
  24. package/dist/chunks/node-pty-preflight-CK1knGIR.js +162 -0
  25. package/dist/chunks/pair-cli-w-gCAF-1.js +110 -0
  26. package/dist/chunks/path-doctor-C23VAqeu.js +63 -0
  27. package/dist/chunks/refocus-core-BKQKllq7.js +38 -0
  28. package/dist/chunks/relay-stdin-CpHvLu6M.js +20 -0
  29. package/dist/chunks/remote-config-C2ytQwrs.js +525 -0
  30. package/dist/chunks/rtk-hook-core-Bl6gYHPN.js +133 -0
  31. package/dist/chunks/rtk-resolver-CLo-gZzw.js +21 -0
  32. package/dist/chunks/rtk-resolver-CMQAidlI.js +2 -0
  33. package/dist/chunks/runtime-paths-Ci_ksSkj.js +75 -0
  34. package/dist/chunks/runtime-paths-JLrZ3wyi.js +2 -0
  35. package/dist/chunks/sandbox-deps-Dd5-kZnf.js +67 -0
  36. package/dist/chunks/session-Cez8aIWg.js +164 -0
  37. package/dist/chunks/spawn-command-Cc40FiZI.js +134 -0
  38. package/dist/chunks/visions-cli-BXQFIBCX.js +98 -0
  39. package/dist/chunks/visions-setup-CvVnOe1r.js +1753 -0
  40. package/dist/client/assets/favicon-CKygeLwW.svg +7 -0
  41. package/dist/client/assets/index-B1MFijjb.css +1 -0
  42. package/dist/client/assets/index-CU1iPPdn.js +249 -0
  43. package/dist/client/index.html +108 -0
  44. package/dist/package.json +3 -0
  45. package/dist/scripts/postinstall-path-check.js +36 -0
  46. package/dist/server/index.js +92 -0
  47. package/dist/session/command-hook-relay.js +16 -0
  48. package/dist/session/hook-relay.js +24 -0
  49. package/dist/session/hook-tool-relay.js +107 -0
  50. package/dist/session/statusline-relay.js +82 -0
  51. package/dist/session/visions-relay.js +627 -0
  52. package/dist/tools/vscode-visions/extension.js +289 -0
  53. package/dist/tools/vscode-visions/lsp-convert.js +80 -0
  54. package/dist/tools/vscode-visions/package.json +32 -0
  55. package/dist/tools/vscode-visions/visions-lsp-core.js +112 -0
  56. package/package.json +96 -4
  57. package/scripts/postinstall.mjs +4 -0
  58. package/scripts/prepare-build.js +38 -0
  59. package/scripts/recover-handoff.mjs +82 -0
@@ -0,0 +1,3020 @@
1
+ import { d as SessionSnapshot, f as SessionState, l as PendingWakeup, m as TaskTitle, s as PendingPromptDetail } from "./session-Cez8aIWg.js";
2
+ import path from "node:path";
3
+ import { z } from "zod";
4
+ //#region shared/settings-ranges.ts
5
+ var POSITIVE_NUMBER_RANGE = Object.freeze({
6
+ min: 0,
7
+ exclusiveMin: true,
8
+ label: "a positive number"
9
+ });
10
+ var NON_NEGATIVE_NUMBER_RANGE = Object.freeze({
11
+ min: 0,
12
+ label: "zero or more"
13
+ });
14
+ var FLYING_ANIMALS_GAP_RANGE = Object.freeze({
15
+ min: 0,
16
+ max: 300
17
+ });
18
+ var FLYING_ANIMALS_DURATION_RANGE = Object.freeze({
19
+ min: 1,
20
+ max: 60
21
+ });
22
+ var FLYING_ANIMALS_SCALE_RANGE = Object.freeze({
23
+ min: .5,
24
+ max: 2
25
+ });
26
+ var REPLAY_BUFFER_KB_RANGE = Object.freeze({
27
+ min: 64,
28
+ max: 16384
29
+ });
30
+ var BRANCH_GC_STALE_DAYS_RANGE = POSITIVE_NUMBER_RANGE;
31
+ var BRANCH_GC_INTERVAL_MS_RANGE = POSITIVE_NUMBER_RANGE;
32
+ var VISIONS_QUIET_MS_RANGE = POSITIVE_NUMBER_RANGE;
33
+ var VISIONS_COOLDOWN_MS_RANGE = POSITIVE_NUMBER_RANGE;
34
+ var VISIONS_MAX_PER_HOUR_RANGE = POSITIVE_NUMBER_RANGE;
35
+ var VISIONS_ACTIVITY_MAX_PER_HOUR_RANGE = NON_NEGATIVE_NUMBER_RANGE;
36
+ var VISIONS_DISPATCH_TIMEOUT_RANGE = POSITIVE_NUMBER_RANGE;
37
+ var VISIONS_INTENT_THREAD_TTL_MS_RANGE = POSITIVE_NUMBER_RANGE;
38
+ var POSTHOG_INTERVAL_RANGE = POSITIVE_NUMBER_RANGE;
39
+ var POSTHOG_MAX_CONCURRENT_RANGE = POSITIVE_NUMBER_RANGE;
40
+ var POSTHOG_INVESTIGATION_TIMEOUT_RANGE = POSITIVE_NUMBER_RANGE;
41
+ var POSTHOG_MIN_USERS_RANGE = POSITIVE_NUMBER_RANGE;
42
+ var POSTHOG_ESCALATION_RANGE = POSITIVE_NUMBER_RANGE;
43
+ var POSTHOG_RECURRENCE_WINDOW_RANGE = POSITIVE_NUMBER_RANGE;
44
+ var POSTHOG_TRANSIENT_RECURRENCE_RANGE = POSITIVE_NUMBER_RANGE;
45
+ var POSTHOG_FIX_TIMEOUT_RANGE = Object.freeze({
46
+ min: 60,
47
+ max: 21600,
48
+ label: "between 60 and 21600"
49
+ });
50
+ var POSTHOG_TRAFFIC_MULTIPLIER_RANGE = Object.freeze({
51
+ min: 1,
52
+ label: "at least 1"
53
+ });
54
+ var POSTHOG_TRAFFIC_MIN_USERS_RANGE = Object.freeze({
55
+ min: 1,
56
+ label: "at least 1"
57
+ });
58
+ var POSTHOG_TRAFFIC_COOLDOWN_RANGE = NON_NEGATIVE_NUMBER_RANGE;
59
+ var POSTHOG_TRAFFIC_BASELINE_RANGE = Object.freeze({
60
+ min: 1,
61
+ max: 30,
62
+ label: "between 1 and 30"
63
+ });
64
+ var USAGE_SCAN_INTERVAL_RANGE = Object.freeze({
65
+ min: 1,
66
+ max: 1440
67
+ });
68
+ var USAGE_RETAIN_DAYS_RANGE = Object.freeze({
69
+ min: 1,
70
+ max: 3650
71
+ });
72
+ var USAGE_WAREHOUSE_RETAIN_DAYS_RANGE = Object.freeze({
73
+ min: 30,
74
+ max: 3650
75
+ });
76
+ var USAGE_SESSION_BLOCK_HOURS_RANGE = Object.freeze({
77
+ min: 1,
78
+ max: 24
79
+ });
80
+ var USAGE_BUDGET_RANGE = POSITIVE_NUMBER_RANGE;
81
+ var USAGE_INTEGER_RANGES = Object.freeze({
82
+ scanIntervalMinutes: USAGE_SCAN_INTERVAL_RANGE,
83
+ retainDays: USAGE_RETAIN_DAYS_RANGE,
84
+ warehouseRetainDays: USAGE_WAREHOUSE_RETAIN_DAYS_RANGE,
85
+ sessionBlockHours: USAGE_SESSION_BLOCK_HOURS_RANGE
86
+ });
87
+ var CHANGE_MAP_NARRATOR_TIMEOUT_RANGE = Object.freeze({
88
+ min: 15,
89
+ max: 600
90
+ });
91
+ var KEEP_MERGEABLE_TIMEOUT_MINUTES_RANGE = Object.freeze({
92
+ min: 5,
93
+ max: 120
94
+ });
95
+ var WORKFLOWS_MAX_CONCURRENT_SESSIONS_RANGE = Object.freeze({
96
+ min: 1,
97
+ max: 5
98
+ });
99
+ var WORKFLOWS_MAX_ACTIONS_PER_POLL_RANGE = Object.freeze({
100
+ min: 1,
101
+ max: 50
102
+ });
103
+ Object.freeze({
104
+ FLYING_ANIMALS_GAP_RANGE,
105
+ FLYING_ANIMALS_DURATION_RANGE,
106
+ FLYING_ANIMALS_SCALE_RANGE,
107
+ CHANGE_MAP_NARRATOR_TIMEOUT_RANGE,
108
+ KEEP_MERGEABLE_TIMEOUT_MINUTES_RANGE,
109
+ POSTHOG_ESCALATION_RANGE,
110
+ POSTHOG_FIX_TIMEOUT_RANGE,
111
+ POSTHOG_INTERVAL_RANGE,
112
+ POSTHOG_INVESTIGATION_TIMEOUT_RANGE,
113
+ POSTHOG_MAX_CONCURRENT_RANGE,
114
+ POSTHOG_MIN_USERS_RANGE,
115
+ POSTHOG_TRAFFIC_BASELINE_RANGE,
116
+ POSTHOG_TRAFFIC_COOLDOWN_RANGE,
117
+ POSTHOG_TRAFFIC_MIN_USERS_RANGE,
118
+ POSTHOG_TRAFFIC_MULTIPLIER_RANGE,
119
+ REPLAY_BUFFER_KB_RANGE,
120
+ USAGE_BUDGET_RANGE,
121
+ USAGE_RETAIN_DAYS_RANGE,
122
+ USAGE_SCAN_INTERVAL_RANGE,
123
+ VISIONS_ACTIVITY_MAX_PER_HOUR_RANGE,
124
+ VISIONS_COOLDOWN_MS_RANGE,
125
+ VISIONS_DISPATCH_TIMEOUT_RANGE,
126
+ VISIONS_INTENT_THREAD_TTL_MS_RANGE,
127
+ VISIONS_MAX_PER_HOUR_RANGE,
128
+ VISIONS_QUIET_MS_RANGE,
129
+ WORKFLOWS_MAX_ACTIONS_PER_POLL_RANGE,
130
+ WORKFLOWS_MAX_CONCURRENT_SESSIONS_RANGE
131
+ });
132
+ //#endregion
133
+ //#region shared/usage-config.ts
134
+ var USAGE_COST_MODES = Object.freeze([
135
+ "auto",
136
+ "calculate",
137
+ "display"
138
+ ]);
139
+ var USAGE_VENDOR_KEYS = Object.freeze(["codex", "grok"]);
140
+ var USAGE_BUDGET_KEYS = Object.freeze(["dailyUsd", "monthlyUsd"]);
141
+ //#endregion
142
+ //#region shared/contracts/reviews.ts
143
+ var ReviewsRetry = z.object({
144
+ attempt: z.number().int().positive(),
145
+ limit: z.number().int().positive()
146
+ }).refine((retry) => retry.attempt <= retry.limit);
147
+ var reviewsPollingShape = {
148
+ error: z.string().nullable().optional(),
149
+ nextAttemptAt: z.number().finite().nonnegative().nullable().optional(),
150
+ retry: ReviewsRetry.nullable().optional(),
151
+ isRefreshing: z.boolean().optional(),
152
+ refreshNotice: z.string().nullable().optional()
153
+ };
154
+ var ReviewsRefreshRequest = z.object({ lane: z.enum(["my-prs", "team-review"]) });
155
+ var ReviewsRefreshResult = z.object({
156
+ ok: z.boolean(),
157
+ error: z.string().optional()
158
+ });
159
+ //#endregion
160
+ //#region shared/contracts/team-review.ts
161
+ var CommitSha = z.string().regex(/^[0-9a-f]{40}$/);
162
+ var repoSlug$1 = z.string().regex(/^[^/]+\/[^/]+$/);
163
+ var SearchedPr = z.object({
164
+ number: z.number().int().positive(),
165
+ title: z.string(),
166
+ html_url: z.string(),
167
+ draft: z.boolean().optional(),
168
+ created_at: z.string().optional(),
169
+ updated_at: z.string().optional(),
170
+ repository_url: z.string(),
171
+ user: z.object({
172
+ login: z.string(),
173
+ type: z.enum(["User", "Bot"])
174
+ }).passthrough(),
175
+ pull_request: z.object({}).passthrough()
176
+ }).passthrough();
177
+ var PrDetail = z.object({
178
+ number: z.number().int().positive(),
179
+ title: z.string(),
180
+ body: z.string(),
181
+ url: z.string(),
182
+ author: z.object({
183
+ login: z.string(),
184
+ is_bot: z.boolean().optional()
185
+ }).passthrough(),
186
+ isDraft: z.boolean(),
187
+ isCrossRepository: z.boolean(),
188
+ baseRefName: z.string(),
189
+ baseRefOid: CommitSha,
190
+ headRefOid: CommitSha,
191
+ additions: z.number().int().nonnegative(),
192
+ deletions: z.number().int().nonnegative(),
193
+ files: z.array(z.object({
194
+ path: z.string(),
195
+ additions: z.number().int().nonnegative(),
196
+ deletions: z.number().int().nonnegative()
197
+ }).passthrough())
198
+ }).passthrough();
199
+ var ReviewComment = z.object({
200
+ path: z.string(),
201
+ line: z.number().int().positive(),
202
+ side: z.enum(["RIGHT", "LEFT"]).default("RIGHT"),
203
+ body: z.string()
204
+ });
205
+ var LEGACY_VERDICTS = Object.freeze({
206
+ STAMP: "APPROVE",
207
+ COMMENT: "APPROVE WITH NITS",
208
+ NEEDS_YOU: "REQUEST CHANGES"
209
+ });
210
+ var ReviewVerdict = z.enum([
211
+ "APPROVE",
212
+ "APPROVE WITH NITS",
213
+ "REQUEST CHANGES",
214
+ "BLOCKED"
215
+ ]);
216
+ var storedVerdict = z.preprocess((verdict) => typeof verdict === "string" && Object.hasOwn(LEGACY_VERDICTS, verdict) ? LEGACY_VERDICTS[verdict] : verdict, ReviewVerdict);
217
+ var FindingSeverity = z.enum([
218
+ "CRITICAL",
219
+ "HIGH",
220
+ "MEDIUM",
221
+ "LOW"
222
+ ]);
223
+ var DraftComment = ReviewComment.extend({ severity: FindingSeverity.optional() });
224
+ var ReviewFinding = z.object({
225
+ path: z.string().min(1),
226
+ line: z.number().int().positive().nullable(),
227
+ side: z.enum(["RIGHT", "LEFT"]),
228
+ severity: FindingSeverity,
229
+ reviewer: z.string().min(1),
230
+ disposition: z.enum([
231
+ "ACTIONABLE",
232
+ "NIT",
233
+ "AMBIGUOUS"
234
+ ]).nullable(),
235
+ body: z.string().min(1)
236
+ });
237
+ var ReviewAssessment = z.object({
238
+ goal: z.string().default(""),
239
+ change: z.string(),
240
+ checked: z.array(z.string()),
241
+ gaps: z.array(z.string())
242
+ });
243
+ var ReviewResult = z.object({
244
+ verdict: ReviewVerdict,
245
+ head: CommitSha,
246
+ summary: z.string(),
247
+ assessment: ReviewAssessment.nullable(),
248
+ findings: z.array(ReviewFinding)
249
+ });
250
+ var PostingPlan = z.object({
251
+ body: z.string(),
252
+ commit_id: CommitSha,
253
+ comments: z.array(z.object({
254
+ path: z.string().min(1),
255
+ line: z.number().int().positive(),
256
+ side: z.enum(["RIGHT", "LEFT"]).default("RIGHT"),
257
+ body: z.string().min(1)
258
+ }))
259
+ });
260
+ var PostedReviewEvent = z.enum(["APPROVE", "COMMENT"]);
261
+ var GithubReviewState = z.enum([
262
+ "APPROVED",
263
+ "CHANGES_REQUESTED",
264
+ "COMMENTED"
265
+ ]);
266
+ var DECIDING_REVIEW_STATES = /* @__PURE__ */ new Set(["APPROVED", "CHANGES_REQUESTED"]);
267
+ var GithubReviewDecision = z.enum([
268
+ "APPROVED",
269
+ "CHANGES_REQUESTED",
270
+ "REVIEW_REQUIRED"
271
+ ]);
272
+ var ReviewChecksState = z.enum([
273
+ "SUCCESS",
274
+ "FAILURE",
275
+ "PENDING",
276
+ "ERROR",
277
+ "EXPECTED"
278
+ ]);
279
+ var reviewPriorityShape = {
280
+ requestSource: z.enum(["direct", "team"]).default("team"),
281
+ isDraft: z.boolean().optional(),
282
+ checksState: ReviewChecksState.nullable().optional()
283
+ };
284
+ var GithubReview = z.object({
285
+ login: z.string().min(1),
286
+ state: GithubReviewState,
287
+ commit: CommitSha.nullable(),
288
+ isViewer: z.boolean(),
289
+ submittedAt: z.string().nullable().optional()
290
+ });
291
+ function decisionAsIfApprovalRequired(githubDecision, opinionatedWriterReviewStates) {
292
+ if (githubDecision) return githubDecision;
293
+ if (opinionatedWriterReviewStates.includes("CHANGES_REQUESTED")) return "CHANGES_REQUESTED";
294
+ if (opinionatedWriterReviewStates.includes("APPROVED")) return "APPROVED";
295
+ return "REVIEW_REQUIRED";
296
+ }
297
+ function hasStandingViewerApproval(draft) {
298
+ if (draft.reviewDecision !== "APPROVED") return false;
299
+ if (draft.requeuedHead !== void 0 && draft.requeuedHead === (draft.liveHead ?? draft.reviewedHead)) return false;
300
+ return (draft.githubReviews ?? []).some((review) => review.isViewer && review.state === "APPROVED");
301
+ }
302
+ z.object({
303
+ head: CommitSha,
304
+ reviews: z.array(GithubReview)
305
+ });
306
+ var PriorReview = z.object({
307
+ head: CommitSha,
308
+ verdict: ReviewVerdict,
309
+ summary: z.string(),
310
+ body: z.string(),
311
+ comments: z.array(ReviewComment),
312
+ wasPosted: z.boolean()
313
+ });
314
+ var ReviewThreadId = z.string().min(1).max(256).regex(/^[A-Za-z0-9_=-]+$/);
315
+ var TeamReviewThreadResult = z.object({
316
+ addressed: z.boolean(),
317
+ reason: z.string().trim().min(1).max(4e3)
318
+ }).strict();
319
+ var TeamReviewThreadNode = z.object({
320
+ id: ReviewThreadId,
321
+ path: z.string(),
322
+ line: z.number().int().positive().nullable(),
323
+ isResolved: z.boolean(),
324
+ viewerCanResolve: z.boolean(),
325
+ comments: z.object({
326
+ pageInfo: z.object({
327
+ hasNextPage: z.boolean(),
328
+ endCursor: z.string().nullable().optional()
329
+ }),
330
+ nodes: z.array(z.object({
331
+ body: z.string(),
332
+ author: z.object({ login: z.string() }).nullable(),
333
+ viewerDidAuthor: z.boolean(),
334
+ createdAt: z.string().datetime(),
335
+ url: z.string().url(),
336
+ originalCommit: z.object({ oid: CommitSha }).nullable()
337
+ }))
338
+ })
339
+ });
340
+ var TeamReviewThreadCommentsResponse = z.object({ data: z.object({ node: z.object({ comments: TeamReviewThreadNode.shape.comments }).nullable() }).nullable() });
341
+ var TeamReviewThreadsRepository = z.object({ pullRequest: z.object({ reviewThreads: z.object({
342
+ pageInfo: z.object({
343
+ hasNextPage: z.boolean(),
344
+ endCursor: z.string().nullable().optional()
345
+ }),
346
+ nodes: z.array(TeamReviewThreadNode)
347
+ }) }).nullable() });
348
+ var TeamReviewResolveResponse = z.object({
349
+ data: z.object({ resolveReviewThread: z.object({ thread: z.object({
350
+ id: ReviewThreadId,
351
+ isResolved: z.literal(true)
352
+ }) }) }).nullable(),
353
+ errors: z.array(z.unknown()).optional()
354
+ });
355
+ var TeamReviewThread = z.object({
356
+ id: ReviewThreadId,
357
+ path: z.string(),
358
+ line: z.number().int().positive().nullable(),
359
+ isResolved: z.boolean(),
360
+ viewerCanResolve: z.boolean(),
361
+ isNit: z.boolean(),
362
+ url: z.string().url(),
363
+ viewerComment: z.string().max(1500).optional(),
364
+ lastReplyBody: z.string().max(1500).optional(),
365
+ viewerCommentTruncated: z.boolean().optional(),
366
+ lastReplyTruncated: z.boolean().optional(),
367
+ lastReplyAuthor: z.string(),
368
+ lastReplyAt: z.string().datetime(),
369
+ judgement: TeamReviewThreadResult.extend({
370
+ head: CommitSha,
371
+ judgedAt: z.number().finite(),
372
+ lastReplyAt: z.string().datetime()
373
+ }).optional(),
374
+ resolveError: z.string().optional(),
375
+ resolveAttemptReplyAt: z.string().optional(),
376
+ judgeAttempt: z.object({
377
+ head: CommitSha,
378
+ lastReplyAt: z.string(),
379
+ retryAt: z.number().finite()
380
+ }).optional(),
381
+ unjudgeable: z.object({
382
+ head: CommitSha,
383
+ lastReplyAt: z.string(),
384
+ reason: z.string().min(1)
385
+ }).optional()
386
+ });
387
+ var TeamReviewCompareFiles = z.object({
388
+ merge_base_commit: z.object({ sha: CommitSha }),
389
+ files: z.array(z.object({
390
+ filename: z.string(),
391
+ previous_filename: z.string().optional(),
392
+ patch: z.string().optional()
393
+ })).max(300)
394
+ });
395
+ var ViewerThreadTally = z.object({
396
+ total: z.number().int().nonnegative(),
397
+ resolved: z.number().int().nonnegative()
398
+ });
399
+ var ReviewDraft = z.object({
400
+ ...reviewPriorityShape,
401
+ key: z.string(),
402
+ repo: repoSlug$1,
403
+ number: z.number().int().positive(),
404
+ title: z.string(),
405
+ url: z.string(),
406
+ author: z.string(),
407
+ tier: z.enum(["stamp", "full"]),
408
+ reasons: z.array(z.string()),
409
+ reviewedHead: CommitSha,
410
+ verdict: storedVerdict,
411
+ summary: z.string(),
412
+ assessment: ReviewAssessment.optional(),
413
+ body: z.string(),
414
+ comments: z.array(DraftComment),
415
+ status: z.enum([
416
+ "ready",
417
+ "stale",
418
+ "posted",
419
+ "discarded",
420
+ "error"
421
+ ]),
422
+ error: z.string().optional(),
423
+ threads: z.array(TeamReviewThread).optional(),
424
+ viewerThreads: ViewerThreadTally.optional(),
425
+ githubReviews: z.array(GithubReview).optional(),
426
+ reviewDecision: GithubReviewDecision.nullable().optional(),
427
+ liveHead: CommitSha.optional(),
428
+ prCreatedAt: z.string().optional(),
429
+ reviewedAt: z.number().finite().optional(),
430
+ postedAt: z.number().finite().optional(),
431
+ postedEvent: PostedReviewEvent.optional(),
432
+ priorReviewedHead: CommitSha.optional(),
433
+ requeuedHead: CommitSha.optional()
434
+ });
435
+ function canApproveAfterComment(draft) {
436
+ return draft.status === "posted" && draft.postedEvent === "COMMENT";
437
+ }
438
+ var TeamReviewAction = z.enum([
439
+ "approve",
440
+ "approve-only",
441
+ "comment",
442
+ "discard",
443
+ "requeue",
444
+ "resolve-thread"
445
+ ]);
446
+ var TeamReviewActionRequest = z.object({
447
+ key: z.string().min(1),
448
+ head: CommitSha,
449
+ action: TeamReviewAction,
450
+ threadId: ReviewThreadId.optional(),
451
+ body: z.string(),
452
+ comments: z.array(ReviewComment)
453
+ }).refine((request) => request.action !== "resolve-thread" || request.threadId !== void 0, {
454
+ message: "resolve-thread requires threadId",
455
+ path: ["threadId"]
456
+ });
457
+ var TeamReviewActionResult = z.object({
458
+ key: z.string(),
459
+ ok: z.boolean(),
460
+ error: z.string().optional(),
461
+ warning: z.string().optional()
462
+ });
463
+ var ResumableReview = z.object({
464
+ sessionId: z.string().min(1),
465
+ workDir: z.string().min(1),
466
+ worktreePath: z.string().min(1),
467
+ head: CommitSha,
468
+ deadlineAt: z.number(),
469
+ remainingAwakeMs: z.number().nonnegative().optional(),
470
+ savedAt: z.number()
471
+ });
472
+ var QueuedReview = z.object({
473
+ ...reviewPriorityShape,
474
+ reviewDecision: GithubReviewDecision.nullable().optional(),
475
+ key: z.string(),
476
+ repo: repoSlug$1,
477
+ number: z.number().int().positive(),
478
+ title: z.string(),
479
+ url: z.string(),
480
+ author: z.string(),
481
+ prCreatedAt: z.string().optional()
482
+ });
483
+ var TeamReviewStateEntry = z.object({
484
+ draft: ReviewDraft.nullable(),
485
+ reviewedHead: CommitSha.nullable(),
486
+ inFlight: z.boolean(),
487
+ skipReason: z.string().nullable(),
488
+ handReview: QueuedReview.optional(),
489
+ reviewAttempts: z.number().int().nonnegative().default(0),
490
+ resumable: ResumableReview.nullable().optional(),
491
+ reviewedAt: z.number().optional(),
492
+ threads: z.array(TeamReviewThread).optional(),
493
+ viewerThreads: ViewerThreadTally.optional(),
494
+ autoResolvedThreadIds: z.array(ReviewThreadId).optional(),
495
+ githubReviews: z.array(GithubReview).optional(),
496
+ reviewDecision: GithubReviewDecision.nullable().optional(),
497
+ liveHead: CommitSha.optional(),
498
+ requeuedHead: CommitSha.optional(),
499
+ priorReview: PriorReview.optional(),
500
+ discardedReviewHead: CommitSha.optional(),
501
+ updatedAt: z.number().finite()
502
+ });
503
+ z.record(z.string(), TeamReviewStateEntry);
504
+ var ReviewProgressPhase = z.enum([
505
+ "preparing",
506
+ "checkout",
507
+ "reviewing"
508
+ ]);
509
+ var ReviewProgressStep = z.object({
510
+ at: z.number().finite(),
511
+ tool: z.string(),
512
+ detail: z.string()
513
+ });
514
+ var InFlightReview = z.object({
515
+ ...reviewPriorityShape,
516
+ reviewDecision: GithubReviewDecision.nullable().optional(),
517
+ key: z.string(),
518
+ repo: repoSlug$1,
519
+ number: z.number().int().positive(),
520
+ title: z.string(),
521
+ url: z.string(),
522
+ author: z.string(),
523
+ tier: z.enum(["stamp", "full"]),
524
+ reasons: z.array(z.string()),
525
+ head: CommitSha,
526
+ phase: ReviewProgressPhase,
527
+ startedAt: z.number().finite(),
528
+ deadlineAt: z.number().finite().nullable(),
529
+ toolCalls: z.number().int().nonnegative(),
530
+ recentSteps: z.array(ReviewProgressStep),
531
+ prCreatedAt: z.string().optional(),
532
+ priorReviewedHead: CommitSha.optional()
533
+ });
534
+ var TeamReviewStatus = z.object({
535
+ ...reviewsPollingShape,
536
+ type: z.literal("team-review-status"),
537
+ ts: z.number().finite(),
538
+ configured: z.boolean(),
539
+ reason: z.string().nullable().optional(),
540
+ drafts: z.array(ReviewDraft),
541
+ inFlight: z.array(InFlightReview),
542
+ queued: z.array(QueuedReview).default([]),
543
+ handReview: z.array(QueuedReview).default([]),
544
+ team: z.object({
545
+ org: z.string(),
546
+ slug: z.string(),
547
+ name: z.string(),
548
+ avatarUrl: z.string()
549
+ }).nullable().optional()
550
+ }).passthrough();
551
+ //#endregion
552
+ //#region shared/contracts/my-prs.ts
553
+ var MyPrStage = z.enum([
554
+ "merged",
555
+ "draft",
556
+ "conflicts",
557
+ "behind",
558
+ "checks-failing",
559
+ "changes-requested",
560
+ "unresolved-threads",
561
+ "checks-pending",
562
+ "needs-approval",
563
+ "ready",
564
+ "unknown"
565
+ ]);
566
+ var nonnegativeInteger$1 = z.number().int().nonnegative();
567
+ var repositoryName = z.string().regex(/^[A-Za-z0-9][A-Za-z0-9._-]*\/[A-Za-z0-9][A-Za-z0-9._-]*$/);
568
+ var pullRequestNumberText = z.string().regex(/^[1-9][0-9]*$/);
569
+ var pullRequestKeyFormat = z.templateLiteral([
570
+ repositoryName,
571
+ "#",
572
+ pullRequestNumberText
573
+ ]);
574
+ var keepMergeableAttemptKeyFormat = z.templateLiteral([
575
+ pullRequestKeyFormat,
576
+ "@",
577
+ CommitSha
578
+ ]);
579
+ var pullRequestKey = z.string().refine((value) => pullRequestKeyFormat.safeParse(value).success);
580
+ var keepMergeableAttemptKey = z.string().refine((value) => keepMergeableAttemptKeyFormat.safeParse(value).success);
581
+ z.discriminatedUnion("outcome", [z.strictObject({ outcome: z.literal("pushed") }), z.strictObject({
582
+ outcome: z.enum([
583
+ "no-change",
584
+ "failed",
585
+ "stopped",
586
+ "timed-out"
587
+ ]),
588
+ reason: z.string().min(1)
589
+ })]);
590
+ var MyPrKeepMergeableAttempt = z.strictObject({
591
+ outcome: z.enum([
592
+ "pushed",
593
+ "no-change",
594
+ "failed",
595
+ "stopped",
596
+ "timed-out"
597
+ ]),
598
+ reason: z.string().min(1).optional(),
599
+ at: z.number().finite()
600
+ });
601
+ var MyPrKeepMergeableAttemptRecord = MyPrKeepMergeableAttempt.extend({
602
+ key: pullRequestKey,
603
+ headRefOid: CommitSha,
604
+ baseRefOid: CommitSha
605
+ });
606
+ var MyPrsState = z.strictObject({
607
+ keepMergeableKeys: z.array(pullRequestKey),
608
+ keepMergeableAttemptKeys: z.array(keepMergeableAttemptKey),
609
+ keepMergeableAttempts: z.array(MyPrKeepMergeableAttemptRecord).default([]),
610
+ mergeQueueKeys: z.array(pullRequestKey).default([]),
611
+ keepMergeablePushedHeadKeys: z.array(keepMergeableAttemptKey).default([])
612
+ });
613
+ var MyPrKeepMergeableRequest = z.object({
614
+ repo: repositoryName,
615
+ number: z.number().int().positive(),
616
+ keepMergeable: z.boolean()
617
+ });
618
+ var MyPrToggleResult = z.object({
619
+ key: z.string(),
620
+ ok: z.boolean(),
621
+ error: z.string().optional()
622
+ });
623
+ var MyPrKeepMergeableResult = MyPrToggleResult;
624
+ var MyPrMergeWhenReadyRequest = z.object({
625
+ repo: repositoryName,
626
+ number: z.number().int().positive(),
627
+ mergeWhenReady: z.boolean()
628
+ });
629
+ var MyPrMergeWhenReadyResult = MyPrToggleResult;
630
+ var MyPrMergeMethod = z.enum([
631
+ "MERGE",
632
+ "SQUASH",
633
+ "REBASE"
634
+ ]);
635
+ var MyPrThread = z.object({
636
+ path: z.string(),
637
+ line: z.number().int().positive().nullable(),
638
+ isOutdated: z.boolean(),
639
+ url: z.url(),
640
+ author: z.string().nullable(),
641
+ excerpt: z.string(),
642
+ commentCount: z.number().int().positive(),
643
+ lastAuthor: z.string().nullable(),
644
+ lastActivityAt: z.string()
645
+ });
646
+ var MyPrReview = z.object({
647
+ reviewer: z.string().nullable(),
648
+ state: z.string(),
649
+ submittedAt: z.string().nullable()
650
+ });
651
+ var MyPrAutoRebase = z.object({
652
+ outcome: z.enum(["rebased", "failed"]),
653
+ at: z.number().finite(),
654
+ message: z.string()
655
+ });
656
+ var MyPr = z.object({
657
+ key: z.string(),
658
+ repo: repositoryName,
659
+ number: z.number().int().positive(),
660
+ title: z.string(),
661
+ url: z.url(),
662
+ isDraft: z.boolean(),
663
+ state: z.enum([
664
+ "OPEN",
665
+ "MERGED",
666
+ "CLOSED"
667
+ ]),
668
+ createdAt: z.string(),
669
+ mergedAt: z.string().nullable(),
670
+ updatedAt: z.string(),
671
+ baseRefName: z.string(),
672
+ baseRefOid: CommitSha,
673
+ headRefName: z.string().min(1),
674
+ isCrossRepository: z.boolean(),
675
+ headRefOid: CommitSha,
676
+ isInMergeQueue: z.boolean(),
677
+ mergeMethod: MyPrMergeMethod,
678
+ mergeable: z.enum([
679
+ "MERGEABLE",
680
+ "CONFLICTING",
681
+ "UNKNOWN"
682
+ ]),
683
+ mergeStateStatus: z.string(),
684
+ reviewDecision: z.enum([
685
+ "APPROVED",
686
+ "CHANGES_REQUESTED",
687
+ "REVIEW_REQUIRED"
688
+ ]).nullable(),
689
+ checks: z.object({
690
+ state: z.enum([
691
+ "SUCCESS",
692
+ "FAILURE",
693
+ "PENDING",
694
+ "ERROR",
695
+ "EXPECTED"
696
+ ]).nullable(),
697
+ failing: z.array(z.string()),
698
+ pendingCount: nonnegativeInteger$1
699
+ }),
700
+ unresolvedThreads: nonnegativeInteger$1,
701
+ threads: z.array(MyPrThread),
702
+ behindBy: nonnegativeInteger$1.nullable(),
703
+ reviewRequests: z.array(z.object({
704
+ name: z.string(),
705
+ isTeam: z.boolean(),
706
+ avatarUrl: z.string().nullable()
707
+ })),
708
+ approvals: nonnegativeInteger$1,
709
+ reviews: z.array(MyPrReview),
710
+ stage: MyPrStage,
711
+ autoRebase: MyPrAutoRebase.optional(),
712
+ keepMergeable: z.boolean().optional(),
713
+ keepMergeableAttempt: MyPrKeepMergeableAttempt.optional(),
714
+ isKeepMergeableFixInFlight: z.boolean().optional(),
715
+ mergeQueuePosition: z.number().int().positive().nullable().optional(),
716
+ isMergeQueueHeldForRepairPush: z.boolean().optional()
717
+ }).refine((pr) => pr.key === `${pr.repo}#${pr.number}`);
718
+ var MyPrsStatus = z.object({
719
+ ...reviewsPollingShape,
720
+ type: z.literal("my-prs-status"),
721
+ ts: z.number().finite(),
722
+ configured: z.boolean(),
723
+ reason: z.string().nullable().optional(),
724
+ viewer: z.string().nullable(),
725
+ prs: z.array(MyPr),
726
+ truncatedNote: z.string().nullable().optional(),
727
+ isKeepMergeableEnabled: z.boolean().optional(),
728
+ isMergeQueueEnabled: z.boolean().optional()
729
+ }).passthrough();
730
+ var MyPrMergeRequest = z.object({
731
+ repo: repositoryName,
732
+ number: z.number().int().positive(),
733
+ headRefOid: CommitSha
734
+ });
735
+ var MyPrMergeKind = z.enum([
736
+ "merged",
737
+ "queued",
738
+ "auto-merge",
739
+ "unconfirmed"
740
+ ]);
741
+ var MyPrMergeResult = z.object({
742
+ key: z.string(),
743
+ ok: z.boolean(),
744
+ kind: MyPrMergeKind.optional(),
745
+ error: z.string().optional()
746
+ });
747
+ var CheckRun = z.object({
748
+ __typename: z.literal("CheckRun"),
749
+ name: z.string(),
750
+ conclusion: z.string().nullable(),
751
+ status: z.string()
752
+ });
753
+ var StatusContext = z.object({
754
+ __typename: z.literal("StatusContext"),
755
+ context: z.string(),
756
+ state: z.string()
757
+ });
758
+ var MyPrSearchNode = z.object({
759
+ __typename: z.literal("PullRequest"),
760
+ id: z.string().regex(/^[A-Za-z0-9_=-]+$/),
761
+ number: z.number().int().positive(),
762
+ title: z.string(),
763
+ url: z.url(),
764
+ isDraft: z.boolean(),
765
+ state: z.enum([
766
+ "OPEN",
767
+ "MERGED",
768
+ "CLOSED"
769
+ ]),
770
+ createdAt: z.string(),
771
+ mergedAt: z.string().nullable(),
772
+ updatedAt: z.string(),
773
+ baseRefName: z.string(),
774
+ baseRefOid: CommitSha,
775
+ headRefName: z.string().min(1),
776
+ isCrossRepository: z.boolean(),
777
+ headRefOid: CommitSha,
778
+ isInMergeQueue: z.boolean(),
779
+ mergeable: z.enum([
780
+ "MERGEABLE",
781
+ "CONFLICTING",
782
+ "UNKNOWN"
783
+ ]),
784
+ mergeStateStatus: z.string(),
785
+ reviewDecision: z.enum([
786
+ "APPROVED",
787
+ "CHANGES_REQUESTED",
788
+ "REVIEW_REQUIRED"
789
+ ]).nullable(),
790
+ repository: z.object({
791
+ nameWithOwner: repositoryName,
792
+ viewerDefaultMergeMethod: MyPrMergeMethod
793
+ }),
794
+ commits: z.object({ nodes: z.array(z.object({ commit: z.object({ statusCheckRollup: z.object({
795
+ state: z.enum([
796
+ "SUCCESS",
797
+ "FAILURE",
798
+ "PENDING",
799
+ "ERROR",
800
+ "EXPECTED"
801
+ ]).nullable(),
802
+ contexts: z.object({ nodes: z.array(z.union([CheckRun, StatusContext])) })
803
+ }).nullable() }) })) }),
804
+ reviewThreads: z.object({
805
+ pageInfo: z.object({ hasNextPage: z.boolean() }),
806
+ nodes: z.array(z.object({ isResolved: z.boolean() }))
807
+ }),
808
+ reviewRequests: z.object({ nodes: z.array(z.object({ requestedReviewer: z.discriminatedUnion("__typename", [
809
+ z.object({
810
+ __typename: z.literal("User"),
811
+ login: z.string()
812
+ }),
813
+ z.object({
814
+ __typename: z.literal("Team"),
815
+ slug: z.string(),
816
+ avatarUrl: z.string().nullable(),
817
+ organization: z.object({ login: z.string() })
818
+ }),
819
+ z.object({ __typename: z.enum(["Bot", "Mannequin"]) })
820
+ ]).nullable() })) }),
821
+ latestOpinionatedReviews: z.object({ nodes: z.array(z.object({ state: z.string() })) }),
822
+ latestReviews: z.object({ nodes: z.array(z.object({
823
+ state: z.string(),
824
+ submittedAt: z.string().nullable(),
825
+ author: z.object({ login: z.string() }).nullable()
826
+ })) })
827
+ });
828
+ var ThreadCommentAuthor = z.object({ login: z.string() }).nullable();
829
+ var MyPrThreadNode = z.object({
830
+ isResolved: z.boolean(),
831
+ isOutdated: z.boolean(),
832
+ path: z.string(),
833
+ line: z.number().int().positive().nullable(),
834
+ firstComment: z.object({
835
+ totalCount: nonnegativeInteger$1,
836
+ nodes: z.array(z.object({
837
+ author: ThreadCommentAuthor,
838
+ bodyText: z.string(),
839
+ url: z.url(),
840
+ createdAt: z.string()
841
+ }))
842
+ }),
843
+ lastComment: z.object({ nodes: z.array(z.object({
844
+ author: ThreadCommentAuthor,
845
+ createdAt: z.string()
846
+ })) })
847
+ });
848
+ var MyPrThreadsResponse = z.object({
849
+ data: z.object({ repository: z.object({ pullRequest: z.object({ reviewThreads: z.object({
850
+ pageInfo: z.object({
851
+ hasNextPage: z.boolean(),
852
+ endCursor: z.string().nullable()
853
+ }),
854
+ nodes: z.array(z.unknown())
855
+ }) }).nullable() }).nullable() }),
856
+ errors: z.array(z.unknown()).optional()
857
+ });
858
+ var MyPrMergeStateResponse = z.object({
859
+ data: z.object({ repository: z.object({ pullRequest: z.object({
860
+ state: z.string(),
861
+ isInMergeQueue: z.boolean(),
862
+ autoMergeRequest: z.object({ enabledAt: z.string().nullable() }).nullable()
863
+ }).nullable() }).nullable() }),
864
+ errors: z.array(z.unknown()).optional()
865
+ });
866
+ var MyPrSearchResponse = z.object({
867
+ data: z.object({
868
+ open: z.object({
869
+ issueCount: nonnegativeInteger$1,
870
+ nodes: z.array(z.unknown())
871
+ }),
872
+ merged: z.object({
873
+ issueCount: nonnegativeInteger$1,
874
+ nodes: z.array(z.unknown())
875
+ })
876
+ }),
877
+ errors: z.array(z.unknown()).optional()
878
+ });
879
+ //#endregion
880
+ //#region shared/contracts/workflows.ts
881
+ var WORKFLOW_TRIGGERS = Object.freeze([
882
+ "opened",
883
+ "checks-failed",
884
+ "review-requested",
885
+ "approved",
886
+ "commented",
887
+ "merged"
888
+ ]);
889
+ var WORKFLOW_ACTION_TYPES = Object.freeze([
890
+ "notify",
891
+ "spawn",
892
+ "label",
893
+ "comment"
894
+ ]);
895
+ var WORKFLOW_PROMPT_TEMPLATE_MAX_CHARACTERS = 2e4;
896
+ var WORKFLOW_COMMENT_BODY_MAX_CHARACTERS = 65536;
897
+ var RULE_ID = /^[a-z0-9][a-z0-9-]{0,63}$/;
898
+ var GITHUB_LOGIN = /^[A-Za-z0-9][A-Za-z0-9._-]*$/;
899
+ var UNSAFE_LABEL_NAME = /[\x00-\x1f\x7f,]|^-/;
900
+ var integerInRange = (field, range) => {
901
+ const message = `${field} must be an integer between ${range.min} and ${range.max}`;
902
+ return z.number({ error: message }).int({ error: message }).min(range.min, { error: message }).max(range.max, { error: message });
903
+ };
904
+ var workflowsEnabled = z.boolean({ error: "workflows.enabled must be a boolean" });
905
+ var workflowsMaxConcurrentSessions = integerInRange("workflows.maxConcurrentSessions", WORKFLOWS_MAX_CONCURRENT_SESSIONS_RANGE);
906
+ var workflowsMaxActionsPerPoll = integerInRange("workflows.maxActionsPerPoll", WORKFLOWS_MAX_ACTIONS_PER_POLL_RANGE);
907
+ var nonEmptyList = (field, item) => z.array(item, { error: `${field} must be an array` }).min(1, { error: `${field} must list at least one entry when present` });
908
+ var WorkflowLabelName = z.string({ error: "a workflow label name must be a string" }).trim().min(1, { error: "a workflow label name must not be empty" }).max(50, { error: `a workflow label name must be at most 50 characters` }).refine((name) => !UNSAFE_LABEL_NAME.test(name), { error: "a workflow label name must not start with a dash or hold a comma or control character" });
909
+ var WorkflowCommentBody = z.string({ error: "a workflow comment body must be a string" }).min(1, { error: "a workflow comment body must not be empty" }).max(WORKFLOW_COMMENT_BODY_MAX_CHARACTERS, { error: `a workflow comment body must be at most ${WORKFLOW_COMMENT_BODY_MAX_CHARACTERS} characters` }).refine((body) => body.trim().length > 0, { error: "a workflow comment body must not be blank" });
910
+ var WorkflowTrigger = z.enum(WORKFLOW_TRIGGERS, { error: `workflows.rules[].trigger must be one of ${WORKFLOW_TRIGGERS.join(", ")}` });
911
+ var WorkflowAction = z.discriminatedUnion("type", [
912
+ z.strictObject({ type: z.literal("notify") }),
913
+ z.strictObject({
914
+ type: z.literal("spawn"),
915
+ promptTemplate: z.string({ error: "a spawn action needs a promptTemplate string" }).min(1, { error: "a spawn action promptTemplate must not be empty" }).max(WORKFLOW_PROMPT_TEMPLATE_MAX_CHARACTERS, { error: `a spawn action promptTemplate must be at most ${WORKFLOW_PROMPT_TEMPLATE_MAX_CHARACTERS} characters` }).refine((template) => template.trim().length > 0, { error: "a spawn action promptTemplate must not be blank" })
916
+ }),
917
+ z.strictObject({
918
+ type: z.literal("label"),
919
+ name: WorkflowLabelName
920
+ }),
921
+ z.strictObject({
922
+ type: z.literal("comment"),
923
+ body: WorkflowCommentBody
924
+ })
925
+ ], { error: `workflows.rules[].actions[].type must be one of ${WORKFLOW_ACTION_TYPES.join(", ")}` });
926
+ var WorkflowFilters = z.strictObject({
927
+ mine: z.boolean({ error: "workflows.rules[].filters.mine must be a boolean" }).optional(),
928
+ teamReviewRequested: z.boolean({ error: "workflows.rules[].filters.teamReviewRequested must be a boolean" }).optional(),
929
+ authors: nonEmptyList("workflows.rules[].filters.authors", z.string({ error: "workflows.rules[].filters.authors must hold GitHub logins" }).regex(GITHUB_LOGIN, { error: "workflows.rules[].filters.authors must hold GitHub logins" })).optional(),
930
+ labels: nonEmptyList("workflows.rules[].filters.labels", WorkflowLabelName).optional(),
931
+ baseBranches: nonEmptyList("workflows.rules[].filters.baseBranches", z.string({ error: "workflows.rules[].filters.baseBranches must hold branch names" }).min(1, { error: "workflows.rules[].filters.baseBranches must hold branch names" })).optional()
932
+ }, { error: "workflows.rules[].filters must be an object" });
933
+ var WorkflowRuleId = z.string({ error: "workflows.rules[].id must be a string" }).regex(RULE_ID, { error: "workflows.rules[].id must be 1 to 64 lowercase letters, digits and dashes, starting with a letter or digit" });
934
+ var WorkflowRuleEnabled = z.boolean({ error: "workflows.rules[].enabled must be a boolean" });
935
+ var WorkflowRule = z.strictObject({
936
+ id: WorkflowRuleId,
937
+ name: z.string({ error: "workflows.rules[].name must be a string" }).trim().min(1, { error: "workflows.rules[].name must not be empty" }).max(80, { error: "workflows.rules[].name must be at most 80 characters" }),
938
+ enabled: WorkflowRuleEnabled.default(false),
939
+ repos: nonEmptyList("workflows.rules[].repos", repositoryName),
940
+ filters: WorkflowFilters.default({}),
941
+ trigger: WorkflowTrigger,
942
+ actions: nonEmptyList("workflows.rules[].actions", WorkflowAction)
943
+ }, { error: "workflows.rules[] must be an object" });
944
+ var WorkflowsSettings = z.strictObject({
945
+ enabled: workflowsEnabled.default(true),
946
+ maxConcurrentSessions: workflowsMaxConcurrentSessions.default(2),
947
+ maxActionsPerPoll: workflowsMaxActionsPerPoll.default(20),
948
+ rules: z.array(WorkflowRule, { error: "workflows.rules must be an array" }).default([])
949
+ }, { error: "workflows must be an object" }).superRefine((settings, ctx) => {
950
+ const claimedIds = /* @__PURE__ */ new Set();
951
+ for (const [index, rule] of settings.rules.entries()) {
952
+ if (!claimedIds.has(rule.id)) {
953
+ claimedIds.add(rule.id);
954
+ continue;
955
+ }
956
+ ctx.addIssue({
957
+ code: "custom",
958
+ path: [
959
+ "rules",
960
+ index,
961
+ "id"
962
+ ],
963
+ message: `workflows.rules[${index}].id "${rule.id}" is declared more than once`
964
+ });
965
+ }
966
+ });
967
+ var WorkflowRuleToggle = z.strictObject({
968
+ id: WorkflowRuleId,
969
+ enabled: WorkflowRuleEnabled
970
+ }, { error: "a dashboard update of workflows.rules[] carries only id and enabled" });
971
+ var WorkflowsSettingsUpdate = z.strictObject({
972
+ enabled: workflowsEnabled.optional(),
973
+ maxConcurrentSessions: workflowsMaxConcurrentSessions.optional(),
974
+ maxActionsPerPoll: workflowsMaxActionsPerPoll.optional(),
975
+ rules: z.array(WorkflowRuleToggle, { error: "workflows.rules must be an array" }).optional()
976
+ }, { error: "a dashboard update of workflows carries only enabled, maxConcurrentSessions, maxActionsPerPoll and rule toggles" });
977
+ var nonnegativeInteger = z.number().int().nonnegative();
978
+ var checksState = z.enum([
979
+ "SUCCESS",
980
+ "FAILURE",
981
+ "PENDING",
982
+ "ERROR",
983
+ "EXPECTED"
984
+ ]).nullable();
985
+ var WorkflowSearchNode = MyPrSearchNode.extend({
986
+ author: z.object({ login: z.string() }).nullable(),
987
+ labels: z.object({ nodes: z.array(z.object({ name: z.string() })) }),
988
+ comments: z.object({ totalCount: nonnegativeInteger })
989
+ });
990
+ var WorkflowPr = z.strictObject({
991
+ repo: repositoryName,
992
+ number: z.number().int().positive(),
993
+ title: z.string(),
994
+ url: z.url(),
995
+ author: z.string().nullable(),
996
+ state: z.enum([
997
+ "OPEN",
998
+ "MERGED",
999
+ "CLOSED"
1000
+ ]),
1001
+ createdAt: z.string(),
1002
+ mergedAt: z.string().nullable(),
1003
+ isDraft: z.boolean(),
1004
+ isCrossRepository: z.boolean(),
1005
+ baseRefName: z.string(),
1006
+ headRefName: z.string().min(1),
1007
+ headRefOid: CommitSha,
1008
+ labels: z.array(z.string()),
1009
+ commentCount: nonnegativeInteger,
1010
+ reviewRequests: z.array(z.string()),
1011
+ checksState,
1012
+ reviewDecision: z.enum([
1013
+ "APPROVED",
1014
+ "CHANGES_REQUESTED",
1015
+ "REVIEW_REQUIRED"
1016
+ ]).nullable()
1017
+ });
1018
+ var WorkflowRepoSnapshot = z.strictObject({
1019
+ polledAtMs: nonnegativeInteger,
1020
+ prs: z.array(WorkflowPr)
1021
+ });
1022
+ var WorkflowsState = z.strictObject({ repos: z.record(z.string().regex(/^[a-z0-9][a-z0-9._-]*\/[a-z0-9][a-z0-9._-]*$/), WorkflowRepoSnapshot) });
1023
+ //#endregion
1024
+ //#region shared/contracts/browser-config.ts
1025
+ var optionalBoolean = (field) => z.boolean({ error: `${field} must be a boolean` }).optional();
1026
+ var optionalString = (field, trim = false) => {
1027
+ const schema = z.string({ error: `${field} must be a string` });
1028
+ return (trim ? schema.transform((value) => value.trim()) : schema).optional();
1029
+ };
1030
+ var numberRangeLabel = (range) => {
1031
+ if (range.label) return range.label;
1032
+ if (range.max != null) return `between ${range.min} and ${range.max}`;
1033
+ if (range.exclusiveMin) return `greater than ${range.min}`;
1034
+ return `at least ${range.min}`;
1035
+ };
1036
+ var optionalNumber = (field, range = POSITIVE_NUMBER_RANGE) => z.number({ error: `${field} must be ${numberRangeLabel(range)}` }).finite().refine((value) => !range.exclusiveMin || value > range.min, { message: `${field} must be ${numberRangeLabel(range)}` }).refine((value) => range.exclusiveMin || value >= range.min, { message: `${field} must be ${numberRangeLabel(range)}` }).refine((value) => range.max == null || value <= range.max, { message: `${field} must be ${numberRangeLabel(range)}` }).optional();
1037
+ var optionalInteger = (field, range) => z.number({ error: `${field} must be an integer between ${range.min} and ${range.max}` }).int({ error: `${field} must be an integer between ${range.min} and ${range.max}` }).min(range.min, { error: `${field} must be an integer between ${range.min} and ${range.max}` }).max(range.max, { error: `${field} must be an integer between ${range.min} and ${range.max}` }).optional();
1038
+ var optionalObject = (field, shape) => z.object(shape, { error: `${field} must be an object` }).nullable().optional();
1039
+ var optionalLooseObject = (field) => z.object({}, { error: `${field} must be an object` }).passthrough().nullable().optional();
1040
+ var CHANGE_MAP_NARRATOR_ENGINES = Object.freeze(["claude", "codex"]);
1041
+ var ChangeMapSettings = optionalObject("changeMap", { narrator: optionalObject("changeMap.narrator", {
1042
+ enabled: optionalBoolean("changeMap.narrator.enabled"),
1043
+ engine: z.enum(CHANGE_MAP_NARRATOR_ENGINES, { error: `changeMap.narrator.engine must be one of ${CHANGE_MAP_NARRATOR_ENGINES.join(", ")}` }).optional(),
1044
+ model: optionalString("changeMap.narrator.model", true),
1045
+ timeoutSeconds: optionalInteger("changeMap.narrator.timeoutSeconds", CHANGE_MAP_NARRATOR_TIMEOUT_RANGE)
1046
+ }) });
1047
+ var TaskTitleSettings = z.object({ refiner: z.object({
1048
+ enabled: optionalBoolean("taskTitle.refiner.enabled"),
1049
+ model: optionalString("taskTitle.refiner.model", true),
1050
+ minIntervalSeconds: optionalNumber("taskTitle.refiner.minIntervalSeconds", { min: 0 }),
1051
+ timeoutSeconds: optionalNumber("taskTitle.refiner.timeoutSeconds", {
1052
+ min: 0,
1053
+ exclusiveMin: true,
1054
+ max: 2147483647 / 1e3
1055
+ })
1056
+ }, { error: "taskTitle.refiner must be an object" }).nullable().optional() }, { error: "taskTitle must be an object" }).nullable().optional();
1057
+ var BRANCH_GC_SETTINGS_SHAPE = {
1058
+ enabled: optionalBoolean("branchGc.enabled"),
1059
+ worktrees: optionalBoolean("branchGc.worktrees"),
1060
+ prefixes: z.array(z.string({ error: "branchGc.prefixes must be an array of strings" }).min(1, { error: "branchGc.prefixes entries must be non-empty strings" }), { error: "branchGc.prefixes must be an array of strings" }).optional(),
1061
+ dryRun: optionalBoolean("branchGc.dryRun"),
1062
+ staleDays: optionalNumber("branchGc.staleDays", BRANCH_GC_STALE_DAYS_RANGE),
1063
+ deleteUnmerged: optionalBoolean("branchGc.deleteUnmerged"),
1064
+ intervalMs: optionalNumber("branchGc.intervalMs", BRANCH_GC_INTERVAL_MS_RANGE)
1065
+ };
1066
+ var BranchGcFileSettings = z.object(BRANCH_GC_SETTINGS_SHAPE, { error: "branchGc must be an object" });
1067
+ var BranchGcSettings = optionalObject("branchGc", BRANCH_GC_SETTINGS_SHAPE);
1068
+ var BranchGcControlSettings = BranchGcFileSettings.omit({
1069
+ prefixes: true,
1070
+ dryRun: true,
1071
+ worktrees: true
1072
+ }).nullable().optional();
1073
+ var BRANCH_GC_CONTROL_BOOLEAN_KEYS = Object.freeze(["enabled", "deleteUnmerged"]);
1074
+ var BRANCH_GC_CONTROL_NUMERIC_KEYS = Object.freeze(["staleDays", "intervalMs"]);
1075
+ var PostTurnChecksSettings = optionalObject("postTurnChecks", { mode: z.enum(["report", "fix"], { error: "postTurnChecks.mode must be one of report, fix" }).optional() });
1076
+ var VisionsSettings = optionalObject("visions", {
1077
+ enabled: optionalBoolean("visions.enabled"),
1078
+ autoFix: optionalBoolean("visions.autoFix"),
1079
+ projects: z.array(z.string({ error: "visions.projects must be an array of strings" }), { error: "visions.projects must be an array of strings" }).optional(),
1080
+ dispatch: optionalObject("visions.dispatch", {
1081
+ enabled: optionalBoolean("visions.dispatch.enabled"),
1082
+ model: optionalString("visions.dispatch.model", true),
1083
+ quietMs: optionalNumber("visions.dispatch.quietMs", VISIONS_QUIET_MS_RANGE),
1084
+ cooldownMs: optionalNumber("visions.dispatch.cooldownMs", VISIONS_COOLDOWN_MS_RANGE),
1085
+ maxPerHour: optionalNumber("visions.dispatch.maxPerHour", VISIONS_MAX_PER_HOUR_RANGE),
1086
+ activityMaxPerHour: optionalNumber("visions.dispatch.activityMaxPerHour", VISIONS_ACTIVITY_MAX_PER_HOUR_RANGE),
1087
+ dispatchTimeoutSeconds: optionalNumber("visions.dispatch.dispatchTimeoutSeconds", VISIONS_DISPATCH_TIMEOUT_RANGE)
1088
+ }),
1089
+ intent: optionalObject("visions.intent", { threadTtlMs: optionalNumber("visions.intent.threadTtlMs", VISIONS_INTENT_THREAD_TTL_MS_RANGE) })
1090
+ });
1091
+ var TeamReviewSettings = optionalObject("teamReview", {
1092
+ enabled: optionalBoolean("teamReview.enabled"),
1093
+ autoRebaseMyPrs: optionalBoolean("teamReview.autoRebaseMyPrs"),
1094
+ keepMergeableEnabled: optionalBoolean("teamReview.keepMergeableEnabled"),
1095
+ mergeQueueEnabled: optionalBoolean("teamReview.mergeQueueEnabled"),
1096
+ keepMergeableTimeoutMinutes: optionalInteger("teamReview.keepMergeableTimeoutMinutes", KEEP_MERGEABLE_TIMEOUT_MINUTES_RANGE),
1097
+ org: optionalString("teamReview.org", true),
1098
+ team: optionalString("teamReview.team", true),
1099
+ skill: optionalString("teamReview.skill", true),
1100
+ reReviewAfterHours: optionalNumber("teamReview.reReviewAfterHours"),
1101
+ skipIdleAfterDays: optionalNumber("teamReview.skipIdleAfterDays")
1102
+ });
1103
+ var BenchmarksSettings = optionalObject("benchmarks", { enabled: optionalBoolean("benchmarks.enabled") });
1104
+ var posthogNumberRanges = {
1105
+ intervalMinutes: POSTHOG_INTERVAL_RANGE,
1106
+ maxConcurrentInvestigations: POSTHOG_MAX_CONCURRENT_RANGE,
1107
+ investigationTimeoutSeconds: POSTHOG_INVESTIGATION_TIMEOUT_RANGE,
1108
+ fixTimeoutSeconds: POSTHOG_FIX_TIMEOUT_RANGE,
1109
+ minUsersToInvestigate: POSTHOG_MIN_USERS_RANGE,
1110
+ userEscalationThreshold: POSTHOG_ESCALATION_RANGE,
1111
+ recurrenceWindowDays: POSTHOG_RECURRENCE_WINDOW_RANGE,
1112
+ transientRecurrenceLimit: POSTHOG_TRANSIENT_RECURRENCE_RANGE,
1113
+ trafficSpikeMultiplier: POSTHOG_TRAFFIC_MULTIPLIER_RANGE,
1114
+ trafficSpikeMinUsers: POSTHOG_TRAFFIC_MIN_USERS_RANGE,
1115
+ trafficSpikeCooldownMinutes: POSTHOG_TRAFFIC_COOLDOWN_RANGE,
1116
+ trafficSpikeBaselineDays: POSTHOG_TRAFFIC_BASELINE_RANGE
1117
+ };
1118
+ var PosthogSettings = optionalObject("posthog", {
1119
+ enabled: optionalBoolean("posthog.enabled"),
1120
+ recurrenceDedupe: optionalBoolean("posthog.recurrenceDedupe"),
1121
+ trafficSpikeEnabled: optionalBoolean("posthog.trafficSpikeEnabled"),
1122
+ autoFix: optionalBoolean("posthog.autoFix"),
1123
+ host: optionalString("posthog.host", true).refine((value) => value == null || !value || /^https?:\/\//i.test(value), { message: "posthog.host must be an http(s) URL" }),
1124
+ apiKey: optionalString("posthog.apiKey", true),
1125
+ repoPath: optionalString("posthog.repoPath", true),
1126
+ projects: z.union([z.literal("all"), z.array(z.number({ error: "posthog.projects must be \"all\" or an array of positive integer project ids" }).int({ error: "posthog.projects must be \"all\" or an array of positive integer project ids" }).positive({ error: "posthog.projects must be \"all\" or an array of positive integer project ids" }), { error: "posthog.projects must be \"all\" or an array of positive integer project ids" })], { error: "posthog.projects must be \"all\" or an array of positive integer project ids" }).optional(),
1127
+ projectMap: z.record(z.string(), z.unknown(), { error: "posthog.projectMap must be an object" }).optional(),
1128
+ ...Object.fromEntries(Object.entries(posthogNumberRanges).map(([key, range]) => [key, optionalNumber(`posthog.${key}`, range)]))
1129
+ });
1130
+ var usageCostModeMessage = `usage.costMode must be one of ${USAGE_COST_MODES.join(", ")}`;
1131
+ var usageVendorShape = Object.fromEntries(USAGE_VENDOR_KEYS.map((key) => [key, optionalBoolean(`usage.vendors.${key}`)]));
1132
+ var usageBudgetShape = Object.fromEntries(USAGE_BUDGET_KEYS.map((key) => [key, z.number({ error: `usage.budget.${key} must be a positive number or null` }).positive({ error: `usage.budget.${key} must be a positive number or null` }).nullable().optional()]));
1133
+ var createUsageSettings = (isAbsolutePath) => optionalObject("usage", {
1134
+ enabled: optionalBoolean("usage.enabled"),
1135
+ fetchPricing: optionalBoolean("usage.fetchPricing"),
1136
+ planLimits: optionalBoolean("usage.planLimits"),
1137
+ rtkSavings: optionalBoolean("usage.rtkSavings"),
1138
+ scanIntervalMinutes: optionalInteger("usage.scanIntervalMinutes", USAGE_INTEGER_RANGES.scanIntervalMinutes),
1139
+ retainDays: optionalInteger("usage.retainDays", USAGE_INTEGER_RANGES.retainDays),
1140
+ warehouseRetainDays: optionalInteger("usage.warehouseRetainDays", USAGE_INTEGER_RANGES.warehouseRetainDays),
1141
+ sessionBlockHours: optionalInteger("usage.sessionBlockHours", USAGE_INTEGER_RANGES.sessionBlockHours),
1142
+ costMode: z.enum(USAGE_COST_MODES, { error: usageCostModeMessage }).optional(),
1143
+ vendors: optionalObject("usage.vendors", usageVendorShape),
1144
+ budget: optionalObject("usage.budget", usageBudgetShape),
1145
+ extraProjectsDirs: z.array(z.string({ error: "usage.extraProjectsDirs must be an array of absolute paths" }), { error: "usage.extraProjectsDirs must be an array of absolute paths" }).transform((directories) => directories.map((directory) => directory.trim())).refine((directories) => directories.every((directory) => directory && isAbsolutePath(directory)), { message: "usage.extraProjectsDirs entries must be absolute paths" }).optional()
1146
+ });
1147
+ var TelegramSettings = optionalObject("telegram", {
1148
+ botToken: optionalString("telegram.botToken", true),
1149
+ chatId: optionalString("telegram.chatId", true)
1150
+ });
1151
+ var IngestSettings = z.object({ enabled: optionalBoolean("ingest.enabled") }, { error: "ingest must be an object" }).passthrough().optional();
1152
+ var TraceSettings = z.object({ enabled: optionalBoolean("trace.enabled") }, { error: "trace must be an object" }).optional();
1153
+ var PlanReviewSettings = z.object({ enabled: optionalBoolean("planReview.enabled") }, { error: "planReview must be an object" }).optional();
1154
+ var agentApiShape = { enabled: optionalBoolean("agentApi.enabled") };
1155
+ var AgentApiSettings = z.object(agentApiShape, { error: "agentApi must be an object" }).strict().optional();
1156
+ var AgentApiFileSettings = z.object(agentApiShape, { error: "agentApi must be an object" }).passthrough().optional();
1157
+ var telemetryShape = { enabled: optionalBoolean("telemetry.enabled") };
1158
+ var TelemetrySettings = z.object(telemetryShape, { error: "telemetry must be an object" }).strict().optional();
1159
+ var TelemetryFileSettings = z.object(telemetryShape, { error: "telemetry must be an object" }).passthrough().optional();
1160
+ var createBrowserConfigShape = (isAbsolutePath) => ({
1161
+ port: z.number().int().min(0).max(65535).optional(),
1162
+ autoRecoverSeconds: z.number().finite().nonnegative().optional(),
1163
+ inputGraceSeconds: z.number().finite().nonnegative().optional(),
1164
+ promptDetectionMs: z.number().finite().nonnegative().optional(),
1165
+ notifyDebounceMs: z.number().finite().nonnegative().optional(),
1166
+ phoneEscalationMs: z.number().finite().nonnegative().optional(),
1167
+ replayBufferKB: optionalNumber("replayBufferKB", {
1168
+ ...REPLAY_BUFFER_KB_RANGE,
1169
+ min: 0
1170
+ }),
1171
+ cursorBlink: optionalBoolean("cursorBlink"),
1172
+ debugMode: optionalBoolean("debugMode"),
1173
+ calmLayout: optionalBoolean("calmLayout"),
1174
+ detectBackgroundAgents: optionalBoolean("detectBackgroundAgents"),
1175
+ recordSignals: optionalBoolean("recordSignals"),
1176
+ antiSlopPrompt: optionalBoolean("antiSlopPrompt"),
1177
+ rtk: optionalBoolean("rtk"),
1178
+ saneYolo: optionalBoolean("saneYolo"),
1179
+ skipPermissionsByDefault: optionalBoolean("skipPermissionsByDefault"),
1180
+ checkForUpdates: optionalBoolean("checkForUpdates"),
1181
+ updateChannel: z.enum(["release", "main"], { error: "updateChannel must be one of release, main" }).optional(),
1182
+ autoResume: optionalBoolean("autoResume"),
1183
+ telegramNotifications: optionalBoolean("telegramNotifications"),
1184
+ integrationBranch: optionalString("integrationBranch").nullable(),
1185
+ worktreeRoot: optionalString("worktreeRoot"),
1186
+ worktreeShare: z.array(z.string()).optional(),
1187
+ repoRoots: z.array(z.string()).optional(),
1188
+ changeMap: ChangeMapSettings,
1189
+ taskTitle: TaskTitleSettings,
1190
+ branchGc: BranchGcSettings,
1191
+ postTurnChecks: PostTurnChecksSettings,
1192
+ visions: VisionsSettings,
1193
+ teamReview: TeamReviewSettings,
1194
+ benchmarks: BenchmarksSettings,
1195
+ posthog: PosthogSettings,
1196
+ usage: createUsageSettings(isAbsolutePath),
1197
+ telegram: TelegramSettings,
1198
+ ingest: IngestSettings,
1199
+ agentApi: AgentApiSettings,
1200
+ telemetry: TelemetrySettings,
1201
+ workflows: WorkflowsSettings.nullable().optional()
1202
+ });
1203
+ var createBrowserConfig = (isAbsolutePath) => z.object(createBrowserConfigShape(isAbsolutePath));
1204
+ //#endregion
1205
+ //#region shared/contracts/config.ts
1206
+ var BrowserConfig = createBrowserConfig(path.isAbsolute);
1207
+ var BROWSER_CONFIG_SHAPE = BrowserConfig.shape;
1208
+ var ConfigUpdate = z.object({
1209
+ ...BROWSER_CONFIG_SHAPE,
1210
+ autoRecoverSeconds: z.number({ error: "autoRecoverSeconds must be a positive number" }).finite().positive({ error: "autoRecoverSeconds must be a positive number" }).optional(),
1211
+ inputGraceSeconds: z.number({ error: "inputGraceSeconds must be a positive number" }).finite().positive({ error: "inputGraceSeconds must be a positive number" }).optional(),
1212
+ promptDetectionMs: z.number({ error: "promptDetectionMs must be a positive number" }).finite().positive({ error: "promptDetectionMs must be a positive number" }).optional(),
1213
+ notifyDebounceMs: z.number({ error: "notifyDebounceMs must be a positive number" }).finite().positive({ error: "notifyDebounceMs must be a positive number" }).optional(),
1214
+ phoneEscalationMs: z.number({ error: "phoneEscalationMs must be a positive number" }).finite().positive({ error: "phoneEscalationMs must be a positive number" }).optional(),
1215
+ replayBufferKB: optionalNumber("replayBufferKB", REPLAY_BUFFER_KB_RANGE),
1216
+ branchGc: BranchGcControlSettings,
1217
+ worktreeAutoRebase: optionalBoolean("worktreeAutoRebase"),
1218
+ worktreeSyncOnStart: optionalBoolean("worktreeSyncOnStart"),
1219
+ worktreeRerere: optionalBoolean("worktreeRerere"),
1220
+ workflows: WorkflowsSettingsUpdate.optional()
1221
+ }).omit({
1222
+ port: true,
1223
+ worktreeShare: true
1224
+ }).strict();
1225
+ var AGENT_ID_RE = /^[a-z][a-z0-9-]{1,31}$/;
1226
+ var BUILTIN_AGENT_IDS = Object.freeze([
1227
+ "claude-code",
1228
+ "codex",
1229
+ "grok"
1230
+ ]);
1231
+ var AGENT_ID_SHAPE_MESSAGE = "an agent id of 2 to 32 characters of lowercase letters, digits and dashes, starting with a letter";
1232
+ var AGENT_COMMAND_BASENAME_RE = /^[A-Za-z0-9._+-]+$/;
1233
+ var AGENT_COMMAND_ABSOLUTE_RE = /^(?:\/|[A-Za-z]:[\\/])[A-Za-z0-9._+\-\\/]*[A-Za-z0-9._+-]$/;
1234
+ var AGENT_COMMAND_SHAPE_MESSAGE = "a bare command name or an absolute path, built only from letters, digits, dot, underscore, plus, dash and path separators";
1235
+ function isSpawnableCommand(command) {
1236
+ if (AGENT_COMMAND_BASENAME_RE.test(command)) return true;
1237
+ return AGENT_COMMAND_ABSOLUTE_RE.test(command);
1238
+ }
1239
+ var CustomAgentDeclaration = z.object({
1240
+ id: z.string({ error: "customAgents[].id must be a string" }).regex(AGENT_ID_RE, { error: `customAgents[].id must be ${AGENT_ID_SHAPE_MESSAGE}` }),
1241
+ label: z.string({ error: "customAgents[].label must be a string" }).min(1, { error: "customAgents[].label must not be empty" }).max(60, { error: "customAgents[].label must be at most 60 characters" }),
1242
+ command: z.string({ error: "customAgents[].command must be a string" }).min(1, { error: "customAgents[].command must not be empty" }).refine((command) => command.trim().length > 0, { error: "customAgents[].command must not be blank" }).refine(isSpawnableCommand, { error: `customAgents[].command must be ${AGENT_COMMAND_SHAPE_MESSAGE}` }),
1243
+ args: z.array(z.string({ error: "customAgents[].args must be an array of strings" }), { error: "customAgents[].args must be an array of strings" }).default([]),
1244
+ idleTitle: z.string({ error: "customAgents[].idleTitle must be a string" }).optional(),
1245
+ busyTitle: z.string({ error: "customAgents[].busyTitle must be a string" }).optional()
1246
+ }).strict();
1247
+ var CustomAgentDeclarations = z.array(CustomAgentDeclaration, { error: "customAgents must be an array" }).superRefine((declarations, ctx) => {
1248
+ const claimedIds = new Set(BUILTIN_AGENT_IDS);
1249
+ for (const [index, declaration] of declarations.entries()) {
1250
+ if (!claimedIds.has(declaration.id)) {
1251
+ claimedIds.add(declaration.id);
1252
+ continue;
1253
+ }
1254
+ const message = BUILTIN_AGENT_IDS.some((builtinAgentId) => builtinAgentId === declaration.id) ? `customAgents[${index}].id "${declaration.id}" collides with the builtin agent of the same id` : `customAgents[${index}].id "${declaration.id}" is declared more than once`;
1255
+ ctx.addIssue({
1256
+ code: "custom",
1257
+ path: [index, "id"],
1258
+ message
1259
+ });
1260
+ }
1261
+ });
1262
+ var ProjectConfig = z.object({
1263
+ id: z.string().optional(),
1264
+ name: z.string().optional(),
1265
+ customTitle: TaskTitle.optional(),
1266
+ path: z.string(),
1267
+ repos: z.array(z.string()).min(2).optional(),
1268
+ agent: z.string({ error: "projects[].agent must be a string" }).regex(AGENT_ID_RE, { error: `projects[].agent must be ${AGENT_ID_SHAPE_MESSAGE}` }).optional(),
1269
+ codexBypassHookTrust: z.boolean().optional(),
1270
+ dangerouslySkipPermissions: z.boolean({ error: "projects[].dangerouslySkipPermissions must be a boolean" }).optional()
1271
+ }).passthrough();
1272
+ var FILE_CONFIG_SHAPE = {
1273
+ ...BROWSER_CONFIG_SHAPE,
1274
+ changeMap: ChangeMapSettings,
1275
+ branchGc: optionalLooseObject("branchGc"),
1276
+ coder: z.object({ appSlug: z.string().optional() }).loose().optional(),
1277
+ visions: optionalLooseObject("visions"),
1278
+ teamReview: optionalLooseObject("teamReview"),
1279
+ benchmarks: optionalLooseObject("benchmarks"),
1280
+ posthog: optionalLooseObject("posthog"),
1281
+ usage: optionalLooseObject("usage"),
1282
+ telegram: optionalLooseObject("telegram"),
1283
+ ingest: optionalLooseObject("ingest"),
1284
+ workflows: optionalLooseObject("workflows"),
1285
+ agentApi: AgentApiFileSettings,
1286
+ telemetry: TelemetryFileSettings,
1287
+ trace: TraceSettings,
1288
+ planReview: PlanReviewSettings,
1289
+ customAgents: CustomAgentDeclarations.optional()
1290
+ };
1291
+ var Config = z.object({
1292
+ ...FILE_CONFIG_SHAPE,
1293
+ detectScheduledWakeups: optionalBoolean("detectScheduledWakeups"),
1294
+ worktreeAutoRebase: optionalBoolean("worktreeAutoRebase"),
1295
+ worktreeSyncOnStart: optionalBoolean("worktreeSyncOnStart"),
1296
+ worktreeRerere: optionalBoolean("worktreeRerere"),
1297
+ postTurnChecks: z.record(z.string(), z.unknown()).optional(),
1298
+ hooks: z.unknown().optional(),
1299
+ remote: z.object({
1300
+ enabled: z.boolean().optional(),
1301
+ port: z.number().int().min(1).max(65535).nullable().optional(),
1302
+ publicHost: z.string().optional(),
1303
+ allowedOrigins: z.array(z.string()).optional(),
1304
+ ownerLogin: z.string().optional()
1305
+ }).passthrough().optional(),
1306
+ projects: z.array(ProjectConfig)
1307
+ }).passthrough().superRefine((config, ctx) => {
1308
+ if (!Array.isArray(config.projects)) return;
1309
+ const declaredAgentIds = new Set(BUILTIN_AGENT_IDS);
1310
+ for (const declaration of config.customAgents ?? []) declaredAgentIds.add(declaration.id);
1311
+ for (const [index, project] of config.projects.entries()) {
1312
+ const agent = project?.agent;
1313
+ if (typeof agent !== "string" || !AGENT_ID_RE.test(agent)) continue;
1314
+ if (declaredAgentIds.has(agent)) continue;
1315
+ ctx.addIssue({
1316
+ code: "custom",
1317
+ path: [
1318
+ "projects",
1319
+ index,
1320
+ "agent"
1321
+ ],
1322
+ message: `projects[${index}].agent "${agent}" names no known agent; declare it under customAgents or use one of ${[...declaredAgentIds].join(", ")}`
1323
+ });
1324
+ }
1325
+ });
1326
+ Object.freeze(Object.keys(BROWSER_CONFIG_SHAPE));
1327
+ var CONFIG_BLOCK_KEYS = Object.freeze([
1328
+ "changeMap",
1329
+ "taskTitle",
1330
+ "branchGc",
1331
+ "postTurnChecks",
1332
+ "visions",
1333
+ "teamReview",
1334
+ "benchmarks",
1335
+ "posthog",
1336
+ "usage",
1337
+ "telegram",
1338
+ "ingest",
1339
+ "agentApi",
1340
+ "telemetry",
1341
+ "workflows",
1342
+ "coder"
1343
+ ]);
1344
+ var CONFIG_SCALAR_KEYS = Object.freeze(Object.keys(BROWSER_CONFIG_SHAPE).filter((key) => {
1345
+ if (CONFIG_BLOCK_KEYS.includes(key)) return false;
1346
+ return key !== "port" && key !== "repoRoots" && key !== "worktreeShare";
1347
+ }));
1348
+ var RUNTIME_CONFIG_SCALAR_KEYS = Object.freeze([
1349
+ ...CONFIG_SCALAR_KEYS,
1350
+ "worktreeAutoRebase",
1351
+ "worktreeSyncOnStart",
1352
+ "worktreeRerere"
1353
+ ]);
1354
+ Object.freeze([
1355
+ "detectScheduledWakeups",
1356
+ "worktreeAutoRebase",
1357
+ "worktreeSyncOnStart",
1358
+ "worktreeRerere",
1359
+ "hooks",
1360
+ "remote",
1361
+ "projects"
1362
+ ]);
1363
+ function configIssueMessage(error) {
1364
+ return error.issues[0]?.message || "settings are invalid";
1365
+ }
1366
+ //#endregion
1367
+ //#region shared/contracts/telemetry.ts
1368
+ var TELEMETRY_ADAPTERS = Object.freeze([...BUILTIN_AGENT_IDS, "custom"]);
1369
+ var SESSION_EXIT_KINDS = Object.freeze([
1370
+ "clean",
1371
+ "error",
1372
+ "signal",
1373
+ "no_output"
1374
+ ]);
1375
+ var nonNegativeInteger = z.number().int().nonnegative();
1376
+ var boundedText = z.string().max(512);
1377
+ var AppStartedProperties = z.object({}).strict();
1378
+ var AppActiveProperties = z.object({ active_session_count: nonNegativeInteger }).strict();
1379
+ var SessionStartedProperties = z.object({ adapter: z.enum(TELEMETRY_ADAPTERS) }).strict();
1380
+ var SessionEndedProperties = z.object({
1381
+ adapter: z.enum(TELEMETRY_ADAPTERS),
1382
+ exit_kind: z.enum(SESSION_EXIT_KINDS),
1383
+ duration_seconds: nonNegativeInteger
1384
+ }).strict();
1385
+ var ExceptionFrame = z.object({
1386
+ platform: z.enum(["node:javascript", "web:javascript"]),
1387
+ function: boundedText,
1388
+ filename: boundedText,
1389
+ lineno: nonNegativeInteger,
1390
+ colno: nonNegativeInteger,
1391
+ in_app: z.boolean()
1392
+ }).strict();
1393
+ var ExceptionProperties = z.object({
1394
+ $exception_list: z.array(z.object({
1395
+ type: boundedText,
1396
+ value: boundedText,
1397
+ mechanism: z.object({
1398
+ handled: z.boolean(),
1399
+ synthetic: z.boolean(),
1400
+ type: z.literal("generic")
1401
+ }).strict(),
1402
+ stacktrace: z.object({
1403
+ type: z.literal("raw"),
1404
+ frames: z.array(ExceptionFrame).max(64)
1405
+ }).strict()
1406
+ }).strict()).length(1),
1407
+ $exception_level: z.enum(["error", "fatal"])
1408
+ }).strict();
1409
+ var AiGenerationProperties = z.object({
1410
+ $ai_trace_id: z.string().regex(/^[0-9a-f]{64}$/),
1411
+ $ai_provider: z.string().max(64),
1412
+ $ai_model: z.string().max(128),
1413
+ $ai_input_tokens: nonNegativeInteger,
1414
+ $ai_output_tokens: nonNegativeInteger,
1415
+ $ai_cache_read_input_tokens: nonNegativeInteger.optional(),
1416
+ $ai_cache_creation_input_tokens: nonNegativeInteger.optional(),
1417
+ $ai_total_cost_usd: z.number().finite().nonnegative().optional(),
1418
+ agent_adapter: z.enum(TELEMETRY_ADAPTERS)
1419
+ }).strict();
1420
+ var TELEMETRY_EVENT_SCHEMAS = Object.freeze({
1421
+ app_started: AppStartedProperties,
1422
+ app_active: AppActiveProperties,
1423
+ session_started: SessionStartedProperties,
1424
+ session_ended: SessionEndedProperties,
1425
+ $exception: ExceptionProperties,
1426
+ $ai_generation: AiGenerationProperties
1427
+ });
1428
+ Object.freeze([
1429
+ {
1430
+ name: "app_started",
1431
+ description: "The server started listening."
1432
+ },
1433
+ {
1434
+ name: "app_active",
1435
+ description: "Once a day while the server runs, with how many sessions are live."
1436
+ },
1437
+ {
1438
+ name: "session_started",
1439
+ description: "A session spawned, with which kind of agent (any custom agent counts as `custom`)."
1440
+ },
1441
+ {
1442
+ name: "session_ended",
1443
+ description: "A session exited: how it exited and how long it ran, in whole seconds."
1444
+ },
1445
+ {
1446
+ name: "$exception",
1447
+ description: "An error in the server or the dashboard: its type, an error code when it has one, and stack frames with file paths cut to the package or URL path. Never the error message. Each distinct error is sent once per run, and a crash is sent on the next start."
1448
+ },
1449
+ {
1450
+ name: "$ai_generation",
1451
+ description: "Per agent session and model, after each usage scan, for usage recorded in the last 24 hours: token counts, the model name and estimated cost, under a one-way hash of the session. A model name outside the shipped pricing table is sent as unknown. No prompts or output."
1452
+ }
1453
+ ]);
1454
+ Object.freeze([
1455
+ "app_version",
1456
+ "os_platform",
1457
+ "node_major",
1458
+ "install_flavor",
1459
+ "is_bundled",
1460
+ "is_dev_install"
1461
+ ]);
1462
+ Object.freeze(["$release_id"]);
1463
+ var TELEMETRY_KILL_SWITCH_FLAG = "telemetry-enabled";
1464
+ var FeatureFlagsResponse = z.object({
1465
+ flags: z.object({ [TELEMETRY_KILL_SWITCH_FLAG]: z.object({ enabled: z.boolean() }).passthrough().optional() }).passthrough(),
1466
+ errorsWhileComputingFlags: z.boolean().optional()
1467
+ }).passthrough();
1468
+ var PendingCrashReport = z.object({
1469
+ timestamp: z.string(),
1470
+ properties: ExceptionProperties
1471
+ }).strict();
1472
+ var TelemetryState = z.object({
1473
+ installId: z.uuid(),
1474
+ noticeShownAt: z.string().nullable().optional(),
1475
+ remoteDisabled: z.boolean().optional()
1476
+ });
1477
+ //#endregion
1478
+ //#region shared/contracts/benchmark.ts
1479
+ var BENCHMARK_ID_RE = /^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$/;
1480
+ var ENV_NAME_RE = /^[A-Za-z_][A-Za-z0-9_]*$/;
1481
+ var repoSlug = z.string().regex(/^[^/\s]+\/[^/\s]+$/);
1482
+ var timestamp$1 = z.number().finite();
1483
+ var nonEmptyText = z.string().min(1);
1484
+ var BENCHMARK_INJECTED_ENV_NAMES = Object.freeze(["CLAUDE_CODE_OAUTH_TOKEN"]);
1485
+ Object.freeze(["human", "bot"]);
1486
+ var BenchmarkId = z.string().regex(BENCHMARK_ID_RE);
1487
+ function hasUniqueIds(entries) {
1488
+ return new Set(entries.map((entry) => entry.id)).size === entries.length;
1489
+ }
1490
+ var BenchmarkCaseSource = z.discriminatedUnion("kind", [z.strictObject({ kind: z.literal("manual") }), z.strictObject({
1491
+ kind: z.literal("github-merged-prs"),
1492
+ repo: repoSlug,
1493
+ minBodies: z.number().int().min(1),
1494
+ limit: z.number().int().min(1).max(500)
1495
+ })]);
1496
+ var BenchmarkWorkspace = z.discriminatedUnion("kind", [z.strictObject({ kind: z.literal("none") }), z.strictObject({ kind: z.literal("pr-checkout") })]);
1497
+ var BenchmarkSubjectOutput = z.enum(["review-findings", "json"]);
1498
+ var BenchmarkSubject = z.strictObject({
1499
+ promptTemplate: nonEmptyText,
1500
+ output: BenchmarkSubjectOutput,
1501
+ timeoutSeconds: z.number().int().min(30).max(14400)
1502
+ });
1503
+ var BenchmarkArm = z.strictObject({
1504
+ id: BenchmarkId,
1505
+ env: z.record(z.string().regex(ENV_NAME_RE), z.string()).refine((env) => BENCHMARK_INJECTED_ENV_NAMES.every((name) => !Object.hasOwn(env, name)), { message: `arm env must not set ${BENCHMARK_INJECTED_ENV_NAMES.join(", ")}; Glimmervoid injects it per cell` }).optional(),
1506
+ extraArgs: z.array(z.string()).optional(),
1507
+ setup: z.strictObject({ command: z.array(nonEmptyText).min(1) }).optional()
1508
+ });
1509
+ var BenchmarkScorer = z.discriminatedUnion("kind", [z.strictObject({
1510
+ kind: z.literal("llm-judge-match"),
1511
+ model: nonEmptyText
1512
+ })]);
1513
+ var BenchmarkSuite = z.strictObject({
1514
+ id: BenchmarkId,
1515
+ title: nonEmptyText,
1516
+ caseSource: BenchmarkCaseSource,
1517
+ workspace: BenchmarkWorkspace,
1518
+ subject: BenchmarkSubject,
1519
+ arms: z.array(BenchmarkArm).min(2).refine(hasUniqueIds, { message: "arm ids must be unique" }),
1520
+ baselineArm: BenchmarkId,
1521
+ trials: z.number().int().min(1).max(20),
1522
+ scorer: BenchmarkScorer
1523
+ }).refine((suite) => suite.arms.some((arm) => arm.id === suite.baselineArm), {
1524
+ message: "baselineArm must name one of the arms",
1525
+ path: ["baselineArm"]
1526
+ });
1527
+ var BenchmarkReference = z.strictObject({
1528
+ id: BenchmarkId,
1529
+ text: nonEmptyText,
1530
+ tags: z.array(BenchmarkId),
1531
+ path: nonEmptyText.optional(),
1532
+ line: z.number().int().positive().optional()
1533
+ });
1534
+ var BenchmarkCaseOrigin = z.discriminatedUnion("kind", [z.strictObject({ kind: z.literal("manual") }), z.strictObject({
1535
+ kind: z.literal("github-pr"),
1536
+ repo: repoSlug,
1537
+ number: z.number().int().positive(),
1538
+ url: nonEmptyText,
1539
+ minedAt: timestamp$1
1540
+ })]);
1541
+ var BenchmarkCase = z.strictObject({
1542
+ id: BenchmarkId,
1543
+ input: z.record(z.string(), z.unknown()),
1544
+ references: z.array(BenchmarkReference).min(1).refine(hasUniqueIds, { message: "reference ids must be unique" }),
1545
+ source: BenchmarkCaseOrigin
1546
+ });
1547
+ var PrCheckoutCaseInput = z.object({
1548
+ repo: repoSlug,
1549
+ number: z.number().int().positive(),
1550
+ reviewedSha: CommitSha,
1551
+ baseSha: CommitSha,
1552
+ changedFiles: z.array(nonEmptyText)
1553
+ });
1554
+ var BenchmarkMatchVerdict = z.enum([
1555
+ "found",
1556
+ "partial",
1557
+ "missed"
1558
+ ]);
1559
+ var BenchmarkJudgement = z.strictObject({
1560
+ referenceId: BenchmarkId,
1561
+ verdict: BenchmarkMatchVerdict,
1562
+ findingIndexes: z.array(z.number().int().nonnegative())
1563
+ });
1564
+ var BenchmarkCellStatus = z.enum([
1565
+ "scored",
1566
+ "invalid",
1567
+ "error"
1568
+ ]);
1569
+ var BenchmarkCellResult = z.strictObject({
1570
+ caseId: BenchmarkId,
1571
+ armId: BenchmarkId,
1572
+ trial: z.number().int().min(1),
1573
+ status: BenchmarkCellStatus,
1574
+ startedAt: timestamp$1,
1575
+ finishedAt: timestamp$1,
1576
+ degradedReasons: z.array(nonEmptyText),
1577
+ findingCount: z.number().int().nonnegative(),
1578
+ judgements: z.array(BenchmarkJudgement),
1579
+ costUsd: z.number().finite().nonnegative().nullable(),
1580
+ error: nonEmptyText.nullable()
1581
+ });
1582
+ var BenchmarkRunStatus = z.enum([
1583
+ "running",
1584
+ "completed",
1585
+ "interrupted",
1586
+ "failed"
1587
+ ]);
1588
+ var BenchmarkRun = z.strictObject({
1589
+ id: BenchmarkId,
1590
+ suiteId: BenchmarkId,
1591
+ status: BenchmarkRunStatus,
1592
+ startedAt: timestamp$1,
1593
+ finishedAt: timestamp$1.nullable(),
1594
+ error: nonEmptyText.nullable(),
1595
+ cells: z.array(BenchmarkCellResult)
1596
+ });
1597
+ var nullableRatio = z.number().min(0).max(1).nullable();
1598
+ var BenchmarkArmScore = z.strictObject({
1599
+ trials: z.number().int().nonnegative(),
1600
+ recall: nullableRatio,
1601
+ recallByTag: z.record(BenchmarkId, nullableRatio),
1602
+ degraded: z.number().int().nonnegative(),
1603
+ invalid: z.number().int().nonnegative(),
1604
+ costUsd: z.number().finite().nonnegative().nullable()
1605
+ });
1606
+ var BenchmarkReportRow = z.strictObject({
1607
+ caseId: BenchmarkId,
1608
+ arms: z.record(BenchmarkId, BenchmarkArmScore),
1609
+ deltaVsBaseline: z.record(BenchmarkId, z.number().min(-1).max(1).nullable())
1610
+ });
1611
+ var BenchmarkReport = z.strictObject({
1612
+ runId: BenchmarkId,
1613
+ suiteId: BenchmarkId,
1614
+ status: BenchmarkRunStatus,
1615
+ baselineArm: BenchmarkId,
1616
+ armIds: z.array(BenchmarkId),
1617
+ rows: z.array(BenchmarkReportRow),
1618
+ totals: z.record(BenchmarkId, BenchmarkArmScore)
1619
+ });
1620
+ var BenchmarkAction = z.enum([
1621
+ "mine",
1622
+ "run",
1623
+ "cancel"
1624
+ ]);
1625
+ var BenchmarkActionRequest = z.object({
1626
+ suiteId: BenchmarkId,
1627
+ action: BenchmarkAction
1628
+ });
1629
+ var BenchmarkActionResult = z.object({
1630
+ suiteId: BenchmarkId,
1631
+ action: BenchmarkAction,
1632
+ ok: z.boolean(),
1633
+ error: z.string().optional(),
1634
+ runId: BenchmarkId.optional()
1635
+ });
1636
+ var BenchmarkCellPhase = z.enum([
1637
+ "setup",
1638
+ "preflight",
1639
+ "workspace",
1640
+ "subject",
1641
+ "judge"
1642
+ ]);
1643
+ var BenchmarkInFlightCell = z.object({
1644
+ suiteId: BenchmarkId,
1645
+ runId: BenchmarkId,
1646
+ caseId: BenchmarkId.nullable(),
1647
+ armId: BenchmarkId,
1648
+ trial: z.number().int().min(1),
1649
+ phase: BenchmarkCellPhase,
1650
+ cellIndex: z.number().int().nonnegative(),
1651
+ cellCount: z.number().int().positive(),
1652
+ startedAt: timestamp$1
1653
+ });
1654
+ var BenchmarkSuiteSummary = z.object({
1655
+ id: BenchmarkId,
1656
+ title: z.string(),
1657
+ error: z.string().nullable(),
1658
+ caseCount: z.number().int().nonnegative(),
1659
+ candidateCount: z.number().int().nonnegative(),
1660
+ armIds: z.array(BenchmarkId),
1661
+ baselineArm: BenchmarkId.nullable(),
1662
+ latestReport: BenchmarkReport.nullable()
1663
+ });
1664
+ var BenchmarkStatus = z.object({
1665
+ type: z.literal("benchmark-status"),
1666
+ ts: timestamp$1,
1667
+ configured: z.boolean(),
1668
+ reason: z.string().nullable(),
1669
+ suites: z.array(BenchmarkSuiteSummary),
1670
+ inFlight: BenchmarkInFlightCell.nullable()
1671
+ }).passthrough();
1672
+ var githubAuthor = z.object({
1673
+ __typename: z.string(),
1674
+ login: z.string()
1675
+ }).nullable();
1676
+ var MergedPrListing = z.object({
1677
+ number: z.number().int().positive(),
1678
+ title: z.string(),
1679
+ url: nonEmptyText,
1680
+ mergedAt: z.string().nullable(),
1681
+ reviewThreads: z.object({ totalCount: z.number().int().nonnegative() }),
1682
+ reviews: z.object({ totalCount: z.number().int().nonnegative() })
1683
+ });
1684
+ var MinedReviewThread = z.object({
1685
+ path: z.string(),
1686
+ line: z.number().int().positive().nullable(),
1687
+ originalLine: z.number().int().positive().nullable(),
1688
+ comments: z.object({ nodes: z.array(z.object({
1689
+ databaseId: z.number().int().positive(),
1690
+ author: githubAuthor,
1691
+ body: z.string(),
1692
+ createdAt: z.string(),
1693
+ originalCommit: z.object({ oid: CommitSha }).nullable()
1694
+ })) })
1695
+ });
1696
+ var MinedReview = z.object({
1697
+ databaseId: z.number().int().positive(),
1698
+ author: githubAuthor,
1699
+ body: z.string(),
1700
+ submittedAt: z.string().nullable(),
1701
+ commit: z.object({ oid: CommitSha }).nullable()
1702
+ });
1703
+ var MinedBaseEvent = z.discriminatedUnion("__typename", [z.object({
1704
+ __typename: z.literal("BaseRefChangedEvent"),
1705
+ createdAt: z.string()
1706
+ }), z.object({
1707
+ __typename: z.literal("BaseRefForcePushedEvent"),
1708
+ createdAt: z.string(),
1709
+ beforeCommit: z.object({ oid: CommitSha }).nullable()
1710
+ })]);
1711
+ var MinedPrReviewData = z.object({
1712
+ author: githubAuthor,
1713
+ baseRefOid: CommitSha,
1714
+ reviewThreads: z.object({
1715
+ pageInfo: z.object({ hasNextPage: z.boolean() }),
1716
+ nodes: z.array(MinedReviewThread)
1717
+ }),
1718
+ reviews: z.object({
1719
+ pageInfo: z.object({ hasNextPage: z.boolean() }),
1720
+ nodes: z.array(MinedReview)
1721
+ }),
1722
+ timelineItems: z.object({
1723
+ pageInfo: z.object({ hasNextPage: z.boolean() }),
1724
+ nodes: z.array(MinedBaseEvent)
1725
+ })
1726
+ });
1727
+ var CommitComparison = z.object({
1728
+ mergeBaseSha: CommitSha,
1729
+ changedFiles: z.array(nonEmptyText),
1730
+ isFileListComplete: z.boolean()
1731
+ });
1732
+ Object.freeze([
1733
+ "file",
1734
+ "subsystem",
1735
+ "co-change",
1736
+ "hotspot",
1737
+ "blast",
1738
+ "untested",
1739
+ "collision",
1740
+ "link"
1741
+ ]);
1742
+ function changeMapFactId(kind, repoName, ...parts) {
1743
+ return [
1744
+ kind,
1745
+ repoName,
1746
+ ...parts
1747
+ ].join(":");
1748
+ }
1749
+ var factId = z.string().min(1);
1750
+ var repoPath = z.string().min(1);
1751
+ var count = z.number().int().nonnegative();
1752
+ var cappedPaths = z.array(repoPath).max(20);
1753
+ var ChangedFileStatus = z.enum([
1754
+ "added",
1755
+ "modified",
1756
+ "deleted",
1757
+ "renamed",
1758
+ "untracked"
1759
+ ]);
1760
+ var ChangedFile = z.strictObject({
1761
+ factId,
1762
+ path: repoPath,
1763
+ previousPath: repoPath.optional(),
1764
+ status: ChangedFileStatus,
1765
+ isCommitted: z.boolean()
1766
+ });
1767
+ var SubsystemFact = z.strictObject({
1768
+ factId,
1769
+ agentsPath: repoPath,
1770
+ title: z.string(),
1771
+ paths: z.array(repoPath).min(1)
1772
+ });
1773
+ var CoChangeGap = z.strictObject({
1774
+ factId,
1775
+ path: repoPath,
1776
+ partner: repoPath,
1777
+ support: count,
1778
+ confidence: z.number().min(0).max(1)
1779
+ });
1780
+ var HotspotFact = z.strictObject({
1781
+ factId,
1782
+ path: repoPath,
1783
+ commitCount: count,
1784
+ fixCommitCount: count
1785
+ });
1786
+ var BlastRadiusFact = z.strictObject({
1787
+ factId,
1788
+ path: repoPath,
1789
+ directDependents: cappedPaths,
1790
+ directDependentCount: count,
1791
+ transitiveDependentCount: count,
1792
+ dependentTests: cappedPaths,
1793
+ dependentTestCount: count
1794
+ });
1795
+ var UntestedFileFact = z.strictObject({
1796
+ factId,
1797
+ path: repoPath
1798
+ });
1799
+ var CollisionFact = z.strictObject({
1800
+ factId,
1801
+ path: repoPath,
1802
+ otherSessionId: z.string().min(1),
1803
+ otherSessionName: z.string()
1804
+ });
1805
+ var CrossRepoLink = z.strictObject({
1806
+ factId,
1807
+ providerRepo: z.string().min(1),
1808
+ packageName: z.string().min(1),
1809
+ packageDir: z.string(),
1810
+ consumerManifest: repoPath,
1811
+ versionSpec: z.string(),
1812
+ isLocalLink: z.boolean(),
1813
+ providerChangedPathCount: count,
1814
+ importers: cappedPaths,
1815
+ importerCount: count,
1816
+ changedImporterCount: count
1817
+ });
1818
+ var RepoChangeMap = z.strictObject({
1819
+ name: z.string().min(1),
1820
+ root: z.string().min(1),
1821
+ sessionPathPrefix: z.string(),
1822
+ base: z.string().nullable(),
1823
+ files: z.array(ChangedFile),
1824
+ subsystems: z.array(SubsystemFact),
1825
+ coChangeGaps: z.array(CoChangeGap),
1826
+ hotspots: z.array(HotspotFact),
1827
+ blastRadius: z.array(BlastRadiusFact),
1828
+ untestedFiles: z.array(UntestedFileFact),
1829
+ collisions: z.array(CollisionFact),
1830
+ links: z.array(CrossRepoLink),
1831
+ error: z.string().nullable()
1832
+ });
1833
+ var NarrativeClaim = z.strictObject({
1834
+ text: z.string().min(1).max(600),
1835
+ factIds: z.array(factId).min(1)
1836
+ });
1837
+ var ChangeNarrative = z.strictObject({
1838
+ factsHash: z.string().min(1),
1839
+ model: z.string().nullable(),
1840
+ claims: z.array(NarrativeClaim).max(12)
1841
+ });
1842
+ var NarratorState = z.enum([
1843
+ "disabled",
1844
+ "pending",
1845
+ "ready",
1846
+ "failed"
1847
+ ]);
1848
+ var ChangeMap = z.strictObject({
1849
+ sessionId: z.string().min(1),
1850
+ sig: z.string().nullable(),
1851
+ generatedAt: z.number().finite(),
1852
+ repos: z.array(RepoChangeMap),
1853
+ narrative: ChangeNarrative.nullable(),
1854
+ narratorState: NarratorState,
1855
+ error: z.string().min(1).optional()
1856
+ });
1857
+ var PLAN_FEEDBACK_MAX_CHARS = 2e4;
1858
+ var PLAN_COMMENT_MAX_CHARS = 4e3;
1859
+ var PLAN_BODY_CAP_BYTES = 524288;
1860
+ var PLAN_HOOK_OUTPUT_MAX_CHARS = 1e4;
1861
+ var PLAN_HOOK_EVENT = "permissionrequest-plan";
1862
+ var PLAN_RESULT_HOOK_EVENT = "posttooluse-plan";
1863
+ var PLAN_TOOL_NAME = "ExitPlanMode";
1864
+ var HEADING_SCAN_MAX_CHARS = 4096;
1865
+ var ATX_HEADING = /^ {0,3}#{1,6}[ \t]+(.*)$/;
1866
+ function capPlanTitle(text) {
1867
+ const trimmed = text.trim();
1868
+ if (trimmed.length <= 120) return trimmed;
1869
+ return trimmed.slice(0, 120);
1870
+ }
1871
+ function withoutClosingHeadingMarks(text) {
1872
+ const trimmed = text.trimEnd();
1873
+ let textEnd = trimmed.length;
1874
+ while (textEnd > 0 && trimmed[textEnd - 1] === "#") textEnd--;
1875
+ if (textEnd === trimmed.length || textEnd === 0) return trimmed;
1876
+ const charBeforeMarks = trimmed[textEnd - 1];
1877
+ if (charBeforeMarks !== " " && charBeforeMarks !== " ") return trimmed;
1878
+ return trimmed.slice(0, textEnd).trimEnd();
1879
+ }
1880
+ function headingTitle(line) {
1881
+ const heading = ATX_HEADING.exec(line.slice(0, HEADING_SCAN_MAX_CHARS));
1882
+ if (!heading) return "";
1883
+ return withoutClosingHeadingMarks(heading[1]);
1884
+ }
1885
+ function planTitle(plan) {
1886
+ const lines = typeof plan === "string" ? plan.split(/\r?\n/) : [];
1887
+ for (const line of lines) {
1888
+ const title = headingTitle(line);
1889
+ if (title.length > 0) return capPlanTitle(title);
1890
+ }
1891
+ return capPlanTitle(lines.find((line) => line.trim().length > 0) ?? "");
1892
+ }
1893
+ var ExitPlanModeInput = z.object({
1894
+ plan: z.string().min(1),
1895
+ planFilePath: z.string().min(1),
1896
+ agent_id: z.string().min(1).optional(),
1897
+ agent_type: z.string().min(1).optional()
1898
+ }).passthrough();
1899
+ var ExitPlanModeHookPayload = z.object({
1900
+ tool_name: z.literal(PLAN_TOOL_NAME),
1901
+ tool_input: ExitPlanModeInput,
1902
+ agent_id: z.string().min(1).optional(),
1903
+ agent_type: z.string().min(1).optional()
1904
+ }).passthrough();
1905
+ var ExitPlanModeRequest = z.object({
1906
+ plan: z.string(),
1907
+ planFilePath: z.string(),
1908
+ agentId: z.string().nullable(),
1909
+ agentType: z.string().nullable()
1910
+ });
1911
+ function parseExitPlanModeHookPayload(body) {
1912
+ const parsed = ExitPlanModeHookPayload.safeParse(body);
1913
+ if (!parsed.success) return null;
1914
+ const input = parsed.data.tool_input;
1915
+ return {
1916
+ plan: input.plan,
1917
+ planFilePath: input.planFilePath,
1918
+ agentId: parsed.data.agent_id ?? input.agent_id ?? null,
1919
+ agentType: parsed.data.agent_type ?? input.agent_type ?? null
1920
+ };
1921
+ }
1922
+ var PlanRevision = ExitPlanModeRequest.extend({
1923
+ sessionId: z.string().min(1),
1924
+ revision: z.number().int().positive(),
1925
+ receivedAt: z.number().finite()
1926
+ });
1927
+ var PLAN_REVIEW_STATE_VALUES = Object.freeze([
1928
+ "open",
1929
+ "released",
1930
+ "decided",
1931
+ "closed"
1932
+ ]);
1933
+ var PlanReviewStateValue = z.enum(PLAN_REVIEW_STATE_VALUES);
1934
+ var PLAN_DECISION_KINDS = Object.freeze([
1935
+ "approve",
1936
+ "approve-accept-edits",
1937
+ "revise",
1938
+ "terminal"
1939
+ ]);
1940
+ var PlanDecisionKind = z.enum(PLAN_DECISION_KINDS);
1941
+ var PlanSectionComment = z.object({
1942
+ heading: z.string().max(PLAN_COMMENT_MAX_CHARS).nullable(),
1943
+ comment: z.string().min(1).max(PLAN_COMMENT_MAX_CHARS)
1944
+ });
1945
+ var PlanDecision = z.object({
1946
+ id: z.string().min(1),
1947
+ agentId: z.string().nullable(),
1948
+ revision: z.number().int().positive(),
1949
+ decision: PlanDecisionKind,
1950
+ feedback: z.string().max(PLAN_FEEDBACK_MAX_CHARS).optional(),
1951
+ comments: z.array(PlanSectionComment).max(40).optional(),
1952
+ plan: z.string().min(1).max(PLAN_BODY_CAP_BYTES).optional()
1953
+ });
1954
+ var PlanRevisionSummary = z.object({
1955
+ revision: z.number().int().positive(),
1956
+ receivedAt: z.number().finite(),
1957
+ chars: z.number().int().nonnegative(),
1958
+ title: z.string()
1959
+ });
1960
+ var PlanReviewOpenRevision = z.object({
1961
+ revision: z.number().int().positive(),
1962
+ since: z.number().finite()
1963
+ });
1964
+ var PlanReview = z.object({
1965
+ agentId: z.string().nullable(),
1966
+ agentType: z.string().nullable(),
1967
+ revisions: z.array(PlanRevisionSummary),
1968
+ state: PlanReviewStateValue,
1969
+ openRevision: PlanReviewOpenRevision.nullable(),
1970
+ approvedRevision: z.number().int().positive().nullable(),
1971
+ lastDecision: PlanDecisionKind.nullable()
1972
+ });
1973
+ z.object({ reviews: z.array(PlanReview) });
1974
+ var PlanRevisionBody = z.object({
1975
+ agentId: z.string().nullable(),
1976
+ revision: z.number().int().nonnegative(),
1977
+ plan: z.string(),
1978
+ planFilePath: z.string(),
1979
+ receivedAt: z.number().finite()
1980
+ });
1981
+ var PlanChangedPush = z.object({
1982
+ id: z.string(),
1983
+ agentId: z.string().nullable(),
1984
+ agentType: z.string().nullable(),
1985
+ revision: z.number().int().positive(),
1986
+ receivedAt: z.number().finite(),
1987
+ state: PlanReviewStateValue,
1988
+ lastDecision: PlanDecisionKind.nullable(),
1989
+ approvedRevision: z.number().int().positive().nullable(),
1990
+ chars: z.number().int().nonnegative(),
1991
+ title: z.string(),
1992
+ hasPlan: z.boolean()
1993
+ });
1994
+ var PlanDraftPush = z.object({
1995
+ id: z.string(),
1996
+ agentId: z.string().nullable(),
1997
+ planFilePath: z.string(),
1998
+ changedAt: z.number().finite()
1999
+ });
2000
+ var PlanResponseFrame = z.object({
2001
+ id: z.string(),
2002
+ reviews: z.array(PlanReview),
2003
+ body: PlanRevisionBody.nullable()
2004
+ });
2005
+ //#endregion
2006
+ //#region shared/contracts/trace.ts
2007
+ var MAX_RAW_LINE_CHARS = 4e3;
2008
+ var TraceRecordBase = z.object({
2009
+ ts: z.number().finite(),
2010
+ uuid: z.string().nullable(),
2011
+ parentUuid: z.string().nullable(),
2012
+ vendorSessionId: z.string().min(1),
2013
+ agentId: z.string().min(1).optional(),
2014
+ agentType: z.string().min(1).optional(),
2015
+ transcriptOffset: z.number().int().nonnegative().optional(),
2016
+ truncated: z.boolean().optional()
2017
+ });
2018
+ var TraceRecord = z.discriminatedUnion("kind", [
2019
+ TraceRecordBase.extend({
2020
+ kind: z.literal("prompt"),
2021
+ text: z.string()
2022
+ }),
2023
+ TraceRecordBase.extend({
2024
+ kind: z.literal("expansion"),
2025
+ text: z.string(),
2026
+ toolUseId: z.string().min(1).optional()
2027
+ }),
2028
+ TraceRecordBase.extend({
2029
+ kind: z.literal("thinking"),
2030
+ text: z.string()
2031
+ }),
2032
+ TraceRecordBase.extend({
2033
+ kind: z.literal("assistant"),
2034
+ text: z.string()
2035
+ }),
2036
+ TraceRecordBase.extend({
2037
+ kind: z.literal("tool_call"),
2038
+ toolUseId: z.string().min(1),
2039
+ name: z.string().min(1),
2040
+ input: z.unknown()
2041
+ }),
2042
+ TraceRecordBase.extend({
2043
+ kind: z.literal("tool_result"),
2044
+ toolUseId: z.string().min(1),
2045
+ content: z.string(),
2046
+ isError: z.boolean(),
2047
+ truncated: z.boolean()
2048
+ }),
2049
+ TraceRecordBase.extend({
2050
+ kind: z.literal("session"),
2051
+ vendor: z.string().min(1),
2052
+ transcriptPath: z.string().min(1),
2053
+ reason: z.string().min(1).optional()
2054
+ }),
2055
+ TraceRecordBase.extend({
2056
+ kind: z.literal("notice"),
2057
+ text: z.string().max(MAX_RAW_LINE_CHARS)
2058
+ }),
2059
+ TraceRecordBase.extend({
2060
+ kind: z.literal("raw"),
2061
+ line: z.string().max(MAX_RAW_LINE_CHARS)
2062
+ })
2063
+ ]);
2064
+ var TraceCheckpoint = z.object({
2065
+ transcriptPath: z.string().min(1),
2066
+ vendorSessionId: z.string().min(1),
2067
+ offset: z.number().int().nonnegative(),
2068
+ ingestedSubagentPaths: z.array(z.string().min(1)),
2069
+ offsetByTranscriptPath: z.record(z.string().min(1), z.number().int().nonnegative()).default({}),
2070
+ subagentOffsetByPath: z.record(z.string().min(1), z.number().int().nonnegative()).default({})
2071
+ });
2072
+ //#endregion
2073
+ //#region shared/contracts/update-journal.ts
2074
+ var UpdateChannel = z.enum(["release", "main"]);
2075
+ var UpdateRunState = z.enum([
2076
+ "idle",
2077
+ "running",
2078
+ "staged",
2079
+ "succeeded",
2080
+ "failed",
2081
+ "discarded",
2082
+ "interrupted"
2083
+ ]);
2084
+ var UpdateStepId = z.enum([
2085
+ "fetch",
2086
+ "stage",
2087
+ "install",
2088
+ "link-deps",
2089
+ "build"
2090
+ ]);
2091
+ var UpdateStepStatus = z.enum([
2092
+ "pending",
2093
+ "running",
2094
+ "succeeded",
2095
+ "failed"
2096
+ ]);
2097
+ var UpdateJournalStep = z.object({
2098
+ id: UpdateStepId,
2099
+ status: UpdateStepStatus,
2100
+ startedAt: z.number().finite().nullable(),
2101
+ finishedAt: z.number().finite().nullable(),
2102
+ outputTail: z.array(z.string())
2103
+ }).strict();
2104
+ var UpdateJournal = z.object({
2105
+ state: UpdateRunState,
2106
+ fromSha: z.string().nullable(),
2107
+ toSha: z.string().nullable(),
2108
+ toVersion: z.string().nullable(),
2109
+ channel: UpdateChannel,
2110
+ steps: z.array(UpdateJournalStep),
2111
+ activeStep: UpdateStepId.nullable(),
2112
+ reason: z.string().nullable(),
2113
+ startedAt: z.number().finite().nullable(),
2114
+ finishedAt: z.number().finite().nullable(),
2115
+ failedAtHandOff: z.boolean().optional()
2116
+ }).strict();
2117
+ var UpdateJournalSummary = UpdateJournal.pick({
2118
+ state: true,
2119
+ activeStep: true,
2120
+ reason: true,
2121
+ startedAt: true,
2122
+ finishedAt: true
2123
+ });
2124
+ //#endregion
2125
+ //#region shared/contracts/control-messages.ts
2126
+ var requestId = z.string().nullable().optional();
2127
+ var sessionId = z.string();
2128
+ function loose(type, shape) {
2129
+ return z.looseObject({
2130
+ type: z.literal(type),
2131
+ ...shape
2132
+ });
2133
+ }
2134
+ function openObject(shape = {}) {
2135
+ return z.looseObject(shape);
2136
+ }
2137
+ var nullableString = z.string().nullable();
2138
+ var timestamp = z.number().finite();
2139
+ var optionalTimestamp = timestamp.optional();
2140
+ var optionalError = nullableString.optional();
2141
+ var opaqueObject = openObject();
2142
+ var opaqueArray = z.array(z.unknown());
2143
+ var planRevisionNumber = z.number().int().positive();
2144
+ var trailSteps = z.array(openObject({
2145
+ at: timestamp,
2146
+ tool: z.string(),
2147
+ detail: z.string()
2148
+ }));
2149
+ z.object({
2150
+ id: z.string(),
2151
+ label: z.string(),
2152
+ command: z.string(),
2153
+ args: z.array(z.string()),
2154
+ resolvable: z.boolean().nullable()
2155
+ }).strict();
2156
+ var SessionCardFields = z.object({
2157
+ id: sessionId,
2158
+ session: z.string(),
2159
+ taskTitle: TaskTitle.nullable().optional(),
2160
+ taskTitleIsCustom: z.boolean().optional(),
2161
+ path: z.string(),
2162
+ agent: z.string(),
2163
+ state: SessionState,
2164
+ stateSince: timestamp,
2165
+ skipPerms: z.boolean(),
2166
+ saneYolo: z.boolean(),
2167
+ worktree: z.boolean(),
2168
+ workspace: z.boolean().optional(),
2169
+ resumeSessionId: nullableString,
2170
+ ephemeral: z.boolean().optional()
2171
+ });
2172
+ var githubIssueRow = z.object({
2173
+ number: z.number().int().positive(),
2174
+ title: z.string(),
2175
+ labels: z.array(z.object({
2176
+ name: z.string(),
2177
+ color: z.string()
2178
+ }).passthrough()),
2179
+ url: z.string(),
2180
+ updatedAt: z.string()
2181
+ }).passthrough();
2182
+ var IssuesReportPush = z.object({
2183
+ ts: timestamp,
2184
+ projectId: z.string(),
2185
+ issues: z.array(githubIssueRow),
2186
+ error: optionalError
2187
+ });
2188
+ var DIFF_ANNOTATION_NOTE_MAX_CHARS = 1e3;
2189
+ var DIFF_ANNOTATION_PATH_RE = new RegExp(`^[^${String.fromCharCode(0)}-${String.fromCharCode(31)}${String.fromCharCode(127)}-${String.fromCharCode(159)}]+$`);
2190
+ var DiffAnnotation = z.strictObject({
2191
+ section: z.enum(["committed", "uncommitted"]),
2192
+ path: z.string().min(1).max(400).regex(DIFF_ANNOTATION_PATH_RE),
2193
+ line: z.number().int().positive(),
2194
+ side: z.enum(["old", "new"]),
2195
+ note: z.string().min(1).max(DIFF_ANNOTATION_NOTE_MAX_CHARS)
2196
+ });
2197
+ var CONTROL_FRAME_MAX_BYTES = 4096 + 2 * (PLAN_BODY_CAP_BYTES + PLAN_FEEDBACK_MAX_CHARS + 80 * PLAN_COMMENT_MAX_CHARS);
2198
+ var UpdateApplyRefusal = z.object({
2199
+ reason: z.string(),
2200
+ message: z.string()
2201
+ });
2202
+ var InstallFlavor = z.enum([
2203
+ "npm-global",
2204
+ "npx",
2205
+ "clone",
2206
+ "unknown"
2207
+ ]);
2208
+ var updateStatusShape = {
2209
+ updateAvailable: z.boolean(),
2210
+ current: nullableString,
2211
+ latest: nullableString,
2212
+ currentSha: nullableString,
2213
+ latestSha: nullableString,
2214
+ releaseUrl: nullableString,
2215
+ command: z.string(),
2216
+ flavor: InstallFlavor,
2217
+ platform: z.string(),
2218
+ installedBranch: nullableString,
2219
+ upstream: nullableString,
2220
+ isTreeClean: z.boolean().nullable(),
2221
+ lastCheckAt: timestamp,
2222
+ channel: UpdateChannel,
2223
+ behindCount: z.number().int().nonnegative().nullable(),
2224
+ reason: nullableString,
2225
+ journalSummary: UpdateJournalSummary.nullable(),
2226
+ applyRefusal: UpdateApplyRefusal.nullable()
2227
+ };
2228
+ z.object(updateStatusShape);
2229
+ Object.freeze([
2230
+ "add-session",
2231
+ "list-conversations",
2232
+ "resume-conversation",
2233
+ "remove-session",
2234
+ "rename-session",
2235
+ "set-session-title",
2236
+ "reorder-sessions",
2237
+ "ping",
2238
+ "get-settings",
2239
+ "update-settings",
2240
+ "scan-repo-roots",
2241
+ "list-agents",
2242
+ "get-posthog-report",
2243
+ "posthog-open-session",
2244
+ "request-issues",
2245
+ "open-issue-session",
2246
+ "posthog-issue-action",
2247
+ "team-review-action",
2248
+ "benchmark-action",
2249
+ "my-pr-merge",
2250
+ "my-pr-keep-mergeable",
2251
+ "my-pr-merge-when-ready",
2252
+ "reviews-refresh",
2253
+ "posthog-archive-investigation",
2254
+ "request-usage-report",
2255
+ "request-hooks-report",
2256
+ "save-hook",
2257
+ "delete-hook",
2258
+ "kill",
2259
+ "start-session",
2260
+ "restart",
2261
+ "force-restart",
2262
+ "dismiss",
2263
+ "sleep",
2264
+ "wake",
2265
+ "merge-session",
2266
+ "finish-session",
2267
+ "merge-continue-session",
2268
+ "discard-session-worktree",
2269
+ "resolve-session-merge",
2270
+ "request-session-diff",
2271
+ "request-change-map",
2272
+ "send-diff-annotations",
2273
+ "request-branch-sync",
2274
+ "resync-branch",
2275
+ "debug-state",
2276
+ "session-trace",
2277
+ "session-plan",
2278
+ "plan-decision",
2279
+ "shutdown",
2280
+ "restart-server",
2281
+ "focus-change",
2282
+ "request-health-snapshot",
2283
+ "update-check",
2284
+ "update-apply",
2285
+ "client-error"
2286
+ ]);
2287
+ var ClientErrorReport = z.object({
2288
+ name: z.string().max(128),
2289
+ stack: z.string().max(8192)
2290
+ }).strict();
2291
+ var idOnlyClientTypes = [
2292
+ "remove-session",
2293
+ "kill",
2294
+ "start-session",
2295
+ "restart",
2296
+ "force-restart",
2297
+ "dismiss",
2298
+ "sleep",
2299
+ "wake",
2300
+ "merge-session",
2301
+ "finish-session",
2302
+ "merge-continue-session",
2303
+ "discard-session-worktree",
2304
+ "resolve-session-merge",
2305
+ "request-session-diff",
2306
+ "request-change-map",
2307
+ "request-branch-sync",
2308
+ "resync-branch",
2309
+ "debug-state"
2310
+ ];
2311
+ function idOnlyClientVariant(type) {
2312
+ return loose(type, {
2313
+ id: sessionId,
2314
+ force: z.unknown().optional()
2315
+ });
2316
+ }
2317
+ var idOnlyClientVariants = idOnlyClientTypes.map(idOnlyClientVariant);
2318
+ var clientVariants = [
2319
+ loose("add-session", {
2320
+ name: z.string(),
2321
+ path: z.string(),
2322
+ repos: z.array(z.string()).optional(),
2323
+ agent: z.string().optional(),
2324
+ dangerouslySkipPermissions: z.boolean().optional()
2325
+ }),
2326
+ loose("list-conversations", {
2327
+ id: sessionId,
2328
+ requestId
2329
+ }),
2330
+ loose("resume-conversation", {
2331
+ id: sessionId,
2332
+ conversationId: z.string()
2333
+ }),
2334
+ loose("rename-session", {
2335
+ id: sessionId,
2336
+ newName: z.string()
2337
+ }),
2338
+ loose("set-session-title", {
2339
+ id: sessionId,
2340
+ title: TaskTitle
2341
+ }),
2342
+ loose("reorder-sessions", { order: z.array(sessionId) }),
2343
+ loose("ping", { requestId }),
2344
+ loose("get-settings", { requestId }),
2345
+ loose("update-settings", {
2346
+ settings: z.record(z.string(), z.unknown()),
2347
+ requestId
2348
+ }),
2349
+ loose("scan-repo-roots", { requestId }),
2350
+ loose("list-agents", { requestId }),
2351
+ loose("get-posthog-report", {
2352
+ issueId: z.union([z.string(), z.number()]),
2353
+ requestId
2354
+ }),
2355
+ loose("posthog-open-session", {
2356
+ projectId: z.union([z.string(), z.number()]),
2357
+ issueId: z.union([z.string(), z.number()]),
2358
+ requestId
2359
+ }),
2360
+ loose("request-issues", {
2361
+ requestId,
2362
+ projectId: z.string()
2363
+ }),
2364
+ loose("open-issue-session", {
2365
+ requestId,
2366
+ projectId: z.string(),
2367
+ issueNumber: z.number().int().positive()
2368
+ }),
2369
+ loose("posthog-issue-action", {
2370
+ projectId: z.union([z.string(), z.number()]),
2371
+ issueId: z.union([z.string(), z.number()]),
2372
+ action: z.string(),
2373
+ requestId
2374
+ }),
2375
+ loose("team-review-action", {
2376
+ ...TeamReviewActionRequest.shape,
2377
+ requestId
2378
+ }),
2379
+ loose("benchmark-action", {
2380
+ ...BenchmarkActionRequest.shape,
2381
+ requestId
2382
+ }),
2383
+ loose("my-pr-merge", {
2384
+ ...MyPrMergeRequest.shape,
2385
+ requestId
2386
+ }),
2387
+ loose("my-pr-keep-mergeable", {
2388
+ ...MyPrKeepMergeableRequest.shape,
2389
+ requestId
2390
+ }),
2391
+ loose("my-pr-merge-when-ready", {
2392
+ ...MyPrMergeWhenReadyRequest.shape,
2393
+ requestId
2394
+ }),
2395
+ loose("reviews-refresh", {
2396
+ ...ReviewsRefreshRequest.shape,
2397
+ requestId
2398
+ }),
2399
+ loose("posthog-archive-investigation", {
2400
+ id: z.unknown().optional(),
2401
+ requestId
2402
+ }),
2403
+ loose("request-usage-report", {
2404
+ requestId,
2405
+ days: z.unknown().optional(),
2406
+ force: z.unknown().optional()
2407
+ }),
2408
+ loose("request-hooks-report", { requestId }),
2409
+ loose("send-diff-annotations", {
2410
+ id: sessionId,
2411
+ annotations: z.array(DiffAnnotation).min(1).max(50),
2412
+ requestId
2413
+ }),
2414
+ loose("save-hook", {
2415
+ hook: z.record(z.string(), z.unknown()),
2416
+ requestId
2417
+ }),
2418
+ loose("delete-hook", {
2419
+ id: z.string(),
2420
+ requestId
2421
+ }),
2422
+ loose("shutdown"),
2423
+ loose("restart-server"),
2424
+ loose("focus-change", { focused: z.boolean() }),
2425
+ loose("request-health-snapshot"),
2426
+ loose("update-check"),
2427
+ loose("update-apply", {
2428
+ restartWhenStaged: z.boolean().optional(),
2429
+ confirmedSessionIds: z.array(z.string().min(1)).max(1e3).optional()
2430
+ }),
2431
+ loose("session-trace", {
2432
+ id: sessionId,
2433
+ after: z.number().int().nonnegative().default(0),
2434
+ endingAt: z.union([z.number().int().nonnegative(), z.literal("tail")]).optional()
2435
+ }),
2436
+ loose("session-plan", {
2437
+ id: sessionId,
2438
+ agentId: nullableString,
2439
+ revision: planRevisionNumber.optional(),
2440
+ draft: z.boolean().optional()
2441
+ }),
2442
+ loose("plan-decision", PlanDecision.shape),
2443
+ loose("client-error", ClientErrorReport.shape),
2444
+ ...idOnlyClientVariants
2445
+ ];
2446
+ var ClientMessage = z.discriminatedUnion("type", clientVariants);
2447
+ Object.freeze([
2448
+ "snapshot",
2449
+ "hooks-report",
2450
+ "save-hook-result",
2451
+ "delete-hook-result",
2452
+ "hooks-updated",
2453
+ "state-change",
2454
+ "session-added",
2455
+ "session-removed",
2456
+ "session-renamed",
2457
+ "session-title",
2458
+ "session-modified",
2459
+ "session-git",
2460
+ "session-agents",
2461
+ "session-wakeup",
2462
+ "session-prompt",
2463
+ "session-sleep",
2464
+ "session-wake",
2465
+ "session-merge-status",
2466
+ "session-worktree-blocked",
2467
+ "session-worktree-warning",
2468
+ "session-worktree-ready",
2469
+ "session-diff",
2470
+ "change-map",
2471
+ "send-diff-annotations-result",
2472
+ "branch-sync-status",
2473
+ "session-changed",
2474
+ "post-turn-result",
2475
+ "debug-state-response",
2476
+ "session-trace-response",
2477
+ "session-trace-changed",
2478
+ "session-plan-changed",
2479
+ "session-plan-draft",
2480
+ "session-plan-response",
2481
+ "notify",
2482
+ "update-status",
2483
+ "update-progress",
2484
+ "error",
2485
+ "session-error",
2486
+ "settings",
2487
+ "settings-error",
2488
+ "settings-updated",
2489
+ "pong",
2490
+ "agents-listed",
2491
+ "repo-roots-scanned",
2492
+ "conversations",
2493
+ "resume-conversation-ack",
2494
+ "health-snapshot",
2495
+ "posthog-status",
2496
+ "posthog-investigation-activity",
2497
+ "posthog-investigation-finished",
2498
+ "posthog-report",
2499
+ "posthog-open-session-result",
2500
+ "issues-report",
2501
+ "open-issue-session-result",
2502
+ "posthog-issue-action-result",
2503
+ "team-review-action-result",
2504
+ "benchmark-action-result",
2505
+ "my-pr-merge-result",
2506
+ "my-pr-keep-mergeable-result",
2507
+ "my-pr-merge-when-ready-result",
2508
+ "reviews-refresh-result",
2509
+ "posthog-archive-investigation-result",
2510
+ "team-review-status",
2511
+ "benchmark-status",
2512
+ "my-prs-status",
2513
+ "branch-gc-status",
2514
+ "usage-sessions",
2515
+ "usage-report",
2516
+ "plan-limits",
2517
+ "usage-budget-alert",
2518
+ "visions-findings",
2519
+ "visions-comments",
2520
+ "visions-hand",
2521
+ "visions-intent",
2522
+ "visions-fix",
2523
+ "visions-snapshot",
2524
+ "ingest-activity",
2525
+ "ingest-snapshot",
2526
+ "client-trust",
2527
+ "sessions-reordered",
2528
+ "shutting-down",
2529
+ "restarting"
2530
+ ]);
2531
+ var serverVariants = [
2532
+ loose("snapshot", {
2533
+ sessions: z.array(SessionSnapshot),
2534
+ serverBuild: nullableString
2535
+ }),
2536
+ loose("hooks-report", {
2537
+ requestId,
2538
+ ts: optionalTimestamp,
2539
+ hooks: z.array(opaqueObject).optional(),
2540
+ builtin: z.array(opaqueObject).optional(),
2541
+ events: z.array(openObject({
2542
+ name: z.string(),
2543
+ matcher: nullableString,
2544
+ description: z.string(),
2545
+ http: z.boolean().optional()
2546
+ })).optional(),
2547
+ projects: z.array(openObject({
2548
+ id: z.string(),
2549
+ name: z.string(),
2550
+ agent: z.string()
2551
+ })).optional(),
2552
+ limits: openObject({ maxTimeoutSec: z.number().int().positive() }).optional(),
2553
+ error: optionalError
2554
+ }),
2555
+ loose("save-hook-result", {
2556
+ requestId,
2557
+ ok: z.boolean(),
2558
+ error: optionalError,
2559
+ hook: opaqueObject.optional()
2560
+ }),
2561
+ loose("delete-hook-result", {
2562
+ requestId,
2563
+ ok: z.boolean(),
2564
+ error: optionalError,
2565
+ id: z.string().optional()
2566
+ }),
2567
+ loose("hooks-updated", { count: z.number().int().nonnegative() }),
2568
+ loose("state-change", {
2569
+ id: sessionId,
2570
+ session: z.string(),
2571
+ from: SessionState,
2572
+ to: SessionState,
2573
+ event: z.string(),
2574
+ timestamp,
2575
+ skipPerms: z.boolean().optional(),
2576
+ saneYolo: z.boolean().optional(),
2577
+ hasEndedTurn: z.boolean().optional()
2578
+ }),
2579
+ loose("session-added", SessionCardFields.shape),
2580
+ loose("session-modified", SessionCardFields.shape),
2581
+ loose("session-removed", {
2582
+ id: sessionId,
2583
+ session: z.string()
2584
+ }),
2585
+ loose("session-renamed", {
2586
+ id: sessionId,
2587
+ oldName: z.string(),
2588
+ newName: z.string()
2589
+ }),
2590
+ loose("session-title", {
2591
+ id: sessionId,
2592
+ taskTitle: TaskTitle.nullable(),
2593
+ isCustom: z.boolean()
2594
+ }),
2595
+ loose("session-git", {
2596
+ id: sessionId,
2597
+ worktree: z.boolean()
2598
+ }),
2599
+ loose("session-agents", {
2600
+ id: sessionId,
2601
+ activeAgents: z.number().int().nonnegative(),
2602
+ awaitingBackgroundTasks: z.boolean(),
2603
+ timestamp
2604
+ }),
2605
+ loose("session-wakeup", {
2606
+ id: sessionId,
2607
+ pendingWakeup: PendingWakeup.nullable(),
2608
+ timestamp
2609
+ }),
2610
+ loose("session-prompt", {
2611
+ id: sessionId,
2612
+ pendingPromptKind: nullableString,
2613
+ pendingPromptDetail: PendingPromptDetail.nullable().optional(),
2614
+ timestamp
2615
+ }),
2616
+ loose("session-sleep"),
2617
+ loose("session-wake"),
2618
+ loose("session-merge-status", {
2619
+ id: sessionId,
2620
+ mergeStatus: z.string(),
2621
+ reason: nullableString,
2622
+ parked: z.boolean(),
2623
+ timestamp
2624
+ }),
2625
+ loose("session-worktree-blocked", {
2626
+ id: sessionId,
2627
+ session: z.string(),
2628
+ branch: nullableString,
2629
+ notice: nullableString,
2630
+ timestamp
2631
+ }),
2632
+ loose("session-worktree-warning", {
2633
+ id: sessionId,
2634
+ session: z.string(),
2635
+ branch: nullableString,
2636
+ notice: nullableString,
2637
+ timestamp
2638
+ }),
2639
+ loose("session-worktree-ready", {
2640
+ id: sessionId,
2641
+ session: z.string(),
2642
+ branch: nullableString,
2643
+ base: nullableString,
2644
+ timestamp
2645
+ }),
2646
+ loose("session-diff", {
2647
+ id: sessionId,
2648
+ committed: openObject({
2649
+ stat: z.string(),
2650
+ diff: z.string()
2651
+ }),
2652
+ uncommitted: openObject({
2653
+ stat: z.string(),
2654
+ diff: z.string()
2655
+ }),
2656
+ hasCommits: z.boolean()
2657
+ }),
2658
+ loose("change-map", {
2659
+ id: sessionId,
2660
+ map: ChangeMap
2661
+ }),
2662
+ loose("send-diff-annotations-result", {
2663
+ requestId,
2664
+ ok: z.boolean(),
2665
+ error: optionalError,
2666
+ pending: z.boolean().optional()
2667
+ }),
2668
+ loose("branch-sync-status", {
2669
+ id: sessionId,
2670
+ branch: nullableString,
2671
+ upstream: nullableString,
2672
+ state: z.string(),
2673
+ ahead: z.number().int().nonnegative(),
2674
+ behind: z.number().int().nonnegative(),
2675
+ fetched: z.boolean().nullable(),
2676
+ action: z.string().optional(),
2677
+ error: optionalError
2678
+ }),
2679
+ loose("session-changed", { id: sessionId }),
2680
+ loose("post-turn-result", {
2681
+ id: sessionId,
2682
+ mode: z.string(),
2683
+ skipped: nullableString,
2684
+ filesFixed: z.number().int().nonnegative(),
2685
+ findings: z.array(openObject({
2686
+ file: z.string(),
2687
+ rule: z.string(),
2688
+ count: z.number().int().nonnegative()
2689
+ })),
2690
+ timestamp
2691
+ }),
2692
+ loose("debug-state-response", {
2693
+ id: sessionId,
2694
+ payload: opaqueObject
2695
+ }),
2696
+ loose("session-trace-response", {
2697
+ id: sessionId,
2698
+ records: z.array(TraceRecord),
2699
+ start: z.number().int().nonnegative(),
2700
+ next: z.number().int().nonnegative(),
2701
+ reset: z.boolean(),
2702
+ path: z.string()
2703
+ }),
2704
+ loose("session-trace-changed", { id: sessionId }),
2705
+ loose("session-plan-changed", PlanChangedPush.shape),
2706
+ loose("session-plan-draft", PlanDraftPush.shape),
2707
+ loose("session-plan-response", PlanResponseFrame.shape),
2708
+ loose("notify", {
2709
+ session: z.string(),
2710
+ category: z.string(),
2711
+ message: z.string(),
2712
+ escalationCount: z.number().int().nonnegative(),
2713
+ kind: z.literal("plan").optional()
2714
+ }),
2715
+ loose("update-status", updateStatusShape),
2716
+ loose("update-progress", { journal: UpdateJournal }),
2717
+ loose("error", {
2718
+ id: sessionId.optional(),
2719
+ message: z.string(),
2720
+ requestId,
2721
+ scope: z.string().optional()
2722
+ }),
2723
+ loose("session-error", {
2724
+ id: sessionId.optional(),
2725
+ session: z.string(),
2726
+ message: z.string(),
2727
+ scope: z.string().optional()
2728
+ }),
2729
+ loose("settings", {
2730
+ settings: opaqueObject,
2731
+ requestId
2732
+ }),
2733
+ loose("settings-error", {
2734
+ message: z.string(),
2735
+ requestId
2736
+ }),
2737
+ loose("settings-updated", {
2738
+ settings: opaqueObject,
2739
+ requestId
2740
+ }),
2741
+ loose("pong", { requestId }),
2742
+ loose("agents-listed", {
2743
+ requestId,
2744
+ agents: z.array(openObject({
2745
+ id: z.string(),
2746
+ label: z.string(),
2747
+ resolvable: z.boolean()
2748
+ }))
2749
+ }),
2750
+ loose("repo-roots-scanned", {
2751
+ requestId,
2752
+ directories: z.array(openObject({
2753
+ root: z.string(),
2754
+ projects: z.array(openObject({
2755
+ name: z.string(),
2756
+ path: z.string()
2757
+ }))
2758
+ })),
2759
+ error: z.string().optional()
2760
+ }),
2761
+ loose("conversations", {
2762
+ requestId,
2763
+ id: nullableString,
2764
+ current: nullableString.optional(),
2765
+ conversations: z.array(openObject({
2766
+ id: z.string(),
2767
+ title: z.string(),
2768
+ cwd: z.string(),
2769
+ worktreePath: z.string(),
2770
+ worktreeName: z.string(),
2771
+ gitBranch: nullableString,
2772
+ mtime: timestamp
2773
+ })),
2774
+ error: z.string().optional()
2775
+ }),
2776
+ loose("resume-conversation-ack", {
2777
+ id: sessionId.optional(),
2778
+ resumeSessionId: nullableString.optional(),
2779
+ ok: z.boolean(),
2780
+ error: z.string().optional(),
2781
+ requestId
2782
+ }),
2783
+ loose("health-snapshot", { stats: opaqueObject }),
2784
+ loose("posthog-status", {
2785
+ ts: timestamp,
2786
+ intervalMinutes: z.number(),
2787
+ projects: z.array(opaqueObject),
2788
+ investigations: z.array(opaqueObject)
2789
+ }),
2790
+ loose("posthog-investigation-activity", {
2791
+ projectId: z.union([z.string(), z.number()]),
2792
+ issueId: z.string(),
2793
+ inFlight: z.literal(true),
2794
+ startedAt: timestamp.nullable(),
2795
+ trail: trailSteps
2796
+ }),
2797
+ loose("posthog-investigation-finished", {
2798
+ projectId: z.union([z.string(), z.number()]),
2799
+ issueId: z.string(),
2800
+ verdict: z.string(),
2801
+ summaryLine: nullableString,
2802
+ startedAt: timestamp.nullable(),
2803
+ trail: trailSteps
2804
+ }),
2805
+ loose("posthog-report", {
2806
+ requestId,
2807
+ ok: z.boolean(),
2808
+ found: z.boolean(),
2809
+ issueId: nullableString,
2810
+ format: z.string().optional(),
2811
+ content: z.string().optional(),
2812
+ message: z.string().optional(),
2813
+ error: z.string().optional()
2814
+ }),
2815
+ loose("posthog-open-session-result", {
2816
+ requestId,
2817
+ ok: z.boolean(),
2818
+ error: optionalError,
2819
+ sessionId: z.string().optional(),
2820
+ sessionName: z.string().optional(),
2821
+ pending: z.boolean().optional()
2822
+ }),
2823
+ loose("issues-report", {
2824
+ requestId,
2825
+ ...IssuesReportPush.shape
2826
+ }),
2827
+ loose("open-issue-session-result", {
2828
+ requestId,
2829
+ ok: z.boolean(),
2830
+ error: optionalError,
2831
+ sessionId: z.string().optional(),
2832
+ sessionName: z.string().optional(),
2833
+ pending: z.boolean().optional()
2834
+ }),
2835
+ loose("posthog-issue-action-result", {
2836
+ requestId,
2837
+ ok: z.boolean(),
2838
+ error: optionalError,
2839
+ status: nullableString.optional()
2840
+ }),
2841
+ loose("team-review-action-result", {
2842
+ ...TeamReviewActionResult.shape,
2843
+ requestId
2844
+ }),
2845
+ loose("benchmark-action-result", {
2846
+ ...BenchmarkActionResult.shape,
2847
+ requestId
2848
+ }),
2849
+ loose("my-pr-merge-result", {
2850
+ ...MyPrMergeResult.shape,
2851
+ requestId
2852
+ }),
2853
+ loose("my-pr-keep-mergeable-result", {
2854
+ ...MyPrKeepMergeableResult.shape,
2855
+ requestId
2856
+ }),
2857
+ loose("my-pr-merge-when-ready-result", {
2858
+ ...MyPrMergeWhenReadyResult.shape,
2859
+ requestId
2860
+ }),
2861
+ loose("reviews-refresh-result", {
2862
+ ...ReviewsRefreshResult.shape,
2863
+ requestId
2864
+ }),
2865
+ loose("posthog-archive-investigation-result", {
2866
+ requestId,
2867
+ ok: z.boolean(),
2868
+ error: optionalError
2869
+ }),
2870
+ TeamReviewStatus,
2871
+ BenchmarkStatus,
2872
+ MyPrsStatus,
2873
+ loose("branch-gc-status"),
2874
+ loose("usage-sessions", {
2875
+ ts: timestamp,
2876
+ pricingSource: nullableString,
2877
+ sessions: z.array(openObject({
2878
+ id: sessionId,
2879
+ tokens: z.number(),
2880
+ costUSD: z.number(),
2881
+ officialCostUSD: z.number().nullable().optional()
2882
+ }))
2883
+ }),
2884
+ loose("usage-report", {
2885
+ requestId,
2886
+ ts: optionalTimestamp,
2887
+ tz: z.string().optional(),
2888
+ blockHours: z.number().optional(),
2889
+ totals: opaqueObject.optional(),
2890
+ daily: opaqueArray.optional(),
2891
+ models: opaqueArray.optional(),
2892
+ sessions: opaqueArray.optional(),
2893
+ blocks: opaqueArray.optional(),
2894
+ activeBlock: z.unknown().nullable().optional(),
2895
+ anomaly: z.unknown().nullable().optional(),
2896
+ byLane: z.unknown().optional(),
2897
+ planWindowLanes: z.unknown().nullable().optional(),
2898
+ budget: z.unknown().optional(),
2899
+ savings: z.unknown().optional(),
2900
+ tokenLimit: z.unknown().nullable().optional(),
2901
+ pricing: opaqueObject.optional(),
2902
+ scan: opaqueObject.optional(),
2903
+ warning: optionalError,
2904
+ error: optionalError
2905
+ }),
2906
+ loose("plan-limits", {
2907
+ ts: timestamp,
2908
+ fiveHour: z.unknown().nullable(),
2909
+ sevenDay: z.unknown().nullable(),
2910
+ source: z.string()
2911
+ }),
2912
+ loose("usage-budget-alert", {
2913
+ scope: z.string(),
2914
+ periodKey: z.string(),
2915
+ threshold: z.number(),
2916
+ text: z.string(),
2917
+ ts: timestamp
2918
+ }),
2919
+ loose("visions-findings", {
2920
+ uri: z.string(),
2921
+ diagnostics: opaqueArray,
2922
+ ts: timestamp
2923
+ }),
2924
+ loose("visions-comments", {
2925
+ uri: z.string(),
2926
+ comments: opaqueArray,
2927
+ ts: timestamp
2928
+ }),
2929
+ loose("visions-hand", {
2930
+ uri: z.string(),
2931
+ hand: nullableString,
2932
+ ts: timestamp
2933
+ }),
2934
+ loose("visions-intent", {
2935
+ projectId: nullableString,
2936
+ intent: opaqueObject,
2937
+ ts: timestamp
2938
+ }),
2939
+ loose("visions-fix", {
2940
+ uri: z.string(),
2941
+ fix: opaqueObject,
2942
+ ts: timestamp
2943
+ }),
2944
+ loose("visions-snapshot", {
2945
+ documents: z.array(opaqueObject),
2946
+ intent: opaqueObject,
2947
+ fixes: z.array(opaqueObject),
2948
+ ts: timestamp
2949
+ }),
2950
+ loose("ingest-activity", {
2951
+ events: z.array(opaqueObject),
2952
+ overflow: z.number().int().nonnegative(),
2953
+ ts: timestamp
2954
+ }),
2955
+ loose("ingest-snapshot", {
2956
+ events: z.array(opaqueObject),
2957
+ sources: z.unknown(),
2958
+ ts: timestamp
2959
+ }),
2960
+ loose("client-trust", { trust: z.enum(["local", "remote"]) }),
2961
+ loose("sessions-reordered", { order: z.array(sessionId) }),
2962
+ loose("shutting-down"),
2963
+ loose("restarting")
2964
+ ];
2965
+ z.discriminatedUnion("type", serverVariants);
2966
+ var viewerCols = z.number().int().min(1).max(500);
2967
+ var viewerRows = z.number().int().min(1).max(200);
2968
+ var DataClientMessage = z.discriminatedUnion("type", [
2969
+ z.object({
2970
+ type: z.literal("input"),
2971
+ data: z.string()
2972
+ }),
2973
+ z.object({
2974
+ type: z.literal("claim"),
2975
+ cols: viewerCols,
2976
+ rows: viewerRows
2977
+ }),
2978
+ z.object({ type: z.literal("unview") })
2979
+ ]);
2980
+ z.object({
2981
+ type: z.literal("pty-size"),
2982
+ cols: viewerCols,
2983
+ rows: viewerRows,
2984
+ seq: z.number().int().nonnegative()
2985
+ });
2986
+ function decodeJson(raw) {
2987
+ try {
2988
+ return JSON.parse(raw);
2989
+ } catch {
2990
+ return null;
2991
+ }
2992
+ }
2993
+ function parseDataClientMessage(raw) {
2994
+ const parsed = DataClientMessage.safeParse(decodeJson(raw));
2995
+ if (!parsed.success) return null;
2996
+ return parsed.data;
2997
+ }
2998
+ //#endregion
2999
+ //#region shared/contracts/hooks.ts
3000
+ var HookPayload = z.record(z.string(), z.unknown());
3001
+ var HookEnvelope = z.object({
3002
+ glimmervoidId: z.string().min(1),
3003
+ event: z.string().min(1),
3004
+ token: z.string().nullable().optional(),
3005
+ payload: HookPayload
3006
+ });
3007
+ z.object({
3008
+ id: z.string().min(1),
3009
+ name: z.string().min(1),
3010
+ event: z.string().min(1),
3011
+ matcher: z.string().optional(),
3012
+ type: z.enum(["command", "http"]),
3013
+ command: z.string().optional(),
3014
+ url: z.string().optional(),
3015
+ timeout: z.number().int().positive().optional(),
3016
+ enabled: z.boolean(),
3017
+ projects: z.array(z.string()).optional()
3018
+ }).passthrough();
3019
+ //#endregion
3020
+ export { MyPrKeepMergeableRequest as $, POSTHOG_TRAFFIC_MULTIPLIER_RANGE as $t, MergedPrListing as A, TeamReviewStatus as At, BrowserConfig as B, BRANCH_GC_INTERVAL_MS_RANGE as Bt, BenchmarkCase as C, ReviewThreadId as Ct, BenchmarkStatus as D, TeamReviewCompareFiles as Dt, BenchmarkRun as E, TeamReviewActionRequest as Et, TELEMETRY_EVENT_SCHEMAS as F, decisionAsIfApprovalRequired as Ft, BRANCH_GC_CONTROL_BOOLEAN_KEYS as G, POSTHOG_INTERVAL_RANGE as Gt, ConfigUpdate as H, KEEP_MERGEABLE_TIMEOUT_MINUTES_RANGE as Ht, TELEMETRY_KILL_SWITCH_FLAG as I, hasStandingViewerApproval as It, WorkflowCommentBody as J, POSTHOG_MIN_USERS_RANGE as Jt, BRANCH_GC_CONTROL_NUMERIC_KEYS as K, POSTHOG_INVESTIGATION_TIMEOUT_RANGE as Kt, TelemetryState as L, USAGE_BUDGET_KEYS as Lt, PrCheckoutCaseInput as M, TeamReviewThreadResult as Mt, FeatureFlagsResponse as N, TeamReviewThreadsRepository as Nt, BenchmarkSuite as O, TeamReviewResolveResponse as Ot, PendingCrashReport as P, canApproveAfterComment as Pt, WorkflowsState as Q, POSTHOG_TRAFFIC_MIN_USERS_RANGE as Qt, AGENT_ID_SHAPE_MESSAGE as R, USAGE_COST_MODES as Rt, BenchmarkActionRequest as S, ReviewResult as St, BenchmarkJudgement as T, SearchedPr as Tt, RUNTIME_CONFIG_SCALAR_KEYS as U, POSTHOG_ESCALATION_RANGE as Ut, Config as V, BRANCH_GC_STALE_DAYS_RANGE as Vt, configIssueMessage as W, POSTHOG_FIX_TIMEOUT_RANGE as Wt, WorkflowSearchNode as X, POSTHOG_TRAFFIC_BASELINE_RANGE as Xt, WorkflowLabelName as Y, POSTHOG_RECURRENCE_WINDOW_RANGE as Yt, WorkflowsSettings as Z, POSTHOG_TRAFFIC_COOLDOWN_RANGE as Zt, PlanRevision as _, QueuedReview as _t, DIFF_ANNOTATION_NOTE_MAX_CHARS as a, VISIONS_INTENT_THREAD_TTL_MS_RANGE as an, MyPrSearchResponse as at, ChangeMap as b, ReviewDraft as bt, MAX_RAW_LINE_CHARS as c, MyPrsState as ct, PLAN_BODY_CAP_BYTES as d, DECIDING_REVIEW_STATES as dt, POSTHOG_TRANSIENT_RECURRENCE_RANGE as en, MyPrMergeMethod as et, PLAN_HOOK_EVENT as f, FindingSeverity as ft, PlanDecision as g, PrDetail as gt, PLAN_TOOL_NAME as h, PostingPlan as ht, ClientMessage as i, VISIONS_DISPATCH_TIMEOUT_RANGE as in, MyPrSearchNode as it, MinedPrReviewData as j, TeamReviewThreadCommentsResponse as jt, CommitComparison as k, TeamReviewStateEntry as kt, TraceCheckpoint as l, MyPrsStatus as lt, PLAN_RESULT_HOOK_EVENT as m, GithubReviewState as mt, parseDataClientMessage as n, VISIONS_ACTIVITY_MAX_PER_HOUR_RANGE as nn, MyPrMergeStateResponse as nt, InstallFlavor as o, VISIONS_MAX_PER_HOUR_RANGE as on, MyPrThreadNode as ot, PLAN_HOOK_OUTPUT_MAX_CHARS as p, GithubReviewDecision as pt, BranchGcFileSettings as q, POSTHOG_MAX_CONCURRENT_RANGE as qt, CONTROL_FRAME_MAX_BYTES as r, VISIONS_COOLDOWN_MS_RANGE as rn, MyPrMergeWhenReadyRequest as rt, UpdateJournal as s, VISIONS_QUIET_MS_RANGE as sn, MyPrThreadsResponse as st, HookEnvelope as t, USAGE_INTEGER_RANGES as tn, MyPrMergeRequest as tt, TraceRecord as u, CommitSha as ut, parseExitPlanModeHookPayload as v, ReviewChecksState as vt, BenchmarkId as w, ReviewVerdict as wt, changeMapFactId as x, ReviewFinding as xt, planTitle as y, ReviewComment as yt, BUILTIN_AGENT_IDS as z, USAGE_VENDOR_KEYS as zt };