@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.cjs +75 -6
- package/dist/index.d.cts +371 -25
- package/dist/index.d.mts +371 -25
- package/dist/index.mjs +72 -7
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -372,22 +372,39 @@ const WorkflowAgentSchema = z.z.object({
|
|
|
372
372
|
revision: z.z.number().int().positive(),
|
|
373
373
|
name: z.z.string().min(1).max(60),
|
|
374
374
|
description: z.z.string().max(300),
|
|
375
|
-
provider: z.z.
|
|
375
|
+
provider: z.z.enum(["codex", "claude", "muse"]),
|
|
376
376
|
model: z.z.string().min(1).max(200),
|
|
377
|
+
modelLabel: z.z.string().max(300).optional(),
|
|
377
378
|
effort: z.z.string().max(30).nullable(),
|
|
378
379
|
permissionMode: z.z.enum(["default", "read-only"]),
|
|
379
380
|
instructions: text,
|
|
380
381
|
documents: z.z.array(z.z.object({ name: z.z.string().max(120), content: z.z.string().max(16e3) })).max(5)
|
|
381
382
|
});
|
|
382
383
|
const WorkflowSlotSchema = z.z.object({ agent: WorkflowAgentSchema, assignment: text });
|
|
384
|
+
const WorkflowStepSchema = z.z.object({
|
|
385
|
+
id: z.z.string().uuid(),
|
|
386
|
+
name: z.z.string().trim().min(1).max(80),
|
|
387
|
+
kind: z.z.enum(["plan", "execute", "review"]),
|
|
388
|
+
agents: z.z.array(WorkflowSlotSchema).min(1).max(3),
|
|
389
|
+
criteria: z.z.string().trim().max(24e3),
|
|
390
|
+
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)
|
|
391
|
+
});
|
|
392
|
+
function workflowProjection(steps) {
|
|
393
|
+
return {
|
|
394
|
+
planners: steps.find((s) => s.kind === "plan")?.agents ?? [],
|
|
395
|
+
executor: steps.find((s) => s.kind === "execute")?.agents[0],
|
|
396
|
+
reviewers: [...steps].reverse().find((s) => s.kind === "review")?.agents ?? []
|
|
397
|
+
};
|
|
398
|
+
}
|
|
383
399
|
const WorkflowDefinitionSchema = z.z.object({
|
|
384
400
|
id: z.z.string().uuid(),
|
|
385
401
|
revision: z.z.number().int().positive(),
|
|
386
402
|
name: z.z.string().trim().min(1).max(80),
|
|
387
403
|
description: z.z.string().max(1e3),
|
|
388
|
-
planners: z.z.array(WorkflowSlotSchema).min(
|
|
404
|
+
planners: z.z.array(WorkflowSlotSchema).min(1).max(4),
|
|
389
405
|
executor: WorkflowSlotSchema,
|
|
390
|
-
reviewers: z.z.array(WorkflowSlotSchema).min(
|
|
406
|
+
reviewers: z.z.array(WorkflowSlotSchema).min(1).max(4),
|
|
407
|
+
steps: z.z.array(WorkflowStepSchema).min(3).max(8).optional(),
|
|
391
408
|
criteria: text,
|
|
392
409
|
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
410
|
planningRounds: z.z.number().int().min(1).max(5),
|
|
@@ -398,11 +415,40 @@ const WorkflowDefinitionSchema = z.z.object({
|
|
|
398
415
|
updatedAt: z.z.number()
|
|
399
416
|
}).superRefine((d, ctx) => {
|
|
400
417
|
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
|
|
402
|
-
if (
|
|
403
|
-
|
|
418
|
+
const issue = (message) => ctx.addIssue({ code: "custom", message });
|
|
419
|
+
if (d.steps) {
|
|
420
|
+
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.");
|
|
421
|
+
if (new Set(d.steps.map((s) => s.id)).size !== d.steps.length) issue("Each step needs a unique ID.");
|
|
422
|
+
const writers = new Set(d.steps.filter((s) => s.kind === "execute").flatMap((s) => s.agents.map((a) => a.agent.id)));
|
|
423
|
+
const identities = /* @__PURE__ */ new Map();
|
|
424
|
+
let executed = false;
|
|
425
|
+
for (const step of d.steps) {
|
|
426
|
+
if (step.kind === "plan") executed = false;
|
|
427
|
+
if (step.kind === "execute") executed = true;
|
|
428
|
+
if (step.kind === "review" && !executed) issue("Place an execution step between planning and review.");
|
|
429
|
+
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.");
|
|
430
|
+
if (step.kind !== "review" && step.checks.length) issue("Attach step checks to a review step.");
|
|
431
|
+
if (new Set(step.agents.map((s) => s.agent.id)).size !== step.agents.length) issue("Choose distinct agents within a consensus step.");
|
|
432
|
+
for (const slot of step.agents) {
|
|
433
|
+
if (step.kind === "review" && writers.has(slot.agent.id)) issue("Reviewers must be independent of every executor.");
|
|
434
|
+
const snapshot = JSON.stringify(slot.agent);
|
|
435
|
+
if (identities.has(slot.agent.id) && identities.get(slot.agent.id) !== snapshot) issue("A reused agent must have the same configuration in every step.");
|
|
436
|
+
identities.set(slot.agent.id, snapshot);
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
const projection = workflowProjection(d.steps);
|
|
440
|
+
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.");
|
|
441
|
+
} else {
|
|
442
|
+
if (d.planners.length < 2 || d.reviewers.length < 2) issue("Legacy workflows require at least two planners and reviewers.");
|
|
443
|
+
const ids = [...d.planners, d.executor, ...d.reviewers].map((s) => s.agent.id);
|
|
444
|
+
if (new Set(ids).size !== ids.length) issue("Each workflow participant must be a different saved agent.");
|
|
445
|
+
if (d.executor.agent.permissionMode === "read-only") issue("The executor must allow workspace edits.");
|
|
446
|
+
}
|
|
404
447
|
});
|
|
405
448
|
const WorkflowLibrarySchema = z.z.array(WorkflowDefinitionSchema).max(20).refine((x) => JSON.stringify(x).length < 128e3, "Workflow library is too large.");
|
|
449
|
+
function workflowSlots(d) {
|
|
450
|
+
return d.steps?.flatMap((s) => s.agents) ?? [...d.planners, d.executor, ...d.reviewers];
|
|
451
|
+
}
|
|
406
452
|
const WorkflowStageSchema = z.z.enum(["propose", "consolidate", "plan_vote", "execute", "review", "verify"]);
|
|
407
453
|
const WorkflowDecisionSchema = z.z.object({
|
|
408
454
|
decision: z.z.enum(["approve", "changes", "information", "replan"]),
|
|
@@ -416,6 +462,8 @@ const WorkflowTaskSchema = z.z.object({
|
|
|
416
462
|
round: z.z.number(),
|
|
417
463
|
agentId: z.z.string(),
|
|
418
464
|
agentName: z.z.string(),
|
|
465
|
+
stepId: z.z.string().uuid().optional(),
|
|
466
|
+
attempt: z.z.number().int().positive().optional(),
|
|
419
467
|
clarifications: z.z.number().int().optional(),
|
|
420
468
|
assignment: z.z.string(),
|
|
421
469
|
version: z.z.string(),
|
|
@@ -441,6 +489,10 @@ const WorkflowRunSchema = z.z.object({
|
|
|
441
489
|
baseCommit: z.z.string(),
|
|
442
490
|
status: z.z.enum(["running", "paused", "needs_input", "complete", "cancelled"]),
|
|
443
491
|
stage: WorkflowStageSchema,
|
|
492
|
+
stepIndex: z.z.number().int().nonnegative().optional(),
|
|
493
|
+
stepAttempt: z.z.number().int().positive().optional(),
|
|
494
|
+
stepRounds: z.z.record(z.z.string(), z.z.number().int().positive()).optional(),
|
|
495
|
+
completedSteps: z.z.array(z.z.string().uuid()).max(8).optional(),
|
|
444
496
|
planningRound: z.z.number().int(),
|
|
445
497
|
reviewRound: z.z.number().int(),
|
|
446
498
|
planVersion: z.z.number().int(),
|
|
@@ -454,6 +506,16 @@ const WorkflowRunSchema = z.z.object({
|
|
|
454
506
|
approvedPlanVersion: z.z.number().nullable(),
|
|
455
507
|
createdAt: z.z.number(),
|
|
456
508
|
updatedAt: z.z.number()
|
|
509
|
+
}).superRefine((run, ctx) => {
|
|
510
|
+
if (!run.definition.steps) return;
|
|
511
|
+
const steps = run.definition.steps;
|
|
512
|
+
const step = steps[run.stepIndex ?? -1];
|
|
513
|
+
if (!step || !run.stepAttempt || !run.completedSteps || !run.stepRounds) {
|
|
514
|
+
ctx.addIssue({ code: "custom", message: "Editable workflow recovery state is incomplete." });
|
|
515
|
+
return;
|
|
516
|
+
}
|
|
517
|
+
const stages = step.kind === "plan" ? ["propose", "consolidate", "plan_vote"] : step.kind === "execute" ? ["execute"] : ["verify", "review"];
|
|
518
|
+
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
519
|
});
|
|
458
520
|
const WorkflowStartSchema = z.z.object({ id: z.z.string().uuid(), definition: WorkflowDefinitionSchema, task: text, directory: z.z.string().min(1).max(4e3) });
|
|
459
521
|
const WorkflowActionSchema = z.z.object({
|
|
@@ -468,6 +530,9 @@ function workflowEnabled(s) {
|
|
|
468
530
|
return s.experiments === true && s.expWorkflows === true;
|
|
469
531
|
}
|
|
470
532
|
const workflowStageLabel = { propose: "Independent proposals", consolidate: "Consolidating plan", plan_vote: "Planning consensus", execute: "Executing", review: "Independent review", verify: "Completion checks" };
|
|
533
|
+
function workflowNeedsProviders(definition) {
|
|
534
|
+
return workflowSlots(definition).some((slot) => slot.agent.provider !== "codex");
|
|
535
|
+
}
|
|
471
536
|
|
|
472
537
|
exports.AgentMessageSchema = AgentMessageSchema;
|
|
473
538
|
exports.ApiMessageSchema = ApiMessageSchema;
|
|
@@ -509,6 +574,7 @@ exports.WorkflowRunSchema = WorkflowRunSchema;
|
|
|
509
574
|
exports.WorkflowSlotSchema = WorkflowSlotSchema;
|
|
510
575
|
exports.WorkflowStageSchema = WorkflowStageSchema;
|
|
511
576
|
exports.WorkflowStartSchema = WorkflowStartSchema;
|
|
577
|
+
exports.WorkflowStepSchema = WorkflowStepSchema;
|
|
512
578
|
exports.WorkflowTaskSchema = WorkflowTaskSchema;
|
|
513
579
|
exports.authenticationContexts = authenticationContexts;
|
|
514
580
|
exports.createEnvelope = createEnvelope;
|
|
@@ -532,4 +598,7 @@ exports.sessionTurnEndStatusSchema = sessionTurnEndStatusSchema;
|
|
|
532
598
|
exports.sessionTurnStartEventSchema = sessionTurnStartEventSchema;
|
|
533
599
|
exports.toWireMetadata = toWireMetadata;
|
|
534
600
|
exports.workflowEnabled = workflowEnabled;
|
|
601
|
+
exports.workflowNeedsProviders = workflowNeedsProviders;
|
|
602
|
+
exports.workflowProjection = workflowProjection;
|
|
603
|
+
exports.workflowSlots = workflowSlots;
|
|
535
604
|
exports.workflowStageLabel = workflowStageLabel;
|