@drisp/protocol 0.8.8 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/v2.js CHANGED
@@ -3,7 +3,7 @@ import {
3
3
  } from "./chunk-HMYWICNI.js";
4
4
 
5
5
  // src/v2.ts
6
- import { z as z3 } from "zod";
6
+ import { z as z15 } from "zod";
7
7
 
8
8
  // src/history.ts
9
9
  function readableHistory(records) {
@@ -47,90 +47,27 @@ function readableHistory(records) {
47
47
  return result;
48
48
  }
49
49
 
50
- // src/budget.ts
51
- import { z } from "zod";
52
- var SIZE_CLASS_CAPS = {
53
- S: 3e6,
54
- M: 6e6,
55
- L: 12e6
56
- };
57
- var SIZE_CLASS_FORECASTS = {
58
- S: 15e4,
59
- M: 4e5,
60
- L: 12e5
61
- };
62
- function classOfCap(declaredCap) {
63
- if (Number.isNaN(declaredCap) || declaredCap <= SIZE_CLASS_CAPS.S) return "S";
64
- if (declaredCap <= SIZE_CLASS_CAPS.M) return "M";
65
- return "L";
66
- }
67
- function forecastOfCap(declaredCap) {
68
- return SIZE_CLASS_FORECASTS[classOfCap(declaredCap)];
69
- }
70
- function attemptForecast(declaredCap) {
71
- const forecast = forecastOfCap(declaredCap);
72
- return declaredCap > 0 ? Math.min(declaredCap, forecast) : forecast;
73
- }
74
- function attemptCost(attempt) {
75
- const forecast = attemptForecast(attempt.tokenCap);
76
- const cost = attempt.closed ? attempt.spent ?? forecast : Math.max(forecast, attempt.spent ?? 0);
77
- return attempt.tokenCap > 0 ? Math.min(attempt.tokenCap, cost) : cost;
78
- }
79
- function budgetCheck(input) {
80
- const used = input.attempts.reduce((sum, attempt) => sum + attemptCost(attempt), 0);
81
- return { used, fits: used + input.next <= input.tokenBudget };
82
- }
83
- var CALIBRATION_MIN_RUNS = 10;
84
- var CALIBRATION_WINDOW_DAYS = 90;
85
- function calibrate(samples) {
86
- const byKey = /* @__PURE__ */ new Map();
87
- for (const { harness, sizeClass, counted } of samples) {
88
- if (counted === void 0 || !Number.isFinite(counted) || counted < 0) continue;
89
- const key = `${harness}\0${sizeClass}`;
90
- const group = byKey.get(key) ?? { harness, sizeClass, counted: [] };
91
- group.counted.push(counted);
92
- byKey.set(key, group);
93
- }
94
- const result = {};
95
- for (const { harness, sizeClass, counted } of byKey.values()) {
96
- if (counted.length < CALIBRATION_MIN_RUNS) continue;
97
- const sorted = [...counted].sort((a, b) => a - b);
98
- const p90 = sorted[Math.ceil(sorted.length * 0.9) - 1];
99
- (result[harness] ??= {})[sizeClass] = { forecast: Math.max(SIZE_CLASS_FORECASTS[sizeClass], p90), runs: sorted.length };
100
- }
101
- return result;
102
- }
103
- var classCalibrationSchema = z.strictObject({
104
- S: z.strictObject({ forecast: z.number(), runs: z.number() }).optional(),
105
- M: z.strictObject({ forecast: z.number(), runs: z.number() }).optional(),
106
- L: z.strictObject({ forecast: z.number(), runs: z.number() }).optional()
107
- });
108
- var calibrationSchema = z.record(z.string(), classCalibrationSchema);
109
- function forecastOfClass(sizeClass, calibration) {
110
- return calibration?.[sizeClass]?.forecast ?? SIZE_CLASS_FORECASTS[sizeClass];
111
- }
112
-
113
50
  // src/tracker.ts
114
- import { z as z2 } from "zod";
115
- var id = z2.string().min(1).max(160);
116
- var text = z2.string().max(1e5);
117
- var deliveryEvidenceKindSchema = z2.enum(["pr_opened", "merged", "staging", "qa_started", "qa_passed", "released"]);
118
- var deliveryStageSchema = z2.strictObject({
51
+ import { z } from "zod";
52
+ var id = z.string().min(1).max(160);
53
+ var text = z.string().max(1e5);
54
+ var deliveryEvidenceKindSchema = z.enum(["pr_opened", "merged", "staging", "qa_started", "qa_passed", "released"]);
55
+ var deliveryStageSchema = z.strictObject({
119
56
  id,
120
- name: z2.string().trim().min(1).max(100),
121
- category: z2.enum(["backlog", "unstarted", "started", "completed", "canceled"]),
122
- behavior: z2.enum(["manual", "agent_start", ...deliveryEvidenceKindSchema.options]).default("manual")
57
+ name: z.string().trim().min(1).max(100),
58
+ category: z.enum(["backlog", "unstarted", "started", "completed", "canceled"]),
59
+ behavior: z.enum(["manual", "agent_start", ...deliveryEvidenceKindSchema.options]).default("manual")
123
60
  });
124
- var deliveryTransitionSchema = z2.strictObject({
61
+ var deliveryTransitionSchema = z.strictObject({
125
62
  from: id,
126
63
  to: id,
127
- requires: z2.array(deliveryEvidenceKindSchema).default([])
64
+ requires: z.array(deliveryEvidenceKindSchema).default([])
128
65
  });
129
- var deliveryWorkflowSchema = z2.strictObject({
130
- revision: z2.number().int().nonnegative(),
131
- stages: z2.array(deliveryStageSchema).min(1).max(100),
132
- transitions: z2.array(deliveryTransitionSchema).max(1e4),
133
- attentionColumn: z2.boolean().default(true)
66
+ var deliveryWorkflowSchema = z.strictObject({
67
+ revision: z.number().int().nonnegative(),
68
+ stages: z.array(deliveryStageSchema).min(1).max(100),
69
+ transitions: z.array(deliveryTransitionSchema).max(1e4),
70
+ attentionColumn: z.boolean().default(true)
134
71
  }).superRefine((workflow, ctx) => {
135
72
  const ids = new Set(workflow.stages.map((s) => s.id));
136
73
  if (ids.size !== workflow.stages.length) ctx.addIssue({ code: "custom", message: "Duplicate stage ID" });
@@ -170,79 +107,79 @@ function defaultDeliveryWorkflow() {
170
107
  }
171
108
  return { revision: 0, stages, transitions, attentionColumn: true };
172
109
  }
173
- var trackerSourceSchema = z2.strictObject({ workspace: id, id, identifier: id, url: z2.string().url() });
174
- var trackerPlanSchema = z2.strictObject({ id, name: z2.string().trim().min(1).max(200), description: text.default(""), source: trackerSourceSchema.optional() });
175
- var trackerCommentSchema = z2.strictObject({ id, body: text, author: id, createdAt: z2.number(), sourceId: id.optional() });
176
- var trackerEvidenceSchema = z2.strictObject({
110
+ var trackerSourceSchema = z.strictObject({ workspace: id, id, identifier: id, url: z.string().url() });
111
+ var trackerPlanSchema = z.strictObject({ id, name: z.string().trim().min(1).max(200), description: text.default(""), source: trackerSourceSchema.optional() });
112
+ var trackerCommentSchema = z.strictObject({ id, body: text, author: id, createdAt: z.number(), sourceId: id.optional() });
113
+ var trackerEvidenceSchema = z.strictObject({
177
114
  id,
178
115
  kind: deliveryEvidenceKindSchema,
179
116
  revision: id,
180
- reference: z2.string().min(1).max(2e3),
117
+ reference: z.string().min(1).max(2e3),
181
118
  deploymentId: id.optional(),
182
119
  runId: id.optional(),
183
- createdAt: z2.number(),
120
+ createdAt: z.number(),
184
121
  author: id
185
122
  });
186
- var trackerIssueSchema = z2.strictObject({
123
+ var trackerIssueSchema = z.strictObject({
187
124
  id,
188
125
  identifier: id,
189
- title: z2.string().trim().min(1).max(500),
126
+ title: z.string().trim().min(1).max(500),
190
127
  description: text,
191
128
  stageId: id,
192
129
  planId: id.nullable(),
193
130
  parentId: id.nullable(),
194
131
  assignee: id.nullable(),
195
- priority: z2.number().int().min(0).max(4),
196
- labels: z2.array(z2.string().max(100)).max(100),
197
- blockedBy: z2.array(id).max(100),
198
- externalBlockers: z2.array(z2.string().max(2e3)).max(100),
199
- agentEligible: z2.boolean(),
200
- automationHeld: z2.boolean(),
132
+ priority: z.number().int().min(0).max(4),
133
+ labels: z.array(z.string().max(100)).max(100),
134
+ blockedBy: z.array(id).max(100),
135
+ externalBlockers: z.array(z.string().max(2e3)).max(100),
136
+ agentEligible: z.boolean(),
137
+ automationHeld: z.boolean(),
201
138
  revision: id.nullable(),
202
- attention: z2.strictObject({
139
+ attention: z.strictObject({
203
140
  id,
204
- message: z2.string().trim().min(1).max(1e4),
141
+ message: z.string().trim().min(1).max(1e4),
205
142
  runId: id.optional(),
206
- origin: z2.enum(["manual", "run"]).default("manual")
143
+ origin: z.enum(["manual", "run"]).default("manual")
207
144
  }).nullable(),
208
145
  threadId: id,
209
- runIds: z2.array(id),
210
- comments: z2.array(trackerCommentSchema),
211
- evidence: z2.array(trackerEvidenceSchema),
212
- history: z2.array(z2.strictObject({ at: z2.number(), actor: id, action: z2.string(), from: id.optional(), to: id.optional() })),
146
+ runIds: z.array(id),
147
+ comments: z.array(trackerCommentSchema),
148
+ evidence: z.array(trackerEvidenceSchema),
149
+ history: z.array(z.strictObject({ at: z.number(), actor: id, action: z.string(), from: id.optional(), to: id.optional() })),
213
150
  source: trackerSourceSchema.optional(),
214
- sourceAssignee: z2.string().optional(),
215
- createdAt: z2.number(),
216
- updatedAt: z2.number(),
217
- version: z2.number().int().nonnegative()
151
+ sourceAssignee: z.string().optional(),
152
+ createdAt: z.number(),
153
+ updatedAt: z.number(),
154
+ version: z.number().int().nonnegative()
218
155
  });
219
- var trackerSnapshotSchema = z2.strictObject({
156
+ var trackerSnapshotSchema = z.strictObject({
220
157
  workflow: deliveryWorkflowSchema,
221
- issues: z2.array(trackerIssueSchema),
222
- plans: z2.array(trackerPlanSchema),
223
- members: z2.array(id)
158
+ issues: z.array(trackerIssueSchema),
159
+ plans: z.array(trackerPlanSchema),
160
+ members: z.array(id)
224
161
  });
225
162
  var issueFields = {
226
- title: z2.string().trim().min(1).max(500),
163
+ title: z.string().trim().min(1).max(500),
227
164
  description: text.default(""),
228
165
  planId: id.nullable().default(null),
229
166
  parentId: id.nullable().default(null),
230
167
  assignee: id.nullable().default(null),
231
- priority: z2.number().int().min(0).max(4).default(0),
232
- labels: z2.array(z2.string().max(100)).max(100).default([]),
233
- blockedBy: z2.array(id).max(100).default([]),
234
- externalBlockers: z2.array(z2.string().max(2e3)).max(100).default([]),
235
- agentEligible: z2.boolean().default(false),
168
+ priority: z.number().int().min(0).max(4).default(0),
169
+ labels: z.array(z.string().max(100)).max(100).default([]),
170
+ blockedBy: z.array(id).max(100).default([]),
171
+ externalBlockers: z.array(z.string().max(2e3)).max(100).default([]),
172
+ agentEligible: z.boolean().default(false),
236
173
  revision: id.nullable().default(null)
237
174
  };
238
- var trackerImportSchema = z2.strictObject({
175
+ var trackerImportSchema = z.strictObject({
239
176
  workspace: id,
240
177
  teamId: id,
241
- stages: z2.array(deliveryStageSchema).min(1).max(100),
242
- stageMapping: z2.record(z2.string(), id),
243
- adoptWorkflow: z2.boolean(),
244
- plans: z2.array(z2.strictObject({ source: trackerSourceSchema, name: z2.string().min(1).max(200), description: text })).max(500),
245
- issues: z2.array(z2.strictObject({
178
+ stages: z.array(deliveryStageSchema).min(1).max(100),
179
+ stageMapping: z.record(z.string(), id),
180
+ adoptWorkflow: z.boolean(),
181
+ plans: z.array(z.strictObject({ source: trackerSourceSchema, name: z.string().min(1).max(200), description: text })).max(500),
182
+ issues: z.array(z.strictObject({
246
183
  source: trackerSourceSchema,
247
184
  title: issueFields.title,
248
185
  description: text,
@@ -250,20 +187,20 @@ var trackerImportSchema = z2.strictObject({
250
187
  planId: id.nullable(),
251
188
  parentId: id.nullable(),
252
189
  assignee: id.nullable(),
253
- sourceAssignee: z2.string().optional(),
190
+ sourceAssignee: z.string().optional(),
254
191
  priority: issueFields.priority,
255
192
  labels: issueFields.labels,
256
- blockedBy: z2.array(id).max(100),
257
- externalBlockers: z2.array(z2.string().max(2e3)).max(100).default([]),
258
- comments: z2.array(trackerCommentSchema).max(1e3),
259
- createdAt: z2.number()
193
+ blockedBy: z.array(id).max(100),
194
+ externalBlockers: z.array(z.string().max(2e3)).max(100).default([]),
195
+ comments: z.array(trackerCommentSchema).max(1e3),
196
+ createdAt: z.number()
260
197
  })).max(2e3),
261
- omissions: z2.array(z2.string().max(2e3)).max(500).default([])
198
+ omissions: z.array(z.string().max(2e3)).max(500).default([])
262
199
  });
263
- var trackerOperationSchema = z2.discriminatedUnion("kind", [
264
- z2.strictObject({ kind: z2.literal("tracker.sync") }),
265
- z2.strictObject({ kind: z2.literal("issue.create"), id: id.max(147), stageId: id.optional(), ...issueFields }),
266
- z2.strictObject({ kind: z2.literal("issue.update"), id, version: z2.number().int(), changes: trackerIssueSchema.pick({
200
+ var trackerOperationSchema = z.discriminatedUnion("kind", [
201
+ z.strictObject({ kind: z.literal("tracker.sync") }),
202
+ z.strictObject({ kind: z.literal("issue.create"), id: id.max(147), stageId: id.optional(), ...issueFields }),
203
+ z.strictObject({ kind: z.literal("issue.update"), id, version: z.number().int(), changes: trackerIssueSchema.pick({
267
204
  title: true,
268
205
  description: true,
269
206
  planId: true,
@@ -276,28 +213,2693 @@ var trackerOperationSchema = z2.discriminatedUnion("kind", [
276
213
  agentEligible: true,
277
214
  revision: true
278
215
  }).partial() }),
279
- z2.strictObject({ kind: z2.literal("plan.save"), ...trackerPlanSchema.shape }),
280
- z2.strictObject({ kind: z2.literal("workflow.save"), workflow: deliveryWorkflowSchema, replacements: z2.record(z2.string(), id).default({}) }),
281
- z2.strictObject({ kind: z2.literal("issue.transition"), id, version: z2.number().int(), stageId: id }),
282
- z2.strictObject({ kind: z2.literal("issue.attention"), id, version: z2.number().int(), message: z2.string().trim().min(1).max(1e4), runId: id.optional() }),
283
- z2.strictObject({ kind: z2.literal("issue.resolve"), id, version: z2.number().int(), attentionId: id }),
284
- z2.strictObject({ kind: z2.literal("issue.resume"), id, version: z2.number().int() }),
285
- z2.strictObject({ kind: z2.literal("issue.revision"), id, version: z2.number().int(), revision: id, runId: id }),
286
- z2.strictObject({ kind: z2.literal("issue.comment"), id, commentId: id, body: text }),
287
- z2.strictObject({ kind: z2.literal("issue.evidence"), id, evidenceId: id, evidence: trackerEvidenceSchema.omit({ id: true, author: true, createdAt: true }) }),
288
- z2.strictObject({ kind: z2.literal("import.preview"), input: trackerImportSchema }),
289
- z2.strictObject({ kind: z2.literal("import.commit"), previewId: id })
290
- ]);
291
- var trackerImportPreviewSchema = z2.strictObject({
216
+ z.strictObject({ kind: z.literal("plan.save"), ...trackerPlanSchema.shape }),
217
+ z.strictObject({ kind: z.literal("workflow.save"), workflow: deliveryWorkflowSchema, replacements: z.record(z.string(), id).default({}) }),
218
+ z.strictObject({ kind: z.literal("issue.transition"), id, version: z.number().int(), stageId: id }),
219
+ z.strictObject({ kind: z.literal("issue.attention"), id, version: z.number().int(), message: z.string().trim().min(1).max(1e4), runId: id.optional() }),
220
+ z.strictObject({ kind: z.literal("issue.resolve"), id, version: z.number().int(), attentionId: id }),
221
+ z.strictObject({ kind: z.literal("issue.resume"), id, version: z.number().int() }),
222
+ z.strictObject({ kind: z.literal("issue.revision"), id, version: z.number().int(), revision: id, runId: id }),
223
+ z.strictObject({ kind: z.literal("issue.comment"), id, commentId: id, body: text }),
224
+ z.strictObject({ kind: z.literal("issue.evidence"), id, evidenceId: id, evidence: trackerEvidenceSchema.omit({ id: true, author: true, createdAt: true }) }),
225
+ z.strictObject({ kind: z.literal("import.preview"), input: trackerImportSchema }),
226
+ z.strictObject({ kind: z.literal("import.commit"), previewId: id })
227
+ ]);
228
+ var trackerImportPreviewSchema = z.strictObject({
292
229
  previewId: id,
293
- creates: z2.number().int(),
294
- skips: z2.number().int(),
295
- plans: z2.number().int(),
296
- omissions: z2.array(z2.string())
230
+ creates: z.number().int(),
231
+ skips: z.number().int(),
232
+ plans: z.number().int(),
233
+ omissions: z.array(z.string())
234
+ });
235
+
236
+ // src/work.ts
237
+ import { z as z2 } from "zod";
238
+ var id2 = z2.string().min(1).max(160);
239
+ var timestamp = z2.iso.datetime();
240
+ var title = z2.string().trim().min(1).max(500);
241
+ var markdown = z2.string().max(1e5);
242
+ var version = z2.number().int().nonnegative();
243
+ var workCommandVersion = 1;
244
+ var workPrioritySchema = z2.enum(["none", "low", "normal", "high", "urgent"]);
245
+ var workLifecycleSchema = z2.enum(["active", "archived", "deleted"]);
246
+ var workActorSchema = z2.discriminatedUnion("kind", [
247
+ z2.strictObject({ kind: z2.literal("human"), memberId: id2 }),
248
+ z2.strictObject({ kind: z2.literal("agent"), runId: id2 }),
249
+ z2.strictObject({ kind: z2.literal("system"), component: id2 }),
250
+ z2.strictObject({ kind: z2.literal("external"), principalId: id2 })
251
+ ]);
252
+ var workRefSchema = z2.strictObject({ teamId: id2, id: id2 });
253
+ var workAutomationSchema = z2.object({
254
+ state: z2.enum(["active", "held"]),
255
+ // `reopened` (DRI-304): a transition out of a completed or canceled status holds automation until resumed.
256
+ reason: z2.enum([
257
+ "manual_correction",
258
+ "migration",
259
+ "scope_revised",
260
+ "candidate_changed",
261
+ "reopened",
262
+ // `deployment_changed` (DRI-299): a verified deployment of the current candidate was replaced or retired.
263
+ "deployment_changed",
264
+ // `imported` (DRI-306): an imported Issue placed at a status other than the initial one, until a member resumes.
265
+ "imported"
266
+ ]).nullable(),
267
+ heldBy: workActorSchema.nullable(),
268
+ heldAt: timestamp.nullable(),
269
+ activityId: id2.nullable()
270
+ });
271
+ var workDeliveryRefSchema = z2.object({
272
+ workflowId: id2,
273
+ workflowRevision: version,
274
+ statusId: id2,
275
+ automation: workAutomationSchema
276
+ });
277
+ var workScopeRevisionRefSchema = z2.object({ id: id2, number: z2.number().int().positive() });
278
+ var workIssueSchema = z2.object({
279
+ id: id2,
280
+ teamId: id2,
281
+ number: z2.number().int().positive(),
282
+ identifier: id2,
283
+ title: z2.string(),
284
+ description: z2.string(),
285
+ priority: workPrioritySchema,
286
+ creator: workActorSchema,
287
+ threadId: id2,
288
+ scopeRevision: workScopeRevisionRefSchema,
289
+ delivery: workDeliveryRefSchema.nullable(),
290
+ planId: id2.nullable(),
291
+ parentId: id2.nullable(),
292
+ lifecycle: workLifecycleSchema,
293
+ version,
294
+ createdAt: timestamp,
295
+ updatedAt: timestamp
296
+ });
297
+ var workPlanSchema = z2.object({
298
+ id: id2,
299
+ teamId: id2,
300
+ number: z2.number().int().positive(),
301
+ title: z2.string(),
302
+ description: z2.string(),
303
+ creator: workActorSchema,
304
+ threadId: id2,
305
+ lifecycle: workLifecycleSchema,
306
+ version,
307
+ createdAt: timestamp,
308
+ updatedAt: timestamp
309
+ });
310
+ var workScopeRevisionSchema = z2.object({
311
+ id: id2,
312
+ issueId: id2,
313
+ number: z2.number().int().positive(),
314
+ title: z2.string(),
315
+ description: z2.string(),
316
+ recordedBy: workActorSchema,
317
+ recordedAt: timestamp,
318
+ commandId: id2
319
+ });
320
+ var workActivityKindSchema = z2.enum([
321
+ "issue.created",
322
+ "issue.edited",
323
+ "plan.created",
324
+ "plan.edited",
325
+ "issue.delivery_changed",
326
+ "issue.delivery_migrated",
327
+ "issue.automation_resumed",
328
+ "issue.automation_held",
329
+ "workflow.created",
330
+ "workflow.published",
331
+ "workflow.activated",
332
+ // Plans and sub-Issue trees (DRI-296).
333
+ "plan.archived",
334
+ "plan.unarchived",
335
+ "issue.plan_changed",
336
+ "issue.parent_changed",
337
+ // Lifecycle and tombstones (DRI-304).
338
+ "issue.archived",
339
+ "issue.deleted",
340
+ "issue.restored",
341
+ "plan.deleted",
342
+ "plan.restored",
343
+ // Import commit (DRI-306): an Issue's import provenance and the delivery status it was placed at, as an assertion.
344
+ "issue.imported"
345
+ ]);
346
+ var workActivitySchema = z2.object({
347
+ id: id2,
348
+ seq: z2.number().int().positive(),
349
+ teamId: id2,
350
+ subject: z2.object({ kind: z2.enum(["issue", "plan", "workflow"]), id: id2 }),
351
+ kind: workActivityKindSchema,
352
+ actor: workActorSchema,
353
+ operation: z2.object({ commandId: id2, type: z2.string() }),
354
+ at: timestamp,
355
+ /** Field name → `{from, to}`; `from` is null on creation. */
356
+ changes: z2.record(z2.string(), z2.object({ from: z2.json(), to: z2.json() }))
357
+ });
358
+ var workDeliverySlugSchema = z2.string().regex(/^[a-z0-9][a-z0-9-]{0,63}$/);
359
+ var workDeliveryStatusCategorySchema = z2.enum(["backlog", "unstarted", "started", "completed", "canceled"]);
360
+ var workDeliveryRequirementSchema = z2.string().max(120).regex(/^[a-z][a-z0-9_]*(\.[a-z][a-z0-9_]*)*$/);
361
+ var workDeliveryGateSchema = z2.discriminatedUnion("kind", [
362
+ z2.strictObject({ kind: z2.literal("manual") }),
363
+ z2.strictObject({ kind: z2.literal("evidence"), requirement: workDeliveryRequirementSchema, humanAcceptance: z2.boolean().default(false) })
364
+ ]);
365
+ var statusName = z2.string().trim().min(1).max(100);
366
+ var workDeliveryWorkflowDefinitionSchema = z2.strictObject({
367
+ name: title,
368
+ statuses: z2.array(z2.strictObject({ id: workDeliverySlugSchema, name: statusName, category: workDeliveryStatusCategorySchema })).min(1).max(100),
369
+ /** Every non-retired status exactly once. Presentation only: it defines neither transitions nor creation. */
370
+ order: z2.array(workDeliverySlugSchema).max(100),
371
+ /** Where a new Issue starts. Independent of the order. */
372
+ initialStatusId: workDeliverySlugSchema,
373
+ /** The only legal moves. A status reachable from several others lists them in `from`. */
374
+ transitions: z2.array(z2.strictObject({
375
+ id: workDeliverySlugSchema,
376
+ from: z2.array(workDeliverySlugSchema).min(1).max(100),
377
+ to: workDeliverySlugSchema,
378
+ /** No gates means none: the move is legal for anyone whenever it leaves the current status. */
379
+ gates: z2.array(workDeliveryGateSchema).max(16).default([]),
380
+ /**
381
+ * Whether a member taking this transition manually holds automation. True (the default) for a correction;
382
+ * false for a step a person is meant to take, such as triage or release. Automatic advancement never holds.
383
+ */
384
+ holdsAutomation: z2.boolean().default(true)
385
+ })).max(500),
386
+ /** Which transitions automation may take. A transition with a `manual` gate cannot be one of them. */
387
+ automation: z2.strictObject({ transitionIds: z2.array(workDeliverySlugSchema).max(500).default([]) })
388
+ });
389
+ var workDeliveryMigrationMappingSchema = z2.record(workDeliverySlugSchema, workDeliverySlugSchema);
390
+ var workDeliveryStatusSchema = z2.object({
391
+ id: id2,
392
+ name: z2.string(),
393
+ category: workDeliveryStatusCategorySchema,
394
+ /** A retired status keeps its identity so history stays readable; no Issue occupies it. */
395
+ retired: z2.boolean()
396
+ });
397
+ var workDeliveryTransitionSchema = z2.object({
398
+ id: id2,
399
+ from: z2.array(id2),
400
+ to: id2,
401
+ gates: z2.array(workDeliveryGateSchema),
402
+ holdsAutomation: z2.boolean().default(true)
403
+ });
404
+ var workDeliveryWorkflowRevisionSchema = z2.object({
405
+ workflowId: id2,
406
+ teamId: id2,
407
+ revision: z2.number().int().positive(),
408
+ name: z2.string(),
409
+ statuses: z2.array(workDeliveryStatusSchema),
410
+ order: z2.array(id2),
411
+ initialStatusId: id2,
412
+ transitions: z2.array(workDeliveryTransitionSchema),
413
+ automation: z2.object({ transitionIds: z2.array(id2) }),
414
+ publishedBy: workActorSchema,
415
+ publishedAt: timestamp,
416
+ commandId: id2
417
+ });
418
+ var workDeliveryWorkflowSchema = z2.object({
419
+ id: id2,
420
+ teamId: id2,
421
+ number: z2.number().int().positive(),
422
+ name: z2.string(),
423
+ active: z2.boolean(),
424
+ currentRevision: z2.number().int().positive(),
425
+ version,
426
+ createdAt: timestamp,
427
+ updatedAt: timestamp
428
+ });
429
+ var workDeliveryMigrationSchema = z2.object({
430
+ id: id2,
431
+ seq: z2.number().int().positive(),
432
+ teamId: id2,
433
+ kind: z2.enum(["bootstrap", "revision", "activation"]),
434
+ from: z2.object({ workflowId: id2, revision: z2.number().int().positive() }).nullable(),
435
+ to: z2.object({ workflowId: id2, revision: z2.number().int().positive() }),
436
+ mapping: z2.record(z2.string(), z2.string()),
437
+ issueCount: z2.number().int().nonnegative(),
438
+ remappedCount: z2.number().int().nonnegative(),
439
+ recordedBy: workActorSchema,
440
+ recordedAt: timestamp,
441
+ commandId: id2
442
+ });
443
+ var workDeliveryGateFindingSchema = z2.object({ gate: z2.number().int().nonnegative(), kind: z2.string(), reason: z2.string() });
444
+ var workIssueTransitionsSchema = z2.object({
445
+ issueId: id2,
446
+ workflowId: id2,
447
+ workflowRevision: z2.number().int().positive(),
448
+ statusId: id2,
449
+ automation: workAutomationSchema,
450
+ transitions: z2.array(z2.object({
451
+ id: id2,
452
+ to: id2,
453
+ automatic: z2.boolean(),
454
+ /** Whether the caller's manual transition would pass every gate now (without an acceptance). */
455
+ satisfied: z2.boolean(),
456
+ unmet: z2.array(workDeliveryGateFindingSchema)
457
+ }))
458
+ });
459
+ var workPageSchema = (item) => z2.object({ items: z2.array(item), nextCursor: z2.string().nullable() });
460
+ var workIssuePageSchema = workPageSchema(workIssueSchema);
461
+ var workPlanPageSchema = workPageSchema(workPlanSchema);
462
+ var workActivityPageSchema = workPageSchema(workActivitySchema);
463
+ var workScopeRevisionPageSchema = workPageSchema(workScopeRevisionSchema);
464
+ var workDeliveryWorkflowPageSchema = workPageSchema(workDeliveryWorkflowSchema);
465
+ var workDeliveryWorkflowRevisionPageSchema = workPageSchema(workDeliveryWorkflowRevisionSchema);
466
+ var workDeliveryMigrationPageSchema = workPageSchema(workDeliveryMigrationSchema);
467
+ var workPageLimits = { default: 50, max: 200 };
468
+ var envelope = {
469
+ version: z2.literal(workCommandVersion),
470
+ /** The caller's idempotency key, retained for retries. Scoped by Team and the authenticated principal. */
471
+ commandId: z2.string().min(1).max(200),
472
+ /** The Team the command is for; it must be the Team of the route. */
473
+ teamId: id2
474
+ };
475
+ var issueTarget = z2.strictObject({ kind: z2.literal("issue"), id: id2 });
476
+ var planTarget = z2.strictObject({ kind: z2.literal("plan"), id: id2 });
477
+ var workflowTarget = z2.strictObject({ kind: z2.literal("workflow"), id: id2 });
478
+ var candidateId = id2.nullable().default(null);
479
+ var lifecycleReason = z2.strictObject({ reason: z2.string().trim().min(1).max(2e3).nullable().default(null) });
480
+ var workCommandSchema = z2.discriminatedUnion("type", [
481
+ z2.strictObject({
482
+ ...envelope,
483
+ type: z2.literal("issue.create"),
484
+ payload: z2.strictObject({
485
+ title,
486
+ description: markdown.default(""),
487
+ priority: workPrioritySchema.default("none"),
488
+ plan: workRefSchema.nullable().default(null),
489
+ parent: workRefSchema.nullable().default(null)
490
+ })
491
+ }),
492
+ z2.strictObject({
493
+ ...envelope,
494
+ type: z2.literal("issue.edit"),
495
+ target: issueTarget,
496
+ expectedVersion: version,
497
+ payload: z2.strictObject({
498
+ title: title.optional(),
499
+ description: markdown.optional(),
500
+ priority: workPrioritySchema.optional(),
501
+ /**
502
+ * Whether this edit changes the requirements being delivered. `revise` publishes a new scope revision;
503
+ * `unchanged` (a typo, a retitle, a priority change) does not. Required: the caller decides, never inference.
504
+ */
505
+ scope: z2.enum(["revise", "unchanged"])
506
+ })
507
+ }),
508
+ z2.strictObject({
509
+ ...envelope,
510
+ type: z2.literal("plan.create"),
511
+ payload: z2.strictObject({ title, description: markdown.default("") })
512
+ }),
513
+ z2.strictObject({
514
+ ...envelope,
515
+ type: z2.literal("plan.edit"),
516
+ target: planTarget,
517
+ expectedVersion: version,
518
+ payload: z2.strictObject({ title: title.optional(), description: markdown.optional() })
519
+ }),
520
+ // ── Plans and sub-Issue trees (DRI-296) ──
521
+ /**
522
+ * Archives an active Plan. Its Issues keep their membership, versions and Activity; an archived Plan accepts no
523
+ * new member Issue and no edit until it is unarchived. Deletion and tombstones are DRI-304's.
524
+ */
525
+ z2.strictObject({
526
+ ...envelope,
527
+ type: z2.literal("plan.archive"),
528
+ target: planTarget,
529
+ expectedVersion: version,
530
+ payload: z2.strictObject({})
531
+ }),
532
+ /** Makes an archived Plan active again, with the same identity, number and Thread. */
533
+ z2.strictObject({
534
+ ...envelope,
535
+ type: z2.literal("plan.unarchive"),
536
+ target: planTarget,
537
+ expectedVersion: version,
538
+ payload: z2.strictObject({})
539
+ }),
540
+ /**
541
+ * Moves an Issue into an active Plan of its Team, or out of its Plan (`plan: null`). An Issue has zero or one Plan.
542
+ * `expectedVersion` is the Issue's; the Plans' versions and Activity do not change.
543
+ */
544
+ z2.strictObject({
545
+ ...envelope,
546
+ type: z2.literal("issue.set_plan"),
547
+ target: issueTarget,
548
+ expectedVersion: version,
549
+ payload: z2.strictObject({ plan: workRefSchema.nullable() })
550
+ }),
551
+ /**
552
+ * Sets an Issue's one parent to an active Issue of its Team, or clears it (`parent: null`). The Issue's `parentId`
553
+ * is the only record of parentage. Refused when it would make the Issue its own parent (`self_parent`) or its own
554
+ * ancestor (`hierarchy_cycle`). It changes neither Issue's Plan, delivery status nor the parent's version.
555
+ */
556
+ z2.strictObject({
557
+ ...envelope,
558
+ type: z2.literal("issue.set_parent"),
559
+ target: issueTarget,
560
+ expectedVersion: version,
561
+ payload: z2.strictObject({ parent: workRefSchema.nullable() })
562
+ }),
563
+ // ── end DRI-296 ──
564
+ // ── Lifecycle and tombstones (DRI-304) ──
565
+ /**
566
+ * Archives an active Issue. It keeps its delivery status, Plan, parent, Thread and source bindings; while archived
567
+ * it takes no ordinary edit (`not_active`). Refused while an execution reservation is held (`issue_occupied`).
568
+ */
569
+ z2.strictObject({
570
+ ...envelope,
571
+ type: z2.literal("issue.archive"),
572
+ target: issueTarget,
573
+ expectedVersion: version,
574
+ payload: lifecycleReason
575
+ }),
576
+ /**
577
+ * Tombstones an active or archived Issue (soft delete). It keeps its ID, number (never reused), Thread, source keys
578
+ * and history; every ordinary edit is then `tombstoned`, and an import cannot recreate it. Refused while an
579
+ * execution reservation is held (`issue_occupied`). It cancels, reparents or moves nothing else.
580
+ */
581
+ z2.strictObject({
582
+ ...envelope,
583
+ type: z2.literal("issue.delete"),
584
+ target: issueTarget,
585
+ expectedVersion: version,
586
+ payload: lifecycleReason
587
+ }),
588
+ /** Brings an archived or tombstoned Issue back to `active`, explicitly and attributed. The only way back. */
589
+ z2.strictObject({
590
+ ...envelope,
591
+ type: z2.literal("issue.restore"),
592
+ target: issueTarget,
593
+ expectedVersion: version,
594
+ payload: lifecycleReason
595
+ }),
596
+ /** Tombstones an active or archived Plan. Its Issues keep their membership; it accepts no new member. */
597
+ z2.strictObject({
598
+ ...envelope,
599
+ type: z2.literal("plan.delete"),
600
+ target: planTarget,
601
+ expectedVersion: version,
602
+ payload: lifecycleReason
603
+ }),
604
+ /** Brings an archived or tombstoned Plan back to `active`. */
605
+ z2.strictObject({
606
+ ...envelope,
607
+ type: z2.literal("plan.restore"),
608
+ target: planTarget,
609
+ expectedVersion: version,
610
+ payload: lifecycleReason
611
+ }),
612
+ // ── end DRI-304 ──
613
+ /**
614
+ * A member's manual delivery transition. It passes the same gates as automation and then holds automation.
615
+ * `acceptance` records an audited human acceptance for evidence gates that allow one; `candidateId` names the
616
+ * candidate whose evidence the gates evaluate (DRI-298).
617
+ */
618
+ z2.strictObject({
619
+ ...envelope,
620
+ type: z2.literal("issue.transition"),
621
+ target: issueTarget,
622
+ expectedVersion: version,
623
+ payload: z2.strictObject({
624
+ transitionId: workDeliverySlugSchema,
625
+ candidateId,
626
+ acceptance: z2.strictObject({ reason: z2.string().trim().min(1).max(2e3) }).nullable().default(null)
627
+ })
628
+ }),
629
+ /**
630
+ * Automatic advancement: take the one eligible automatic transition out of the current status. Refused while
631
+ * automation is held; more than one eligible transition needs an explicit `choice`.
632
+ */
633
+ z2.strictObject({
634
+ ...envelope,
635
+ type: z2.literal("issue.advance"),
636
+ target: issueTarget,
637
+ expectedVersion: version,
638
+ payload: z2.strictObject({ choice: workDeliverySlugSchema.nullable().default(null), candidateId })
639
+ }),
640
+ /** Ends an automation hold explicitly and reevaluates which automatic transitions are now eligible. */
641
+ z2.strictObject({
642
+ ...envelope,
643
+ type: z2.literal("issue.resume"),
644
+ target: issueTarget,
645
+ expectedVersion: version,
646
+ payload: z2.strictObject({})
647
+ }),
648
+ /** A new, inactive delivery workflow with its first revision. Team admin authority. */
649
+ z2.strictObject({
650
+ ...envelope,
651
+ type: z2.literal("workflow.create"),
652
+ payload: workDeliveryWorkflowDefinitionSchema
653
+ }),
654
+ /**
655
+ * Publishes the next immutable revision of a workflow. `expectedVersion` is the workflow's version, so a stale
656
+ * edit is refused. A status left out is retired; an occupied one needs a `migration` replacement.
657
+ */
658
+ z2.strictObject({
659
+ ...envelope,
660
+ type: z2.literal("workflow.publish"),
661
+ target: workflowTarget,
662
+ expectedVersion: version,
663
+ payload: z2.strictObject({ definition: workDeliveryWorkflowDefinitionSchema, migration: workDeliveryMigrationMappingSchema.default({}) })
664
+ }),
665
+ /** Makes a workflow the Team's active one, moving every Issue by an explicit mapping of its occupied statuses. */
666
+ z2.strictObject({
667
+ ...envelope,
668
+ type: z2.literal("workflow.activate"),
669
+ target: workflowTarget,
670
+ expectedVersion: version,
671
+ payload: z2.strictObject({ migration: workDeliveryMigrationMappingSchema.default({}) })
672
+ })
673
+ ]);
674
+ var workCommandResultSchema = z2.object({
675
+ commandId: id2,
676
+ type: z2.string(),
677
+ teamId: id2,
678
+ status: z2.enum(["accepted", "completed"]),
679
+ replayed: z2.boolean(),
680
+ recordedAt: timestamp,
681
+ activityId: id2,
682
+ outcome: z2.discriminatedUnion("kind", [
683
+ z2.object({ kind: z2.literal("issue"), issue: workIssueSchema }),
684
+ z2.object({ kind: z2.literal("plan"), plan: workPlanSchema }),
685
+ z2.object({
686
+ kind: z2.literal("workflow"),
687
+ workflow: workDeliveryWorkflowSchema,
688
+ revision: workDeliveryWorkflowRevisionSchema,
689
+ migration: workDeliveryMigrationSchema.nullable()
690
+ })
691
+ ])
692
+ });
693
+ var workErrorCodes = [
694
+ "unauthorized",
695
+ "forbidden",
696
+ "not_found",
697
+ "invalid_request",
698
+ "payload_too_large",
699
+ "team_mismatch",
700
+ "foreign_team_reference",
701
+ "unknown_reference",
702
+ "version_conflict",
703
+ "idempotency_conflict",
704
+ "no_change",
705
+ "not_active",
706
+ // Delivery workflows (DRI-297). `invalid_workflow` carries `reason` and `subject`; `migration_required` the
707
+ // unmapped `statuses`; `gate_unsatisfied` the `transitionId` and `unmet` findings; `ambiguous_transition` the
708
+ // `eligible` transition IDs; `no_eligible_transition` each automatic `candidates` entry with its `unmet` findings.
709
+ "invalid_workflow",
710
+ "migration_required",
711
+ "transition_not_allowed",
712
+ "gate_unsatisfied",
713
+ "ambiguous_transition",
714
+ "no_eligible_transition",
715
+ "automation_held",
716
+ // Plans and sub-Issue trees (DRI-296): an Issue named as its own parent, or a parent that is its descendant.
717
+ "self_parent",
718
+ "hierarchy_cycle",
719
+ // Lifecycle and tombstones (DRI-304): an ordinary edit of a deleted Issue or Plan; archival or deletion of an
720
+ // Issue whose execution reservation is held (with `owner` and `reservation` once DRI-310 supplies them).
721
+ "tombstoned",
722
+ "issue_occupied",
723
+ // Restoring an Issue whose Plan or parent is a tombstone: restore that first.
724
+ "plan_tombstoned",
725
+ "parent_tombstoned"
726
+ ];
727
+
728
+ // src/work-attention.ts
729
+ import { z as z3 } from "zod";
730
+ var id3 = z3.string().min(1).max(160);
731
+ var timestamp2 = z3.iso.datetime();
732
+ var version2 = z3.number().int().nonnegative();
733
+ var message = z3.string().trim().min(1).max(1e4);
734
+ var workManualAttentionReasonSchema = z3.enum(["requirements", "decision", "approval", "access", "blocked", "other"]);
735
+ var workRunAttentionReasonSchema = z3.enum(["permission", "question", "guidance", "recovery"]);
736
+ var workAttentionReasonSchema = z3.enum([...workManualAttentionReasonSchema.options, ...workRunAttentionReasonSchema.options]);
737
+ var workAttentionRunRefSchema = z3.object({
738
+ runId: id3,
739
+ interruptionId: id3.nullable(),
740
+ interruptionRevision: z3.number().int().positive().nullable()
741
+ });
742
+ var workAttentionResolutionSchema = z3.object({
743
+ kind: z3.enum(["answered", "dismissed", "run_interruption_closed"]),
744
+ note: z3.string().nullable(),
745
+ /** For `run_interruption_closed`: what the Run did. */
746
+ runState: z3.enum(["answered", "closed", "superseded"]).nullable(),
747
+ by: workActorSchema,
748
+ at: timestamp2,
749
+ commandId: id3
750
+ });
751
+ var workAttentionRequestSchema = z3.object({
752
+ id: id3,
753
+ teamId: id3,
754
+ issueId: id3,
755
+ origin: z3.enum(["manual", "run"]),
756
+ reason: workAttentionReasonSchema,
757
+ message: z3.string(),
758
+ /** Who must act. Only human requests exist today; they make up the Issue's Needs Human projection. */
759
+ respondent: z3.enum(["human"]),
760
+ /** Attributed requester: the member, or the Run (`agent`) whose interruption it projects. */
761
+ requestedBy: workActorSchema,
762
+ run: workAttentionRunRefSchema.nullable(),
763
+ state: z3.enum(["open", "resolved"]),
764
+ resolution: workAttentionResolutionSchema.nullable(),
765
+ /** The request's own optimistic version; the Issue's version never moves with attention. */
766
+ version: z3.number().int().positive(),
767
+ createdAt: timestamp2,
768
+ updatedAt: timestamp2
769
+ });
770
+ var workExecutionPolicySchema = z3.object({
771
+ issueId: id3,
772
+ teamId: id3,
773
+ agentEligible: z3.boolean(),
774
+ hold: z3.object({ reason: z3.string(), heldBy: workActorSchema, heldAt: timestamp2, commandId: id3 }).nullable(),
775
+ version: version2,
776
+ updatedAt: timestamp2.nullable()
777
+ });
778
+ var workAttentionActivityKindSchema = z3.enum([
779
+ "attention.requested",
780
+ "attention.updated",
781
+ "attention.resolved",
782
+ "execution_policy.held",
783
+ "execution_policy.resumed",
784
+ "execution_policy.eligibility_changed"
785
+ ]);
786
+ var workAttentionActivitySchema = workActivitySchema.extend({
787
+ subject: z3.object({ kind: z3.enum(["attention", "execution_policy"]), id: id3 }),
788
+ kind: workAttentionActivityKindSchema
789
+ });
790
+ var workAttentionRequestPageSchema = workPageSchema(workAttentionRequestSchema);
791
+ var workAttentionActivityPageSchema = workPageSchema(workAttentionActivitySchema);
792
+ var envelope2 = { version: z3.literal(workCommandVersion), commandId: z3.string().min(1).max(200), teamId: id3 };
793
+ var issueTarget2 = z3.strictObject({ kind: z3.literal("issue"), id: id3 });
794
+ var workAttentionCommandSchema = z3.discriminatedUnion("type", [
795
+ /** A member asks for human attention on an Issue. It edits neither the Issue nor its delivery. */
796
+ z3.strictObject({
797
+ ...envelope2,
798
+ type: z3.literal("attention.request"),
799
+ target: issueTarget2,
800
+ payload: z3.strictObject({
801
+ reason: workManualAttentionReasonSchema,
802
+ message,
803
+ /** Context only: a Run the member can see. It is not an interruption and answers nothing. */
804
+ runId: id3.nullable().default(null)
805
+ })
806
+ }),
807
+ /** A member resolves one request at its version. A Run-origin request whose interruption is pending is refused. */
808
+ z3.strictObject({
809
+ ...envelope2,
810
+ type: z3.literal("attention.resolve"),
811
+ target: z3.strictObject({ kind: z3.literal("attention"), id: id3 }),
812
+ expectedVersion: z3.number().int().positive(),
813
+ payload: z3.strictObject({ resolution: z3.enum(["answered", "dismissed"]), note: z3.string().max(1e4).nullable().default(null) })
814
+ }),
815
+ /**
816
+ * Reconciles the Issue's Run-origin requests from the Run's authoritative state (an organization-visible Run; the
817
+ * Issue is the caller's choice until DRI-310 binds Runs to Issues): opens a request for its pending
818
+ * human interruption, refreshes one whose revision moved, and resolves those the Run has answered, closed or
819
+ * replaced. The same interruption is always the same request.
820
+ */
821
+ z3.strictObject({ ...envelope2, type: z3.literal("attention.sync_run"), target: issueTarget2, payload: z3.strictObject({ runId: id3 }) }),
822
+ z3.strictObject({
823
+ ...envelope2,
824
+ type: z3.literal("execution_policy.hold"),
825
+ target: issueTarget2,
826
+ expectedVersion: version2,
827
+ payload: z3.strictObject({ reason: z3.string().trim().min(1).max(2e3) })
828
+ }),
829
+ z3.strictObject({
830
+ ...envelope2,
831
+ type: z3.literal("execution_policy.resume"),
832
+ target: issueTarget2,
833
+ expectedVersion: version2,
834
+ payload: z3.strictObject({})
835
+ }),
836
+ z3.strictObject({
837
+ ...envelope2,
838
+ type: z3.literal("execution_policy.set_agent_eligibility"),
839
+ target: issueTarget2,
840
+ expectedVersion: version2,
841
+ payload: z3.strictObject({ agentEligible: z3.boolean() })
842
+ })
843
+ ]);
844
+ var workAttentionCommandTypes = workAttentionCommandSchema.options.map((o) => o.shape.type.value);
845
+ function isWorkAttentionCommand(raw) {
846
+ const type = raw?.type;
847
+ return typeof type === "string" && workAttentionCommandTypes.includes(type);
848
+ }
849
+ var workAttentionCommandResultSchema = z3.object({
850
+ commandId: id3,
851
+ type: z3.string(),
852
+ teamId: id3,
853
+ status: z3.enum(["accepted", "completed"]),
854
+ replayed: z3.boolean(),
855
+ recordedAt: timestamp2,
856
+ activityId: id3,
857
+ outcome: z3.discriminatedUnion("kind", [
858
+ z3.object({ kind: z3.literal("attention"), attention: workAttentionRequestSchema }),
859
+ /** The requests a reconciliation opened, refreshed or resolved, in that order of decision. */
860
+ z3.object({ kind: z3.literal("attention_sync"), requests: z3.array(workAttentionRequestSchema) }),
861
+ z3.object({ kind: z3.literal("execution_policy"), policy: workExecutionPolicySchema })
862
+ ])
863
+ });
864
+ var workAttentionErrorCodes = ["not_open", "interruption_pending", "run_not_team_visible"];
865
+
866
+ // src/work-sources.ts
867
+ import { z as z4 } from "zod";
868
+ var id4 = z4.string().min(1).max(160);
869
+ var timestamp3 = z4.iso.datetime();
870
+ var sourceTimestamp = z4.iso.datetime({ offset: true });
871
+ var version3 = z4.number().int().nonnegative();
872
+ var token = z4.string().min(1).max(200).regex(/^\S(?:.*\S)?$/, "no surrounding whitespace");
873
+ var externalId = z4.string().min(1).max(500);
874
+ var readable = z4.string().trim().min(1).max(500);
875
+ var url = z4.url({ protocol: /^https?$/ }).max(2e3);
876
+ var workSourceContainerSchema = z4.strictObject({
877
+ kind: token,
878
+ id: externalId,
879
+ name: readable.nullable().default(null)
880
+ });
881
+ var workSourceTargetSchema = z4.strictObject({ kind: z4.enum(["issue", "plan"]), id: id4 });
882
+ var workSourceKeySchema = z4.strictObject({ spaceId: id4, entityKind: token, idNamespace: token, externalId });
883
+ var workSourceSpaceSchema = z4.object({
884
+ id: id4,
885
+ teamId: id4,
886
+ provider: z4.string(),
887
+ instance: z4.string(),
888
+ workspaceId: z4.string(),
889
+ displayName: z4.string().nullable(),
890
+ recordedBy: workActorSchema,
891
+ version: version3,
892
+ createdAt: timestamp3,
893
+ updatedAt: timestamp3
894
+ });
895
+ var workSourcePrincipalSchema = z4.object({
896
+ id: id4,
897
+ teamId: id4,
898
+ spaceId: id4,
899
+ idNamespace: z4.string(),
900
+ externalId: z4.string(),
901
+ displayName: z4.string().nullable(),
902
+ /** The member this external identity is explicitly mapped to, or null. Never inferred from a name or email. */
903
+ memberId: id4.nullable(),
904
+ recordedBy: workActorSchema,
905
+ version: version3,
906
+ createdAt: timestamp3,
907
+ updatedAt: timestamp3
908
+ });
909
+ var workSourceReferenceSchema = z4.object({
910
+ id: id4,
911
+ teamId: id4,
912
+ key: z4.object({ spaceId: id4, entityKind: z4.string(), idNamespace: z4.string(), externalId: z4.string() }),
913
+ containers: z4.array(z4.object({ kind: z4.string(), id: z4.string(), name: z4.string().nullable() })),
914
+ /** The readable source identifier as last observed (a mutable alias, not identity); null when unknown or empty. */
915
+ identifier: z4.string().nullable(),
916
+ url: z4.string().nullable(),
917
+ sourceCreatedAt: z4.string().nullable(),
918
+ sourceUpdatedAt: z4.string().nullable(),
919
+ /**
920
+ * Who authored the source record: an external source principal, or null when unknown. Set once, when the reference
921
+ * is recorded (an import supplies it); `observe` never changes it.
922
+ */
923
+ author: z4.object({ kind: z4.literal("external"), principalId: id4 }).nullable(),
924
+ /** The member who recorded this reference in Drisp. Distinct from `author`. */
925
+ recordedBy: workActorSchema,
926
+ /** The Issue or Plan this reference is explicitly associated with now, or null when detached. */
927
+ target: z4.object({ kind: z4.enum(["issue", "plan"]), id: id4 }).nullable(),
928
+ version: version3,
929
+ createdAt: timestamp3,
930
+ updatedAt: timestamp3
931
+ });
932
+ var workSourceAliasSchema = z4.object({
933
+ seq: z4.number().int().positive(),
934
+ referenceId: id4,
935
+ kind: z4.enum(["key", "identifier"]),
936
+ idNamespace: z4.string().nullable(),
937
+ value: z4.string(),
938
+ recordedAt: timestamp3,
939
+ commandId: id4
940
+ });
941
+ var workSourceAssociationSchema = z4.object({
942
+ seq: z4.number().int().positive(),
943
+ referenceId: id4,
944
+ from: workSourceTargetSchema.nullable(),
945
+ to: workSourceTargetSchema.nullable(),
946
+ actor: workActorSchema,
947
+ commandId: id4,
948
+ activityId: id4,
949
+ at: timestamp3
950
+ });
951
+ var workSourceActivityKindSchema = z4.enum([
952
+ "source_space.registered",
953
+ "source_principal.recorded",
954
+ "source_principal.mapped",
955
+ "source_reference.recorded",
956
+ "source_reference.observed",
957
+ "source_reference.associated",
958
+ "source_reference.key_aliased"
959
+ ]);
960
+ var workSourceActivitySchema = z4.object({
961
+ id: id4,
962
+ seq: z4.number().int().positive(),
963
+ teamId: id4,
964
+ subject: z4.object({ kind: z4.enum(["source_space", "source_principal", "source_reference"]), id: id4 }),
965
+ kind: workSourceActivityKindSchema,
966
+ actor: workActorSchema,
967
+ operation: z4.object({ commandId: id4, type: z4.string() }),
968
+ at: timestamp3,
969
+ changes: z4.record(z4.string(), z4.object({ from: z4.json(), to: z4.json() }))
970
+ });
971
+ var workSourceSpacePageSchema = workPageSchema(workSourceSpaceSchema);
972
+ var workSourcePrincipalPageSchema = workPageSchema(workSourcePrincipalSchema);
973
+ var workSourceReferencePageSchema = workPageSchema(workSourceReferenceSchema);
974
+ var workSourceAliasPageSchema = workPageSchema(workSourceAliasSchema);
975
+ var workSourceAssociationPageSchema = workPageSchema(workSourceAssociationSchema);
976
+ var workSourceActivityPageSchema = workPageSchema(workSourceActivitySchema);
977
+ var envelope3 = {
978
+ version: z4.literal(workCommandVersion),
979
+ commandId: z4.string().min(1).max(200),
980
+ teamId: id4
981
+ };
982
+ var principalTarget = z4.strictObject({ kind: z4.literal("source_principal"), id: id4 });
983
+ var referenceTarget = z4.strictObject({ kind: z4.literal("source_reference"), id: id4 });
984
+ var associationTarget = z4.strictObject({ kind: z4.enum(["issue", "plan"]), teamId: id4, id: id4 });
985
+ var workSourceCommandSchema = z4.discriminatedUnion("type", [
986
+ z4.strictObject({
987
+ ...envelope3,
988
+ type: z4.literal("source_space.register"),
989
+ payload: z4.strictObject({ provider: token, instance: token, workspaceId: externalId, displayName: readable.nullable().default(null) })
990
+ }),
991
+ z4.strictObject({
992
+ ...envelope3,
993
+ type: z4.literal("source_principal.record"),
994
+ payload: z4.strictObject({ spaceId: id4, idNamespace: token, externalId, displayName: readable.nullable().default(null) })
995
+ }),
996
+ z4.strictObject({
997
+ ...envelope3,
998
+ type: z4.literal("source_principal.map"),
999
+ target: principalTarget,
1000
+ expectedVersion: version3,
1001
+ payload: z4.strictObject({ memberId: id4.nullable() })
1002
+ }),
1003
+ z4.strictObject({
1004
+ ...envelope3,
1005
+ type: z4.literal("source_reference.record"),
1006
+ payload: z4.strictObject({
1007
+ key: workSourceKeySchema,
1008
+ containers: z4.array(workSourceContainerSchema).max(20).default([]),
1009
+ identifier: readable.nullable().default(null),
1010
+ url: url.nullable().default(null),
1011
+ sourceCreatedAt: sourceTimestamp.nullable().default(null),
1012
+ sourceUpdatedAt: sourceTimestamp.nullable().default(null),
1013
+ /** A source principal in the same space, or null when the author is unknown. */
1014
+ authorPrincipalId: id4.nullable().default(null),
1015
+ target: associationTarget.nullable().default(null)
1016
+ })
1017
+ }),
1018
+ z4.strictObject({
1019
+ ...envelope3,
1020
+ type: z4.literal("source_reference.observe"),
1021
+ target: referenceTarget,
1022
+ expectedVersion: version3,
1023
+ payload: z4.strictObject({
1024
+ containers: z4.array(workSourceContainerSchema).max(20).optional(),
1025
+ identifier: readable.nullable().optional(),
1026
+ url: url.nullable().optional(),
1027
+ sourceUpdatedAt: sourceTimestamp.nullable().optional()
1028
+ })
1029
+ }),
1030
+ z4.strictObject({
1031
+ ...envelope3,
1032
+ type: z4.literal("source_reference.associate"),
1033
+ target: referenceTarget,
1034
+ expectedVersion: version3,
1035
+ payload: z4.strictObject({ to: associationTarget.nullable() })
1036
+ }),
1037
+ z4.strictObject({
1038
+ ...envelope3,
1039
+ type: z4.literal("source_reference.alias_key"),
1040
+ target: referenceTarget,
1041
+ expectedVersion: version3,
1042
+ payload: z4.strictObject({ idNamespace: token, externalId })
1043
+ })
1044
+ ]);
1045
+ var workSourceCommandTypes = workSourceCommandSchema.options.map((option) => option.shape.type.value);
1046
+ function isWorkSourceCommand(body) {
1047
+ const type = body?.type;
1048
+ return typeof type === "string" && workSourceCommandTypes.includes(type);
1049
+ }
1050
+ var workSourceCommandResultSchema = z4.object({
1051
+ commandId: id4,
1052
+ type: z4.string(),
1053
+ teamId: id4,
1054
+ status: z4.enum(["accepted", "completed"]),
1055
+ replayed: z4.boolean(),
1056
+ recordedAt: timestamp3,
1057
+ activityId: id4,
1058
+ outcome: z4.discriminatedUnion("kind", [
1059
+ z4.object({ kind: z4.literal("source_space"), space: workSourceSpaceSchema }),
1060
+ z4.object({ kind: z4.literal("source_principal"), principal: workSourcePrincipalSchema }),
1061
+ z4.object({ kind: z4.literal("source_reference"), reference: workSourceReferenceSchema })
1062
+ ])
1063
+ });
1064
+ var workSourceErrorCodes = ["source_key_conflict", "unknown_member"];
1065
+
1066
+ // src/work-membership.ts
1067
+ import { z as z5 } from "zod";
1068
+ var id5 = z5.string().min(1).max(160);
1069
+ var timestamp4 = z5.iso.datetime();
1070
+ var version4 = z5.number().int().nonnegative();
1071
+ var workLabelNameSchema = z5.string().trim().min(1).max(80);
1072
+ var workLabelColorSchema = z5.string().regex(/^#[0-9a-fA-F]{6}$/);
1073
+ var workLabelSchema = z5.object({
1074
+ id: id5,
1075
+ teamId: id5,
1076
+ name: z5.string(),
1077
+ color: z5.string().nullable(),
1078
+ description: z5.string(),
1079
+ creator: workActorSchema,
1080
+ /** Only `active` is produced today; archival and tombstones arrive with DRI-304. */
1081
+ lifecycle: workLifecycleSchema,
1082
+ version: z5.number().int().positive(),
1083
+ createdAt: timestamp4,
1084
+ updatedAt: timestamp4
1085
+ });
1086
+ var workMembershipRemovalSchema = z5.object({ by: workActorSchema, at: timestamp4, commandId: id5 });
1087
+ var workIssueAssigneeSchema = z5.object({
1088
+ id: id5,
1089
+ teamId: id5,
1090
+ issueId: id5,
1091
+ memberId: id5,
1092
+ memberActive: z5.boolean(),
1093
+ assignedBy: workActorSchema,
1094
+ assignedAt: timestamp4,
1095
+ commandId: id5,
1096
+ removal: workMembershipRemovalSchema.nullable()
1097
+ });
1098
+ var workIssueLabelSchema = z5.object({
1099
+ id: id5,
1100
+ teamId: id5,
1101
+ issueId: id5,
1102
+ labelId: id5,
1103
+ label: workLabelSchema,
1104
+ addedBy: workActorSchema,
1105
+ addedAt: timestamp4,
1106
+ commandId: id5,
1107
+ removal: workMembershipRemovalSchema.nullable()
1108
+ });
1109
+ var workIssueMembershipSchema = z5.object({
1110
+ issueId: id5,
1111
+ teamId: id5,
1112
+ version: version4,
1113
+ assigneeCount: z5.number().int().nonnegative(),
1114
+ labelCount: z5.number().int().nonnegative(),
1115
+ updatedAt: timestamp4.nullable()
1116
+ });
1117
+ var workMembershipActivityKindSchema = z5.enum([
1118
+ "issue.assignee_added",
1119
+ "issue.assignee_removed",
1120
+ "issue.label_added",
1121
+ "issue.label_removed",
1122
+ "label.created",
1123
+ "label.edited"
1124
+ ]);
1125
+ var workMembershipActivitySchema = workActivitySchema.extend({
1126
+ subject: z5.object({ kind: z5.enum(["issue_membership", "label"]), id: id5 }),
1127
+ kind: workMembershipActivityKindSchema
1128
+ });
1129
+ var workLabelPageSchema = workPageSchema(workLabelSchema);
1130
+ var workIssueAssigneePageSchema = workPageSchema(workIssueAssigneeSchema);
1131
+ var workIssueLabelPageSchema = workPageSchema(workIssueLabelSchema);
1132
+ var workMembershipActivityPageSchema = workPageSchema(workMembershipActivitySchema);
1133
+ var workLabelIssuePageSchema = workPageSchema(workIssueSchema);
1134
+ var envelope4 = { version: z5.literal(workCommandVersion), commandId: z5.string().min(1).max(200), teamId: id5 };
1135
+ var issueTarget3 = z5.strictObject({ kind: z5.literal("issue"), id: id5 });
1136
+ var membershipVersion = version4;
1137
+ var workMembershipCommandSchema = z5.discriminatedUnion("type", [
1138
+ /** Assigns an active member of this Team. A member reference into another Team is `foreign_team_reference`. */
1139
+ z5.strictObject({
1140
+ ...envelope4,
1141
+ type: z5.literal("issue_membership.assign"),
1142
+ target: issueTarget3,
1143
+ expectedVersion: membershipVersion,
1144
+ payload: z5.strictObject({ member: workRefSchema })
1145
+ }),
1146
+ /** Ends a current assignment, attributed; a member who left the Team can still be unassigned. */
1147
+ z5.strictObject({
1148
+ ...envelope4,
1149
+ type: z5.literal("issue_membership.unassign"),
1150
+ target: issueTarget3,
1151
+ expectedVersion: membershipVersion,
1152
+ payload: z5.strictObject({ member: workRefSchema })
1153
+ }),
1154
+ z5.strictObject({
1155
+ ...envelope4,
1156
+ type: z5.literal("issue_membership.add_label"),
1157
+ target: issueTarget3,
1158
+ expectedVersion: membershipVersion,
1159
+ payload: z5.strictObject({ label: workRefSchema })
1160
+ }),
1161
+ z5.strictObject({
1162
+ ...envelope4,
1163
+ type: z5.literal("issue_membership.remove_label"),
1164
+ target: issueTarget3,
1165
+ expectedVersion: membershipVersion,
1166
+ payload: z5.strictObject({ label: workRefSchema })
1167
+ }),
1168
+ z5.strictObject({
1169
+ ...envelope4,
1170
+ type: z5.literal("label.create"),
1171
+ payload: z5.strictObject({
1172
+ name: workLabelNameSchema,
1173
+ color: workLabelColorSchema.nullable().default(null),
1174
+ description: z5.string().max(2e3).default("")
1175
+ })
1176
+ }),
1177
+ /** Renames or recolors a label at its version. Every membership follows: they name the label's ID. */
1178
+ z5.strictObject({
1179
+ ...envelope4,
1180
+ type: z5.literal("label.edit"),
1181
+ target: z5.strictObject({ kind: z5.literal("label"), id: id5 }),
1182
+ expectedVersion: z5.number().int().positive(),
1183
+ payload: z5.strictObject({
1184
+ name: workLabelNameSchema.optional(),
1185
+ color: workLabelColorSchema.nullable().optional(),
1186
+ description: z5.string().max(2e3).optional()
1187
+ })
1188
+ })
1189
+ ]);
1190
+ var workMembershipCommandTypes = workMembershipCommandSchema.options.map((o) => o.shape.type.value);
1191
+ function isWorkMembershipCommand(raw) {
1192
+ const type = raw?.type;
1193
+ return typeof type === "string" && workMembershipCommandTypes.includes(type);
1194
+ }
1195
+ var workMembershipCommandResultSchema = z5.object({
1196
+ commandId: id5,
1197
+ type: z5.string(),
1198
+ teamId: id5,
1199
+ status: z5.enum(["accepted", "completed"]),
1200
+ replayed: z5.boolean(),
1201
+ recordedAt: timestamp4,
1202
+ activityId: id5,
1203
+ outcome: z5.discriminatedUnion("kind", [
1204
+ z5.object({ kind: z5.literal("assignee"), assignee: workIssueAssigneeSchema, membership: workIssueMembershipSchema }),
1205
+ z5.object({ kind: z5.literal("issue_label"), issueLabel: workIssueLabelSchema, membership: workIssueMembershipSchema }),
1206
+ z5.object({ kind: z5.literal("label"), label: workLabelSchema })
1207
+ ])
1208
+ });
1209
+ var workMembershipErrorCodes = ["member_inactive", "label_name_taken"];
1210
+
1211
+ // src/work-evidence.ts
1212
+ import { z as z6 } from "zod";
1213
+ var id6 = z6.string().min(1).max(160);
1214
+ var timestamp5 = z6.iso.datetime();
1215
+ var version5 = z6.number().int().nonnegative();
1216
+ var reason = z6.string().trim().min(1).max(2e3);
1217
+ var slug = z6.string().regex(/^[a-z][a-z0-9_-]{0,63}$/);
1218
+ var workCandidateArtifactSchema = z6.object({
1219
+ kind: z6.enum(["commit", "pull_request", "branch", "build", "other"]),
1220
+ locator: z6.string().trim().min(1).max(500),
1221
+ revision: z6.string().trim().min(1).max(200),
1222
+ url: z6.string().nullable()
1223
+ });
1224
+ var workCandidateDeploymentSchema = z6.object({ environment: slug, id: id6 });
1225
+ var workCandidateQaProfileSchema = z6.enum(["staging", "pre_merge"]);
1226
+ var workCandidateSchema = z6.object({
1227
+ id: id6,
1228
+ teamId: id6,
1229
+ issueId: id6,
1230
+ /** Per Issue, from 1, in proposal order. */
1231
+ number: z6.number().int().positive(),
1232
+ /** The scope revision these artifacts are proposed to satisfy. */
1233
+ scopeRevision: workScopeRevisionRefSchema,
1234
+ artifacts: z6.array(workCandidateArtifactSchema),
1235
+ deployment: workCandidateDeploymentSchema.nullable(),
1236
+ qaProfile: workCandidateQaProfileSchema,
1237
+ proposedBy: workActorSchema,
1238
+ proposedAt: timestamp5,
1239
+ commandId: id6
1240
+ });
1241
+ var workCandidateSelectionSchema = z6.object({
1242
+ issueId: id6,
1243
+ teamId: id6,
1244
+ candidateId: id6.nullable(),
1245
+ version: version5,
1246
+ selectedBy: workActorSchema.nullable(),
1247
+ selectedAt: timestamp5.nullable(),
1248
+ commandId: id6.nullable()
1249
+ });
1250
+ var workEvidenceAssignmentSchema = z6.object({
1251
+ ref: z6.string().trim().min(1).max(200),
1252
+ standing: z6.enum(["open", "closed", "superseded"])
1253
+ });
1254
+ var workEvidenceReferenceSchema = z6.object({ kind: slug, value: z6.string().trim().min(1).max(2e3) });
1255
+ var workEvidenceDecisionSchema = z6.object({ by: workActorSchema, at: timestamp5, reason: z6.string(), commandId: id6 });
1256
+ var workEvidenceApplicabilitySchema = z6.enum([
1257
+ "applicable",
1258
+ "retracted",
1259
+ "superseded",
1260
+ "reported_after_closure",
1261
+ "stale_scope_revision",
1262
+ "stale_candidate",
1263
+ // Deployments and verification attempts (DRI-299): a source's assertion never applies; evidence about a replaced
1264
+ // or retired deployment, or about a verification attempt that is superseded (or, for a production confirmation,
1265
+ // no longer passed), no longer applies.
1266
+ "source_assertion",
1267
+ "stale_deployment",
1268
+ "stale_attempt"
1269
+ ]);
1270
+ var workEvidenceSourceAssertionSchema = z6.object({ source: slug, ref: z6.string().trim().min(1).max(500) });
1271
+ var workEvidenceSchema = z6.object({
1272
+ id: id6,
1273
+ teamId: id6,
1274
+ issueId: id6,
1275
+ /** The fact reported, in requirement form (`pull_request.open`, `pull_request.merged`, `qa.passed`, `run.live`). */
1276
+ kind: workDeliveryRequirementSchema,
1277
+ /** The input tuple the reporter verified. */
1278
+ scopeRevision: workScopeRevisionRefSchema,
1279
+ candidateId: id6.nullable(),
1280
+ /** A deployment record (`dep_…`, DRI-299) of the candidate: for QA, the attempt's; for a release, production's. */
1281
+ deploymentId: id6.nullable(),
1282
+ /**
1283
+ * The verification attempt (`vat_…`, DRI-299) a QA result concludes, or the verified attempt a production
1284
+ * confirmation names (null for a `pre_merge` candidate, verified before merge).
1285
+ */
1286
+ verificationAttemptId: id6.nullable(),
1287
+ runId: id6.nullable(),
1288
+ assignment: workEvidenceAssignmentSchema.nullable(),
1289
+ sourceAssertion: workEvidenceSourceAssertionSchema.nullable(),
1290
+ disposition: z6.enum(["current", "reported_after_closure", "source_assertion"]),
1291
+ /** A member's audited acceptance of evidence reported after closure; only then can it satisfy a gate. */
1292
+ acceptance: workEvidenceDecisionSchema.nullable(),
1293
+ references: z6.array(workEvidenceReferenceSchema),
1294
+ reportedBy: workActorSchema,
1295
+ occurredAt: timestamp5,
1296
+ recordedAt: timestamp5,
1297
+ commandId: id6,
1298
+ supersedes: id6.nullable(),
1299
+ supersededBy: id6.nullable(),
1300
+ retraction: workEvidenceDecisionSchema.nullable(),
1301
+ /** The evidence record's own concurrency version: supersession, retraction and acceptance bump it. */
1302
+ version: z6.number().int().positive(),
1303
+ applicability: workEvidenceApplicabilitySchema
1304
+ });
1305
+ var workEvidenceAutomationSchema = z6.object({
1306
+ status: z6.enum(["advanced", "held", "no_eligible_transition", "ambiguous_transition", "skipped"]),
1307
+ /** For `skipped`: `not_applicable` (the evidence does not apply to the Issue's current inputs). */
1308
+ reason: z6.string().nullable(),
1309
+ /** For `advanced`: the status reached, the Issue version and the transition's Activity. */
1310
+ statusId: id6.nullable(),
1311
+ issueVersion: version5.nullable(),
1312
+ activityId: id6.nullable(),
1313
+ /** For `ambiguous_transition`: the eligible transition IDs. */
1314
+ eligible: z6.array(id6)
1315
+ });
1316
+ var workEvidenceActivityKindSchema = z6.enum([
1317
+ "candidate.proposed",
1318
+ "candidate.selected",
1319
+ "evidence.recorded",
1320
+ "evidence.superseded",
1321
+ "evidence.retracted",
1322
+ "evidence.accepted",
1323
+ // A member's production confirmation (DRI-299): the `release.recorded` evidence it records.
1324
+ "production.confirmed"
1325
+ ]);
1326
+ var workEvidenceActivitySchema = workActivitySchema.extend({
1327
+ subject: z6.object({ kind: z6.enum(["candidate", "candidate_selection", "evidence"]), id: id6 }),
1328
+ kind: workEvidenceActivityKindSchema
1329
+ });
1330
+ var workCandidatePageSchema = workPageSchema(workCandidateSchema);
1331
+ var workEvidencePageSchema = workPageSchema(workEvidenceSchema);
1332
+ var workEvidenceActivityPageSchema = workPageSchema(workEvidenceActivitySchema);
1333
+ var envelope5 = { version: z6.literal(workCommandVersion), commandId: z6.string().min(1).max(200), teamId: id6 };
1334
+ var issueTarget4 = z6.strictObject({ kind: z6.literal("issue"), id: id6 });
1335
+ var evidenceTarget = z6.strictObject({ kind: z6.literal("evidence"), id: id6 });
1336
+ var workEvidenceCommandSchema = z6.discriminatedUnion("type", [
1337
+ /** Proposes an immutable candidate for the Issue's current scope revision. It does not select it. */
1338
+ z6.strictObject({
1339
+ ...envelope5,
1340
+ type: z6.literal("candidate.propose"),
1341
+ target: issueTarget4,
1342
+ payload: z6.strictObject({
1343
+ scopeRevisionId: id6,
1344
+ artifacts: z6.array(z6.strictObject({
1345
+ kind: workCandidateArtifactSchema.shape.kind,
1346
+ locator: workCandidateArtifactSchema.shape.locator,
1347
+ revision: workCandidateArtifactSchema.shape.revision,
1348
+ url: z6.url({ protocol: /^https?$/ }).max(2e3).nullable().default(null)
1349
+ })).min(1).max(20),
1350
+ deployment: z6.strictObject({ environment: slug, id: id6 }).nullable().default(null),
1351
+ qaProfile: workCandidateQaProfileSchema
1352
+ })
1353
+ }),
1354
+ /**
1355
+ * Makes a candidate of the current scope revision the Issue's current one, or none (`null`). `expectedVersion` is
1356
+ * the selection's version. Replacing or clearing a current candidate holds the Issue's automation.
1357
+ */
1358
+ z6.strictObject({
1359
+ ...envelope5,
1360
+ type: z6.literal("candidate.select"),
1361
+ target: issueTarget4,
1362
+ expectedVersion: version5,
1363
+ payload: z6.strictObject({ candidateId: id6.nullable() })
1364
+ }),
1365
+ /**
1366
+ * Records evidence about the input tuple the reporter verified. `supersedes` names the Issue's earlier evidence
1367
+ * this replaces. A member records as themself and cannot name a Run; an in-process reporter supplies its own.
1368
+ */
1369
+ z6.strictObject({
1370
+ ...envelope5,
1371
+ type: z6.literal("evidence.record"),
1372
+ target: issueTarget4,
1373
+ payload: z6.strictObject({
1374
+ kind: workDeliveryRequirementSchema,
1375
+ scopeRevisionId: id6,
1376
+ candidateId: id6.nullable().default(null),
1377
+ deploymentId: id6.nullable().default(null),
1378
+ /** Required for `qa.passed` and `qa.failed` (DRI-299): the attempt the result concludes. */
1379
+ verificationAttemptId: id6.nullable().default(null),
1380
+ runId: id6.nullable().default(null),
1381
+ assignment: z6.strictObject({ ref: workEvidenceAssignmentSchema.shape.ref, standing: workEvidenceAssignmentSchema.shape.standing }).nullable().default(null),
1382
+ occurredAt: timestamp5,
1383
+ references: z6.array(z6.strictObject({ kind: slug, value: workEvidenceReferenceSchema.shape.value })).max(20).default([]),
1384
+ supersedes: id6.nullable().default(null),
1385
+ /** What an imported source said (DRI-299): recorded as history with the disposition `source_assertion`. */
1386
+ sourceAssertion: z6.strictObject({ source: slug, ref: workEvidenceSourceAssertionSchema.shape.ref }).nullable().default(null)
1387
+ })
1388
+ }),
1389
+ /**
1390
+ * A member's production confirmation (DRI-299; root ADR-0017: a Work operation by a human, never a step an
1391
+ * execution waits on). It names the verified attempt on a verification deployment (null only for a `pre_merge`
1392
+ * candidate) and the production deployment of the same, current candidate, and records `release.recorded`
1393
+ * evidence for them, which the Released gate reads. Refused for delegated Run tokens and in-process reporters.
1394
+ */
1395
+ z6.strictObject({
1396
+ ...envelope5,
1397
+ type: z6.literal("production.confirm"),
1398
+ target: issueTarget4,
1399
+ payload: z6.strictObject({
1400
+ verificationAttemptId: id6.nullable(),
1401
+ productionDeploymentId: id6,
1402
+ occurredAt: timestamp5,
1403
+ references: z6.array(z6.strictObject({ kind: slug, value: workEvidenceReferenceSchema.shape.value })).max(20).default([])
1404
+ })
1405
+ }),
1406
+ /** Retracts evidence explicitly, at its version. It stays in history and satisfies nothing. */
1407
+ z6.strictObject({
1408
+ ...envelope5,
1409
+ type: z6.literal("evidence.retract"),
1410
+ target: evidenceTarget,
1411
+ expectedVersion: z6.number().int().positive(),
1412
+ payload: z6.strictObject({ reason })
1413
+ }),
1414
+ /** A member's audited acceptance of evidence reported after closure (ADR-0017), at its version. Human only. */
1415
+ z6.strictObject({
1416
+ ...envelope5,
1417
+ type: z6.literal("evidence.accept"),
1418
+ target: evidenceTarget,
1419
+ expectedVersion: z6.number().int().positive(),
1420
+ payload: z6.strictObject({ reason })
1421
+ })
1422
+ ]);
1423
+ var workEvidenceCommandTypes = workEvidenceCommandSchema.options.map((o) => o.shape.type.value);
1424
+ function isWorkEvidenceCommand(raw) {
1425
+ const type = raw?.type;
1426
+ return typeof type === "string" && workEvidenceCommandTypes.includes(type);
1427
+ }
1428
+ var workEvidenceCommandResultSchema = z6.object({
1429
+ commandId: id6,
1430
+ type: z6.string(),
1431
+ teamId: id6,
1432
+ status: z6.enum(["accepted", "completed"]),
1433
+ replayed: z6.boolean(),
1434
+ recordedAt: timestamp5,
1435
+ activityId: id6,
1436
+ outcome: z6.discriminatedUnion("kind", [
1437
+ z6.object({ kind: z6.literal("candidate"), candidate: workCandidateSchema }),
1438
+ /** `issue` is the Issue when the change held its automation, otherwise null. */
1439
+ z6.object({ kind: z6.literal("candidate_selection"), selection: workCandidateSelectionSchema, issue: workIssueSchema.nullable() }),
1440
+ /** `superseded` is the evidence this record replaced; `automation` is null for a retraction or replay of one. */
1441
+ z6.object({
1442
+ kind: z6.literal("evidence"),
1443
+ evidence: workEvidenceSchema,
1444
+ superseded: workEvidenceSchema.nullable(),
1445
+ automation: workEvidenceAutomationSchema.nullable()
1446
+ })
1447
+ ])
1448
+ });
1449
+ var workEvidenceErrorCodes = ["stale_scope_revision", "evidence_closed", "not_after_closure"];
1450
+
1451
+ // src/work-reservations.ts
1452
+ import { z as z7 } from "zod";
1453
+ var id7 = z7.string().min(1).max(200);
1454
+ var timestamp6 = z7.iso.datetime();
1455
+ var generation = z7.number().int().positive();
1456
+ var workReservationOwnerSchema = z7.object({ kind: z7.literal("run"), runId: id7 });
1457
+ var workOutstandingEffectSchema = z7.object({ id: id7, summary: z7.string().max(2e3) });
1458
+ var workExecutionReservationSchema = z7.object({
1459
+ id: id7,
1460
+ teamId: id7,
1461
+ issueId: id7,
1462
+ owner: workReservationOwnerSchema,
1463
+ /** The Issue's ownership generation this reservation was acquired at. */
1464
+ generation,
1465
+ state: z7.enum(["held", "released"]),
1466
+ /** The authority admission granted the owner; every binding inherits a subset of it. */
1467
+ authority: z7.array(z7.string()),
1468
+ /** The versions the work was admitted against. */
1469
+ scopeRevision: z7.object({ id: id7, number: z7.number().int().positive() }),
1470
+ delivery: z7.object({ workflowId: id7, workflowRevision: z7.number().int().positive(), statusId: id7 }),
1471
+ /** The reservation released before this one on the same Issue (a successor's predecessor), if any. */
1472
+ predecessorId: id7.nullable(),
1473
+ /** Set when the Issue was cancelled while occupied: a recorded request, which releases nothing. */
1474
+ cancelRequest: z7.object({ by: workActorSchema, at: timestamp6, commandId: id7, activityId: id7 }).nullable(),
1475
+ closure: z7.object({
1476
+ outcome: z7.enum(["run_closed", "accepted", "cancelled", "failed", "legacy_run_closed"]),
1477
+ by: workActorSchema,
1478
+ at: timestamp6,
1479
+ commandId: id7,
1480
+ /** The Issue's generation after closure: every binding of `generation` is stale from here on. */
1481
+ releasedGeneration: generation,
1482
+ outstandingEffects: z7.array(workOutstandingEffectSchema),
1483
+ acknowledgement: z7.object({ reason: z7.string() }).nullable()
1484
+ }).nullable(),
1485
+ acquiredBy: workActorSchema,
1486
+ acquiredAt: timestamp6,
1487
+ releasedAt: timestamp6.nullable(),
1488
+ version: z7.number().int().positive()
1489
+ });
1490
+ var workExecutionBindingSchema = z7.object({
1491
+ id: id7,
1492
+ teamId: id7,
1493
+ reservationId: id7,
1494
+ issueId: id7,
1495
+ runId: id7,
1496
+ /** The assignment the Run carries out; for a Run admitted by a start, the start's own activation. */
1497
+ assignmentId: id7,
1498
+ role: z7.string(),
1499
+ generation,
1500
+ /** The applicable input version: the scope revision this Run works against. */
1501
+ scopeRevision: z7.object({ id: id7, number: z7.number().int().positive() }),
1502
+ authority: z7.array(z7.string()),
1503
+ boundBy: workActorSchema,
1504
+ boundAt: timestamp6,
1505
+ commandId: id7
1506
+ });
1507
+ var workIssueReservationSchema = z7.object({
1508
+ issueId: id7,
1509
+ teamId: id7,
1510
+ generation: z7.number().int().nonnegative(),
1511
+ occupied: z7.boolean(),
1512
+ reservation: workExecutionReservationSchema.nullable()
1513
+ });
1514
+ var workLegacyAliasSchema = z7.object({
1515
+ teamId: id7,
1516
+ alias: id7,
1517
+ issueId: id7,
1518
+ recordedBy: workActorSchema,
1519
+ recordedAt: timestamp6,
1520
+ commandId: id7
1521
+ });
1522
+ var workReservationActivityKindSchema = z7.enum([
1523
+ "execution.reserved",
1524
+ "execution.run_bound",
1525
+ "execution.cancel_requested",
1526
+ "execution.released",
1527
+ // Recorded before DRI-364 only.
1528
+ "execution.state_reported",
1529
+ "execution.closed",
1530
+ "execution.legacy_released",
1531
+ "legacy_alias.recorded"
1532
+ ]);
1533
+ var workReservationActivitySchema = workActivitySchema.extend({
1534
+ subject: z7.object({ kind: z7.enum(["reservation", "legacy_alias"]), id: id7 }),
1535
+ kind: workReservationActivityKindSchema
1536
+ });
1537
+ var workExecutionReservationPageSchema = workPageSchema(workExecutionReservationSchema);
1538
+ var workExecutionBindingPageSchema = workPageSchema(workExecutionBindingSchema);
1539
+ var workReservationActivityPageSchema = workPageSchema(workReservationActivitySchema);
1540
+ var envelope6 = { version: z7.literal(workCommandVersion), commandId: z7.string().min(1).max(200), teamId: id7 };
1541
+ var issueTarget5 = z7.strictObject({ kind: z7.literal("issue"), id: id7 });
1542
+ var workReservationCommandSchema = z7.discriminatedUnion("type", [
1543
+ /** Records one exact legacy reference for an Issue (Team admin). */
1544
+ z7.strictObject({
1545
+ ...envelope6,
1546
+ type: z7.literal("legacy_alias.record"),
1547
+ target: issueTarget5,
1548
+ payload: z7.strictObject({ alias: id7 })
1549
+ })
1550
+ ]);
1551
+ var workReservationCommandTypes = workReservationCommandSchema.options.map((o) => o.shape.type.value);
1552
+ function isWorkReservationCommand(raw) {
1553
+ const type = raw?.type;
1554
+ return typeof type === "string" && workReservationCommandTypes.includes(type);
1555
+ }
1556
+ var workReservationCommandResultSchema = z7.object({
1557
+ commandId: id7,
1558
+ type: z7.string(),
1559
+ teamId: id7,
1560
+ status: z7.enum(["accepted", "completed"]),
1561
+ replayed: z7.boolean(),
1562
+ recordedAt: timestamp6,
1563
+ activityId: id7,
1564
+ outcome: z7.discriminatedUnion("kind", [
1565
+ z7.object({ kind: z7.literal("reservation"), reservation: workExecutionReservationSchema }),
1566
+ z7.object({ kind: z7.literal("binding"), binding: workExecutionBindingSchema, reservation: workExecutionReservationSchema }),
1567
+ z7.object({ kind: z7.literal("legacy_alias"), alias: workLegacyAliasSchema })
1568
+ ])
1569
+ });
1570
+ var workReservationErrorCodes = [
1571
+ "issue_run_live",
1572
+ "stale_generation",
1573
+ "scope_revision_conflict",
1574
+ "agent_ineligible",
1575
+ "execution_held",
1576
+ "attention_open",
1577
+ "agent_start_not_allowed",
1578
+ "stale_run_active",
1579
+ "alias_conflict",
1580
+ "issue_occupied"
1581
+ ];
1582
+
1583
+ // src/work-discussion.ts
1584
+ import { z as z8 } from "zod";
1585
+ var id8 = z8.string().min(1).max(160);
1586
+ var timestamp7 = z8.iso.datetime();
1587
+ var version6 = z8.number().int().positive();
1588
+ var sequence = z8.number().int().positive();
1589
+ var workCommentBodySchema = z8.string().trim().min(1).max(1e5);
1590
+ var reason2 = z8.string().trim().max(2e3).nullable().default(null);
1591
+ var url2 = z8.url({ protocol: /^https?$/ }).max(2e3).refine((value) => {
1592
+ const parsed = new URL(value);
1593
+ return parsed.username === "" && parsed.password === "";
1594
+ }, "credentials are not allowed in a link");
1595
+ var workLinkUrlSchema = url2;
1596
+ var workThreadOwnerSchema = z8.object({ kind: z8.enum(["issue", "plan"]), id: id8 });
1597
+ var workThreadSchema = z8.object({ threadId: id8, teamId: id8, owner: workThreadOwnerSchema, boundAt: timestamp7 });
1598
+ var workDiscussionTombstoneSchema = z8.object({ by: workActorSchema, at: timestamp7, commandId: id8, reason: z8.string().nullable() });
1599
+ var workCommentEditSchema = z8.object({ by: workActorSchema, at: timestamp7, commandId: id8 });
1600
+ var workCommentSchema = z8.object({
1601
+ id: id8,
1602
+ teamId: id8,
1603
+ threadId: id8,
1604
+ owner: workThreadOwnerSchema,
1605
+ /** The comment this one replies to, in the same Thread; null for a top-level comment. */
1606
+ parentId: id8.nullable(),
1607
+ /** The current Markdown text; null once the comment is deleted (the tombstone stays readable). */
1608
+ body: z8.string().nullable(),
1609
+ /**
1610
+ * The original author: `human` (a member), `agent` (a Run) or `external` (a source principal); or, for an imported
1611
+ * comment whose source author was not captured, `{kind: "system", component: "import"}` (DRI-307). Decoders (the
1612
+ * CLI and macOS consumers of DRI-342) must accept `system` here.
1613
+ */
1614
+ author: workActorSchema,
1615
+ /** Who recorded it: the member who posted or imported it, or an in-Hub component. */
1616
+ recordedBy: workActorSchema,
1617
+ sourceReferenceId: id8.nullable(),
1618
+ /** The current revision of its text, from 1. */
1619
+ revision: sequence,
1620
+ edited: workCommentEditSchema.nullable(),
1621
+ deletion: workDiscussionTombstoneSchema.nullable(),
1622
+ version: version6,
1623
+ createdAt: timestamp7,
1624
+ updatedAt: timestamp7
1625
+ });
1626
+ var workCommentRevisionSchema = z8.object({
1627
+ commentId: id8,
1628
+ revision: sequence,
1629
+ body: z8.string().nullable(),
1630
+ recordedBy: workActorSchema,
1631
+ at: timestamp7,
1632
+ commandId: id8
297
1633
  });
1634
+ var workAttachmentAvailabilitySchema = z8.enum(["unknown", "available", "unavailable"]);
1635
+ var workAttachmentCheckSchema = z8.object({
1636
+ id: id8,
1637
+ attachmentId: id8,
1638
+ availability: z8.enum(["available", "unavailable"]),
1639
+ httpStatus: z8.number().int().nullable(),
1640
+ detail: z8.string().nullable(),
1641
+ checkedBy: workActorSchema,
1642
+ checkedAt: timestamp7,
1643
+ commandId: id8
1644
+ });
1645
+ var workAttachmentSchema = z8.object({
1646
+ id: id8,
1647
+ teamId: id8,
1648
+ threadId: id8,
1649
+ owner: workThreadOwnerSchema,
1650
+ /** The comment it belongs to, or null when it belongs to the Thread's Issue or Plan. */
1651
+ commentId: id8.nullable(),
1652
+ url: z8.string(),
1653
+ title: z8.string(),
1654
+ mediaType: z8.string().nullable(),
1655
+ sizeBytes: z8.number().int().nullable(),
1656
+ /** The latest check's verdict (`unknown` before any), with that check's ID and time. */
1657
+ availability: z8.object({ state: workAttachmentAvailabilitySchema, checkId: id8.nullable(), checkedAt: timestamp7.nullable() }),
1658
+ /** As a comment's: `human`, `external`, or `system` (`import`) for an imported link with no captured author (DRI-307). */
1659
+ author: workActorSchema,
1660
+ recordedBy: workActorSchema,
1661
+ sourceReferenceId: id8.nullable(),
1662
+ removal: workDiscussionTombstoneSchema.nullable(),
1663
+ version: version6,
1664
+ createdAt: timestamp7,
1665
+ updatedAt: timestamp7
1666
+ });
1667
+ var workTranscriptLinkSchema = z8.object({
1668
+ id: id8,
1669
+ teamId: id8,
1670
+ threadId: id8,
1671
+ owner: workThreadOwnerSchema,
1672
+ access: z8.enum(["visible", "restricted"]),
1673
+ run: z8.object({ runId: id8, attemptId: id8.nullable() }).nullable(),
1674
+ /** Inclusive history sequence range; `throughSeq` null follows the Run's history as it grows. */
1675
+ range: z8.object({ fromSeq: sequence, throughSeq: sequence.nullable() }).nullable(),
1676
+ label: z8.string().nullable(),
1677
+ linkedBy: workActorSchema,
1678
+ linkedAt: timestamp7
1679
+ });
1680
+ var workTranscriptHistorySchema = z8.object({
1681
+ linkId: id8,
1682
+ runId: id8,
1683
+ range: z8.object({ fromSeq: sequence, throughSeq: sequence.nullable() }),
1684
+ /** The last sequence of the range the Run has recorded so far. */
1685
+ through: z8.number().int().nonnegative(),
1686
+ archives: z8.array(z8.object({ id: id8, checksum: z8.string(), firstSeq: sequence, lastSeq: sequence })),
1687
+ batches: z8.array(z8.object({ firstSeq: sequence, records: z8.array(z8.unknown()) }))
1688
+ });
1689
+ var workDiscussionActivityKindSchema = z8.enum([
1690
+ "comment.added",
1691
+ "comment.edited",
1692
+ "comment.deleted",
1693
+ "attachment.linked",
1694
+ "attachment.checked",
1695
+ "attachment.removed",
1696
+ "transcript.linked"
1697
+ ]);
1698
+ var workDiscussionActivitySchema = workActivitySchema.extend({
1699
+ subject: z8.object({ kind: z8.enum(["comment", "attachment", "transcript_link"]), id: id8 }),
1700
+ kind: workDiscussionActivityKindSchema
1701
+ });
1702
+ var workCommentPageSchema = workPageSchema(workCommentSchema);
1703
+ var workCommentRevisionPageSchema = workPageSchema(workCommentRevisionSchema);
1704
+ var workAttachmentPageSchema = workPageSchema(workAttachmentSchema);
1705
+ var workAttachmentCheckPageSchema = workPageSchema(workAttachmentCheckSchema);
1706
+ var workTranscriptLinkPageSchema = workPageSchema(workTranscriptLinkSchema);
1707
+ var workDiscussionActivityPageSchema = workPageSchema(workDiscussionActivitySchema);
1708
+ var envelope7 = { version: z8.literal(workCommandVersion), commandId: z8.string().min(1).max(200), teamId: id8 };
1709
+ var threadTarget = z8.strictObject({ kind: z8.literal("thread"), id: id8 });
1710
+ var commentTarget = z8.strictObject({ kind: z8.literal("comment"), id: id8 });
1711
+ var attachmentTarget = z8.strictObject({ kind: z8.literal("attachment"), id: id8 });
1712
+ var otherAuthor = z8.discriminatedUnion("kind", [
1713
+ z8.strictObject({ kind: z8.literal("external"), principalId: id8 }),
1714
+ z8.strictObject({ kind: z8.literal("agent"), runId: id8 })
1715
+ ]);
1716
+ var workDiscussionCommandSchema = z8.discriminatedUnion("type", [
1717
+ z8.strictObject({
1718
+ ...envelope7,
1719
+ type: z8.literal("comment.add"),
1720
+ target: threadTarget,
1721
+ payload: z8.strictObject({
1722
+ body: workCommentBodySchema,
1723
+ parentId: id8.nullable().default(null),
1724
+ author: otherAuthor.nullable().default(null),
1725
+ sourceReferenceId: id8.nullable().default(null)
1726
+ })
1727
+ }),
1728
+ /** Replaces the text at the comment's version, recording the next revision. */
1729
+ z8.strictObject({
1730
+ ...envelope7,
1731
+ type: z8.literal("comment.edit"),
1732
+ target: commentTarget,
1733
+ expectedVersion: version6,
1734
+ payload: z8.strictObject({ body: workCommentBodySchema })
1735
+ }),
1736
+ /** A soft delete: an attributed tombstone; replies, attachments and history stay. */
1737
+ z8.strictObject({
1738
+ ...envelope7,
1739
+ type: z8.literal("comment.delete"),
1740
+ target: commentTarget,
1741
+ expectedVersion: version6,
1742
+ payload: z8.strictObject({ reason: reason2 })
1743
+ }),
1744
+ z8.strictObject({
1745
+ ...envelope7,
1746
+ type: z8.literal("attachment.link"),
1747
+ target: threadTarget,
1748
+ payload: z8.strictObject({
1749
+ url: url2,
1750
+ title: z8.string().trim().min(1).max(500),
1751
+ mediaType: z8.string().regex(/^[a-z0-9][a-z0-9!#$&^_.+-]*\/[a-z0-9][a-z0-9!#$&^_.+-]*$/i).max(200).nullable().default(null),
1752
+ sizeBytes: z8.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER).nullable().default(null),
1753
+ commentId: id8.nullable().default(null),
1754
+ author: z8.strictObject({ kind: z8.literal("external"), principalId: id8 }).nullable().default(null),
1755
+ sourceReferenceId: id8.nullable().default(null)
1756
+ })
1757
+ }),
1758
+ /** Records one availability observation; every check is kept, the latest is the attachment's state. */
1759
+ z8.strictObject({
1760
+ ...envelope7,
1761
+ type: z8.literal("attachment.check"),
1762
+ target: attachmentTarget,
1763
+ expectedVersion: version6,
1764
+ payload: z8.strictObject({
1765
+ availability: z8.enum(["available", "unavailable"]),
1766
+ httpStatus: z8.number().int().min(100).max(599).nullable().default(null),
1767
+ detail: reason2
1768
+ })
1769
+ }),
1770
+ z8.strictObject({
1771
+ ...envelope7,
1772
+ type: z8.literal("attachment.remove"),
1773
+ target: attachmentTarget,
1774
+ expectedVersion: version6,
1775
+ payload: z8.strictObject({ reason: reason2 })
1776
+ }),
1777
+ /**
1778
+ * Links a range of a Run's history; the caller must be able to see the Run. The Hub records the Run's current
1779
+ * attempt; a given `attemptId` must be that attempt (`invalid_request` otherwise).
1780
+ */
1781
+ z8.strictObject({
1782
+ ...envelope7,
1783
+ type: z8.literal("transcript.link"),
1784
+ target: threadTarget,
1785
+ payload: z8.strictObject({
1786
+ runId: id8,
1787
+ attemptId: id8.nullable().default(null),
1788
+ range: z8.strictObject({ fromSeq: sequence.default(1), throughSeq: sequence.nullable().default(null) }).default({ fromSeq: 1, throughSeq: null }),
1789
+ label: z8.string().trim().max(500).nullable().default(null)
1790
+ })
1791
+ })
1792
+ ]);
1793
+ var workDiscussionCommandTypes = workDiscussionCommandSchema.options.map((o) => o.shape.type.value);
1794
+ function isWorkDiscussionCommand(raw) {
1795
+ const type = raw?.type;
1796
+ return typeof type === "string" && workDiscussionCommandTypes.includes(type);
1797
+ }
1798
+ var workDiscussionCommandResultSchema = z8.object({
1799
+ commandId: id8,
1800
+ type: z8.string(),
1801
+ teamId: id8,
1802
+ status: z8.enum(["accepted", "completed"]),
1803
+ replayed: z8.boolean(),
1804
+ recordedAt: timestamp7,
1805
+ activityId: id8,
1806
+ outcome: z8.discriminatedUnion("kind", [
1807
+ z8.object({ kind: z8.literal("comment"), comment: workCommentSchema }),
1808
+ z8.object({ kind: z8.literal("attachment"), attachment: workAttachmentSchema }),
1809
+ z8.object({ kind: z8.literal("transcript_link"), link: workTranscriptLinkSchema })
1810
+ ])
1811
+ });
1812
+ var workDiscussionErrorCodes = [
1813
+ "run_not_team_visible",
1814
+ "transcript_already_linked",
1815
+ "source_key_conflict",
1816
+ "source_kind_mismatch",
1817
+ "source_target_mismatch"
1818
+ ];
1819
+
1820
+ // src/work-lifecycle.ts
1821
+ import { z as z9 } from "zod";
1822
+ var id9 = z9.string().min(1).max(160);
1823
+ var workLifecycleEventKindSchema = z9.enum([
1824
+ "completed",
1825
+ "canceled",
1826
+ "reopened",
1827
+ "archived",
1828
+ "unarchived",
1829
+ "deleted",
1830
+ "restored"
1831
+ ]);
1832
+ var workLifecycleEventSchema = z9.object({
1833
+ seq: z9.number().int().positive(),
1834
+ teamId: id9,
1835
+ subject: z9.object({ kind: z9.enum(["issue", "plan"]), id: id9 }),
1836
+ event: workLifecycleEventKindSchema,
1837
+ from: z9.string(),
1838
+ to: z9.string(),
1839
+ /**
1840
+ * `requested` on a cancellation: the Issue's cancellation asks Coordination to cancel its execution. It is a
1841
+ * request only, never proof that compute stopped or that a reservation was released (root ADR-0017).
1842
+ */
1843
+ executionCancel: z9.enum(["requested"]).nullable(),
1844
+ /** The attributed Activity that made the change: actor, command, time and `{from, to}` changes. */
1845
+ activity: workActivitySchema
1846
+ });
1847
+ var workLifecycleEventPageSchema = workPageSchema(workLifecycleEventSchema);
1848
+ var workSourceKeyLifecycleSchema = z9.object({
1849
+ key: workSourceKeySchema,
1850
+ referenceId: id9.nullable(),
1851
+ target: workSourceTargetSchema.nullable(),
1852
+ lifecycle: workLifecycleSchema.nullable(),
1853
+ tombstoned: z9.boolean()
1854
+ });
1855
+
1856
+ // src/work-imports.ts
1857
+ import { z as z10 } from "zod";
1858
+ var id10 = z10.string().min(1).max(160);
1859
+ var timestamp8 = z10.iso.datetime();
1860
+ var sourceTimestamp2 = z10.iso.datetime({ offset: true });
1861
+ var version7 = z10.number().int().nonnegative();
1862
+ var token2 = z10.string().min(1).max(200).regex(/^\S(?:.*\S)?$/, "no surrounding whitespace");
1863
+ var externalId2 = z10.string().min(1).max(500);
1864
+ var readable2 = z10.string().trim().min(1).max(500);
1865
+ var reason3 = z10.string().trim().min(1).max(2e3);
1866
+ var markdown2 = z10.string().max(1e5);
1867
+ var url3 = z10.url({ protocol: /^https?$/ }).max(2e3);
1868
+ var title2 = z10.string().trim().min(1).max(500);
1869
+ var workImportFormat = "drisp.normalized-import";
1870
+ var workImportFormatVersion = 1;
1871
+ var workImportKeySchema = z10.strictObject({ idNamespace: token2, externalId: externalId2 });
1872
+ var workImportFieldStates = ["value", "empty", "omitted", "unavailable", "unknown"];
1873
+ function workImportField(value) {
1874
+ return z10.discriminatedUnion("state", [
1875
+ z10.strictObject({ state: z10.literal("value"), value }),
1876
+ z10.strictObject({ state: z10.literal("empty") }),
1877
+ z10.strictObject({ state: z10.literal("omitted"), reason: reason3 }),
1878
+ z10.strictObject({ state: z10.literal("unavailable"), reason: reason3 }),
1879
+ z10.strictObject({ state: z10.literal("unknown") })
1880
+ ]).default({ state: "unknown" });
1881
+ }
1882
+ var field = workImportField;
1883
+ var workImportCollections = [
1884
+ "issues",
1885
+ "containers",
1886
+ "statuses",
1887
+ "principals",
1888
+ "labels",
1889
+ "groups",
1890
+ "comments",
1891
+ "attachments",
1892
+ "relations"
1893
+ ];
1894
+ var workImportCollectionSchema = z10.enum(workImportCollections);
1895
+ var workImportCollectionStateSchema = z10.strictObject({
1896
+ state: z10.enum(["complete", "empty", "partial", "omitted", "unavailable", "unknown"]),
1897
+ reason: reason3.nullable().default(null)
1898
+ });
1899
+ var collectionDefault = { state: "unknown", reason: null };
1900
+ var workImportContainerSchema = z10.strictObject({
1901
+ key: workImportKeySchema,
1902
+ kind: token2,
1903
+ name: readable2,
1904
+ url: field(url3)
1905
+ });
1906
+ var workImportStatusSchema = z10.strictObject({
1907
+ key: workImportKeySchema,
1908
+ name: z10.string().trim().min(1).max(100),
1909
+ category: workDeliveryStatusCategorySchema,
1910
+ position: z10.number().int().nonnegative(),
1911
+ /**
1912
+ * `needs_human`: the source uses this status to ask a person for something ("Needs Human", "Needs Input"). It has
1913
+ * no delivery meaning of its own: the mapping must name the delivery status an Issue keeps and an attention request.
1914
+ */
1915
+ semantics: z10.enum(["needs_human"]).nullable().default(null)
1916
+ });
1917
+ var workImportPrincipalSchema = z10.strictObject({
1918
+ key: workImportKeySchema,
1919
+ kind: z10.enum(["person", "bot", "unknown"]).default("unknown"),
1920
+ displayName: field(readable2)
1921
+ });
1922
+ var workImportLabelSchema = z10.strictObject({
1923
+ /** DRI-295's label name and color rules, so a label the preview would create is one the commit can create. */
1924
+ key: workImportKeySchema,
1925
+ name: workLabelNameSchema,
1926
+ color: field(workLabelColorSchema),
1927
+ /** The source group the label belongs to, if any. Drisp labels are flat: the group is reported, not imported. */
1928
+ group: workImportKeySchema.nullable().default(null)
1929
+ });
1930
+ var workImportGroupSchema = z10.strictObject({
1931
+ key: workImportKeySchema,
1932
+ kind: token2,
1933
+ of: z10.enum(["labels", "principals"]),
1934
+ name: readable2,
1935
+ members: z10.array(workImportKeySchema).max(1e3).default([])
1936
+ });
1937
+ var workImportIssueSchema = z10.strictObject({
1938
+ key: workImportKeySchema,
1939
+ title: title2,
1940
+ identifier: field(readable2),
1941
+ url: field(url3),
1942
+ description: field(markdown2),
1943
+ priority: field(workPrioritySchema),
1944
+ /** A status of the envelope's catalog. */
1945
+ status: field(workImportKeySchema),
1946
+ /** Every container the source record sat in; one may be the import's Plan, the rest stay provenance. */
1947
+ containers: field(z10.array(workImportKeySchema).max(20)),
1948
+ creator: field(workImportKeySchema),
1949
+ assignees: field(z10.array(workImportKeySchema).max(50)),
1950
+ labels: field(z10.array(workImportKeySchema).max(100)),
1951
+ sourceCreatedAt: field(sourceTimestamp2),
1952
+ sourceUpdatedAt: field(sourceTimestamp2)
1953
+ });
1954
+ var workImportRelationSchema = z10.strictObject({
1955
+ kind: z10.enum(["parent", "blocks", "duplicates", "related"]),
1956
+ from: workImportKeySchema,
1957
+ to: workImportKeySchema
1958
+ });
1959
+ var workImportCommentSchema = z10.strictObject({
1960
+ key: workImportKeySchema,
1961
+ issue: workImportKeySchema,
1962
+ parent: workImportKeySchema.nullable().default(null),
1963
+ author: field(workImportKeySchema),
1964
+ /** DRI-303's comment body (trimmed, non-empty); a body that is empty or was not captured is a field state, not a comment. */
1965
+ body: field(workCommentBodySchema),
1966
+ sourceCreatedAt: field(sourceTimestamp2)
1967
+ });
1968
+ var workImportAttachmentSchema = z10.strictObject({
1969
+ /** DRI-303's link rule: http or https, no embedded credentials. */
1970
+ key: workImportKeySchema,
1971
+ issue: workImportKeySchema,
1972
+ title: field(readable2),
1973
+ url: workLinkUrlSchema,
1974
+ availability: z10.enum(["available", "unavailable", "unknown"]).default("unknown"),
1975
+ author: field(workImportKeySchema),
1976
+ sourceCreatedAt: field(sourceTimestamp2),
1977
+ /**
1978
+ * DRI-307: the comment that owns the link, when the source attached it to a comment rather than to the Issue. Left
1979
+ * out (not null) when the link belongs to the Issue, so an envelope without it keeps its canonical form and digest.
1980
+ */
1981
+ comment: workImportKeySchema.optional()
1982
+ });
1983
+ var workImportLimitSchema = z10.strictObject({
1984
+ collection: workImportCollectionSchema,
1985
+ scope: z10.enum(["envelope", "per_issue"]),
1986
+ limit: z10.number().int().positive(),
1987
+ observed: z10.number().int().nonnegative().nullable().default(null),
1988
+ reason: reason3.nullable().default(null)
1989
+ });
1990
+ var workImportUnsupportedSchema = z10.strictObject({
1991
+ semantics: token2,
1992
+ description: reason3,
1993
+ subjects: z10.array(z10.strictObject({ collection: workImportCollectionSchema, key: workImportKeySchema })).max(1e3).default([])
1994
+ });
1995
+ var workImportCompletenessSchema = z10.strictObject({
1996
+ collections: z10.strictObject(Object.fromEntries(workImportCollections.map((c) => [c, workImportCollectionStateSchema.default(collectionDefault)]))),
1997
+ limits: z10.array(workImportLimitSchema).max(100).default([]),
1998
+ unsupported: z10.array(workImportUnsupportedSchema).max(200).default([])
1999
+ });
2000
+ var workImportEnvelopeSchema = z10.strictObject({
2001
+ format: z10.literal(workImportFormat),
2002
+ formatVersion: z10.literal(workImportFormatVersion),
2003
+ adapter: z10.strictObject({ name: token2, version: z10.string().trim().min(1).max(100) }),
2004
+ capturedAt: sourceTimestamp2,
2005
+ /** The one source space every record belongs to; compared exactly with DRI-302's source spaces. */
2006
+ source: z10.strictObject({ provider: token2, instance: token2, workspaceId: externalId2, displayName: readable2.nullable().default(null) }),
2007
+ containers: z10.array(workImportContainerSchema).default([]),
2008
+ statuses: z10.array(workImportStatusSchema).default([]),
2009
+ principals: z10.array(workImportPrincipalSchema).default([]),
2010
+ labels: z10.array(workImportLabelSchema).default([]),
2011
+ groups: z10.array(workImportGroupSchema).default([]),
2012
+ issues: z10.array(workImportIssueSchema).default([]),
2013
+ relations: z10.array(workImportRelationSchema).default([]),
2014
+ comments: z10.array(workImportCommentSchema).default([]),
2015
+ attachments: z10.array(workImportAttachmentSchema).default([]),
2016
+ completeness: workImportCompletenessSchema
2017
+ });
2018
+ var workImportLimits = {
2019
+ issues: 500,
2020
+ containers: 100,
2021
+ statuses: 100,
2022
+ principals: 500,
2023
+ labels: 500,
2024
+ groups: 100,
2025
+ comments: 2e3,
2026
+ attachments: 1e3,
2027
+ relations: 2e3
2028
+ };
2029
+ var workImportBodyLimit = 1536 * 1024;
2030
+ var statusEntry = z10.strictObject({ source: workImportKeySchema, statusId: workDeliverySlugSchema });
2031
+ var needsHumanEntry = z10.strictObject({
2032
+ source: workImportKeySchema,
2033
+ statusId: workDeliverySlugSchema,
2034
+ /** The request's message; when absent the commit derives one naming the source status. */
2035
+ attention: z10.strictObject({ reason: workManualAttentionReasonSchema, message: z10.string().trim().min(1).max(1e4).nullable().default(null) })
2036
+ });
2037
+ var workImportMappingSchema = z10.strictObject({
2038
+ expectedWorkflow: z10.strictObject({ workflowId: id10, revision: z10.number().int().positive() }),
2039
+ statuses: z10.discriminatedUnion("mode", [
2040
+ z10.strictObject({
2041
+ mode: z10.literal("map"),
2042
+ statuses: z10.array(statusEntry).max(100).default([]),
2043
+ needsHuman: z10.array(needsHumanEntry).max(100).default([])
2044
+ }),
2045
+ z10.strictObject({
2046
+ mode: z10.literal("adopt"),
2047
+ name: title2,
2048
+ statuses: z10.array(statusEntry).min(1).max(100),
2049
+ initialStatus: workImportKeySchema,
2050
+ needsHuman: z10.array(needsHumanEntry).max(100).default([])
2051
+ })
2052
+ ]),
2053
+ principals: z10.array(z10.strictObject({ source: workImportKeySchema, memberId: id10 })).max(500).default([]),
2054
+ labels: z10.array(z10.discriminatedUnion("kind", [
2055
+ z10.strictObject({ source: workImportKeySchema, kind: z10.literal("existing"), labelId: id10 }),
2056
+ z10.strictObject({ source: workImportKeySchema, kind: z10.literal("create"), name: workLabelNameSchema })
2057
+ ])).max(500).default([]),
2058
+ plan: z10.strictObject({
2059
+ target: z10.discriminatedUnion("kind", [
2060
+ z10.strictObject({ kind: z10.literal("existing"), planId: id10 }),
2061
+ z10.strictObject({ kind: z10.literal("create"), title: title2, description: markdown2.default("") })
2062
+ ]),
2063
+ /** Only Issues observed in this container join the Plan; null means every created Issue does. */
2064
+ container: workImportKeySchema.nullable().default(null)
2065
+ }).nullable().default(null)
2066
+ });
2067
+ var workImportCommandSchema = z10.discriminatedUnion("type", [
2068
+ z10.strictObject({
2069
+ version: z10.literal(workCommandVersion),
2070
+ commandId: z10.string().min(1).max(200),
2071
+ teamId: id10,
2072
+ type: z10.literal("import.preview"),
2073
+ payload: z10.strictObject({ envelope: workImportEnvelopeSchema, mapping: workImportMappingSchema })
2074
+ }),
2075
+ // ── Import commit (DRI-306) ──
2076
+ /**
2077
+ * Commits a previewed batch, on the same route, authority (Team admin), envelope and receipts as the preview. The
2078
+ * Hub rechecks the batch against the Team as it is now, inside the commit's transaction, and refuses it with
2079
+ * `import_preview_stale` (or `import_batch_blocked`) and the blocking findings when anything changed.
2080
+ */
2081
+ z10.strictObject({
2082
+ version: z10.literal(workCommandVersion),
2083
+ commandId: z10.string().min(1).max(200),
2084
+ teamId: id10,
2085
+ type: z10.literal("import.commit"),
2086
+ payload: z10.strictObject({ batchId: id10 })
2087
+ }),
2088
+ // ── end DRI-306 ──
2089
+ // ── Import completion (DRI-307) ──
2090
+ /**
2091
+ * Completes the discussion components (comments, replies and link-only attachments) a committed batch left pending,
2092
+ * on the same route, authority (Team admin), envelope and receipts. `components` narrows the attempt to some of
2093
+ * them; null attempts every component still pending (or failed by an earlier completion). Already completed,
2094
+ * skipped, omitted and commit-time failed components keep their outcome.
2095
+ */
2096
+ z10.strictObject({
2097
+ version: z10.literal(workCommandVersion),
2098
+ commandId: z10.string().min(1).max(200),
2099
+ teamId: id10,
2100
+ type: z10.literal("import.complete"),
2101
+ payload: z10.strictObject({
2102
+ batchId: id10,
2103
+ components: z10.array(z10.strictObject({ collection: z10.enum(["comments", "attachments"]), key: workImportKeySchema })).min(1).max(500).nullable().default(null)
2104
+ })
2105
+ })
2106
+ // ── end DRI-307 ──
2107
+ ]);
2108
+ var workImportCommandTypes = workImportCommandSchema.options.map((option) => option.shape.type.value);
2109
+ function isWorkImportCommand(body) {
2110
+ const type = body?.type;
2111
+ return typeof type === "string" && workImportCommandTypes.includes(type);
2112
+ }
2113
+ var workImportDispositions = [
2114
+ "create",
2115
+ "already_bound",
2116
+ "map",
2117
+ "external",
2118
+ "preserved",
2119
+ "unresolved",
2120
+ "omitted",
2121
+ "conflict"
2122
+ ];
2123
+ var workImportFindingSchema = z10.object({
2124
+ code: z10.string(),
2125
+ severity: z10.enum(["blocking", "notice"]),
2126
+ detail: z10.record(z10.string(), z10.json()).default({})
2127
+ });
2128
+ var workImportTargetSchema = z10.object({
2129
+ kind: z10.enum(["issue", "plan", "member", "label", "status", "source_reference"]),
2130
+ id: id10
2131
+ });
2132
+ var workImportItemSchema = z10.object({
2133
+ seq: z10.number().int().positive(),
2134
+ batchId: id10,
2135
+ collection: workImportCollectionSchema,
2136
+ /** The source record's key; a relation's is `from`, with both endpoints in `proposed`. */
2137
+ key: z10.object({ idNamespace: z10.string(), externalId: z10.string() }),
2138
+ disposition: z10.enum(workImportDispositions),
2139
+ target: workImportTargetSchema.nullable(),
2140
+ /** What the commit would write, for review: resolved status, Plan, parent, assignees, labels, attention. */
2141
+ proposed: z10.record(z10.string(), z10.json()).nullable(),
2142
+ findings: z10.array(workImportFindingSchema)
2143
+ });
2144
+ var collectionSummary = z10.object({ state: z10.string(), reason: z10.string().nullable(), count: z10.number().int().nonnegative() });
2145
+ var workImportCompletenessSummarySchema = z10.object({
2146
+ collections: z10.record(z10.string(), collectionSummary),
2147
+ /** Per collection and field, how many records had it `empty`, `omitted`, `unavailable` or `unknown`. */
2148
+ fields: z10.array(z10.object({ collection: z10.string(), field: z10.string(), state: z10.string(), count: z10.number().int().positive() })),
2149
+ limits: z10.array(z10.object({
2150
+ collection: z10.string(),
2151
+ scope: z10.string(),
2152
+ limit: z10.number().int(),
2153
+ observed: z10.number().int().nullable(),
2154
+ reason: z10.string().nullable()
2155
+ })),
2156
+ unsupported: z10.array(z10.object({
2157
+ semantics: z10.string(),
2158
+ description: z10.string(),
2159
+ subjects: z10.array(z10.object({ collection: z10.string(), key: z10.object({ idNamespace: z10.string(), externalId: z10.string() }) }))
2160
+ }))
2161
+ });
2162
+ var workImportCommitSchema = z10.object({
2163
+ commandId: id10,
2164
+ committedBy: workActorSchema,
2165
+ committedAt: timestamp8,
2166
+ activityId: id10,
2167
+ /** Outcome counts over every outcome row (records and components). */
2168
+ counts: z10.record(z10.string(), z10.number().int().nonnegative())
2169
+ });
2170
+ var workImportBatchSchema = z10.object({
2171
+ id: id10,
2172
+ teamId: id10,
2173
+ /** `ready` when no finding blocks the commit; `blocked` otherwise; `committed` once the commit (DRI-306) wrote it. */
2174
+ state: z10.enum(["ready", "blocked", "committed"]),
2175
+ format: z10.string(),
2176
+ formatVersion: z10.number().int().positive(),
2177
+ adapter: z10.object({ name: z10.string(), version: z10.string() }),
2178
+ capturedAt: z10.string(),
2179
+ source: z10.object({ provider: z10.string(), instance: z10.string(), workspaceId: z10.string(), displayName: z10.string().nullable() }),
2180
+ /** DRI-302's registered space for that key, or null when the commit would register it. */
2181
+ spaceId: id10.nullable(),
2182
+ /** sha256 of the canonical envelope, and of the canonical mapping; both frozen with the batch. */
2183
+ snapshotDigest: z10.string().regex(/^[0-9a-f]{64}$/),
2184
+ mappingDigest: z10.string().regex(/^[0-9a-f]{64}$/),
2185
+ expectedWorkflow: z10.object({ workflowId: id10, revision: z10.number().int().positive() }),
2186
+ statusMode: z10.enum(["map", "adopt"]),
2187
+ /**
2188
+ * For `adopt`: the admin workflow commands the commit would run, previewed and not executed: `workflow.create` with
2189
+ * this manual-only definition, then `workflow.activate` with an empty migration (the Team has no Issues).
2190
+ */
2191
+ proposedWorkflow: z10.object({ definition: workDeliveryWorkflowDefinitionSchema, commands: z10.array(z10.string()) }).nullable(),
2192
+ plan: z10.object({
2193
+ kind: z10.enum(["existing", "create"]),
2194
+ planId: id10.nullable(),
2195
+ title: z10.string().nullable(),
2196
+ container: z10.object({ idNamespace: z10.string(), externalId: z10.string() }).nullable()
2197
+ }).nullable(),
2198
+ counts: z10.object({
2199
+ items: z10.number().int().nonnegative(),
2200
+ blocking: z10.number().int().nonnegative(),
2201
+ dispositions: z10.record(z10.string(), z10.number().int().nonnegative())
2202
+ }),
2203
+ /** Findings about the batch as a whole (adoption into a non-empty Team, an unknown Plan, an unregistered space). */
2204
+ findings: z10.array(workImportFindingSchema),
2205
+ completeness: workImportCompletenessSummarySchema,
2206
+ limits: z10.record(z10.string(), z10.number().int().positive()),
2207
+ initiator: workActorSchema,
2208
+ commandId: id10,
2209
+ version: version7,
2210
+ createdAt: timestamp8,
2211
+ /** The commit (DRI-306), once there is one: who, when, under which command, and its outcome counts. */
2212
+ commit: workImportCommitSchema.nullable().default(null),
2213
+ /** DRI-307: the latest completion of its discussion components, once there is one. */
2214
+ completion: z10.lazy(() => workImportCompletionSchema).nullable().default(null)
2215
+ });
2216
+ var workImportOutcomes = ["created", "mapped", "skipped_existing", "pending", "omitted", "failed"];
2217
+ var workImportOutcomeSchema = z10.object({
2218
+ seq: z10.number().int().positive(),
2219
+ batchId: id10,
2220
+ /** The previewed item this outcome belongs to. */
2221
+ itemSeq: z10.number().int().positive(),
2222
+ collection: workImportCollectionSchema,
2223
+ key: z10.object({ idNamespace: z10.string(), externalId: z10.string() }),
2224
+ /** `record` for the source record itself; otherwise the part (`source_reference`, `assignee`, `label`, `parent`, …). */
2225
+ component: z10.string(),
2226
+ outcome: z10.enum(workImportOutcomes),
2227
+ /** The record written or resolved: `{kind, id}` (`issue`, `plan`, `label`, `member`, `comment`, `attention`, …). */
2228
+ target: z10.object({ kind: z10.string(), id: id10 }).nullable(),
2229
+ code: z10.string().nullable(),
2230
+ detail: z10.record(z10.string(), z10.json())
2231
+ });
2232
+ var workImportOutcomePageSchema = workPageSchema(workImportOutcomeSchema);
2233
+ var workImportComponentStates = [
2234
+ "pending",
2235
+ "completed",
2236
+ "failed",
2237
+ "omitted",
2238
+ "skipped_existing",
2239
+ "skipped_local_edit",
2240
+ "skipped_tombstoned"
2241
+ ];
2242
+ var workImportComponentSchema = z10.object({
2243
+ seq: z10.number().int().positive(),
2244
+ batchId: id10,
2245
+ itemSeq: z10.number().int().positive(),
2246
+ collection: z10.enum(["comments", "attachments"]),
2247
+ key: z10.object({ idNamespace: z10.string(), externalId: z10.string() }),
2248
+ state: z10.enum(workImportComponentStates),
2249
+ code: z10.string().nullable(),
2250
+ target: z10.object({ kind: z10.string(), id: id10 }).nullable(),
2251
+ detail: z10.record(z10.string(), z10.json()),
2252
+ /** `commit` while the state is the commit's; `completion` once a completion attempted it. */
2253
+ origin: z10.enum(["commit", "completion"]),
2254
+ /** How many completions attempted it, and the last one's command ID. */
2255
+ attempts: z10.number().int().nonnegative(),
2256
+ lastCommandId: z10.string().nullable(),
2257
+ updatedAt: timestamp8
2258
+ });
2259
+ var workImportComponentPageSchema = workPageSchema(workImportComponentSchema);
2260
+ var workImportCompletenessNoteSchema = z10.object({
2261
+ collection: z10.string(),
2262
+ state: z10.string(),
2263
+ reason: z10.string().nullable(),
2264
+ limits: z10.array(z10.object({ scope: z10.string(), limit: z10.number().int(), observed: z10.number().int().nullable(), reason: z10.string().nullable() }))
2265
+ });
2266
+ var workImportCompletionSchema = z10.object({
2267
+ commandId: id10,
2268
+ completedBy: workActorSchema,
2269
+ completedAt: timestamp8,
2270
+ activityId: id10,
2271
+ /** Components this completion attempted, and their resulting states. */
2272
+ attempted: z10.number().int().nonnegative(),
2273
+ counts: z10.record(z10.string(), z10.number().int().nonnegative()),
2274
+ /** Every discussion component of the batch by state, after this completion. */
2275
+ totals: z10.record(z10.string(), z10.number().int().nonnegative()),
2276
+ /** Never an implied "all imported": each discussion collection the source did not capture completely. */
2277
+ completeness: z10.array(workImportCompletenessNoteSchema)
2278
+ });
2279
+ var workImportSnapshotSchema = z10.object({
2280
+ batchId: id10,
2281
+ snapshotDigest: z10.string(),
2282
+ mappingDigest: z10.string(),
2283
+ envelope: z10.record(z10.string(), z10.json()),
2284
+ mapping: z10.record(z10.string(), z10.json())
2285
+ });
2286
+ var workImportBatchPageSchema = workPageSchema(workImportBatchSchema);
2287
+ var workImportItemPageSchema = workPageSchema(workImportItemSchema);
2288
+ var workImportCommandResultSchema = z10.object({
2289
+ commandId: id10,
2290
+ type: z10.string(),
2291
+ teamId: id10,
2292
+ status: z10.enum(["accepted", "completed"]),
2293
+ replayed: z10.boolean(),
2294
+ recordedAt: timestamp8,
2295
+ activityId: id10,
2296
+ outcome: z10.discriminatedUnion("kind", [
2297
+ z10.object({ kind: z10.literal("import_batch"), batch: workImportBatchSchema }),
2298
+ /**
2299
+ * The commit (DRI-306): the committed batch. `alreadyCommitted` when another command had committed it first: no
2300
+ * record was written and the batch's durable outcome is returned. Outcomes are read by page.
2301
+ */
2302
+ z10.object({ kind: z10.literal("import_commit"), batch: workImportBatchSchema, alreadyCommitted: z10.boolean() }),
2303
+ /** The completion (DRI-307): the batch with this completion as its latest. Components are read by page. */
2304
+ z10.object({ kind: z10.literal("import_completion"), batch: workImportBatchSchema, completion: workImportCompletionSchema })
2305
+ ])
2306
+ });
2307
+ var workImportErrorCodes = [
2308
+ "invalid_import_envelope",
2309
+ "invalid_import_mapping",
2310
+ "import_limit_exceeded",
2311
+ "workflow_revision_conflict",
2312
+ /**
2313
+ * DRI-306. `import_preview_stale`: the Team changed since a `ready` preview so that the commit would now refuse it;
2314
+ * `import_batch_blocked`: the preview itself was `blocked`. Both carry `findings` (each with `collection` and `key`,
2315
+ * or neither for a batch finding, `code`, `severity: "blocking"` and `detail`) and `count`; nothing is recorded.
2316
+ */
2317
+ "import_preview_stale",
2318
+ "import_batch_blocked",
2319
+ /**
2320
+ * DRI-307. `import_batch_not_committed`: a completion of a batch that was never committed. `import_component_unknown`:
2321
+ * a named component is not a comment or attachment of the batch (carries `collection` and `key`).
2322
+ */
2323
+ "import_batch_not_committed",
2324
+ "import_component_unknown"
2325
+ ];
2326
+
2327
+ // src/work-deployments.ts
2328
+ import { z as z11 } from "zod";
2329
+ var id11 = z11.string().min(1).max(160);
2330
+ var timestamp9 = z11.iso.datetime();
2331
+ var version8 = z11.number().int().positive();
2332
+ var slug2 = z11.string().regex(/^[a-z][a-z0-9_-]{0,63}$/);
2333
+ var workDeploymentPurposeSchema = z11.enum(["verification", "production"]);
2334
+ var workDeploymentLifecycleSchema = z11.enum(["active", "replaced", "retired"]);
2335
+ var workDeploymentSchema = z11.object({
2336
+ id: id11,
2337
+ teamId: id11,
2338
+ issueId: id11,
2339
+ /** Per Issue, from 1, in recording order. */
2340
+ number: z11.number().int().positive(),
2341
+ /** The candidate this deployment deploys. */
2342
+ candidateId: id11,
2343
+ environment: slug2,
2344
+ purpose: workDeploymentPurposeSchema,
2345
+ /** The deployment or release identity in that environment (a deploy ID, a release tag). */
2346
+ ref: z11.string(),
2347
+ url: z11.string().nullable(),
2348
+ lifecycle: workDeploymentLifecycleSchema,
2349
+ /** The deployment this one replaced in its environment, and the one that replaced it. */
2350
+ replaces: id11.nullable(),
2351
+ replacedBy: id11.nullable(),
2352
+ retirement: workEvidenceDecisionSchema.nullable(),
2353
+ runId: id11.nullable(),
2354
+ recordedBy: workActorSchema,
2355
+ occurredAt: timestamp9,
2356
+ recordedAt: timestamp9,
2357
+ commandId: id11,
2358
+ /** The deployment's own concurrency version: replacement and retirement bump it. */
2359
+ version: version8
2360
+ });
2361
+ var workVerificationOutcomeSchema = z11.enum(["pending", "passed", "failed"]);
2362
+ var workVerificationStandingSchema = z11.enum([
2363
+ "current",
2364
+ "superseded",
2365
+ "stale_deployment",
2366
+ "stale_candidate",
2367
+ "stale_scope_revision"
2368
+ ]);
2369
+ var workVerificationAttemptSchema = z11.object({
2370
+ id: id11,
2371
+ teamId: id11,
2372
+ issueId: id11,
2373
+ /** Per deployment, from 1. */
2374
+ number: z11.number().int().positive(),
2375
+ /** The evaluated inputs: the scope revision, the candidate and the deployment of that candidate. */
2376
+ inputs: z11.object({ scopeRevision: workScopeRevisionRefSchema, candidateId: id11, deploymentId: id11, environment: slug2, deploymentRef: z11.string() }),
2377
+ outcome: workVerificationOutcomeSchema,
2378
+ /** The QA evidence that decides the outcome, while it is live. */
2379
+ outcomeEvidenceId: id11.nullable(),
2380
+ runId: id11.nullable(),
2381
+ supersedes: id11.nullable(),
2382
+ supersededBy: id11.nullable(),
2383
+ startedBy: workActorSchema,
2384
+ occurredAt: timestamp9,
2385
+ recordedAt: timestamp9,
2386
+ commandId: id11,
2387
+ version: version8,
2388
+ standing: workVerificationStandingSchema
2389
+ });
2390
+ var workProductionTrailEntrySchema = z11.object({
2391
+ confirmation: workEvidenceSchema,
2392
+ verificationAttempt: workVerificationAttemptSchema.nullable(),
2393
+ verificationDeployment: workDeploymentSchema.nullable(),
2394
+ productionDeployment: workDeploymentSchema
2395
+ });
2396
+ var workDeploymentActivityKindSchema = z11.enum([
2397
+ "deployment.recorded",
2398
+ "deployment.replaced",
2399
+ "deployment.retired",
2400
+ "verification.started",
2401
+ "verification.superseded",
2402
+ "verification.concluded"
2403
+ ]);
2404
+ var workDeploymentActivitySchema = workActivitySchema.extend({
2405
+ subject: z11.object({ kind: z11.enum(["deployment", "verification_attempt"]), id: id11 }),
2406
+ kind: workDeploymentActivityKindSchema
2407
+ });
2408
+ var workDeploymentPageSchema = workPageSchema(workDeploymentSchema);
2409
+ var workVerificationAttemptPageSchema = workPageSchema(workVerificationAttemptSchema);
2410
+ var workProductionTrailPageSchema = workPageSchema(workProductionTrailEntrySchema);
2411
+ var workDeploymentActivityPageSchema = workPageSchema(workDeploymentActivitySchema);
2412
+ var envelope8 = { version: z11.literal(workCommandVersion), commandId: z11.string().min(1).max(200), teamId: id11 };
2413
+ var issueTarget6 = z11.strictObject({ kind: z11.literal("issue"), id: id11 });
2414
+ var workDeploymentCommandSchema = z11.discriminatedUnion("type", [
2415
+ /**
2416
+ * Records a deployment of a candidate of the Issue's current scope revision. An active deployment of the Issue in
2417
+ * the same environment is replaced by it; replacing a verified deployment of the current candidate holds automation.
2418
+ */
2419
+ z11.strictObject({
2420
+ ...envelope8,
2421
+ type: z11.literal("deployment.record"),
2422
+ target: issueTarget6,
2423
+ payload: z11.strictObject({
2424
+ candidateId: id11,
2425
+ environment: slug2,
2426
+ purpose: workDeploymentPurposeSchema,
2427
+ ref: z11.string().trim().min(1).max(200),
2428
+ url: z11.url({ protocol: /^https?$/ }).max(2e3).nullable().default(null),
2429
+ occurredAt: timestamp9,
2430
+ runId: id11.nullable().default(null)
2431
+ })
2432
+ }),
2433
+ /** Retires an active deployment at its version, with a reason. It stays in history and satisfies nothing. */
2434
+ z11.strictObject({
2435
+ ...envelope8,
2436
+ type: z11.literal("deployment.retire"),
2437
+ target: z11.strictObject({ kind: z11.literal("deployment"), id: id11 }),
2438
+ expectedVersion: version8,
2439
+ payload: z11.strictObject({ reason: z11.string().trim().min(1).max(2e3) })
2440
+ }),
2441
+ /**
2442
+ * Starts a verification attempt on an active verification deployment. It becomes the deployment's current attempt
2443
+ * and supersedes the one before; a QA result (`evidence.record` naming it) concludes it.
2444
+ */
2445
+ z11.strictObject({
2446
+ ...envelope8,
2447
+ type: z11.literal("verification.start"),
2448
+ target: issueTarget6,
2449
+ payload: z11.strictObject({ deploymentId: id11, occurredAt: timestamp9, runId: id11.nullable().default(null) })
2450
+ })
2451
+ ]);
2452
+ var workDeploymentCommandTypes = workDeploymentCommandSchema.options.map((o) => o.shape.type.value);
2453
+ function isWorkDeploymentCommand(raw) {
2454
+ const type = raw?.type;
2455
+ return typeof type === "string" && workDeploymentCommandTypes.includes(type);
2456
+ }
2457
+ var workDeploymentCommandResultSchema = z11.object({
2458
+ commandId: id11,
2459
+ type: z11.string(),
2460
+ teamId: id11,
2461
+ status: z11.enum(["accepted", "completed"]),
2462
+ replayed: z11.boolean(),
2463
+ recordedAt: timestamp9,
2464
+ activityId: id11,
2465
+ outcome: z11.discriminatedUnion("kind", [
2466
+ /** `replaced` is the deployment this one replaced; `issue` is the Issue when the change held its automation. */
2467
+ z11.object({
2468
+ kind: z11.literal("deployment"),
2469
+ deployment: workDeploymentSchema,
2470
+ replaced: workDeploymentSchema.nullable(),
2471
+ issue: workIssueSchema.nullable()
2472
+ }),
2473
+ /** `superseded` is the deployment's previous current attempt. */
2474
+ z11.object({
2475
+ kind: z11.literal("verification_attempt"),
2476
+ attempt: workVerificationAttemptSchema,
2477
+ superseded: workVerificationAttemptSchema.nullable()
2478
+ })
2479
+ ])
2480
+ });
2481
+ var workDeploymentErrorCodes = ["deployment_closed", "attempt_concluded", "not_verified", "not_current_candidate"];
2482
+
2483
+ // src/work-relations.ts
2484
+ import { z as z12 } from "zod";
2485
+ var id12 = z12.string().min(1).max(160);
2486
+ var timestamp10 = z12.iso.datetime();
2487
+ var workIssueRelationKindSchema = z12.enum(["blocked_by", "duplicate_of", "related"]);
2488
+ var workRelationRemovalSchema = z12.object({ by: workActorSchema, at: timestamp10, commandId: id12, reason: z12.string().nullable() });
2489
+ var workIssueRelationSchema = z12.object({
2490
+ id: id12,
2491
+ teamId: id12,
2492
+ kind: workIssueRelationKindSchema,
2493
+ /** The dependent (`blocked_by`), the duplicate (`duplicate_of`), or the side that recorded a `related` link. */
2494
+ issueId: id12,
2495
+ /** The prerequisite (`blocked_by`), the canonical Issue (`duplicate_of`), or the other side of a `related` link. */
2496
+ targetId: id12,
2497
+ addedBy: workActorSchema,
2498
+ addedAt: timestamp10,
2499
+ commandId: id12,
2500
+ removal: workRelationRemovalSchema.nullable()
2501
+ });
2502
+ var workRelationEndpointSchema = z12.object({
2503
+ id: id12,
2504
+ identifier: id12,
2505
+ statusId: id12,
2506
+ category: workDeliveryStatusCategorySchema,
2507
+ lifecycle: workLifecycleSchema
2508
+ });
2509
+ var workDependencyReasonSchema = z12.enum(["not_completed", "canceled"]);
2510
+ var workDependencyRemedySchema = z12.enum(["complete_prerequisite", "repoint_to_canonical", "remove_relation"]);
2511
+ var workUnsatisfiedDependencySchema = z12.object({
2512
+ relationId: id12,
2513
+ blocker: workRelationEndpointSchema,
2514
+ reason: workDependencyReasonSchema,
2515
+ /** The prerequisite's canonical Issue when it is a current duplicate, else null: a hint, never a satisfaction. */
2516
+ canonical: workRelationEndpointSchema.nullable(),
2517
+ remedy: workDependencyRemedySchema
2518
+ });
2519
+ var workDependencyGateSchema = z12.object({
2520
+ issueId: id12,
2521
+ teamId: id12,
2522
+ satisfied: z12.boolean(),
2523
+ blockerCount: z12.number().int().nonnegative(),
2524
+ items: z12.array(workUnsatisfiedDependencySchema),
2525
+ nextCursor: z12.string().nullable(),
2526
+ /**
2527
+ * Imported blockers an import commit could not record as relations (DRI-306), unresolved until DRI-308 resolves or
2528
+ * dismisses them: each keeps `satisfied` false (reason `pending_import`). The source key of the blocker, which resolved
2529
+ * to no Drisp Issue, the batch, and why it is pending. Up to 20, on the first page only; omitted when
2530
+ * there are none. Only a blocker that resolved to no Drisp Issue counts.
2531
+ */
2532
+ pendingImports: z12.array(z12.object({
2533
+ reason: z12.literal("pending_import"),
2534
+ batchId: id12,
2535
+ from: z12.object({ idNamespace: z12.string(), externalId: z12.string() }),
2536
+ /** Why the commit left it pending: `pending_relation` (an endpoint not resolved) or the refusal it met. */
2537
+ importReason: z12.string()
2538
+ })).optional(),
2539
+ /** Whether there are more pending imported blockers than listed (DRI-306); present with `pendingImports`. */
2540
+ pendingImportsMore: z12.boolean().optional()
2541
+ });
2542
+ var workRelationActivityKindSchema = z12.enum(["issue_relation.added", "issue_relation.removed"]);
2543
+ var workRelationActivitySchema = workActivitySchema.extend({
2544
+ subject: z12.object({ kind: z12.literal("relation"), id: id12 }),
2545
+ kind: workRelationActivityKindSchema
2546
+ });
2547
+ var workIssueRelationPageSchema = workPageSchema(workIssueRelationSchema);
2548
+ var workRelationActivityPageSchema = workPageSchema(workRelationActivitySchema);
2549
+ var envelope9 = { version: z12.literal(workCommandVersion), commandId: z12.string().min(1).max(200), teamId: id12 };
2550
+ var workRelationCommandSchema = z12.discriminatedUnion("type", [
2551
+ /**
2552
+ * Records a relation from the target Issue to `issue`, both active Issues of this Team. A self-link is
2553
+ * `self_relation`; another Team's Issue `foreign_team_reference`; an existing current relation `no_change`.
2554
+ */
2555
+ z12.strictObject({
2556
+ ...envelope9,
2557
+ type: z12.literal("issue_relation.add"),
2558
+ target: z12.strictObject({ kind: z12.literal("issue"), id: id12 }),
2559
+ payload: z12.strictObject({ kind: workIssueRelationKindSchema, issue: workRefSchema })
2560
+ }),
2561
+ /** Ends a current relation, attributed; the period stays in history. Removing a removed one is `no_change`. */
2562
+ z12.strictObject({
2563
+ ...envelope9,
2564
+ type: z12.literal("issue_relation.remove"),
2565
+ target: z12.strictObject({ kind: z12.literal("relation"), id: id12 }),
2566
+ payload: z12.strictObject({ reason: z12.string().trim().min(1).max(2e3).optional() })
2567
+ })
2568
+ ]);
2569
+ var workRelationCommandTypes = workRelationCommandSchema.options.map((o) => o.shape.type.value);
2570
+ function isWorkRelationCommand(raw) {
2571
+ const type = raw?.type;
2572
+ return typeof type === "string" && workRelationCommandTypes.includes(type);
2573
+ }
2574
+ var workRelationCommandResultSchema = z12.object({
2575
+ commandId: id12,
2576
+ type: z12.string(),
2577
+ teamId: id12,
2578
+ status: z12.enum(["accepted", "completed"]),
2579
+ replayed: z12.boolean(),
2580
+ recordedAt: timestamp10,
2581
+ activityId: id12,
2582
+ outcome: z12.discriminatedUnion("kind", [z12.object({ kind: z12.literal("relation"), relation: workIssueRelationSchema })])
2583
+ });
2584
+ var workRelationErrorCodes = [
2585
+ "self_relation",
2586
+ "dependency_cycle",
2587
+ "duplicate_cycle",
2588
+ "duplicate_chain",
2589
+ "duplicate_conflict",
2590
+ "dependency_unsatisfied",
2591
+ "dependency_status_unknown"
2592
+ ];
2593
+ var pendingKey = z12.object({ idNamespace: z12.string(), externalId: z12.string() });
2594
+ var workPendingRelationKindSchema = z12.enum(["blocks", "duplicates", "related", "parent"]);
2595
+ var workPendingRelationDispositions = ["pending", "resolved", "dismissed", "superseded_by_local_edit", "endpoint_tombstoned"];
2596
+ var workPendingRelationDispositionSchema = z12.enum(workPendingRelationDispositions);
2597
+ var workPendingRelationAttemptOutcomeSchema = z12.enum(["unresolvable_cycle", "invalid_mapping", "local_parent_differs"]);
2598
+ var workPendingRelationSchema = z12.object({
2599
+ id: id12,
2600
+ teamId: id12,
2601
+ spaceId: id12,
2602
+ kind: workPendingRelationKindSchema,
2603
+ /** Each endpoint's complete source key and the Drisp Issue it resolves to, null while it has none. */
2604
+ from: z12.object({ key: pendingKey, issueId: id12.nullable() }),
2605
+ to: z12.object({ key: pendingKey, issueId: id12.nullable() }),
2606
+ /** For `blocks`, the dependent Drisp Issue whose gate it may close; null otherwise or while the dependent is missing. */
2607
+ blockedIssueId: id12.nullable(),
2608
+ /** The import that recorded it: the batch and its item. */
2609
+ import: z12.object({ batchId: id12, itemSeq: z12.number().int() }),
2610
+ /** Why the commit left it pending (`pending_relation`, `existing_endpoints`, `local_parent_differs`, a refusal code). */
2611
+ reason: z12.string(),
2612
+ disposition: workPendingRelationDispositionSchema,
2613
+ /** Whether it closes `blockedIssueId`'s dependency gate now. */
2614
+ blocking: z12.boolean(),
2615
+ guard: z12.object({ childId: id12, parentId: id12.nullable(), parentChangeSeq: z12.number().int().nonnegative() }).nullable(),
2616
+ lastAttempt: z12.object({
2617
+ outcome: workPendingRelationAttemptOutcomeSchema,
2618
+ code: z12.string().nullable(),
2619
+ at: timestamp10,
2620
+ batchId: id12.nullable(),
2621
+ commandId: id12.nullable()
2622
+ }).nullable(),
2623
+ /** Who or what settled it, when, by which command or import, and what it wrote. Null while pending. */
2624
+ settlement: z12.object({
2625
+ by: workActorSchema,
2626
+ at: timestamp10,
2627
+ commandId: id12,
2628
+ batchId: id12.nullable(),
2629
+ reason: z12.string().nullable(),
2630
+ code: z12.string().nullable(),
2631
+ relationId: id12.nullable(),
2632
+ parentId: id12.nullable()
2633
+ }).nullable(),
2634
+ recordedAt: timestamp10
2635
+ });
2636
+ var workPendingRelationPageSchema = workPageSchema(workPendingRelationSchema);
2637
+ var workPendingRelationActivityKindSchema = z12.enum([
2638
+ "pending_relation.resolved",
2639
+ "pending_relation.dismissed",
2640
+ "pending_relation.superseded",
2641
+ "pending_relation.tombstoned",
2642
+ "pending_relation.attempted"
2643
+ ]);
2644
+ var workPendingRelationActivitySchema = workActivitySchema.extend({
2645
+ subject: z12.object({ kind: z12.literal("pending_relation"), id: id12 }),
2646
+ kind: workPendingRelationActivityKindSchema
2647
+ });
2648
+ var workPendingRelationActivityPageSchema = workPageSchema(workPendingRelationActivitySchema);
2649
+ var workPendingRelationCommandSchema = z12.discriminatedUnion("type", [
2650
+ /** A member's attributed dismissal: the record is settled `dismissed`, and a dismissed blocker no longer gates. */
2651
+ z12.strictObject({
2652
+ ...envelope9,
2653
+ type: z12.literal("pending_relation.dismiss"),
2654
+ target: z12.strictObject({ kind: z12.literal("pending_relation"), id: id12 }),
2655
+ payload: z12.strictObject({ reason: z12.string().trim().min(1).max(2e3) })
2656
+ }),
2657
+ /**
2658
+ * A member's explicit resolution once both endpoints resolve to Drisp Issues, through the same Work rules. It is the
2659
+ * member's own decision, so the local-edit guard does not hold it back. A cycle or another refusal is recorded as
2660
+ * the record's `lastAttempt` and the record stays pending; a tombstoned endpoint settles it `endpoint_tombstoned`.
2661
+ */
2662
+ z12.strictObject({
2663
+ ...envelope9,
2664
+ type: z12.literal("pending_relation.resolve"),
2665
+ target: z12.strictObject({ kind: z12.literal("pending_relation"), id: id12 }),
2666
+ payload: z12.strictObject({})
2667
+ })
2668
+ ]);
2669
+ var workPendingRelationCommandTypes = workPendingRelationCommandSchema.options.map((o) => o.shape.type.value);
2670
+ function isWorkPendingRelationCommand(raw) {
2671
+ const type = raw?.type;
2672
+ return typeof type === "string" && workPendingRelationCommandTypes.includes(type);
2673
+ }
2674
+ var workPendingRelationCommandResultSchema = z12.object({
2675
+ commandId: id12,
2676
+ type: z12.string(),
2677
+ teamId: id12,
2678
+ status: z12.enum(["accepted", "completed"]),
2679
+ replayed: z12.boolean(),
2680
+ recordedAt: timestamp10,
2681
+ activityId: id12,
2682
+ outcome: z12.discriminatedUnion("kind", [z12.object({
2683
+ kind: z12.literal("pending_relation"),
2684
+ pendingRelation: workPendingRelationSchema,
2685
+ /**
2686
+ * Whether the command took effect: a dismissal, or a resolution that wrote (or found current) the relation or
2687
+ * parent. A resolution that could not apply is still recorded (its `lastAttempt`, Activity and receipt) and
2688
+ * answers `applied: false` with why in `result` and `code`.
2689
+ */
2690
+ applied: z12.boolean(),
2691
+ result: z12.enum([
2692
+ "resolved",
2693
+ "dismissed",
2694
+ "unresolvable_cycle",
2695
+ "invalid_mapping",
2696
+ "local_parent_differs",
2697
+ "superseded_by_local_edit",
2698
+ "endpoint_tombstoned"
2699
+ ]),
2700
+ code: z12.string().nullable()
2701
+ })])
2702
+ });
2703
+ var workPendingRelationErrorCodes = ["pending_relation_settled", "pending_relation_endpoint_missing"];
2704
+
2705
+ // src/session-control.ts
2706
+ import { z as z13 } from "zod";
2707
+ var activeSessionControlCapability = "active_session_control_v1";
2708
+ var sessionControlHistoryKind = "session_control.observation";
2709
+ var sessionCapabilityNames = [
2710
+ /** Informational guidance reaches the model inside the running Turn, at a safe opportunity, not only at its end. */
2711
+ "guidance.active_delivery",
2712
+ /** The harness itself records that the guidance entered the model context, with a correlation the Runner can read. */
2713
+ "guidance.delivery_receipt",
2714
+ /** The harness or agent acknowledges having reconciled the guidance. Never inferred from a transport receipt. */
2715
+ "guidance.incorporation_ack",
2716
+ /** Pause takes effect at the next tool boundary: no further model request or tool starts until unpaused. */
2717
+ "pause.tool_boundary",
2718
+ /** Pause suspends a tool that is already running. */
2719
+ "pause.during_tool",
2720
+ /** Stop one running tool while the session continues. */
2721
+ "interrupt.tool_keep_session",
2722
+ /** Cancelling the harness process reverses effects a tool already made. No harness is expected to support this. */
2723
+ "cancel.rollback"
2724
+ ];
2725
+ var sessionCapabilityNameSchema = z13.enum(sessionCapabilityNames);
2726
+ var capabilitySupportSchema = z13.enum(["supported", "unsupported", "unverified"]);
2727
+ var sessionCapabilitySchema = z13.strictObject({
2728
+ support: capabilitySupportSchema,
2729
+ /** How the harness provides it, e.g. `PostToolUse.additionalContext`. */
2730
+ mechanism: z13.string().max(256).optional(),
2731
+ /** What bounds it, e.g. the hook timeout. */
2732
+ limits: z13.string().max(1024).optional(),
2733
+ /** Where the proof is recorded: a section of docs/specs/harness-capabilities.md. */
2734
+ evidence: z13.string().max(256)
2735
+ });
2736
+ var harnessSessionControlSchema = z13.strictObject({
2737
+ harness: z13.enum(["claude-code", "codex"]),
2738
+ /** The exact version string the harness printed; `unknown` when it could not be read. */
2739
+ version: z13.string().min(1).max(128),
2740
+ capabilities: z13.partialRecord(sessionCapabilityNameSchema, sessionCapabilitySchema)
2741
+ });
2742
+ function capabilitySupport(record, name) {
2743
+ return record.capabilities[name]?.support ?? "unverified";
2744
+ }
2745
+ var id13 = z13.string().min(1).max(160);
2746
+ var timestamp11 = z13.iso.datetime();
2747
+ var sessionControlCommandSchema = z13.strictObject({
2748
+ commandId: id13,
2749
+ runId: id13,
2750
+ intent: z13.discriminatedUnion("kind", [
2751
+ z13.strictObject({
2752
+ kind: z13.literal("guidance"),
2753
+ text: z13.string().min(1).max(131072),
2754
+ /** Ask for an incorporation acknowledgement; refused where `guidance.incorporation_ack` is not supported. */
2755
+ requireIncorporation: z13.literal(true).optional()
2756
+ }),
2757
+ z13.strictObject({ kind: z13.literal("pause") }),
2758
+ z13.strictObject({ kind: z13.literal("unpause") }),
2759
+ z13.strictObject({ kind: z13.literal("interrupt_tool"), toolUseId: id13.optional() })
2760
+ ])
2761
+ });
2762
+ var inFlightToolSchema = z13.strictObject({ toolUseId: id13, toolName: z13.string().max(256), startedAt: timestamp11 });
2763
+ var correlation = {
2764
+ commandId: id13,
2765
+ runId: id13,
2766
+ attemptId: id13,
2767
+ observedAt: timestamp11
2768
+ };
2769
+ var sessionControlRejectionSchema = z13.enum([
2770
+ /** The capability is `unsupported` or `unverified` for this harness version; `capability` names it. */
2771
+ "capability_unsupported",
2772
+ /** The Run has no live harness session on this Runner. */
2773
+ "no_active_session",
2774
+ /** The session ended before a safe opportunity to deliver. */
2775
+ "execution_ended",
2776
+ /** `interrupt_tool` named a tool that is not running, or none is running (DRI-316). */
2777
+ "tool_not_in_flight",
2778
+ /** The harness mechanism would stop more than the tool asked for, so nothing is stopped (DRI-316). */
2779
+ "target_ambiguous",
2780
+ /** The harness refused the control request itself; `detail` carries its error (DRI-316). */
2781
+ "harness_refused"
2782
+ ]);
2783
+ var sessionControlObservationSchema = z13.discriminatedUnion("kind", [
2784
+ /** The capability record the Runner resolved for this session, before any command. */
2785
+ z13.strictObject({
2786
+ kind: z13.literal("capabilities"),
2787
+ runId: id13,
2788
+ attemptId: id13,
2789
+ observedAt: timestamp11,
2790
+ record: harnessSessionControlSchema
2791
+ }),
2792
+ /** Transport receipt: the Runner durably accepted the command. Says nothing about the agent. */
2793
+ z13.strictObject({ kind: z13.literal("received"), ...correlation, intent: z13.enum(["guidance", "pause", "unpause", "interrupt_tool"]) }),
2794
+ /** Agent delivery: the harness recorded the guidance in the model context of this session. */
2795
+ z13.strictObject({
2796
+ kind: z13.literal("delivered"),
2797
+ ...correlation,
2798
+ mechanism: z13.string().max(256),
2799
+ sessionId: id13,
2800
+ /** The harness's own identity of the user input being processed: unchanged means the same Turn. */
2801
+ promptId: id13.optional(),
2802
+ /** The tool boundary the guidance was attached at. */
2803
+ toolUseId: id13,
2804
+ /**
2805
+ * What proves it: the harness's own record, never the hook reply. `harness_transcript` is a session transcript
2806
+ * entry (Claude Code); `harness_history_item` is the model-visible history item the harness reports as it records
2807
+ * it (Codex app-server `rawResponseItem/completed`, DRI-316).
2808
+ */
2809
+ evidence: z13.strictObject({ source: z13.enum(["harness_transcript", "harness_history_item"]), recordId: id13 })
2810
+ }),
2811
+ /** Incorporation acknowledgement. Only for a harness whose `guidance.incorporation_ack` is supported. */
2812
+ z13.strictObject({ kind: z13.literal("incorporated"), ...correlation, evidence: z13.string().max(1024) }),
2813
+ z13.strictObject({
2814
+ kind: z13.literal("rejected"),
2815
+ ...correlation,
2816
+ reason: sessionControlRejectionSchema,
2817
+ capability: sessionCapabilityNameSchema.optional(),
2818
+ harness: z13.string().max(64).optional(),
2819
+ version: z13.string().max(128).optional(),
2820
+ /** What the Runner or the harness said, e.g. which tools are in flight (DRI-316). */
2821
+ detail: z13.string().max(1024).optional()
2822
+ }),
2823
+ /**
2824
+ * An `interrupt_tool` took effect (DRI-316): the harness recorded the targeted tool's end after the Runner asked it
2825
+ * to stop the tool. Whatever the tool already did remains; the session's later `tool` observations show it went on.
2826
+ */
2827
+ z13.strictObject({
2828
+ kind: z13.literal("interrupted"),
2829
+ ...correlation,
2830
+ toolUseId: id13,
2831
+ mechanism: z13.string().max(256),
2832
+ /** The tool's end as the harness recorded it, e.g. Codex `failed` with exit code -1. */
2833
+ harnessStatus: z13.string().max(64),
2834
+ exitCode: z13.number().int().nullable()
2835
+ }),
2836
+ /** The Runner handed the guidance to the harness, but the harness never recorded it: delivery is not claimed. */
2837
+ z13.strictObject({ kind: z13.literal("unconfirmed"), ...correlation, toolUseId: id13.optional() }),
2838
+ /** Requested versus effective pause, and the tools still running when it was observed. */
2839
+ z13.strictObject({
2840
+ kind: z13.literal("state"),
2841
+ ...correlation,
2842
+ requested: z13.enum(["running", "paused"]),
2843
+ effective: z13.enum(["running", "pause_pending", "paused"]),
2844
+ inFlight: z13.array(inFlightToolSchema).max(64),
2845
+ /** Where the session is held while `effective` is `paused`. */
2846
+ safePoint: z13.strictObject({ hookEvent: z13.enum(["PreToolUse", "PostToolUse"]), toolUseId: id13 }).optional(),
2847
+ /** Why a requested pause stopped being effective without an unpause. */
2848
+ lapse: z13.enum(["hook_deadline", "session_ended"]).optional()
2849
+ }),
2850
+ /**
2851
+ * The Run was cancelled while these tools were running. Cancelling stops the harness process; it does not reverse
2852
+ * anything a tool already did, and whatever these tools started may have completed, partly completed, or not run.
2853
+ */
2854
+ z13.strictObject({
2855
+ kind: z13.literal("cancelled"),
2856
+ runId: id13,
2857
+ attemptId: id13,
2858
+ observedAt: timestamp11,
2859
+ inFlight: z13.array(inFlightToolSchema).max(64),
2860
+ rollback: z13.literal(false)
2861
+ }),
2862
+ /** A harness tool boundary, for correlation: which tool, in which session and Turn. */
2863
+ z13.strictObject({
2864
+ kind: z13.literal("tool"),
2865
+ runId: id13,
2866
+ attemptId: id13,
2867
+ observedAt: timestamp11,
2868
+ phase: z13.enum(["started", "ended"]),
2869
+ sessionId: id13,
2870
+ promptId: id13.optional(),
2871
+ toolUseId: id13,
2872
+ toolName: z13.string().max(256)
2873
+ })
2874
+ ]);
2875
+
2876
+ // src/client-integration.ts
2877
+ import { z as z14 } from "zod";
2878
+ var workClientContract = 1;
2879
+ var workClientContractHeader = "drisp-client-contract";
2880
+ var workClientContractMinimum = 1;
2881
+ var workAuthoritySchema = z14.object({
2882
+ teamId: z14.string().min(1),
2883
+ work: z14.enum(["legacy", "core"]),
2884
+ contract: z14.object({ current: z14.number().int().positive(), minimum: z14.number().int().positive() })
2885
+ });
2886
+ var workClientOperations = ["work.read", "history.read"];
2887
+ function selectWorkPath(authority, client = workClientContract) {
2888
+ if (authority === null) return { kind: "legacy", work: "legacy" };
2889
+ if (client < authority.contract.minimum)
2890
+ return { kind: "unsupported", code: "client_upgrade_required", minimum: authority.contract.minimum, current: authority.contract.current };
2891
+ if (client > authority.contract.current)
2892
+ return { kind: "unsupported", code: "hub_upgrade_required", minimum: authority.contract.minimum, current: authority.contract.current };
2893
+ if (authority.work === "legacy") return { kind: "legacy", work: "legacy" };
2894
+ return { kind: "work_only", work: "core" };
2895
+ }
2896
+ function supportedOperations(path) {
2897
+ if (path.kind === "unsupported" || path.kind === "legacy") return [];
2898
+ return [...workClientOperations];
2899
+ }
298
2900
 
299
2901
  // src/v2.ts
300
- var protocolVersion = { major: 2, minor: 3 };
2902
+ var protocolVersion = { major: 2, minor: 4 };
301
2903
  var conversationContinuationCapability = "conversation_continuation";
302
2904
  var abandonedConversationContinuationCapability = "abandoned_conversation_continuation";
303
2905
  var repositoryAccessCapability = "repository_checkout_v1";
@@ -305,30 +2907,32 @@ var workflowInstallCapability = "workflow_install_v1";
305
2907
  var runDelegationCapability = "run_delegation_v1";
306
2908
  var orchestratorGuidanceCapability = "orchestrator_guidance_v1";
307
2909
  var runUsageCapability = "run_usage_v1";
2910
+ var coordinationSupervisionCapability = "coordination_supervision_v1";
2911
+ var buildGatesCapability = "build_gates_v1";
308
2912
  var delegationTokenPrefix = "drisp_dlg_";
309
- var runArtifactNameSchema = z3.string().regex(/^[a-z][a-z0-9_]{0,63}$/);
2913
+ var runArtifactNameSchema = z15.string().regex(/^[a-z][a-z0-9_]{0,63}$/);
310
2914
  var runArtifactMaxBytes = 64 * 1024;
311
- var secretEnvironmentSchema = z3.record(
312
- z3.string().regex(/^(?:OPENAI_API_KEY|ANTHROPIC_API_KEY|CLAUDE_CODE_OAUTH_TOKEN|NPM_TOKEN|NODE_AUTH_TOKEN|PIP_INDEX_URL|PIP_EXTRA_INDEX_URL|UV_INDEX_URL|DRISP_TEST_[A-Z0-9_]+)$/),
313
- z3.string().regex(/^projects\/[a-zA-Z0-9-]+\/secrets\/[a-zA-Z0-9_-]+\/versions\/(?:latest|[0-9]+)$/)
2915
+ var secretEnvironmentSchema = z15.record(
2916
+ z15.string().regex(/^(?:OPENAI_API_KEY|ANTHROPIC_API_KEY|CLAUDE_CODE_OAUTH_TOKEN|NPM_TOKEN|NODE_AUTH_TOKEN|PIP_INDEX_URL|PIP_EXTRA_INDEX_URL|UV_INDEX_URL|DRISP_TEST_[A-Z0-9_]+)$/),
2917
+ z15.string().regex(/^projects\/[a-zA-Z0-9-]+\/secrets\/[a-zA-Z0-9_-]+\/versions\/(?:latest|[0-9]+)$/)
314
2918
  );
315
- var permissionAnswerSchema = z3.strictObject({
316
- kind: z3.literal("permission"),
317
- decision: z3.enum(["allow", "deny"]),
318
- reason: z3.string().max(4096).optional()
319
- });
320
- var id2 = z3.string().min(1).max(160);
321
- var sequence = z3.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER);
322
- var positive = sequence.refine((n) => n > 0);
323
- var timestamp = z3.iso.datetime();
324
- var scopeSchema = z3.discriminatedUnion("visibility", [
325
- z3.strictObject({ visibility: z3.literal("organization") }),
326
- z3.strictObject({ visibility: z3.literal("private"), ownerUserId: id2 })
327
- ]);
328
- var installedWorkflowsSchema = z3.array(InstalledWorkflowSchema).max(256);
329
- var harnessSchema = z3.enum(["claude-code", "codex"]);
330
- var harnessReadinessSchema = z3.strictObject({ installed: z3.boolean(), signedIn: z3.boolean() });
331
- var runnerReadinessSchema = z3.strictObject({
2919
+ var permissionAnswerSchema = z15.strictObject({
2920
+ kind: z15.literal("permission"),
2921
+ decision: z15.enum(["allow", "deny"]),
2922
+ reason: z15.string().max(4096).optional()
2923
+ });
2924
+ var id14 = z15.string().min(1).max(160);
2925
+ var sequence2 = z15.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER);
2926
+ var positive = sequence2.refine((n) => n > 0);
2927
+ var timestamp12 = z15.iso.datetime();
2928
+ var scopeSchema = z15.discriminatedUnion("visibility", [
2929
+ z15.strictObject({ visibility: z15.literal("organization") }),
2930
+ z15.strictObject({ visibility: z15.literal("private"), ownerUserId: id14 })
2931
+ ]);
2932
+ var installedWorkflowsSchema = z15.array(InstalledWorkflowSchema).max(256);
2933
+ var harnessSchema = z15.enum(["claude-code", "codex"]);
2934
+ var harnessReadinessSchema = z15.strictObject({ installed: z15.boolean(), signedIn: z15.boolean() });
2935
+ var runnerReadinessSchema = z15.strictObject({
332
2936
  "claude-code": harnessReadinessSchema.optional(),
333
2937
  codex: harnessReadinessSchema.optional()
334
2938
  });
@@ -343,27 +2947,27 @@ function readinessFixCommand(harness, readiness) {
343
2947
  return void 0;
344
2948
  }
345
2949
  var runnerUpdateCommand = "npm i -g @drisp/cli";
346
- var interruptionSchema = z3.strictObject({
347
- interruptionId: id2,
2950
+ var interruptionSchema = z15.strictObject({
2951
+ interruptionId: id14,
348
2952
  revision: positive,
349
2953
  /** `waiting` (root ADR-0008) is non-human: a Run parked until one of its children closes or parks. */
350
- kind: z3.enum(["permission", "question", "guidance", "recovery", "waiting"]),
351
- message: z3.string().max(16384),
2954
+ kind: z15.enum(["permission", "question", "guidance", "recovery", "waiting"]),
2955
+ message: z15.string().max(16384),
352
2956
  /** Explicit technical question for a parent; absent always reserves the answer to a member. */
353
- respondent: z3.enum(["orchestrator"]).optional(),
354
- requestId: id2.optional()
2957
+ respondent: z15.enum(["orchestrator"]).optional(),
2958
+ requestId: id14.optional()
355
2959
  });
356
- var workflowIdentitySchema = z3.strictObject({
357
- name: z3.string().min(1).max(128),
358
- version: z3.string().min(1).max(128).optional()
2960
+ var workflowIdentitySchema = z15.strictObject({
2961
+ name: z15.string().min(1).max(128),
2962
+ version: z15.string().min(1).max(128).optional()
359
2963
  });
360
- var buildCloseReasonSchema = z3.enum([
2964
+ var buildCloseReasonSchema = z15.enum([
361
2965
  "workflow_template_mismatch",
362
2966
  "child_project_dir_invalid",
363
2967
  "build_not_approved",
364
2968
  "approval_question_missing"
365
2969
  ]);
366
- var runCloseReasonSchema = z3.enum([
2970
+ var runCloseReasonSchema = z15.enum([
367
2971
  "execution_terminal",
368
2972
  "cancelled_before_start",
369
2973
  "admission_failed",
@@ -381,53 +2985,53 @@ var runCloseReasonSchema = z3.enum([
381
2985
  ...buildCloseReasonSchema.options
382
2986
  ]);
383
2987
  var factIdentity = {
384
- runId: id2,
385
- attemptId: id2,
2988
+ runId: id14,
2989
+ attemptId: id14,
386
2990
  executionRevision: positive,
387
- emittedAt: timestamp
2991
+ emittedAt: timestamp12
388
2992
  };
389
- var runUsageSchema = z3.strictObject({ counted: sequence, cacheRead: sequence });
2993
+ var runUsageSchema = z15.strictObject({ counted: sequence2, cacheRead: sequence2 });
390
2994
  var reportedUsage = { usage: runUsageSchema.optional() };
391
- var controlRecordSchema = z3.discriminatedUnion("kind", [
2995
+ var controlRecordSchema = z15.discriminatedUnion("kind", [
392
2996
  /** Instance-scoped, not tied to a Run: the full replacement inventory of installed Workflows. */
393
- z3.strictObject({ kind: z3.literal("workflows.changed"), workflows: installedWorkflowsSchema }),
2997
+ z15.strictObject({ kind: z15.literal("workflows.changed"), workflows: installedWorkflowsSchema }),
394
2998
  /** Instance-scoped, not tied to a Run: the Runner's full Readiness, sent when it changes after hello. */
395
- z3.strictObject({ kind: z3.literal("readiness.changed"), readiness: runnerReadinessSchema }),
396
- z3.strictObject({ kind: z3.literal("assignment.accepted"), runId: id2, attemptId: id2 }),
397
- z3.strictObject({
398
- kind: z3.literal("assignment.rejected"),
399
- runId: id2,
400
- attemptId: id2,
401
- reason: z3.string().max(1024)
2999
+ z15.strictObject({ kind: z15.literal("readiness.changed"), readiness: runnerReadinessSchema }),
3000
+ z15.strictObject({ kind: z15.literal("assignment.accepted"), runId: id14, attemptId: id14 }),
3001
+ z15.strictObject({
3002
+ kind: z15.literal("assignment.rejected"),
3003
+ runId: id14,
3004
+ attemptId: id14,
3005
+ reason: z15.string().max(1024)
402
3006
  }),
403
- z3.strictObject({
404
- kind: z3.literal("run.started"),
3007
+ z15.strictObject({
3008
+ kind: z15.literal("run.started"),
405
3009
  ...factIdentity,
406
3010
  /** Absent from runners that predate Workflow reporting. */
407
3011
  workflow: workflowIdentitySchema.optional()
408
3012
  }),
409
- z3.strictObject({ kind: z3.literal("run.resumed"), ...factIdentity }),
410
- z3.strictObject({
411
- kind: z3.literal("run.attention"),
3013
+ z15.strictObject({ kind: z15.literal("run.resumed"), ...factIdentity }),
3014
+ z15.strictObject({
3015
+ kind: z15.literal("run.attention"),
412
3016
  ...factIdentity,
413
3017
  interruption: interruptionSchema,
414
- occupancy: z3.enum(["held", "released"]),
415
- historyThrough: sequence,
416
- continuation: z3.discriminatedUnion("kind", [
417
- z3.strictObject({ kind: z3.literal("live_request") }),
418
- z3.strictObject({ kind: z3.literal("local_checkpoint"), checkpointId: id2 }),
419
- z3.strictObject({ kind: z3.literal("portable_checkpoint"), checkpointId: id2 }),
420
- z3.strictObject({ kind: z3.literal("repair_required"), detail: z3.string().max(4096) })
3018
+ occupancy: z15.enum(["held", "released"]),
3019
+ historyThrough: sequence2,
3020
+ continuation: z15.discriminatedUnion("kind", [
3021
+ z15.strictObject({ kind: z15.literal("live_request") }),
3022
+ z15.strictObject({ kind: z15.literal("local_checkpoint"), checkpointId: id14 }),
3023
+ z15.strictObject({ kind: z15.literal("portable_checkpoint"), checkpointId: id14 }),
3024
+ z15.strictObject({ kind: z15.literal("repair_required"), detail: z15.string().max(4096) })
421
3025
  ]),
422
3026
  ...reportedUsage
423
3027
  }),
424
- z3.strictObject({
425
- kind: z3.literal("run.finished"),
3028
+ z15.strictObject({
3029
+ kind: z15.literal("run.finished"),
426
3030
  ...factIdentity,
427
- status: z3.enum(["completed", "failed", "cancelled"]),
428
- historyThrough: sequence,
3031
+ status: z15.enum(["completed", "failed", "cancelled"]),
3032
+ historyThrough: sequence2,
429
3033
  /** No setup/harness executed and no workspace was produced; safe to retire without export. */
430
- workspaceUnavailable: z3.literal(true).optional(),
3034
+ workspaceUnavailable: z15.literal(true).optional(),
431
3035
  /**
432
3036
  * Why a Build Run failed, as its close reason (docs/specs/build-orchestrator.md). Sent only for a grant with
433
3037
  * `parent` or `delegationToken`, which only a Hub that knows this field issues.
@@ -439,262 +3043,290 @@ var controlRecordSchema = z3.discriminatedUnion("kind", [
439
3043
  * The usage of a Run while it executes, for a grant marked `reportUsage`. Not an execution fact: it carries no
440
3044
  * execution revision, so it never advances, parks or closes the Run, and never wakes its parent.
441
3045
  */
442
- z3.strictObject({ kind: z3.literal("run.usage"), runId: id2, attemptId: id2, ...runUsageSchema.shape }),
443
- z3.strictObject({ kind: z3.literal("command.applied"), runId: id2, attemptId: id2, commandId: id2 }),
444
- z3.strictObject({
445
- kind: z3.literal("command.rejected"),
446
- runId: id2,
447
- attemptId: id2,
448
- commandId: id2,
449
- reason: z3.string().max(1024)
3046
+ z15.strictObject({ kind: z15.literal("run.usage"), runId: id14, attemptId: id14, ...runUsageSchema.shape }),
3047
+ z15.strictObject({ kind: z15.literal("command.applied"), runId: id14, attemptId: id14, commandId: id14 }),
3048
+ z15.strictObject({
3049
+ kind: z15.literal("command.rejected"),
3050
+ runId: id14,
3051
+ attemptId: id14,
3052
+ commandId: id14,
3053
+ reason: z15.string().max(1024)
450
3054
  }),
451
- z3.strictObject({ kind: z3.literal("revoked_not_started"), runId: id2, attemptId: id2 })
3055
+ z15.strictObject({ kind: z15.literal("revoked_not_started"), runId: id14, attemptId: id14 })
452
3056
  ]);
453
- var repositoryRefSchema = z3.string().min(1).max(512).regex(
3057
+ var repositoryRefSchema = z15.string().min(1).max(512).regex(
454
3058
  /^(?![-/])(?!.*\.\.)(?!.*@\{)(?!.*(?:^|\/)\.)(?!.*\.lock(?:\/|$))(?!.*\/\/)[^\x00-\x20\x7f~^:?*\[\\]+(?<![/.])$/
455
3059
  );
456
- var repositoryWorkingDirectorySchema = z3.string().min(1).max(1024).regex(
3060
+ var repositoryWorkingDirectorySchema = z15.string().min(1).max(1024).regex(
457
3061
  /^(?:\.|(?!\/)(?!.*(?:^|\/)\.\.?(?:\/|$))(?!.*(?:^|\/)\.git(?:\/|$))[^\x00-\x1f\x7f\\:]+(?<!\/))$/
458
3062
  );
459
3063
  var repositoryIdentity = {
460
- repositoryId: z3.number().int().positive().max(Number.MAX_SAFE_INTEGER),
461
- installationId: z3.number().int().positive().max(Number.MAX_SAFE_INTEGER),
462
- owner: z3.string().min(1).max(100).regex(/^[a-zA-Z0-9][a-zA-Z0-9-]*$/),
463
- name: z3.string().min(1).max(100).regex(/^(?!\.{1,2}$)[a-zA-Z0-9_.-]+$/)
3064
+ repositoryId: z15.number().int().positive().max(Number.MAX_SAFE_INTEGER),
3065
+ installationId: z15.number().int().positive().max(Number.MAX_SAFE_INTEGER),
3066
+ owner: z15.string().min(1).max(100).regex(/^[a-zA-Z0-9][a-zA-Z0-9-]*$/),
3067
+ name: z15.string().min(1).max(100).regex(/^(?!\.{1,2}$)[a-zA-Z0-9_.-]+$/)
464
3068
  };
465
- var repositoryBindingSchema = z3.strictObject({
466
- id: id2,
467
- label: z3.string().min(1).max(160),
3069
+ var repositoryBindingSchema = z15.strictObject({
3070
+ id: id14,
3071
+ label: z15.string().min(1).max(160),
468
3072
  ...repositoryIdentity,
469
3073
  defaultRef: repositoryRefSchema,
470
3074
  workingDirectory: repositoryWorkingDirectorySchema,
471
- setupCommands: z3.array(z3.string().min(1).max(8192)).max(16),
3075
+ setupCommands: z15.array(z15.string().min(1).max(8192)).max(16),
472
3076
  revision: positive,
473
- enabled: z3.boolean()
3077
+ enabled: z15.boolean()
474
3078
  });
475
- var repositorySourceSchema = z3.strictObject({
476
- bindingId: id2,
3079
+ var repositorySourceSchema = z15.strictObject({
3080
+ bindingId: id14,
477
3081
  ...repositoryIdentity,
478
3082
  ref: repositoryRefSchema,
479
- commitSha: z3.string().regex(/^[0-9a-f]{40}$/),
3083
+ commitSha: z15.string().regex(/^[0-9a-f]{40}$/),
480
3084
  branch: repositoryRefSchema,
481
3085
  workingDirectory: repositoryWorkingDirectorySchema,
482
- setupCommands: z3.array(z3.string().min(1).max(8192)).max(16),
3086
+ setupCommands: z15.array(z15.string().min(1).max(8192)).max(16),
483
3087
  configRevision: positive
484
3088
  });
485
- var workflowSourceSchema = z3.string().max(201).regex(/^[A-Za-z0-9][A-Za-z0-9_.-]*\/[A-Za-z0-9][A-Za-z0-9_.-]*$/);
486
- var workflowReferenceSchema = z3.union([
487
- z3.string().max(512),
488
- z3.strictObject({
489
- name: z3.string().min(1).max(128).regex(/^[A-Za-z0-9][A-Za-z0-9_-]*$/),
3089
+ var workflowSourceSchema = z15.string().max(201).regex(/^[A-Za-z0-9][A-Za-z0-9_.-]*\/[A-Za-z0-9][A-Za-z0-9_.-]*$/);
3090
+ var workflowReferenceSchema = z15.union([
3091
+ z15.string().max(512),
3092
+ z15.strictObject({
3093
+ name: z15.string().min(1).max(128).regex(/^[A-Za-z0-9][A-Za-z0-9_-]*$/),
490
3094
  source: workflowSourceSchema.optional(),
491
- ref: z3.string().min(1).max(512).optional(),
492
- version: z3.string().min(1).max(128).regex(/^\d[A-Za-z0-9_.+-]*$/).optional()
3095
+ ref: z15.string().min(1).max(512).optional(),
3096
+ version: z15.string().min(1).max(128).regex(/^\d[A-Za-z0-9_.+-]*$/).optional()
493
3097
  })
494
3098
  ]);
495
3099
  var workflowName = (workflow) => typeof workflow === "object" ? workflow.name : workflow;
496
3100
  var installReference = (workflow) => typeof workflow === "object" && workflow.source !== void 0 ? workflow : void 0;
497
3101
  var sameWorkflow = (a, b) => canonicalJson(a ?? null) === canonicalJson(b ?? null);
498
- var runSpecSchema = z3.strictObject({
499
- prompt: z3.string().min(1).max(131072),
500
- projectDir: z3.string().min(1).max(4096),
3102
+ var gateModeSchema = z15.enum(["ask", "auto"]);
3103
+ var gateOverridesSchema = z15.strictObject({
3104
+ planApproval: gateModeSchema.optional(),
3105
+ merge: gateModeSchema.optional(),
3106
+ budget: gateModeSchema.optional(),
3107
+ irreversible: gateModeSchema.optional()
3108
+ });
3109
+ var tokenBudgetSchema = z15.number().int().positive().max(Number.MAX_SAFE_INTEGER);
3110
+ var runSpecSchema = z15.strictObject({
3111
+ prompt: z15.string().min(1).max(131072),
3112
+ projectDir: z15.string().min(1).max(4096),
501
3113
  harness: harnessSchema,
502
3114
  workflow: workflowReferenceSchema.optional(),
503
- repository: repositorySourceSchema.optional()
504
- });
505
- var runKeySchema = z3.string().min(1).max(160);
506
- var delegationSchema = z3.strictObject({
507
- // Omitted: follow the Runner capacity. An explicit value is a per-Build ceiling.
508
- maxChildren: z3.number().int().min(1).max(64).optional(),
509
- tokenBudget: z3.number().int().positive().max(Number.MAX_SAFE_INTEGER)
510
- });
511
- var tokenCapSchema = z3.number().int().positive().max(Number.MAX_SAFE_INTEGER);
512
- var runParentIntentSchema = z3.strictObject({ runId: id2, tokenCap: tokenCapSchema.optional() });
513
- var runParentSchema = z3.strictObject({ runId: id2, tokenCap: tokenCapSchema });
514
- var commandSchema = z3.strictObject({
515
- commandId: id2,
516
- hubEpoch: id2,
517
- runId: id2,
518
- expectedRecordRevision: sequence.optional(),
519
- intent: z3.discriminatedUnion("kind", [
520
- z3.strictObject({
521
- kind: z3.literal("start"),
522
- sessionId: id2,
3115
+ repository: repositorySourceSchema.optional(),
3116
+ /** DRI-367: the Build's gates, applied as the "Build" source (tighten only). Only to a `build_gates_v1` runner. */
3117
+ gates: gateOverridesSchema.optional(),
3118
+ /**
3119
+ * DRI-367: the member's token budget for this Run's own stop (root ADR-0011 as amended by ADR-0018), at start. It
3120
+ * replaces the Workflow's `maxRunTokens`. A `setBudget` rewrites the Run's budget on the Hub, never this field: a
3121
+ * grant's `tokenBudget` is the current value. Only to a `build_gates_v1` runner.
3122
+ */
3123
+ tokenBudget: tokenBudgetSchema.optional()
3124
+ });
3125
+ var runKeySchema = z15.string().min(1).max(160);
3126
+ var delegationSchema = z15.strictObject({
3127
+ maxChildren: z15.number().int().min(1).max(64).optional(),
3128
+ tokenBudget: tokenBudgetSchema
3129
+ });
3130
+ var commandSchema = z15.strictObject({
3131
+ commandId: id14,
3132
+ hubEpoch: id14,
3133
+ runId: id14,
3134
+ expectedRecordRevision: sequence2.optional(),
3135
+ intent: z15.discriminatedUnion("kind", [
3136
+ z15.strictObject({
3137
+ kind: z15.literal("start"),
3138
+ sessionId: id14,
523
3139
  /**
524
3140
  * Absent: the Hub resolves the Runner member-first (root ADR-0005): the Session's conversation Runner, else
525
3141
  * the starting member's own ready Personal Runner, else the Team default, else the start is refused.
526
3142
  */
527
- runnerId: id2.optional(),
528
- computeProfileId: id2.optional(),
3143
+ runnerId: id14.optional(),
3144
+ computeProfileId: id14.optional(),
529
3145
  scope: scopeSchema,
530
3146
  spec: runSpecSchema,
531
3147
  key: runKeySchema.optional(),
532
- /** Member starts only. */
533
- delegation: delegationSchema.optional(),
534
- /** Delegated starts only, and required on them. */
535
- parent: runParentIntentSchema.optional()
3148
+ /** Member starts only: mints the Run a delegation token per attempt. */
3149
+ delegation: delegationSchema.optional()
536
3150
  }),
537
- z3.strictObject({ kind: z3.literal("cancel") }),
538
- z3.strictObject({ kind: z3.literal("abandon") }),
539
- z3.strictObject({ kind: z3.literal("steer"), text: z3.string().min(1).max(131072) }),
540
- z3.strictObject({
541
- kind: z3.literal("answer"),
542
- interruptionId: id2,
3151
+ z15.strictObject({ kind: z15.literal("cancel") }),
3152
+ z15.strictObject({ kind: z15.literal("abandon") }),
3153
+ z15.strictObject({ kind: z15.literal("steer"), text: z15.string().min(1).max(131072) }),
3154
+ z15.strictObject({
3155
+ kind: z15.literal("answer"),
3156
+ interruptionId: id14,
543
3157
  expectedInterruptionRevision: positive,
544
- requestId: id2.optional(),
545
- answer: z3.json()
3158
+ requestId: id14.optional(),
3159
+ answer: z15.json()
546
3160
  }),
547
- z3.strictObject({
548
- kind: z3.literal("resume"),
549
- interruptionId: id2,
550
- guidance: z3.string().max(131072).optional()
3161
+ z15.strictObject({
3162
+ kind: z15.literal("resume"),
3163
+ interruptionId: id14,
3164
+ guidance: z15.string().max(131072).optional()
551
3165
  }),
552
3166
  /**
553
- * A member rewrites an Orchestrator's `delegation.tokenBudget` (root ADR-0011), never below what its children
554
- * used. With `resume`, a parked Orchestrator with no live child is resumed when the value is strictly greater.
555
- * Hub-only: never delivered to a Runner.
3167
+ * A member rewrites a Run's own token budget (root ADR-0011, DRI-367), never below what it used. With `resume`, a
3168
+ * parked Run is resumed when the value is strictly greater. Hub-only: never delivered to a Runner.
556
3169
  */
557
- z3.strictObject({
558
- kind: z3.literal("setBudget"),
559
- tokenBudget: delegationSchema.shape.tokenBudget,
560
- resume: z3.boolean().optional()
3170
+ z15.strictObject({
3171
+ kind: z15.literal("setBudget"),
3172
+ tokenBudget: tokenBudgetSchema,
3173
+ resume: z15.boolean().optional()
561
3174
  })
562
3175
  ])
563
3176
  });
564
- var deliveredCommandSchema = commandSchema.extend({ orchestratorRunId: id2.optional() });
565
- var grantSchema = z3.strictObject({
566
- commandId: id2,
567
- hubEpoch: id2,
568
- runId: id2,
569
- sessionId: id2,
570
- runnerId: id2,
571
- installationId: id2,
572
- attemptId: id2,
3177
+ var deliveredCommandSchema = commandSchema.extend({ orchestratorRunId: id14.optional() });
3178
+ var grantSchema = z15.strictObject({
3179
+ commandId: id14,
3180
+ hubEpoch: id14,
3181
+ runId: id14,
3182
+ sessionId: id14,
3183
+ runnerId: id14,
3184
+ installationId: id14,
3185
+ attemptId: id14,
573
3186
  generation: positive,
574
- baseExecutionRevision: sequence,
575
- baseHistorySeq: sequence,
576
- cloudHistoryThrough: sequence,
577
- purpose: z3.enum(["start", "resume"]),
3187
+ baseExecutionRevision: sequence2,
3188
+ baseHistorySeq: sequence2,
3189
+ cloudHistoryThrough: sequence2,
3190
+ purpose: z15.enum(["start", "resume"]),
578
3191
  spec: runSpecSchema,
579
- continuation: z3.json().optional(),
3192
+ continuation: z15.json().optional(),
580
3193
  /** Authenticated source of a delegated continuation; absence retains member semantics. */
581
- orchestratorRunId: id2.optional(),
3194
+ orchestratorRunId: id14.optional(),
582
3195
  /** A new Run in a durable conversation; never resumes the predecessor's lifecycle. */
583
- previousRun: z3.strictObject({
584
- runId: id2,
585
- executionRevision: sequence,
586
- historyProduced: sequence,
3196
+ previousRun: z15.strictObject({
3197
+ runId: id14,
3198
+ executionRevision: sequence2,
3199
+ historyProduced: sequence2,
587
3200
  /** Hub-confirmed administrative closure; allows an exact parked predecessor snapshot. */
588
- closeReason: z3.literal("abandoned").optional(),
589
- checkpoint: z3.strictObject({ checkpointId: id2, checksum: z3.string().regex(/^[a-f0-9]{64}$/) }).optional()
3201
+ closeReason: z15.literal("abandoned").optional(),
3202
+ checkpoint: z15.strictObject({ checkpointId: id14, checksum: z15.string().regex(/^[a-f0-9]{64}$/) }).optional()
590
3203
  }).optional(),
591
- checkpoint: z3.strictObject({ checkpointId: id2, checksum: z3.string().regex(/^[a-f0-9]{64}$/) }).optional(),
592
- /** This attempt's delegation token: only for a Run started with `delegation`, only to a `run_delegation_v1` Runner. */
593
- delegationToken: z3.string().min(32).max(256).optional(),
594
- /** Copied from the start intent of a delegated child. */
595
- parent: runParentSchema.optional(),
3204
+ checkpoint: z15.strictObject({ checkpointId: id14, checksum: z15.string().regex(/^[a-f0-9]{64}$/) }).optional(),
3205
+ /**
3206
+ * This attempt's delegation token: for a Run started with `delegation` or a coordinated Run's credential, only to a
3207
+ * `run_delegation_v1` Runner.
3208
+ */
3209
+ delegationToken: z15.string().min(32).max(256).optional(),
596
3210
  /** The runner reports this attempt's usage: set only for a `run_usage_v1` Runner. */
597
- reportUsage: z3.literal(true).optional()
3211
+ reportUsage: z15.literal(true).optional(),
3212
+ /**
3213
+ * DRI-322: open the session-control channel for this attempt: set only for a coordination-bound Run on a Runner that
3214
+ * advertises `active_session_control_v1`. Any other Run (a chat, a Build) gets no relay.
3215
+ */
3216
+ sessionControl: z15.literal(true).optional(),
3217
+ /**
3218
+ * DRI-330: the Run works under a coordinating parent (a coordinated specialist, or a child execution's coordinator):
3219
+ * its NEEDS_ORCHESTRATOR question is that parent's to answer. Set only on a `coordination_supervision_v1` runner.
3220
+ */
3221
+ supervised: z15.literal(true).optional(),
3222
+ /**
3223
+ * DRI-367: the Run's current token budget, for a Run started with `spec.tokenBudget`: what the member last set
3224
+ * (`setBudget`), so a resumed attempt stops at the new value. Only to a `build_gates_v1` runner.
3225
+ */
3226
+ tokenBudget: tokenBudgetSchema.optional(),
3227
+ /**
3228
+ * DRI-367: the Team's gates, the floor of the gate resolution with the runner's global config. Reserved: the Hub has
3229
+ * no Team gate setting yet, so it never sets this. Only to a `build_gates_v1` runner.
3230
+ */
3231
+ teamGates: gateOverridesSchema.optional()
598
3232
  });
599
- var historyRecordSchema = z3.strictObject({
600
- eventId: id2,
601
- attemptId: id2,
602
- emittedAt: timestamp,
603
- kind: z3.string().min(1).max(128),
604
- data: z3.json()
3233
+ var historyRecordSchema = z15.strictObject({
3234
+ eventId: id14,
3235
+ attemptId: id14,
3236
+ emittedAt: timestamp12,
3237
+ kind: z15.string().min(1).max(128),
3238
+ data: z15.json()
605
3239
  });
606
- var runnerFrameSchema = z3.discriminatedUnion("type", [
607
- z3.strictObject({
608
- type: z3.literal("hello"),
609
- role: z3.literal("runner"),
610
- protocol: z3.strictObject({ major: z3.literal(2), minor: sequence }),
611
- runnerId: id2,
612
- installationId: id2,
613
- softwareVersion: z3.string().max(128),
614
- capabilities: z3.array(z3.string().max(128)).max(64),
3240
+ var runnerFrameSchema = z15.discriminatedUnion("type", [
3241
+ z15.strictObject({
3242
+ type: z15.literal("hello"),
3243
+ role: z15.literal("runner"),
3244
+ protocol: z15.strictObject({ major: z15.literal(2), minor: sequence2 }),
3245
+ runnerId: id14,
3246
+ installationId: id14,
3247
+ softwareVersion: z15.string().max(128),
3248
+ capabilities: z15.array(z15.string().max(128)).max(64),
615
3249
  /** Absent from older runners: the Hub treats the inventory as unknown, never as empty. */
616
3250
  workflows: installedWorkflowsSchema.optional(),
617
3251
  /** Absent from older runners, and from a runner that has not finished its first check: unknown, not "not ready". */
618
3252
  readiness: runnerReadinessSchema.optional(),
619
- control: z3.strictObject({ firstRetainedSeq: positive, lastProducedSeq: sequence })
3253
+ control: z15.strictObject({ firstRetainedSeq: positive, lastProducedSeq: sequence2 })
620
3254
  }),
621
- z3.strictObject({
622
- type: z3.literal("control.batch"),
3255
+ z15.strictObject({
3256
+ type: z15.literal("control.batch"),
623
3257
  firstSeq: positive,
624
- records: z3.array(controlRecordSchema).min(1).max(128)
3258
+ records: z15.array(controlRecordSchema).min(1).max(128)
625
3259
  }),
626
- z3.strictObject({
627
- type: z3.literal("history.batch"),
628
- runId: id2,
3260
+ z15.strictObject({
3261
+ type: z15.literal("history.batch"),
3262
+ runId: id14,
629
3263
  firstSeq: positive,
630
- records: z3.array(historyRecordSchema).min(1).max(128)
3264
+ records: z15.array(historyRecordSchema).min(1).max(128)
631
3265
  }),
632
- z3.strictObject({ type: z3.literal("ping"), nonce: id2 }),
633
- z3.strictObject({
634
- type: z3.literal("reconcile.page"),
635
- inventoryId: id2.default("single-page"),
636
- page: sequence.default(0),
637
- complete: z3.boolean(),
638
- runs: z3.array(
639
- z3.strictObject({
640
- runId: id2,
641
- attemptId: id2,
642
- executionRevision: sequence,
643
- phase: z3.enum(["admitted", "prepared", "executing", "parked", "terminal", "recovery"])
3266
+ z15.strictObject({ type: z15.literal("ping"), nonce: id14 }),
3267
+ z15.strictObject({
3268
+ type: z15.literal("reconcile.page"),
3269
+ inventoryId: id14.default("single-page"),
3270
+ page: sequence2.default(0),
3271
+ complete: z15.boolean(),
3272
+ runs: z15.array(
3273
+ z15.strictObject({
3274
+ runId: id14,
3275
+ attemptId: id14,
3276
+ executionRevision: sequence2,
3277
+ phase: z15.enum(["admitted", "prepared", "executing", "parked", "terminal", "recovery"])
644
3278
  })
645
3279
  ).max(128)
646
3280
  })
647
3281
  ]);
648
- var runViewSchema = z3.object({
649
- runId: id2,
650
- sessionId: id2,
651
- runnerId: id2,
652
- computeProfileId: id2.optional(),
3282
+ var runViewSchema = z15.object({
3283
+ runId: id14,
3284
+ sessionId: id14,
3285
+ runnerId: id14,
3286
+ computeProfileId: id14.optional(),
653
3287
  scope: scopeSchema,
654
3288
  recordRevision: positive,
655
- label: z3.string().max(160).optional(),
3289
+ label: z15.string().max(160).optional(),
656
3290
  key: runKeySchema.optional(),
657
- parent: runParentSchema.optional(),
658
- /**
659
- * Not strict, unlike the start intent's: a Hub keeps more on the Run's delegation (`initialTokenBudget`) than it
660
- * shows, and a client never refuses a view for a field it does not read.
661
- */
662
- delegation: z3.object({
663
- ...delegationSchema.shape,
664
- // A resolved Runner default may exceed the explicit settings ceiling on configured Runners.
665
- maxChildren: z3.number().int().positive().max(Number.MAX_SAFE_INTEGER).optional()
666
- }).optional(),
3291
+ /** The start's `delegation`, as the Run's token grant. Not strict: a client never refuses a view for a field it does not read. */
3292
+ delegation: z15.object({ tokenBudget: tokenBudgetSchema }).optional(),
667
3293
  /** The largest cumulative usage the Run's Runner reported; absent until one does (an older Runner never does). */
668
3294
  usage: runUsageSchema.optional(),
3295
+ /**
3296
+ * DRI-367: a Run's own token budget (started with `spec.tokenBudget`), as the member last set it, and how many
3297
+ * `setBudget` commands raised it. Absent for any other Run.
3298
+ */
3299
+ tokenBudget: tokenBudgetSchema.optional(),
3300
+ raiseCount: sequence2.optional(),
669
3301
  /** Resolved by the runner at start; absent until the Run starts and for runners that predate reporting. */
670
3302
  workflow: workflowIdentitySchema.optional(),
671
- execution: z3.object({
672
- status: z3.enum(["running", "awaiting_attention", "completed", "failed", "cancelled"]),
3303
+ execution: z15.object({
3304
+ status: z15.enum(["running", "awaiting_attention", "completed", "failed", "cancelled"]),
673
3305
  revision: positive,
674
- attemptId: id2,
675
- occupancy: z3.enum(["held", "released"]),
676
- startedAt: timestamp.optional(),
677
- endedAt: timestamp.optional(),
3306
+ attemptId: id14,
3307
+ occupancy: z15.enum(["held", "released"]),
3308
+ startedAt: timestamp12.optional(),
3309
+ endedAt: timestamp12.optional(),
678
3310
  interruption: interruptionSchema.optional()
679
3311
  }).nullable(),
680
- scheduling: z3.enum(["queued", "dispatching", "admitted", "idle"]),
681
- closed: z3.boolean(),
682
- closeReason: z3.string().optional(),
683
- cancellation: id2.optional(),
3312
+ scheduling: z15.enum(["queued", "dispatching", "admitted", "idle"]),
3313
+ closed: z15.boolean(),
3314
+ closeReason: z15.string().optional(),
3315
+ cancellation: id14.optional(),
684
3316
  pendingResume: commandSchema.shape.intent.optional(),
685
3317
  /** Derived per viewer; absent on older Hubs. Never grants execution authority. */
686
- runnerStopped: z3.boolean().optional(),
687
- canAbandon: z3.boolean().optional(),
688
- historyThrough: sequence,
689
- expectedHistoryThrough: sequence.optional(),
690
- createdAt: sequence,
691
- checkpoint: z3.object({ id: id2, state: z3.enum(["pending", "ready"]), checksum: z3.string().optional() }).optional()
692
- });
693
- var clientFrameSchema = z3.discriminatedUnion("type", [
694
- z3.strictObject({ type: z3.literal("watch"), hubEpoch: id2, runIds: z3.array(id2).max(100) }),
695
- z3.strictObject({ type: z3.literal("watch.ack"), subscriptionId: id2, through: sequence }),
696
- z3.strictObject({ type: z3.literal("command.submit"), command: commandSchema }),
697
- z3.strictObject({ type: z3.literal("ping"), nonce: id2 })
3318
+ runnerStopped: z15.boolean().optional(),
3319
+ canAbandon: z15.boolean().optional(),
3320
+ historyThrough: sequence2,
3321
+ expectedHistoryThrough: sequence2.optional(),
3322
+ createdAt: sequence2,
3323
+ checkpoint: z15.object({ id: id14, state: z15.enum(["pending", "ready"]), checksum: z15.string().optional() }).optional()
3324
+ });
3325
+ var clientFrameSchema = z15.discriminatedUnion("type", [
3326
+ z15.strictObject({ type: z15.literal("watch"), hubEpoch: id14, runIds: z15.array(id14).max(100) }),
3327
+ z15.strictObject({ type: z15.literal("watch.ack"), subscriptionId: id14, through: sequence2 }),
3328
+ z15.strictObject({ type: z15.literal("command.submit"), command: commandSchema }),
3329
+ z15.strictObject({ type: z15.literal("ping"), nonce: id14 })
698
3330
  ]);
699
3331
  function canonicalJson(value) {
700
3332
  if (value === null || typeof value !== "object") {
@@ -705,78 +3337,78 @@ function canonicalJson(value) {
705
3337
  if (Array.isArray(value)) return `[${value.map(canonicalJson).join(",")}]`;
706
3338
  return `{${Object.entries(value).filter(([, v]) => v !== void 0).sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0).map(([k, v]) => `${JSON.stringify(k)}:${canonicalJson(v)}`).join(",")}}`;
707
3339
  }
708
- var checkpointPathSchema = z3.string().min(1).max(4096).refine(
3340
+ var checkpointPathSchema = z15.string().min(1).max(4096).refine(
709
3341
  (path) => !path.startsWith("/") && !path.includes("\\") && path.split("/").every((part) => part !== "" && part !== "." && part !== ".." && part !== ".git")
710
3342
  );
711
- var checkpointSchema = z3.strictObject({
712
- version: z3.literal(1),
713
- checkpointId: z3.string().min(1),
714
- orgId: z3.string().min(1),
715
- phase: z3.enum(["parked", "terminal"]),
716
- runId: z3.string().min(1),
717
- sessionId: z3.string().min(1),
718
- sourceAttemptId: z3.string().min(1),
719
- executionRevision: z3.number().int().positive().max(Number.MAX_SAFE_INTEGER),
720
- historyProduced: z3.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER),
721
- historyAck: z3.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER),
3343
+ var checkpointSchema = z15.strictObject({
3344
+ version: z15.literal(1),
3345
+ checkpointId: z15.string().min(1),
3346
+ orgId: z15.string().min(1),
3347
+ phase: z15.enum(["parked", "terminal"]),
3348
+ runId: z15.string().min(1),
3349
+ sessionId: z15.string().min(1),
3350
+ sourceAttemptId: z15.string().min(1),
3351
+ executionRevision: z15.number().int().positive().max(Number.MAX_SAFE_INTEGER),
3352
+ historyProduced: z15.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER),
3353
+ historyAck: z15.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER),
722
3354
  grant: grantSchema,
723
- gitHead: z3.string().regex(/^[0-9a-f]{40,64}$/),
724
- gitBase: z3.string().regex(/^[0-9a-f]{40,64}$/).optional(),
725
- gitBundle: z3.string(),
726
- indexPatch: z3.string(),
727
- files: z3.array(
728
- z3.strictObject({ path: checkpointPathSchema, content: z3.string(), executable: z3.boolean() })
3355
+ gitHead: z15.string().regex(/^[0-9a-f]{40,64}$/),
3356
+ gitBase: z15.string().regex(/^[0-9a-f]{40,64}$/).optional(),
3357
+ gitBundle: z15.string(),
3358
+ indexPatch: z15.string(),
3359
+ files: z15.array(
3360
+ z15.strictObject({ path: checkpointPathSchema, content: z15.string(), executable: z15.boolean() })
729
3361
  ).max(1e5),
730
- deleted: z3.array(checkpointPathSchema).max(1e5),
731
- sessionRows: z3.array(z3.strictObject({ kind: z3.string(), id: z3.string(), payload: z3.string() })),
732
- history: z3.array(
733
- z3.strictObject({ seq: z3.number().int().positive(), record: historyRecordSchema })
3362
+ deleted: z15.array(checkpointPathSchema).max(1e5),
3363
+ sessionRows: z15.array(z15.strictObject({ kind: z15.string(), id: z15.string(), payload: z15.string() })),
3364
+ history: z15.array(
3365
+ z15.strictObject({ seq: z15.number().int().positive(), record: historyRecordSchema })
734
3366
  )
735
3367
  });
736
3368
  var connectCodeAlphabet = "ABCDEFGHJKMNPQRSTUVWXYZ23456789";
737
- var connectCodeSchema = z3.string().regex(/^[A-HJKMNP-Z2-9]{8}$/);
738
- var connectCodeRequestSchema = z3.strictObject({ hubEpoch: z3.string() });
739
- var connectCodeResponseSchema = z3.strictObject({
3369
+ var connectCodeSchema = z15.string().regex(/^[A-HJKMNP-Z2-9]{8}$/);
3370
+ var connectCodeRequestSchema = z15.strictObject({ hubEpoch: z15.string() });
3371
+ var connectCodeResponseSchema = z15.strictObject({
740
3372
  code: connectCodeSchema,
741
- expiresAt: sequence
742
- });
743
- var connectRedeemRequestSchema = z3.strictObject({
744
- code: z3.string().min(8).max(16),
745
- installationId: id2,
746
- hostname: z3.string().min(1).max(255),
747
- os: z3.string().min(1).max(64),
748
- softwareVersion: z3.string().min(1).max(128)
749
- });
750
- var connectRedeemResponseSchema = z3.strictObject({
751
- orgId: id2,
752
- hubEpoch: z3.string(),
753
- runnerId: id2,
754
- installationId: id2,
755
- name: z3.string(),
756
- token: z3.string().min(32),
757
- credentialId: id2,
758
- expiresAt: sequence
759
- });
760
- var connectAlreadyConnectedSchema = z3.strictObject({
761
- error: z3.literal("runner_already_connected"),
762
- orgId: id2,
763
- runnerId: id2,
764
- name: z3.string()
765
- });
766
- var audienceSchema = z3.enum(["personal", "team"]);
767
- var runnerListEntrySchema = z3.object({
768
- id: id2,
769
- online: z3.number(),
770
- capacity: z3.number(),
771
- managed: z3.number(),
772
- draining: z3.number(),
773
- stopped: z3.number(),
774
- name: z3.string().nullable(),
775
- connectedBy: z3.string().nullable(),
3373
+ expiresAt: sequence2
3374
+ });
3375
+ var connectRedeemRequestSchema = z15.strictObject({
3376
+ code: z15.string().min(8).max(16),
3377
+ installationId: id14,
3378
+ hostname: z15.string().min(1).max(255),
3379
+ os: z15.string().min(1).max(64),
3380
+ softwareVersion: z15.string().min(1).max(128)
3381
+ });
3382
+ var connectRedeemResponseSchema = z15.strictObject({
3383
+ orgId: id14,
3384
+ hubEpoch: z15.string(),
3385
+ runnerId: id14,
3386
+ installationId: id14,
3387
+ name: z15.string(),
3388
+ token: z15.string().min(32),
3389
+ credentialId: id14,
3390
+ expiresAt: sequence2
3391
+ });
3392
+ var connectAlreadyConnectedSchema = z15.strictObject({
3393
+ error: z15.literal("runner_already_connected"),
3394
+ orgId: id14,
3395
+ runnerId: id14,
3396
+ name: z15.string()
3397
+ });
3398
+ var audienceSchema = z15.enum(["personal", "team"]);
3399
+ var runnerListEntrySchema = z15.object({
3400
+ id: id14,
3401
+ online: z15.number(),
3402
+ capacity: z15.number(),
3403
+ managed: z15.number(),
3404
+ draining: z15.number(),
3405
+ stopped: z15.number(),
3406
+ name: z15.string().nullable(),
3407
+ connectedBy: z15.string().nullable(),
776
3408
  audience: audienceSchema.nullable(),
777
- softwareVersion: z3.string().nullable(),
3409
+ softwareVersion: z15.string().nullable(),
778
3410
  /** Milliseconds since the epoch of the last hello or disconnect; null before the first connection. */
779
- lastSeen: sequence.nullable(),
3411
+ lastSeen: sequence2.nullable(),
780
3412
  /** Absent when the runner has not reported an inventory: unknown, not none. */
781
3413
  workflows: installedWorkflowsSchema.optional(),
782
3414
  /**
@@ -784,125 +3416,119 @@ var runnerListEntrySchema = z3.object({
784
3416
  * Runner seen by an admin (who may still Disconnect it), or a Runner a member did not connect. Absent from Hubs
785
3417
  * older than Audience, like the list's `viewer`, `teamDefault` and `runsGoTo`.
786
3418
  */
787
- readOnly: z3.boolean().optional(),
3419
+ readOnly: z15.boolean().optional(),
788
3420
  /** What the Runner last reported; absent when it never has (an older runner, or one not yet connected). */
789
3421
  readiness: runnerReadinessSchema.optional(),
790
3422
  /**
791
3423
  * True when the Runner reported a version below the Hub's minimum: it is listed as "Update required" and takes no
792
3424
  * Runs until it is updated (`runnerUpdateCommand`). Absent from Hubs older than Readiness.
793
3425
  */
794
- updateRequired: z3.boolean().optional(),
3426
+ updateRequired: z15.boolean().optional(),
795
3427
  /**
796
3428
  * True while it is paused as "Needs an owner": the member who connected this Team Runner left the Team, so it
797
3429
  * takes no Runs until an admin adopts it (`/runners/{id}/adopt`) or Disconnects it. Absent from older Hubs.
798
3430
  */
799
- needsOwner: z3.boolean().optional()
3431
+ needsOwner: z15.boolean().optional()
800
3432
  });
801
- var teamDefaultSchema = z3.discriminatedUnion("kind", [
802
- z3.strictObject({ kind: z3.literal("runner"), runnerId: id2 }),
803
- z3.strictObject({ kind: z3.literal("profile"), profileId: id2 })
3433
+ var teamDefaultSchema = z15.discriminatedUnion("kind", [
3434
+ z15.strictObject({ kind: z15.literal("runner"), runnerId: id14 }),
3435
+ z15.strictObject({ kind: z15.literal("profile"), profileId: id14 })
804
3436
  ]);
805
- var teamDefaultRequestSchema = z3.strictObject({
806
- hubEpoch: z3.string(),
3437
+ var teamDefaultRequestSchema = z15.strictObject({
3438
+ hubEpoch: z15.string(),
807
3439
  teamDefault: teamDefaultSchema.nullable()
808
3440
  });
809
- var runnerUpdateRequestSchema = z3.strictObject({
810
- hubEpoch: z3.string(),
811
- name: z3.string().max(100).optional(),
812
- capacity: z3.number().int().min(1).max(64).optional(),
3441
+ var runnerUpdateRequestSchema = z15.strictObject({
3442
+ hubEpoch: z15.string(),
3443
+ name: z15.string().max(100).optional(),
3444
+ capacity: z15.number().int().min(1).max(64).optional(),
813
3445
  audience: audienceSchema.optional()
814
3446
  }).refine(
815
3447
  (update) => update.name !== void 0 || update.capacity !== void 0 || update.audience !== void 0,
816
3448
  { message: "nothing to update" }
817
3449
  );
818
- var runsGoToSchema = z3.union([
3450
+ var runsGoToSchema = z15.union([
819
3451
  /** The viewer's own Runner: Personal, or one they connected that was widened to Team (DRI-42). */
820
- z3.strictObject({ via: z3.literal("personal"), runnerId: id2 }),
821
- z3.strictObject({ via: z3.literal("team_default"), runnerId: id2 }),
822
- z3.strictObject({ via: z3.literal("team_default"), profileId: id2 }),
3452
+ z15.strictObject({ via: z15.literal("personal"), runnerId: id14 }),
3453
+ z15.strictObject({ via: z15.literal("team_default"), runnerId: id14 }),
3454
+ z15.strictObject({ via: z15.literal("team_default"), profileId: id14 }),
823
3455
  /** `runner_needs_owner`: the Team default is a Runner paused because the member who connected it left. */
824
- z3.strictObject({ via: z3.literal("none"), reason: z3.enum(["no_runner_available", "runner_needs_owner"]) })
3456
+ z15.strictObject({ via: z15.literal("none"), reason: z15.enum(["no_runner_available", "runner_needs_owner"]) })
825
3457
  ]);
826
- var runnerListSchema = z3.object({
827
- capabilities: z3.record(z3.string(), z3.boolean()).optional(),
828
- historyRetentionDays: z3.number().int().positive().nullable().optional(),
3458
+ var runnerListSchema = z15.object({
3459
+ capabilities: z15.record(z15.string(), z15.boolean()).optional(),
3460
+ historyRetentionDays: z15.number().int().positive().nullable().optional(),
829
3461
  /** Who the list was filtered for: a member sees their own and Team Runners, an admin every Runner. */
830
- viewer: z3.object({ userId: z3.string(), admin: z3.boolean() }).optional(),
3462
+ viewer: z15.object({ userId: z15.string(), admin: z15.boolean() }).optional(),
831
3463
  teamDefault: teamDefaultSchema.nullable().optional(),
832
3464
  runsGoTo: runsGoToSchema.optional(),
833
3465
  /** The lowest Runner version this Hub sends Runs to. Absent from Hubs older than Readiness. */
834
- minimumRunnerVersion: z3.string().optional(),
835
- runners: z3.array(runnerListEntrySchema),
836
- profiles: z3.array(z3.object({
837
- id: z3.string(),
838
- label: z3.string(),
839
- projectDir: z3.string(),
840
- repositoryRequired: z3.boolean().optional(),
3466
+ minimumRunnerVersion: z15.string().optional(),
3467
+ runners: z15.array(runnerListEntrySchema),
3468
+ profiles: z15.array(z15.object({
3469
+ id: z15.string(),
3470
+ label: z15.string(),
3471
+ projectDir: z15.string(),
3472
+ repositoryRequired: z15.boolean().optional(),
841
3473
  /** Marketplace refs baked into the profile's image; absent when the profile declares none. */
842
- workflows: z3.array(z3.string()).optional(),
843
- workflowSources: z3.array(z3.string()).optional()
3474
+ workflows: z15.array(z15.string()).optional(),
3475
+ workflowSources: z15.array(z15.string()).optional()
844
3476
  }))
845
3477
  });
846
- var runnerDisconnectRequestSchema = z3.strictObject({ hubEpoch: z3.string() });
3478
+ var runnerDisconnectRequestSchema = z15.strictObject({ hubEpoch: z15.string() });
847
3479
  var hubEpochRequestSchema = runnerDisconnectRequestSchema;
848
- var runnerDisconnectPreviewSchema = z3.object({
849
- runnerId: id2,
850
- name: z3.string().nullable(),
851
- runs: z3.array(z3.object({
852
- runId: id2,
853
- label: z3.string().optional(),
3480
+ var runnerDisconnectPreviewSchema = z15.object({
3481
+ runnerId: id14,
3482
+ name: z15.string().nullable(),
3483
+ runs: z15.array(z15.object({
3484
+ runId: id14,
3485
+ label: z15.string().optional(),
854
3486
  /** Working: executing now. Parked: waiting for a person, Runner released. Queued: not started yet. */
855
- state: z3.enum(["working", "parked", "queued"])
3487
+ state: z15.enum(["working", "parked", "queued"])
856
3488
  })),
857
- hiddenRuns: z3.number().int().nonnegative()
3489
+ hiddenRuns: z15.number().int().nonnegative()
858
3490
  });
859
- var runnerDisconnectResponseSchema = z3.object({
860
- disconnected: z3.literal(true),
3491
+ var runnerDisconnectResponseSchema = z15.object({
3492
+ disconnected: z15.literal(true),
861
3493
  /** How many Runs were Stopped with the reason `runner_disconnected`. */
862
- stoppedRuns: z3.number().int().nonnegative()
3494
+ stoppedRuns: z15.number().int().nonnegative()
863
3495
  });
864
3496
  var runnerAdoptRequestSchema = hubEpochRequestSchema;
865
3497
  var connectStartRequestSchema = connectRedeemRequestSchema.omit({ code: true });
866
- var connectStartResponseSchema = z3.strictObject({
3498
+ var connectStartResponseSchema = z15.strictObject({
867
3499
  /** The machine's secret for polling; never shown. */
868
- deviceCode: z3.string().min(32).max(160),
3500
+ deviceCode: z15.string().min(32).max(160),
869
3501
  code: connectCodeSchema,
870
- expiresAt: sequence,
871
- intervalSec: z3.number().int().positive(),
3502
+ expiresAt: sequence2,
3503
+ intervalSec: z15.number().int().positive(),
872
3504
  /** The web console page that approves `code`. */
873
- verificationUrl: z3.string().url()
874
- });
875
- var connectPollRequestSchema = z3.strictObject({ deviceCode: z3.string().min(32).max(160) });
876
- var connectPendingResponseSchema = z3.strictObject({
877
- hostname: z3.string(),
878
- os: z3.string(),
879
- softwareVersion: z3.string(),
880
- requestedAt: sequence,
881
- expiresAt: sequence
882
- });
883
- var connectApproveRequestSchema = z3.strictObject({
884
- code: z3.string().min(8).max(16),
3505
+ verificationUrl: z15.string().url()
3506
+ });
3507
+ var connectPollRequestSchema = z15.strictObject({ deviceCode: z15.string().min(32).max(160) });
3508
+ var connectPendingResponseSchema = z15.strictObject({
3509
+ hostname: z15.string(),
3510
+ os: z15.string(),
3511
+ softwareVersion: z15.string(),
3512
+ requestedAt: sequence2,
3513
+ expiresAt: sequence2
3514
+ });
3515
+ var connectApproveRequestSchema = z15.strictObject({
3516
+ code: z15.string().min(8).max(16),
885
3517
  audience: audienceSchema,
886
- hubEpoch: z3.string().optional()
3518
+ hubEpoch: z15.string().optional()
887
3519
  });
888
- var connectDenyRequestSchema = z3.strictObject({ code: z3.string().min(8).max(16) });
3520
+ var connectDenyRequestSchema = z15.strictObject({ code: z15.string().min(8).max(16) });
889
3521
  export {
890
- CALIBRATION_MIN_RUNS,
891
- CALIBRATION_WINDOW_DAYS,
892
- SIZE_CLASS_CAPS,
893
- SIZE_CLASS_FORECASTS,
894
3522
  abandonedConversationContinuationCapability,
895
- attemptCost,
896
- attemptForecast,
3523
+ activeSessionControlCapability,
897
3524
  audienceSchema,
898
- budgetCheck,
899
3525
  buildCloseReasonSchema,
900
- calibrate,
901
- calibrationSchema,
3526
+ buildGatesCapability,
902
3527
  canonicalJson,
3528
+ capabilitySupport,
3529
+ capabilitySupportSchema,
903
3530
  checkpointPathSchema,
904
3531
  checkpointSchema,
905
- classOfCap,
906
3532
  clientFrameSchema,
907
3533
  commandSchema,
908
3534
  connectAlreadyConnectedSchema,
@@ -920,6 +3546,7 @@ export {
920
3546
  connectStartResponseSchema,
921
3547
  controlRecordSchema,
922
3548
  conversationContinuationCapability,
3549
+ coordinationSupervisionCapability,
923
3550
  defaultDeliveryWorkflow,
924
3551
  delegationSchema,
925
3552
  delegationTokenPrefix,
@@ -928,16 +3555,28 @@ export {
928
3555
  deliveryStageSchema,
929
3556
  deliveryTransitionSchema,
930
3557
  deliveryWorkflowSchema,
931
- forecastOfCap,
932
- forecastOfClass,
3558
+ gateModeSchema,
3559
+ gateOverridesSchema,
933
3560
  grantSchema,
934
3561
  harnessReadinessSchema,
935
3562
  harnessSchema,
3563
+ harnessSessionControlSchema,
936
3564
  historyRecordSchema,
937
3565
  hubEpochRequestSchema,
3566
+ inFlightToolSchema,
938
3567
  installReference,
939
3568
  installedWorkflowsSchema,
940
3569
  interruptionSchema,
3570
+ isWorkAttentionCommand,
3571
+ isWorkDeploymentCommand,
3572
+ isWorkDiscussionCommand,
3573
+ isWorkEvidenceCommand,
3574
+ isWorkImportCommand,
3575
+ isWorkMembershipCommand,
3576
+ isWorkPendingRelationCommand,
3577
+ isWorkRelationCommand,
3578
+ isWorkReservationCommand,
3579
+ isWorkSourceCommand,
941
3580
  orchestratorGuidanceCapability,
942
3581
  permissionAnswerSchema,
943
3582
  protocolVersion,
@@ -953,8 +3592,6 @@ export {
953
3592
  runCloseReasonSchema,
954
3593
  runDelegationCapability,
955
3594
  runKeySchema,
956
- runParentIntentSchema,
957
- runParentSchema,
958
3595
  runSpecSchema,
959
3596
  runUsageCapability,
960
3597
  runUsageSchema,
@@ -973,7 +3610,16 @@ export {
973
3610
  sameWorkflow,
974
3611
  scopeSchema,
975
3612
  secretEnvironmentSchema,
976
- sequence,
3613
+ selectWorkPath,
3614
+ sequence2 as sequence,
3615
+ sessionCapabilityNameSchema,
3616
+ sessionCapabilityNames,
3617
+ sessionCapabilitySchema,
3618
+ sessionControlCommandSchema,
3619
+ sessionControlHistoryKind,
3620
+ sessionControlObservationSchema,
3621
+ sessionControlRejectionSchema,
3622
+ supportedOperations,
977
3623
  teamDefaultRequestSchema,
978
3624
  teamDefaultSchema,
979
3625
  trackerCommentSchema,
@@ -985,6 +3631,259 @@ export {
985
3631
  trackerPlanSchema,
986
3632
  trackerSnapshotSchema,
987
3633
  trackerSourceSchema,
3634
+ workActivityKindSchema,
3635
+ workActivityPageSchema,
3636
+ workActivitySchema,
3637
+ workActorSchema,
3638
+ workAttachmentAvailabilitySchema,
3639
+ workAttachmentCheckPageSchema,
3640
+ workAttachmentCheckSchema,
3641
+ workAttachmentPageSchema,
3642
+ workAttachmentSchema,
3643
+ workAttentionActivityKindSchema,
3644
+ workAttentionActivityPageSchema,
3645
+ workAttentionActivitySchema,
3646
+ workAttentionCommandResultSchema,
3647
+ workAttentionCommandSchema,
3648
+ workAttentionCommandTypes,
3649
+ workAttentionErrorCodes,
3650
+ workAttentionReasonSchema,
3651
+ workAttentionRequestPageSchema,
3652
+ workAttentionRequestSchema,
3653
+ workAttentionResolutionSchema,
3654
+ workAttentionRunRefSchema,
3655
+ workAuthoritySchema,
3656
+ workAutomationSchema,
3657
+ workCandidateArtifactSchema,
3658
+ workCandidateDeploymentSchema,
3659
+ workCandidatePageSchema,
3660
+ workCandidateQaProfileSchema,
3661
+ workCandidateSchema,
3662
+ workCandidateSelectionSchema,
3663
+ workClientContract,
3664
+ workClientContractHeader,
3665
+ workClientContractMinimum,
3666
+ workClientOperations,
3667
+ workCommandResultSchema,
3668
+ workCommandSchema,
3669
+ workCommandVersion,
3670
+ workCommentBodySchema,
3671
+ workCommentEditSchema,
3672
+ workCommentPageSchema,
3673
+ workCommentRevisionPageSchema,
3674
+ workCommentRevisionSchema,
3675
+ workCommentSchema,
3676
+ workDeliveryGateFindingSchema,
3677
+ workDeliveryGateSchema,
3678
+ workDeliveryMigrationMappingSchema,
3679
+ workDeliveryMigrationPageSchema,
3680
+ workDeliveryMigrationSchema,
3681
+ workDeliveryRefSchema,
3682
+ workDeliveryRequirementSchema,
3683
+ workDeliverySlugSchema,
3684
+ workDeliveryStatusCategorySchema,
3685
+ workDeliveryStatusSchema,
3686
+ workDeliveryTransitionSchema,
3687
+ workDeliveryWorkflowDefinitionSchema,
3688
+ workDeliveryWorkflowPageSchema,
3689
+ workDeliveryWorkflowRevisionPageSchema,
3690
+ workDeliveryWorkflowRevisionSchema,
3691
+ workDeliveryWorkflowSchema,
3692
+ workDependencyGateSchema,
3693
+ workDependencyReasonSchema,
3694
+ workDependencyRemedySchema,
3695
+ workDeploymentActivityKindSchema,
3696
+ workDeploymentActivityPageSchema,
3697
+ workDeploymentActivitySchema,
3698
+ workDeploymentCommandResultSchema,
3699
+ workDeploymentCommandSchema,
3700
+ workDeploymentCommandTypes,
3701
+ workDeploymentErrorCodes,
3702
+ workDeploymentLifecycleSchema,
3703
+ workDeploymentPageSchema,
3704
+ workDeploymentPurposeSchema,
3705
+ workDeploymentSchema,
3706
+ workDiscussionActivityKindSchema,
3707
+ workDiscussionActivityPageSchema,
3708
+ workDiscussionActivitySchema,
3709
+ workDiscussionCommandResultSchema,
3710
+ workDiscussionCommandSchema,
3711
+ workDiscussionCommandTypes,
3712
+ workDiscussionErrorCodes,
3713
+ workDiscussionTombstoneSchema,
3714
+ workErrorCodes,
3715
+ workEvidenceActivityKindSchema,
3716
+ workEvidenceActivityPageSchema,
3717
+ workEvidenceActivitySchema,
3718
+ workEvidenceApplicabilitySchema,
3719
+ workEvidenceAssignmentSchema,
3720
+ workEvidenceAutomationSchema,
3721
+ workEvidenceCommandResultSchema,
3722
+ workEvidenceCommandSchema,
3723
+ workEvidenceCommandTypes,
3724
+ workEvidenceDecisionSchema,
3725
+ workEvidenceErrorCodes,
3726
+ workEvidencePageSchema,
3727
+ workEvidenceReferenceSchema,
3728
+ workEvidenceSchema,
3729
+ workEvidenceSourceAssertionSchema,
3730
+ workExecutionBindingPageSchema,
3731
+ workExecutionBindingSchema,
3732
+ workExecutionPolicySchema,
3733
+ workExecutionReservationPageSchema,
3734
+ workExecutionReservationSchema,
3735
+ workImportAttachmentSchema,
3736
+ workImportBatchPageSchema,
3737
+ workImportBatchSchema,
3738
+ workImportBodyLimit,
3739
+ workImportCollectionSchema,
3740
+ workImportCollectionStateSchema,
3741
+ workImportCollections,
3742
+ workImportCommandResultSchema,
3743
+ workImportCommandSchema,
3744
+ workImportCommandTypes,
3745
+ workImportCommentSchema,
3746
+ workImportCommitSchema,
3747
+ workImportCompletenessNoteSchema,
3748
+ workImportCompletenessSchema,
3749
+ workImportCompletenessSummarySchema,
3750
+ workImportCompletionSchema,
3751
+ workImportComponentPageSchema,
3752
+ workImportComponentSchema,
3753
+ workImportComponentStates,
3754
+ workImportContainerSchema,
3755
+ workImportDispositions,
3756
+ workImportEnvelopeSchema,
3757
+ workImportErrorCodes,
3758
+ workImportField,
3759
+ workImportFieldStates,
3760
+ workImportFindingSchema,
3761
+ workImportFormat,
3762
+ workImportFormatVersion,
3763
+ workImportGroupSchema,
3764
+ workImportIssueSchema,
3765
+ workImportItemPageSchema,
3766
+ workImportItemSchema,
3767
+ workImportKeySchema,
3768
+ workImportLabelSchema,
3769
+ workImportLimitSchema,
3770
+ workImportLimits,
3771
+ workImportMappingSchema,
3772
+ workImportOutcomePageSchema,
3773
+ workImportOutcomeSchema,
3774
+ workImportOutcomes,
3775
+ workImportPrincipalSchema,
3776
+ workImportRelationSchema,
3777
+ workImportSnapshotSchema,
3778
+ workImportStatusSchema,
3779
+ workImportTargetSchema,
3780
+ workImportUnsupportedSchema,
3781
+ workIssueAssigneePageSchema,
3782
+ workIssueAssigneeSchema,
3783
+ workIssueLabelPageSchema,
3784
+ workIssueLabelSchema,
3785
+ workIssueMembershipSchema,
3786
+ workIssuePageSchema,
3787
+ workIssueRelationKindSchema,
3788
+ workIssueRelationPageSchema,
3789
+ workIssueRelationSchema,
3790
+ workIssueReservationSchema,
3791
+ workIssueSchema,
3792
+ workIssueTransitionsSchema,
3793
+ workLabelColorSchema,
3794
+ workLabelIssuePageSchema,
3795
+ workLabelNameSchema,
3796
+ workLabelPageSchema,
3797
+ workLabelSchema,
3798
+ workLegacyAliasSchema,
3799
+ workLifecycleEventKindSchema,
3800
+ workLifecycleEventPageSchema,
3801
+ workLifecycleEventSchema,
3802
+ workLifecycleSchema,
3803
+ workLinkUrlSchema,
3804
+ workManualAttentionReasonSchema,
3805
+ workMembershipActivityKindSchema,
3806
+ workMembershipActivityPageSchema,
3807
+ workMembershipActivitySchema,
3808
+ workMembershipCommandResultSchema,
3809
+ workMembershipCommandSchema,
3810
+ workMembershipCommandTypes,
3811
+ workMembershipErrorCodes,
3812
+ workMembershipRemovalSchema,
3813
+ workOutstandingEffectSchema,
3814
+ workPageLimits,
3815
+ workPageSchema,
3816
+ workPendingRelationActivityKindSchema,
3817
+ workPendingRelationActivityPageSchema,
3818
+ workPendingRelationActivitySchema,
3819
+ workPendingRelationAttemptOutcomeSchema,
3820
+ workPendingRelationCommandResultSchema,
3821
+ workPendingRelationCommandSchema,
3822
+ workPendingRelationCommandTypes,
3823
+ workPendingRelationDispositionSchema,
3824
+ workPendingRelationDispositions,
3825
+ workPendingRelationErrorCodes,
3826
+ workPendingRelationKindSchema,
3827
+ workPendingRelationPageSchema,
3828
+ workPendingRelationSchema,
3829
+ workPlanPageSchema,
3830
+ workPlanSchema,
3831
+ workPrioritySchema,
3832
+ workProductionTrailEntrySchema,
3833
+ workProductionTrailPageSchema,
3834
+ workRefSchema,
3835
+ workRelationActivityKindSchema,
3836
+ workRelationActivityPageSchema,
3837
+ workRelationActivitySchema,
3838
+ workRelationCommandResultSchema,
3839
+ workRelationCommandSchema,
3840
+ workRelationCommandTypes,
3841
+ workRelationEndpointSchema,
3842
+ workRelationErrorCodes,
3843
+ workRelationRemovalSchema,
3844
+ workReservationActivityKindSchema,
3845
+ workReservationActivityPageSchema,
3846
+ workReservationActivitySchema,
3847
+ workReservationCommandResultSchema,
3848
+ workReservationCommandSchema,
3849
+ workReservationCommandTypes,
3850
+ workReservationErrorCodes,
3851
+ workReservationOwnerSchema,
3852
+ workRunAttentionReasonSchema,
3853
+ workScopeRevisionPageSchema,
3854
+ workScopeRevisionRefSchema,
3855
+ workScopeRevisionSchema,
3856
+ workSourceActivityKindSchema,
3857
+ workSourceActivityPageSchema,
3858
+ workSourceActivitySchema,
3859
+ workSourceAliasPageSchema,
3860
+ workSourceAliasSchema,
3861
+ workSourceAssociationPageSchema,
3862
+ workSourceAssociationSchema,
3863
+ workSourceCommandResultSchema,
3864
+ workSourceCommandSchema,
3865
+ workSourceCommandTypes,
3866
+ workSourceContainerSchema,
3867
+ workSourceErrorCodes,
3868
+ workSourceKeyLifecycleSchema,
3869
+ workSourceKeySchema,
3870
+ workSourcePrincipalPageSchema,
3871
+ workSourcePrincipalSchema,
3872
+ workSourceReferencePageSchema,
3873
+ workSourceReferenceSchema,
3874
+ workSourceSpacePageSchema,
3875
+ workSourceSpaceSchema,
3876
+ workSourceTargetSchema,
3877
+ workThreadOwnerSchema,
3878
+ workThreadSchema,
3879
+ workTranscriptHistorySchema,
3880
+ workTranscriptLinkPageSchema,
3881
+ workTranscriptLinkSchema,
3882
+ workUnsatisfiedDependencySchema,
3883
+ workVerificationAttemptPageSchema,
3884
+ workVerificationAttemptSchema,
3885
+ workVerificationOutcomeSchema,
3886
+ workVerificationStandingSchema,
988
3887
  workflowIdentitySchema,
989
3888
  workflowInstallCapability,
990
3889
  workflowName,