@anthropic-ai/claude-code 1.0.82 → 1.0.84

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@anthropic-ai/claude-code",
3
- "version": "1.0.82",
3
+ "version": "1.0.84",
4
4
  "main": "sdk.mjs",
5
5
  "types": "sdk.d.ts",
6
6
  "bin": {
package/sdk.d.ts CHANGED
@@ -1,171 +1,126 @@
1
- import type {
2
- Message as APIAssistantMessage,
3
- MessageParam as APIUserMessage,
4
- Usage,
5
- } from '@anthropic-ai/sdk/resources/index.mjs'
6
-
1
+ import type { Message as APIAssistantMessage, MessageParam as APIUserMessage, Usage } from '@anthropic-ai/sdk/resources/index.mjs';
7
2
  export type NonNullableUsage = {
8
- [K in keyof Usage]: NonNullable<Usage[K]>
9
- }
10
-
11
- export type ApiKeySource = 'user' | 'project' | 'org' | 'temporary'
12
-
13
- export type ConfigScope = 'local' | 'user' | 'project'
14
-
3
+ [K in keyof Usage]: NonNullable<Usage[K]>;
4
+ };
5
+ export type ApiKeySource = 'user' | 'project' | 'org' | 'temporary';
6
+ export type ConfigScope = 'local' | 'user' | 'project';
15
7
  export type McpStdioServerConfig = {
16
- type?: 'stdio' // Optional for backwards compatibility
17
- command: string
18
- args?: string[]
19
- env?: Record<string, string>
20
- }
21
-
8
+ type?: 'stdio';
9
+ command: string;
10
+ args?: string[];
11
+ env?: Record<string, string>;
12
+ };
22
13
  export type McpSSEServerConfig = {
23
- type: 'sse'
24
- url: string
25
- headers?: Record<string, string>
26
- }
27
-
14
+ type: 'sse';
15
+ url: string;
16
+ headers?: Record<string, string>;
17
+ };
28
18
  export type McpHttpServerConfig = {
29
- type: 'http'
30
- url: string
31
- headers?: Record<string, string>
32
- }
33
-
34
- export type McpServerConfig =
35
- | McpStdioServerConfig
36
- | McpSSEServerConfig
37
- | McpHttpServerConfig
38
-
39
- export type PermissionResult =
40
- | {
41
- behavior: 'allow'
42
- updatedInput: Record<string, unknown>
43
- }
44
- | {
45
- behavior: 'deny'
46
- message: string
47
- }
48
-
49
- export type CanUseTool = (
50
- toolName: string,
51
- input: Record<string, unknown>,
52
- options: {
53
- // Signaled if the operation should be aborted
54
- signal: AbortSignal
55
- },
56
- ) => Promise<PermissionResult>
57
-
19
+ type: 'http';
20
+ url: string;
21
+ headers?: Record<string, string>;
22
+ };
23
+ export type McpServerConfig = McpStdioServerConfig | McpSSEServerConfig | McpHttpServerConfig;
24
+ export type PermissionResult = {
25
+ behavior: 'allow';
26
+ updatedInput: Record<string, unknown>;
27
+ } | {
28
+ behavior: 'deny';
29
+ message: string;
30
+ };
31
+ export type CanUseTool = (toolName: string, input: Record<string, unknown>, options: {
32
+ signal: AbortSignal;
33
+ }) => Promise<PermissionResult>;
58
34
  export type Options = {
59
- abortController?: AbortController
60
- allowedTools?: string[]
61
- appendSystemPrompt?: string
62
- customSystemPrompt?: string
63
- cwd?: string
64
- disallowedTools?: string[]
65
- executable?: 'bun' | 'deno' | 'node'
66
- executableArgs?: string[]
67
- maxThinkingTokens?: number
68
- maxTurns?: number
69
- mcpServers?: Record<string, McpServerConfig>
70
- pathToClaudeCodeExecutable?: string
71
- permissionMode?: PermissionMode
72
- permissionPromptToolName?: string
73
- continue?: boolean
74
- resume?: string
75
- model?: string
76
- fallbackModel?: string
77
- stderr?: (data: string) => void
78
- canUseTool?: CanUseTool
79
- }
80
-
81
- export type PermissionMode =
82
- | 'default'
83
- | 'acceptEdits'
84
- | 'bypassPermissions'
85
- | 'plan'
86
-
35
+ abortController?: AbortController;
36
+ additionalDirectories?: string[];
37
+ allowedTools?: string[];
38
+ appendSystemPrompt?: string;
39
+ canUseTool?: CanUseTool;
40
+ continue?: boolean;
41
+ customSystemPrompt?: string;
42
+ cwd?: string;
43
+ disallowedTools?: string[];
44
+ env?: Dict<string>;
45
+ executable?: 'bun' | 'deno' | 'node';
46
+ executableArgs?: string[];
47
+ fallbackModel?: string;
48
+ maxThinkingTokens?: number;
49
+ maxTurns?: number;
50
+ mcpServers?: Record<string, McpServerConfig>;
51
+ model?: string;
52
+ pathToClaudeCodeExecutable?: string;
53
+ permissionMode?: PermissionMode;
54
+ permissionPromptToolName?: string;
55
+ resume?: string;
56
+ stderr?: (data: string) => void;
57
+ strictMcpConfig?: boolean;
58
+ };
59
+ export type PermissionMode = 'default' | 'acceptEdits' | 'bypassPermissions' | 'plan';
87
60
  export type SDKUserMessage = {
88
- type: 'user'
89
- message: APIUserMessage
90
- parent_tool_use_id: string | null
91
- session_id: string
92
- }
93
-
61
+ type: 'user';
62
+ message: APIUserMessage;
63
+ parent_tool_use_id: string | null;
64
+ session_id: string;
65
+ };
94
66
  export type SDKAssistantMessage = {
95
- type: 'assistant'
96
- message: APIAssistantMessage
97
- parent_tool_use_id: string | null
98
- session_id: string
99
- }
100
-
67
+ type: 'assistant';
68
+ message: APIAssistantMessage;
69
+ parent_tool_use_id: string | null;
70
+ session_id: string;
71
+ };
101
72
  export type SDKPermissionDenial = {
102
- tool_name: string
103
- tool_use_id: string
104
- tool_input: Record<string, unknown>
105
- }
106
-
107
- export type SDKResultMessage =
108
- | {
109
- type: 'result'
110
- subtype: 'success'
111
- duration_ms: number
112
- duration_api_ms: number
113
- is_error: boolean
114
- num_turns: number
115
- result: string
116
- session_id: string
117
- total_cost_usd: number
118
- usage: NonNullableUsage
119
- permission_denials: SDKPermissionDenial[]
120
- }
121
- | {
122
- type: 'result'
123
- subtype: 'error_max_turns' | 'error_during_execution'
124
- duration_ms: number
125
- duration_api_ms: number
126
- is_error: boolean
127
- num_turns: number
128
- session_id: string
129
- total_cost_usd: number
130
- usage: NonNullableUsage
131
- permission_denials: SDKPermissionDenial[]
132
- }
133
-
73
+ tool_name: string;
74
+ tool_use_id: string;
75
+ tool_input: Record<string, unknown>;
76
+ };
77
+ export type SDKResultMessage = {
78
+ type: 'result';
79
+ subtype: 'success';
80
+ duration_ms: number;
81
+ duration_api_ms: number;
82
+ is_error: boolean;
83
+ num_turns: number;
84
+ result: string;
85
+ session_id: string;
86
+ total_cost_usd: number;
87
+ usage: NonNullableUsage;
88
+ permission_denials: SDKPermissionDenial[];
89
+ } | {
90
+ type: 'result';
91
+ subtype: 'error_max_turns' | 'error_during_execution';
92
+ duration_ms: number;
93
+ duration_api_ms: number;
94
+ is_error: boolean;
95
+ num_turns: number;
96
+ session_id: string;
97
+ total_cost_usd: number;
98
+ usage: NonNullableUsage;
99
+ permission_denials: SDKPermissionDenial[];
100
+ };
134
101
  export type SDKSystemMessage = {
135
- type: 'system'
136
- subtype: 'init'
137
- apiKeySource: ApiKeySource
138
- cwd: string
139
- session_id: string
140
- tools: string[]
141
- mcp_servers: {
142
- name: string
143
- status: string
144
- }[]
145
- model: string
146
- permissionMode: PermissionMode
147
- slash_commands: string[]
148
- }
149
-
150
- export type SDKMessage =
151
- | SDKAssistantMessage
152
- | SDKUserMessage
153
- | SDKResultMessage
154
- | SDKSystemMessage
155
-
156
- type Props = {
157
- prompt: string | AsyncIterable<SDKUserMessage>
158
- options?: Options
159
- }
160
-
102
+ type: 'system';
103
+ subtype: 'init';
104
+ apiKeySource: ApiKeySource;
105
+ cwd: string;
106
+ session_id: string;
107
+ tools: string[];
108
+ mcp_servers: {
109
+ name: string;
110
+ status: string;
111
+ }[];
112
+ model: string;
113
+ permissionMode: PermissionMode;
114
+ slash_commands: string[];
115
+ };
116
+ export type SDKMessage = SDKAssistantMessage | SDKUserMessage | SDKResultMessage | SDKSystemMessage;
161
117
  export interface Query extends AsyncGenerator<SDKMessage, void> {
162
- /**
163
- * Interrupt the query.
164
- * Only supported when streaming input is used.
165
- */
166
- interrupt(): Promise<void>
118
+ /**
119
+ * Interrupt the query.
120
+ * Only supported when streaming input is used.
121
+ */
122
+ interrupt(): Promise<void>;
167
123
  }
168
-
169
124
  /**
170
125
  * Query Claude Code
171
126
  *
@@ -181,6 +136,9 @@ export interface Query extends AsyncGenerator<SDKMessage, void> {
181
136
  * }
182
137
  * ```
183
138
  */
184
- export function query({ prompt, options }: Props): Query
185
-
186
- export class AbortError extends Error {}
139
+ export declare function query({ prompt, options, }: {
140
+ prompt: string | AsyncIterable<SDKUserMessage>;
141
+ options?: Options;
142
+ }): Query;
143
+ export declare class AbortError extends Error {
144
+ }
package/sdk.mjs CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  // (c) Anthropic PBC. All rights reserved. Use is subject to Anthropic's Commercial Terms of Service (https://www.anthropic.com/legal/commercial-terms).
4
4
 
5
- // Version: 1.0.82
5
+ // Version: 1.0.84
6
6
 
7
7
  // Want to see the unminified source? We're hiring!
8
8
  // https://job-boards.greenhouse.io/anthropic/jobs/4816199008
@@ -97,6 +97,10 @@ function createAbortController(maxListeners = DEFAULT_MAX_LISTENERS) {
97
97
  return controller;
98
98
  }
99
99
 
100
+ // src/entrypoints/sdkTypes.ts
101
+ class AbortError extends Error {
102
+ }
103
+
100
104
  // src/entrypoints/sdk.ts
101
105
  function query({
102
106
  prompt,
@@ -121,7 +125,8 @@ function query({
121
125
  fallbackModel,
122
126
  strictMcpConfig,
123
127
  stderr,
124
- env
128
+ env,
129
+ additionalDirectories = []
125
130
  } = {}
126
131
  }) {
127
132
  if (!env) {
@@ -187,6 +192,9 @@ function query({
187
192
  } else {
188
193
  args.push("--input-format", "stream-json");
189
194
  }
195
+ for (const dir of additionalDirectories) {
196
+ args.push("--add-dir", dir);
197
+ }
190
198
  if (!existsSync(pathToClaudeCodeExecutable)) {
191
199
  throw new ReferenceError(`Claude Code executable not found at ${pathToClaudeCodeExecutable}. Is options.pathToClaudeCodeExecutable set?`);
192
200
  }
@@ -432,11 +440,7 @@ function logDebug(message) {
432
440
  function isRunningWithBun() {
433
441
  return process.versions.bun !== undefined || process.env.BUN_INSTALL !== undefined;
434
442
  }
435
-
436
- class AbortError extends Error {
437
- }
438
443
  export {
439
444
  query,
440
- Query,
441
- AbortError
445
+ Query
442
446
  };
Binary file
Binary file