Skip to content

Commit 4e25c1c

Browse files
ZhiXiao-Linclaude
andcommitted
fix(sdk/node): regenerate index.js and index.d.ts from napi build
The previous index.d.ts was stale — it declared a constructor-based Agent(options) API that no longer exists. The regenerated types correctly reflect the current API: Agent.create() factory + Session class with send/stream/tool methods. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 604eabe commit 4e25c1c

2 files changed

Lines changed: 238 additions & 71 deletions

File tree

sdk/node/index.d.ts

Lines changed: 34 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,87 +1,66 @@
1+
/* tslint:disable */
12
/* eslint-disable */
2-
/* auto-generated by napi-rs */
33

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 */
185

196
export interface AgentResult {
20-
/** The final text response from the agent */
217
text: string
22-
/** Number of tool calls made during execution */
238
toolCallsCount: number
24-
/** Total prompt tokens used */
259
promptTokens: number
26-
/** Total completion tokens used */
2710
completionTokens: number
28-
/** Total tokens used */
2911
totalTokens: number
3012
}
31-
3213
export interface AgentEvent {
33-
/** Event type: "start", "text_delta", "tool_start", "tool_end", "turn_start", "turn_end", "end", "error" */
3414
type: string
35-
/** Text content (for text_delta and end events) */
3615
text?: string
37-
/** Tool name (for tool_start and tool_end events) */
3816
toolName?: string
39-
/** Tool ID (for tool_start and tool_end events) */
4017
toolId?: string
41-
/** Tool output (for tool_end events) */
4218
toolOutput?: string
43-
/** Exit code (for tool_end events) */
4419
exitCode?: number
45-
/** Turn number (for turn_start and turn_end events) */
4620
turn?: number
47-
/** Prompt text (for start events) */
4821
prompt?: string
49-
/** Error message (for error events) */
5022
error?: string
51-
/** Token usage (for turn_end and end events) */
5223
totalTokens?: number
5324
}
54-
5525
export interface ToolResult {
56-
/** Tool name */
5726
name: string
58-
/** Tool output text */
5927
output: string
60-
/** Exit code (0 = success) */
6128
exitCode: number
6229
}
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. */
7453
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. */
8059
readFile(path: string): Promise<string>
81-
/** Execute a bash command in the workspace */
60+
/** Execute a bash command in the workspace. */
8261
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. */
8665
grep(pattern: string): Promise<string>
8766
}

0 commit comments

Comments
 (0)