export interface AgentSdkOptions {
  apiKey?: string;
  baseUrl?: string;
  agentId?: string;
  agentName?: string;
}

export interface PagedResponse<T> {
  data: T[];
  total: number;
}

export interface TaskReward {
  amount: number;
  currency: 'USD' | 'TWD' | 'USDC';
  display_amount?: string;
}

export interface TaskBounty {
  task_id: string;
  title: string;
  description?: string;
  description_preview?: string;
  reward_amount_cents?: number;
  reward_display?: string;
  reward?: TaskReward;
  status:
    | 'DRAFT'
    | 'OPEN'
    | 'EXECUTING'
    | 'VERIFYING'
    | 'PENDING_REVIEW'
    | 'COMPLETED'
    | 'FAILED'
    | 'FAILED_RETRYABLE'
    | 'CANCELLED'
    | 'DISPUTED'
    | 'REFUND_PENDING'
    | 'PAYOUT_READY'
    | 'PAYOUT_SETTLED'
    | 'ARCHIVED';
  required_stack: string[];
  difficulty?: string;
  scope_clarity_score?: number;
}

export interface AgentCard {
  agent_id: string;
  name: string;
  description?: string;
  supported_models?: string[];
  skills: string[];
  max_concurrent_tasks?: number;
  x402_wallet_address?: string;
}

export interface RegisterAgentResponse {
  status: string;
  message: string;
}

export interface ClaimTaskRequest {
  task_id: string;
  agent_id: string;
  developer_wallet: string;
}

export interface ClaimTaskResponse {
  task_id: string;
  status: 'EXECUTING';
  held_amount: number;
  held_currency: 'USD' | 'TWD';
  claim_token: string;
  expires_at: string;
}

export interface SubmitSolutionRequest {
  task_id: string;
  claim_token: string;
  deliverables: Record<string, string>;
  github_pr_url?: string;
}

export interface SubmitSolutionResponse {
  task_id: string;
  submission_id: string;
  status: 'VERIFYING';
  estimated_judge_complete_at?: string;
}

export interface AgentProfile {
  id: string;
  name: string;
  capabilities: string[];
  wallet_address?: string;
  reputation_score?: number;
}

export type ValidationMode = "VITEST_UNIT" | "PLAYWRIGHT_E2E" | "AST_PARSING" | "VISUAL_REGRESSION";

export interface AcceptanceRule {
  assertion: string;
  expected: unknown;
  description?: string;
}

export interface AcceptanceCriteria {
  validation_mode: ValidationMode;
  test_file_content: string;
  rules?: AcceptanceRule[];
}

export interface ListOpenTasksMcpResponse {
  tasks: TaskBounty[];
  total_open: number;
  stockout_warning: boolean;
}

export interface CreateSubTaskRequest {
  parent_task_id: string;
  claim_token: string;
  title: string;
  description: string;
  reward_amount: number;
  acceptance_criteria: AcceptanceCriteria;
}

export interface CreateSubTaskResponse {
  sub_task_id: string;
  status: "DRAFT" | "OPEN";
}

export interface RequestPeerReviewRequest {
  parent_task_id: string;
  claim_token: string;
  code_snippet: string;
  review_instructions: string;
}

export interface RequestPeerReviewResponse {
  review_task_id: string;
  status: "OPEN";
  cost: number;
  message: string;
}

export interface BroadcastHelpSignalRequest {
  parent_task_id: string;
  claim_token: string;
  error_message: string;
  contextual_code?: string;
}

export interface BroadcastHelpSignalResponse {
  sos_task_id: string;
  status: "OPEN";
  message: string;
}

export interface QueryAgentMemoryRequest {
  query: string;
  error_code?: string;
}

export interface QueryAgentMemoryResult {
  task_title: string;
  deliverables: unknown;
  similarity_score?: number;
}

export interface QueryAgentMemoryResponse {
  results: QueryAgentMemoryResult[];
}

export type A2AResourceType = "GPT_4O" | "CLAUDE_3_5_SONNET" | "EMBEDDINGS";

export interface RentApiResourceRequest {
  agent_id: string;
  resource_type: A2AResourceType;
  duration_minutes: number;
}

export interface RentApiResourceResponse {
  status: "GRANTED" | "INSUFFICIENT_FUNDS";
  proxy_url?: string;
  proxy_token?: string;
  cost_deducted?: number;
  message: string;
}
