@cat-factory/app 0.36.0 → 0.37.1

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 (88) hide show
  1. package/app/components/auth/UserMenu.vue +11 -1
  2. package/app/components/brainstorm/BrainstormWindow.vue +2 -1
  3. package/app/components/clarity/ClarityReviewWindow.vue +2 -1
  4. package/app/components/layout/IntegrationBackTitle.vue +12 -7
  5. package/app/components/layout/IntegrationsHub.vue +191 -43
  6. package/app/components/layout/PersonalSetupModal.vue +141 -0
  7. package/app/components/pipeline/PipelineBuilder.vue +1 -1
  8. package/app/components/providers/VendorCredentialsModal.vue +7 -2
  9. package/app/composables/api/accounts.ts +36 -51
  10. package/app/composables/api/auth.ts +20 -19
  11. package/app/composables/api/board.ts +60 -40
  12. package/app/composables/api/bootstrap.ts +25 -22
  13. package/app/composables/api/client.ts +102 -0
  14. package/app/composables/api/context.ts +25 -6
  15. package/app/composables/api/documents.ts +36 -34
  16. package/app/composables/api/execution.ts +65 -48
  17. package/app/composables/api/followUps.ts +26 -26
  18. package/app/composables/api/fragments.ts +47 -34
  19. package/app/composables/api/github.ts +65 -45
  20. package/app/composables/api/humanReview.ts +7 -6
  21. package/app/composables/api/humanTest.ts +15 -11
  22. package/app/composables/api/kaizen.ts +8 -6
  23. package/app/composables/api/localSettings.ts +5 -4
  24. package/app/composables/api/models.ts +58 -51
  25. package/app/composables/api/notifications.ts +13 -7
  26. package/app/composables/api/presets.ts +34 -28
  27. package/app/composables/api/providerConnections.ts +68 -26
  28. package/app/composables/api/recurring.ts +40 -30
  29. package/app/composables/api/releaseHealth.ts +28 -26
  30. package/app/composables/api/reviews.ts +136 -114
  31. package/app/composables/api/sandbox.ts +52 -34
  32. package/app/composables/api/slack.ts +22 -25
  33. package/app/composables/api/spec.ts +3 -3
  34. package/app/composables/api/tasks.ts +42 -41
  35. package/app/composables/api/userSecrets.ts +12 -17
  36. package/app/composables/api/workspaces.ts +21 -15
  37. package/app/composables/useApi.ts +9 -1
  38. package/app/composables/useIntegrationBack.ts +9 -3
  39. package/app/composables/useSourceIntegration.ts +107 -0
  40. package/app/composables/useUpsertList.spec.ts +60 -0
  41. package/app/composables/useUpsertList.ts +57 -0
  42. package/app/pages/index.vue +2 -0
  43. package/app/stores/auth.ts +2 -1
  44. package/app/stores/board.ts +2 -1
  45. package/app/stores/brainstorm.ts +2 -2
  46. package/app/stores/clarity.ts +6 -2
  47. package/app/stores/documents.ts +27 -62
  48. package/app/stores/execution.ts +3 -2
  49. package/app/stores/github.ts +1 -2
  50. package/app/stores/mergePresets.ts +2 -6
  51. package/app/stores/notifications.ts +9 -6
  52. package/app/stores/pipelines.ts +1 -1
  53. package/app/stores/recurringPipelines.ts +2 -7
  54. package/app/stores/sandbox.ts +1 -2
  55. package/app/stores/tasks.ts +25 -76
  56. package/app/stores/ui.ts +62 -19
  57. package/app/types/accountSettings.ts +11 -36
  58. package/app/types/accounts.ts +16 -71
  59. package/app/types/bootstrap.ts +13 -75
  60. package/app/types/brainstorm.ts +13 -38
  61. package/app/types/clarity.ts +12 -43
  62. package/app/types/consensus.ts +16 -89
  63. package/app/types/documents.ts +19 -94
  64. package/app/types/domain.ts +54 -586
  65. package/app/types/execution.ts +48 -515
  66. package/app/types/fragments.ts +15 -83
  67. package/app/types/github.ts +25 -161
  68. package/app/types/incidentEnrichment.ts +10 -25
  69. package/app/types/localModels.ts +11 -61
  70. package/app/types/localSettings.ts +9 -26
  71. package/app/types/merge.ts +10 -68
  72. package/app/types/model-presets.ts +7 -28
  73. package/app/types/models.ts +16 -164
  74. package/app/types/notifications.ts +18 -77
  75. package/app/types/openrouter.ts +8 -34
  76. package/app/types/providerConnections.ts +21 -41
  77. package/app/types/provisioningLogs.ts +9 -29
  78. package/app/types/recurring.ts +10 -63
  79. package/app/types/releaseHealth.ts +15 -39
  80. package/app/types/requirements.ts +14 -84
  81. package/app/types/sandbox.ts +45 -161
  82. package/app/types/services.ts +3 -22
  83. package/app/types/slack.ts +10 -47
  84. package/app/types/spec.ts +15 -68
  85. package/app/types/tasks.ts +15 -111
  86. package/app/types/tracker.ts +9 -24
  87. package/app/types/userSecrets.ts +12 -47
  88. package/package.json +9 -2
@@ -1,25 +1,56 @@
1
1
  // ---------------------------------------------------------------------------
2
2
  // Execution model: a pipeline of agents running against a single block.
3
- // Mirrors the `@cat-factory/contracts` execution schemas.
3
+ //
4
+ // The wire shapes are sourced from @cat-factory/contracts (single source of
5
+ // truth) and re-exported here. A few names are aliased to the historical
6
+ // frontend names, and the handful with no exported contract equivalent (the
7
+ // agent-context snapshot view, the inline companion-state shape) are kept
8
+ // frontend-only below.
4
9
  // ---------------------------------------------------------------------------
5
10
 
6
- import type { AgentKind, TestReport } from './domain'
7
- import type { ConsensusStepConfig } from './consensus'
11
+ export type {
12
+ CompanionVerdict,
13
+ IterationCapChoice,
14
+ AgentState,
15
+ Decision,
16
+ StepSubtaskItem,
17
+ StepSubtasks,
18
+ AgentRunKind,
19
+ AgentFailureKind,
20
+ AgentFailure,
21
+ StepApproval,
22
+ StepMetrics,
23
+ LlmCallMetric,
24
+ LlmCallActivity,
25
+ LlmExportInsight,
26
+ LlmMetricsExport,
27
+ PipelineStep,
28
+ FollowUpItemKind,
29
+ FollowUpItemStatus,
30
+ FollowUpItem,
31
+ FollowUpsStepState,
32
+ GateFailingCheck,
33
+ GateAttempt,
34
+ GateStepState,
35
+ TesterStepState,
36
+ HumanTestEnvironment,
37
+ RunEnvironment,
38
+ HumanTestRound,
39
+ HumanTestStepState,
40
+ ExecutionInstance,
41
+ // The historical frontend name for a per-block review comment is the contract's
42
+ // StepReviewComment; the env-status union is the contract's EnvironmentStatus.
43
+ StepReviewComment as ReviewComment,
44
+ EnvironmentStatus as HumanTestEnvironmentStatus,
45
+ } from '@cat-factory/contracts'
46
+
47
+ import type { CompanionVerdict } from '@cat-factory/contracts'
8
48
 
9
- /**
10
- * A quality companion's verdict on one producer output the standardized shape every
11
- * pipeline companion step stores, one per rework cycle.
12
- */
13
- export interface CompanionVerdict {
14
- /** Overall quality rating of the graded output (0..1, higher = better). */
15
- rating: number
16
- /** The quality bar the rating had to reach to pass. */
17
- threshold: number
18
- /** Whether the rating met the threshold. */
19
- passed: boolean
20
- /** The companion's challenge, shown to the human and fed into the next rework. */
21
- feedback: string
22
- }
49
+ // ---------------------------------------------------------------------------
50
+ // Frontend-only shapes with no exported contract type. The contract defines them
51
+ // inline (anonymous) on their parent schemas, so they are re-stated here for the
52
+ // few components/stores that reference them directly.
53
+ // ---------------------------------------------------------------------------
23
54
 
24
55
  /** Live companion state on a companion step: the bar, the budget, and every verdict. */
25
56
  export interface StepCompanion {
@@ -39,196 +70,6 @@ export interface StepCompanion {
39
70
  exceeded?: boolean
40
71
  }
41
72
 
42
- /**
43
- * How a human resolves an iterative agent gate that hit its budget — shared by the
44
- * requirements reviewer and the quality companions. Mirror of the backend's
45
- * `IterationCapChoice` (see `@cat-factory/contracts` iteration-cap.ts).
46
- */
47
- export type IterationCapChoice = 'extra-round' | 'proceed' | 'stop-reset'
48
-
49
- /** Runtime state of a single agent within a running execution. */
50
- export type AgentState =
51
- | 'pending' // not started
52
- | 'working' // actively (visually) working
53
- | 'waiting_decision' // paused, needs a human decision
54
- | 'done' // finished
55
-
56
- /** A decision an agent surfaces mid-step that a human must resolve. */
57
- export interface Decision {
58
- id: string
59
- question: string
60
- options: string[]
61
- chosen: string | null
62
- }
63
-
64
- /** One entry of a running step's todo list — its label and current status. */
65
- export interface StepSubtaskItem {
66
- label: string
67
- status: 'pending' | 'in_progress' | 'completed'
68
- }
69
-
70
- /** Live subtask counts a running step reports from the agent's own todo list. */
71
- export interface StepSubtasks {
72
- completed: number
73
- inProgress: number
74
- total: number
75
- /** The individual todo entries, so a zoomed-in card can show the actual list. */
76
- items?: StepSubtaskItem[]
77
- }
78
-
79
- // ---------------------------------------------------------------------------
80
- // Shared "agent run" failure model. Both flows that run an agent in a container
81
- // — a task pipeline `execution` and a repo `bootstrap` — surface failures with
82
- // this shape, so the board renders one failure banner + retry for either. Mirrors
83
- // `agentFailureSchema` in `@cat-factory/contracts`.
84
- // ---------------------------------------------------------------------------
85
-
86
- /** The agent flows that produce a container-backed "agent run". */
87
- export type AgentRunKind = 'bootstrap' | 'execution'
88
-
89
- /** How an agent run faulted, so the board can classify it (and hint at a retry).
90
- * The union spans both flows; a given flow only ever produces a subset. */
91
- export type AgentFailureKind =
92
- | 'preflight'
93
- | 'dispatch'
94
- | 'evicted'
95
- | 'timeout'
96
- | 'agent'
97
- | 'job_failed'
98
- | 'rejected'
99
- | 'cancelled'
100
- | 'unknown'
101
-
102
- /** Structured diagnostics captured when an agent run fails. */
103
- export interface AgentFailure {
104
- kind: AgentFailureKind
105
- /** Human-readable summary (mirrors the run's one-line `error`). */
106
- message: string
107
- /** Extended detail when available (the harness's reason, an HTTP body, …). */
108
- detail: string | null
109
- /** Where to look next (e.g. "check the container logs for this job id"). */
110
- hint: string | null
111
- /** Epoch ms the failure was recorded. */
112
- occurredAt: number
113
- /** Last subtask counts seen before the failure, for context (null if none). */
114
- lastSubtasks: StepSubtasks | null
115
- }
116
-
117
- /**
118
- * One GitHub-review-style comment on a block of an agent's proposal (mirrors
119
- * `stepReviewCommentSchema` in contracts). `quotedSource` is the verbatim raw
120
- * markdown of the commented block, so a "request changes" re-run quotes the
121
- * agent's own text back to it.
122
- */
123
- export interface ReviewComment {
124
- quotedSource: string
125
- /** 0-based source line range [start, end) of the commented block. */
126
- srcStart: number
127
- srcEnd: number
128
- body: string
129
- }
130
-
131
- /**
132
- * A human approval gate on a step (mirrors `stepApprovalSchema` in contracts).
133
- * Raised once a gated step's proposal is ready; the human reviews it in the
134
- * conclusions reader, then approves (advance), requests changes (re-run with
135
- * freeform feedback + per-block comments) or rejects (stop the run).
136
- */
137
- export interface StepApproval {
138
- id: string
139
- status: 'pending' | 'approved' | 'changes_requested' | 'rejected'
140
- /** the agent's output the human reviews */
141
- proposal: string
142
- /** the human's freeform guidance when changes were requested */
143
- feedback?: string
144
- /** per-block review comments when changes were requested */
145
- comments?: ReviewComment[]
146
- }
147
-
148
- /**
149
- * LLM observability rollup for a step (mirrors `stepMetricsSchema` in contracts):
150
- * a compact aggregate over every model call the step's container made — token
151
- * usage, how close it ran to the output-token limit (truncation), the latency
152
- * split between transport/proxy overhead and actual model execution, and any
153
- * errors/warnings. Absent when the observability sink is not wired.
154
- */
155
- export interface StepMetrics {
156
- calls: number
157
- promptTokens: number
158
- completionTokens: number
159
- /** the largest single completion produced (closest approach to the limit) */
160
- peakCompletionTokens: number
161
- /** the output ceiling in effect (max requested max_tokens), or null when unknown */
162
- maxOutputTokens: number | null
163
- /** calls cut short by the output limit (finish_reason === 'length') */
164
- truncatedCalls: number
165
- /** sum of model execution time (ms) — the actual prompt/tool execution */
166
- upstreamMs: number
167
- /** sum of transport/proxy overhead (ms) — the interim-layer cost */
168
- overheadMs: number
169
- /** calls that failed (non-2xx / refused / in-process error) */
170
- errors: number
171
- /** successful calls that warned (truncated or content-filtered) */
172
- warnings: number
173
- }
174
-
175
- /** One proxied LLM call's full detail (mirrors `llmCallMetricSchema` in contracts). */
176
- export interface LlmCallMetric {
177
- id: string
178
- workspaceId: string
179
- executionId: string | null
180
- agentKind: string
181
- provider: string
182
- model: string
183
- createdAt: number
184
- streaming: boolean
185
- messageCount: number
186
- toolCount: number
187
- requestMaxTokens: number | null
188
- promptTokens: number
189
- /** prompt tokens served from the provider's prompt cache (subset of promptTokens) */
190
- cachedPromptTokens: number
191
- completionTokens: number
192
- totalTokens: number
193
- finishReason: string | null
194
- upstreamMs: number
195
- overheadMs: number
196
- totalMs: number
197
- ok: boolean
198
- httpStatus: number | null
199
- errorMessage: string | null
200
- /**
201
- * the request messages serialised as JSON, stored as a delta — only the messages
202
- * this call appended beyond `promptPrefixCount` (the full array when that is 0)
203
- */
204
- promptText: string
205
- /** leading messages elided from `promptText` (0 ⇒ it is the full array) */
206
- promptPrefixCount: number
207
- /** hash of the call's full messages array (chain key for the next call's delta) */
208
- promptHash: string
209
- /** the full assistant response text */
210
- responseText: string
211
- /**
212
- * the model's reasoning/"thinking" trace on a separate channel, when emitted (empty
213
- * for non-reasoning models). a thinking model can spend its whole output budget here
214
- * and return empty `responseText`.
215
- */
216
- reasoningText: string
217
- }
218
-
219
- /**
220
- * The compact per-call summary pushed live over the workspace stream (the `llmCall`
221
- * event). It is {@link LlmCallMetric} WITHOUT the heavy text bodies and delta
222
- * bookkeeping, so an open "Model activity" panel updates in real time without
223
- * shipping prompt bytes. The panel lazy-loads the full bodies for an expanded row
224
- * from the persisted metrics endpoint, keyed by the shared `id`. Mirrors
225
- * `LlmCallActivity` in `@cat-factory/contracts`.
226
- */
227
- export type LlmCallActivity = Omit<
228
- LlmCallMetric,
229
- 'promptText' | 'responseText' | 'reasoningText' | 'promptPrefixCount' | 'promptHash'
230
- >
231
-
232
73
  /** One best-practice fragment folded into an agent's system prompt. */
233
74
  export interface AgentContextFragment {
234
75
  id: string
@@ -264,311 +105,3 @@ export interface AgentContextSnapshot {
264
105
  contextFiles: AgentContextFile[]
265
106
  extras: Record<string, unknown>
266
107
  }
267
-
268
- /** One per-agent-kind insight in the LLM-friendly export (rollup + derived ratios). */
269
- export interface LlmExportInsight extends StepMetrics {
270
- agentKind: string
271
- /** peakCompletionTokens / maxOutputTokens, 0..1; null when the ceiling is unknown. */
272
- outputHeadroomRatio: number | null
273
- /** overheadMs / (upstreamMs + overheadMs), 0..1; the share spent in transport. */
274
- transportOverheadRatio: number | null
275
- }
276
-
277
- /** LLM-friendly export of a run's model activity (mirrors `llmMetricsExportSchema`). */
278
- export interface LlmMetricsExport {
279
- kind: 'cat-factory.llm-metrics-export'
280
- version: 1
281
- executionId: string
282
- generatedAt: number
283
- totals: {
284
- calls: number
285
- promptTokens: number
286
- completionTokens: number
287
- upstreamMs: number
288
- overheadMs: number
289
- transportOverheadRatio: number | null
290
- errors: number
291
- warnings: number
292
- truncatedCalls: number
293
- }
294
- insights: LlmExportInsight[]
295
- calls: LlmCallMetric[]
296
- }
297
-
298
- /** One agent's slot in a running pipeline. */
299
- export interface PipelineStep {
300
- /**
301
- * Id of the run this step belongs to (always the enclosing ExecutionInstance's id);
302
- * surfaced on every step so a lone step is self-describing for debugging.
303
- */
304
- runId?: string
305
- agentKind: AgentKind
306
- state: AgentState
307
- /** 0..1 progress of this individual step */
308
- progress: number
309
- /** LLM observability rollup for this step (token use, headroom, latency split). */
310
- metrics?: StepMetrics | null
311
- /** live "N/M done" subtask counts while an async (container) step runs */
312
- subtasks?: StepSubtasks
313
- /**
314
- * True while a container-backed step's per-run container is cold-booting (set at
315
- * dispatch, cleared once the container is up). Drives the "Spinning up container…"
316
- * phase indicator before any execution progress is available.
317
- */
318
- startingContainer?: boolean
319
- /** present + unresolved => the step (and block) is blocked */
320
- decision: Decision | null
321
- /** whether a human approval gate fires after this step (from the pipeline) */
322
- requiresApproval?: boolean
323
- /** the live approval gate for this step; pending => the run is blocked on a human */
324
- approval?: StepApproval | null
325
- /**
326
- * Live companion state when this step is a companion kind: its quality bar, rework
327
- * budget, and the full sequence of verdicts (one per correction cycle). Absent on
328
- * non-companion steps.
329
- */
330
- companion?: StepCompanion | null
331
- /**
332
- * Consensus config for this step, copied from the pipeline at run start; present (with
333
- * `enabled`) when the step runs through the multi-model consensus mechanism. Absent ⇒
334
- * standard single-actor agent.
335
- */
336
- consensus?: ConsensusStepConfig | null
337
- /** text the agent produced for this step (when LLM execution is enabled). */
338
- output?: string
339
- /**
340
- * Structured JSON a registered CUSTOM kind's agent step returned (the generic
341
- * manifest-driven `agent` dispatch). Rendered by the `generic-structured` result view.
342
- * Absent for built-in / prose kinds.
343
- */
344
- custom?: unknown
345
- /** identifier of the model that produced `output`, for transparency. */
346
- model?: string
347
- /** prompt-fragment library ids folded into this step (manual ∪ selector pick). */
348
- selectedFragmentIds?: string[]
349
- /** epoch ms the step first began executing (transitioned to `working`). */
350
- startedAt?: number | null
351
- /** epoch ms the step finished (transitioned to `done`); with `startedAt` gives duration. */
352
- finishedAt?: number | null
353
- /**
354
- * epoch ms the step parked on a human (approval / decision / iteration-cap gate),
355
- * freezing its duration while it waits for input; cleared (null) once it resumes or
356
- * finishes. The counterpart of `finishedAt` for the "waiting on input" freeze.
357
- */
358
- pausedAt?: number | null
359
- /**
360
- * Live Tester→Fixer loop state when this step is a `tester` kind: which phase is in
361
- * flight (testing vs fixing the issues it found), the fixer attempt budget, and the
362
- * latest structured test report. Absent on non-tester steps.
363
- */
364
- test?: TesterStepState | null
365
- /**
366
- * Live gate state when this step is a polling gate (`ci` / `conflicts`): which phase
367
- * is in flight (checking the precheck vs a helper working), the helper attempt
368
- * budget, the gated commit, and the latest precheck verdict + failure detail. Absent
369
- * on non-gate steps. Mirrors `gateStepStateSchema`.
370
- */
371
- gate?: GateStepState | null
372
- /**
373
- * Live state of a `human-test` gate (ephemeral env + human validation loop): the phase,
374
- * the live environment, the fix/pull-main round history, and any degraded-mode reason.
375
- * Absent on non-human-test steps. Mirrors `humanTestStepStateSchema`.
376
- */
377
- humanTest?: HumanTestStepState | null
378
- /**
379
- * The ephemeral environment this step runs against (when its block has one), so a
380
- * run's details show its lifecycle state + the exact error. Populated by the engine
381
- * for container/deployer steps; the `human-test` gate uses `humanTest.environment`.
382
- * Mirrors `runEnvironmentSchema`.
383
- */
384
- environment?: RunEnvironment | null
385
- /**
386
- * Live Follow-up companion state when this (coder) step has the future-looking companion
387
- * enabled: the forward-looking items the Coder streamed (loose ends / side-tasks /
388
- * questions) and the send-back loop budget. The chip blinks while any item is `pending`;
389
- * the gate holds the pipeline until every item is decided. Mirrors `followUpsStepStateSchema`.
390
- */
391
- followUps?: FollowUpsStepState | null
392
- }
393
-
394
- /** What a streamed item is: a forward-looking follow-up or a clarifying question. */
395
- export type FollowUpItemKind = 'follow_up' | 'question'
396
-
397
- /** Lifecycle of a single follow-up / question item (mirrors `followUpItemStatusSchema`). */
398
- export type FollowUpItemStatus = 'pending' | 'filed' | 'queued' | 'answered' | 'dismissed'
399
-
400
- /** One forward-looking item the Coder surfaced (mirrors `followUpItemSchema`). */
401
- export interface FollowUpItem {
402
- id: string
403
- kind: FollowUpItemKind
404
- title: string
405
- detail: string
406
- suggestedAction?: string | null
407
- status: FollowUpItemStatus
408
- /** The human's answer to a `question` item, or null while unanswered / not a question. */
409
- answer?: string | null
410
- /** Canonical external id of the filed ticket (e.g. "owner/repo#123"), when `filed`. */
411
- ticketExternalId?: string | null
412
- /** URL of the filed ticket, when `filed`. */
413
- ticketUrl?: string | null
414
- /** True once a queued / answered item was folded into a Coder loop-back. */
415
- sentToCoder?: boolean
416
- createdAt: number
417
- updatedAt: number
418
- }
419
-
420
- /** Live Follow-up companion state on the Coder step (mirrors `followUpsStepStateSchema`). */
421
- export interface FollowUpsStepState {
422
- enabled: boolean
423
- items: FollowUpItem[]
424
- loops?: number
425
- maxLoops?: number
426
- }
427
-
428
- /** One failing CI check the gate's precheck saw (mirrors `gateFailingCheckSchema`). */
429
- export interface GateFailingCheck {
430
- name: string
431
- conclusion: string | null
432
- /** GitHub web URL of the check run, so the UI can link to the failed run's logs */
433
- url?: string | null
434
- }
435
-
436
- /** One helper-agent attempt the gate dispatched (mirrors `gateAttemptSchema`). */
437
- export interface GateAttempt {
438
- /** 1-based attempt number */
439
- attempt: number
440
- /** epoch ms when the helper job finished */
441
- at: number
442
- /** how the helper job ended */
443
- outcome: 'completed' | 'failed'
444
- /** the PR head commit the helper worked against, when known */
445
- headSha?: string | null
446
- /** the helper's own account of what it did / what remains */
447
- summary?: string | null
448
- }
449
-
450
- /** Live state of a polling gate step (`ci` / `conflicts`); mirrors `gateStepStateSchema`. */
451
- export interface GateStepState {
452
- phase: 'checking' | 'working'
453
- /** how many helper-agent attempts have been dispatched so far */
454
- attempts: number
455
- /** ceiling on helper attempts (from the task's merge preset) */
456
- maxAttempts: number
457
- /** the PR head commit being gated, once resolved */
458
- headSha?: string | null
459
- /** the most recent precheck verdict (why the gate is looping vs idle-passing) */
460
- lastVerdict?: 'pass' | 'pending' | 'fail' | null
461
- /** human-readable summary of the latest failing precheck (failing checks / conflict reason) */
462
- lastFailureSummary?: string | null
463
- /** structured failing checks behind the summary (CI gate only; absent for conflicts) */
464
- failingChecks?: GateFailingCheck[] | null
465
- /** history of the helper-agent attempts this gate dispatched, newest last */
466
- attemptLog?: GateAttempt[] | null
467
- // ---- human-review gate only ----
468
- /** approvals the PR had at the last probe (human-review gate) */
469
- lastApprovals?: number | null
470
- /**
471
- * raw branch-protection required count, cached after the first probe (human-review gate).
472
- * The displayed "required" count is `max(1, this)` — the gate's effective floor.
473
- */
474
- requiredApprovingReviewCount?: number | null
475
- /** review threads handed to the fixer, pending resolve on its completion (human-review gate) */
476
- pendingThreadIds?: string[] | null
477
- /** the grace window (minutes) before the fixer addresses a comment batch (human-review gate) */
478
- humanReviewGraceMinutes?: number | null
479
- /** newest plain PR comment already handed to the fixer (human-review gate) */
480
- lastAddressedCommentAt?: number | null
481
- /** a human-initiated freeform fix parked on the gate, consumed on the next poll (human-review gate) */
482
- pendingFix?: { instructions: string; at: number } | null
483
- }
484
-
485
- /** Live state of a `tester` step's Tester→Fixer loop (mirrors `testerStepStateSchema`). */
486
- export interface TesterStepState {
487
- phase: 'testing' | 'fixing'
488
- /** how many fixer attempts have been dispatched so far */
489
- attempts: number
490
- /** ceiling on fixer attempts (from the task's merge preset) */
491
- maxAttempts: number
492
- /** the most recent Tester report (what was tested, outcomes, concerns, greenlight) */
493
- lastReport?: TestReport | null
494
- }
495
-
496
- /** The lifecycle status of an ephemeral environment (mirrors `environmentStatusSchema`). */
497
- export type HumanTestEnvironmentStatus =
498
- | 'provisioning'
499
- | 'ready'
500
- | 'failed'
501
- | 'expired'
502
- | 'tearing_down'
503
- | 'torn_down'
504
-
505
- /** The compact env view a `human-test` gate carries (mirrors `humanTestEnvironmentSchema`). */
506
- export interface HumanTestEnvironment {
507
- id: string
508
- url: string | null
509
- status: HumanTestEnvironmentStatus
510
- expiresAt?: number | null
511
- }
512
-
513
- /**
514
- * The ephemeral environment a run's step is associated with — surfaced in run details
515
- * so its spinning-up / running / shut-down / errored state + the exact error show next
516
- * to the consuming step (tester/coder). Mirrors `runEnvironmentSchema`.
517
- */
518
- export interface RunEnvironment {
519
- id: string
520
- url: string | null
521
- status: HumanTestEnvironmentStatus
522
- expiresAt?: number | null
523
- /** The verbatim provider error when the environment failed/expired, else null. */
524
- lastError?: string | null
525
- }
526
-
527
- /** One fix / pull-main round on a `human-test` gate (mirrors `humanTestRoundSchema`). */
528
- export interface HumanTestRound {
529
- kind: 'fix' | 'pull-main'
530
- /** The human's findings (fix), or a one-line note (pull-main). */
531
- findings: string
532
- /** The helper container kind this round dispatched (`fixer` / `conflict-resolver`). */
533
- helperKind: string
534
- jobId?: string | null
535
- /** How the helper ended once its job settled; absent while in flight. */
536
- outcome?: 'completed' | 'failed' | null
537
- /** epoch ms the round opened */
538
- at: number
539
- }
540
-
541
- /** Live state of a `human-test` gate (mirrors `humanTestStepStateSchema`). */
542
- export interface HumanTestStepState {
543
- phase: 'provisioning' | 'awaiting_human' | 'fixing' | 'resolving_conflicts' | 'passed'
544
- /** the live ephemeral environment (null in degraded manual mode / after destroy) */
545
- environment?: HumanTestEnvironment | null
546
- /** why no env was auto-provisioned (degraded manual mode), for the window to explain */
547
- degradedReason?: string | null
548
- /** how many helper (fixer / conflict-resolver) attempts have been dispatched so far */
549
- attempts: number
550
- /** ceiling on helper attempts (from the task's merge preset) */
551
- maxAttempts: number
552
- headSha?: string | null
553
- /** append-only history of fix / pull-main rounds */
554
- rounds?: HumanTestRound[]
555
- }
556
-
557
- /** A pipeline instance running against one block. */
558
- export interface ExecutionInstance {
559
- id: string
560
- blockId: string
561
- pipelineId: string
562
- pipelineName: string
563
- steps: PipelineStep[]
564
- /** index into steps of the currently active step */
565
- currentStep: number
566
- /**
567
- * 'paused' = halted by the spend safeguard until the budget frees up;
568
- * 'failed' = the run faulted (see `failure`) — surfaces the shared failure
569
- * banner + retry, instead of the old success-looking `pr_ready` lie.
570
- */
571
- status: 'running' | 'blocked' | 'done' | 'paused' | 'failed'
572
- /** Structured failure diagnostics when `status` is `failed`; null otherwise. */
573
- failure?: AgentFailure | null
574
- }
@@ -3,86 +3,18 @@
3
3
  // fragment-library schemas: the managed, tenant-scoped catalog a workspace
4
4
  // resolves (built-in ∪ account ∪ workspace), plus the repo sources that feed it.
5
5
  // ---------------------------------------------------------------------------
6
-
7
- import type { AgentKind, BlockType } from './domain'
8
- import type { DocumentSourceKind } from './documents'
9
- import type { PromptFragment } from './models'
10
-
11
- /** Which scope owns a managed fragment / source. */
12
- export type FragmentOwnerKind = 'account' | 'workspace'
13
-
14
- /** The tier a resolved fragment originates from after override-by-id. */
15
- export type FragmentTier = 'builtin' | 'account' | 'workspace'
16
-
17
- /** Inputs for creating a hand-authored fragment at a tier. */
18
- export interface CreatePromptFragmentInput {
19
- id?: string
20
- title: string
21
- category?: string
22
- summary: string
23
- body: string
24
- tags?: string[]
25
- appliesTo?: { blockTypes?: BlockType[]; agentKinds?: AgentKind[] }
26
- version?: string
27
- }
28
-
29
- /** Partial patch for editing a fragment at a tier. */
30
- export type UpdatePromptFragmentInput = Partial<CreatePromptFragmentInput>
31
-
32
- /**
33
- * Inputs for linking an external document (Confluence/Notion page or GitHub file)
34
- * as a LIVING fragment at a tier. Title/summary/body are derived from the fetched
35
- * document, not supplied here. `viaWorkspaceId` is only needed at the account tier.
36
- */
37
- export interface CreateDocumentFragmentInput {
38
- source: DocumentSourceKind
39
- ref: string
40
- id?: string
41
- category?: string
42
- tags?: string[]
43
- appliesTo?: { blockTypes?: BlockType[]; agentKinds?: AgentKind[] }
44
- viaWorkspaceId?: string
45
- }
46
-
47
- /** A fragment after the three tiers are merged for a workspace. */
48
- export interface ResolvedFragment extends PromptFragment {
49
- tier: FragmentTier
50
- }
51
-
52
- /** A repo directory linked as a source of Markdown guideline files. */
53
- export interface FragmentSource {
54
- id: string
55
- ownerKind: FragmentOwnerKind
56
- ownerId: string
57
- repoOwner: string
58
- repoName: string
59
- gitRef: string
60
- dirPath: string
61
- lastSyncedSha: string | null
62
- lastSyncedAt: number | null
63
- createdAt: number
64
- }
65
-
66
- /** Inputs for linking a repo directory as a fragment source. */
67
- export interface LinkFragmentSourceInput {
68
- repoOwner: string
69
- repoName: string
70
- gitRef?: string
71
- dirPath?: string
72
- }
73
-
74
- /** Outcome of resyncing a source. */
75
- export interface FragmentSyncResult {
76
- upserted: number
77
- tombstoned: number
78
- unchanged: number
79
- lastSyncedSha: string | null
80
- }
81
-
82
- /** Cheap "check for changes" result (no writes); powers the resync badge. */
83
- export interface FragmentSourceStatus {
84
- changed: boolean
85
- changedCount: number
86
- lastSyncedSha: string | null
87
- remoteSha: string | null
88
- }
6
+ //
7
+ // All wire shapes are sourced from @cat-factory/contracts (single source of truth).
8
+
9
+ export type {
10
+ FragmentOwnerKind,
11
+ FragmentTier,
12
+ CreatePromptFragmentInput,
13
+ UpdatePromptFragmentInput,
14
+ CreateDocumentFragmentInput,
15
+ ResolvedFragment,
16
+ FragmentSource,
17
+ LinkFragmentSourceInput,
18
+ FragmentSyncResult,
19
+ FragmentSourceStatus,
20
+ } from '@cat-factory/contracts'