|
1 | | -import type { Model } from '@codebuff/common/constants' |
2 | | -import type { ToolName } from '@codebuff/common/tools/constants' |
3 | 1 | import type { |
4 | | - AgentState, |
5 | | - AgentTemplateType, |
6 | | - ToolResult, |
7 | | -} from '@codebuff/common/types/session-state' |
8 | | -import type { z } from 'zod/v4' |
9 | | -import type { CodebuffToolCall } from '../tools/constants' |
| 2 | + AgentTemplate, |
| 3 | + StepGenerator, |
| 4 | + StepHandler, |
| 5 | +} from '@codebuff/common/types/agent-template' |
| 6 | +import type { AgentTemplateType } from '@codebuff/common/types/session-state' |
| 7 | +import type { ToolName } from '@codebuff/common/tools/constants' |
10 | 8 |
|
11 | 9 | import { AgentTemplateTypes } from '@codebuff/common/types/session-state' |
12 | 10 |
|
13 | | -export type AgentTemplate< |
14 | | - P = string | undefined, |
15 | | - T = Record<string, any> | undefined, |
16 | | -> = { |
17 | | - id: AgentTemplateType |
18 | | - displayName: string |
19 | | - model: Model |
20 | | - |
21 | | - toolNames: ToolName[] |
22 | | - subagents: AgentTemplateType[] |
23 | | - |
24 | | - parentPrompt?: string |
25 | | - systemPrompt: string |
26 | | - instructionsPrompt: string |
27 | | - stepPrompt: string |
28 | | - parentInstructions?: Record<string, string> |
29 | | - |
30 | | - // Required parameters for spawning this agent. |
31 | | - inputSchema: { |
32 | | - prompt?: z.ZodSchema<P> |
33 | | - params?: z.ZodSchema<T> |
34 | | - } |
35 | | - includeMessageHistory: boolean |
36 | | - outputMode: 'last_message' | 'all_messages' | 'json' |
37 | | - outputSchema?: z.ZodSchema<any> |
38 | | - |
39 | | - handleSteps?: StepHandler<P, T> | string // Function or string of the generator code for running in a sandbox |
40 | | -} |
41 | | - |
42 | | -export type StepGenerator = Generator< |
43 | | - Omit<CodebuffToolCall, 'toolCallId'> | 'STEP' | 'STEP_ALL', |
44 | | - void, |
45 | | - { agentState: AgentState; toolResult: ToolResult | undefined } |
46 | | -> |
47 | | - |
48 | | -export type StepHandler< |
49 | | - P = string | undefined, |
50 | | - T = Record<string, any> | undefined, |
51 | | -> = (params: { agentState: AgentState; prompt: P; params: T }) => StepGenerator |
| 11 | +// Re-export for backward compatibility |
| 12 | +export type { AgentTemplate, StepGenerator, StepHandler } |
52 | 13 |
|
53 | 14 | const placeholderNames = [ |
54 | 15 | 'AGENT_NAME', |
|
0 commit comments