import { type VerbNativeMetadata } from '@canonmsg/backend-contracts'; import type { CanonUnifiedDiff } from './types.js'; export interface ApprovalRequestMetadata { type: 'approval_request'; approvalId: string; /** Canon user who should answer this card. UI hint only; reply APIs still enforce authorization. */ responseUserId?: string; toolName: string; /** Pre-computed, redacted summary — raw toolInput is never stored */ toolSummary: string; /** Broad action family for richer Canon approval cards. */ category?: ApprovalRequestCategory; /** Preferred v2 risk signal. `riskLevel` remains for older clients. */ risk?: ApprovalRisk; riskLevel?: 'normal' | 'destructive'; runtimeId?: string; turnId?: string; /** Native runtime correlation handle. Canon stores this opaquely for plugins/SDK bridges. */ native?: ApprovalNativeRequestMetadata; /** Redacted, normalized details. Raw tool input must not be stored here. */ details?: ApprovalRequestDetail[]; /** * File-change preview for file approvals — full unified diff so the owner * can review the change inline before approving, like native habitats. * Size-disciplined via truncateUnifiedDiff. */ diff?: CanonUnifiedDiff; /** Whether the responder may create a rule that applies to later turns. */ allowSessionRule?: boolean; expiresAt: string; } export interface ApprovalOutcomeMetadata { type: 'approval_outcome'; approvalId?: string; decision?: 'allow' | 'deny'; reason?: 'replied' | 'timeout' | 'session-rule'; } export interface ApprovalReplyMetadata { type: 'approval_reply'; approvalId: string; decision: 'allow' | 'deny'; sessionRule?: SessionRule; } export type ApprovalRequestCategory = 'command' | 'file' | 'network' | 'browser' | 'mcp' | 'plugin' | 'canon' | 'tool'; export type ApprovalRisk = 'low' | 'normal' | 'high' | 'destructive'; export interface ApprovalRequestDetail { label: string; value: string; monospace?: boolean; } export type ApprovalNativeRequestMetadata = VerbNativeMetadata; export interface SessionRule { type: 'approve-all' | 'approve-tool' | 'deny-tool'; /** Tool name pattern (regex) — only for approve-tool/deny-tool */ toolPattern?: string; /** When this rule expires (ISO 8601), null = session lifetime */ expiresAt?: string | null; } export interface ApprovalResult { decision: 'allow' | 'deny'; sessionRule?: SessionRule; /** Canon-authenticated human who submitted this decision. */ respondedBy?: string; } export interface ApprovalConfig { enabled: boolean; timeoutSeconds: number; defaultOnTimeout: 'deny' | 'ask'; redactPatterns: string[]; } export declare const DEFAULT_APPROVAL_CONFIG: ApprovalConfig; export declare function parseSessionRule(value: unknown): SessionRule | null; export declare function parseApprovalReplyMetadata(value: unknown): ApprovalReplyMetadata | null; export declare function parseApprovalRequestMetadata(value: unknown): ApprovalRequestMetadata | null;