@anthropic-ai/claude-agent-sdk 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/LICENSE.md +1 -0
  2. package/README.md +41 -0
  3. package/cli.js +3782 -0
  4. package/package.json +38 -0
  5. package/sdk-tools.d.ts +313 -0
  6. package/sdk.d.ts +23 -0
  7. package/sdk.mjs +14173 -0
  8. package/sdkTypes.d.ts +416 -0
  9. package/vendor/claude-code-jetbrains-plugin/lib/annotations-23.0.0.jar +0 -0
  10. package/vendor/claude-code-jetbrains-plugin/lib/claude-code-jetbrains-plugin-0.1.11-beta-searchableOptions.jar +0 -0
  11. package/vendor/claude-code-jetbrains-plugin/lib/claude-code-jetbrains-plugin-0.1.11-beta.jar +0 -0
  12. package/vendor/claude-code-jetbrains-plugin/lib/config-1.4.3.jar +0 -0
  13. package/vendor/claude-code-jetbrains-plugin/lib/jansi-2.4.1.jar +0 -0
  14. package/vendor/claude-code-jetbrains-plugin/lib/kotlin-logging-jvm-7.0.0.jar +0 -0
  15. package/vendor/claude-code-jetbrains-plugin/lib/kotlin-reflect-2.0.21.jar +0 -0
  16. package/vendor/claude-code-jetbrains-plugin/lib/kotlin-sdk-jvm-0.4.0.jar +0 -0
  17. package/vendor/claude-code-jetbrains-plugin/lib/kotlin-stdlib-2.1.20.jar +0 -0
  18. package/vendor/claude-code-jetbrains-plugin/lib/kotlinx-coroutines-core-jvm-1.9.0.jar +0 -0
  19. package/vendor/claude-code-jetbrains-plugin/lib/kotlinx-coroutines-slf4j-1.9.0.jar +0 -0
  20. package/vendor/claude-code-jetbrains-plugin/lib/kotlinx-io-bytestring-jvm-0.5.4.jar +0 -0
  21. package/vendor/claude-code-jetbrains-plugin/lib/kotlinx-io-core-jvm-0.5.4.jar +0 -0
  22. package/vendor/claude-code-jetbrains-plugin/lib/kotlinx-serialization-core-jvm-1.8.1.jar +0 -0
  23. package/vendor/claude-code-jetbrains-plugin/lib/kotlinx-serialization-json-jvm-1.8.1.jar +0 -0
  24. package/vendor/claude-code-jetbrains-plugin/lib/ktor-client-cio-jvm-3.0.2.jar +0 -0
  25. package/vendor/claude-code-jetbrains-plugin/lib/ktor-client-core-jvm-3.0.2.jar +0 -0
  26. package/vendor/claude-code-jetbrains-plugin/lib/ktor-events-jvm-3.0.2.jar +0 -0
  27. package/vendor/claude-code-jetbrains-plugin/lib/ktor-http-cio-jvm-3.0.2.jar +0 -0
  28. package/vendor/claude-code-jetbrains-plugin/lib/ktor-http-jvm-3.0.2.jar +0 -0
  29. package/vendor/claude-code-jetbrains-plugin/lib/ktor-io-jvm-3.0.2.jar +0 -0
  30. package/vendor/claude-code-jetbrains-plugin/lib/ktor-network-jvm-3.0.2.jar +0 -0
  31. package/vendor/claude-code-jetbrains-plugin/lib/ktor-network-tls-jvm-3.0.2.jar +0 -0
  32. package/vendor/claude-code-jetbrains-plugin/lib/ktor-serialization-jvm-3.0.2.jar +0 -0
  33. package/vendor/claude-code-jetbrains-plugin/lib/ktor-server-cio-jvm-3.0.2.jar +0 -0
  34. package/vendor/claude-code-jetbrains-plugin/lib/ktor-server-core-jvm-3.0.2.jar +0 -0
  35. package/vendor/claude-code-jetbrains-plugin/lib/ktor-server-sse-jvm-3.0.2.jar +0 -0
  36. package/vendor/claude-code-jetbrains-plugin/lib/ktor-server-websockets-jvm-3.0.2.jar +0 -0
  37. package/vendor/claude-code-jetbrains-plugin/lib/ktor-sse-jvm-3.0.2.jar +0 -0
  38. package/vendor/claude-code-jetbrains-plugin/lib/ktor-utils-jvm-3.0.2.jar +0 -0
  39. package/vendor/claude-code-jetbrains-plugin/lib/ktor-websocket-serialization-jvm-3.0.2.jar +0 -0
  40. package/vendor/claude-code-jetbrains-plugin/lib/ktor-websockets-jvm-3.0.2.jar +0 -0
  41. package/vendor/claude-code-jetbrains-plugin/lib/slf4j-api-2.0.16.jar +0 -0
  42. package/vendor/ripgrep/COPYING +3 -0
  43. package/vendor/ripgrep/arm64-darwin/rg +0 -0
  44. package/vendor/ripgrep/arm64-darwin/ripgrep.node +0 -0
  45. package/vendor/ripgrep/arm64-linux/rg +0 -0
  46. package/vendor/ripgrep/arm64-linux/ripgrep.node +0 -0
  47. package/vendor/ripgrep/x64-darwin/rg +0 -0
  48. package/vendor/ripgrep/x64-darwin/ripgrep.node +0 -0
  49. package/vendor/ripgrep/x64-linux/rg +0 -0
  50. package/vendor/ripgrep/x64-linux/ripgrep.node +0 -0
  51. package/vendor/ripgrep/x64-win32/rg.exe +0 -0
  52. package/vendor/ripgrep/x64-win32/ripgrep.node +0 -0
  53. package/yoga.wasm +0 -0
package/package.json ADDED
@@ -0,0 +1,38 @@
1
+ {
2
+ "name": "@anthropic-ai/claude-agent-sdk",
3
+ "version": "0.0.4",
4
+ "main": "sdk.mjs",
5
+ "types": "sdk.d.ts",
6
+ "engines": {
7
+ "node": ">=18.0.0"
8
+ },
9
+ "type": "module",
10
+ "author": "Anthropic <support@anthropic.com>",
11
+ "license": "SEE LICENSE IN README.md",
12
+ "description": "SDK for building AI agents with Claude Code's capabilities. Programmatically interact with Claude to build autonomous agents that can understand codebases, edit files, and execute workflows.",
13
+ "homepage": "https://github.com/anthropics/claude-code",
14
+ "bugs": {
15
+ "url": "https://github.com/anthropics/claude-code/issues"
16
+ },
17
+ "keywords": [
18
+ "ai",
19
+ "agent",
20
+ "sdk",
21
+ "claude",
22
+ "anthropic",
23
+ "automation",
24
+ "code-generation"
25
+ ],
26
+ "scripts": {
27
+ "prepare": "node -e \"if (!process.env.AUTHORIZED) { console.error('ERROR: Direct publishing is not allowed.\\nPlease use the publish-agent-sdk.sh script to publish this package.'); process.exit(1); }\""
28
+ },
29
+ "dependencies": {},
30
+ "optionalDependencies": {
31
+ "@img/sharp-darwin-arm64": "^0.33.5",
32
+ "@img/sharp-darwin-x64": "^0.33.5",
33
+ "@img/sharp-linux-arm": "^0.33.5",
34
+ "@img/sharp-linux-arm64": "^0.33.5",
35
+ "@img/sharp-linux-x64": "^0.33.5",
36
+ "@img/sharp-win32-x64": "^0.33.5"
37
+ }
38
+ }
package/sdk-tools.d.ts ADDED
@@ -0,0 +1,313 @@
1
+ /* eslint-disable */
2
+ /**
3
+ * This file was automatically generated by json-schema-to-typescript.
4
+ * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
5
+ * and run json-schema-to-typescript to regenerate this file.
6
+ */
7
+
8
+ /**
9
+ * JSON Schema definitions for Claude CLI tool inputs
10
+ */
11
+ export type ToolInputSchemas =
12
+ | AgentInput
13
+ | BashInput
14
+ | BashOutputInput
15
+ | ExitPlanModeInput
16
+ | FileEditInput
17
+ | FileMultiEditInput
18
+ | FileReadInput
19
+ | FileWriteInput
20
+ | GlobInput
21
+ | GrepInput
22
+ | KillShellInput
23
+ | ListMcpResourcesInput
24
+ | McpInput
25
+ | NotebookEditInput
26
+ | ReadMcpResourceInput
27
+ | TodoWriteInput
28
+ | WebFetchInput
29
+ | WebSearchInput;
30
+
31
+ export interface AgentInput {
32
+ /**
33
+ * A short (3-5 word) description of the task
34
+ */
35
+ description: string;
36
+ /**
37
+ * The task for the agent to perform
38
+ */
39
+ prompt: string;
40
+ /**
41
+ * The type of specialized agent to use for this task
42
+ */
43
+ subagent_type: string;
44
+ }
45
+ export interface BashInput {
46
+ /**
47
+ * The command to execute
48
+ */
49
+ command: string;
50
+ /**
51
+ * Optional timeout in milliseconds (max 600000)
52
+ */
53
+ timeout?: number;
54
+ /**
55
+ * Clear, concise description of what this command does in 5-10 words, in active voice. Examples:
56
+ * Input: ls
57
+ * Output: List files in current directory
58
+ *
59
+ * Input: git status
60
+ * Output: Show working tree status
61
+ *
62
+ * Input: npm install
63
+ * Output: Install package dependencies
64
+ *
65
+ * Input: mkdir foo
66
+ * Output: Create directory 'foo'
67
+ */
68
+ description?: string;
69
+ /**
70
+ * Set to true to run this command in the background. Use BashOutput to read the output later.
71
+ */
72
+ run_in_background?: boolean;
73
+ }
74
+ export interface BashOutputInput {
75
+ /**
76
+ * The ID of the background shell to retrieve output from
77
+ */
78
+ bash_id: string;
79
+ /**
80
+ * Optional regular expression to filter the output lines. Only lines matching this regex will be included in the result. Any lines that do not match will no longer be available to read.
81
+ */
82
+ filter?: string;
83
+ }
84
+ export interface ExitPlanModeInput {
85
+ /**
86
+ * The plan you came up with, that you want to run by the user for approval. Supports markdown. The plan should be pretty concise.
87
+ */
88
+ plan: string;
89
+ }
90
+ export interface FileEditInput {
91
+ /**
92
+ * The absolute path to the file to modify
93
+ */
94
+ file_path: string;
95
+ /**
96
+ * The text to replace
97
+ */
98
+ old_string: string;
99
+ /**
100
+ * The text to replace it with (must be different from old_string)
101
+ */
102
+ new_string: string;
103
+ /**
104
+ * Replace all occurences of old_string (default false)
105
+ */
106
+ replace_all?: boolean;
107
+ }
108
+ export interface FileMultiEditInput {
109
+ /**
110
+ * The absolute path to the file to modify
111
+ */
112
+ file_path: string;
113
+ /**
114
+ * Array of edit operations to perform sequentially on the file
115
+ *
116
+ * @minItems 1
117
+ */
118
+ edits: [
119
+ {
120
+ /**
121
+ * The text to replace
122
+ */
123
+ old_string: string;
124
+ /**
125
+ * The text to replace it with
126
+ */
127
+ new_string: string;
128
+ /**
129
+ * Replace all occurences of old_string (default false).
130
+ */
131
+ replace_all?: boolean;
132
+ },
133
+ ...{
134
+ /**
135
+ * The text to replace
136
+ */
137
+ old_string: string;
138
+ /**
139
+ * The text to replace it with
140
+ */
141
+ new_string: string;
142
+ /**
143
+ * Replace all occurences of old_string (default false).
144
+ */
145
+ replace_all?: boolean;
146
+ }[]
147
+ ];
148
+ }
149
+ export interface FileReadInput {
150
+ /**
151
+ * The absolute path to the file to read
152
+ */
153
+ file_path: string;
154
+ /**
155
+ * The line number to start reading from. Only provide if the file is too large to read at once
156
+ */
157
+ offset?: number;
158
+ /**
159
+ * The number of lines to read. Only provide if the file is too large to read at once.
160
+ */
161
+ limit?: number;
162
+ }
163
+ export interface FileWriteInput {
164
+ /**
165
+ * The absolute path to the file to write (must be absolute, not relative)
166
+ */
167
+ file_path: string;
168
+ /**
169
+ * The content to write to the file
170
+ */
171
+ content: string;
172
+ }
173
+ export interface GlobInput {
174
+ /**
175
+ * The glob pattern to match files against
176
+ */
177
+ pattern: string;
178
+ /**
179
+ * The directory to search in. If not specified, the current working directory will be used. IMPORTANT: Omit this field to use the default directory. DO NOT enter "undefined" or "null" - simply omit it for the default behavior. Must be a valid directory path if provided.
180
+ */
181
+ path?: string;
182
+ }
183
+ export interface GrepInput {
184
+ /**
185
+ * The regular expression pattern to search for in file contents
186
+ */
187
+ pattern: string;
188
+ /**
189
+ * File or directory to search in (rg PATH). Defaults to current working directory.
190
+ */
191
+ path?: string;
192
+ /**
193
+ * Glob pattern to filter files (e.g. "*.js", "*.{ts,tsx}") - maps to rg --glob
194
+ */
195
+ glob?: string;
196
+ /**
197
+ * Output mode: "content" shows matching lines (supports -A/-B/-C context, -n line numbers, head_limit), "files_with_matches" shows file paths (supports head_limit), "count" shows match counts (supports head_limit). Defaults to "files_with_matches".
198
+ */
199
+ output_mode?: "content" | "files_with_matches" | "count";
200
+ /**
201
+ * Number of lines to show before each match (rg -B). Requires output_mode: "content", ignored otherwise.
202
+ */
203
+ "-B"?: number;
204
+ /**
205
+ * Number of lines to show after each match (rg -A). Requires output_mode: "content", ignored otherwise.
206
+ */
207
+ "-A"?: number;
208
+ /**
209
+ * Number of lines to show before and after each match (rg -C). Requires output_mode: "content", ignored otherwise.
210
+ */
211
+ "-C"?: number;
212
+ /**
213
+ * Show line numbers in output (rg -n). Requires output_mode: "content", ignored otherwise.
214
+ */
215
+ "-n"?: boolean;
216
+ /**
217
+ * Case insensitive search (rg -i)
218
+ */
219
+ "-i"?: boolean;
220
+ /**
221
+ * File type to search (rg --type). Common types: js, py, rust, go, java, etc. More efficient than include for standard file types.
222
+ */
223
+ type?: string;
224
+ /**
225
+ * Limit output to first N lines/entries, equivalent to "| head -N". Works across all output modes: content (limits output lines), files_with_matches (limits file paths), count (limits count entries). When unspecified, shows all results from ripgrep.
226
+ */
227
+ head_limit?: number;
228
+ /**
229
+ * Enable multiline mode where . matches newlines and patterns can span lines (rg -U --multiline-dotall). Default: false.
230
+ */
231
+ multiline?: boolean;
232
+ }
233
+ export interface KillShellInput {
234
+ /**
235
+ * The ID of the background shell to kill
236
+ */
237
+ shell_id: string;
238
+ }
239
+ export interface ListMcpResourcesInput {
240
+ /**
241
+ * Optional server name to filter resources by
242
+ */
243
+ server?: string;
244
+ }
245
+ export interface McpInput {
246
+ [k: string]: unknown;
247
+ }
248
+ export interface NotebookEditInput {
249
+ /**
250
+ * The absolute path to the Jupyter notebook file to edit (must be absolute, not relative)
251
+ */
252
+ notebook_path: string;
253
+ /**
254
+ * The ID of the cell to edit. When inserting a new cell, the new cell will be inserted after the cell with this ID, or at the beginning if not specified.
255
+ */
256
+ cell_id?: string;
257
+ /**
258
+ * The new source for the cell
259
+ */
260
+ new_source: string;
261
+ /**
262
+ * The type of the cell (code or markdown). If not specified, it defaults to the current cell type. If using edit_mode=insert, this is required.
263
+ */
264
+ cell_type?: "code" | "markdown";
265
+ /**
266
+ * The type of edit to make (replace, insert, delete). Defaults to replace.
267
+ */
268
+ edit_mode?: "replace" | "insert" | "delete";
269
+ }
270
+ export interface ReadMcpResourceInput {
271
+ /**
272
+ * The MCP server name
273
+ */
274
+ server: string;
275
+ /**
276
+ * The resource URI to read
277
+ */
278
+ uri: string;
279
+ }
280
+ export interface TodoWriteInput {
281
+ /**
282
+ * The updated todo list
283
+ */
284
+ todos: {
285
+ content: string;
286
+ status: "pending" | "in_progress" | "completed";
287
+ activeForm: string;
288
+ }[];
289
+ }
290
+ export interface WebFetchInput {
291
+ /**
292
+ * The URL to fetch content from
293
+ */
294
+ url: string;
295
+ /**
296
+ * The prompt to run on the fetched content
297
+ */
298
+ prompt: string;
299
+ }
300
+ export interface WebSearchInput {
301
+ /**
302
+ * The search query to use
303
+ */
304
+ query: string;
305
+ /**
306
+ * Only include search results from these domains
307
+ */
308
+ allowed_domains?: string[];
309
+ /**
310
+ * Never include search results from these domains
311
+ */
312
+ blocked_domains?: string[];
313
+ }
package/sdk.d.ts ADDED
@@ -0,0 +1,23 @@
1
+ import type { Options as BaseOptions, Query, SDKUserMessage } from './sdkTypes.js';
2
+ export type AgentDefinition = {
3
+ description: string;
4
+ tools?: string[];
5
+ prompt: string;
6
+ model?: 'sonnet' | 'opus' | 'haiku' | 'inherit';
7
+ };
8
+ export type SettingSource = 'user' | 'project' | 'local';
9
+ export type Options = Omit<BaseOptions, 'customSystemPrompt' | 'appendSystemPrompt'> & {
10
+ agents?: Record<string, AgentDefinition>;
11
+ settingSources?: SettingSource[];
12
+ systemPrompt?: string | {
13
+ type: 'preset';
14
+ preset: 'claude_code';
15
+ append?: string;
16
+ };
17
+ };
18
+ export declare function query(_params: {
19
+ prompt: string | AsyncIterable<SDKUserMessage>;
20
+ options?: Options;
21
+ }): Query;
22
+ export type { NonNullableUsage, ModelUsage, ApiKeySource, ConfigScope, McpStdioServerConfig, McpSSEServerConfig, McpHttpServerConfig, McpSdkServerConfig, McpSdkServerConfigWithInstance, McpServerConfig, McpServerConfigForProcessTransport, PermissionBehavior, PermissionUpdate, PermissionResult, PermissionRuleValue, CanUseTool, HookEvent, HookCallback, HookCallbackMatcher, BaseHookInput, PreToolUseHookInput, PostToolUseHookInput, NotificationHookInput, UserPromptSubmitHookInput, SessionStartHookInput, StopHookInput, SubagentStopHookInput, PreCompactHookInput, ExitReason, SessionEndHookInput, HookInput, AsyncHookJSONOutput, SyncHookJSONOutput, HookJSONOutput, PermissionMode, SlashCommand, ModelInfo, McpServerStatus, SDKMessageBase, SDKUserMessage, SDKUserMessageReplay, SDKAssistantMessage, SDKPermissionDenial, SDKResultMessage, SDKSystemMessage, SDKPartialAssistantMessage, SDKCompactBoundaryMessage, SDKMessage, Query, } from './sdkTypes.js';
23
+ export { HOOK_EVENTS, EXIT_REASONS, tool, createSdkMcpServer, AbortError, } from './sdkTypes.js';