Skip to content

Commit f964db4

Browse files
committed
initial agent-template.d.ts
1 parent 9525910 commit f964db4

File tree

1 file changed

+278
-0
lines changed

1 file changed

+278
-0
lines changed
Lines changed: 278 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,278 @@
1+
/**
2+
* Codebuff Agent Type Definitions
3+
*
4+
* This file provides TypeScript type definitions for creating custom Codebuff agents.
5+
* Import these types in your agent files to get full type safety and IntelliSense.
6+
*
7+
* Usage:
8+
* import { AgentConfig, ToolName, ModelName } from './agent-template.d.ts'
9+
*
10+
* const config: AgentConfig = {
11+
* // Your agent configuration with full type safety
12+
* }
13+
*/
14+
15+
// ============================================================================
16+
// Core Agent Configuration Types
17+
// ============================================================================
18+
19+
/**
20+
* Simple configuration interface for defining a custom agent
21+
*/
22+
export interface AgentConfig {
23+
/** Unique identifier for this agent */
24+
id: string
25+
26+
/** Human-readable name for the agent */
27+
name: string
28+
29+
/** Description of what this agent does */
30+
purpose: string
31+
32+
/** AI model to use for this agent */
33+
model: ModelName
34+
35+
/** Main system prompt defining the agent's behavior */
36+
systemPrompt: string
37+
38+
/** Optional: Tools this agent can use (defaults to common file editing tools) */
39+
tools?: ToolName[]
40+
41+
/** Optional: Other agents this agent can spawn */
42+
spawnableAgents?: SpawnableAgentName[]
43+
44+
/** Optional: Advanced generator function for programmatic control */
45+
handleSteps?: (context: AgentStepContext) => AsyncGenerator<any, any, any>
46+
}
47+
/**
48+
* Advanced configuration interface with all options (for power users)
49+
*/
50+
export interface AdvancedAgentConfig extends AgentConfig {
51+
/** Version string (defaults to '1.0.0') */
52+
version?: string
53+
54+
/** How the agent should output responses (defaults to 'last_message') */
55+
outputMode?: 'last_message' | 'all_messages' | 'json'
56+
57+
/** JSON schema for structured output (when outputMode is 'json') */
58+
outputSchema?: JsonSchema
59+
60+
/** Whether to include conversation history (defaults to true) */
61+
includeMessageHistory?: boolean
62+
63+
/** Prompt template for user input (defaults to standard template) */
64+
userInputPrompt?: string
65+
66+
/** Prompt for continuing agent steps (defaults to standard template) */
67+
agentStepPrompt?: string
68+
69+
/** Instructions for spawned sub-agents */
70+
parentInstructions?: Record<SpawnableAgentName, string>
71+
}
72+
73+
// ============================================================================
74+
// Supporting Types
75+
// ============================================================================
76+
77+
/**
78+
* Context provided to handleSteps generator function
79+
*/
80+
export interface AgentStepContext {
81+
agentState: any
82+
prompt: string
83+
params: any
84+
}
85+
86+
/**
87+
* JSON Schema definition (for advanced users)
88+
*/
89+
export interface JsonSchema {
90+
type: string
91+
properties?: Record<string, any>
92+
required?: string[]
93+
[key: string]: any
94+
}
95+
96+
// ============================================================================
97+
// Available Tools
98+
// ============================================================================
99+
100+
/**
101+
* File operation tools
102+
*/
103+
export type FileTools =
104+
| 'read_files'
105+
| 'write_file'
106+
| 'str_replace'
107+
| 'find_files'
108+
109+
/**
110+
* Code analysis tools
111+
*/
112+
export type CodeAnalysisTools = 'code_search' | 'find_files'
113+
114+
/**
115+
* Terminal and system tools
116+
*/
117+
export type TerminalTools = 'run_terminal_command' | 'run_file_change_hooks'
118+
119+
/**
120+
* Web and browser tools
121+
*/
122+
export type WebTools = 'browser_logs' | 'web_search' | 'read_docs'
123+
124+
/**
125+
* Agent management tools
126+
*/
127+
export type AgentTools =
128+
| 'spawn_agents'
129+
| 'spawn_agents_async'
130+
| 'send_agent_message'
131+
| 'set_messages'
132+
| 'add_message'
133+
134+
/**
135+
* Planning and organization tools
136+
*/
137+
export type PlanningTools =
138+
| 'think_deeply'
139+
| 'create_plan'
140+
| 'add_subgoal'
141+
| 'update_subgoal'
142+
143+
/**
144+
* Output and control tools
145+
*/
146+
export type OutputTools = 'set_output' | 'end_turn'
147+
148+
/**
149+
* All available tools that agents can use
150+
*/
151+
export type ToolName =
152+
| FileTools
153+
| CodeAnalysisTools
154+
| TerminalTools
155+
| WebTools
156+
| AgentTools
157+
| PlanningTools
158+
| OutputTools
159+
160+
// ============================================================================
161+
// Available Models (see: https://openrouter.ai/models)
162+
// ============================================================================
163+
164+
/**
165+
* AI models available for agents (all models in OpenRouter are supported)
166+
*/
167+
export type ModelName =
168+
// Verified OpenRouter Models
169+
| 'anthropic/claude-4-sonnet-20250522'
170+
| 'anthropic/claude-4-opus-20250522'
171+
| 'anthropic/claude-3.5-haiku-20241022'
172+
| 'anthropic/claude-3.5-sonnet-20240620'
173+
| 'openai/gpt-4o-2024-11-20'
174+
| 'openai/gpt-4o-mini-2024-07-18'
175+
| 'openai/o3'
176+
| 'openai/o4-mini'
177+
| 'openai/o4-mini-high'
178+
| 'google/gemini-2.5-pro'
179+
| 'google/gemini-2.5-flash'
180+
| 'x-ai/grok-4-07-09'
181+
182+
// Or any string for custom models, as long as they are supported by OpenRouter
183+
| string
184+
185+
// ============================================================================
186+
// Spawnable Agents
187+
// ============================================================================
188+
189+
/**
190+
* Built-in agents that can be spawned by custom agents
191+
*/
192+
export type SpawnableAgentName =
193+
| 'file_picker'
194+
| 'file_explorer'
195+
| 'researcher'
196+
| 'thinker'
197+
| 'reviewer'
198+
| string // Allow custom agent names
199+
200+
// ============================================================================
201+
// Utility Types
202+
// ============================================================================
203+
204+
/**
205+
* Common tool combinations for convenience
206+
*/
207+
export type FileEditingTools = FileTools | 'end_turn'
208+
export type ResearchTools = WebTools | 'write_file' | 'end_turn'
209+
export type CodeAnalysisToolSet = FileTools | CodeAnalysisTools | 'end_turn'
210+
211+
// ============================================================================
212+
// Example Configurations
213+
// ============================================================================
214+
215+
/**
216+
* Example configuration for a basic file-editing agent
217+
*/
218+
export const FileEditorExample: AgentConfig = {
219+
id: 'file-editor',
220+
name: 'File Editor',
221+
purpose: 'Specialized in reading and editing files',
222+
model: 'anthropic/claude-4-sonnet-20250522',
223+
tools: ['read_files', 'write_file', 'str_replace', 'end_turn'],
224+
systemPrompt:
225+
'You are a file editing specialist. Help users read, write, and modify files with precision and care.',
226+
}
227+
228+
/**
229+
* Example configuration for a research agent
230+
*/
231+
export const ResearcherExample: AgentConfig = {
232+
id: 'researcher',
233+
name: 'Research Assistant',
234+
purpose: 'Specialized in gathering information and research',
235+
model: 'anthropic/claude-3.5-haiku-20241022',
236+
tools: ['web_search', 'read_docs', 'write_file', 'end_turn'],
237+
spawnableAgents: ['researcher', 'knowledge-keeper'],
238+
systemPrompt:
239+
'You are a research specialist. Help users gather information, analyze sources, and document findings.',
240+
}
241+
242+
/**
243+
* Example configuration for a code analysis agent
244+
*/
245+
export const CodeAnalyzerExample: AgentConfig = {
246+
id: 'code-analyzer',
247+
name: 'Code Analyzer',
248+
purpose: 'Specialized in understanding codebases and finding patterns',
249+
model: 'google/gemini-2.5-flash',
250+
tools: ['read_files', 'code_search', 'find_files', 'end_turn'],
251+
systemPrompt:
252+
'You are a code analysis expert. Help users understand codebases, find patterns, and identify issues.',
253+
}
254+
255+
/**
256+
* Example configuration using advanced features
257+
*/
258+
export const AdvancedExample: AdvancedAgentConfig = {
259+
id: 'advanced-agent',
260+
name: 'Advanced Agent',
261+
purpose: 'Demonstrates advanced configuration options',
262+
model: 'anthropic/claude-4-sonnet-20250522',
263+
outputMode: 'json',
264+
outputSchema: {
265+
type: 'object',
266+
properties: {
267+
result: { type: 'string' },
268+
confidence: { type: 'number' },
269+
},
270+
required: ['result'],
271+
},
272+
tools: ['read_files', 'code_search', 'set_output'],
273+
systemPrompt:
274+
'You analyze code and return structured JSON responses with confidence scores.',
275+
parentInstructions: {
276+
file_picker: 'Focus on finding the most relevant code files for analysis',
277+
},
278+
}

0 commit comments

Comments
 (0)