import type { AgentExecutionRefs, TransportResponsePayload, TransportUsageInfo, TransportBillingInfo } from "./transport.js";
import type { ModelSelectionReason } from "./session.js";
import type { TransportCapabilitySummaryContract, TransportApprovalRequiredToolHintEntry, TransportToolEligibilitySummaryEntry, ToolExecutionStepContext, ToolInvokeApprovalDescriptor, AgentTurnConversation, AgentTurnExperience, AgentTurnRequestSpec, AgentTurnLocalContext, AgentTurnClientHints } from "./capability-transport.js";
export interface AgentTurnStartPayload extends AgentExecutionRefs {
    sessionId: string;
    turnId: string;
    deviceId?: string;
    principalId?: string;
    entitlementId?: string;
    subscriptionKey?: string;
    conversation: AgentTurnConversation;
    experience?: AgentTurnExperience;
    request?: AgentTurnRequestSpec;
    localContext?: AgentTurnLocalContext;
    clientHints?: AgentTurnClientHints;
}
export interface AgentTurnStartMsg extends AgentTurnStartPayload {
    type: "agent.turn.start";
    id: string;
}
export interface AgentTurnThinkingPayload extends AgentExecutionRefs {
    sessionId: string;
    turnId: string;
    stage?: "routing" | "execution" | "tool-wait";
    message?: string;
}
export interface AgentTurnThinkingMsg {
    type: "agent.turn.thinking";
    id: string;
    payload: AgentTurnThinkingPayload;
}
export interface AgentTurnDeltaPayload extends AgentExecutionRefs {
    sessionId: string;
    turnId: string;
    chunk: string;
}
export interface AgentTurnDeltaMsg {
    type: "agent.turn.delta";
    id: string;
    payload: AgentTurnDeltaPayload;
}
export interface AgentTurnToolPlannedPayload extends AgentExecutionRefs {
    sessionId: string;
    turnId: string;
    callId: string;
    toolName: string;
    arguments?: Record<string, unknown>;
    approvalMode?: "user-confirm" | "pre-authorized";
}
export interface AgentTurnToolPlannedMsg {
    type: "agent.turn.tool-planned";
    id: string;
    payload: AgentTurnToolPlannedPayload;
}
export interface AgentTurnToolRunningPayload extends AgentExecutionRefs {
    sessionId: string;
    turnId: string;
    callId: string;
    toolName: string;
}
export interface AgentTurnToolRunningMsg {
    type: "agent.turn.tool-running";
    id: string;
    payload: AgentTurnToolRunningPayload;
}
export interface AgentTurnCompletedPayload extends AgentExecutionRefs {
    sessionId: string;
    turnId: string;
    outcomeId: string;
    resolvedModel?: string;
    modelSelectionReason?: ModelSelectionReason;
    capabilitySummary?: TransportCapabilitySummaryContract;
    approvalRequiredToolHint?: TransportApprovalRequiredToolHintEntry[];
    eligibleToolSummary?: TransportToolEligibilitySummaryEntry[];
    ineligibleToolSummary?: TransportToolEligibilitySummaryEntry[];
    response?: TransportResponsePayload;
    usage?: TransportUsageInfo;
    billed?: TransportBillingInfo | null;
}
export interface AgentTurnCompletedMsg {
    type: "agent.turn.completed";
    id: string;
    payload: AgentTurnCompletedPayload;
}
export interface BillingRecordedPayload extends AgentExecutionRefs {
    sessionId: string;
    turnId: string;
    outcomeId: string;
    billed: TransportBillingInfo;
}
export interface BillingRecordedMsg {
    type: "billing.recorded";
    id: string;
    payload: BillingRecordedPayload;
}
export interface AgentTurnFailedPayload extends AgentExecutionRefs {
    sessionId: string;
    turnId: string;
    outcomeId: string;
    code: string;
    error: string;
    retryable: boolean;
}
export interface AgentTurnFailedMsg {
    type: "agent.turn.failed";
    id: string;
    payload: AgentTurnFailedPayload;
}
export interface ToolInvokePlannedPayload extends AgentExecutionRefs, ToolExecutionStepContext {
    sessionId: string;
    turnId: string;
    callId: string;
    toolName: string;
    arguments?: Record<string, unknown>;
    approvalMode?: "user-confirm" | "pre-authorized";
}
export interface ToolInvokePlannedMsg {
    type: "tool.invoke.planned";
    id: string;
    payload: ToolInvokePlannedPayload;
}
export interface ToolInvokeStartedPayload extends AgentExecutionRefs, ToolExecutionStepContext {
    sessionId: string;
    turnId: string;
    callId: string;
    toolName: string;
}
export interface ToolInvokeStartedMsg {
    type: "tool.invoke.started";
    id: string;
    payload: ToolInvokeStartedPayload;
}
export interface ToolInvokeRequestPayload extends AgentExecutionRefs, ToolExecutionStepContext {
    sessionId: string;
    turnId: string;
    callId: string;
    tool: {
        name: string;
        arguments: Record<string, unknown>;
    };
    approval?: ToolInvokeApprovalDescriptor;
}
export interface ToolInvokeRequestMsg {
    type: "tool.invoke.request";
    id: string;
    payload: ToolInvokeRequestPayload;
}
export interface ToolInvokeResultPayload extends AgentExecutionRefs, ToolExecutionStepContext {
    sessionId: string;
    turnId: string;
    callId: string;
    outcomeId: string;
    ok: boolean;
    payload?: unknown;
    error?: string;
}
export interface ToolInvokeResultMsg {
    type: "tool.invoke.result";
    id: string;
    payload: ToolInvokeResultPayload;
}
export type LocalExecutionEnvelopeKind = "started" | "partial" | "checkpoint" | "artifact" | "final" | "error";
export type LocalExecutionEnvelopeStage = "turn" | "tool" | "checkpoint" | "artifact" | "control" | "memory";
export interface LocalExecutionEnvelopePayload extends AgentExecutionRefs, ToolExecutionStepContext {
    sessionId: string;
    turnId?: string;
    kind: LocalExecutionEnvelopeKind;
    stage: LocalExecutionEnvelopeStage;
    eventType: string;
    emittedAtMs: number;
    callId?: string;
    approvalId?: string;
    checkpointId?: string;
    restoreId?: string;
    summary?: string;
    data?: Record<string, unknown>;
}
export interface LocalExecutionEnvelopeMsg {
    type: "local.execution.envelope";
    id: string;
    payload: LocalExecutionEnvelopePayload;
}
export interface AgentSkillCreatePayload {
    sessionId: string;
    turnId: string;
    executionId?: string;
    suggestedName: string;
    description: string;
    tools: string[];
    stepCount: number;
}
export interface AgentSkillCreateMsg {
    type: "agent.skill.create";
    id: string;
    payload: AgentSkillCreatePayload;
}
export interface AgentSkillImprovePayload {
    sessionId: string;
    turnId: string;
    executionId?: string;
    skillName: string;
    reason: string;
}
export interface AgentSkillImproveMsg {
    type: "agent.skill.improve";
    id: string;
    payload: AgentSkillImprovePayload;
}
