glimmervoid 0.30.0 → 0.31.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 (66) hide show
  1. package/README.md +1 -1
  2. package/dist/bin/glimmervoid.js +140 -57
  3. package/dist/chunks/{adapters-Dho1VSY5.js → adapters-ClA_GbtA.js} +1 -1
  4. package/dist/chunks/{adapters-zPDx1Xox.js → adapters-gn7ulNO4.js} +32 -12
  5. package/dist/chunks/agent-api-cli-DAA7Jx8N.js +135 -0
  6. package/dist/chunks/{agent-api-core-Dz0r21y9.js → agent-api-core-hVcT26JW.js} +10 -1
  7. package/dist/chunks/{agent-setup-cli-B5Atxr3F.js → agent-setup-cli-CiJSDWSo.js} +11 -28
  8. package/dist/chunks/backoff-DjVpfHk7.js +14 -0
  9. package/dist/chunks/child-process-safe-BKPZ-5qQ.js +2 -0
  10. package/dist/chunks/coerce-NSst8oRP.js +32 -0
  11. package/dist/chunks/{contracts-DGkKNh9W.js → config-W1Sv-iPK.js} +358 -1682
  12. package/dist/chunks/{config-store-mm7MgzoL.js → config-store-BCy4FHNG.js} +583 -327
  13. package/dist/chunks/config-store-DbBp7LJZ.js +2 -0
  14. package/dist/chunks/contracts-3LkrilQX.js +2078 -0
  15. package/dist/chunks/{grok-DuU8xVLZ.js → grok-CXKeSt2z.js} +24 -20
  16. package/dist/chunks/{hook-relay-core-BHfYFnYV.js → hook-relay-core-DA_bz2KA.js} +10 -5
  17. package/dist/chunks/{hook-tools-pSJia7ks.js → hook-tools-UX2fmt81.js} +3 -5
  18. package/dist/chunks/{ingest-editor-core-BuI1gMF_.js → ingest-editor-core-vR6Wv6bP.js} +24 -13
  19. package/dist/chunks/json-core-dfa_7Fak.js +23 -0
  20. package/dist/chunks/json-file-oEH9vt-0.js +352 -0
  21. package/dist/chunks/knowledge-graph-cli-D2tt5hPn.js +1354 -0
  22. package/dist/chunks/{loopback-post-C7C22eYi.js → loopback-post-DepQfdcM.js} +40 -26
  23. package/dist/chunks/{main-CuIZQPhZ.js → main-DyTCWIu2.js} +28498 -21129
  24. package/dist/chunks/{node-pty-preflight-CK1knGIR.js → node-pty-preflight-C8QIlrtU.js} +4 -6
  25. package/dist/chunks/{pair-cli-w-gCAF-1.js → pair-cli-BbCBfd6l.js} +4 -3
  26. package/dist/chunks/paths-CeJl2Vcg.js +55 -0
  27. package/dist/chunks/{remote-config-C2ytQwrs.js → remote-config-DKIH_VxM.js} +36 -40
  28. package/dist/chunks/{rtk-hook-core-Bl6gYHPN.js → rtk-hook-core-BmEz2aq9.js} +3 -5
  29. package/dist/chunks/{rtk-resolver-CLo-gZzw.js → rtk-resolver-BGDzw5XK.js} +2 -2
  30. package/dist/chunks/rtk-resolver-D4Nke1Fr.js +2 -0
  31. package/dist/chunks/{runtime-paths-Ci_ksSkj.js → runtime-paths-BPoxENmK.js} +2 -6
  32. package/dist/chunks/runtime-paths-DU5jBEEO.js +2 -0
  33. package/dist/chunks/{sandbox-deps-Dd5-kZnf.js → sandbox-deps-BPKE-ylr.js} +16 -13
  34. package/dist/chunks/sandbox-proxy-core-hnQgKR0T.js +27 -0
  35. package/dist/chunks/{session-Cez8aIWg.js → session-fc4pFbon.js} +8 -2
  36. package/dist/chunks/text-DoirglWV.js +21 -0
  37. package/dist/chunks/timer-deps-u2DAQLok.js +15 -0
  38. package/dist/chunks/{visions-cli-BXQFIBCX.js → visions-cli-CT5rjiwf.js} +1 -1
  39. package/dist/chunks/{visions-setup-CvVnOe1r.js → visions-setup-BmOkI-QE.js} +20 -357
  40. package/dist/client/assets/index-C6KD8lgZ.css +1 -0
  41. package/dist/client/assets/index-CThQEAEy.js +249 -0
  42. package/dist/client/fonts/CommitMono-OFL.txt +92 -0
  43. package/dist/client/fonts/commit-mono-400-italic.woff2 +0 -0
  44. package/dist/client/fonts/commit-mono-400-regular.woff2 +0 -0
  45. package/dist/client/fonts/commit-mono-700-italic.woff2 +0 -0
  46. package/dist/client/fonts/commit-mono-700-regular.woff2 +0 -0
  47. package/dist/client/index.html +7 -24
  48. package/dist/client/octicons-LICENSE.txt +21 -0
  49. package/dist/scripts/postinstall-path-check.js +1 -1
  50. package/dist/server/index.js +3 -3
  51. package/dist/session/command-hook-relay.js +1 -1
  52. package/dist/session/hook-relay.js +3 -3
  53. package/dist/session/hook-tool-relay.js +2 -2
  54. package/dist/session/sandbox-open-launcher.js +79 -0
  55. package/dist/session/statusline-relay.js +8 -18
  56. package/dist/session/visions-relay.js +20 -11
  57. package/package.json +4 -1
  58. package/dist/chunks/agent-api-cli-D0MmtEdz.js +0 -71
  59. package/dist/chunks/child-process-safe-DvQjXsgz.js +0 -2
  60. package/dist/chunks/config-store-CC8T3okC.js +0 -2
  61. package/dist/chunks/ingest-core-DWI1Mbu4.js +0 -342
  62. package/dist/chunks/rtk-resolver-CMQAidlI.js +0 -2
  63. package/dist/chunks/runtime-paths-JLrZ3wyi.js +0 -2
  64. package/dist/client/assets/index-B1MFijjb.css +0 -1
  65. package/dist/client/assets/index-CU1iPPdn.js +0 -249
  66. package/dist/chunks/{child-process-safe-DRGsp0TE.js → child-process-safe-Ch-Zgxqs.js} +1 -1
@@ -1,7 +1,153 @@
1
- import { d as SessionSnapshot, f as SessionState, l as PendingWakeup, m as TaskTitle, s as PendingPromptDetail } from "./session-Cez8aIWg.js";
1
+ import { h as TaskTitle } from "./session-fc4pFbon.js";
2
+ import { n as isRecord } from "./coerce-NSst8oRP.js";
2
3
  import path from "node:path";
3
4
  import { z } from "zod";
5
+ //#region shared/contracts/coherence.ts
6
+ var CoherenceRisk = z.enum([
7
+ "low",
8
+ "medium",
9
+ "high",
10
+ "critical"
11
+ ]);
12
+ var CoherenceWorkState = z.enum([
13
+ "open",
14
+ "active",
15
+ "blocked",
16
+ "completed",
17
+ "cancelled"
18
+ ]);
19
+ var CoherenceReadiness = z.enum([
20
+ "ready",
21
+ "waiting",
22
+ "active",
23
+ "blocked",
24
+ "done"
25
+ ]);
26
+ var CoherenceWorkStats = z.looseObject({
27
+ total: z.number().int().nonnegative(),
28
+ roots: z.number().int().nonnegative(),
29
+ dependencies: z.number().int().nonnegative(),
30
+ states: z.looseObject({
31
+ open: z.number().int().nonnegative(),
32
+ active: z.number().int().nonnegative(),
33
+ blocked: z.number().int().nonnegative(),
34
+ completed: z.number().int().nonnegative(),
35
+ cancelled: z.number().int().nonnegative()
36
+ }),
37
+ readiness: z.looseObject({
38
+ ready: z.number().int().nonnegative(),
39
+ waiting: z.number().int().nonnegative(),
40
+ active: z.number().int().nonnegative(),
41
+ blocked: z.number().int().nonnegative(),
42
+ done: z.number().int().nonnegative()
43
+ }),
44
+ risks: z.looseObject({
45
+ low: z.number().int().nonnegative(),
46
+ medium: z.number().int().nonnegative(),
47
+ high: z.number().int().nonnegative(),
48
+ critical: z.number().int().nonnegative()
49
+ }),
50
+ graphProblems: z.number().int().nonnegative(),
51
+ scopeOverlaps: z.number().int().nonnegative(),
52
+ scopeConflicts: z.number().int().nonnegative(),
53
+ orphans: z.number().int().nonnegative(),
54
+ unsynthesizedChildren: z.number().int().nonnegative()
55
+ });
56
+ var CoherenceOrient = z.looseObject({
57
+ action: z.enum([
58
+ "steady",
59
+ "dispatch",
60
+ "continue",
61
+ "verify",
62
+ "synthesize",
63
+ "unblock",
64
+ "resolve-conflict",
65
+ "repair-navigation",
66
+ "refuse"
67
+ ]),
68
+ reasons: z.array(z.string()),
69
+ sources: z.array(z.looseObject({
70
+ name: z.string(),
71
+ ok: z.boolean(),
72
+ detail: z.string()
73
+ })),
74
+ work: z.looseObject({
75
+ stats: CoherenceWorkStats,
76
+ ready: z.array(z.string()),
77
+ active: z.array(z.string()),
78
+ blocked: z.array(z.string()),
79
+ completed: z.array(z.string()),
80
+ conflicts: z.array(z.looseObject({
81
+ left: z.string(),
82
+ right: z.string(),
83
+ scope: z.string()
84
+ })),
85
+ unsynthesized: z.array(z.unknown())
86
+ }).nullable(),
87
+ consequences: z.looseObject({ unverifiedCompletedWork: z.array(z.string()) }),
88
+ verification: z.looseObject({ state: z.string() })
89
+ });
90
+ var CoherenceWorkInspect = z.looseObject({
91
+ work: z.array(z.looseObject({
92
+ work: z.string(),
93
+ state: CoherenceWorkState,
94
+ readiness: CoherenceReadiness,
95
+ owner: z.looseObject({
96
+ session: z.string(),
97
+ agent: z.string()
98
+ }),
99
+ last: z.looseObject({
100
+ event: z.string(),
101
+ at: z.string(),
102
+ session: z.string()
103
+ }).nullable(),
104
+ opened: z.looseObject({
105
+ at: z.iso.datetime(),
106
+ objective: z.string(),
107
+ authority: z.looseObject({ boundary: z.string() }),
108
+ criteria: z.array(z.string()),
109
+ risk: CoherenceRisk,
110
+ parent: z.string().nullable(),
111
+ dependsOn: z.array(z.string()),
112
+ readScopes: z.array(z.string()),
113
+ writeScopes: z.array(z.string())
114
+ })
115
+ })),
116
+ scopeConflicts: z.array(z.looseObject({
117
+ left: z.string(),
118
+ right: z.string(),
119
+ leftScope: z.string(),
120
+ rightScope: z.string(),
121
+ status: z.string()
122
+ }))
123
+ });
124
+ var CoherenceWorkCreated = z.looseObject({
125
+ version: z.literal(1),
126
+ event: z.literal("opened"),
127
+ at: z.iso.datetime(),
128
+ session: z.literal("glimmervoid-factory"),
129
+ work: z.string().regex(/^wrk-[a-f0-9]{16}$/),
130
+ id: z.string().regex(/^wev-[a-f0-9]{16}$/),
131
+ parent: z.null(),
132
+ objective: z.string(),
133
+ criteria: z.array(z.string()),
134
+ risk: CoherenceRisk,
135
+ state: z.literal("open"),
136
+ authority: z.object({
137
+ kind: z.literal("user-directed"),
138
+ grantedBy: z.literal("operator"),
139
+ boundary: z.string()
140
+ }),
141
+ writeScopes: z.array(z.string())
142
+ });
143
+ var CoherenceTicketCreated = CoherenceWorkCreated.extend({ parent: z.string().regex(/^wrk-[a-f0-9]{16}$/) });
144
+ //#endregion
4
145
  //#region shared/settings-ranges.ts
146
+ var FACTORY_WATCH_WINDOW_RANGE = Object.freeze({
147
+ min: 1,
148
+ max: 1440
149
+ });
150
+ var FACTORY_MAX_LIVE_WORKERS_RANGE = Object.freeze({ min: 1 });
5
151
  var POSITIVE_NUMBER_RANGE = Object.freeze({
6
152
  min: 0,
7
153
  exclusiveMin: true,
@@ -101,6 +247,9 @@ var WORKFLOWS_MAX_ACTIONS_PER_POLL_RANGE = Object.freeze({
101
247
  max: 50
102
248
  });
103
249
  Object.freeze({
250
+ NON_NEGATIVE_NUMBER_RANGE,
251
+ FACTORY_MAX_LIVE_WORKERS_RANGE,
252
+ FACTORY_WATCH_WINDOW_RANGE,
104
253
  FLYING_ANIMALS_GAP_RANGE,
105
254
  FLYING_ANIMALS_DURATION_RANGE,
106
255
  FLYING_ANIMALS_SCALE_RANGE,
@@ -130,6 +279,97 @@ Object.freeze({
130
279
  WORKFLOWS_MAX_CONCURRENT_SESSIONS_RANGE
131
280
  });
132
281
  //#endregion
282
+ //#region shared/contracts/config-numbers-core.ts
283
+ var POSTHOG_WHOLE_NUMBER_ROUNDING = {
284
+ maxConcurrentInvestigations: Math.ceil,
285
+ minUsersToInvestigate: Math.ceil,
286
+ userEscalationThreshold: Math.ceil,
287
+ trafficSpikeMinUsers: Math.ceil,
288
+ trafficSpikeBaselineDays: Math.floor
289
+ };
290
+ var LEGACY_INTEGER_FIELDS = [
291
+ {
292
+ path: [
293
+ "visions",
294
+ "dispatch",
295
+ "quietMs"
296
+ ],
297
+ min: 1,
298
+ round: Math.floor
299
+ },
300
+ {
301
+ path: [
302
+ "visions",
303
+ "dispatch",
304
+ "cooldownMs"
305
+ ],
306
+ min: 1,
307
+ round: Math.floor
308
+ },
309
+ {
310
+ path: [
311
+ "visions",
312
+ "dispatch",
313
+ "maxPerHour"
314
+ ],
315
+ min: 1,
316
+ round: Math.floor
317
+ },
318
+ {
319
+ path: [
320
+ "visions",
321
+ "dispatch",
322
+ "activityMaxPerHour"
323
+ ],
324
+ min: 0,
325
+ round: Math.floor
326
+ },
327
+ {
328
+ path: [
329
+ "visions",
330
+ "dispatch",
331
+ "dispatchTimeoutSeconds"
332
+ ],
333
+ min: 1,
334
+ round: Math.floor
335
+ },
336
+ {
337
+ path: [
338
+ "visions",
339
+ "intent",
340
+ "threadTtlMs"
341
+ ],
342
+ min: 1,
343
+ round: Math.floor
344
+ },
345
+ ...Object.entries(POSTHOG_WHOLE_NUMBER_ROUNDING).map(([key, round]) => ({
346
+ path: ["posthog", key],
347
+ min: 1,
348
+ round
349
+ }))
350
+ ];
351
+ function normalizeIntegerField(config, path, min, round) {
352
+ let target = config;
353
+ for (const segment of path.slice(0, -1)) {
354
+ const block = target[segment];
355
+ if (!isRecord(block)) return;
356
+ target[segment] = { ...block };
357
+ target = target[segment];
358
+ }
359
+ const key = path.at(-1);
360
+ const value = target[key];
361
+ if (typeof value !== "number" || !Number.isFinite(value) || value < 0) return;
362
+ if (Number.isInteger(value)) return;
363
+ target[key] = Math.min(Number.MAX_SAFE_INTEGER, Math.max(min, round(value)));
364
+ }
365
+ function normalizeLegacyConfigNumbers(candidate) {
366
+ const normalized = { ...candidate };
367
+ const replayBufferKB = candidate.replayBufferKB;
368
+ if (typeof replayBufferKB === "number" && Number.isFinite(replayBufferKB) && replayBufferKB >= 0 && replayBufferKB <= REPLAY_BUFFER_KB_RANGE.max) normalized.replayBufferKB = Math.max(REPLAY_BUFFER_KB_RANGE.min, Math.floor(replayBufferKB));
369
+ for (const { path, min, round } of LEGACY_INTEGER_FIELDS) normalizeIntegerField(normalized, path, min, round);
370
+ return normalized;
371
+ }
372
+ //#endregion
133
373
  //#region shared/usage-config.ts
134
374
  var USAGE_COST_MODES = Object.freeze([
135
375
  "auto",
@@ -151,15 +391,38 @@ var reviewsPollingShape = {
151
391
  isRefreshing: z.boolean().optional(),
152
392
  refreshNotice: z.string().nullable().optional()
153
393
  };
154
- var ReviewsRefreshRequest = z.object({ lane: z.enum(["my-prs", "team-review"]) });
394
+ var ReviewsRefreshRequest = z.object({ lane: z.enum([
395
+ "my-prs",
396
+ "team-review",
397
+ "issues"
398
+ ]) });
155
399
  var ReviewsRefreshResult = z.object({
156
400
  ok: z.boolean(),
157
401
  error: z.string().optional()
158
402
  });
159
403
  //#endregion
404
+ //#region shared/contracts/github-ids.ts
405
+ var GH_SEGMENT = /^[A-Za-z0-9][A-Za-z0-9._-]*$/;
406
+ var REPO_SLUG_RE = /^[A-Za-z0-9][A-Za-z0-9._-]*\/[A-Za-z0-9][A-Za-z0-9._-]*$/;
407
+ var NODE_ID_RE = /^[A-Za-z0-9_=-]+$/;
408
+ function repoParts(repo) {
409
+ const parts = repo.split("/");
410
+ if (parts.length !== 2 || !parts.every((part) => GH_SEGMENT.test(part))) return null;
411
+ return [parts[0], parts[1]];
412
+ }
413
+ var HEX_SHA_RE = /^[0-9a-f]{7,40}$/i;
414
+ var FULL_SHA_RE = /^[0-9a-f]{40}$/;
415
+ function shortSha(sha, { chars = 7, validate = false } = {}) {
416
+ if (typeof sha !== "string" || !sha) return "";
417
+ if (!validate) return sha.slice(0, chars);
418
+ const text = sha.trim();
419
+ if (!HEX_SHA_RE.test(text)) return "";
420
+ return text.slice(0, chars).toLowerCase();
421
+ }
422
+ //#endregion
160
423
  //#region shared/contracts/team-review.ts
161
- var CommitSha = z.string().regex(/^[0-9a-f]{40}$/);
162
- var repoSlug$1 = z.string().regex(/^[^/]+\/[^/]+$/);
424
+ var CommitSha = z.string().regex(FULL_SHA_RE);
425
+ var repoSlug = z.string().regex(/^[^/]+\/[^/]+$/);
163
426
  var SearchedPr = z.object({
164
427
  number: z.number().int().positive(),
165
428
  title: z.string(),
@@ -311,7 +574,7 @@ var PriorReview = z.object({
311
574
  comments: z.array(ReviewComment),
312
575
  wasPosted: z.boolean()
313
576
  });
314
- var ReviewThreadId = z.string().min(1).max(256).regex(/^[A-Za-z0-9_=-]+$/);
577
+ var ReviewThreadId = z.string().min(1).max(256).regex(NODE_ID_RE);
315
578
  var TeamReviewThreadResult = z.object({
316
579
  addressed: z.boolean(),
317
580
  reason: z.string().trim().min(1).max(4e3)
@@ -399,7 +662,7 @@ var ViewerThreadTally = z.object({
399
662
  var ReviewDraft = z.object({
400
663
  ...reviewPriorityShape,
401
664
  key: z.string(),
402
- repo: repoSlug$1,
665
+ repo: repoSlug,
403
666
  number: z.number().int().positive(),
404
667
  title: z.string(),
405
668
  url: z.string(),
@@ -473,7 +736,7 @@ var QueuedReview = z.object({
473
736
  ...reviewPriorityShape,
474
737
  reviewDecision: GithubReviewDecision.nullable().optional(),
475
738
  key: z.string(),
476
- repo: repoSlug$1,
739
+ repo: repoSlug,
477
740
  number: z.number().int().positive(),
478
741
  title: z.string(),
479
742
  url: z.string(),
@@ -515,7 +778,7 @@ var InFlightReview = z.object({
515
778
  ...reviewPriorityShape,
516
779
  reviewDecision: GithubReviewDecision.nullable().optional(),
517
780
  key: z.string(),
518
- repo: repoSlug$1,
781
+ repo: repoSlug,
519
782
  number: z.number().int().positive(),
520
783
  title: z.string(),
521
784
  url: z.string(),
@@ -564,7 +827,7 @@ var MyPrStage = z.enum([
564
827
  "unknown"
565
828
  ]);
566
829
  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._-]*$/);
830
+ var repositoryName = z.string().regex(REPO_SLUG_RE);
568
831
  var pullRequestNumberText = z.string().regex(/^[1-9][0-9]*$/);
569
832
  var pullRequestKeyFormat = z.templateLiteral([
570
833
  repositoryName,
@@ -601,7 +864,8 @@ var MyPrKeepMergeableAttempt = z.strictObject({
601
864
  var MyPrKeepMergeableAttemptRecord = MyPrKeepMergeableAttempt.extend({
602
865
  key: pullRequestKey,
603
866
  headRefOid: CommitSha,
604
- baseRefOid: CommitSha
867
+ baseRefOid: CommitSha,
868
+ consecutiveAttempts: z.number().int().min(1).optional()
605
869
  });
606
870
  var MyPrsState = z.strictObject({
607
871
  keepMergeableKeys: z.array(pullRequestKey),
@@ -757,7 +1021,7 @@ var StatusContext = z.object({
757
1021
  });
758
1022
  var MyPrSearchNode = z.object({
759
1023
  __typename: z.literal("PullRequest"),
760
- id: z.string().regex(/^[A-Za-z0-9_=-]+$/),
1024
+ id: z.string().regex(NODE_ID_RE),
761
1025
  number: z.number().int().positive(),
762
1026
  title: z.string(),
763
1027
  url: z.url(),
@@ -895,7 +1159,6 @@ var WORKFLOW_ACTION_TYPES = Object.freeze([
895
1159
  var WORKFLOW_PROMPT_TEMPLATE_MAX_CHARACTERS = 2e4;
896
1160
  var WORKFLOW_COMMENT_BODY_MAX_CHARACTERS = 65536;
897
1161
  var RULE_ID = /^[a-z0-9][a-z0-9-]{0,63}$/;
898
- var GITHUB_LOGIN = /^[A-Za-z0-9][A-Za-z0-9._-]*$/;
899
1162
  var UNSAFE_LABEL_NAME = /[\x00-\x1f\x7f,]|^-/;
900
1163
  var integerInRange = (field, range) => {
901
1164
  const message = `${field} must be an integer between ${range.min} and ${range.max}`;
@@ -926,7 +1189,7 @@ var WorkflowAction = z.discriminatedUnion("type", [
926
1189
  var WorkflowFilters = z.strictObject({
927
1190
  mine: z.boolean({ error: "workflows.rules[].filters.mine must be a boolean" }).optional(),
928
1191
  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(),
1192
+ authors: nonEmptyList("workflows.rules[].filters.authors", z.string({ error: "workflows.rules[].filters.authors must hold GitHub logins" }).regex(GH_SEGMENT, { error: "workflows.rules[].filters.authors must hold GitHub logins" })).optional(),
930
1193
  labels: nonEmptyList("workflows.rules[].filters.labels", WorkflowLabelName).optional(),
931
1194
  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
1195
  }, { error: "workflows.rules[].filters must be an object" });
@@ -1034,10 +1297,13 @@ var numberRangeLabel = (range) => {
1034
1297
  return `at least ${range.min}`;
1035
1298
  };
1036
1299
  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();
1300
+ var optionalWholeNumber = (field, range) => optionalNumber(field, range).unwrap().int({ error: `${field} must be a whole number ${numberRangeLabel(range)}` }).optional();
1037
1301
  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
1302
  var optionalObject = (field, shape) => z.object(shape, { error: `${field} must be an object` }).nullable().optional();
1039
1303
  var optionalLooseObject = (field) => z.object({}, { error: `${field} must be an object` }).passthrough().nullable().optional();
1040
1304
  var CHANGE_MAP_NARRATOR_ENGINES = Object.freeze(["claude", "codex"]);
1305
+ var UPDATE_CHANNELS = Object.freeze(["release", "main"]);
1306
+ var POST_TURN_CHECK_MODES = Object.freeze(["report", "fix"]);
1041
1307
  var ChangeMapSettings = optionalObject("changeMap", { narrator: optionalObject("changeMap.narrator", {
1042
1308
  enabled: optionalBoolean("changeMap.narrator.enabled"),
1043
1309
  engine: z.enum(CHANGE_MAP_NARRATOR_ENGINES, { error: `changeMap.narrator.engine must be one of ${CHANGE_MAP_NARRATOR_ENGINES.join(", ")}` }).optional(),
@@ -1072,7 +1338,7 @@ var BranchGcControlSettings = BranchGcFileSettings.omit({
1072
1338
  }).nullable().optional();
1073
1339
  var BRANCH_GC_CONTROL_BOOLEAN_KEYS = Object.freeze(["enabled", "deleteUnmerged"]);
1074
1340
  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() });
1341
+ var PostTurnChecksSettings = optionalObject("postTurnChecks", { mode: z.enum(POST_TURN_CHECK_MODES, { error: "postTurnChecks.mode must be one of report, fix" }).optional() });
1076
1342
  var VisionsSettings = optionalObject("visions", {
1077
1343
  enabled: optionalBoolean("visions.enabled"),
1078
1344
  autoFix: optionalBoolean("visions.autoFix"),
@@ -1080,14 +1346,15 @@ var VisionsSettings = optionalObject("visions", {
1080
1346
  dispatch: optionalObject("visions.dispatch", {
1081
1347
  enabled: optionalBoolean("visions.dispatch.enabled"),
1082
1348
  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)
1349
+ quietMs: optionalWholeNumber("visions.dispatch.quietMs", VISIONS_QUIET_MS_RANGE),
1350
+ cooldownMs: optionalWholeNumber("visions.dispatch.cooldownMs", VISIONS_COOLDOWN_MS_RANGE),
1351
+ maxPerHour: optionalWholeNumber("visions.dispatch.maxPerHour", VISIONS_MAX_PER_HOUR_RANGE),
1352
+ activityMaxPerHour: optionalWholeNumber("visions.dispatch.activityMaxPerHour", VISIONS_ACTIVITY_MAX_PER_HOUR_RANGE),
1353
+ dispatchTimeoutSeconds: optionalWholeNumber("visions.dispatch.dispatchTimeoutSeconds", VISIONS_DISPATCH_TIMEOUT_RANGE)
1088
1354
  }),
1089
- intent: optionalObject("visions.intent", { threadTtlMs: optionalNumber("visions.intent.threadTtlMs", VISIONS_INTENT_THREAD_TTL_MS_RANGE) })
1355
+ intent: optionalObject("visions.intent", { threadTtlMs: optionalWholeNumber("visions.intent.threadTtlMs", VISIONS_INTENT_THREAD_TTL_MS_RANGE) })
1090
1356
  });
1357
+ var GithubSettings = z.object({ teams: z.array(z.string({ error: "github.teams must be an array of org/slug strings" }).refine((team) => repoParts(team) !== null, { message: "github.teams entries must be org/slug with valid GitHub segments" }), { error: "github.teams must be an array of org/slug strings" }).optional() }, { error: "github must be an object" }).nullable().optional();
1091
1358
  var TeamReviewSettings = optionalObject("teamReview", {
1092
1359
  enabled: optionalBoolean("teamReview.enabled"),
1093
1360
  autoRebaseMyPrs: optionalBoolean("teamReview.autoRebaseMyPrs"),
@@ -1101,6 +1368,38 @@ var TeamReviewSettings = optionalObject("teamReview", {
1101
1368
  skipIdleAfterDays: optionalNumber("teamReview.skipIdleAfterDays")
1102
1369
  });
1103
1370
  var BenchmarksSettings = optionalObject("benchmarks", { enabled: optionalBoolean("benchmarks.enabled") });
1371
+ var DEFAULT_FACTORY_CHECKS = [
1372
+ "npm run typecheck",
1373
+ "npm run lint",
1374
+ "npm test"
1375
+ ];
1376
+ var DEFAULT_FACTORY_PROTECTED_PATHS = [
1377
+ "coherence.config.json",
1378
+ ".coherence/",
1379
+ "package.json",
1380
+ "package-lock.json",
1381
+ "**/AGENTS.md",
1382
+ "**/CLAUDE.md",
1383
+ "**/CLAUDE.local.md",
1384
+ ".claude/",
1385
+ ".github/"
1386
+ ];
1387
+ var FactorySettings = z.object({
1388
+ enabled: optionalBoolean("factory.enabled"),
1389
+ maxRisk: CoherenceRisk.optional(),
1390
+ maxLiveWorkers: z.number().int().min(FACTORY_MAX_LIVE_WORKERS_RANGE.min).optional(),
1391
+ checks: z.array(z.string().trim().min(1)).optional(),
1392
+ protectedPaths: z.array(z.string().trim().min(1)).optional(),
1393
+ reviewerModel: z.string().trim().min(1).nullable().optional(),
1394
+ watchWindowMinutes: z.number().int().min(FACTORY_WATCH_WINDOW_RANGE.min).max(FACTORY_WATCH_WINDOW_RANGE.max).optional(),
1395
+ watchProjects: z.array(z.object({
1396
+ project: z.string().trim().min(1),
1397
+ posthogProjectId: z.number().int().positive()
1398
+ })).optional(),
1399
+ dailyBudgetUsd: z.number().finite().nonnegative().nullable().optional(),
1400
+ verifierModel: z.string().trim().min(1).nullable().optional()
1401
+ }).nullable().optional();
1402
+ var KnowledgeGraphSettings = optionalObject("knowledgeGraph", { enabled: optionalBoolean("knowledgeGraph.enabled") });
1104
1403
  var posthogNumberRanges = {
1105
1404
  intervalMinutes: POSTHOG_INTERVAL_RANGE,
1106
1405
  maxConcurrentInvestigations: POSTHOG_MAX_CONCURRENT_RANGE,
@@ -1125,7 +1424,7 @@ var PosthogSettings = optionalObject("posthog", {
1125
1424
  repoPath: optionalString("posthog.repoPath", true),
1126
1425
  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
1426
  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)]))
1427
+ ...Object.fromEntries(Object.entries(posthogNumberRanges).map(([key, range]) => [key, Object.hasOwn(POSTHOG_WHOLE_NUMBER_ROUNDING, key) ? optionalWholeNumber(`posthog.${key}`, range) : optionalNumber(`posthog.${key}`, range)]))
1129
1428
  });
1130
1429
  var usageCostModeMessage = `usage.costMode must be one of ${USAGE_COST_MODES.join(", ")}`;
1131
1430
  var usageVendorShape = Object.fromEntries(USAGE_VENDOR_KEYS.map((key) => [key, optionalBoolean(`usage.vendors.${key}`)]));
@@ -1164,10 +1463,7 @@ var createBrowserConfigShape = (isAbsolutePath) => ({
1164
1463
  promptDetectionMs: z.number().finite().nonnegative().optional(),
1165
1464
  notifyDebounceMs: z.number().finite().nonnegative().optional(),
1166
1465
  phoneEscalationMs: z.number().finite().nonnegative().optional(),
1167
- replayBufferKB: optionalNumber("replayBufferKB", {
1168
- ...REPLAY_BUFFER_KB_RANGE,
1169
- min: 0
1170
- }),
1466
+ replayBufferKB: optionalWholeNumber("replayBufferKB", REPLAY_BUFFER_KB_RANGE),
1171
1467
  cursorBlink: optionalBoolean("cursorBlink"),
1172
1468
  debugMode: optionalBoolean("debugMode"),
1173
1469
  calmLayout: optionalBoolean("calmLayout"),
@@ -1178,7 +1474,7 @@ var createBrowserConfigShape = (isAbsolutePath) => ({
1178
1474
  saneYolo: optionalBoolean("saneYolo"),
1179
1475
  skipPermissionsByDefault: optionalBoolean("skipPermissionsByDefault"),
1180
1476
  checkForUpdates: optionalBoolean("checkForUpdates"),
1181
- updateChannel: z.enum(["release", "main"], { error: "updateChannel must be one of release, main" }).optional(),
1477
+ updateChannel: z.enum(UPDATE_CHANNELS, { error: "updateChannel must be one of release, main" }).optional(),
1182
1478
  autoResume: optionalBoolean("autoResume"),
1183
1479
  telegramNotifications: optionalBoolean("telegramNotifications"),
1184
1480
  integrationBranch: optionalString("integrationBranch").nullable(),
@@ -1190,8 +1486,11 @@ var createBrowserConfigShape = (isAbsolutePath) => ({
1190
1486
  branchGc: BranchGcSettings,
1191
1487
  postTurnChecks: PostTurnChecksSettings,
1192
1488
  visions: VisionsSettings,
1489
+ github: GithubSettings,
1193
1490
  teamReview: TeamReviewSettings,
1194
1491
  benchmarks: BenchmarksSettings,
1492
+ factory: FactorySettings,
1493
+ knowledgeGraph: KnowledgeGraphSettings,
1195
1494
  posthog: PosthogSettings,
1196
1495
  usage: createUsageSettings(isAbsolutePath),
1197
1496
  telegram: TelegramSettings,
@@ -1212,7 +1511,6 @@ var ConfigUpdate = z.object({
1212
1511
  promptDetectionMs: z.number({ error: "promptDetectionMs must be a positive number" }).finite().positive({ error: "promptDetectionMs must be a positive number" }).optional(),
1213
1512
  notifyDebounceMs: z.number({ error: "notifyDebounceMs must be a positive number" }).finite().positive({ error: "notifyDebounceMs must be a positive number" }).optional(),
1214
1513
  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
1514
  branchGc: BranchGcControlSettings,
1217
1515
  worktreeAutoRebase: optionalBoolean("worktreeAutoRebase"),
1218
1516
  worktreeSyncOnStart: optionalBoolean("worktreeSyncOnStart"),
@@ -1259,10 +1557,36 @@ var CustomAgentDeclarations = z.array(CustomAgentDeclaration, { error: "customAg
1259
1557
  });
1260
1558
  }
1261
1559
  });
1560
+ var TaskTitleSources = z.object({
1561
+ customTitle: TaskTitle.nullable().optional(),
1562
+ pendingPromptTitle: TaskTitle.nullable().optional(),
1563
+ refinedTitle: TaskTitle.nullable().optional(),
1564
+ aiTitle: TaskTitle.nullable().optional(),
1565
+ oscTitle: TaskTitle.nullable().optional(),
1566
+ promptTitle: TaskTitle.nullable().optional()
1567
+ }).strict();
1568
+ var TASK_TITLE_SOURCE_PRIORITY = [
1569
+ "customTitle",
1570
+ "pendingPromptTitle",
1571
+ "refinedTitle",
1572
+ "aiTitle",
1573
+ "oscTitle",
1574
+ "promptTitle"
1575
+ ];
1576
+ var PersistedTaskTitle = z.object({
1577
+ taskTitle: TaskTitle.min(1),
1578
+ isCustom: z.boolean(),
1579
+ sources: TaskTitleSources
1580
+ }).strict().refine(({ taskTitle, isCustom, sources }) => {
1581
+ const source = TASK_TITLE_SOURCE_PRIORITY.find((candidate) => sources[candidate]?.trim());
1582
+ if (!source) return false;
1583
+ return sources[source]?.replace(/\s+/g, " ").trim() === taskTitle && isCustom === (source === "customTitle");
1584
+ });
1262
1585
  var ProjectConfig = z.object({
1263
1586
  id: z.string().optional(),
1264
1587
  name: z.string().optional(),
1265
1588
  customTitle: TaskTitle.optional(),
1589
+ taskTitleState: PersistedTaskTitle.optional().catch(void 0),
1266
1590
  path: z.string(),
1267
1591
  repos: z.array(z.string()).min(2).optional(),
1268
1592
  agent: z.string({ error: "projects[].agent must be a string" }).regex(AGENT_ID_RE, { error: `projects[].agent must be ${AGENT_ID_SHAPE_MESSAGE}` }).optional(),
@@ -1275,8 +1599,11 @@ var FILE_CONFIG_SHAPE = {
1275
1599
  branchGc: optionalLooseObject("branchGc"),
1276
1600
  coder: z.object({ appSlug: z.string().optional() }).loose().optional(),
1277
1601
  visions: optionalLooseObject("visions"),
1602
+ github: GithubSettings,
1278
1603
  teamReview: optionalLooseObject("teamReview"),
1279
1604
  benchmarks: optionalLooseObject("benchmarks"),
1605
+ factory: FactorySettings,
1606
+ knowledgeGraph: optionalLooseObject("knowledgeGraph"),
1280
1607
  posthog: optionalLooseObject("posthog"),
1281
1608
  usage: optionalLooseObject("usage"),
1282
1609
  telegram: optionalLooseObject("telegram"),
@@ -1323,15 +1650,17 @@ var Config = z.object({
1323
1650
  });
1324
1651
  }
1325
1652
  });
1326
- Object.freeze(Object.keys(BROWSER_CONFIG_SHAPE));
1327
1653
  var CONFIG_BLOCK_KEYS = Object.freeze([
1328
1654
  "changeMap",
1329
1655
  "taskTitle",
1330
1656
  "branchGc",
1331
1657
  "postTurnChecks",
1332
1658
  "visions",
1659
+ "github",
1333
1660
  "teamReview",
1334
1661
  "benchmarks",
1662
+ "factory",
1663
+ "knowledgeGraph",
1335
1664
  "posthog",
1336
1665
  "usage",
1337
1666
  "telegram",
@@ -1364,1657 +1693,4 @@ function configIssueMessage(error) {
1364
1693
  return error.issues[0]?.message || "settings are invalid";
1365
1694
  }
1366
1695
  //#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 };
1696
+ export { TeamReviewCompareFiles as $, MyPrSearchResponse as A, CoherenceWorkInspect as At, PostingPlan as B, MyPrMergeMethod as C, KEEP_MERGEABLE_TIMEOUT_MINUTES_RANGE as Ct, MyPrMergeWhenReadyRequest as D, CoherenceRisk as Dt, MyPrMergeStateResponse as E, CoherenceReadiness as Et, CommitSha as F, ReviewDraft as G, QueuedReview as H, DECIDING_REVIEW_STATES as I, ReviewThreadId as J, ReviewFinding as K, FindingSeverity as L, MyPrThreadsResponse as M, MyPrsState as N, MyPrMergeWhenReadyResult as O, CoherenceTicketCreated as Ot, MyPrsStatus as P, TeamReviewActionResult as Q, GithubReviewDecision as R, MyPrKeepMergeableResult as S, normalizeLegacyConfigNumbers as St, MyPrMergeResult as T, CoherenceOrient as Tt, ReviewChecksState as U, PrDetail as V, ReviewComment as W, SearchedPr as X, ReviewVerdict as Y, TeamReviewActionRequest as Z, WorkflowSearchNode as _, ReviewsRefreshResult as _t, ConfigUpdate as a, TeamReviewThreadsRepository as at, MyPrAutoRebase as b, USAGE_COST_MODES as bt, TASK_TITLE_SOURCE_PRIORITY as c, hasStandingViewerApproval as ct, BRANCH_GC_CONTROL_NUMERIC_KEYS as d, shortSha as dt, TeamReviewResolveResponse as et, BranchGcFileSettings as f, GH_SEGMENT as ft, WorkflowLabelName as g, ReviewsRefreshRequest as gt, WorkflowCommentBody as h, repoParts as ht, Config as i, TeamReviewThreadResult as it, MyPrThreadNode as j, CoherenceWorkState as jt, MyPrSearchNode as k, CoherenceWorkCreated as kt, configIssueMessage as l, FULL_SHA_RE as lt, DEFAULT_FACTORY_PROTECTED_PATHS as m, REPO_SLUG_RE as mt, BUILTIN_AGENT_IDS as n, TeamReviewStatus as nt, PersistedTaskTitle as o, canApproveAfterComment as ot, DEFAULT_FACTORY_CHECKS as p, NODE_ID_RE as pt, ReviewResult as q, BrowserConfig as r, TeamReviewThreadCommentsResponse as rt, RUNTIME_CONFIG_SCALAR_KEYS as s, decisionAsIfApprovalRequired as st, AGENT_ID_SHAPE_MESSAGE as t, TeamReviewStateEntry as tt, BRANCH_GC_CONTROL_BOOLEAN_KEYS as u, HEX_SHA_RE as ut, WorkflowsSettings as v, reviewsPollingShape as vt, MyPrMergeRequest as w, USAGE_INTEGER_RANGES as wt, MyPrKeepMergeableRequest as x, USAGE_VENDOR_KEYS as xt, WorkflowsState as y, USAGE_BUDGET_KEYS as yt, GithubReviewState as z };