import { AgentCard, Artifact, Message, Part, Task, TaskState } from "@inkeep/agents-core";

//#region src/domains/run/a2a/types.d.ts
interface RegisteredAgent {
  subAgentId: string;
  tenantId: string;
  projectId: string;
  agentId: string;
  agentCard: AgentCard;
  taskHandler: (task: A2ATask) => Promise<A2ATaskResult>;
}
interface A2ATask {
  id: string;
  input: {
    parts: Part[];
  };
  context?: {
    conversationId?: string;
    userId?: string;
    metadata?: Record<string, any>;
  };
}
type A2ATaskErrorType = 'connection_refused' | 'unknown';
interface A2ATaskResult {
  status: {
    state: TaskState;
    message?: string;
    type?: A2ATaskErrorType;
  };
  artifacts?: Artifact[];
}
/**
 * Transfer data structure - what the transfer tool returns
 * This gets wrapped into a DataPart by the AI SDK
 */
interface TransferData {
  type: 'transfer';
  targetSubAgentId: string;
  fromSubAgentId?: string;
}
/**
 * Full transfer response following A2A protocol
 * The TransferData is wrapped in artifacts[0].parts[0].data
 */
interface TransferTask extends Task {
  artifacts: Artifact[];
}
/**
 * Type guard to check if a Task contains transfer data
 */
declare function isTransferTask(result: Task | Message): result is TransferTask;
/**
 * Helper to safely extract transfer data from a TransferTask
 * Returns null if no transfer data found
 */
declare function extractTransferData(task: TransferTask): TransferData | null;
interface JsonRpcRequest {
  jsonrpc: '2.0';
  method: string;
  params?: any;
  id?: string | number | null;
}
interface JsonRpcResponse {
  jsonrpc: '2.0';
  result?: any;
  error?: {
    code: number;
    message: string;
    data?: any;
  };
  id?: string | number | null;
}
type A2AMethod = 'agent.invoke' | 'agent.getCapabilities' | 'agent.getStatus';
//#endregion
export { A2AMethod, A2ATask, A2ATaskErrorType, A2ATaskResult, type AgentCard, JsonRpcRequest, JsonRpcResponse, RegisteredAgent, TransferData, TransferTask, extractTransferData, isTransferTask };