feat(agents): 完善恢复费用与云资源交互

This commit is contained in:
2026-09-10 22:29:24 +08:00
parent f8f39f39de
commit 303f26294e
24 changed files with 1170 additions and 127 deletions

View File

@@ -10,6 +10,7 @@ export interface CloudAgentDraft {
configuration: CloudAgentConfiguration;
published_version: number | null;
enabled: boolean;
archived?: boolean;
}
export interface CloudAgentPage {
@@ -73,7 +74,9 @@ 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;
@@ -90,7 +93,11 @@ export interface CloudMessage {
}
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;
}
@@ -98,6 +105,19 @@ 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<string, unknown>; created_at: string;
}
export interface CloudRecoveryState {
recent: CloudRecent | null;
pending: CloudPendingOperation[];
}
export interface CloudScheduleInput {
name: string; prompt: string; cron_expression: string; timezone: string; enabled: boolean;
}
@@ -107,13 +127,21 @@ export interface CloudSchedule extends CloudScheduleInput {
}
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; run_id: string; request_id: 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';
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 }
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 }
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<string, string> | 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, Output> = { input: Input; output: Output };
type Agent = { slug: string };
type Application = { application_id: string };
@@ -122,6 +150,24 @@ type Thread = { thread_id: string };
type Run = { run_id: string };
type Operation = { operation_id: string };
export interface CloudAgentOperations {
applicationCalls: Op<Application & { offset?: number }, { items: { request_id: string; request_status: string; run_id: string | null; run_status: string | null; version: string | null; created_at: string }[]; next_offset: number | null }>;
resources: Op<Record<string, never>, CloudPersonalResources>;
createMcp: Op<CloudMcpInput & Operation, CloudMcp>;
updateMcp: Op<CloudMcpInput & { key: string }, CloudMcp>;
enableMcp: Op<{ key: string; enabled: boolean }, CloudMcp>;
deleteMcp: Op<{ key: string }, { deleted: boolean }>;
createChild: Op<Omit<CloudChild, 'slug'> & Operation, CloudChild>;
updateChild: Op<Omit<CloudChild, 'slug'> & { key: string }, CloudChild>;
confirmSkill: Op<{ draft_id: string }, { items: { slug: string; success: boolean; error?: string }[] }>;
deleteSkill: Op<{ key: string }, { deleted: boolean }>;
deleteKnowledge: Op<Agent & { kb_id: string }, { deleted: boolean }>;
deleteKnowledgeFile: Op<Agent & { kb_id: string; file_id: string }, { deleted: boolean }>;
importKnowledgeAttachment: Op<Agent & Operation & { kb_id: string; thread_id: string; attachment_id: string }, CloudKnowledgeFile>;
archiveAgent: Op<Agent & { archived: boolean }, CloudAgentDraft>;
archiveThread: Op<Thread & { archived: boolean }, { thread_id: string; archived: boolean }>;
version: Op<Agent & { version: string }, CloudVersion>;
restoreVersion: Op<Agent & { version: string; expected_revision: number }, CloudAgentDraft>;
scheduleContext: Op<Agent, CloudScheduleContext>;
knowledge: Op<Agent, { databases: CloudKnowledge[]; models: { id: string; name: string; dimension: number }[] }>;
createKnowledge: Op<Agent & Operation & { name: string; embedding_model: string }, CloudKnowledge>;
knowledgeFiles: Op<Agent & { kb_id: string; offset?: number }, { files: CloudKnowledgeFile[]; next_offset: number | null }>;
@@ -139,8 +185,10 @@ export interface CloudAgentOperations {
keys: Op<Application, { keys: CloudKey[] }>;
createKey: Op<Application & Operation, { id: string; prefix: string; secret: string }>;
revokeKey: Op<Application & { key_id: string }, { revoked: boolean }>;
costs: Op<{ slug?: string }, { unit: string; items: CloudCost[] }>;
threads: Op<{ slug?: string; offset?: number }, { threads: CloudThread[]; next_offset: number | null }>;
costs: Op<{ slug?: string; offset?: number; started_at?: string; ended_at?: string; source?: CloudCostSource; application_id?: string }, CloudCostPage>;
budget: Op<Agent, CloudBudget>;
saveBudget: Op<Agent & { request_limit_points: string | null; daily_limit_points: string | null }, CloudBudget>;
threads: Op<{ slug?: string; offset?: number; archived?: boolean }, { threads: CloudThread[]; next_offset: number | null }>;
createThread: Op<Agent & Thread & { preview: boolean; expected_revision?: number }, { thread_id: string; client_thread_id: string }>;
history: Op<Thread & { offset?: number }, CloudHistory>;
viewed: Op<Thread & Run, { viewed: boolean }>;