@ahmadposten/talos-wire 0.1.1 → 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 +179 -0
- package/dist/index.d.cts +813 -2
- package/dist/index.d.mts +813 -2
- package/dist/index.mjs +166 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as z from 'zod';
|
|
2
|
+
import { z as z$1 } from 'zod';
|
|
2
3
|
import { isCuid, createId } from '@paralleldrive/cuid2';
|
|
3
4
|
|
|
4
5
|
const sessionRoleSchema = z.enum(["user", "agent"]);
|
|
@@ -345,4 +346,168 @@ const ProviderUsageSnapshotSchema = z.object({
|
|
|
345
346
|
retryAt: z.number().finite().optional()
|
|
346
347
|
});
|
|
347
348
|
|
|
348
|
-
|
|
349
|
+
const text = z$1.string().trim().min(1).max(24e3);
|
|
350
|
+
const WorkflowAgentSchema = z$1.object({
|
|
351
|
+
id: z$1.string().min(1).max(100),
|
|
352
|
+
revision: z$1.number().int().positive(),
|
|
353
|
+
name: z$1.string().min(1).max(60),
|
|
354
|
+
description: z$1.string().max(300),
|
|
355
|
+
provider: z$1.literal("codex"),
|
|
356
|
+
model: z$1.string().min(1).max(200),
|
|
357
|
+
effort: z$1.string().max(30).nullable(),
|
|
358
|
+
permissionMode: z$1.enum(["default", "read-only"]),
|
|
359
|
+
instructions: text,
|
|
360
|
+
documents: z$1.array(z$1.object({ name: z$1.string().max(120), content: z$1.string().max(16e3) })).max(5)
|
|
361
|
+
});
|
|
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
|
+
}
|
|
378
|
+
const WorkflowDefinitionSchema = z$1.object({
|
|
379
|
+
id: z$1.string().uuid(),
|
|
380
|
+
revision: z$1.number().int().positive(),
|
|
381
|
+
name: z$1.string().trim().min(1).max(80),
|
|
382
|
+
description: z$1.string().max(1e3),
|
|
383
|
+
planners: z$1.array(WorkflowSlotSchema).min(1).max(4),
|
|
384
|
+
executor: WorkflowSlotSchema,
|
|
385
|
+
reviewers: z$1.array(WorkflowSlotSchema).min(1).max(4),
|
|
386
|
+
steps: z$1.array(WorkflowStepSchema).min(3).max(8).optional(),
|
|
387
|
+
criteria: text,
|
|
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),
|
|
389
|
+
planningRounds: z$1.number().int().min(1).max(5),
|
|
390
|
+
reviewRounds: z$1.number().int().min(1).max(5),
|
|
391
|
+
turnMinutes: z$1.number().int().min(1).max(30),
|
|
392
|
+
maxTurns: z$1.number().int().min(8).max(100),
|
|
393
|
+
approvePlan: z$1.boolean(),
|
|
394
|
+
updatedAt: z$1.number()
|
|
395
|
+
}).superRefine((d, ctx) => {
|
|
396
|
+
if (new TextEncoder().encode(JSON.stringify(d)).length > 64e3) ctx.addIssue({ code: "custom", message: "Workflow definition exceeds 64 KB. Shorten instructions or documents." });
|
|
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
|
+
}
|
|
426
|
+
});
|
|
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
|
+
}
|
|
431
|
+
const WorkflowStageSchema = z$1.enum(["propose", "consolidate", "plan_vote", "execute", "review", "verify"]);
|
|
432
|
+
const WorkflowDecisionSchema = z$1.object({
|
|
433
|
+
decision: z$1.enum(["approve", "changes", "information", "replan"]),
|
|
434
|
+
summary: text,
|
|
435
|
+
document: z$1.string().max(24e3),
|
|
436
|
+
findings: z$1.array(z$1.object({ title: z$1.string().min(1).max(300), evidence: text, correction: text, blocking: z$1.boolean() })).max(20)
|
|
437
|
+
});
|
|
438
|
+
const WorkflowTaskSchema = z$1.object({
|
|
439
|
+
id: z$1.string(),
|
|
440
|
+
stage: WorkflowStageSchema,
|
|
441
|
+
round: z$1.number(),
|
|
442
|
+
agentId: z$1.string(),
|
|
443
|
+
agentName: z$1.string(),
|
|
444
|
+
stepId: z$1.string().uuid().optional(),
|
|
445
|
+
attempt: z$1.number().int().positive().optional(),
|
|
446
|
+
clarifications: z$1.number().int().optional(),
|
|
447
|
+
assignment: z$1.string(),
|
|
448
|
+
version: z$1.string(),
|
|
449
|
+
status: z$1.enum(["running", "done", "interrupted"]),
|
|
450
|
+
startedAt: z$1.number(),
|
|
451
|
+
completedAt: z$1.number().optional(),
|
|
452
|
+
sessionId: z$1.string().optional(),
|
|
453
|
+
threadId: z$1.string().optional(),
|
|
454
|
+
prompt: z$1.string(),
|
|
455
|
+
result: WorkflowDecisionSchema.optional(),
|
|
456
|
+
error: z$1.string().optional()
|
|
457
|
+
});
|
|
458
|
+
const WorkflowRunSchema = z$1.object({
|
|
459
|
+
id: z$1.string().uuid(),
|
|
460
|
+
revision: z$1.number().int(),
|
|
461
|
+
definition: WorkflowDefinitionSchema,
|
|
462
|
+
machineId: z$1.string(),
|
|
463
|
+
task: text,
|
|
464
|
+
requestedDirectory: z$1.string().optional(),
|
|
465
|
+
sourceDirectory: z$1.string(),
|
|
466
|
+
directory: z$1.string(),
|
|
467
|
+
branch: z$1.string(),
|
|
468
|
+
baseCommit: z$1.string(),
|
|
469
|
+
status: z$1.enum(["running", "paused", "needs_input", "complete", "cancelled"]),
|
|
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(),
|
|
475
|
+
planningRound: z$1.number().int(),
|
|
476
|
+
reviewRound: z$1.number().int(),
|
|
477
|
+
planVersion: z$1.number().int(),
|
|
478
|
+
plan: z$1.string(),
|
|
479
|
+
artifactVersion: z$1.string(),
|
|
480
|
+
reason: z$1.string(),
|
|
481
|
+
tasks: z$1.array(WorkflowTaskSchema).max(200),
|
|
482
|
+
checks: z$1.array(z$1.object({ name: z$1.string(), exitCode: z$1.number().nullable(), output: z$1.string(), version: z$1.string() })),
|
|
483
|
+
events: z$1.array(z$1.object({ at: z$1.number(), text: z$1.string() })).max(500),
|
|
484
|
+
notes: z$1.array(z$1.string()).max(30),
|
|
485
|
+
approvedPlanVersion: z$1.number().nullable(),
|
|
486
|
+
createdAt: z$1.number(),
|
|
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." });
|
|
498
|
+
});
|
|
499
|
+
const WorkflowStartSchema = z$1.object({ id: z$1.string().uuid(), definition: WorkflowDefinitionSchema, task: text, directory: z$1.string().min(1).max(4e3) });
|
|
500
|
+
const WorkflowActionSchema = z$1.object({
|
|
501
|
+
id: z$1.string().uuid(),
|
|
502
|
+
expectedRevision: z$1.number().int(),
|
|
503
|
+
action: z$1.enum(["pause", "resume", "cancel", "approve_plan", "revise_plan", "retry_review", "replace_agent"]),
|
|
504
|
+
note: z$1.string().trim().max(24e3).default(""),
|
|
505
|
+
agentId: z$1.string().optional(),
|
|
506
|
+
replacement: WorkflowAgentSchema.optional()
|
|
507
|
+
});
|
|
508
|
+
function workflowEnabled(s) {
|
|
509
|
+
return s.experiments === true && s.expWorkflows === true;
|
|
510
|
+
}
|
|
511
|
+
const workflowStageLabel = { propose: "Independent proposals", consolidate: "Consolidating plan", plan_vote: "Planning consensus", execute: "Executing", review: "Independent review", verify: "Completion checks" };
|
|
512
|
+
|
|
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 };
|