mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2026-01-01 01:30:51 +08:00
- 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.
32 lines
1.0 KiB
TypeScript
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>
|
|
}
|