@ahmadposten/talos-wire 0.1.2 → 0.1.3

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/index.cjs CHANGED
@@ -380,14 +380,30 @@ const WorkflowAgentSchema = z.z.object({
380
380
  documents: z.z.array(z.z.object({ name: z.z.string().max(120), content: z.z.string().max(16e3) })).max(5)
381
381
  });
382
382
  const WorkflowSlotSchema = z.z.object({ agent: WorkflowAgentSchema, assignment: text });
383
+ const WorkflowStepSchema = z.z.object({
384
+ id: z.z.string().uuid(),
385
+ name: z.z.string().trim().min(1).max(80),
386
+ kind: z.z.enum(["plan", "execute", "review"]),
387
+ agents: z.z.array(WorkflowSlotSchema).min(1).max(3),
388
+ criteria: z.z.string().trim().max(24e3),
389
+ checks: z.z.array(z.z.object({ name: z.z.string().trim().min(1).max(100), command: z.z.string().trim().min(1).max(2e3) })).max(8)
390
+ });
391
+ function workflowProjection(steps) {
392
+ return {
393
+ planners: steps.find((s) => s.kind === "plan")?.agents ?? [],
394
+ executor: steps.find((s) => s.kind === "execute")?.agents[0],
395
+ reviewers: [...steps].reverse().find((s) => s.kind === "review")?.agents ?? []
396
+ };
397
+ }
383
398
  const WorkflowDefinitionSchema = z.z.object({
384
399
  id: z.z.string().uuid(),
385
400
  revision: z.z.number().int().positive(),
386
401
  name: z.z.string().trim().min(1).max(80),
387
402
  description: z.z.string().max(1e3),
388
- planners: z.z.array(WorkflowSlotSchema).min(2).max(4),
403
+ planners: z.z.array(WorkflowSlotSchema).min(1).max(4),
389
404
  executor: WorkflowSlotSchema,
390
- reviewers: z.z.array(WorkflowSlotSchema).min(2).max(4),
405
+ reviewers: z.z.array(WorkflowSlotSchema).min(1).max(4),
406
+ steps: z.z.array(WorkflowStepSchema).min(3).max(8).optional(),
391
407
  criteria: text,
392
408
  checks: z.z.array(z.z.object({ name: z.z.string().trim().min(1).max(100), command: z.z.string().trim().min(1).max(2e3) })).min(1).max(8),
393
409
  planningRounds: z.z.number().int().min(1).max(5),
@@ -398,11 +414,40 @@ const WorkflowDefinitionSchema = z.z.object({
398
414
  updatedAt: z.z.number()
399
415
  }).superRefine((d, ctx) => {
400
416
  if (new TextEncoder().encode(JSON.stringify(d)).length > 64e3) ctx.addIssue({ code: "custom", message: "Workflow definition exceeds 64 KB. Shorten instructions or documents." });
401
- const ids = [...d.planners, d.executor, ...d.reviewers].map((s) => s.agent.id);
402
- if (new Set(ids).size !== ids.length) ctx.addIssue({ code: "custom", message: "Each workflow participant must be a different saved agent." });
403
- if (d.executor.agent.permissionMode === "read-only") ctx.addIssue({ code: "custom", message: "The executor must allow workspace edits." });
417
+ const issue = (message) => ctx.addIssue({ code: "custom", message });
418
+ if (d.steps) {
419
+ if (d.steps[0].kind !== "plan" || d.steps.at(-1)?.kind !== "review" || !d.steps.some((s) => s.kind === "execute")) issue("Start with planning, include execution, and finish with review.");
420
+ if (new Set(d.steps.map((s) => s.id)).size !== d.steps.length) issue("Each step needs a unique ID.");
421
+ const writers = new Set(d.steps.filter((s) => s.kind === "execute").flatMap((s) => s.agents.map((a) => a.agent.id)));
422
+ const identities = /* @__PURE__ */ new Map();
423
+ let executed = false;
424
+ for (const step of d.steps) {
425
+ if (step.kind === "plan") executed = false;
426
+ if (step.kind === "execute") executed = true;
427
+ if (step.kind === "review" && !executed) issue("Place an execution step between planning and review.");
428
+ if (step.kind === "execute" && (step.agents.length !== 1 || step.agents[0].agent.permissionMode === "read-only")) issue("Each execution step needs one agent that allows workspace edits.");
429
+ if (step.kind !== "review" && step.checks.length) issue("Attach step checks to a review step.");
430
+ if (new Set(step.agents.map((s) => s.agent.id)).size !== step.agents.length) issue("Choose distinct agents within a consensus step.");
431
+ for (const slot of step.agents) {
432
+ if (step.kind === "review" && writers.has(slot.agent.id)) issue("Reviewers must be independent of every executor.");
433
+ const snapshot = JSON.stringify(slot.agent);
434
+ if (identities.has(slot.agent.id) && identities.get(slot.agent.id) !== snapshot) issue("A reused agent must have the same configuration in every step.");
435
+ identities.set(slot.agent.id, snapshot);
436
+ }
437
+ }
438
+ const projection = workflowProjection(d.steps);
439
+ if (JSON.stringify([d.planners, d.executor, d.reviewers]) !== JSON.stringify([projection.planners, projection.executor, projection.reviewers])) issue("Workflow role summaries must match its steps.");
440
+ } else {
441
+ if (d.planners.length < 2 || d.reviewers.length < 2) issue("Legacy workflows require at least two planners and reviewers.");
442
+ const ids = [...d.planners, d.executor, ...d.reviewers].map((s) => s.agent.id);
443
+ if (new Set(ids).size !== ids.length) issue("Each workflow participant must be a different saved agent.");
444
+ if (d.executor.agent.permissionMode === "read-only") issue("The executor must allow workspace edits.");
445
+ }
404
446
  });
405
447
  const WorkflowLibrarySchema = z.z.array(WorkflowDefinitionSchema).max(20).refine((x) => JSON.stringify(x).length < 128e3, "Workflow library is too large.");
448
+ function workflowSlots(d) {
449
+ return d.steps?.flatMap((s) => s.agents) ?? [...d.planners, d.executor, ...d.reviewers];
450
+ }
406
451
  const WorkflowStageSchema = z.z.enum(["propose", "consolidate", "plan_vote", "execute", "review", "verify"]);
407
452
  const WorkflowDecisionSchema = z.z.object({
408
453
  decision: z.z.enum(["approve", "changes", "information", "replan"]),
@@ -416,6 +461,8 @@ const WorkflowTaskSchema = z.z.object({
416
461
  round: z.z.number(),
417
462
  agentId: z.z.string(),
418
463
  agentName: z.z.string(),
464
+ stepId: z.z.string().uuid().optional(),
465
+ attempt: z.z.number().int().positive().optional(),
419
466
  clarifications: z.z.number().int().optional(),
420
467
  assignment: z.z.string(),
421
468
  version: z.z.string(),
@@ -441,6 +488,10 @@ const WorkflowRunSchema = z.z.object({
441
488
  baseCommit: z.z.string(),
442
489
  status: z.z.enum(["running", "paused", "needs_input", "complete", "cancelled"]),
443
490
  stage: WorkflowStageSchema,
491
+ stepIndex: z.z.number().int().nonnegative().optional(),
492
+ stepAttempt: z.z.number().int().positive().optional(),
493
+ stepRounds: z.z.record(z.z.string(), z.z.number().int().positive()).optional(),
494
+ completedSteps: z.z.array(z.z.string().uuid()).max(8).optional(),
444
495
  planningRound: z.z.number().int(),
445
496
  reviewRound: z.z.number().int(),
446
497
  planVersion: z.z.number().int(),
@@ -454,6 +505,16 @@ const WorkflowRunSchema = z.z.object({
454
505
  approvedPlanVersion: z.z.number().nullable(),
455
506
  createdAt: z.z.number(),
456
507
  updatedAt: z.z.number()
508
+ }).superRefine((run, ctx) => {
509
+ if (!run.definition.steps) return;
510
+ const steps = run.definition.steps;
511
+ const step = steps[run.stepIndex ?? -1];
512
+ if (!step || !run.stepAttempt || !run.completedSteps || !run.stepRounds) {
513
+ ctx.addIssue({ code: "custom", message: "Editable workflow recovery state is incomplete." });
514
+ return;
515
+ }
516
+ const stages = step.kind === "plan" ? ["propose", "consolidate", "plan_vote"] : step.kind === "execute" ? ["execute"] : ["verify", "review"];
517
+ if (!stages.includes(run.stage) || run.completedSteps.some((id) => !steps.some((s) => s.id === id)) || run.tasks.some((t) => !t.stepId || !t.attempt || !steps.some((s) => s.id === t.stepId))) ctx.addIssue({ code: "custom", message: "Saved workflow stage does not match its definition." });
457
518
  });
458
519
  const WorkflowStartSchema = z.z.object({ id: z.z.string().uuid(), definition: WorkflowDefinitionSchema, task: text, directory: z.z.string().min(1).max(4e3) });
459
520
  const WorkflowActionSchema = z.z.object({
@@ -509,6 +570,7 @@ exports.WorkflowRunSchema = WorkflowRunSchema;
509
570
  exports.WorkflowSlotSchema = WorkflowSlotSchema;
510
571
  exports.WorkflowStageSchema = WorkflowStageSchema;
511
572
  exports.WorkflowStartSchema = WorkflowStartSchema;
573
+ exports.WorkflowStepSchema = WorkflowStepSchema;
512
574
  exports.WorkflowTaskSchema = WorkflowTaskSchema;
513
575
  exports.authenticationContexts = authenticationContexts;
514
576
  exports.createEnvelope = createEnvelope;
@@ -532,4 +594,6 @@ exports.sessionTurnEndStatusSchema = sessionTurnEndStatusSchema;
532
594
  exports.sessionTurnStartEventSchema = sessionTurnStartEventSchema;
533
595
  exports.toWireMetadata = toWireMetadata;
534
596
  exports.workflowEnabled = workflowEnabled;
597
+ exports.workflowProjection = workflowProjection;
598
+ exports.workflowSlots = workflowSlots;
535
599
  exports.workflowStageLabel = workflowStageLabel;
package/dist/index.d.cts CHANGED
@@ -1070,6 +1070,99 @@ declare const WorkflowSlotSchema: z$1.ZodObject<{
1070
1070
  }, z$1.core.$strip>;
1071
1071
  assignment: z$1.ZodString;
1072
1072
  }, z$1.core.$strip>;
1073
+ declare const WorkflowStepSchema: z$1.ZodObject<{
1074
+ id: z$1.ZodString;
1075
+ name: z$1.ZodString;
1076
+ kind: z$1.ZodEnum<{
1077
+ plan: "plan";
1078
+ execute: "execute";
1079
+ review: "review";
1080
+ }>;
1081
+ agents: z$1.ZodArray<z$1.ZodObject<{
1082
+ agent: z$1.ZodObject<{
1083
+ id: z$1.ZodString;
1084
+ revision: z$1.ZodNumber;
1085
+ name: z$1.ZodString;
1086
+ description: z$1.ZodString;
1087
+ provider: z$1.ZodLiteral<"codex">;
1088
+ model: z$1.ZodString;
1089
+ effort: z$1.ZodNullable<z$1.ZodString>;
1090
+ permissionMode: z$1.ZodEnum<{
1091
+ default: "default";
1092
+ "read-only": "read-only";
1093
+ }>;
1094
+ instructions: z$1.ZodString;
1095
+ documents: z$1.ZodArray<z$1.ZodObject<{
1096
+ name: z$1.ZodString;
1097
+ content: z$1.ZodString;
1098
+ }, z$1.core.$strip>>;
1099
+ }, z$1.core.$strip>;
1100
+ assignment: z$1.ZodString;
1101
+ }, z$1.core.$strip>>;
1102
+ criteria: z$1.ZodString;
1103
+ checks: z$1.ZodArray<z$1.ZodObject<{
1104
+ name: z$1.ZodString;
1105
+ command: z$1.ZodString;
1106
+ }, z$1.core.$strip>>;
1107
+ }, z$1.core.$strip>;
1108
+ type WorkflowStep = z$1.infer<typeof WorkflowStepSchema>;
1109
+ /** Legacy summaries are derived, never independently editable in a staged workflow. */
1110
+ declare function workflowProjection(steps: WorkflowStep[]): {
1111
+ planners: {
1112
+ agent: {
1113
+ id: string;
1114
+ revision: number;
1115
+ name: string;
1116
+ description: string;
1117
+ provider: "codex";
1118
+ model: string;
1119
+ effort: string | null;
1120
+ permissionMode: "default" | "read-only";
1121
+ instructions: string;
1122
+ documents: {
1123
+ name: string;
1124
+ content: string;
1125
+ }[];
1126
+ };
1127
+ assignment: string;
1128
+ }[];
1129
+ executor: {
1130
+ agent: {
1131
+ id: string;
1132
+ revision: number;
1133
+ name: string;
1134
+ description: string;
1135
+ provider: "codex";
1136
+ model: string;
1137
+ effort: string | null;
1138
+ permissionMode: "default" | "read-only";
1139
+ instructions: string;
1140
+ documents: {
1141
+ name: string;
1142
+ content: string;
1143
+ }[];
1144
+ };
1145
+ assignment: string;
1146
+ } | undefined;
1147
+ reviewers: {
1148
+ agent: {
1149
+ id: string;
1150
+ revision: number;
1151
+ name: string;
1152
+ description: string;
1153
+ provider: "codex";
1154
+ model: string;
1155
+ effort: string | null;
1156
+ permissionMode: "default" | "read-only";
1157
+ instructions: string;
1158
+ documents: {
1159
+ name: string;
1160
+ content: string;
1161
+ }[];
1162
+ };
1163
+ assignment: string;
1164
+ }[];
1165
+ };
1073
1166
  declare const WorkflowDefinitionSchema: z$1.ZodObject<{
1074
1167
  id: z$1.ZodString;
1075
1168
  revision: z$1.ZodNumber;
@@ -1138,6 +1231,41 @@ declare const WorkflowDefinitionSchema: z$1.ZodObject<{
1138
1231
  }, z$1.core.$strip>;
1139
1232
  assignment: z$1.ZodString;
1140
1233
  }, z$1.core.$strip>>;
1234
+ steps: z$1.ZodOptional<z$1.ZodArray<z$1.ZodObject<{
1235
+ id: z$1.ZodString;
1236
+ name: z$1.ZodString;
1237
+ kind: z$1.ZodEnum<{
1238
+ plan: "plan";
1239
+ execute: "execute";
1240
+ review: "review";
1241
+ }>;
1242
+ agents: z$1.ZodArray<z$1.ZodObject<{
1243
+ agent: z$1.ZodObject<{
1244
+ id: z$1.ZodString;
1245
+ revision: z$1.ZodNumber;
1246
+ name: z$1.ZodString;
1247
+ description: z$1.ZodString;
1248
+ provider: z$1.ZodLiteral<"codex">;
1249
+ model: z$1.ZodString;
1250
+ effort: z$1.ZodNullable<z$1.ZodString>;
1251
+ permissionMode: z$1.ZodEnum<{
1252
+ default: "default";
1253
+ "read-only": "read-only";
1254
+ }>;
1255
+ instructions: z$1.ZodString;
1256
+ documents: z$1.ZodArray<z$1.ZodObject<{
1257
+ name: z$1.ZodString;
1258
+ content: z$1.ZodString;
1259
+ }, z$1.core.$strip>>;
1260
+ }, z$1.core.$strip>;
1261
+ assignment: z$1.ZodString;
1262
+ }, z$1.core.$strip>>;
1263
+ criteria: z$1.ZodString;
1264
+ checks: z$1.ZodArray<z$1.ZodObject<{
1265
+ name: z$1.ZodString;
1266
+ command: z$1.ZodString;
1267
+ }, z$1.core.$strip>>;
1268
+ }, z$1.core.$strip>>>;
1141
1269
  criteria: z$1.ZodString;
1142
1270
  checks: z$1.ZodArray<z$1.ZodObject<{
1143
1271
  name: z$1.ZodString;
@@ -1218,6 +1346,41 @@ declare const WorkflowLibrarySchema: z$1.ZodArray<z$1.ZodObject<{
1218
1346
  }, z$1.core.$strip>;
1219
1347
  assignment: z$1.ZodString;
1220
1348
  }, z$1.core.$strip>>;
1349
+ steps: z$1.ZodOptional<z$1.ZodArray<z$1.ZodObject<{
1350
+ id: z$1.ZodString;
1351
+ name: z$1.ZodString;
1352
+ kind: z$1.ZodEnum<{
1353
+ plan: "plan";
1354
+ execute: "execute";
1355
+ review: "review";
1356
+ }>;
1357
+ agents: z$1.ZodArray<z$1.ZodObject<{
1358
+ agent: z$1.ZodObject<{
1359
+ id: z$1.ZodString;
1360
+ revision: z$1.ZodNumber;
1361
+ name: z$1.ZodString;
1362
+ description: z$1.ZodString;
1363
+ provider: z$1.ZodLiteral<"codex">;
1364
+ model: z$1.ZodString;
1365
+ effort: z$1.ZodNullable<z$1.ZodString>;
1366
+ permissionMode: z$1.ZodEnum<{
1367
+ default: "default";
1368
+ "read-only": "read-only";
1369
+ }>;
1370
+ instructions: z$1.ZodString;
1371
+ documents: z$1.ZodArray<z$1.ZodObject<{
1372
+ name: z$1.ZodString;
1373
+ content: z$1.ZodString;
1374
+ }, z$1.core.$strip>>;
1375
+ }, z$1.core.$strip>;
1376
+ assignment: z$1.ZodString;
1377
+ }, z$1.core.$strip>>;
1378
+ criteria: z$1.ZodString;
1379
+ checks: z$1.ZodArray<z$1.ZodObject<{
1380
+ name: z$1.ZodString;
1381
+ command: z$1.ZodString;
1382
+ }, z$1.core.$strip>>;
1383
+ }, z$1.core.$strip>>>;
1221
1384
  criteria: z$1.ZodString;
1222
1385
  checks: z$1.ZodArray<z$1.ZodObject<{
1223
1386
  name: z$1.ZodString;
@@ -1232,13 +1395,14 @@ declare const WorkflowLibrarySchema: z$1.ZodArray<z$1.ZodObject<{
1232
1395
  }, z$1.core.$strip>>;
1233
1396
  type WorkflowDefinition = z$1.infer<typeof WorkflowDefinitionSchema>;
1234
1397
  type WorkflowSlot = z$1.infer<typeof WorkflowSlotSchema>;
1398
+ declare function workflowSlots(d: WorkflowDefinition): WorkflowSlot[];
1235
1399
  type WorkflowAgent = z$1.infer<typeof WorkflowAgentSchema>;
1236
1400
  declare const WorkflowStageSchema: z$1.ZodEnum<{
1401
+ execute: "execute";
1402
+ review: "review";
1237
1403
  propose: "propose";
1238
1404
  consolidate: "consolidate";
1239
1405
  plan_vote: "plan_vote";
1240
- execute: "execute";
1241
- review: "review";
1242
1406
  verify: "verify";
1243
1407
  }>;
1244
1408
  type WorkflowStage = z$1.infer<typeof WorkflowStageSchema>;
@@ -1262,16 +1426,18 @@ type WorkflowDecision = z$1.infer<typeof WorkflowDecisionSchema>;
1262
1426
  declare const WorkflowTaskSchema: z$1.ZodObject<{
1263
1427
  id: z$1.ZodString;
1264
1428
  stage: z$1.ZodEnum<{
1429
+ execute: "execute";
1430
+ review: "review";
1265
1431
  propose: "propose";
1266
1432
  consolidate: "consolidate";
1267
1433
  plan_vote: "plan_vote";
1268
- execute: "execute";
1269
- review: "review";
1270
1434
  verify: "verify";
1271
1435
  }>;
1272
1436
  round: z$1.ZodNumber;
1273
1437
  agentId: z$1.ZodString;
1274
1438
  agentName: z$1.ZodString;
1439
+ stepId: z$1.ZodOptional<z$1.ZodString>;
1440
+ attempt: z$1.ZodOptional<z$1.ZodNumber>;
1275
1441
  clarifications: z$1.ZodOptional<z$1.ZodNumber>;
1276
1442
  assignment: z$1.ZodString;
1277
1443
  version: z$1.ZodString;
@@ -1374,6 +1540,41 @@ declare const WorkflowRunSchema: z$1.ZodObject<{
1374
1540
  }, z$1.core.$strip>;
1375
1541
  assignment: z$1.ZodString;
1376
1542
  }, z$1.core.$strip>>;
1543
+ steps: z$1.ZodOptional<z$1.ZodArray<z$1.ZodObject<{
1544
+ id: z$1.ZodString;
1545
+ name: z$1.ZodString;
1546
+ kind: z$1.ZodEnum<{
1547
+ plan: "plan";
1548
+ execute: "execute";
1549
+ review: "review";
1550
+ }>;
1551
+ agents: z$1.ZodArray<z$1.ZodObject<{
1552
+ agent: z$1.ZodObject<{
1553
+ id: z$1.ZodString;
1554
+ revision: z$1.ZodNumber;
1555
+ name: z$1.ZodString;
1556
+ description: z$1.ZodString;
1557
+ provider: z$1.ZodLiteral<"codex">;
1558
+ model: z$1.ZodString;
1559
+ effort: z$1.ZodNullable<z$1.ZodString>;
1560
+ permissionMode: z$1.ZodEnum<{
1561
+ default: "default";
1562
+ "read-only": "read-only";
1563
+ }>;
1564
+ instructions: z$1.ZodString;
1565
+ documents: z$1.ZodArray<z$1.ZodObject<{
1566
+ name: z$1.ZodString;
1567
+ content: z$1.ZodString;
1568
+ }, z$1.core.$strip>>;
1569
+ }, z$1.core.$strip>;
1570
+ assignment: z$1.ZodString;
1571
+ }, z$1.core.$strip>>;
1572
+ criteria: z$1.ZodString;
1573
+ checks: z$1.ZodArray<z$1.ZodObject<{
1574
+ name: z$1.ZodString;
1575
+ command: z$1.ZodString;
1576
+ }, z$1.core.$strip>>;
1577
+ }, z$1.core.$strip>>>;
1377
1578
  criteria: z$1.ZodString;
1378
1579
  checks: z$1.ZodArray<z$1.ZodObject<{
1379
1580
  name: z$1.ZodString;
@@ -1401,13 +1602,17 @@ declare const WorkflowRunSchema: z$1.ZodObject<{
1401
1602
  complete: "complete";
1402
1603
  }>;
1403
1604
  stage: z$1.ZodEnum<{
1605
+ execute: "execute";
1606
+ review: "review";
1404
1607
  propose: "propose";
1405
1608
  consolidate: "consolidate";
1406
1609
  plan_vote: "plan_vote";
1407
- execute: "execute";
1408
- review: "review";
1409
1610
  verify: "verify";
1410
1611
  }>;
1612
+ stepIndex: z$1.ZodOptional<z$1.ZodNumber>;
1613
+ stepAttempt: z$1.ZodOptional<z$1.ZodNumber>;
1614
+ stepRounds: z$1.ZodOptional<z$1.ZodRecord<z$1.ZodString, z$1.ZodNumber>>;
1615
+ completedSteps: z$1.ZodOptional<z$1.ZodArray<z$1.ZodString>>;
1411
1616
  planningRound: z$1.ZodNumber;
1412
1617
  reviewRound: z$1.ZodNumber;
1413
1618
  planVersion: z$1.ZodNumber;
@@ -1417,16 +1622,18 @@ declare const WorkflowRunSchema: z$1.ZodObject<{
1417
1622
  tasks: z$1.ZodArray<z$1.ZodObject<{
1418
1623
  id: z$1.ZodString;
1419
1624
  stage: z$1.ZodEnum<{
1625
+ execute: "execute";
1626
+ review: "review";
1420
1627
  propose: "propose";
1421
1628
  consolidate: "consolidate";
1422
1629
  plan_vote: "plan_vote";
1423
- execute: "execute";
1424
- review: "review";
1425
1630
  verify: "verify";
1426
1631
  }>;
1427
1632
  round: z$1.ZodNumber;
1428
1633
  agentId: z$1.ZodString;
1429
1634
  agentName: z$1.ZodString;
1635
+ stepId: z$1.ZodOptional<z$1.ZodString>;
1636
+ attempt: z$1.ZodOptional<z$1.ZodNumber>;
1430
1637
  clarifications: z$1.ZodOptional<z$1.ZodNumber>;
1431
1638
  assignment: z$1.ZodString;
1432
1639
  version: z$1.ZodString;
@@ -1545,6 +1752,41 @@ declare const WorkflowStartSchema: z$1.ZodObject<{
1545
1752
  }, z$1.core.$strip>;
1546
1753
  assignment: z$1.ZodString;
1547
1754
  }, z$1.core.$strip>>;
1755
+ steps: z$1.ZodOptional<z$1.ZodArray<z$1.ZodObject<{
1756
+ id: z$1.ZodString;
1757
+ name: z$1.ZodString;
1758
+ kind: z$1.ZodEnum<{
1759
+ plan: "plan";
1760
+ execute: "execute";
1761
+ review: "review";
1762
+ }>;
1763
+ agents: z$1.ZodArray<z$1.ZodObject<{
1764
+ agent: z$1.ZodObject<{
1765
+ id: z$1.ZodString;
1766
+ revision: z$1.ZodNumber;
1767
+ name: z$1.ZodString;
1768
+ description: z$1.ZodString;
1769
+ provider: z$1.ZodLiteral<"codex">;
1770
+ model: z$1.ZodString;
1771
+ effort: z$1.ZodNullable<z$1.ZodString>;
1772
+ permissionMode: z$1.ZodEnum<{
1773
+ default: "default";
1774
+ "read-only": "read-only";
1775
+ }>;
1776
+ instructions: z$1.ZodString;
1777
+ documents: z$1.ZodArray<z$1.ZodObject<{
1778
+ name: z$1.ZodString;
1779
+ content: z$1.ZodString;
1780
+ }, z$1.core.$strip>>;
1781
+ }, z$1.core.$strip>;
1782
+ assignment: z$1.ZodString;
1783
+ }, z$1.core.$strip>>;
1784
+ criteria: z$1.ZodString;
1785
+ checks: z$1.ZodArray<z$1.ZodObject<{
1786
+ name: z$1.ZodString;
1787
+ command: z$1.ZodString;
1788
+ }, z$1.core.$strip>>;
1789
+ }, z$1.core.$strip>>>;
1548
1790
  criteria: z$1.ZodString;
1549
1791
  checks: z$1.ZodArray<z$1.ZodObject<{
1550
1792
  name: z$1.ZodString;
@@ -1599,5 +1841,5 @@ declare function workflowEnabled(s: {
1599
1841
  }): boolean;
1600
1842
  declare const workflowStageLabel: Record<WorkflowStage, string>;
1601
1843
 
1602
- export { AgentMessageSchema, ApiMessageSchema, ApiUpdateMachineStateSchema, ApiUpdateNewMessageSchema, ApiUpdateSessionStateSchema, CoreUpdateBodySchema, CoreUpdateContainerSchema, LegacyMessageContentSchema, MessageContentSchema, MessageMetaSchema, ProviderUsageBalanceSchema, ProviderUsageRequestSchema, ProviderUsageSnapshotSchema, ProviderUsageWindowSchema, SessionMessageContentSchema, SessionMessageSchema, SessionProtocolMessageSchema, UpdateBodySchema, UpdateMachineBodySchema, UpdateNewMessageBodySchema, UpdateSchema, UpdateSessionBodySchema, UsageProviderSchema, UserMessageSchema, VersionedEncryptedValueSchema, VersionedMachineEncryptedValueSchema, VersionedNullableEncryptedValueSchema, VoiceConversationDeniedSchema, VoiceConversationGrantedSchema, VoiceConversationResponseSchema, VoiceUsageResponseSchema, WorkflowActionSchema, WorkflowAgentSchema, WorkflowDecisionSchema, WorkflowDefinitionSchema, WorkflowLibrarySchema, WorkflowRunSchema, WorkflowSlotSchema, WorkflowStageSchema, WorkflowStartSchema, WorkflowTaskSchema, authenticationContexts, createEnvelope, encryptionContexts, legacyInstallation, legacyServerBanner, normalizeMetadata, rpcMethods, sessionEnvelopeSchema, sessionEventSchema, sessionFileEventSchema, sessionRoleSchema, sessionServiceMessageEventSchema, sessionStartEventSchema, sessionStopEventSchema, sessionTextEventSchema, sessionToolCallEndEventSchema, sessionToolCallStartEventSchema, sessionTurnEndEventSchema, sessionTurnEndStatusSchema, sessionTurnStartEventSchema, toWireMetadata, workflowEnabled, workflowStageLabel };
1603
- export type { AgentMessage, ApiMessage, ApiUpdateMachineState, ApiUpdateNewMessage, ApiUpdateSessionState, CoreUpdateBody, CoreUpdateContainer, CreateEnvelopeOptions, LegacyMessageContent, MessageContent, MessageMeta, ProviderUsageBalance, ProviderUsageRequest, ProviderUsageSnapshot, ProviderUsageWindow, SessionEnvelope, SessionEvent, SessionMessage, SessionMessageContent, SessionProtocolMessage, SessionRole, SessionTurnEndStatus, Update, UpdateBody, UpdateMachineBody, UpdateNewMessageBody, UpdateSessionBody, UsageProvider, UserMessage, VersionedEncryptedValue, VersionedMachineEncryptedValue, VersionedNullableEncryptedValue, VoiceConversationResponse, VoiceUsageResponse, WorkflowAgent, WorkflowDecision, WorkflowDefinition, WorkflowRun, WorkflowSlot, WorkflowStage, WorkflowTask };
1844
+ export { AgentMessageSchema, ApiMessageSchema, ApiUpdateMachineStateSchema, ApiUpdateNewMessageSchema, ApiUpdateSessionStateSchema, CoreUpdateBodySchema, CoreUpdateContainerSchema, LegacyMessageContentSchema, MessageContentSchema, MessageMetaSchema, ProviderUsageBalanceSchema, ProviderUsageRequestSchema, ProviderUsageSnapshotSchema, ProviderUsageWindowSchema, SessionMessageContentSchema, SessionMessageSchema, SessionProtocolMessageSchema, UpdateBodySchema, UpdateMachineBodySchema, UpdateNewMessageBodySchema, UpdateSchema, UpdateSessionBodySchema, UsageProviderSchema, UserMessageSchema, VersionedEncryptedValueSchema, VersionedMachineEncryptedValueSchema, VersionedNullableEncryptedValueSchema, VoiceConversationDeniedSchema, VoiceConversationGrantedSchema, VoiceConversationResponseSchema, VoiceUsageResponseSchema, WorkflowActionSchema, WorkflowAgentSchema, WorkflowDecisionSchema, WorkflowDefinitionSchema, WorkflowLibrarySchema, WorkflowRunSchema, WorkflowSlotSchema, WorkflowStageSchema, WorkflowStartSchema, WorkflowStepSchema, WorkflowTaskSchema, authenticationContexts, createEnvelope, encryptionContexts, legacyInstallation, legacyServerBanner, normalizeMetadata, rpcMethods, sessionEnvelopeSchema, sessionEventSchema, sessionFileEventSchema, sessionRoleSchema, sessionServiceMessageEventSchema, sessionStartEventSchema, sessionStopEventSchema, sessionTextEventSchema, sessionToolCallEndEventSchema, sessionToolCallStartEventSchema, sessionTurnEndEventSchema, sessionTurnEndStatusSchema, sessionTurnStartEventSchema, toWireMetadata, workflowEnabled, workflowProjection, workflowSlots, workflowStageLabel };
1845
+ export type { AgentMessage, ApiMessage, ApiUpdateMachineState, ApiUpdateNewMessage, ApiUpdateSessionState, CoreUpdateBody, CoreUpdateContainer, CreateEnvelopeOptions, LegacyMessageContent, MessageContent, MessageMeta, ProviderUsageBalance, ProviderUsageRequest, ProviderUsageSnapshot, ProviderUsageWindow, SessionEnvelope, SessionEvent, SessionMessage, SessionMessageContent, SessionProtocolMessage, SessionRole, SessionTurnEndStatus, Update, UpdateBody, UpdateMachineBody, UpdateNewMessageBody, UpdateSessionBody, UsageProvider, UserMessage, VersionedEncryptedValue, VersionedMachineEncryptedValue, VersionedNullableEncryptedValue, VoiceConversationResponse, VoiceUsageResponse, WorkflowAgent, WorkflowDecision, WorkflowDefinition, WorkflowRun, WorkflowSlot, WorkflowStage, WorkflowStep, WorkflowTask };
package/dist/index.d.mts CHANGED
@@ -1070,6 +1070,99 @@ declare const WorkflowSlotSchema: z$1.ZodObject<{
1070
1070
  }, z$1.core.$strip>;
1071
1071
  assignment: z$1.ZodString;
1072
1072
  }, z$1.core.$strip>;
1073
+ declare const WorkflowStepSchema: z$1.ZodObject<{
1074
+ id: z$1.ZodString;
1075
+ name: z$1.ZodString;
1076
+ kind: z$1.ZodEnum<{
1077
+ plan: "plan";
1078
+ execute: "execute";
1079
+ review: "review";
1080
+ }>;
1081
+ agents: z$1.ZodArray<z$1.ZodObject<{
1082
+ agent: z$1.ZodObject<{
1083
+ id: z$1.ZodString;
1084
+ revision: z$1.ZodNumber;
1085
+ name: z$1.ZodString;
1086
+ description: z$1.ZodString;
1087
+ provider: z$1.ZodLiteral<"codex">;
1088
+ model: z$1.ZodString;
1089
+ effort: z$1.ZodNullable<z$1.ZodString>;
1090
+ permissionMode: z$1.ZodEnum<{
1091
+ default: "default";
1092
+ "read-only": "read-only";
1093
+ }>;
1094
+ instructions: z$1.ZodString;
1095
+ documents: z$1.ZodArray<z$1.ZodObject<{
1096
+ name: z$1.ZodString;
1097
+ content: z$1.ZodString;
1098
+ }, z$1.core.$strip>>;
1099
+ }, z$1.core.$strip>;
1100
+ assignment: z$1.ZodString;
1101
+ }, z$1.core.$strip>>;
1102
+ criteria: z$1.ZodString;
1103
+ checks: z$1.ZodArray<z$1.ZodObject<{
1104
+ name: z$1.ZodString;
1105
+ command: z$1.ZodString;
1106
+ }, z$1.core.$strip>>;
1107
+ }, z$1.core.$strip>;
1108
+ type WorkflowStep = z$1.infer<typeof WorkflowStepSchema>;
1109
+ /** Legacy summaries are derived, never independently editable in a staged workflow. */
1110
+ declare function workflowProjection(steps: WorkflowStep[]): {
1111
+ planners: {
1112
+ agent: {
1113
+ id: string;
1114
+ revision: number;
1115
+ name: string;
1116
+ description: string;
1117
+ provider: "codex";
1118
+ model: string;
1119
+ effort: string | null;
1120
+ permissionMode: "default" | "read-only";
1121
+ instructions: string;
1122
+ documents: {
1123
+ name: string;
1124
+ content: string;
1125
+ }[];
1126
+ };
1127
+ assignment: string;
1128
+ }[];
1129
+ executor: {
1130
+ agent: {
1131
+ id: string;
1132
+ revision: number;
1133
+ name: string;
1134
+ description: string;
1135
+ provider: "codex";
1136
+ model: string;
1137
+ effort: string | null;
1138
+ permissionMode: "default" | "read-only";
1139
+ instructions: string;
1140
+ documents: {
1141
+ name: string;
1142
+ content: string;
1143
+ }[];
1144
+ };
1145
+ assignment: string;
1146
+ } | undefined;
1147
+ reviewers: {
1148
+ agent: {
1149
+ id: string;
1150
+ revision: number;
1151
+ name: string;
1152
+ description: string;
1153
+ provider: "codex";
1154
+ model: string;
1155
+ effort: string | null;
1156
+ permissionMode: "default" | "read-only";
1157
+ instructions: string;
1158
+ documents: {
1159
+ name: string;
1160
+ content: string;
1161
+ }[];
1162
+ };
1163
+ assignment: string;
1164
+ }[];
1165
+ };
1073
1166
  declare const WorkflowDefinitionSchema: z$1.ZodObject<{
1074
1167
  id: z$1.ZodString;
1075
1168
  revision: z$1.ZodNumber;
@@ -1138,6 +1231,41 @@ declare const WorkflowDefinitionSchema: z$1.ZodObject<{
1138
1231
  }, z$1.core.$strip>;
1139
1232
  assignment: z$1.ZodString;
1140
1233
  }, z$1.core.$strip>>;
1234
+ steps: z$1.ZodOptional<z$1.ZodArray<z$1.ZodObject<{
1235
+ id: z$1.ZodString;
1236
+ name: z$1.ZodString;
1237
+ kind: z$1.ZodEnum<{
1238
+ plan: "plan";
1239
+ execute: "execute";
1240
+ review: "review";
1241
+ }>;
1242
+ agents: z$1.ZodArray<z$1.ZodObject<{
1243
+ agent: z$1.ZodObject<{
1244
+ id: z$1.ZodString;
1245
+ revision: z$1.ZodNumber;
1246
+ name: z$1.ZodString;
1247
+ description: z$1.ZodString;
1248
+ provider: z$1.ZodLiteral<"codex">;
1249
+ model: z$1.ZodString;
1250
+ effort: z$1.ZodNullable<z$1.ZodString>;
1251
+ permissionMode: z$1.ZodEnum<{
1252
+ default: "default";
1253
+ "read-only": "read-only";
1254
+ }>;
1255
+ instructions: z$1.ZodString;
1256
+ documents: z$1.ZodArray<z$1.ZodObject<{
1257
+ name: z$1.ZodString;
1258
+ content: z$1.ZodString;
1259
+ }, z$1.core.$strip>>;
1260
+ }, z$1.core.$strip>;
1261
+ assignment: z$1.ZodString;
1262
+ }, z$1.core.$strip>>;
1263
+ criteria: z$1.ZodString;
1264
+ checks: z$1.ZodArray<z$1.ZodObject<{
1265
+ name: z$1.ZodString;
1266
+ command: z$1.ZodString;
1267
+ }, z$1.core.$strip>>;
1268
+ }, z$1.core.$strip>>>;
1141
1269
  criteria: z$1.ZodString;
1142
1270
  checks: z$1.ZodArray<z$1.ZodObject<{
1143
1271
  name: z$1.ZodString;
@@ -1218,6 +1346,41 @@ declare const WorkflowLibrarySchema: z$1.ZodArray<z$1.ZodObject<{
1218
1346
  }, z$1.core.$strip>;
1219
1347
  assignment: z$1.ZodString;
1220
1348
  }, z$1.core.$strip>>;
1349
+ steps: z$1.ZodOptional<z$1.ZodArray<z$1.ZodObject<{
1350
+ id: z$1.ZodString;
1351
+ name: z$1.ZodString;
1352
+ kind: z$1.ZodEnum<{
1353
+ plan: "plan";
1354
+ execute: "execute";
1355
+ review: "review";
1356
+ }>;
1357
+ agents: z$1.ZodArray<z$1.ZodObject<{
1358
+ agent: z$1.ZodObject<{
1359
+ id: z$1.ZodString;
1360
+ revision: z$1.ZodNumber;
1361
+ name: z$1.ZodString;
1362
+ description: z$1.ZodString;
1363
+ provider: z$1.ZodLiteral<"codex">;
1364
+ model: z$1.ZodString;
1365
+ effort: z$1.ZodNullable<z$1.ZodString>;
1366
+ permissionMode: z$1.ZodEnum<{
1367
+ default: "default";
1368
+ "read-only": "read-only";
1369
+ }>;
1370
+ instructions: z$1.ZodString;
1371
+ documents: z$1.ZodArray<z$1.ZodObject<{
1372
+ name: z$1.ZodString;
1373
+ content: z$1.ZodString;
1374
+ }, z$1.core.$strip>>;
1375
+ }, z$1.core.$strip>;
1376
+ assignment: z$1.ZodString;
1377
+ }, z$1.core.$strip>>;
1378
+ criteria: z$1.ZodString;
1379
+ checks: z$1.ZodArray<z$1.ZodObject<{
1380
+ name: z$1.ZodString;
1381
+ command: z$1.ZodString;
1382
+ }, z$1.core.$strip>>;
1383
+ }, z$1.core.$strip>>>;
1221
1384
  criteria: z$1.ZodString;
1222
1385
  checks: z$1.ZodArray<z$1.ZodObject<{
1223
1386
  name: z$1.ZodString;
@@ -1232,13 +1395,14 @@ declare const WorkflowLibrarySchema: z$1.ZodArray<z$1.ZodObject<{
1232
1395
  }, z$1.core.$strip>>;
1233
1396
  type WorkflowDefinition = z$1.infer<typeof WorkflowDefinitionSchema>;
1234
1397
  type WorkflowSlot = z$1.infer<typeof WorkflowSlotSchema>;
1398
+ declare function workflowSlots(d: WorkflowDefinition): WorkflowSlot[];
1235
1399
  type WorkflowAgent = z$1.infer<typeof WorkflowAgentSchema>;
1236
1400
  declare const WorkflowStageSchema: z$1.ZodEnum<{
1401
+ execute: "execute";
1402
+ review: "review";
1237
1403
  propose: "propose";
1238
1404
  consolidate: "consolidate";
1239
1405
  plan_vote: "plan_vote";
1240
- execute: "execute";
1241
- review: "review";
1242
1406
  verify: "verify";
1243
1407
  }>;
1244
1408
  type WorkflowStage = z$1.infer<typeof WorkflowStageSchema>;
@@ -1262,16 +1426,18 @@ type WorkflowDecision = z$1.infer<typeof WorkflowDecisionSchema>;
1262
1426
  declare const WorkflowTaskSchema: z$1.ZodObject<{
1263
1427
  id: z$1.ZodString;
1264
1428
  stage: z$1.ZodEnum<{
1429
+ execute: "execute";
1430
+ review: "review";
1265
1431
  propose: "propose";
1266
1432
  consolidate: "consolidate";
1267
1433
  plan_vote: "plan_vote";
1268
- execute: "execute";
1269
- review: "review";
1270
1434
  verify: "verify";
1271
1435
  }>;
1272
1436
  round: z$1.ZodNumber;
1273
1437
  agentId: z$1.ZodString;
1274
1438
  agentName: z$1.ZodString;
1439
+ stepId: z$1.ZodOptional<z$1.ZodString>;
1440
+ attempt: z$1.ZodOptional<z$1.ZodNumber>;
1275
1441
  clarifications: z$1.ZodOptional<z$1.ZodNumber>;
1276
1442
  assignment: z$1.ZodString;
1277
1443
  version: z$1.ZodString;
@@ -1374,6 +1540,41 @@ declare const WorkflowRunSchema: z$1.ZodObject<{
1374
1540
  }, z$1.core.$strip>;
1375
1541
  assignment: z$1.ZodString;
1376
1542
  }, z$1.core.$strip>>;
1543
+ steps: z$1.ZodOptional<z$1.ZodArray<z$1.ZodObject<{
1544
+ id: z$1.ZodString;
1545
+ name: z$1.ZodString;
1546
+ kind: z$1.ZodEnum<{
1547
+ plan: "plan";
1548
+ execute: "execute";
1549
+ review: "review";
1550
+ }>;
1551
+ agents: z$1.ZodArray<z$1.ZodObject<{
1552
+ agent: z$1.ZodObject<{
1553
+ id: z$1.ZodString;
1554
+ revision: z$1.ZodNumber;
1555
+ name: z$1.ZodString;
1556
+ description: z$1.ZodString;
1557
+ provider: z$1.ZodLiteral<"codex">;
1558
+ model: z$1.ZodString;
1559
+ effort: z$1.ZodNullable<z$1.ZodString>;
1560
+ permissionMode: z$1.ZodEnum<{
1561
+ default: "default";
1562
+ "read-only": "read-only";
1563
+ }>;
1564
+ instructions: z$1.ZodString;
1565
+ documents: z$1.ZodArray<z$1.ZodObject<{
1566
+ name: z$1.ZodString;
1567
+ content: z$1.ZodString;
1568
+ }, z$1.core.$strip>>;
1569
+ }, z$1.core.$strip>;
1570
+ assignment: z$1.ZodString;
1571
+ }, z$1.core.$strip>>;
1572
+ criteria: z$1.ZodString;
1573
+ checks: z$1.ZodArray<z$1.ZodObject<{
1574
+ name: z$1.ZodString;
1575
+ command: z$1.ZodString;
1576
+ }, z$1.core.$strip>>;
1577
+ }, z$1.core.$strip>>>;
1377
1578
  criteria: z$1.ZodString;
1378
1579
  checks: z$1.ZodArray<z$1.ZodObject<{
1379
1580
  name: z$1.ZodString;
@@ -1401,13 +1602,17 @@ declare const WorkflowRunSchema: z$1.ZodObject<{
1401
1602
  complete: "complete";
1402
1603
  }>;
1403
1604
  stage: z$1.ZodEnum<{
1605
+ execute: "execute";
1606
+ review: "review";
1404
1607
  propose: "propose";
1405
1608
  consolidate: "consolidate";
1406
1609
  plan_vote: "plan_vote";
1407
- execute: "execute";
1408
- review: "review";
1409
1610
  verify: "verify";
1410
1611
  }>;
1612
+ stepIndex: z$1.ZodOptional<z$1.ZodNumber>;
1613
+ stepAttempt: z$1.ZodOptional<z$1.ZodNumber>;
1614
+ stepRounds: z$1.ZodOptional<z$1.ZodRecord<z$1.ZodString, z$1.ZodNumber>>;
1615
+ completedSteps: z$1.ZodOptional<z$1.ZodArray<z$1.ZodString>>;
1411
1616
  planningRound: z$1.ZodNumber;
1412
1617
  reviewRound: z$1.ZodNumber;
1413
1618
  planVersion: z$1.ZodNumber;
@@ -1417,16 +1622,18 @@ declare const WorkflowRunSchema: z$1.ZodObject<{
1417
1622
  tasks: z$1.ZodArray<z$1.ZodObject<{
1418
1623
  id: z$1.ZodString;
1419
1624
  stage: z$1.ZodEnum<{
1625
+ execute: "execute";
1626
+ review: "review";
1420
1627
  propose: "propose";
1421
1628
  consolidate: "consolidate";
1422
1629
  plan_vote: "plan_vote";
1423
- execute: "execute";
1424
- review: "review";
1425
1630
  verify: "verify";
1426
1631
  }>;
1427
1632
  round: z$1.ZodNumber;
1428
1633
  agentId: z$1.ZodString;
1429
1634
  agentName: z$1.ZodString;
1635
+ stepId: z$1.ZodOptional<z$1.ZodString>;
1636
+ attempt: z$1.ZodOptional<z$1.ZodNumber>;
1430
1637
  clarifications: z$1.ZodOptional<z$1.ZodNumber>;
1431
1638
  assignment: z$1.ZodString;
1432
1639
  version: z$1.ZodString;
@@ -1545,6 +1752,41 @@ declare const WorkflowStartSchema: z$1.ZodObject<{
1545
1752
  }, z$1.core.$strip>;
1546
1753
  assignment: z$1.ZodString;
1547
1754
  }, z$1.core.$strip>>;
1755
+ steps: z$1.ZodOptional<z$1.ZodArray<z$1.ZodObject<{
1756
+ id: z$1.ZodString;
1757
+ name: z$1.ZodString;
1758
+ kind: z$1.ZodEnum<{
1759
+ plan: "plan";
1760
+ execute: "execute";
1761
+ review: "review";
1762
+ }>;
1763
+ agents: z$1.ZodArray<z$1.ZodObject<{
1764
+ agent: z$1.ZodObject<{
1765
+ id: z$1.ZodString;
1766
+ revision: z$1.ZodNumber;
1767
+ name: z$1.ZodString;
1768
+ description: z$1.ZodString;
1769
+ provider: z$1.ZodLiteral<"codex">;
1770
+ model: z$1.ZodString;
1771
+ effort: z$1.ZodNullable<z$1.ZodString>;
1772
+ permissionMode: z$1.ZodEnum<{
1773
+ default: "default";
1774
+ "read-only": "read-only";
1775
+ }>;
1776
+ instructions: z$1.ZodString;
1777
+ documents: z$1.ZodArray<z$1.ZodObject<{
1778
+ name: z$1.ZodString;
1779
+ content: z$1.ZodString;
1780
+ }, z$1.core.$strip>>;
1781
+ }, z$1.core.$strip>;
1782
+ assignment: z$1.ZodString;
1783
+ }, z$1.core.$strip>>;
1784
+ criteria: z$1.ZodString;
1785
+ checks: z$1.ZodArray<z$1.ZodObject<{
1786
+ name: z$1.ZodString;
1787
+ command: z$1.ZodString;
1788
+ }, z$1.core.$strip>>;
1789
+ }, z$1.core.$strip>>>;
1548
1790
  criteria: z$1.ZodString;
1549
1791
  checks: z$1.ZodArray<z$1.ZodObject<{
1550
1792
  name: z$1.ZodString;
@@ -1599,5 +1841,5 @@ declare function workflowEnabled(s: {
1599
1841
  }): boolean;
1600
1842
  declare const workflowStageLabel: Record<WorkflowStage, string>;
1601
1843
 
1602
- export { AgentMessageSchema, ApiMessageSchema, ApiUpdateMachineStateSchema, ApiUpdateNewMessageSchema, ApiUpdateSessionStateSchema, CoreUpdateBodySchema, CoreUpdateContainerSchema, LegacyMessageContentSchema, MessageContentSchema, MessageMetaSchema, ProviderUsageBalanceSchema, ProviderUsageRequestSchema, ProviderUsageSnapshotSchema, ProviderUsageWindowSchema, SessionMessageContentSchema, SessionMessageSchema, SessionProtocolMessageSchema, UpdateBodySchema, UpdateMachineBodySchema, UpdateNewMessageBodySchema, UpdateSchema, UpdateSessionBodySchema, UsageProviderSchema, UserMessageSchema, VersionedEncryptedValueSchema, VersionedMachineEncryptedValueSchema, VersionedNullableEncryptedValueSchema, VoiceConversationDeniedSchema, VoiceConversationGrantedSchema, VoiceConversationResponseSchema, VoiceUsageResponseSchema, WorkflowActionSchema, WorkflowAgentSchema, WorkflowDecisionSchema, WorkflowDefinitionSchema, WorkflowLibrarySchema, WorkflowRunSchema, WorkflowSlotSchema, WorkflowStageSchema, WorkflowStartSchema, WorkflowTaskSchema, authenticationContexts, createEnvelope, encryptionContexts, legacyInstallation, legacyServerBanner, normalizeMetadata, rpcMethods, sessionEnvelopeSchema, sessionEventSchema, sessionFileEventSchema, sessionRoleSchema, sessionServiceMessageEventSchema, sessionStartEventSchema, sessionStopEventSchema, sessionTextEventSchema, sessionToolCallEndEventSchema, sessionToolCallStartEventSchema, sessionTurnEndEventSchema, sessionTurnEndStatusSchema, sessionTurnStartEventSchema, toWireMetadata, workflowEnabled, workflowStageLabel };
1603
- export type { AgentMessage, ApiMessage, ApiUpdateMachineState, ApiUpdateNewMessage, ApiUpdateSessionState, CoreUpdateBody, CoreUpdateContainer, CreateEnvelopeOptions, LegacyMessageContent, MessageContent, MessageMeta, ProviderUsageBalance, ProviderUsageRequest, ProviderUsageSnapshot, ProviderUsageWindow, SessionEnvelope, SessionEvent, SessionMessage, SessionMessageContent, SessionProtocolMessage, SessionRole, SessionTurnEndStatus, Update, UpdateBody, UpdateMachineBody, UpdateNewMessageBody, UpdateSessionBody, UsageProvider, UserMessage, VersionedEncryptedValue, VersionedMachineEncryptedValue, VersionedNullableEncryptedValue, VoiceConversationResponse, VoiceUsageResponse, WorkflowAgent, WorkflowDecision, WorkflowDefinition, WorkflowRun, WorkflowSlot, WorkflowStage, WorkflowTask };
1844
+ export { AgentMessageSchema, ApiMessageSchema, ApiUpdateMachineStateSchema, ApiUpdateNewMessageSchema, ApiUpdateSessionStateSchema, CoreUpdateBodySchema, CoreUpdateContainerSchema, LegacyMessageContentSchema, MessageContentSchema, MessageMetaSchema, ProviderUsageBalanceSchema, ProviderUsageRequestSchema, ProviderUsageSnapshotSchema, ProviderUsageWindowSchema, SessionMessageContentSchema, SessionMessageSchema, SessionProtocolMessageSchema, UpdateBodySchema, UpdateMachineBodySchema, UpdateNewMessageBodySchema, UpdateSchema, UpdateSessionBodySchema, UsageProviderSchema, UserMessageSchema, VersionedEncryptedValueSchema, VersionedMachineEncryptedValueSchema, VersionedNullableEncryptedValueSchema, VoiceConversationDeniedSchema, VoiceConversationGrantedSchema, VoiceConversationResponseSchema, VoiceUsageResponseSchema, WorkflowActionSchema, WorkflowAgentSchema, WorkflowDecisionSchema, WorkflowDefinitionSchema, WorkflowLibrarySchema, WorkflowRunSchema, WorkflowSlotSchema, WorkflowStageSchema, WorkflowStartSchema, WorkflowStepSchema, WorkflowTaskSchema, authenticationContexts, createEnvelope, encryptionContexts, legacyInstallation, legacyServerBanner, normalizeMetadata, rpcMethods, sessionEnvelopeSchema, sessionEventSchema, sessionFileEventSchema, sessionRoleSchema, sessionServiceMessageEventSchema, sessionStartEventSchema, sessionStopEventSchema, sessionTextEventSchema, sessionToolCallEndEventSchema, sessionToolCallStartEventSchema, sessionTurnEndEventSchema, sessionTurnEndStatusSchema, sessionTurnStartEventSchema, toWireMetadata, workflowEnabled, workflowProjection, workflowSlots, workflowStageLabel };
1845
+ export type { AgentMessage, ApiMessage, ApiUpdateMachineState, ApiUpdateNewMessage, ApiUpdateSessionState, CoreUpdateBody, CoreUpdateContainer, CreateEnvelopeOptions, LegacyMessageContent, MessageContent, MessageMeta, ProviderUsageBalance, ProviderUsageRequest, ProviderUsageSnapshot, ProviderUsageWindow, SessionEnvelope, SessionEvent, SessionMessage, SessionMessageContent, SessionProtocolMessage, SessionRole, SessionTurnEndStatus, Update, UpdateBody, UpdateMachineBody, UpdateNewMessageBody, UpdateSessionBody, UsageProvider, UserMessage, VersionedEncryptedValue, VersionedMachineEncryptedValue, VersionedNullableEncryptedValue, VoiceConversationResponse, VoiceUsageResponse, WorkflowAgent, WorkflowDecision, WorkflowDefinition, WorkflowRun, WorkflowSlot, WorkflowStage, WorkflowStep, WorkflowTask };
package/dist/index.mjs CHANGED
@@ -360,14 +360,30 @@ const WorkflowAgentSchema = z$1.object({
360
360
  documents: z$1.array(z$1.object({ name: z$1.string().max(120), content: z$1.string().max(16e3) })).max(5)
361
361
  });
362
362
  const WorkflowSlotSchema = z$1.object({ agent: WorkflowAgentSchema, assignment: text });
363
+ const WorkflowStepSchema = z$1.object({
364
+ id: z$1.string().uuid(),
365
+ name: z$1.string().trim().min(1).max(80),
366
+ kind: z$1.enum(["plan", "execute", "review"]),
367
+ agents: z$1.array(WorkflowSlotSchema).min(1).max(3),
368
+ criteria: z$1.string().trim().max(24e3),
369
+ checks: z$1.array(z$1.object({ name: z$1.string().trim().min(1).max(100), command: z$1.string().trim().min(1).max(2e3) })).max(8)
370
+ });
371
+ function workflowProjection(steps) {
372
+ return {
373
+ planners: steps.find((s) => s.kind === "plan")?.agents ?? [],
374
+ executor: steps.find((s) => s.kind === "execute")?.agents[0],
375
+ reviewers: [...steps].reverse().find((s) => s.kind === "review")?.agents ?? []
376
+ };
377
+ }
363
378
  const WorkflowDefinitionSchema = z$1.object({
364
379
  id: z$1.string().uuid(),
365
380
  revision: z$1.number().int().positive(),
366
381
  name: z$1.string().trim().min(1).max(80),
367
382
  description: z$1.string().max(1e3),
368
- planners: z$1.array(WorkflowSlotSchema).min(2).max(4),
383
+ planners: z$1.array(WorkflowSlotSchema).min(1).max(4),
369
384
  executor: WorkflowSlotSchema,
370
- reviewers: z$1.array(WorkflowSlotSchema).min(2).max(4),
385
+ reviewers: z$1.array(WorkflowSlotSchema).min(1).max(4),
386
+ steps: z$1.array(WorkflowStepSchema).min(3).max(8).optional(),
371
387
  criteria: text,
372
388
  checks: z$1.array(z$1.object({ name: z$1.string().trim().min(1).max(100), command: z$1.string().trim().min(1).max(2e3) })).min(1).max(8),
373
389
  planningRounds: z$1.number().int().min(1).max(5),
@@ -378,11 +394,40 @@ const WorkflowDefinitionSchema = z$1.object({
378
394
  updatedAt: z$1.number()
379
395
  }).superRefine((d, ctx) => {
380
396
  if (new TextEncoder().encode(JSON.stringify(d)).length > 64e3) ctx.addIssue({ code: "custom", message: "Workflow definition exceeds 64 KB. Shorten instructions or documents." });
381
- const ids = [...d.planners, d.executor, ...d.reviewers].map((s) => s.agent.id);
382
- if (new Set(ids).size !== ids.length) ctx.addIssue({ code: "custom", message: "Each workflow participant must be a different saved agent." });
383
- if (d.executor.agent.permissionMode === "read-only") ctx.addIssue({ code: "custom", message: "The executor must allow workspace edits." });
397
+ const issue = (message) => ctx.addIssue({ code: "custom", message });
398
+ if (d.steps) {
399
+ if (d.steps[0].kind !== "plan" || d.steps.at(-1)?.kind !== "review" || !d.steps.some((s) => s.kind === "execute")) issue("Start with planning, include execution, and finish with review.");
400
+ if (new Set(d.steps.map((s) => s.id)).size !== d.steps.length) issue("Each step needs a unique ID.");
401
+ const writers = new Set(d.steps.filter((s) => s.kind === "execute").flatMap((s) => s.agents.map((a) => a.agent.id)));
402
+ const identities = /* @__PURE__ */ new Map();
403
+ let executed = false;
404
+ for (const step of d.steps) {
405
+ if (step.kind === "plan") executed = false;
406
+ if (step.kind === "execute") executed = true;
407
+ if (step.kind === "review" && !executed) issue("Place an execution step between planning and review.");
408
+ if (step.kind === "execute" && (step.agents.length !== 1 || step.agents[0].agent.permissionMode === "read-only")) issue("Each execution step needs one agent that allows workspace edits.");
409
+ if (step.kind !== "review" && step.checks.length) issue("Attach step checks to a review step.");
410
+ if (new Set(step.agents.map((s) => s.agent.id)).size !== step.agents.length) issue("Choose distinct agents within a consensus step.");
411
+ for (const slot of step.agents) {
412
+ if (step.kind === "review" && writers.has(slot.agent.id)) issue("Reviewers must be independent of every executor.");
413
+ const snapshot = JSON.stringify(slot.agent);
414
+ if (identities.has(slot.agent.id) && identities.get(slot.agent.id) !== snapshot) issue("A reused agent must have the same configuration in every step.");
415
+ identities.set(slot.agent.id, snapshot);
416
+ }
417
+ }
418
+ const projection = workflowProjection(d.steps);
419
+ if (JSON.stringify([d.planners, d.executor, d.reviewers]) !== JSON.stringify([projection.planners, projection.executor, projection.reviewers])) issue("Workflow role summaries must match its steps.");
420
+ } else {
421
+ if (d.planners.length < 2 || d.reviewers.length < 2) issue("Legacy workflows require at least two planners and reviewers.");
422
+ const ids = [...d.planners, d.executor, ...d.reviewers].map((s) => s.agent.id);
423
+ if (new Set(ids).size !== ids.length) issue("Each workflow participant must be a different saved agent.");
424
+ if (d.executor.agent.permissionMode === "read-only") issue("The executor must allow workspace edits.");
425
+ }
384
426
  });
385
427
  const WorkflowLibrarySchema = z$1.array(WorkflowDefinitionSchema).max(20).refine((x) => JSON.stringify(x).length < 128e3, "Workflow library is too large.");
428
+ function workflowSlots(d) {
429
+ return d.steps?.flatMap((s) => s.agents) ?? [...d.planners, d.executor, ...d.reviewers];
430
+ }
386
431
  const WorkflowStageSchema = z$1.enum(["propose", "consolidate", "plan_vote", "execute", "review", "verify"]);
387
432
  const WorkflowDecisionSchema = z$1.object({
388
433
  decision: z$1.enum(["approve", "changes", "information", "replan"]),
@@ -396,6 +441,8 @@ const WorkflowTaskSchema = z$1.object({
396
441
  round: z$1.number(),
397
442
  agentId: z$1.string(),
398
443
  agentName: z$1.string(),
444
+ stepId: z$1.string().uuid().optional(),
445
+ attempt: z$1.number().int().positive().optional(),
399
446
  clarifications: z$1.number().int().optional(),
400
447
  assignment: z$1.string(),
401
448
  version: z$1.string(),
@@ -421,6 +468,10 @@ const WorkflowRunSchema = z$1.object({
421
468
  baseCommit: z$1.string(),
422
469
  status: z$1.enum(["running", "paused", "needs_input", "complete", "cancelled"]),
423
470
  stage: WorkflowStageSchema,
471
+ stepIndex: z$1.number().int().nonnegative().optional(),
472
+ stepAttempt: z$1.number().int().positive().optional(),
473
+ stepRounds: z$1.record(z$1.string(), z$1.number().int().positive()).optional(),
474
+ completedSteps: z$1.array(z$1.string().uuid()).max(8).optional(),
424
475
  planningRound: z$1.number().int(),
425
476
  reviewRound: z$1.number().int(),
426
477
  planVersion: z$1.number().int(),
@@ -434,6 +485,16 @@ const WorkflowRunSchema = z$1.object({
434
485
  approvedPlanVersion: z$1.number().nullable(),
435
486
  createdAt: z$1.number(),
436
487
  updatedAt: z$1.number()
488
+ }).superRefine((run, ctx) => {
489
+ if (!run.definition.steps) return;
490
+ const steps = run.definition.steps;
491
+ const step = steps[run.stepIndex ?? -1];
492
+ if (!step || !run.stepAttempt || !run.completedSteps || !run.stepRounds) {
493
+ ctx.addIssue({ code: "custom", message: "Editable workflow recovery state is incomplete." });
494
+ return;
495
+ }
496
+ const stages = step.kind === "plan" ? ["propose", "consolidate", "plan_vote"] : step.kind === "execute" ? ["execute"] : ["verify", "review"];
497
+ if (!stages.includes(run.stage) || run.completedSteps.some((id) => !steps.some((s) => s.id === id)) || run.tasks.some((t) => !t.stepId || !t.attempt || !steps.some((s) => s.id === t.stepId))) ctx.addIssue({ code: "custom", message: "Saved workflow stage does not match its definition." });
437
498
  });
438
499
  const WorkflowStartSchema = z$1.object({ id: z$1.string().uuid(), definition: WorkflowDefinitionSchema, task: text, directory: z$1.string().min(1).max(4e3) });
439
500
  const WorkflowActionSchema = z$1.object({
@@ -449,4 +510,4 @@ function workflowEnabled(s) {
449
510
  }
450
511
  const workflowStageLabel = { propose: "Independent proposals", consolidate: "Consolidating plan", plan_vote: "Planning consensus", execute: "Executing", review: "Independent review", verify: "Completion checks" };
451
512
 
452
- export { AgentMessageSchema, ApiMessageSchema, ApiUpdateMachineStateSchema, ApiUpdateNewMessageSchema, ApiUpdateSessionStateSchema, CoreUpdateBodySchema, CoreUpdateContainerSchema, LegacyMessageContentSchema, MessageContentSchema, MessageMetaSchema, ProviderUsageBalanceSchema, ProviderUsageRequestSchema, ProviderUsageSnapshotSchema, ProviderUsageWindowSchema, SessionMessageContentSchema, SessionMessageSchema, SessionProtocolMessageSchema, UpdateBodySchema, UpdateMachineBodySchema, UpdateNewMessageBodySchema, UpdateSchema, UpdateSessionBodySchema, UsageProviderSchema, UserMessageSchema, VersionedEncryptedValueSchema, VersionedMachineEncryptedValueSchema, VersionedNullableEncryptedValueSchema, VoiceConversationDeniedSchema, VoiceConversationGrantedSchema, VoiceConversationResponseSchema, VoiceUsageResponseSchema, WorkflowActionSchema, WorkflowAgentSchema, WorkflowDecisionSchema, WorkflowDefinitionSchema, WorkflowLibrarySchema, WorkflowRunSchema, WorkflowSlotSchema, WorkflowStageSchema, WorkflowStartSchema, WorkflowTaskSchema, authenticationContexts, createEnvelope, encryptionContexts, legacyInstallation, legacyServerBanner, normalizeMetadata, rpcMethods, sessionEnvelopeSchema, sessionEventSchema, sessionFileEventSchema, sessionRoleSchema, sessionServiceMessageEventSchema, sessionStartEventSchema, sessionStopEventSchema, sessionTextEventSchema, sessionToolCallEndEventSchema, sessionToolCallStartEventSchema, sessionTurnEndEventSchema, sessionTurnEndStatusSchema, sessionTurnStartEventSchema, toWireMetadata, workflowEnabled, workflowStageLabel };
513
+ export { AgentMessageSchema, ApiMessageSchema, ApiUpdateMachineStateSchema, ApiUpdateNewMessageSchema, ApiUpdateSessionStateSchema, CoreUpdateBodySchema, CoreUpdateContainerSchema, LegacyMessageContentSchema, MessageContentSchema, MessageMetaSchema, ProviderUsageBalanceSchema, ProviderUsageRequestSchema, ProviderUsageSnapshotSchema, ProviderUsageWindowSchema, SessionMessageContentSchema, SessionMessageSchema, SessionProtocolMessageSchema, UpdateBodySchema, UpdateMachineBodySchema, UpdateNewMessageBodySchema, UpdateSchema, UpdateSessionBodySchema, UsageProviderSchema, UserMessageSchema, VersionedEncryptedValueSchema, VersionedMachineEncryptedValueSchema, VersionedNullableEncryptedValueSchema, VoiceConversationDeniedSchema, VoiceConversationGrantedSchema, VoiceConversationResponseSchema, VoiceUsageResponseSchema, WorkflowActionSchema, WorkflowAgentSchema, WorkflowDecisionSchema, WorkflowDefinitionSchema, WorkflowLibrarySchema, WorkflowRunSchema, WorkflowSlotSchema, WorkflowStageSchema, WorkflowStartSchema, WorkflowStepSchema, WorkflowTaskSchema, authenticationContexts, createEnvelope, encryptionContexts, legacyInstallation, legacyServerBanner, normalizeMetadata, rpcMethods, sessionEnvelopeSchema, sessionEventSchema, sessionFileEventSchema, sessionRoleSchema, sessionServiceMessageEventSchema, sessionStartEventSchema, sessionStopEventSchema, sessionTextEventSchema, sessionToolCallEndEventSchema, sessionToolCallStartEventSchema, sessionTurnEndEventSchema, sessionTurnEndStatusSchema, sessionTurnStartEventSchema, toWireMetadata, workflowEnabled, workflowProjection, workflowSlots, workflowStageLabel };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ahmadposten/talos-wire",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "description": "Shared message wire types and Zod schemas for Talos clients and services",
5
5
  "author": "Kirill Dubovitskiy",
6
6
  "license": "MIT",