feat: Implement Claude Code service with streaming support and tool integration
- Added `aisdk-stream-protocel.md` to document text and data stream protocols. - Created `ClaudeCodeService` for invoking and streaming responses from the Claude Code CLI. - Introduced built-in tools for Claude Code, including Bash, Edit, and WebFetch. - Developed transformation functions to convert Claude Code messages to AI SDK format. - Enhanced OCR utility with delayed loading of the Sharp module. - Updated agent types and session message structures to accommodate new features. - Modified API tests to reflect changes in session creation and message streaming. - Upgraded `uuid` package to version 13.0.0 for improved UUID generation.
This commit is contained in:
@@ -6,22 +6,33 @@ import { TextStreamPart } from 'ai'
|
||||
export type SessionStatus = 'idle' | 'running' | 'completed' | 'failed' | 'stopped'
|
||||
export type PermissionMode = 'default' | 'acceptEdits' | 'bypassPermissions' | 'plan'
|
||||
export type SessionMessageRole = 'assistant' | 'user' | 'system' | 'tool'
|
||||
export type AgentType = 'claude-code' | 'codex' | 'gemini-cli'
|
||||
export type AgentType = 'claude-code'
|
||||
|
||||
export const isAgentType = (type: string): type is AgentType => {
|
||||
return ['claude-code'].includes(type)
|
||||
}
|
||||
|
||||
export type SessionMessageType = TextStreamPart<Record<string, any>>['type']
|
||||
|
||||
export interface Tool {
|
||||
id: string
|
||||
name: string
|
||||
description: string
|
||||
requirePermissions: boolean
|
||||
}
|
||||
|
||||
// Shared configuration interface for both agents and sessions
|
||||
export interface AgentConfiguration {
|
||||
model: string // Main Model ID (required)
|
||||
plan_model?: string // Optional plan/thinking model ID
|
||||
small_model?: string // Optional small/fast model ID
|
||||
built_in_tools?: string[] // Array of built-in tool IDs
|
||||
built_in_tools?: Tool[] // Array of built-in tool IDs
|
||||
mcps?: string[] // Array of MCP tool IDs
|
||||
knowledges?: string[] // Array of enabled knowledge base IDs
|
||||
configuration?: Record<string, any> // Extensible settings like temperature, top_p
|
||||
accessible_paths?: string[] // Array of directory paths the agent can access
|
||||
permission_mode?: PermissionMode // Permission mode
|
||||
max_steps?: number // Maximum number of steps the agent can take
|
||||
accessible_paths: string[] // Array of directory paths the agent can access
|
||||
permission_mode: PermissionMode // Permission mode
|
||||
max_steps: number // Maximum number of steps the agent can take
|
||||
}
|
||||
|
||||
// Agent entity representing an autonomous agent configuration
|
||||
|
||||
Reference in New Issue
Block a user