|
| 1 | +/* tslint:disable */ |
1 | 2 | /* eslint-disable */ |
2 | | -/* auto-generated by napi-rs */ |
3 | 3 |
|
4 | | -export interface AgentOptions { |
5 | | - /** LLM model identifier (e.g., "claude-sonnet-4-20250514", "gpt-4o") */ |
6 | | - model: string |
7 | | - /** API key for the LLM provider */ |
8 | | - apiKey: string |
9 | | - /** Path to the workspace directory (sandbox root) */ |
10 | | - workspace?: string |
11 | | - /** System prompt for the agent */ |
12 | | - systemPrompt?: string |
13 | | - /** Base URL override for the LLM API */ |
14 | | - baseUrl?: string |
15 | | - /** Maximum tool execution rounds per turn */ |
16 | | - maxToolRounds?: number |
17 | | -} |
| 4 | +/* auto-generated by NAPI-RS */ |
18 | 5 |
|
19 | 6 | export interface AgentResult { |
20 | | - /** The final text response from the agent */ |
21 | 7 | text: string |
22 | | - /** Number of tool calls made during execution */ |
23 | 8 | toolCallsCount: number |
24 | | - /** Total prompt tokens used */ |
25 | 9 | promptTokens: number |
26 | | - /** Total completion tokens used */ |
27 | 10 | completionTokens: number |
28 | | - /** Total tokens used */ |
29 | 11 | totalTokens: number |
30 | 12 | } |
31 | | - |
32 | 13 | export interface AgentEvent { |
33 | | - /** Event type: "start", "text_delta", "tool_start", "tool_end", "turn_start", "turn_end", "end", "error" */ |
34 | 14 | type: string |
35 | | - /** Text content (for text_delta and end events) */ |
36 | 15 | text?: string |
37 | | - /** Tool name (for tool_start and tool_end events) */ |
38 | 16 | toolName?: string |
39 | | - /** Tool ID (for tool_start and tool_end events) */ |
40 | 17 | toolId?: string |
41 | | - /** Tool output (for tool_end events) */ |
42 | 18 | toolOutput?: string |
43 | | - /** Exit code (for tool_end events) */ |
44 | 19 | exitCode?: number |
45 | | - /** Turn number (for turn_start and turn_end events) */ |
46 | 20 | turn?: number |
47 | | - /** Prompt text (for start events) */ |
48 | 21 | prompt?: string |
49 | | - /** Error message (for error events) */ |
50 | 22 | error?: string |
51 | | - /** Token usage (for turn_end and end events) */ |
52 | 23 | totalTokens?: number |
53 | 24 | } |
54 | | - |
55 | 25 | export interface ToolResult { |
56 | | - /** Tool name */ |
57 | 26 | name: string |
58 | | - /** Tool output text */ |
59 | 27 | output: string |
60 | | - /** Exit code (0 = success) */ |
61 | 28 | exitCode: number |
62 | 29 | } |
63 | | - |
64 | | -/** |
65 | | - * AI coding agent with tool execution capabilities. |
66 | | - * |
67 | | - * Create an Agent by providing a model name, API key, and workspace path. |
68 | | - * The agent auto-detects whether to use the Anthropic or OpenAI API based |
69 | | - * on the model name. |
70 | | - */ |
71 | | -export class Agent { |
72 | | - constructor(options: AgentOptions) |
73 | | - /** Send a prompt and wait for the complete response */ |
| 30 | +export interface SessionOptions { |
| 31 | + /** Override the default model. Format: "provider/model" (e.g., "openai/gpt-4o"). */ |
| 32 | + model?: string |
| 33 | +} |
| 34 | +/** AI coding agent. Create with `Agent.create()`, then call `agent.session()`. */ |
| 35 | +export declare class Agent { |
| 36 | + /** |
| 37 | + * Create an Agent from a config file path or inline config string. |
| 38 | + * |
| 39 | + * @param configSource - Path to .hcl/.json file, or inline JSON/HCL string |
| 40 | + */ |
| 41 | + static create(configSource: string): Promise<Agent> |
| 42 | + /** |
| 43 | + * Bind to a workspace directory, returning a Session. |
| 44 | + * |
| 45 | + * @param workspace - Path to the workspace directory |
| 46 | + * @param options - Optional session overrides (model) |
| 47 | + */ |
| 48 | + session(workspace: string, options?: SessionOptions | undefined | null): Session |
| 49 | +} |
| 50 | +/** Workspace-bound session. All LLM and tool operations happen here. */ |
| 51 | +export declare class Session { |
| 52 | + /** Send a prompt and wait for the complete response. */ |
74 | 53 | send(prompt: string): Promise<AgentResult> |
75 | | - /** Send a prompt and get all streaming events as an array */ |
76 | | - stream(prompt: string): Promise<AgentEvent[]> |
77 | | - /** Execute a tool by name, bypassing the LLM */ |
78 | | - tool(name: string, args: Record<string, unknown>): Promise<ToolResult> |
79 | | - /** Read a file from the workspace */ |
| 54 | + /** Send a prompt and get a stream of events. */ |
| 55 | + stream(prompt: string): Promise<Array<AgentEvent>> |
| 56 | + /** Execute a tool by name, bypassing the LLM. */ |
| 57 | + tool(name: string, args: any): Promise<ToolResult> |
| 58 | + /** Read a file from the workspace. */ |
80 | 59 | readFile(path: string): Promise<string> |
81 | | - /** Execute a bash command in the workspace */ |
| 60 | + /** Execute a bash command in the workspace. */ |
82 | 61 | bash(command: string): Promise<string> |
83 | | - /** Search for files matching a glob pattern */ |
84 | | - glob(pattern: string): Promise<string[]> |
85 | | - /** Search file contents with a regex pattern */ |
| 62 | + /** Search for files matching a glob pattern. */ |
| 63 | + glob(pattern: string): Promise<Array<string>> |
| 64 | + /** Search file contents with a regex pattern. */ |
86 | 65 | grep(pattern: string): Promise<string> |
87 | 66 | } |
0 commit comments