| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124 |
- // 全局事件模型
- export interface GlobalEvent {
- directory?: string;
- payload: EventPayload;
- }
-
- // 事件负载
- export interface EventPayload {
- type: string;
- properties?: Record<string, any>;
- }
-
- // 会话更新事件
- export interface SessionUpdatedEvent {
- type: 'session.updated';
- properties: {
- info: SessionInfo;
- };
- }
-
- // 会话信息
- export interface SessionInfo {
- id: string;
- slug: string;
- version: string;
- projectID: string;
- directory: string;
- title: string;
- time: {
- created: number;
- updated: number;
- };
- summary?: {
- additions: number;
- deletions: number;
- files: number;
- };
- // 扩展字段(用于项目功能)
- project_id?: string;
- agent_name?: string;
- description?: string;
- status?: string;
- user_id?: string;
- tenant_id?: string;
- created_at?: string;
- updated_at?: string;
- }
-
- // 会话差异事件
- export interface SessionDiffEvent {
- type: 'session.diff';
- properties: {
- sessionID: string;
- diff: any[];
- };
- }
-
- // 服务器心跳事件
- export interface ServerHeartbeatEvent {
- type: 'server.heartbeat';
- properties: Record<string, never>;
- }
-
- // 消息更新事件
- export interface MessageUpdatedEvent {
- type: 'message.updated';
- properties: {
- info: MessageInfo;
- };
- }
-
- // 消息部分更新事件
- export interface MessagePartUpdatedEvent {
- type: 'message.part.updated';
- properties: {
- part: MessagePart;
- delta?: string;
- };
- }
-
- // 消息信息
- export interface MessageInfo {
- id: string;
- role: string;
- content?: string;
- parts?: MessagePart[];
- }
-
- // 消息部分
- export interface MessagePart {
- type: 'text' | 'reasoning' | string;
- text?: string;
- }
-
- // 会话状态事件
- export interface SessionStatusEvent {
- type: 'session.status';
- properties: {
- status: {
- type: string;
- [key: string]: any;
- };
- };
- }
-
- // 服务器连接事件
- export interface ServerConnectedEvent {
- type: 'server.connected';
- properties: Record<string, any>;
- }
-
- // 事件类型映射
- export type EventType =
- | 'session.updated'
- | 'session.diff'
- | 'server.heartbeat'
- | 'message.updated'
- | 'message.part.updated'
- | 'session.status'
- | 'server.connected'
- | string;
-
- // 事件处理器类型
- export type EventHandler<T = any> = (event: T) => void;
|