/** * @fileoverview Canonical Intent type definitions for the Vorion Platform. * * This file provides the authoritative definition for intents - requests from * agents to perform actions. It combines and reconciles the various Intent * definitions found across the codebase into a single canonical source. * * An Intent represents what an agent wants to do, including the action, * resources involved, classification metadata, and trust context. * * @module @orion/contracts/canonical/intent */ import { z } from 'zod'; import type { TrustBand } from './trust-band.js'; import { type TrustScore } from './trust-score.js'; export type { TrustScore }; export { ActionType, DataSensitivity, Reversibility } from '../v2/enums.js'; import { ActionType, DataSensitivity, Reversibility } from '../v2/enums.js'; /** * Intent lifecycle status. * * Tracks the intent through its complete lifecycle from submission * to completion or termination. * * @type {string} */ export type IntentStatus = /** Intent received, awaiting evaluation */ 'pending' /** Intent is being evaluated by trust/policy systems */ | 'evaluating' /** Intent approved, awaiting execution */ | 'approved' /** Intent denied by policy or trust requirements */ | 'denied' /** Intent escalated for human review */ | 'escalated' /** Intent is currently being executed */ | 'executing' /** Intent execution completed successfully */ | 'completed' /** Intent execution failed */ | 'failed' /** Intent was cancelled before completion */ | 'cancelled'; /** * All possible intent status values as an array. */ export declare const INTENT_STATUS_VALUES: readonly IntentStatus[]; /** * Terminal intent statuses (intent lifecycle has ended). */ export declare const TERMINAL_INTENT_STATUSES: readonly IntentStatus[]; /** * Active intent statuses (intent is still in progress). */ export declare const ACTIVE_INTENT_STATUSES: readonly IntentStatus[]; /** * Context information for intent evaluation. * * Provides additional context that policies and trust calculations * can use when evaluating whether to approve an intent. */ export interface IntentContext { /** * Domain of operation (e.g., 'healthcare', 'finance', 'hr'). * Used for domain-specific policy application. */ domain?: string; /** * Deployment environment. * Different policies may apply per environment. */ environment?: 'production' | 'staging' | 'development' | 'test' | string; /** * User or entity on whose behalf the agent is acting. * Important for delegation and audit trails. */ onBehalfOf?: string; /** * Session or conversation identifier. * Groups related intents together. */ sessionId?: string; /** * Parent intent ID for chained operations. * Enables multi-step operation tracking. */ parentIntentId?: string; /** * Priority level (0 = lowest, 10 = highest). * May affect queue ordering and resource allocation. */ priority?: number; /** * Whether this intent handles Personally Identifiable Information. * Triggers additional privacy controls. */ handlesPii?: boolean; /** * Whether this intent handles Protected Health Information. * Triggers HIPAA-related controls. */ handlesPhi?: boolean; /** * Jurisdictions involved (e.g., 'EU', 'US-CA', 'APAC'). * Affects applicable compliance rules. */ jurisdictions?: string[]; /** * Tags for categorization and filtering. */ tags?: string[]; /** * Custom metadata for domain-specific context. */ metadata?: Record; } /** * Trust state snapshot at intent submission time. * * Captures the agent's trust profile when the intent was created, * providing context for decisions and audit. */ export interface TrustSnapshot { /** Trust score at submission (0-1000 scale) */ score: TrustScore; /** Trust band at submission */ band: TrustBand; /** Timestamp when snapshot was taken */ capturedAt: Date; /** Profile version for optimistic concurrency */ profileVersion?: number; } /** * Canonical Intent interface. * * Represents a complete intent record with all fields from across * the platform's various Intent definitions unified into a single * authoritative structure. * * @example * ```typescript * const intent: Intent = { * intentId: 'int_abc123', * tenantId: 'ten_xyz789', * agentId: 'agt_def456', * correlationId: 'corr_ghi012', * action: 'Send quarterly report to stakeholders', * actionType: ActionType.COMMUNICATE, * resourceScope: ['reports:quarterly', 'email:external'], * dataSensitivity: DataSensitivity.CONFIDENTIAL, * reversibility: Reversibility.IRREVERSIBLE, * context: { * domain: 'finance', * environment: 'production', * handlesPii: true, * }, * trustSnapshot: { * score: createTrustScore(750), * band: TrustBand.T4_TRUSTED, * capturedAt: new Date(), * }, * status: 'pending', * createdAt: new Date(), * updatedAt: new Date(), * }; * ``` */ export interface Intent { /** * Unique intent identifier (UUID format). * Primary key for the intent. */ intentId: string; /** * Tenant/organization identifier. * Enables multi-tenant isolation. */ tenantId: string; /** * Agent making the request. * References the agent's unique identifier. */ agentId: string; /** * Correlation ID for end-to-end distributed tracing. * Links related events across services. */ correlationId: string; /** * Human-readable description of the intended action. * Should be clear and specific about what the agent wants to do. */ action: string; /** * Category of action being performed. * Used for policy matching and risk assessment. */ actionType: ActionType; /** * Resources this intent will access or modify. * Format: 'resource_type:resource_id' or URN patterns. * * @example ['database:users', 'api:payments/*', 'file:reports/q4.pdf'] */ resourceScope: string[]; /** * Data sensitivity level involved in this action. * Determines required trust level and audit depth. */ dataSensitivity: DataSensitivity; /** * Whether this action can be undone. * Affects approval requirements and safeguards. */ reversibility: Reversibility; /** * Additional context for policy evaluation. * Contains domain, environment, and other contextual information. */ context: IntentContext; /** * Trust profile snapshot at submission time. * Captures the agent's trust state when the intent was created. */ trustSnapshot: TrustSnapshot; /** * Current status in the intent lifecycle. */ status: IntentStatus; /** * When the intent was created. */ createdAt: Date; /** * When the intent was last updated. */ updatedAt: Date; /** * When the intent expires (optional). * After this time, the intent should be auto-denied. */ expiresAt?: Date; /** * Soft delete timestamp for GDPR compliance. * If set, the intent is considered deleted but retained for audit. */ deletedAt?: Date; /** * Reason for cancellation (if status is 'cancelled'). */ cancellationReason?: string; /** * Reason for denial (if status is 'denied'). */ denialReason?: string; /** * Reason for failure (if status is 'failed'). */ failureReason?: string; /** * Source system that generated this intent. * Useful for debugging and analytics. */ source?: string; /** * Decision ID if a decision has been made. * Links to the authorization decision record. */ decisionId?: string; /** * Execution ID if execution has started. * Links to the execution record. */ executionId?: string; } /** * Summary view of an intent for listings and dashboards. */ export interface IntentSummary { intentId: string; tenantId: string; agentId: string; correlationId: string; action: string; actionType: ActionType; dataSensitivity: DataSensitivity; status: IntentStatus; trustBand: TrustBand; createdAt: Date; } /** * Request to create a new intent. * * Contains the minimum required fields plus optional overrides. */ export interface CreateIntentRequest { /** Agent making the request */ agentId: string; /** Action description */ action: string; /** Action category */ actionType: ActionType; /** Resources to access/modify */ resourceScope: string[]; /** Data sensitivity level */ dataSensitivity: DataSensitivity; /** Reversibility classification */ reversibility: Reversibility; /** Optional correlation ID (generated if not provided) */ correlationId?: string; /** Optional context */ context?: Partial; /** Optional expiration in milliseconds from creation */ expiresInMs?: number; /** Optional source identifier */ source?: string; } /** * Type guard to check if a value is a valid IntentStatus. * * @param value - Value to check * @returns True if value is a valid IntentStatus */ export declare function isIntentStatus(value: unknown): value is IntentStatus; /** * Type guard to check if an IntentStatus is terminal. * * @param status - Status to check * @returns True if status is a terminal state */ export declare function isTerminalStatus(status: IntentStatus): boolean; /** * Type guard to check if an IntentStatus is active. * * @param status - Status to check * @returns True if status is an active state */ export declare function isActiveStatus(status: IntentStatus): boolean; /** * Zod schema for ActionType enum. */ export declare const actionTypeSchema: z.ZodNativeEnum; /** * Zod schema for DataSensitivity enum. */ export declare const dataSensitivitySchema: z.ZodNativeEnum; /** * Zod schema for Reversibility enum. */ export declare const reversibilitySchema: z.ZodNativeEnum; /** * Zod schema for IntentStatus. */ export declare const intentStatusSchema: z.ZodEnum<["pending", "evaluating", "approved", "denied", "escalated", "executing", "completed", "failed", "cancelled"]>; /** * Zod schema for IntentContext. */ export declare const intentContextSchema: z.ZodObject<{ domain: z.ZodOptional; environment: z.ZodOptional; onBehalfOf: z.ZodOptional; sessionId: z.ZodOptional; parentIntentId: z.ZodOptional; priority: z.ZodOptional; handlesPii: z.ZodOptional; handlesPhi: z.ZodOptional; jurisdictions: z.ZodOptional>; tags: z.ZodOptional>; metadata: z.ZodOptional>; }, "strict", z.ZodTypeAny, { metadata?: Record | undefined; domain?: string | undefined; priority?: number | undefined; environment?: string | undefined; sessionId?: string | undefined; onBehalfOf?: string | undefined; parentIntentId?: string | undefined; handlesPii?: boolean | undefined; handlesPhi?: boolean | undefined; jurisdictions?: string[] | undefined; tags?: string[] | undefined; }, { metadata?: Record | undefined; domain?: string | undefined; priority?: number | undefined; environment?: string | undefined; sessionId?: string | undefined; onBehalfOf?: string | undefined; parentIntentId?: string | undefined; handlesPii?: boolean | undefined; handlesPhi?: boolean | undefined; jurisdictions?: string[] | undefined; tags?: string[] | undefined; }>; /** * Zod schema for TrustSnapshot. */ export declare const trustSnapshotSchema: z.ZodObject<{ score: z.ZodNumber; band: z.ZodNativeEnum; capturedAt: z.ZodDate; profileVersion: z.ZodOptional; }, "strip", z.ZodTypeAny, { band: TrustBand; score: number; capturedAt: Date; profileVersion?: number | undefined; }, { band: TrustBand; score: number; capturedAt: Date; profileVersion?: number | undefined; }>; /** * Zod schema for Intent validation. */ export declare const intentSchema: z.ZodObject<{ intentId: z.ZodString; tenantId: z.ZodString; agentId: z.ZodString; correlationId: z.ZodString; action: z.ZodString; actionType: z.ZodNativeEnum; resourceScope: z.ZodArray; dataSensitivity: z.ZodNativeEnum; reversibility: z.ZodNativeEnum; context: z.ZodObject<{ domain: z.ZodOptional; environment: z.ZodOptional; onBehalfOf: z.ZodOptional; sessionId: z.ZodOptional; parentIntentId: z.ZodOptional; priority: z.ZodOptional; handlesPii: z.ZodOptional; handlesPhi: z.ZodOptional; jurisdictions: z.ZodOptional>; tags: z.ZodOptional>; metadata: z.ZodOptional>; }, "strict", z.ZodTypeAny, { metadata?: Record | undefined; domain?: string | undefined; priority?: number | undefined; environment?: string | undefined; sessionId?: string | undefined; onBehalfOf?: string | undefined; parentIntentId?: string | undefined; handlesPii?: boolean | undefined; handlesPhi?: boolean | undefined; jurisdictions?: string[] | undefined; tags?: string[] | undefined; }, { metadata?: Record | undefined; domain?: string | undefined; priority?: number | undefined; environment?: string | undefined; sessionId?: string | undefined; onBehalfOf?: string | undefined; parentIntentId?: string | undefined; handlesPii?: boolean | undefined; handlesPhi?: boolean | undefined; jurisdictions?: string[] | undefined; tags?: string[] | undefined; }>; trustSnapshot: z.ZodObject<{ score: z.ZodNumber; band: z.ZodNativeEnum; capturedAt: z.ZodDate; profileVersion: z.ZodOptional; }, "strip", z.ZodTypeAny, { band: TrustBand; score: number; capturedAt: Date; profileVersion?: number | undefined; }, { band: TrustBand; score: number; capturedAt: Date; profileVersion?: number | undefined; }>; status: z.ZodEnum<["pending", "evaluating", "approved", "denied", "escalated", "executing", "completed", "failed", "cancelled"]>; createdAt: z.ZodDate; updatedAt: z.ZodDate; expiresAt: z.ZodOptional; deletedAt: z.ZodOptional; cancellationReason: z.ZodOptional; denialReason: z.ZodOptional; failureReason: z.ZodOptional; source: z.ZodOptional; decisionId: z.ZodOptional; executionId: z.ZodOptional; }, "strip", z.ZodTypeAny, { status: "completed" | "failed" | "cancelled" | "pending" | "evaluating" | "approved" | "denied" | "escalated" | "executing"; correlationId: string; intentId: string; createdAt: Date; updatedAt: Date; agentId: string; context: { metadata?: Record | undefined; domain?: string | undefined; priority?: number | undefined; environment?: string | undefined; sessionId?: string | undefined; onBehalfOf?: string | undefined; parentIntentId?: string | undefined; handlesPii?: boolean | undefined; handlesPhi?: boolean | undefined; jurisdictions?: string[] | undefined; tags?: string[] | undefined; }; tenantId: string; action: string; actionType: ActionType; resourceScope: string[]; dataSensitivity: DataSensitivity; reversibility: Reversibility; trustSnapshot: { band: TrustBand; score: number; capturedAt: Date; profileVersion?: number | undefined; }; decisionId?: string | undefined; expiresAt?: Date | undefined; deletedAt?: Date | undefined; source?: string | undefined; cancellationReason?: string | undefined; denialReason?: string | undefined; failureReason?: string | undefined; executionId?: string | undefined; }, { status: "completed" | "failed" | "cancelled" | "pending" | "evaluating" | "approved" | "denied" | "escalated" | "executing"; correlationId: string; intentId: string; createdAt: Date; updatedAt: Date; agentId: string; context: { metadata?: Record | undefined; domain?: string | undefined; priority?: number | undefined; environment?: string | undefined; sessionId?: string | undefined; onBehalfOf?: string | undefined; parentIntentId?: string | undefined; handlesPii?: boolean | undefined; handlesPhi?: boolean | undefined; jurisdictions?: string[] | undefined; tags?: string[] | undefined; }; tenantId: string; action: string; actionType: ActionType; resourceScope: string[]; dataSensitivity: DataSensitivity; reversibility: Reversibility; trustSnapshot: { band: TrustBand; score: number; capturedAt: Date; profileVersion?: number | undefined; }; decisionId?: string | undefined; expiresAt?: Date | undefined; deletedAt?: Date | undefined; source?: string | undefined; cancellationReason?: string | undefined; denialReason?: string | undefined; failureReason?: string | undefined; executionId?: string | undefined; }>; /** * Zod schema for IntentSummary. */ export declare const intentSummarySchema: z.ZodObject<{ intentId: z.ZodString; tenantId: z.ZodString; agentId: z.ZodString; correlationId: z.ZodString; action: z.ZodString; actionType: z.ZodNativeEnum; dataSensitivity: z.ZodNativeEnum; status: z.ZodEnum<["pending", "evaluating", "approved", "denied", "escalated", "executing", "completed", "failed", "cancelled"]>; trustBand: z.ZodNativeEnum; createdAt: z.ZodDate; }, "strip", z.ZodTypeAny, { status: "completed" | "failed" | "cancelled" | "pending" | "evaluating" | "approved" | "denied" | "escalated" | "executing"; correlationId: string; intentId: string; createdAt: Date; agentId: string; tenantId: string; action: string; actionType: ActionType; dataSensitivity: DataSensitivity; trustBand: TrustBand; }, { status: "completed" | "failed" | "cancelled" | "pending" | "evaluating" | "approved" | "denied" | "escalated" | "executing"; correlationId: string; intentId: string; createdAt: Date; agentId: string; tenantId: string; action: string; actionType: ActionType; dataSensitivity: DataSensitivity; trustBand: TrustBand; }>; /** * Zod schema for CreateIntentRequest validation. */ export declare const createIntentRequestSchema: z.ZodObject<{ agentId: z.ZodString; action: z.ZodString; actionType: z.ZodNativeEnum; resourceScope: z.ZodArray; dataSensitivity: z.ZodNativeEnum; reversibility: z.ZodNativeEnum; correlationId: z.ZodOptional; context: z.ZodOptional>; environment: z.ZodOptional>; onBehalfOf: z.ZodOptional>; sessionId: z.ZodOptional>; parentIntentId: z.ZodOptional>; priority: z.ZodOptional>; handlesPii: z.ZodOptional>; handlesPhi: z.ZodOptional>; jurisdictions: z.ZodOptional>>; tags: z.ZodOptional>>; metadata: z.ZodOptional>>; }, "strict", z.ZodTypeAny, { metadata?: Record | undefined; domain?: string | undefined; priority?: number | undefined; environment?: string | undefined; sessionId?: string | undefined; onBehalfOf?: string | undefined; parentIntentId?: string | undefined; handlesPii?: boolean | undefined; handlesPhi?: boolean | undefined; jurisdictions?: string[] | undefined; tags?: string[] | undefined; }, { metadata?: Record | undefined; domain?: string | undefined; priority?: number | undefined; environment?: string | undefined; sessionId?: string | undefined; onBehalfOf?: string | undefined; parentIntentId?: string | undefined; handlesPii?: boolean | undefined; handlesPhi?: boolean | undefined; jurisdictions?: string[] | undefined; tags?: string[] | undefined; }>>; expiresInMs: z.ZodOptional; source: z.ZodOptional; }, "strip", z.ZodTypeAny, { agentId: string; action: string; actionType: ActionType; resourceScope: string[]; dataSensitivity: DataSensitivity; reversibility: Reversibility; correlationId?: string | undefined; context?: { metadata?: Record | undefined; domain?: string | undefined; priority?: number | undefined; environment?: string | undefined; sessionId?: string | undefined; onBehalfOf?: string | undefined; parentIntentId?: string | undefined; handlesPii?: boolean | undefined; handlesPhi?: boolean | undefined; jurisdictions?: string[] | undefined; tags?: string[] | undefined; } | undefined; source?: string | undefined; expiresInMs?: number | undefined; }, { agentId: string; action: string; actionType: ActionType; resourceScope: string[]; dataSensitivity: DataSensitivity; reversibility: Reversibility; correlationId?: string | undefined; context?: { metadata?: Record | undefined; domain?: string | undefined; priority?: number | undefined; environment?: string | undefined; sessionId?: string | undefined; onBehalfOf?: string | undefined; parentIntentId?: string | undefined; handlesPii?: boolean | undefined; handlesPhi?: boolean | undefined; jurisdictions?: string[] | undefined; tags?: string[] | undefined; } | undefined; source?: string | undefined; expiresInMs?: number | undefined; }>; /** * Inferred Intent type from Zod schema. */ export type IntentInput = z.input; /** * Inferred IntentContext type from Zod schema. */ export type IntentContextInput = z.input; /** * Inferred CreateIntentRequest type from Zod schema. */ export type CreateIntentRequestInput = z.input;