import type {
  ItemId,
  PhaseResultPhaseName,
  ProviderTurnActionPolicy,
  SessionUsageOperation,
  Turn,
} from "@best-agent/protocol";
import type {
  ConversationMessage,
  ProviderCacheControl,
  ProviderDecisionOutput,
  ProviderToolOption,
} from "../../provider/provider-core.js";
import type { PromptDeliverableFailure } from "../../prompt/runtime-prompts.js";
import type { ProviderTurnInvokeContext } from "./provider-turn-budget.js";
import type { RequiredToolConstraint } from "./tool-constraint-types.js";

export type ProviderDecisionResolutionControls = {
  allowPhaseResult: boolean;
  allowPlanUpdate: boolean;
  phaseResultPhaseName?: PhaseResultPhaseName;
};

export type ProviderDecisionResolutionInput = {
  actionPolicyOverride?: ProviderTurnActionPolicy;
  approvalTurn?: Turn;
  availableTools: ProviderToolOption[];
  cacheControl?: ProviderCacheControl;
  controls: ProviderDecisionResolutionControls;
  decision: ProviderDecisionOutput;
  invokeContext: ProviderTurnInvokeContext;
  messages: ConversationMessage[];
  objective?: string;
  operation: SessionUsageOperation;
  repairAttempt: number;
  requiredToolConstraint?: RequiredToolConstraint;
  responseRepairDeliverableFailures?: PromptDeliverableFailure[];
  resolvePreviewToolCallId?: (providerToolCallId?: string) => ItemId | undefined;
  systemPrompt?: string;
  toolStepCount: number;
  turn: Turn;
  visibleTools: ProviderToolOption[];
};
