cherry-studio/src/main/services/agents/interfaces/AgentStreamInterface.ts
fullex 2c102ed3b4 refactor: update imports to use 'type' for type-only imports across multiple files
- Changed imports to use 'type' for type-only imports in various files, improving clarity and potentially optimizing the build process.
- Adjusted imports in files related to agents, models, and types to ensure consistency in type usage.
2025-10-09 12:45:17 +08:00

32 lines
1.0 KiB
TypeScript

// Agent-agnostic streaming interface
// This interface should be implemented by all agent services
import type { EventEmitter } from 'node:events'
import type { GetAgentSessionResponse } from '@types'
import type { TextStreamPart } from 'ai'
// Generic agent stream event that works with any agent type
export interface AgentStreamEvent {
type: 'chunk' | 'error' | 'complete' | 'cancelled'
chunk?: TextStreamPart<any> // Standard AI SDK chunk for UI consumption
error?: Error
}
// Agent stream interface that all agents should implement
export interface AgentStream extends EventEmitter {
emit(event: 'data', data: AgentStreamEvent): boolean
on(event: 'data', listener: (data: AgentStreamEvent) => void): this
once(event: 'data', listener: (data: AgentStreamEvent) => void): this
}
// Base agent service interface
export interface AgentServiceInterface {
invoke(
prompt: string,
session: GetAgentSessionResponse,
abortController: AbortController,
lastAgentSessionId?: string
): Promise<AgentStream>
}