/** * PEAC Workflow Correlation Types (v0.10.2+) * * Workflow correlation primitives for multi-agent orchestration. * These types enable tracking and verification of multi-step agentic workflows * across different frameworks (MCP, A2A, CrewAI, LangGraph, etc.). * * Design principles: * - Non-breaking: Uses extensions mechanism (auth.extensions['org.peacprotocol/workflow']) * - DAG semantics: Parent linking for execution graph reconstruction * - Framework-agnostic: Works with any orchestration layer * - Deterministic: Supports offline verification and audit * * @see docs/specs/WORKFLOW-CORRELATION.md */ import { z } from 'zod'; /** * Extension key for workflow context * Used in auth.extensions['org.peacprotocol/workflow'] */ export declare const WORKFLOW_EXTENSION_KEY = "org.peacprotocol/workflow"; /** * Attestation type for workflow summaries */ export declare const WORKFLOW_SUMMARY_TYPE: "peac/workflow-summary"; /** * Workflow status values */ export declare const WORKFLOW_STATUSES: readonly ["in_progress", "completed", "failed", "cancelled"]; /** * Well-known orchestration frameworks (informational, not normative) * * The framework field accepts any string matching the framework grammar. * These well-known values are listed in the PEAC registries for interop. * New frameworks do NOT require protocol updates - just use the name. * * @see docs/specs/registries.json - orchestration_frameworks section */ export declare const WELL_KNOWN_FRAMEWORKS: readonly ["mcp", "a2a", "crewai", "langgraph", "autogen", "custom"]; /** * @deprecated Use WELL_KNOWN_FRAMEWORKS instead. Kept for backwards compatibility. */ export declare const ORCHESTRATION_FRAMEWORKS: readonly ["mcp", "a2a", "crewai", "langgraph", "autogen", "custom"]; /** * Framework identifier grammar pattern * * Lowercase letters, digits, hyphens, underscores. * Must start with a letter. Max 64 characters. * Examples: "mcp", "a2a", "crewai", "langgraph", "dspy", "smolagents" */ export declare const FRAMEWORK_ID_PATTERN: RegExp; /** * Workflow correlation limits (DoS protection) */ export declare const WORKFLOW_LIMITS: { /** Maximum parent steps per step (DAG fan-in) */ readonly maxParentSteps: 16; /** Maximum workflow ID length */ readonly maxWorkflowIdLength: 128; /** Maximum step ID length */ readonly maxStepIdLength: 128; /** Maximum tool name length */ readonly maxToolNameLength: 256; /** Maximum framework identifier length */ readonly maxFrameworkLength: 64; /** Maximum agents in a workflow summary */ readonly maxAgentsInvolved: 100; /** Maximum receipt refs in a workflow summary */ readonly maxReceiptRefs: 10000; /** Maximum error message length */ readonly maxErrorMessageLength: 1024; }; /** * Workflow ID format: wf_{ulid} or wf_{uuid} * Examples: * - wf_01HXYZ... (ULID) * - wf_550e8400-e29b-41d4-a716-446655440000 (UUID) */ export declare const WORKFLOW_ID_PATTERN: RegExp; /** * Step ID format: step_{ulid} or step_{uuid} * Examples: * - step_01HXYZ... (ULID) * - step_550e8400-e29b-41d4-a716-446655440000 (UUID) */ export declare const STEP_ID_PATTERN: RegExp; /** * Workflow ID schema */ export declare const WorkflowIdSchema: z.ZodString; /** * Step ID schema */ export declare const StepIdSchema: z.ZodString; /** * Workflow status schema */ export declare const WorkflowStatusSchema: z.ZodEnum<{ failed: "failed"; cancelled: "cancelled"; completed: "completed"; in_progress: "in_progress"; }>; /** * Orchestration framework schema * * Open string field with constrained grammar. Any lowercase identifier * matching the framework grammar is valid. Well-known values are listed * in WELL_KNOWN_FRAMEWORKS and the PEAC registries. * * Grammar: /^[a-z][a-z0-9_-]*$/ (max 64 chars) */ export declare const OrchestrationFrameworkSchema: z.ZodString; /** * Workflow context schema - attached to individual receipts * * This is the core primitive that links receipts into a workflow DAG. * Place in auth.extensions['org.peacprotocol/workflow'] */ export declare const WorkflowContextSchema: z.ZodObject<{ workflow_id: z.ZodString; step_id: z.ZodString; parent_step_ids: z.ZodDefault>; orchestrator_id: z.ZodOptional; orchestrator_receipt_ref: z.ZodOptional; step_index: z.ZodOptional; step_total: z.ZodOptional; tool_name: z.ZodOptional; framework: z.ZodOptional; prev_receipt_hash: z.ZodOptional; }, z.core.$strict>; /** * Error context for failed workflows */ export declare const WorkflowErrorContextSchema: z.ZodObject<{ failed_step_id: z.ZodString; error_code: z.ZodString; error_message: z.ZodString; }, z.core.$strict>; /** * Workflow summary evidence - the "proof of run" artifact * * Used in peac/workflow-summary attestations. * This is the single handle auditors use to verify an entire workflow. */ export declare const WorkflowSummaryEvidenceSchema: z.ZodObject<{ workflow_id: z.ZodString; status: z.ZodEnum<{ failed: "failed"; cancelled: "cancelled"; completed: "completed"; in_progress: "in_progress"; }>; started_at: z.ZodString; completed_at: z.ZodOptional; receipt_refs: z.ZodOptional>; receipt_merkle_root: z.ZodOptional; receipt_count: z.ZodOptional; orchestrator_id: z.ZodString; agents_involved: z.ZodArray; final_result_hash: z.ZodOptional; error_context: z.ZodOptional>; }, z.core.$strict>; /** * Workflow summary attestation schema * * A signed attestation containing the workflow summary evidence. */ export declare const WorkflowSummaryAttestationSchema: z.ZodObject<{ type: z.ZodLiteral<"peac/workflow-summary">; issuer: z.ZodString; issued_at: z.ZodString; expires_at: z.ZodOptional; evidence: z.ZodObject<{ workflow_id: z.ZodString; status: z.ZodEnum<{ failed: "failed"; cancelled: "cancelled"; completed: "completed"; in_progress: "in_progress"; }>; started_at: z.ZodString; completed_at: z.ZodOptional; receipt_refs: z.ZodOptional>; receipt_merkle_root: z.ZodOptional; receipt_count: z.ZodOptional; orchestrator_id: z.ZodString; agents_involved: z.ZodArray; final_result_hash: z.ZodOptional; error_context: z.ZodOptional>; }, z.core.$strict>; }, z.core.$strict>; export type WorkflowId = z.infer; export type StepId = z.infer; export type WorkflowStatus = z.infer; export type OrchestrationFramework = z.infer; export type WorkflowContext = z.infer; export type WorkflowErrorContext = z.infer; export type WorkflowSummaryEvidence = z.infer; export type WorkflowSummaryAttestation = z.infer; /** * Result of ordered workflow context validation. * * Returns a canonical error code per Section 6.5.1 validation ordering * instead of Zod error messages, enabling language-neutral conformance testing. */ export type WorkflowValidationResult = { valid: true; value: WorkflowContext; } | { valid: false; error_code: string; error: string; }; /** * Validate a WorkflowContext with explicit evaluation ordering. * * Implements Section 6.5.1 of WORKFLOW-CORRELATION.md: * 1. Required field format (rules 4, 5) * 2. Structural constraints (rule 3) * 3. Optional field format (rules 6, 7) * 4. Semantic DAG checks (rules 1, 2) * * This function does NOT depend on Zod's internal validation ordering. * Cross-language implementations MUST produce identical error_code values * for the same invalid input. * * @param input - Raw input to validate * @returns Validation result with canonical error code on failure */ export declare function validateWorkflowContextOrdered(input: unknown): WorkflowValidationResult; /** * Generate a workflow ID with the wf_ prefix * * @param id - ULID or UUID payload (without prefix) * @returns Prefixed workflow ID */ export declare function createWorkflowId(id: string): WorkflowId; /** * Generate a step ID with the step_ prefix * * @param id - ULID or UUID payload (without prefix) * @returns Prefixed step ID */ export declare function createStepId(id: string): StepId; /** * Validate a workflow context object * * @param context - Object to validate * @returns Validated WorkflowContext * @throws ZodError if validation fails */ export declare function validateWorkflowContext(context: unknown): WorkflowContext; /** * Check if an object is a valid workflow context (non-throwing) * * @param context - Object to check * @returns True if valid WorkflowContext */ export declare function isValidWorkflowContext(context: unknown): context is WorkflowContext; /** * Validate a workflow summary attestation * * @param attestation - Object to validate * @returns Validated WorkflowSummaryAttestation * @throws ZodError if validation fails */ export declare function validateWorkflowSummaryAttestation(attestation: unknown): WorkflowSummaryAttestation; /** * Check if an object is a workflow summary attestation (non-throwing) * * @param attestation - Object to check * @returns True if valid WorkflowSummaryAttestation */ export declare function isWorkflowSummaryAttestation(attestation: unknown): attestation is WorkflowSummaryAttestation; /** * Check if a workflow summary is in a terminal state * * @param status - Workflow status * @returns True if completed, failed, or cancelled */ export declare function isTerminalWorkflowStatus(status: WorkflowStatus): boolean; /** * Check if workflow context has valid DAG semantics (no self-parent) * * @param context - Workflow context to check * @returns True if DAG semantics are valid */ export declare function hasValidDagSemantics(context: WorkflowContext): boolean; /** * Create a workflow context for attaching to a receipt * * @param params - Workflow context parameters * @returns Validated WorkflowContext */ export declare function createWorkflowContext(params: { workflow_id: string; step_id: string; parent_step_ids?: string[]; orchestrator_id?: string; orchestrator_receipt_ref?: string; step_index?: number; step_total?: number; tool_name?: string; framework?: string; prev_receipt_hash?: string; }): WorkflowContext; /** * Create parameters for a workflow summary attestation */ export interface CreateWorkflowSummaryParams { workflow_id: string; status: WorkflowStatus; started_at: string; completed_at?: string; orchestrator_id: string; agents_involved: string[]; receipt_refs?: string[]; receipt_merkle_root?: string; receipt_count?: number; final_result_hash?: string; error_context?: WorkflowErrorContext; issuer: string; issued_at: string; expires_at?: string; } /** * Create a workflow summary attestation * * @param params - Attestation parameters * @returns Validated WorkflowSummaryAttestation */ export declare function createWorkflowSummaryAttestation(params: CreateWorkflowSummaryParams): WorkflowSummaryAttestation; //# sourceMappingURL=workflow.d.ts.map