export const CLOUD_AGENTS_PATH = '/api/cloud-agents'; export interface CloudAgentDraft { slug: string; name: string; purpose: string; system_prompt: string; draft_revision: number; updated_at: string; configuration: CloudAgentConfiguration; published_version: number | null; enabled: boolean; archived?: boolean; } export interface CloudAgentPage { agents: CloudAgentDraft[]; next_cursor: string | null; } export interface CreateCloudAgent { operation_id: string; name: string; purpose: string; } export interface SaveCloudAgentDraft { expected_revision: number; name: string; purpose: string; system_prompt: string; configuration?: CloudAgentConfiguration; } export interface CloudAgentConfiguration { model: string; tools: string[]; knowledges: string[]; mcps: string[]; skills: string[]; preload_skills: string[]; subagents: string[]; tool_approval_mode: 'default' | 'always_trust'; max_execution_steps: number; max_output_tokens: number; max_run_seconds: number; } export const EMPTY_CLOUD_CONFIGURATION: CloudAgentConfiguration = { model: '', tools: [], knowledges: [], mcps: [], skills: [], preload_skills: [], subagents: [], tool_approval_mode: 'default', max_execution_steps: 300, max_output_tokens: 4096, max_run_seconds: 600, }; export interface CloudAgentEntry { slug: string; name: string; purpose: string; published_version: number; is_creator?: boolean; payer?: string; } export interface CloudResource { key: string; name: string; description?: string } export interface CloudCatalog { models: { id: string; name: string }[]; resources: Partial>; pricing: { unit: string; usage_unit: string; unit_size: number; points_per_unit: string; version: number }; } export interface CloudApplication { id: string; name: string; enabled: boolean } export interface CloudKey { id: string; prefix: string; revoked_at: string | null } export interface CloudAccess { published_version: number | null; enabled: boolean; share_url: string; versions: { version: number; draft_revision: number; created_at: string }[]; grants: { account_id: string; enabled: boolean }[]; applications: CloudApplication[]; api_url: string; } export interface CloudThread { thread_id: string; client_thread_id: string | null; agent_slug: string; title: string; mode: 'published' | 'preview'; updated_at: string; run_id: string | null; status: string; unread: boolean; draft_revision?: number; archived?: boolean; } export interface CloudVersion { version: number; created_at: string; name: string; purpose: string; system_prompt: string; configuration: CloudAgentConfiguration } export interface CloudRun { agent_run_id: string; request_id: string; thread_id: string; agent_slug: string; status: string; output: string; version: string; error?: { type: string; message: string }; interrupt?: CloudInterrupt; } export interface CloudInterrupt { status?: string; message?: string; run_id?: string; questions?: unknown[]; approval?: Record; interrupt_info?: unknown; } export interface CloudMessage { id: number; role: 'user' | 'assistant' | 'system'; content: string; request_id: string; run_id: string | null; created_at: string; } export interface CloudHistory { thread_id: string; messages: CloudMessage[]; run: CloudRun | null; next_offset: number | null; queued_requests?: CloudRequest[]; schedule_proposals?: CloudScheduleProposal[]; } export interface CloudScheduleProposal { id: string; name: string; prompt: string; cron_expression: string; timezone: string } export interface CloudScheduleContext { version: number | null; enabled: boolean; configuration: CloudAgentConfiguration | null; result_destination: string; payer: string } export interface CloudRequest { request_id: string; thread_id: string; run_id: string | null; status: string; version: string; } export interface CloudPrompt { request_id: string; thread_id: string; query: string; expected_revision?: number; attachment_file_ids?: string[]; } export interface CloudRecent { slug: string; thread_id?: string; mode: 'published' | 'preview'; draft_revision?: number; } export interface CloudPendingOperation { id: string; operation: string; input: Record; created_at: string; } export interface CloudRecoveryState { recent: CloudRecent | null; pending: CloudPendingOperation[]; } export interface CloudScheduleResultNotification { enabled: true; channel_account_id: string; caller_id: string; } export type CloudScheduleResultNotificationTarget = CloudScheduleResultNotification | null; export interface CloudScheduleInput { name: string; prompt: string; cron_expression: string; timezone: string; enabled: boolean; result_notification?: CloudScheduleResultNotificationTarget; } export interface CloudSchedule extends CloudScheduleInput { id: string; agent_slug: string; next_run_at: string | null; result_notification?: CloudScheduleResultNotificationTarget; runs?: { status: string; thread_id: string; error_message?: string; conversation_available: boolean; result_notification?: { enabled: boolean; state: string; error_message?: string | null; channel_account_id?: string; caller_id?: string; } | null; }[]; } export interface CloudCost { id: string; status: string; reserved_points: string; actual_points: string | null; created_at: string; context: { agent_slug: string; version: string; caller_kind: string; caller_id: string; creator_id?: string; run_id: string; request_id: string; source?: CloudCostSource | null }; } export type CloudCostSource = 'self' | 'shared' | 'api' | 'scheduled' | 'preview' | 'knowledge' | 'channel'; export interface CloudCostPage { unit: string; items: CloudCost[]; next_offset: number | null; summary: { count: number; settled_points: string; pending_points: string } } export interface CloudBudget { agent_slug: string; unit: string; timezone: string; request_limit_points: string | null; daily_limit_points: string | null; daily_committed_points: string; resets_at: string } export interface CloudAttachment { file_id: string; file_name: string; file_size: number; path: string; original_path: string; request_id?: string | null } export interface CloudUpload { object_name: string; file_name: string; file_type: string; parse_supported: boolean; parse_methods: string[] } export interface CloudFile { name: string; path: string; directory_path: string; is_dir: boolean; size: number } /** Safe, credential-free projections returned by the personal channel bridge. */ export interface CloudChannelView { id: string; address: string; display_name: string; target_agent_address: string; route_revision: number; provider_generation: string; binding_id: string; enabled: boolean; status: string; worker_online: boolean; agent_slug?: string; published_version?: number | null; desired_state?: string; sync_state?: string; health?: string; last_confirmed_at?: string | null; revision?: number; blockers?: string[]; adoption_state?: 'available' | 'managed_elsewhere' | 'managed_external' | string; managed_agent_slug?: string | null; target_agent_slug?: string | null; target_agent_name?: string | null; target_agent_published_version?: number | null; } export type CloudChannelAccountView = Partial & { id: string; display_name?: string; target_agent_address?: string | null; adoption_state?: 'available' | 'managed_elsewhere' | 'managed_external' | string; managed_agent_slug?: string | null; }; export interface CloudChannelBindingPage { items: CloudChannelView[]; available_accounts?: CloudChannelAccountView[]; } export interface CloudChannelConnectionPage { items: CloudChannelView[] } export interface CloudUserChannelAccount { id: string; display_name: string; binding_id: string | null; revision: number; enabled: boolean; status: string; health: string; blockers: string[]; target_agent_slug: string | null; target_agent_name: string | null; target_agent_published_version: number | null; provider_generation?: string; desired_state?: string; last_confirmed_at?: string | null; } export interface CloudChannelAccountPage { items: CloudUserChannelAccount[] } export interface CloudChannelAccountMutation { channel: CloudUserChannelAccount; target_agent?: string | null; wechat?: Record; disconnected?: boolean } export interface CloudChannelOperation { operation_id: string; status: 'pending' | 'completed' | 'failed' | 'unknown' | string; steps?: { name?: string; step?: string; operation_id?: string; status: string; error_code?: string | null }[]; result?: Record | null; error_code?: string | null; } export interface CloudChannelSession { session_id: string; caller_id: string; agent_slug: string; agent_name?: string; binding_id: string; provider_generation: string; channel_account_id: string; core_conversation_id: string | null; access_mode: 'self_only' | 'invited' | string; grant_state: string; session_state: string; sequence?: number; content_uid?: string | null; thread_id: string | null; created_at: string; closed_at?: string | null; } export interface CloudChannelConversation extends CloudChannelSession { messages: CloudMessage[]; run: CloudRun | null; queued_requests: CloudRequest[]; next_offset: number | null; } export interface CloudChannelConversationPage { items: CloudChannelSession[]; next_offset: number | null; } export interface CloudChannelFilesPage { session_id: string; thread_id: string | null; files: CloudFile[]; } export interface CloudChannelCaller { caller_id: string; binding_id: string; provider_generation: string; channel_account_id: string; agent_slug: string; core_conversation_id: string | null; access_mode: 'self_only' | 'invited' | string; grant_state: string; paired_ws_account_id: string | null; session_id: string | null; content_uid: string | null; thread_id: string | null; session_state: string; created_at: string; revoked_at: string | null; } export interface CloudChannelCallerPage { items: CloudChannelCaller[] } export interface CloudChannelActivity { run_id?: string | null; request_id?: string | null; session_id?: string | null; status: string; created_at?: string; started_at?: string | null; finished_at?: string | null; token_usage?: Record | null; output_available?: boolean; timing?: Record; delivery?: { state?: string; logical_message_id?: string | null; message_id?: string | null; ack?: Record; progress?: Record; result?: Record; parts?: { part_id?: string; kind?: string; status?: string }[]; core?: { state?: string; core_status?: string; adapter_status?: string; provider_status?: string; delivery_status?: string; parts?: { part_id?: string; type?: string; core_status?: string; adapter_status?: string; provider_status?: string; error_category?: string }[] }; }; input_preparation?: { state?: string; error_type?: string | null }; } export interface CloudChannelActivityPage { items: CloudChannelActivity[]; next_offset: number | null } export interface CloudWechatBindState { session_key: string; status: string; message?: string; qrcode_url?: string; } export interface CloudChannelDeliveryPart { part_id: string; part_index?: number; type?: string; status: string; attempts?: number; sent_at?: string | null; } export interface CloudChannelDelivery { logical_message_id?: string; message_id?: string; status: string; parts: CloudChannelDeliveryPart[]; } export interface CloudChannelWorker { account_id: string; address: string } export interface CloudChannelMutation { channel: CloudChannelView; target_agent?: string | CloudChannelView; worker?: CloudChannelWorker; wechat?: Record; disconnected?: boolean } export interface CloudChannelControl { operation_id: string; status: string; session_id: string; action: 'resume' | 'stop' | 'new-session'; previous_session_id?: string; run_id?: string; request_id?: string; intake_ids?: string[]; session?: CloudChannelSession; } export interface CloudChannelAccountStatus { status: string; message?: string } export interface CloudKnowledge { kb_id: string; name: string; description: string; embedding_model: string } export interface CloudKnowledgeFile { file_id: string; name: string; size: number; status: string; error: string | null; chunk_count: number; available: boolean; replaces_file_id?: string | null; processing_task?: { task_id: string; status: string; error: string | null; created_at?: string | null; started_at?: string | null; completed_at?: string | null; } | null; } export interface CloudMcp { slug: string; name: string; description: string; transport: 'sse' | 'streamable_http'; url: string; enabled: boolean; has_credentials: boolean } export interface CloudMcpInput { name: string; description: string; transport: 'sse' | 'streamable_http'; url: string; headers?: Record | null } export interface CloudChild { slug: string; name: string; purpose: string; system_prompt: string } export interface CloudSkillDraft { draft_id: string; items: { slug: string; name: string; description: string; success?: boolean; error?: string }[] } export interface CloudPersonalResources { mcps: CloudMcp[]; skills: { slug: string; name: string; description: string }[]; subagents: CloudChild[] } type Op = { input: Input; output: Output }; type Agent = { slug: string }; type Application = { application_id: string }; type Schedule = Agent & { job_id: string }; type Thread = { thread_id: string }; type Run = { run_id: string }; type Operation = { operation_id: string }; export interface CloudAgentOperations { applicationCalls: Op; resources: Op, CloudPersonalResources>; createMcp: Op; updateMcp: Op; enableMcp: Op<{ key: string; enabled: boolean }, CloudMcp>; deleteMcp: Op<{ key: string }, { deleted: boolean }>; createChild: Op & Operation, CloudChild>; updateChild: Op & { key: string }, CloudChild>; confirmSkill: Op<{ draft_id: string }, { items: { slug: string; success: boolean; error?: string }[] }>; deleteSkill: Op<{ key: string }, { deleted: boolean }>; deleteKnowledge: Op; deleteKnowledgeFile: Op; importKnowledgeAttachment: Op; archiveAgent: Op; archiveThread: Op; version: Op; restoreVersion: Op; scheduleContext: Op; knowledge: Op; createKnowledge: Op; knowledgeFiles: Op; processKnowledge: Op; catalog: Op, CloudCatalog>; received: Op, { agents: CloudAgentEntry[] }>; entry: Op; publish: Op; access: Op; setEnabled: Op; users: Op<{ query: string }, { users: { account_id: string; username: string; display_name: string }[] }>; share: Op; createApplication: Op; setApplicationEnabled: Op; keys: Op; createKey: Op; revokeKey: Op; costs: Op<{ slug?: string; offset?: number; started_at?: string; ended_at?: string; source?: CloudCostSource; application_id?: string }, CloudCostPage>; budget: Op; saveBudget: Op; threads: Op<{ slug?: string; offset?: number; archived?: boolean }, { threads: CloudThread[]; next_offset: number | null }>; createThread: Op; history: Op; viewed: Op; submit: Op; preview: Op; request: Op<{ request_id: string }, CloudRequest>; cancelRequest: Op<{ request_id: string }, { status: string }>; run: Op; cancelRun: Op; resume: Op }, { run_id: string; status: string }>; schedules: Op; createSchedule: Op; updateSchedule: Op; deleteSchedule: Op; runSchedule: Op; attachments: Op; parseAttachment: Op<{ object_name: string; parse_method: string }, { parsed_object_name: string }>; confirmAttachment: Op; deleteAttachment: Op; files: Op; channelConnections: Op, CloudChannelConnectionPage>; channelAccounts: Op, CloudChannelAccountPage>; createChannelAccount: Op; routeChannelAccount: Op<{ channel_account_id: string; operation_id: string; target_agent_slug: string | null; expected_revision: number; enabled: boolean }, CloudChannelAccountMutation>; enableChannelAccount: Op<{ channel_account_id: string; operation_id: string; expected_revision: number }, CloudChannelAccountMutation>; pauseChannelAccount: Op<{ channel_account_id: string; operation_id: string; expected_revision: number }, CloudChannelAccountMutation>; disconnectChannelAccount: Op<{ channel_account_id: string; operation_id: string; expected_revision: number }, CloudChannelAccountMutation>; channelAccountWechatBindStart: Op<{ channel_account_id: string; operation_id: string; force: boolean }, CloudWechatBindState>; channelAccountWechatBindStatus: Op<{ channel_account_id: string; session_key: string }, CloudWechatBindState>; channelAccountWechatBindVerification: Op<{ channel_account_id: string; operation_id: string; session_key: string; verify_code: string }, CloudWechatBindState>; channelAccountWechatBindAccount: Op<{ channel_account_id: string }, CloudChannelAccountStatus>; channelAccountWechatUnbind: Op<{ channel_account_id: string; operation_id: string }, CloudChannelAccountStatus>; channelAccountOperation: Op<{ operation_id: string }, CloudChannelOperation>; channelBindings: Op; createChannelBinding: Op; switchChannelBindingAgent: Op; enableChannelBinding: Op; pauseChannelBinding: Op; disconnectChannelBinding: Op; wechatBindStart: Op; wechatBindStatus: Op; wechatBindVerification: Op; wechatBindAccount: Op; wechatUnbind: Op; channelSelfCallers: Op; channelActivity: Op; channelConversations: Op; channelConversation: Op<{ session_id: string; offset?: number }, CloudChannelConversation>; channelFiles: Op<{ session_id: string; path?: string }, CloudChannelFilesPage>; channelConversationControl: Op<{ session_id: string; operation_id: string; action: 'resume' | 'stop' | 'new-session'; run_id?: string; decision?: Record }, CloudChannelControl>; channelDelivery: Op; retryChannelDeliveryPart: Op; channelOperation: Op; }