feat(agents): 支持个人微信发布与渠道会话
Some checks failed
Electron E2E / Electron E2E (macos-latest) (push) Has been cancelled
Electron E2E / Electron E2E (ubuntu-latest) (push) Has been cancelled
Electron E2E / Electron E2E (windows-latest) (push) Has been cancelled

This commit is contained in:
2026-09-13 16:22:36 +08:00
parent 03774d0625
commit 2e710db0fb
28 changed files with 2678 additions and 31 deletions

View File

@@ -118,23 +118,205 @@ 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;
runs?: { status: string; thread_id: string; error_message?: string; conversation_available: boolean }[];
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';
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[];
access_mode?: string;
policy_revision?: number;
adoption_state?: 'available' | 'managed_elsewhere' | 'managed_external' | string;
managed_agent_slug?: string | null;
}
export type CloudChannelAccountView = Partial<CloudChannelView> & {
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 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<string, unknown> | 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<string, unknown> | null;
output_available?: boolean;
timing?: Record<string, string | null>;
delivery?: {
state?: string; logical_message_id?: string | null; message_id?: string | null;
ack?: Record<string, unknown>; progress?: Record<string, unknown>; result?: Record<string, unknown>;
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 CloudChannelPairing {
invitation_id?: string;
binding_id: string;
provider_generation: string;
agent_slug?: string;
kind: 'self' | 'invite' | string;
expires_at?: string;
consumed: boolean;
code?: string;
}
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<string, unknown>; disconnected?: boolean }
export interface CloudChannelPolicy {
binding_id: string;
channel_account_id: string;
access_mode: 'self_only' | 'invited' | string;
policy_revision: number;
revoked_caller_ids: string[];
revoked_invitation_ids: string[];
}
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 }
export interface CloudMcp { slug: string; name: string; description: string; transport: 'sse' | 'streamable_http'; url: string; enabled: boolean; has_credentials: boolean }
@@ -209,4 +391,29 @@ export interface CloudAgentOperations {
confirmAttachment: Op<Thread & { attachments: { object_name: string; file_type?: string; parsed_object_name?: string }[] }, { attachments: CloudAttachment[] }>;
deleteAttachment: Op<Thread & { file_id: string }, { message: string }>;
files: Op<Thread & { path: string }, { files: CloudFile[] }>;
channelConnections: Op<Record<string, never>, CloudChannelConnectionPage>;
channelBindings: Op<Agent, CloudChannelBindingPage>;
createChannelBinding: Op<Agent & Operation & { display_name: string; channel_account_id?: string }, CloudChannelMutation>;
switchChannelBindingAgent: Op<Agent & { channel_account_id: string; operation_id: string; target_agent_slug: string; expected_revision: number; enabled: boolean }, CloudChannelMutation>;
enableChannelBinding: Op<Agent & { channel_account_id: string; operation_id: string; expected_revision: number }, CloudChannelMutation>;
pauseChannelBinding: Op<Agent & { channel_account_id: string; operation_id: string; expected_revision: number }, CloudChannelMutation>;
disconnectChannelBinding: Op<Agent & { channel_account_id: string; operation_id: string; expected_revision: number }, CloudChannelMutation>;
channelPolicy: Op<Agent & { channel_account_id: string; operation_id: string; access_mode: 'self_only' | 'invited'; expected_policy_revision: number }, CloudChannelPolicy>;
createChannelPairing: Op<Agent & { channel_account_id: string; operation_id: string; kind: 'self' | 'invite' }, CloudChannelPairing>;
wechatBindStart: Op<Agent & { channel_account_id: string; operation_id: string; force: boolean }, CloudWechatBindState>;
wechatBindStatus: Op<Agent & { channel_account_id: string; session_key: string }, CloudWechatBindState>;
wechatBindVerification: Op<Agent & { channel_account_id: string; operation_id: string; session_key: string; verify_code: string }, CloudWechatBindState>;
wechatBindAccount: Op<Agent & { channel_account_id: string }, CloudChannelAccountStatus>;
wechatUnbind: Op<Agent & { channel_account_id: string; operation_id: string }, CloudChannelAccountStatus>;
channelSelfCallers: Op<Agent, CloudChannelCallerPage>;
channelCallers: Op<Agent & { channel_account_id: string }, CloudChannelCallerPage>;
revokeChannelCaller: Op<Agent & { channel_account_id: string; caller_id: string; operation_id: string }, { status: string; caller_id: string }>;
channelActivity: Op<Agent & { channel_account_id: string; offset?: number; limit?: number }, CloudChannelActivityPage>;
channelConversations: Op<Agent & { offset?: number }, CloudChannelConversationPage>;
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<string, unknown> }, CloudChannelControl>;
channelDelivery: Op<Agent & { channel_account_id: string; logical_message_id: string }, CloudChannelDelivery>;
retryChannelDeliveryPart: Op<Agent & { channel_account_id: string; logical_message_id: string; part_id: string }, CloudChannelDelivery>;
channelOperation: Op<Agent & { operation_id: string }, CloudChannelOperation>;
}