@peac/schema 0.9.31 → 0.10.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.
@@ -0,0 +1,655 @@
1
+ /**
2
+ * PEAC Workflow Correlation Types (v0.10.2+)
3
+ *
4
+ * Workflow correlation primitives for multi-agent orchestration.
5
+ * These types enable tracking and verification of multi-step agentic workflows
6
+ * across different frameworks (MCP, A2A, CrewAI, LangGraph, etc.).
7
+ *
8
+ * Design principles:
9
+ * - Non-breaking: Uses extensions mechanism (auth.extensions['org.peacprotocol/workflow'])
10
+ * - DAG semantics: Parent linking for execution graph reconstruction
11
+ * - Framework-agnostic: Works with any orchestration layer
12
+ * - Deterministic: Supports offline verification and audit
13
+ *
14
+ * @see docs/specs/WORKFLOW-CORRELATION.md
15
+ */
16
+ import { z } from 'zod';
17
+ /**
18
+ * Extension key for workflow context
19
+ * Used in auth.extensions['org.peacprotocol/workflow']
20
+ */
21
+ export declare const WORKFLOW_EXTENSION_KEY = "org.peacprotocol/workflow";
22
+ /**
23
+ * Attestation type for workflow summaries
24
+ */
25
+ export declare const WORKFLOW_SUMMARY_TYPE: "peac/workflow-summary";
26
+ /**
27
+ * Workflow status values
28
+ */
29
+ export declare const WORKFLOW_STATUSES: readonly ["in_progress", "completed", "failed", "cancelled"];
30
+ /**
31
+ * Well-known orchestration frameworks (informational, not normative)
32
+ *
33
+ * The framework field accepts any string matching the framework grammar.
34
+ * These well-known values are listed in the PEAC registries for interop.
35
+ * New frameworks do NOT require protocol updates - just use the name.
36
+ *
37
+ * @see docs/specs/registries.json - orchestration_frameworks section
38
+ */
39
+ export declare const WELL_KNOWN_FRAMEWORKS: readonly ["mcp", "a2a", "crewai", "langgraph", "autogen", "custom"];
40
+ /**
41
+ * @deprecated Use WELL_KNOWN_FRAMEWORKS instead. Kept for backwards compatibility.
42
+ */
43
+ export declare const ORCHESTRATION_FRAMEWORKS: readonly ["mcp", "a2a", "crewai", "langgraph", "autogen", "custom"];
44
+ /**
45
+ * Framework identifier grammar pattern
46
+ *
47
+ * Lowercase letters, digits, hyphens, underscores.
48
+ * Must start with a letter. Max 64 characters.
49
+ * Examples: "mcp", "a2a", "crewai", "langgraph", "dspy", "smolagents"
50
+ */
51
+ export declare const FRAMEWORK_ID_PATTERN: RegExp;
52
+ /**
53
+ * Workflow correlation limits (DoS protection)
54
+ */
55
+ export declare const WORKFLOW_LIMITS: {
56
+ /** Maximum parent steps per step (DAG fan-in) */
57
+ readonly maxParentSteps: 16;
58
+ /** Maximum workflow ID length */
59
+ readonly maxWorkflowIdLength: 128;
60
+ /** Maximum step ID length */
61
+ readonly maxStepIdLength: 128;
62
+ /** Maximum tool name length */
63
+ readonly maxToolNameLength: 256;
64
+ /** Maximum framework identifier length */
65
+ readonly maxFrameworkLength: 64;
66
+ /** Maximum agents in a workflow summary */
67
+ readonly maxAgentsInvolved: 100;
68
+ /** Maximum receipt refs in a workflow summary */
69
+ readonly maxReceiptRefs: 10000;
70
+ /** Maximum error message length */
71
+ readonly maxErrorMessageLength: 1024;
72
+ };
73
+ /**
74
+ * Workflow ID format: wf_{ulid} or wf_{uuid}
75
+ * Examples:
76
+ * - wf_01HXYZ... (ULID)
77
+ * - wf_550e8400-e29b-41d4-a716-446655440000 (UUID)
78
+ */
79
+ export declare const WORKFLOW_ID_PATTERN: RegExp;
80
+ /**
81
+ * Step ID format: step_{ulid} or step_{uuid}
82
+ * Examples:
83
+ * - step_01HXYZ... (ULID)
84
+ * - step_550e8400-e29b-41d4-a716-446655440000 (UUID)
85
+ */
86
+ export declare const STEP_ID_PATTERN: RegExp;
87
+ /**
88
+ * Workflow ID schema
89
+ */
90
+ export declare const WorkflowIdSchema: z.ZodString;
91
+ /**
92
+ * Step ID schema
93
+ */
94
+ export declare const StepIdSchema: z.ZodString;
95
+ /**
96
+ * Workflow status schema
97
+ */
98
+ export declare const WorkflowStatusSchema: z.ZodEnum<["in_progress", "completed", "failed", "cancelled"]>;
99
+ /**
100
+ * Orchestration framework schema
101
+ *
102
+ * Open string field with constrained grammar. Any lowercase identifier
103
+ * matching the framework grammar is valid. Well-known values are listed
104
+ * in WELL_KNOWN_FRAMEWORKS and the PEAC registries.
105
+ *
106
+ * Grammar: /^[a-z][a-z0-9_-]*$/ (max 64 chars)
107
+ */
108
+ export declare const OrchestrationFrameworkSchema: z.ZodString;
109
+ /**
110
+ * Workflow context schema - attached to individual receipts
111
+ *
112
+ * This is the core primitive that links receipts into a workflow DAG.
113
+ * Place in auth.extensions['org.peacprotocol/workflow']
114
+ */
115
+ export declare const WorkflowContextSchema: z.ZodObject<{
116
+ /** Globally unique workflow/run ID */
117
+ workflow_id: z.ZodString;
118
+ /** This step's unique ID */
119
+ step_id: z.ZodString;
120
+ /** DAG parent step IDs (empty array for root step) */
121
+ parent_step_ids: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
122
+ /** Agent identity ref of the orchestrator (optional) */
123
+ orchestrator_id: z.ZodOptional<z.ZodString>;
124
+ /** Receipt ID that initiated this workflow (optional) */
125
+ orchestrator_receipt_ref: z.ZodOptional<z.ZodString>;
126
+ /** 0-based position in sequential runs (optional) */
127
+ step_index: z.ZodOptional<z.ZodNumber>;
128
+ /** Total steps if known upfront (optional) */
129
+ step_total: z.ZodOptional<z.ZodNumber>;
130
+ /** Tool or skill name (MCP tool, A2A skill, etc.) */
131
+ tool_name: z.ZodOptional<z.ZodString>;
132
+ /** Orchestration framework */
133
+ framework: z.ZodOptional<z.ZodString>;
134
+ /** SHA-256 hash of previous receipt in chain (for ordering) */
135
+ prev_receipt_hash: z.ZodOptional<z.ZodString>;
136
+ }, "strict", z.ZodTypeAny, {
137
+ workflow_id: string;
138
+ step_id: string;
139
+ parent_step_ids: string[];
140
+ orchestrator_id?: string | undefined;
141
+ orchestrator_receipt_ref?: string | undefined;
142
+ step_index?: number | undefined;
143
+ step_total?: number | undefined;
144
+ tool_name?: string | undefined;
145
+ framework?: string | undefined;
146
+ prev_receipt_hash?: string | undefined;
147
+ }, {
148
+ workflow_id: string;
149
+ step_id: string;
150
+ parent_step_ids?: string[] | undefined;
151
+ orchestrator_id?: string | undefined;
152
+ orchestrator_receipt_ref?: string | undefined;
153
+ step_index?: number | undefined;
154
+ step_total?: number | undefined;
155
+ tool_name?: string | undefined;
156
+ framework?: string | undefined;
157
+ prev_receipt_hash?: string | undefined;
158
+ }>;
159
+ /**
160
+ * Error context for failed workflows
161
+ */
162
+ export declare const WorkflowErrorContextSchema: z.ZodObject<{
163
+ /** Step ID where failure occurred */
164
+ failed_step_id: z.ZodString;
165
+ /** Error code (E_* format preferred) */
166
+ error_code: z.ZodString;
167
+ /** Human-readable error message */
168
+ error_message: z.ZodString;
169
+ }, "strict", z.ZodTypeAny, {
170
+ failed_step_id: string;
171
+ error_code: string;
172
+ error_message: string;
173
+ }, {
174
+ failed_step_id: string;
175
+ error_code: string;
176
+ error_message: string;
177
+ }>;
178
+ /**
179
+ * Workflow summary evidence - the "proof of run" artifact
180
+ *
181
+ * Used in peac/workflow-summary attestations.
182
+ * This is the single handle auditors use to verify an entire workflow.
183
+ */
184
+ export declare const WorkflowSummaryEvidenceSchema: z.ZodEffects<z.ZodEffects<z.ZodObject<{
185
+ /** Workflow ID this summary describes */
186
+ workflow_id: z.ZodString;
187
+ /** Workflow status */
188
+ status: z.ZodEnum<["in_progress", "completed", "failed", "cancelled"]>;
189
+ /** When the workflow started (ISO 8601) */
190
+ started_at: z.ZodString;
191
+ /** When the workflow completed (ISO 8601, undefined if in_progress) */
192
+ completed_at: z.ZodOptional<z.ZodString>;
193
+ /** Ordered list of receipt IDs (for small workflows) */
194
+ receipt_refs: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
195
+ /** Merkle root of receipt digests (for large workflows, RFC 6962 style) */
196
+ receipt_merkle_root: z.ZodOptional<z.ZodString>;
197
+ /** Total receipt count (required if using Merkle root) */
198
+ receipt_count: z.ZodOptional<z.ZodNumber>;
199
+ /** Agent identity ref of the orchestrator */
200
+ orchestrator_id: z.ZodString;
201
+ /** List of agent IDs involved in the workflow */
202
+ agents_involved: z.ZodArray<z.ZodString, "many">;
203
+ /** SHA-256 hash of final output artifact (optional) */
204
+ final_result_hash: z.ZodOptional<z.ZodString>;
205
+ /** Error context if workflow failed */
206
+ error_context: z.ZodOptional<z.ZodObject<{
207
+ /** Step ID where failure occurred */
208
+ failed_step_id: z.ZodString;
209
+ /** Error code (E_* format preferred) */
210
+ error_code: z.ZodString;
211
+ /** Human-readable error message */
212
+ error_message: z.ZodString;
213
+ }, "strict", z.ZodTypeAny, {
214
+ failed_step_id: string;
215
+ error_code: string;
216
+ error_message: string;
217
+ }, {
218
+ failed_step_id: string;
219
+ error_code: string;
220
+ error_message: string;
221
+ }>>;
222
+ }, "strict", z.ZodTypeAny, {
223
+ status: "in_progress" | "completed" | "failed" | "cancelled";
224
+ workflow_id: string;
225
+ orchestrator_id: string;
226
+ started_at: string;
227
+ agents_involved: string[];
228
+ completed_at?: string | undefined;
229
+ receipt_refs?: string[] | undefined;
230
+ receipt_merkle_root?: string | undefined;
231
+ receipt_count?: number | undefined;
232
+ final_result_hash?: string | undefined;
233
+ error_context?: {
234
+ failed_step_id: string;
235
+ error_code: string;
236
+ error_message: string;
237
+ } | undefined;
238
+ }, {
239
+ status: "in_progress" | "completed" | "failed" | "cancelled";
240
+ workflow_id: string;
241
+ orchestrator_id: string;
242
+ started_at: string;
243
+ agents_involved: string[];
244
+ completed_at?: string | undefined;
245
+ receipt_refs?: string[] | undefined;
246
+ receipt_merkle_root?: string | undefined;
247
+ receipt_count?: number | undefined;
248
+ final_result_hash?: string | undefined;
249
+ error_context?: {
250
+ failed_step_id: string;
251
+ error_code: string;
252
+ error_message: string;
253
+ } | undefined;
254
+ }>, {
255
+ status: "in_progress" | "completed" | "failed" | "cancelled";
256
+ workflow_id: string;
257
+ orchestrator_id: string;
258
+ started_at: string;
259
+ agents_involved: string[];
260
+ completed_at?: string | undefined;
261
+ receipt_refs?: string[] | undefined;
262
+ receipt_merkle_root?: string | undefined;
263
+ receipt_count?: number | undefined;
264
+ final_result_hash?: string | undefined;
265
+ error_context?: {
266
+ failed_step_id: string;
267
+ error_code: string;
268
+ error_message: string;
269
+ } | undefined;
270
+ }, {
271
+ status: "in_progress" | "completed" | "failed" | "cancelled";
272
+ workflow_id: string;
273
+ orchestrator_id: string;
274
+ started_at: string;
275
+ agents_involved: string[];
276
+ completed_at?: string | undefined;
277
+ receipt_refs?: string[] | undefined;
278
+ receipt_merkle_root?: string | undefined;
279
+ receipt_count?: number | undefined;
280
+ final_result_hash?: string | undefined;
281
+ error_context?: {
282
+ failed_step_id: string;
283
+ error_code: string;
284
+ error_message: string;
285
+ } | undefined;
286
+ }>, {
287
+ status: "in_progress" | "completed" | "failed" | "cancelled";
288
+ workflow_id: string;
289
+ orchestrator_id: string;
290
+ started_at: string;
291
+ agents_involved: string[];
292
+ completed_at?: string | undefined;
293
+ receipt_refs?: string[] | undefined;
294
+ receipt_merkle_root?: string | undefined;
295
+ receipt_count?: number | undefined;
296
+ final_result_hash?: string | undefined;
297
+ error_context?: {
298
+ failed_step_id: string;
299
+ error_code: string;
300
+ error_message: string;
301
+ } | undefined;
302
+ }, {
303
+ status: "in_progress" | "completed" | "failed" | "cancelled";
304
+ workflow_id: string;
305
+ orchestrator_id: string;
306
+ started_at: string;
307
+ agents_involved: string[];
308
+ completed_at?: string | undefined;
309
+ receipt_refs?: string[] | undefined;
310
+ receipt_merkle_root?: string | undefined;
311
+ receipt_count?: number | undefined;
312
+ final_result_hash?: string | undefined;
313
+ error_context?: {
314
+ failed_step_id: string;
315
+ error_code: string;
316
+ error_message: string;
317
+ } | undefined;
318
+ }>;
319
+ /**
320
+ * Workflow summary attestation schema
321
+ *
322
+ * A signed attestation containing the workflow summary evidence.
323
+ */
324
+ export declare const WorkflowSummaryAttestationSchema: z.ZodObject<{
325
+ /** Attestation type (must be 'peac/workflow-summary') */
326
+ type: z.ZodLiteral<"peac/workflow-summary">;
327
+ /** Who issued this attestation (HTTPS URL) */
328
+ issuer: z.ZodString;
329
+ /** When this attestation was issued (ISO 8601) */
330
+ issued_at: z.ZodString;
331
+ /** When this attestation expires (ISO 8601, optional) */
332
+ expires_at: z.ZodOptional<z.ZodString>;
333
+ /** The workflow summary evidence */
334
+ evidence: z.ZodEffects<z.ZodEffects<z.ZodObject<{
335
+ /** Workflow ID this summary describes */
336
+ workflow_id: z.ZodString;
337
+ /** Workflow status */
338
+ status: z.ZodEnum<["in_progress", "completed", "failed", "cancelled"]>;
339
+ /** When the workflow started (ISO 8601) */
340
+ started_at: z.ZodString;
341
+ /** When the workflow completed (ISO 8601, undefined if in_progress) */
342
+ completed_at: z.ZodOptional<z.ZodString>;
343
+ /** Ordered list of receipt IDs (for small workflows) */
344
+ receipt_refs: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
345
+ /** Merkle root of receipt digests (for large workflows, RFC 6962 style) */
346
+ receipt_merkle_root: z.ZodOptional<z.ZodString>;
347
+ /** Total receipt count (required if using Merkle root) */
348
+ receipt_count: z.ZodOptional<z.ZodNumber>;
349
+ /** Agent identity ref of the orchestrator */
350
+ orchestrator_id: z.ZodString;
351
+ /** List of agent IDs involved in the workflow */
352
+ agents_involved: z.ZodArray<z.ZodString, "many">;
353
+ /** SHA-256 hash of final output artifact (optional) */
354
+ final_result_hash: z.ZodOptional<z.ZodString>;
355
+ /** Error context if workflow failed */
356
+ error_context: z.ZodOptional<z.ZodObject<{
357
+ /** Step ID where failure occurred */
358
+ failed_step_id: z.ZodString;
359
+ /** Error code (E_* format preferred) */
360
+ error_code: z.ZodString;
361
+ /** Human-readable error message */
362
+ error_message: z.ZodString;
363
+ }, "strict", z.ZodTypeAny, {
364
+ failed_step_id: string;
365
+ error_code: string;
366
+ error_message: string;
367
+ }, {
368
+ failed_step_id: string;
369
+ error_code: string;
370
+ error_message: string;
371
+ }>>;
372
+ }, "strict", z.ZodTypeAny, {
373
+ status: "in_progress" | "completed" | "failed" | "cancelled";
374
+ workflow_id: string;
375
+ orchestrator_id: string;
376
+ started_at: string;
377
+ agents_involved: string[];
378
+ completed_at?: string | undefined;
379
+ receipt_refs?: string[] | undefined;
380
+ receipt_merkle_root?: string | undefined;
381
+ receipt_count?: number | undefined;
382
+ final_result_hash?: string | undefined;
383
+ error_context?: {
384
+ failed_step_id: string;
385
+ error_code: string;
386
+ error_message: string;
387
+ } | undefined;
388
+ }, {
389
+ status: "in_progress" | "completed" | "failed" | "cancelled";
390
+ workflow_id: string;
391
+ orchestrator_id: string;
392
+ started_at: string;
393
+ agents_involved: string[];
394
+ completed_at?: string | undefined;
395
+ receipt_refs?: string[] | undefined;
396
+ receipt_merkle_root?: string | undefined;
397
+ receipt_count?: number | undefined;
398
+ final_result_hash?: string | undefined;
399
+ error_context?: {
400
+ failed_step_id: string;
401
+ error_code: string;
402
+ error_message: string;
403
+ } | undefined;
404
+ }>, {
405
+ status: "in_progress" | "completed" | "failed" | "cancelled";
406
+ workflow_id: string;
407
+ orchestrator_id: string;
408
+ started_at: string;
409
+ agents_involved: string[];
410
+ completed_at?: string | undefined;
411
+ receipt_refs?: string[] | undefined;
412
+ receipt_merkle_root?: string | undefined;
413
+ receipt_count?: number | undefined;
414
+ final_result_hash?: string | undefined;
415
+ error_context?: {
416
+ failed_step_id: string;
417
+ error_code: string;
418
+ error_message: string;
419
+ } | undefined;
420
+ }, {
421
+ status: "in_progress" | "completed" | "failed" | "cancelled";
422
+ workflow_id: string;
423
+ orchestrator_id: string;
424
+ started_at: string;
425
+ agents_involved: string[];
426
+ completed_at?: string | undefined;
427
+ receipt_refs?: string[] | undefined;
428
+ receipt_merkle_root?: string | undefined;
429
+ receipt_count?: number | undefined;
430
+ final_result_hash?: string | undefined;
431
+ error_context?: {
432
+ failed_step_id: string;
433
+ error_code: string;
434
+ error_message: string;
435
+ } | undefined;
436
+ }>, {
437
+ status: "in_progress" | "completed" | "failed" | "cancelled";
438
+ workflow_id: string;
439
+ orchestrator_id: string;
440
+ started_at: string;
441
+ agents_involved: string[];
442
+ completed_at?: string | undefined;
443
+ receipt_refs?: string[] | undefined;
444
+ receipt_merkle_root?: string | undefined;
445
+ receipt_count?: number | undefined;
446
+ final_result_hash?: string | undefined;
447
+ error_context?: {
448
+ failed_step_id: string;
449
+ error_code: string;
450
+ error_message: string;
451
+ } | undefined;
452
+ }, {
453
+ status: "in_progress" | "completed" | "failed" | "cancelled";
454
+ workflow_id: string;
455
+ orchestrator_id: string;
456
+ started_at: string;
457
+ agents_involved: string[];
458
+ completed_at?: string | undefined;
459
+ receipt_refs?: string[] | undefined;
460
+ receipt_merkle_root?: string | undefined;
461
+ receipt_count?: number | undefined;
462
+ final_result_hash?: string | undefined;
463
+ error_context?: {
464
+ failed_step_id: string;
465
+ error_code: string;
466
+ error_message: string;
467
+ } | undefined;
468
+ }>;
469
+ }, "strict", z.ZodTypeAny, {
470
+ type: "peac/workflow-summary";
471
+ issuer: string;
472
+ issued_at: string;
473
+ evidence: {
474
+ status: "in_progress" | "completed" | "failed" | "cancelled";
475
+ workflow_id: string;
476
+ orchestrator_id: string;
477
+ started_at: string;
478
+ agents_involved: string[];
479
+ completed_at?: string | undefined;
480
+ receipt_refs?: string[] | undefined;
481
+ receipt_merkle_root?: string | undefined;
482
+ receipt_count?: number | undefined;
483
+ final_result_hash?: string | undefined;
484
+ error_context?: {
485
+ failed_step_id: string;
486
+ error_code: string;
487
+ error_message: string;
488
+ } | undefined;
489
+ };
490
+ expires_at?: string | undefined;
491
+ }, {
492
+ type: "peac/workflow-summary";
493
+ issuer: string;
494
+ issued_at: string;
495
+ evidence: {
496
+ status: "in_progress" | "completed" | "failed" | "cancelled";
497
+ workflow_id: string;
498
+ orchestrator_id: string;
499
+ started_at: string;
500
+ agents_involved: string[];
501
+ completed_at?: string | undefined;
502
+ receipt_refs?: string[] | undefined;
503
+ receipt_merkle_root?: string | undefined;
504
+ receipt_count?: number | undefined;
505
+ final_result_hash?: string | undefined;
506
+ error_context?: {
507
+ failed_step_id: string;
508
+ error_code: string;
509
+ error_message: string;
510
+ } | undefined;
511
+ };
512
+ expires_at?: string | undefined;
513
+ }>;
514
+ export type WorkflowId = z.infer<typeof WorkflowIdSchema>;
515
+ export type StepId = z.infer<typeof StepIdSchema>;
516
+ export type WorkflowStatus = z.infer<typeof WorkflowStatusSchema>;
517
+ export type OrchestrationFramework = z.infer<typeof OrchestrationFrameworkSchema>;
518
+ export type WorkflowContext = z.infer<typeof WorkflowContextSchema>;
519
+ export type WorkflowErrorContext = z.infer<typeof WorkflowErrorContextSchema>;
520
+ export type WorkflowSummaryEvidence = z.infer<typeof WorkflowSummaryEvidenceSchema>;
521
+ export type WorkflowSummaryAttestation = z.infer<typeof WorkflowSummaryAttestationSchema>;
522
+ /**
523
+ * Result of ordered workflow context validation.
524
+ *
525
+ * Returns a canonical error code per Section 6.5.1 validation ordering
526
+ * instead of Zod error messages, enabling language-neutral conformance testing.
527
+ */
528
+ export type WorkflowValidationResult = {
529
+ valid: true;
530
+ value: WorkflowContext;
531
+ } | {
532
+ valid: false;
533
+ error_code: string;
534
+ error: string;
535
+ };
536
+ /**
537
+ * Validate a WorkflowContext with explicit evaluation ordering.
538
+ *
539
+ * Implements Section 6.5.1 of WORKFLOW-CORRELATION.md:
540
+ * 1. Required field format (rules 4, 5)
541
+ * 2. Structural constraints (rule 3)
542
+ * 3. Optional field format (rules 6, 7)
543
+ * 4. Semantic DAG checks (rules 1, 2)
544
+ *
545
+ * This function does NOT depend on Zod's internal validation ordering.
546
+ * Cross-language implementations MUST produce identical error_code values
547
+ * for the same invalid input.
548
+ *
549
+ * @param input - Raw input to validate
550
+ * @returns Validation result with canonical error code on failure
551
+ */
552
+ export declare function validateWorkflowContextOrdered(input: unknown): WorkflowValidationResult;
553
+ /**
554
+ * Generate a workflow ID with the wf_ prefix
555
+ *
556
+ * @param id - ULID or UUID payload (without prefix)
557
+ * @returns Prefixed workflow ID
558
+ */
559
+ export declare function createWorkflowId(id: string): WorkflowId;
560
+ /**
561
+ * Generate a step ID with the step_ prefix
562
+ *
563
+ * @param id - ULID or UUID payload (without prefix)
564
+ * @returns Prefixed step ID
565
+ */
566
+ export declare function createStepId(id: string): StepId;
567
+ /**
568
+ * Validate a workflow context object
569
+ *
570
+ * @param context - Object to validate
571
+ * @returns Validated WorkflowContext
572
+ * @throws ZodError if validation fails
573
+ */
574
+ export declare function validateWorkflowContext(context: unknown): WorkflowContext;
575
+ /**
576
+ * Check if an object is a valid workflow context (non-throwing)
577
+ *
578
+ * @param context - Object to check
579
+ * @returns True if valid WorkflowContext
580
+ */
581
+ export declare function isValidWorkflowContext(context: unknown): context is WorkflowContext;
582
+ /**
583
+ * Validate a workflow summary attestation
584
+ *
585
+ * @param attestation - Object to validate
586
+ * @returns Validated WorkflowSummaryAttestation
587
+ * @throws ZodError if validation fails
588
+ */
589
+ export declare function validateWorkflowSummaryAttestation(attestation: unknown): WorkflowSummaryAttestation;
590
+ /**
591
+ * Check if an object is a workflow summary attestation (non-throwing)
592
+ *
593
+ * @param attestation - Object to check
594
+ * @returns True if valid WorkflowSummaryAttestation
595
+ */
596
+ export declare function isWorkflowSummaryAttestation(attestation: unknown): attestation is WorkflowSummaryAttestation;
597
+ /**
598
+ * Check if a workflow summary is in a terminal state
599
+ *
600
+ * @param status - Workflow status
601
+ * @returns True if completed, failed, or cancelled
602
+ */
603
+ export declare function isTerminalWorkflowStatus(status: WorkflowStatus): boolean;
604
+ /**
605
+ * Check if workflow context has valid DAG semantics (no self-parent)
606
+ *
607
+ * @param context - Workflow context to check
608
+ * @returns True if DAG semantics are valid
609
+ */
610
+ export declare function hasValidDagSemantics(context: WorkflowContext): boolean;
611
+ /**
612
+ * Create a workflow context for attaching to a receipt
613
+ *
614
+ * @param params - Workflow context parameters
615
+ * @returns Validated WorkflowContext
616
+ */
617
+ export declare function createWorkflowContext(params: {
618
+ workflow_id: string;
619
+ step_id: string;
620
+ parent_step_ids?: string[];
621
+ orchestrator_id?: string;
622
+ orchestrator_receipt_ref?: string;
623
+ step_index?: number;
624
+ step_total?: number;
625
+ tool_name?: string;
626
+ framework?: string;
627
+ prev_receipt_hash?: string;
628
+ }): WorkflowContext;
629
+ /**
630
+ * Create parameters for a workflow summary attestation
631
+ */
632
+ export interface CreateWorkflowSummaryParams {
633
+ workflow_id: string;
634
+ status: WorkflowStatus;
635
+ started_at: string;
636
+ completed_at?: string;
637
+ orchestrator_id: string;
638
+ agents_involved: string[];
639
+ receipt_refs?: string[];
640
+ receipt_merkle_root?: string;
641
+ receipt_count?: number;
642
+ final_result_hash?: string;
643
+ error_context?: WorkflowErrorContext;
644
+ issuer: string;
645
+ issued_at: string;
646
+ expires_at?: string;
647
+ }
648
+ /**
649
+ * Create a workflow summary attestation
650
+ *
651
+ * @param params - Attestation parameters
652
+ * @returns Validated WorkflowSummaryAttestation
653
+ */
654
+ export declare function createWorkflowSummaryAttestation(params: CreateWorkflowSummaryParams): WorkflowSummaryAttestation;
655
+ //# sourceMappingURL=workflow.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workflow.d.ts","sourceRoot":"","sources":["../src/workflow.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAMxB;;;GAGG;AACH,eAAO,MAAM,sBAAsB,8BAA8B,CAAC;AAElE;;GAEG;AACH,eAAO,MAAM,qBAAqB,EAAG,uBAAgC,CAAC;AAEtE;;GAEG;AACH,eAAO,MAAM,iBAAiB,8DAA+D,CAAC;AAE9F;;;;;;;;GAQG;AACH,eAAO,MAAM,qBAAqB,qEAOxB,CAAC;AAEX;;GAEG;AACH,eAAO,MAAM,wBAAwB,qEAAwB,CAAC;AAE9D;;;;;;GAMG;AACH,eAAO,MAAM,oBAAoB,QAAuB,CAAC;AAEzD;;GAEG;AACH,eAAO,MAAM,eAAe;IAC1B,iDAAiD;;IAEjD,iCAAiC;;IAEjC,6BAA6B;;IAE7B,+BAA+B;;IAE/B,0CAA0C;;IAE1C,2CAA2C;;IAE3C,iDAAiD;;IAEj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