@ahmadposten/talos-wire 0.1.2 → 0.1.4

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.mjs CHANGED
@@ -352,22 +352,39 @@ const WorkflowAgentSchema = z$1.object({
352
352
  revision: z$1.number().int().positive(),
353
353
  name: z$1.string().min(1).max(60),
354
354
  description: z$1.string().max(300),
355
- provider: z$1.literal("codex"),
355
+ provider: z$1.enum(["codex", "claude", "muse"]),
356
356
  model: z$1.string().min(1).max(200),
357
+ modelLabel: z$1.string().max(300).optional(),
357
358
  effort: z$1.string().max(30).nullable(),
358
359
  permissionMode: z$1.enum(["default", "read-only"]),
359
360
  instructions: text,
360
361
  documents: z$1.array(z$1.object({ name: z$1.string().max(120), content: z$1.string().max(16e3) })).max(5)
361
362
  });
362
363
  const WorkflowSlotSchema = z$1.object({ agent: WorkflowAgentSchema, assignment: text });
364
+ const WorkflowStepSchema = z$1.object({
365
+ id: z$1.string().uuid(),
366
+ name: z$1.string().trim().min(1).max(80),
367
+ kind: z$1.enum(["plan", "execute", "review"]),
368
+ agents: z$1.array(WorkflowSlotSchema).min(1).max(3),
369
+ criteria: z$1.string().trim().max(24e3),
370
+ 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)
371
+ });
372
+ function workflowProjection(steps) {
373
+ return {
374
+ planners: steps.find((s) => s.kind === "plan")?.agents ?? [],
375
+ executor: steps.find((s) => s.kind === "execute")?.agents[0],
376
+ reviewers: [...steps].reverse().find((s) => s.kind === "review")?.agents ?? []
377
+ };
378
+ }
363
379
  const WorkflowDefinitionSchema = z$1.object({
364
380
  id: z$1.string().uuid(),
365
381
  revision: z$1.number().int().positive(),
366
382
  name: z$1.string().trim().min(1).max(80),
367
383
  description: z$1.string().max(1e3),
368
- planners: z$1.array(WorkflowSlotSchema).min(2).max(4),
384
+ planners: z$1.array(WorkflowSlotSchema).min(1).max(4),
369
385
  executor: WorkflowSlotSchema,
370
- reviewers: z$1.array(WorkflowSlotSchema).min(2).max(4),
386
+ reviewers: z$1.array(WorkflowSlotSchema).min(1).max(4),
387
+ steps: z$1.array(WorkflowStepSchema).min(3).max(8).optional(),
371
388
  criteria: text,
372
389
  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
390
  planningRounds: z$1.number().int().min(1).max(5),
@@ -378,11 +395,40 @@ const WorkflowDefinitionSchema = z$1.object({
378
395
  updatedAt: z$1.number()
379
396
  }).superRefine((d, ctx) => {
380
397
  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." });
398
+ const issue = (message) => ctx.addIssue({ code: "custom", message });
399
+ if (d.steps) {
400
+ 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.");
401
+ if (new Set(d.steps.map((s) => s.id)).size !== d.steps.length) issue("Each step needs a unique ID.");
402
+ const writers = new Set(d.steps.filter((s) => s.kind === "execute").flatMap((s) => s.agents.map((a) => a.agent.id)));
403
+ const identities = /* @__PURE__ */ new Map();
404
+ let executed = false;
405
+ for (const step of d.steps) {
406
+ if (step.kind === "plan") executed = false;
407
+ if (step.kind === "execute") executed = true;
408
+ if (step.kind === "review" && !executed) issue("Place an execution step between planning and review.");
409
+ 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.");
410
+ if (step.kind !== "review" && step.checks.length) issue("Attach step checks to a review step.");
411
+ if (new Set(step.agents.map((s) => s.agent.id)).size !== step.agents.length) issue("Choose distinct agents within a consensus step.");
412
+ for (const slot of step.agents) {
413
+ if (step.kind === "review" && writers.has(slot.agent.id)) issue("Reviewers must be independent of every executor.");
414
+ const snapshot = JSON.stringify(slot.agent);
415
+ if (identities.has(slot.agent.id) && identities.get(slot.agent.id) !== snapshot) issue("A reused agent must have the same configuration in every step.");
416
+ identities.set(slot.agent.id, snapshot);
417
+ }
418
+ }
419
+ const projection = workflowProjection(d.steps);
420
+ 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.");
421
+ } else {
422
+ if (d.planners.length < 2 || d.reviewers.length < 2) issue("Legacy workflows require at least two planners and reviewers.");
423
+ const ids = [...d.planners, d.executor, ...d.reviewers].map((s) => s.agent.id);
424
+ if (new Set(ids).size !== ids.length) issue("Each workflow participant must be a different saved agent.");
425
+ if (d.executor.agent.permissionMode === "read-only") issue("The executor must allow workspace edits.");
426
+ }
384
427
  });
385
428
  const WorkflowLibrarySchema = z$1.array(WorkflowDefinitionSchema).max(20).refine((x) => JSON.stringify(x).length < 128e3, "Workflow library is too large.");
429
+ function workflowSlots(d) {
430
+ return d.steps?.flatMap((s) => s.agents) ?? [...d.planners, d.executor, ...d.reviewers];
431
+ }
386
432
  const WorkflowStageSchema = z$1.enum(["propose", "consolidate", "plan_vote", "execute", "review", "verify"]);
387
433
  const WorkflowDecisionSchema = z$1.object({
388
434
  decision: z$1.enum(["approve", "changes", "information", "replan"]),
@@ -396,6 +442,8 @@ const WorkflowTaskSchema = z$1.object({
396
442
  round: z$1.number(),
397
443
  agentId: z$1.string(),
398
444
  agentName: z$1.string(),
445
+ stepId: z$1.string().uuid().optional(),
446
+ attempt: z$1.number().int().positive().optional(),
399
447
  clarifications: z$1.number().int().optional(),
400
448
  assignment: z$1.string(),
401
449
  version: z$1.string(),
@@ -421,6 +469,10 @@ const WorkflowRunSchema = z$1.object({
421
469
  baseCommit: z$1.string(),
422
470
  status: z$1.enum(["running", "paused", "needs_input", "complete", "cancelled"]),
423
471
  stage: WorkflowStageSchema,
472
+ stepIndex: z$1.number().int().nonnegative().optional(),
473
+ stepAttempt: z$1.number().int().positive().optional(),
474
+ stepRounds: z$1.record(z$1.string(), z$1.number().int().positive()).optional(),
475
+ completedSteps: z$1.array(z$1.string().uuid()).max(8).optional(),
424
476
  planningRound: z$1.number().int(),
425
477
  reviewRound: z$1.number().int(),
426
478
  planVersion: z$1.number().int(),
@@ -434,6 +486,16 @@ const WorkflowRunSchema = z$1.object({
434
486
  approvedPlanVersion: z$1.number().nullable(),
435
487
  createdAt: z$1.number(),
436
488
  updatedAt: z$1.number()
489
+ }).superRefine((run, ctx) => {
490
+ if (!run.definition.steps) return;
491
+ const steps = run.definition.steps;
492
+ const step = steps[run.stepIndex ?? -1];
493
+ if (!step || !run.stepAttempt || !run.completedSteps || !run.stepRounds) {
494
+ ctx.addIssue({ code: "custom", message: "Editable workflow recovery state is incomplete." });
495
+ return;
496
+ }
497
+ const stages = step.kind === "plan" ? ["propose", "consolidate", "plan_vote"] : step.kind === "execute" ? ["execute"] : ["verify", "review"];
498
+ 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
499
  });
438
500
  const WorkflowStartSchema = z$1.object({ id: z$1.string().uuid(), definition: WorkflowDefinitionSchema, task: text, directory: z$1.string().min(1).max(4e3) });
439
501
  const WorkflowActionSchema = z$1.object({
@@ -448,5 +510,8 @@ function workflowEnabled(s) {
448
510
  return s.experiments === true && s.expWorkflows === true;
449
511
  }
450
512
  const workflowStageLabel = { propose: "Independent proposals", consolidate: "Consolidating plan", plan_vote: "Planning consensus", execute: "Executing", review: "Independent review", verify: "Completion checks" };
513
+ function workflowNeedsProviders(definition) {
514
+ return workflowSlots(definition).some((slot) => slot.agent.provider !== "codex");
515
+ }
451
516
 
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 };
517
+ 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, workflowNeedsProviders, 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.4",
4
4
  "description": "Shared message wire types and Zod schemas for Talos clients and services",
5
5
  "author": "Kirill Dubovitskiy",
6
6
  "license": "MIT",