@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/cli.js +807 -806
- package/package.json +1 -1
- package/sdk.d.ts +118 -160
- package/sdk.mjs +11 -7
- package/vendor/claude-code.vsix +0 -0
- package/vendor/ripgrep/arm64-darwin/ripgrep.node +0 -0
- package/vendor/ripgrep/arm64-linux/rg +0 -0
- package/vendor/ripgrep/arm64-linux/ripgrep.node +0 -0
- package/vendor/ripgrep/x64-darwin/ripgrep.node +0 -0
- package/vendor/ripgrep/x64-linux/ripgrep.node +0 -0
- package/vendor/ripgrep/x64-win32/ripgrep.node +0 -0
package/package.json
CHANGED
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
|
-
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export type
|
|
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
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}
|
|
21
|
-
|
|
8
|
+
type?: 'stdio';
|
|
9
|
+
command: string;
|
|
10
|
+
args?: string[];
|
|
11
|
+
env?: Record<string, string>;
|
|
12
|
+
};
|
|
22
13
|
export type McpSSEServerConfig = {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
}
|
|
27
|
-
|
|
14
|
+
type: 'sse';
|
|
15
|
+
url: string;
|
|
16
|
+
headers?: Record<string, string>;
|
|
17
|
+
};
|
|
28
18
|
export type McpHttpServerConfig = {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export type
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
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
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
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
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
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
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
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
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
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
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
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
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
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 }:
|
|
185
|
-
|
|
186
|
-
|
|
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.
|
|
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
|
};
|
package/vendor/claude-code.vsix
CHANGED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|