import { l as ToolDispatchContext, c as AnthropicMessagesClient } from './types-DjPlsx0H.js';
import { a as InlineKeyboardMarkup } from './types-CaN5aq6Y.js';

type ProposalStatus = "PENDING" | "SNOOZED" | "COMPLETED" | "DISMISSED";
/** Where a proposal originated — useful for telemetry + UI grouping. */
type ProposalSource = 
/** Agent proposed during reasoning. */
"AGENT_INITIATED"
/** A watchitem condition was met. */
 | "WATCHITEM_FIRED"
/** User explicitly asked for it ("Archer can you..."). */
 | "USER_REQUESTED";
/**
 * A single proposal in any lifecycle state. `payload` is consumer-defined —
 * the executor receives whatever shape the consumer's tool expects.
 *
 * `originalPayload` is set the first time `editProposal` mutates `payload`,
 * preserving the agent's first attempt for diffing and audit trails.
 */
interface ProposalRecord<TPayload = unknown> {
    id: string;
    agentId: string;
    userId?: string;
    /** Action discriminator, e.g. 'send_email', 'log_transaction'. */
    type: string;
    status: ProposalStatus;
    source: ProposalSource;
    /** Short user-facing title for the approval card. */
    title: string;
    /** Why the agent is proposing this — surfaces to the user on demand. */
    rationale?: string;
    /** The structured action params. Shape is consumer-defined. */
    payload: TPayload;
    createdAt: Date;
    snoozedUntil?: Date | null;
    completedAt?: Date | null;
    dismissedAt?: Date | null;
    /**
     * If the user edited the proposal, the agent's original payload is kept
     * here so the diff can be displayed in the UI / written to the audit log.
     */
    originalPayload?: TPayload;
}
/**
 * Storage contract. Consumers implement against whatever persistence layer
 * they use (Prisma model in Archer, equivalent in FrankiAI, an in-memory
 * map for tests). agent-kit ships only the in-memory adapter.
 *
 * `create` is responsible for generating the id and stamping `createdAt`
 * and initial `status: 'PENDING'`. `listPending` MUST exclude snoozed
 * proposals whose `snoozedUntil` is still in the future.
 */
interface ProposalStorage<TPayload = unknown> {
    create(record: Omit<ProposalRecord<TPayload>, "id" | "createdAt" | "status">): Promise<ProposalRecord<TPayload>>;
    get(id: string): Promise<ProposalRecord<TPayload> | null>;
    update(id: string, patch: Partial<ProposalRecord<TPayload>>): Promise<ProposalRecord<TPayload>>;
    listPending(agentId: string, userId?: string): Promise<ProposalRecord<TPayload>[]>;
    listByStatus(status: ProposalStatus, agentId: string, userId?: string, limit?: number): Promise<ProposalRecord<TPayload>[]>;
}
/** A single state transition record written to the audit log. */
interface ProposalAuditEvent {
    proposalId: string;
    agentId: string;
    userId?: string;
    type: string;
    /** The transition itself, e.g. 'CREATED', 'APPROVED', 'SNOOZED'. */
    transition: ProposalAuditTransition;
    /** Status the proposal is in *after* the transition. */
    status: ProposalStatus;
    /** Optional free-text — user correction, executor error, completion note. */
    note?: string;
    /** Optional structured metadata (executor result, error shape, etc). */
    meta?: Record<string, unknown>;
    occurredAt: Date;
}
type ProposalAuditTransition = "CREATED" | "APPROVED" | "EDITED" | "SNOOZED" | "COMPLETED" | "DISMISSED" | "EXECUTOR_FAILED";
/**
 * Audit log sink — the consumer's hook into the AgentMemory write path.
 * Consumers typically wrap `writeEpisode` from `@sentinel-ai-solutions/agent-kit/memory`.
 * A no-op implementation is acceptable for tests.
 */
interface ProposalAuditLogger {
    record(event: ProposalAuditEvent): Promise<void> | void;
}

declare class ProposalStateError extends Error {
    constructor(message: string);
}
interface CreateProposalArgs<TPayload> {
    storage: ProposalStorage<TPayload>;
    audit: ProposalAuditLogger;
    record: Omit<ProposalRecord<TPayload>, "id" | "createdAt" | "status">;
    ctx: ToolDispatchContext;
}
declare function createProposal<TPayload>(args: CreateProposalArgs<TPayload>): Promise<ProposalRecord<TPayload>>;
interface ApproveProposalArgs<TPayload, TResult = unknown> {
    id: string;
    storage: ProposalStorage<TPayload>;
    audit: ProposalAuditLogger;
    executor: (payload: TPayload, ctx: ToolDispatchContext) => Promise<TResult> | TResult;
    ctx: ToolDispatchContext;
}
interface ApproveProposalResult<TResult = unknown> {
    executed: boolean;
    result?: TResult;
    error?: string;
}
declare function approveProposal<TPayload, TResult = unknown>(args: ApproveProposalArgs<TPayload, TResult>): Promise<ApproveProposalResult<TResult>>;
interface SnoozeProposalArgs<TPayload> {
    id: string;
    until: Date;
    storage: ProposalStorage<TPayload>;
    audit: ProposalAuditLogger;
    ctx: ToolDispatchContext;
}
declare function snoozeProposal<TPayload>(args: SnoozeProposalArgs<TPayload>): Promise<ProposalRecord<TPayload>>;
interface CompleteProposalArgs<TPayload> {
    id: string;
    storage: ProposalStorage<TPayload>;
    audit: ProposalAuditLogger;
    ctx: ToolDispatchContext;
    /** Optional free-text — e.g. "I already did this manually". */
    note?: string;
}
declare function completeProposal<TPayload>(args: CompleteProposalArgs<TPayload>): Promise<ProposalRecord<TPayload>>;
interface DismissProposalArgs<TPayload> {
    id: string;
    storage: ProposalStorage<TPayload>;
    audit: ProposalAuditLogger;
    ctx: ToolDispatchContext;
    reason?: string;
}
declare function dismissProposal<TPayload>(args: DismissProposalArgs<TPayload>): Promise<ProposalRecord<TPayload>>;
interface EditProposalArgs<TPayload> {
    id: string;
    /** Free-text correction the user wrote. */
    userCorrection: string;
    storage: ProposalStorage<TPayload>;
    audit: ProposalAuditLogger;
    haikuClient: AnthropicMessagesClient;
    ctx: ToolDispatchContext;
    /** Override the Haiku model id. Defaults to the latest Haiku 4.5. */
    haikuModel?: string;
    /**
     * Override the merge system prompt. Defaults to a prompt that asks Haiku
     * to return a single JSON object with the merged payload, preserving any
     * field the user didn't mention.
     */
    systemPrompt?: string;
    /**
     * Optional human-readable schema hint to give Haiku alongside the
     * original payload, e.g. "fields: to (email), subject, body".
     */
    payloadShapeHint?: string;
}
declare function editProposal<TPayload>(args: EditProposalArgs<TPayload>): Promise<ProposalRecord<TPayload>>;

type ApprovalAction = "approve" | "edit" | "discard";
interface BuildApprovalMessageOptions {
    /** Include the proposal's rationale in the body. Defaults to true. */
    showRationale?: boolean;
    /** Override the title prefix (default `"📝 "`). */
    titlePrefix?: string;
    /**
     * Inline-keyboard label overrides. Mirrors the existing
     * `createApprovalKeyboard` options.
     */
    yesLabel?: string;
    editLabel?: string;
    discardLabel?: string;
}
interface ApprovalMessage {
    text: string;
    inlineKeyboard: InlineKeyboardMarkup;
}
/**
 * Render a `ProposalRecord` into a Telegram message body + the standard
 * Yes / Edit / Discard inline keyboard.
 *
 * The body is plain text (no Markdown / HTML parse mode required) so it
 * round-trips through `sendMessage` without escaping concerns; callers
 * that want richer formatting pass a custom `titlePrefix` or post-process
 * the returned `text` before sending.
 */
declare function buildApprovalMessage<TPayload>(proposal: ProposalRecord<TPayload>, opts?: BuildApprovalMessageOptions): ApprovalMessage;
interface ParsedApprovalCallback {
    proposalId: string;
    action: ApprovalAction;
}
/**
 * Parse the `callback_data` Telegram sent us back when the user tapped a
 * Yes / Edit / Discard button. Returns `null` if the data does not look
 * like an approval callback — the caller can then fall through to other
 * routes (the Telegram router already does this).
 *
 * Expected shape (matches `createApprovalKeyboard`):
 *
 *   `${action}|${proposalId}`
 */
declare function parseApprovalCallback(callbackData: string): ParsedApprovalCallback | null;

declare class MemoryProposalStorage<TPayload = unknown> implements ProposalStorage<TPayload> {
    private readonly store;
    /** Override the clock for deterministic tests. */
    now: () => Date;
    create(record: Omit<ProposalRecord<TPayload>, "id" | "createdAt" | "status">): Promise<ProposalRecord<TPayload>>;
    get(id: string): Promise<ProposalRecord<TPayload> | null>;
    update(id: string, patch: Partial<ProposalRecord<TPayload>>): Promise<ProposalRecord<TPayload>>;
    listPending(agentId: string, userId?: string): Promise<ProposalRecord<TPayload>[]>;
    listByStatus(status: ProposalStatus, agentId: string, userId?: string, limit?: number): Promise<ProposalRecord<TPayload>[]>;
    size(): number;
    clear(): void;
}

declare class MemoryProposalAuditLogger implements ProposalAuditLogger {
    readonly events: ProposalAuditEvent[];
    record(event: ProposalAuditEvent): void;
    clear(): void;
    byTransition(transition: ProposalAuditEvent["transition"]): ProposalAuditEvent[];
    forProposal(proposalId: string): ProposalAuditEvent[];
}

type index_ApprovalAction = ApprovalAction;
type index_ApprovalMessage = ApprovalMessage;
type index_ApproveProposalArgs<TPayload, TResult = unknown> = ApproveProposalArgs<TPayload, TResult>;
type index_ApproveProposalResult<TResult = unknown> = ApproveProposalResult<TResult>;
type index_BuildApprovalMessageOptions = BuildApprovalMessageOptions;
type index_CompleteProposalArgs<TPayload> = CompleteProposalArgs<TPayload>;
type index_CreateProposalArgs<TPayload> = CreateProposalArgs<TPayload>;
type index_DismissProposalArgs<TPayload> = DismissProposalArgs<TPayload>;
type index_EditProposalArgs<TPayload> = EditProposalArgs<TPayload>;
type index_MemoryProposalAuditLogger = MemoryProposalAuditLogger;
declare const index_MemoryProposalAuditLogger: typeof MemoryProposalAuditLogger;
type index_MemoryProposalStorage<TPayload = unknown> = MemoryProposalStorage<TPayload>;
declare const index_MemoryProposalStorage: typeof MemoryProposalStorage;
type index_ParsedApprovalCallback = ParsedApprovalCallback;
type index_ProposalAuditEvent = ProposalAuditEvent;
type index_ProposalAuditLogger = ProposalAuditLogger;
type index_ProposalAuditTransition = ProposalAuditTransition;
type index_ProposalRecord<TPayload = unknown> = ProposalRecord<TPayload>;
type index_ProposalSource = ProposalSource;
type index_ProposalStateError = ProposalStateError;
declare const index_ProposalStateError: typeof ProposalStateError;
type index_ProposalStatus = ProposalStatus;
type index_ProposalStorage<TPayload = unknown> = ProposalStorage<TPayload>;
type index_SnoozeProposalArgs<TPayload> = SnoozeProposalArgs<TPayload>;
declare const index_approveProposal: typeof approveProposal;
declare const index_buildApprovalMessage: typeof buildApprovalMessage;
declare const index_completeProposal: typeof completeProposal;
declare const index_createProposal: typeof createProposal;
declare const index_dismissProposal: typeof dismissProposal;
declare const index_editProposal: typeof editProposal;
declare const index_parseApprovalCallback: typeof parseApprovalCallback;
declare const index_snoozeProposal: typeof snoozeProposal;
declare namespace index {
  export { type index_ApprovalAction as ApprovalAction, type index_ApprovalMessage as ApprovalMessage, type index_ApproveProposalArgs as ApproveProposalArgs, type index_ApproveProposalResult as ApproveProposalResult, type index_BuildApprovalMessageOptions as BuildApprovalMessageOptions, type index_CompleteProposalArgs as CompleteProposalArgs, type index_CreateProposalArgs as CreateProposalArgs, type index_DismissProposalArgs as DismissProposalArgs, type index_EditProposalArgs as EditProposalArgs, index_MemoryProposalAuditLogger as MemoryProposalAuditLogger, index_MemoryProposalStorage as MemoryProposalStorage, type index_ParsedApprovalCallback as ParsedApprovalCallback, type index_ProposalAuditEvent as ProposalAuditEvent, type index_ProposalAuditLogger as ProposalAuditLogger, type index_ProposalAuditTransition as ProposalAuditTransition, type index_ProposalRecord as ProposalRecord, type index_ProposalSource as ProposalSource, index_ProposalStateError as ProposalStateError, type index_ProposalStatus as ProposalStatus, type index_ProposalStorage as ProposalStorage, type index_SnoozeProposalArgs as SnoozeProposalArgs, index_approveProposal as approveProposal, index_buildApprovalMessage as buildApprovalMessage, index_completeProposal as completeProposal, index_createProposal as createProposal, index_dismissProposal as dismissProposal, index_editProposal as editProposal, index_parseApprovalCallback as parseApprovalCallback, index_snoozeProposal as snoozeProposal };
}

export { type ApprovalAction as A, type BuildApprovalMessageOptions as B, type CompleteProposalArgs as C, type DismissProposalArgs as D, type EditProposalArgs as E, MemoryProposalAuditLogger as M, type ParsedApprovalCallback as P, type SnoozeProposalArgs as S, type ApprovalMessage as a, type ApproveProposalArgs as b, type ApproveProposalResult as c, type CreateProposalArgs as d, MemoryProposalStorage as e, type ProposalAuditEvent as f, type ProposalAuditLogger as g, type ProposalAuditTransition as h, type ProposalRecord as i, type ProposalSource as j, ProposalStateError as k, type ProposalStatus as l, type ProposalStorage as m, approveProposal as n, buildApprovalMessage as o, completeProposal as p, createProposal as q, dismissProposal as r, editProposal as s, index as t, parseApprovalCallback as u, snoozeProposal as v };
