import type { ReplyPayload } from "../../auto-reply/reply-payload.js"; import { type CliDeps } from "../../cli/outbound-send-deps.js"; import type { SessionEntry } from "../../config/sessions.js"; import type { KlawConfig } from "../../config/types.klaw.js"; import { projectOutboundPayloadPlanForJson } from "../../infra/outbound/payloads.js"; import type { OutboundSessionContext } from "../../infra/outbound/session-context.js"; import { type RuntimeEnv } from "../../runtime.js"; import type { EmbeddedPiRunMeta } from "../pi-embedded-runner/types.js"; import type { AgentCommandOpts, AgentCommandResultMetaOverrides } from "./types.js"; type RunResult = Awaited>; export type AgentCommandDeliveryPayloadStatus = "sent" | "suppressed" | "failed"; export type AgentCommandDeliveryPayloadOutcome = { index: number; status: AgentCommandDeliveryPayloadStatus; reason?: string; resultCount?: number; sentBeforeError?: boolean; stage?: string; error?: string; hookEffect?: { cancelReason?: string; metadata?: Record; }; }; export type AgentCommandDeliveryStatus = { requested: true; attempted: boolean; status: "sent" | "suppressed" | "partial_failed" | "failed"; /** `partial` means at least one payload was sent before a later payload failed. */ succeeded: true | false | "partial"; error?: true; errorMessage?: string; /** Free-form lowercase_snake reason from durable delivery or preflight validation. */ reason?: string; resultCount?: number; sentBeforeError?: true; payloadOutcomes?: AgentCommandDeliveryPayloadOutcome[]; }; export type AgentCommandDeliveryResult = { payloads: ReturnType; meta: EmbeddedPiRunMeta & AgentCommandResultMetaOverrides; deliverySucceeded?: boolean; deliveryStatus?: AgentCommandDeliveryStatus; }; type FreshSessionEntryForDeliveryResolver = () => Promise; type FreshSessionDeliveryRefreshParams = { expectedSessionIdForFreshDelivery: string; resolveFreshSessionEntryForDelivery: FreshSessionEntryForDeliveryResolver; } | { expectedSessionIdForFreshDelivery?: string; resolveFreshSessionEntryForDelivery?: undefined; }; type DeliverAgentCommandResultParams = { cfg: KlawConfig; deps: CliDeps; runtime: RuntimeEnv; opts: AgentCommandOpts; outboundSession: OutboundSessionContext | undefined; sessionEntry: SessionEntry | undefined; result: RunResult; payloads: RunResult["payloads"]; } & FreshSessionDeliveryRefreshParams; export declare function normalizeAgentCommandReplyPayloads(params: { cfg: KlawConfig; opts: AgentCommandOpts; outboundSession: OutboundSessionContext | undefined; payloads: RunResult["payloads"]; result: RunResult; deliveryChannel?: string; accountId?: string; applyChannelTransforms?: boolean; }): ReplyPayload[]; export declare function deliverAgentCommandResult(params: DeliverAgentCommandResultParams): Promise; export {};