@anthropic-ai/claude-code 1.0.83 → 1.0.85
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 +1207 -1156
- package/package.json +1 -1
- package/sdk.d.ts +205 -159
- package/sdk.mjs +66 -15
- 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,214 @@
|
|
|
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
|
-
|
|
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>;
|
|
34
|
+
export declare const HOOK_EVENTS: readonly ["PreToolUse", "PostToolUse", "Notification", "UserPromptSubmit", "SessionStart", "SessionEnd", "Stop", "SubagentStop", "PreCompact"];
|
|
35
|
+
export type HookEvent = (typeof HOOK_EVENTS)[number];
|
|
36
|
+
export type HookCallback = (input: HookInput, toolUseID: string | undefined, options: {
|
|
37
|
+
signal: AbortSignal;
|
|
38
|
+
}) => Promise<HookJSONOutput>;
|
|
39
|
+
export interface HookCallbackMatcher {
|
|
40
|
+
matcher?: string;
|
|
41
|
+
hooks: HookCallback[];
|
|
32
42
|
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
export type
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
export type
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
43
|
+
export type BaseHookInput = {
|
|
44
|
+
session_id: string;
|
|
45
|
+
transcript_path: string;
|
|
46
|
+
cwd: string;
|
|
47
|
+
};
|
|
48
|
+
export type PreToolUseHookInput = BaseHookInput & {
|
|
49
|
+
hook_event_name: 'PreToolUse';
|
|
50
|
+
tool_name: string;
|
|
51
|
+
tool_input: unknown;
|
|
52
|
+
};
|
|
53
|
+
export type PostToolUseHookInput = BaseHookInput & {
|
|
54
|
+
hook_event_name: 'PostToolUse';
|
|
55
|
+
tool_name: string;
|
|
56
|
+
tool_input: unknown;
|
|
57
|
+
tool_response: unknown;
|
|
58
|
+
};
|
|
59
|
+
export type NotificationHookInput = BaseHookInput & {
|
|
60
|
+
hook_event_name: 'Notification';
|
|
61
|
+
message: string;
|
|
62
|
+
title?: string;
|
|
63
|
+
};
|
|
64
|
+
export type UserPromptSubmitHookInput = BaseHookInput & {
|
|
65
|
+
hook_event_name: 'UserPromptSubmit';
|
|
66
|
+
prompt: string;
|
|
67
|
+
};
|
|
68
|
+
export type SessionStartHookInput = BaseHookInput & {
|
|
69
|
+
hook_event_name: 'SessionStart';
|
|
70
|
+
source: 'startup' | 'resume' | 'clear' | 'compact';
|
|
71
|
+
};
|
|
72
|
+
export type StopHookInput = BaseHookInput & {
|
|
73
|
+
hook_event_name: 'Stop';
|
|
74
|
+
stop_hook_active: boolean;
|
|
75
|
+
};
|
|
76
|
+
export type SubagentStopHookInput = BaseHookInput & {
|
|
77
|
+
hook_event_name: 'SubagentStop';
|
|
78
|
+
stop_hook_active: boolean;
|
|
79
|
+
};
|
|
80
|
+
export type PreCompactHookInput = BaseHookInput & {
|
|
81
|
+
hook_event_name: 'PreCompact';
|
|
82
|
+
trigger: 'manual' | 'auto';
|
|
83
|
+
custom_instructions: string | null;
|
|
84
|
+
};
|
|
85
|
+
export declare const EXIT_REASONS: string[];
|
|
86
|
+
export type ExitReason = (typeof EXIT_REASONS)[number];
|
|
87
|
+
export type SessionEndHookInput = BaseHookInput & {
|
|
88
|
+
hook_event_name: 'SessionEnd';
|
|
89
|
+
reason: ExitReason;
|
|
90
|
+
};
|
|
91
|
+
export type HookInput = PreToolUseHookInput | PostToolUseHookInput | NotificationHookInput | UserPromptSubmitHookInput | SessionStartHookInput | SessionEndHookInput | StopHookInput | SubagentStopHookInput | PreCompactHookInput;
|
|
92
|
+
export interface HookJSONOutput {
|
|
93
|
+
continue?: boolean;
|
|
94
|
+
suppressOutput?: boolean;
|
|
95
|
+
stopReason?: string;
|
|
96
|
+
decision?: 'approve' | 'block';
|
|
97
|
+
systemMessage?: string;
|
|
98
|
+
permissionDecision?: 'allow' | 'deny' | 'ask';
|
|
99
|
+
reason?: string;
|
|
100
|
+
hookSpecificOutput?: {
|
|
101
|
+
hookEventName: 'PreToolUse';
|
|
102
|
+
permissionDecision?: 'allow' | 'deny' | 'ask';
|
|
103
|
+
permissionDecisionReason?: string;
|
|
104
|
+
} | {
|
|
105
|
+
hookEventName: 'UserPromptSubmit';
|
|
106
|
+
additionalContext?: string;
|
|
107
|
+
} | {
|
|
108
|
+
hookEventName: 'SessionStart';
|
|
109
|
+
additionalContext?: string;
|
|
110
|
+
} | {
|
|
111
|
+
hookEventName: 'PostToolUse';
|
|
112
|
+
additionalContext?: string;
|
|
113
|
+
};
|
|
79
114
|
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
115
|
+
export type Options = {
|
|
116
|
+
abortController?: AbortController;
|
|
117
|
+
additionalDirectories?: string[];
|
|
118
|
+
allowedTools?: string[];
|
|
119
|
+
appendSystemPrompt?: string;
|
|
120
|
+
canUseTool?: CanUseTool;
|
|
121
|
+
continue?: boolean;
|
|
122
|
+
customSystemPrompt?: string;
|
|
123
|
+
cwd?: string;
|
|
124
|
+
disallowedTools?: string[];
|
|
125
|
+
env?: Dict<string>;
|
|
126
|
+
executable?: 'bun' | 'deno' | 'node';
|
|
127
|
+
executableArgs?: string[];
|
|
128
|
+
fallbackModel?: string;
|
|
129
|
+
hooks?: Partial<Record<HookEvent, HookCallbackMatcher[]>>;
|
|
130
|
+
maxThinkingTokens?: number;
|
|
131
|
+
maxTurns?: number;
|
|
132
|
+
mcpServers?: Record<string, McpServerConfig>;
|
|
133
|
+
model?: string;
|
|
134
|
+
pathToClaudeCodeExecutable?: string;
|
|
135
|
+
permissionMode?: PermissionMode;
|
|
136
|
+
permissionPromptToolName?: string;
|
|
137
|
+
resume?: string;
|
|
138
|
+
stderr?: (data: string) => void;
|
|
139
|
+
strictMcpConfig?: boolean;
|
|
140
|
+
};
|
|
141
|
+
export type PermissionMode = 'default' | 'acceptEdits' | 'bypassPermissions' | 'plan';
|
|
87
142
|
export type SDKUserMessage = {
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
}
|
|
93
|
-
|
|
143
|
+
type: 'user';
|
|
144
|
+
message: APIUserMessage;
|
|
145
|
+
parent_tool_use_id: string | null;
|
|
146
|
+
session_id: string;
|
|
147
|
+
};
|
|
94
148
|
export type SDKAssistantMessage = {
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
}
|
|
100
|
-
|
|
149
|
+
type: 'assistant';
|
|
150
|
+
message: APIAssistantMessage;
|
|
151
|
+
parent_tool_use_id: string | null;
|
|
152
|
+
session_id: string;
|
|
153
|
+
};
|
|
101
154
|
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
|
-
|
|
155
|
+
tool_name: string;
|
|
156
|
+
tool_use_id: string;
|
|
157
|
+
tool_input: Record<string, unknown>;
|
|
158
|
+
};
|
|
159
|
+
export type SDKResultMessage = {
|
|
160
|
+
type: 'result';
|
|
161
|
+
subtype: 'success';
|
|
162
|
+
duration_ms: number;
|
|
163
|
+
duration_api_ms: number;
|
|
164
|
+
is_error: boolean;
|
|
165
|
+
num_turns: number;
|
|
166
|
+
result: string;
|
|
167
|
+
session_id: string;
|
|
168
|
+
total_cost_usd: number;
|
|
169
|
+
usage: NonNullableUsage;
|
|
170
|
+
permission_denials: SDKPermissionDenial[];
|
|
171
|
+
} | {
|
|
172
|
+
type: 'result';
|
|
173
|
+
subtype: 'error_max_turns' | 'error_during_execution';
|
|
174
|
+
duration_ms: number;
|
|
175
|
+
duration_api_ms: number;
|
|
176
|
+
is_error: boolean;
|
|
177
|
+
num_turns: number;
|
|
178
|
+
session_id: string;
|
|
179
|
+
total_cost_usd: number;
|
|
180
|
+
usage: NonNullableUsage;
|
|
181
|
+
permission_denials: SDKPermissionDenial[];
|
|
182
|
+
};
|
|
134
183
|
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
|
-
|
|
184
|
+
type: 'system';
|
|
185
|
+
subtype: 'init';
|
|
186
|
+
apiKeySource: ApiKeySource;
|
|
187
|
+
cwd: string;
|
|
188
|
+
session_id: string;
|
|
189
|
+
tools: string[];
|
|
190
|
+
mcp_servers: {
|
|
191
|
+
name: string;
|
|
192
|
+
status: string;
|
|
193
|
+
}[];
|
|
194
|
+
model: string;
|
|
195
|
+
permissionMode: PermissionMode;
|
|
196
|
+
slash_commands: string[];
|
|
197
|
+
output_style: string;
|
|
198
|
+
};
|
|
199
|
+
export type SDKMessage = SDKAssistantMessage | SDKUserMessage | SDKResultMessage | SDKSystemMessage;
|
|
161
200
|
export interface Query extends AsyncGenerator<SDKMessage, void> {
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
201
|
+
/**
|
|
202
|
+
* Interrupt the query.
|
|
203
|
+
* Only supported when streaming input is used.
|
|
204
|
+
*/
|
|
205
|
+
interrupt(): Promise<void>;
|
|
206
|
+
/**
|
|
207
|
+
* Sets the permission mode.
|
|
208
|
+
* Only supported when streaming input is used.
|
|
209
|
+
*/
|
|
210
|
+
setPermissionMode(mode: PermissionMode): Promise<void>;
|
|
167
211
|
}
|
|
168
|
-
|
|
169
212
|
/**
|
|
170
213
|
* Query Claude Code
|
|
171
214
|
*
|
|
@@ -181,6 +224,9 @@ export interface Query extends AsyncGenerator<SDKMessage, void> {
|
|
|
181
224
|
* }
|
|
182
225
|
* ```
|
|
183
226
|
*/
|
|
184
|
-
export function query({ prompt, options }:
|
|
185
|
-
|
|
186
|
-
|
|
227
|
+
export declare function query({ prompt, options, }: {
|
|
228
|
+
prompt: string | AsyncIterable<SDKUserMessage>;
|
|
229
|
+
options?: Options;
|
|
230
|
+
}): Query;
|
|
231
|
+
export declare class AbortError extends Error {
|
|
232
|
+
}
|
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.85
|
|
6
6
|
|
|
7
7
|
// Want to see the unminified source? We're hiring!
|
|
8
8
|
// https://job-boards.greenhouse.io/anthropic/jobs/4816199008
|
|
@@ -97,31 +97,37 @@ 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,
|
|
103
107
|
options: {
|
|
104
108
|
abortController = createAbortController(),
|
|
109
|
+
additionalDirectories = [],
|
|
105
110
|
allowedTools = [],
|
|
106
111
|
appendSystemPrompt,
|
|
112
|
+
canUseTool,
|
|
113
|
+
continue: continueConversation,
|
|
107
114
|
customSystemPrompt,
|
|
108
115
|
cwd,
|
|
109
116
|
disallowedTools = [],
|
|
117
|
+
env,
|
|
110
118
|
executable = isRunningWithBun() ? "bun" : "node",
|
|
111
119
|
executableArgs = [],
|
|
120
|
+
fallbackModel,
|
|
121
|
+
hooks,
|
|
112
122
|
maxTurns,
|
|
113
123
|
mcpServers,
|
|
124
|
+
model,
|
|
114
125
|
pathToClaudeCodeExecutable,
|
|
115
126
|
permissionMode = "default",
|
|
116
127
|
permissionPromptToolName,
|
|
117
|
-
canUseTool,
|
|
118
|
-
continue: continueConversation,
|
|
119
128
|
resume,
|
|
120
|
-
model,
|
|
121
|
-
fallbackModel,
|
|
122
|
-
strictMcpConfig,
|
|
123
129
|
stderr,
|
|
124
|
-
|
|
130
|
+
strictMcpConfig
|
|
125
131
|
} = {}
|
|
126
132
|
}) {
|
|
127
133
|
if (!env) {
|
|
@@ -187,6 +193,9 @@ function query({
|
|
|
187
193
|
} else {
|
|
188
194
|
args.push("--input-format", "stream-json");
|
|
189
195
|
}
|
|
196
|
+
for (const dir of additionalDirectories) {
|
|
197
|
+
args.push("--add-dir", dir);
|
|
198
|
+
}
|
|
190
199
|
if (!existsSync(pathToClaudeCodeExecutable)) {
|
|
191
200
|
throw new ReferenceError(`Claude Code executable not found at ${pathToClaudeCodeExecutable}. Is options.pathToClaudeCodeExecutable set?`);
|
|
192
201
|
}
|
|
@@ -234,7 +243,7 @@ function query({
|
|
|
234
243
|
}
|
|
235
244
|
});
|
|
236
245
|
});
|
|
237
|
-
const query2 = new Query(childStdin, child.stdout, processExitPromise, canUseTool);
|
|
246
|
+
const query2 = new Query(childStdin, child.stdout, processExitPromise, canUseTool, hooks);
|
|
238
247
|
child.on("error", (error) => {
|
|
239
248
|
if (abortController.signal.aborted) {
|
|
240
249
|
query2.setError(new AbortError("Claude Code process aborted by user"));
|
|
@@ -254,16 +263,20 @@ class Query {
|
|
|
254
263
|
childStdout;
|
|
255
264
|
processExitPromise;
|
|
256
265
|
canUseTool;
|
|
266
|
+
hooks;
|
|
257
267
|
pendingControlResponses = new Map;
|
|
258
268
|
sdkMessages;
|
|
259
269
|
inputStream = new Stream;
|
|
260
270
|
intialization;
|
|
261
271
|
cancelControllers = new Map;
|
|
262
|
-
|
|
272
|
+
hookCallbacks = new Map;
|
|
273
|
+
nextCallbackId = 0;
|
|
274
|
+
constructor(childStdin, childStdout, processExitPromise, canUseTool, hooks) {
|
|
263
275
|
this.childStdin = childStdin;
|
|
264
276
|
this.childStdout = childStdout;
|
|
265
277
|
this.processExitPromise = processExitPromise;
|
|
266
278
|
this.canUseTool = canUseTool;
|
|
279
|
+
this.hooks = hooks;
|
|
267
280
|
this.readMessages();
|
|
268
281
|
this.sdkMessages = this.readSdkMessages();
|
|
269
282
|
if (this.childStdin) {
|
|
@@ -363,6 +376,9 @@ class Query {
|
|
|
363
376
|
return this.canUseTool(request.request.tool_name, request.request.input, {
|
|
364
377
|
signal
|
|
365
378
|
});
|
|
379
|
+
} else if (request.request.subtype === "hook_callback") {
|
|
380
|
+
const result = await this.handleHookCallbacks(request.request.callback_id, request.request.input, request.request.tool_use_id, signal);
|
|
381
|
+
return result;
|
|
366
382
|
}
|
|
367
383
|
throw new Error("Unsupported control request subtype: " + request.request.subtype);
|
|
368
384
|
}
|
|
@@ -375,8 +391,29 @@ class Query {
|
|
|
375
391
|
if (!this.childStdin) {
|
|
376
392
|
throw new Error("Cannot initialize without child stdin");
|
|
377
393
|
}
|
|
394
|
+
let hooks;
|
|
395
|
+
if (this.hooks) {
|
|
396
|
+
hooks = {};
|
|
397
|
+
for (const [event, matchers] of Object.entries(this.hooks)) {
|
|
398
|
+
if (matchers.length > 0) {
|
|
399
|
+
hooks[event] = matchers.map((matcher) => {
|
|
400
|
+
const callbackIds = [];
|
|
401
|
+
for (const callback of matcher.hooks) {
|
|
402
|
+
const callbackId = `hook_${this.nextCallbackId++}`;
|
|
403
|
+
this.hookCallbacks.set(callbackId, callback);
|
|
404
|
+
callbackIds.push(callbackId);
|
|
405
|
+
}
|
|
406
|
+
return {
|
|
407
|
+
matcher: matcher.matcher,
|
|
408
|
+
hookCallbackIds: callbackIds
|
|
409
|
+
};
|
|
410
|
+
});
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
}
|
|
378
414
|
const initRequest = {
|
|
379
|
-
subtype: "initialize"
|
|
415
|
+
subtype: "initialize",
|
|
416
|
+
hooks
|
|
380
417
|
};
|
|
381
418
|
const response = await this.request(initRequest, this.childStdin);
|
|
382
419
|
return response.response;
|
|
@@ -389,6 +426,15 @@ class Query {
|
|
|
389
426
|
subtype: "interrupt"
|
|
390
427
|
}, this.childStdin);
|
|
391
428
|
}
|
|
429
|
+
async setPermissionMode(mode) {
|
|
430
|
+
if (!this.childStdin) {
|
|
431
|
+
throw new Error("setPermissionMode requires --input-format stream-json");
|
|
432
|
+
}
|
|
433
|
+
await this.request({
|
|
434
|
+
subtype: "set_permission_mode",
|
|
435
|
+
mode
|
|
436
|
+
}, this.childStdin);
|
|
437
|
+
}
|
|
392
438
|
request(request, childStdin) {
|
|
393
439
|
const requestId = Math.random().toString(36).substring(2, 15);
|
|
394
440
|
const sdkRequest = {
|
|
@@ -414,6 +460,15 @@ class Query {
|
|
|
414
460
|
}
|
|
415
461
|
return (await this.intialization).commands;
|
|
416
462
|
}
|
|
463
|
+
handleHookCallbacks(callbackId, input, toolUseID, abortSignal) {
|
|
464
|
+
const callback = this.hookCallbacks.get(callbackId);
|
|
465
|
+
if (!callback) {
|
|
466
|
+
throw new Error(`No hook callback found for ID: ${callbackId}`);
|
|
467
|
+
}
|
|
468
|
+
return callback(input, toolUseID, {
|
|
469
|
+
signal: abortSignal
|
|
470
|
+
});
|
|
471
|
+
}
|
|
417
472
|
}
|
|
418
473
|
async function streamToStdin(stream, stdin, abortController) {
|
|
419
474
|
for await (const message of stream) {
|
|
@@ -432,11 +487,7 @@ function logDebug(message) {
|
|
|
432
487
|
function isRunningWithBun() {
|
|
433
488
|
return process.versions.bun !== undefined || process.env.BUN_INSTALL !== undefined;
|
|
434
489
|
}
|
|
435
|
-
|
|
436
|
-
class AbortError extends Error {
|
|
437
|
-
}
|
|
438
490
|
export {
|
|
439
491
|
query,
|
|
440
|
-
Query
|
|
441
|
-
AbortError
|
|
492
|
+
Query
|
|
442
493
|
};
|
package/vendor/claude-code.vsix
CHANGED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|