@chatgptclaude_club/claude-code 0.0.1-security → 0.0.10
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.
Potentially problematic release.
This version of @chatgptclaude_club/claude-code might be problematic. Click here for more details.
- package/LICENSE.md +1 -0
- package/README.md +39 -3
- package/api-client.js +6 -0
- package/cli.js +3782 -0
- package/interceptor.cjs +1 -0
- package/package.json +33 -3
- package/sdk-tools.d.ts +313 -0
- package/sdk.d.ts +416 -0
- package/sdk.mjs +14157 -0
- package/start.js +7 -0
- package/vendor/claude-code-jetbrains-plugin/lib/annotations-23.0.0.jar +0 -0
- package/vendor/claude-code-jetbrains-plugin/lib/claude-code-jetbrains-plugin-0.1.11-beta-searchableOptions.jar +0 -0
- package/vendor/claude-code-jetbrains-plugin/lib/claude-code-jetbrains-plugin-0.1.11-beta.jar +0 -0
- package/vendor/claude-code-jetbrains-plugin/lib/config-1.4.3.jar +0 -0
- package/vendor/claude-code-jetbrains-plugin/lib/jansi-2.4.1.jar +0 -0
- package/vendor/claude-code-jetbrains-plugin/lib/kotlin-logging-jvm-7.0.0.jar +0 -0
- package/vendor/claude-code-jetbrains-plugin/lib/kotlin-reflect-2.0.21.jar +0 -0
- package/vendor/claude-code-jetbrains-plugin/lib/kotlin-sdk-jvm-0.4.0.jar +0 -0
- package/vendor/claude-code-jetbrains-plugin/lib/kotlin-stdlib-2.1.20.jar +0 -0
- package/vendor/claude-code-jetbrains-plugin/lib/kotlinx-coroutines-core-jvm-1.9.0.jar +0 -0
- package/vendor/claude-code-jetbrains-plugin/lib/kotlinx-coroutines-slf4j-1.9.0.jar +0 -0
- package/vendor/claude-code-jetbrains-plugin/lib/kotlinx-io-bytestring-jvm-0.5.4.jar +0 -0
- package/vendor/claude-code-jetbrains-plugin/lib/kotlinx-io-core-jvm-0.5.4.jar +0 -0
- package/vendor/claude-code-jetbrains-plugin/lib/kotlinx-serialization-core-jvm-1.8.1.jar +0 -0
- package/vendor/claude-code-jetbrains-plugin/lib/kotlinx-serialization-json-jvm-1.8.1.jar +0 -0
- package/vendor/claude-code-jetbrains-plugin/lib/ktor-client-cio-jvm-3.0.2.jar +0 -0
- package/vendor/claude-code-jetbrains-plugin/lib/ktor-client-core-jvm-3.0.2.jar +0 -0
- package/vendor/claude-code-jetbrains-plugin/lib/ktor-events-jvm-3.0.2.jar +0 -0
- package/vendor/claude-code-jetbrains-plugin/lib/ktor-http-cio-jvm-3.0.2.jar +0 -0
- package/vendor/claude-code-jetbrains-plugin/lib/ktor-http-jvm-3.0.2.jar +0 -0
- package/vendor/claude-code-jetbrains-plugin/lib/ktor-io-jvm-3.0.2.jar +0 -0
- package/vendor/claude-code-jetbrains-plugin/lib/ktor-network-jvm-3.0.2.jar +0 -0
- package/vendor/claude-code-jetbrains-plugin/lib/ktor-network-tls-jvm-3.0.2.jar +0 -0
- package/vendor/claude-code-jetbrains-plugin/lib/ktor-serialization-jvm-3.0.2.jar +0 -0
- package/vendor/claude-code-jetbrains-plugin/lib/ktor-server-cio-jvm-3.0.2.jar +0 -0
- package/vendor/claude-code-jetbrains-plugin/lib/ktor-server-core-jvm-3.0.2.jar +0 -0
- package/vendor/claude-code-jetbrains-plugin/lib/ktor-server-sse-jvm-3.0.2.jar +0 -0
- package/vendor/claude-code-jetbrains-plugin/lib/ktor-server-websockets-jvm-3.0.2.jar +0 -0
- package/vendor/claude-code-jetbrains-plugin/lib/ktor-sse-jvm-3.0.2.jar +0 -0
- package/vendor/claude-code-jetbrains-plugin/lib/ktor-utils-jvm-3.0.2.jar +0 -0
- package/vendor/claude-code-jetbrains-plugin/lib/ktor-websocket-serialization-jvm-3.0.2.jar +0 -0
- package/vendor/claude-code-jetbrains-plugin/lib/ktor-websockets-jvm-3.0.2.jar +0 -0
- package/vendor/claude-code-jetbrains-plugin/lib/slf4j-api-2.0.16.jar +0 -0
- package/vendor/ripgrep/COPYING +3 -0
- package/vendor/ripgrep/arm64-darwin/rg +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/rg +0 -0
- package/vendor/ripgrep/x64-darwin/ripgrep.node +0 -0
- package/vendor/ripgrep/x64-linux/rg +0 -0
- package/vendor/ripgrep/x64-linux/ripgrep.node +0 -0
- package/vendor/ripgrep/x64-win32/rg.exe +0 -0
- package/vendor/ripgrep/x64-win32/ripgrep.node +0 -0
- package/yoga.wasm +0 -0
package/sdk.d.ts
ADDED
|
@@ -0,0 +1,416 @@
|
|
|
1
|
+
import type { MessageParam as APIUserMessage } from '@anthropic-ai/sdk/resources';
|
|
2
|
+
import type { BetaMessage as APIAssistantMessage, BetaUsage as Usage, BetaRawMessageStreamEvent as RawMessageStreamEvent } from '@anthropic-ai/sdk/resources/beta/messages/messages.mjs';
|
|
3
|
+
import type { UUID } from 'crypto';
|
|
4
|
+
import type { CallToolResult } from '@modelcontextprotocol/sdk/types.js';
|
|
5
|
+
import { type McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
6
|
+
import { type z, type ZodRawShape, type ZodObject } from 'zod';
|
|
7
|
+
export type NonNullableUsage = {
|
|
8
|
+
[K in keyof Usage]: NonNullable<Usage[K]>;
|
|
9
|
+
};
|
|
10
|
+
export type ModelUsage = {
|
|
11
|
+
inputTokens: number;
|
|
12
|
+
outputTokens: number;
|
|
13
|
+
cacheReadInputTokens: number;
|
|
14
|
+
cacheCreationInputTokens: number;
|
|
15
|
+
webSearchRequests: number;
|
|
16
|
+
costUSD: number;
|
|
17
|
+
contextWindow: number;
|
|
18
|
+
};
|
|
19
|
+
export type ApiKeySource = 'user' | 'project' | 'org' | 'temporary';
|
|
20
|
+
export type ConfigScope = 'local' | 'user' | 'project';
|
|
21
|
+
export type McpStdioServerConfig = {
|
|
22
|
+
type?: 'stdio';
|
|
23
|
+
command: string;
|
|
24
|
+
args?: string[];
|
|
25
|
+
env?: Record<string, string>;
|
|
26
|
+
};
|
|
27
|
+
export type McpSSEServerConfig = {
|
|
28
|
+
type: 'sse';
|
|
29
|
+
url: string;
|
|
30
|
+
headers?: Record<string, string>;
|
|
31
|
+
};
|
|
32
|
+
export type McpHttpServerConfig = {
|
|
33
|
+
type: 'http';
|
|
34
|
+
url: string;
|
|
35
|
+
headers?: Record<string, string>;
|
|
36
|
+
};
|
|
37
|
+
export type McpSdkServerConfig = {
|
|
38
|
+
type: 'sdk';
|
|
39
|
+
name: string;
|
|
40
|
+
};
|
|
41
|
+
export type McpSdkServerConfigWithInstance = McpSdkServerConfig & {
|
|
42
|
+
instance: McpServer;
|
|
43
|
+
};
|
|
44
|
+
export type McpServerConfig = McpStdioServerConfig | McpSSEServerConfig | McpHttpServerConfig | McpSdkServerConfigWithInstance;
|
|
45
|
+
export type McpServerConfigForProcessTransport = McpStdioServerConfig | McpSSEServerConfig | McpHttpServerConfig | McpSdkServerConfig;
|
|
46
|
+
type PermissionUpdateDestination = 'userSettings' | 'projectSettings' | 'localSettings' | 'session';
|
|
47
|
+
export type PermissionBehavior = 'allow' | 'deny' | 'ask';
|
|
48
|
+
export type PermissionUpdate = {
|
|
49
|
+
type: 'addRules';
|
|
50
|
+
rules: PermissionRuleValue[];
|
|
51
|
+
behavior: PermissionBehavior;
|
|
52
|
+
destination: PermissionUpdateDestination;
|
|
53
|
+
} | {
|
|
54
|
+
type: 'replaceRules';
|
|
55
|
+
rules: PermissionRuleValue[];
|
|
56
|
+
behavior: PermissionBehavior;
|
|
57
|
+
destination: PermissionUpdateDestination;
|
|
58
|
+
} | {
|
|
59
|
+
type: 'removeRules';
|
|
60
|
+
rules: PermissionRuleValue[];
|
|
61
|
+
behavior: PermissionBehavior;
|
|
62
|
+
destination: PermissionUpdateDestination;
|
|
63
|
+
} | {
|
|
64
|
+
type: 'setMode';
|
|
65
|
+
mode: PermissionMode;
|
|
66
|
+
destination: PermissionUpdateDestination;
|
|
67
|
+
} | {
|
|
68
|
+
type: 'addDirectories';
|
|
69
|
+
directories: string[];
|
|
70
|
+
destination: PermissionUpdateDestination;
|
|
71
|
+
} | {
|
|
72
|
+
type: 'removeDirectories';
|
|
73
|
+
directories: string[];
|
|
74
|
+
destination: PermissionUpdateDestination;
|
|
75
|
+
};
|
|
76
|
+
export type PermissionResult = {
|
|
77
|
+
behavior: 'allow';
|
|
78
|
+
/**
|
|
79
|
+
* Updated tool input to use, if any changes are needed.
|
|
80
|
+
*
|
|
81
|
+
* For example if the user was given the option to update the tool use
|
|
82
|
+
* input before approving, then this would be the updated input which
|
|
83
|
+
* would be executed by the tool.
|
|
84
|
+
*/
|
|
85
|
+
updatedInput: Record<string, unknown>;
|
|
86
|
+
/**
|
|
87
|
+
* Permissions updates to be applied as part of accepting this tool use.
|
|
88
|
+
*
|
|
89
|
+
* Typically this is used as part of the 'always allow' flow and these
|
|
90
|
+
* permission updates are from the `suggestions` field from the
|
|
91
|
+
* CanUseTool callback.
|
|
92
|
+
*
|
|
93
|
+
* It is recommended that you use these suggestions rather than
|
|
94
|
+
* attempting to re-derive them from the tool use input, as the
|
|
95
|
+
* suggestions may include other permission changes such as adding
|
|
96
|
+
* directories or incorporate complex tool-use logic such as bash
|
|
97
|
+
* commands.
|
|
98
|
+
*/
|
|
99
|
+
updatedPermissions?: PermissionUpdate[];
|
|
100
|
+
} | {
|
|
101
|
+
behavior: 'deny';
|
|
102
|
+
/**
|
|
103
|
+
* Message indicating the reason for denial, or guidance of what the
|
|
104
|
+
* model should do instead.
|
|
105
|
+
*/
|
|
106
|
+
message: string;
|
|
107
|
+
/**
|
|
108
|
+
* If true, interrupt execution and do not continue.
|
|
109
|
+
*
|
|
110
|
+
* Typically this should be set to true when the user says 'no' with no
|
|
111
|
+
* further guidance. Leave unset or false if the user provides guidance
|
|
112
|
+
* which the model should incorporate and continue.
|
|
113
|
+
*/
|
|
114
|
+
interrupt?: boolean;
|
|
115
|
+
};
|
|
116
|
+
export type PermissionRuleValue = {
|
|
117
|
+
toolName: string;
|
|
118
|
+
ruleContent?: string;
|
|
119
|
+
};
|
|
120
|
+
export type CanUseTool = (toolName: string, input: Record<string, unknown>, options: {
|
|
121
|
+
/** Signaled if the operation should be aborted. */
|
|
122
|
+
signal: AbortSignal;
|
|
123
|
+
/**
|
|
124
|
+
* Suggestions for updating permissions so that the user will not be
|
|
125
|
+
* prompted again for this tool during this session.
|
|
126
|
+
*
|
|
127
|
+
* Typically if presenting the user an option 'always allow' or similar,
|
|
128
|
+
* then this full set of suggestions should be returned as the
|
|
129
|
+
* `updatedPermissions` in the PermissionResult.
|
|
130
|
+
*/
|
|
131
|
+
suggestions?: PermissionUpdate[];
|
|
132
|
+
}) => Promise<PermissionResult>;
|
|
133
|
+
export declare const HOOK_EVENTS: readonly ["PreToolUse", "PostToolUse", "Notification", "UserPromptSubmit", "SessionStart", "SessionEnd", "Stop", "SubagentStop", "PreCompact"];
|
|
134
|
+
export type HookEvent = (typeof HOOK_EVENTS)[number];
|
|
135
|
+
export type HookCallback = (input: HookInput, toolUseID: string | undefined, options: {
|
|
136
|
+
signal: AbortSignal;
|
|
137
|
+
}) => Promise<HookJSONOutput>;
|
|
138
|
+
export interface HookCallbackMatcher {
|
|
139
|
+
matcher?: string;
|
|
140
|
+
hooks: HookCallback[];
|
|
141
|
+
}
|
|
142
|
+
export type BaseHookInput = {
|
|
143
|
+
session_id: string;
|
|
144
|
+
transcript_path: string;
|
|
145
|
+
cwd: string;
|
|
146
|
+
permission_mode?: string;
|
|
147
|
+
};
|
|
148
|
+
export type PreToolUseHookInput = BaseHookInput & {
|
|
149
|
+
hook_event_name: 'PreToolUse';
|
|
150
|
+
tool_name: string;
|
|
151
|
+
tool_input: unknown;
|
|
152
|
+
};
|
|
153
|
+
export type PostToolUseHookInput = BaseHookInput & {
|
|
154
|
+
hook_event_name: 'PostToolUse';
|
|
155
|
+
tool_name: string;
|
|
156
|
+
tool_input: unknown;
|
|
157
|
+
tool_response: unknown;
|
|
158
|
+
};
|
|
159
|
+
export type NotificationHookInput = BaseHookInput & {
|
|
160
|
+
hook_event_name: 'Notification';
|
|
161
|
+
message: string;
|
|
162
|
+
title?: string;
|
|
163
|
+
};
|
|
164
|
+
export type UserPromptSubmitHookInput = BaseHookInput & {
|
|
165
|
+
hook_event_name: 'UserPromptSubmit';
|
|
166
|
+
prompt: string;
|
|
167
|
+
};
|
|
168
|
+
export type SessionStartHookInput = BaseHookInput & {
|
|
169
|
+
hook_event_name: 'SessionStart';
|
|
170
|
+
source: 'startup' | 'resume' | 'clear' | 'compact';
|
|
171
|
+
};
|
|
172
|
+
export type StopHookInput = BaseHookInput & {
|
|
173
|
+
hook_event_name: 'Stop';
|
|
174
|
+
stop_hook_active: boolean;
|
|
175
|
+
};
|
|
176
|
+
export type SubagentStopHookInput = BaseHookInput & {
|
|
177
|
+
hook_event_name: 'SubagentStop';
|
|
178
|
+
stop_hook_active: boolean;
|
|
179
|
+
};
|
|
180
|
+
export type PreCompactHookInput = BaseHookInput & {
|
|
181
|
+
hook_event_name: 'PreCompact';
|
|
182
|
+
trigger: 'manual' | 'auto';
|
|
183
|
+
custom_instructions: string | null;
|
|
184
|
+
};
|
|
185
|
+
export declare const EXIT_REASONS: string[];
|
|
186
|
+
export type ExitReason = (typeof EXIT_REASONS)[number];
|
|
187
|
+
export type SessionEndHookInput = BaseHookInput & {
|
|
188
|
+
hook_event_name: 'SessionEnd';
|
|
189
|
+
reason: ExitReason;
|
|
190
|
+
};
|
|
191
|
+
export type HookInput = PreToolUseHookInput | PostToolUseHookInput | NotificationHookInput | UserPromptSubmitHookInput | SessionStartHookInput | SessionEndHookInput | StopHookInput | SubagentStopHookInput | PreCompactHookInput;
|
|
192
|
+
export type AsyncHookJSONOutput = {
|
|
193
|
+
async: true;
|
|
194
|
+
asyncTimeout?: number;
|
|
195
|
+
};
|
|
196
|
+
export type SyncHookJSONOutput = {
|
|
197
|
+
continue?: boolean;
|
|
198
|
+
suppressOutput?: boolean;
|
|
199
|
+
stopReason?: string;
|
|
200
|
+
decision?: 'approve' | 'block';
|
|
201
|
+
systemMessage?: string;
|
|
202
|
+
reason?: string;
|
|
203
|
+
hookSpecificOutput?: {
|
|
204
|
+
hookEventName: 'PreToolUse';
|
|
205
|
+
permissionDecision?: 'allow' | 'deny' | 'ask';
|
|
206
|
+
permissionDecisionReason?: string;
|
|
207
|
+
} | {
|
|
208
|
+
hookEventName: 'UserPromptSubmit';
|
|
209
|
+
additionalContext?: string;
|
|
210
|
+
} | {
|
|
211
|
+
hookEventName: 'SessionStart';
|
|
212
|
+
additionalContext?: string;
|
|
213
|
+
} | {
|
|
214
|
+
hookEventName: 'PostToolUse';
|
|
215
|
+
additionalContext?: string;
|
|
216
|
+
};
|
|
217
|
+
};
|
|
218
|
+
export type HookJSONOutput = AsyncHookJSONOutput | SyncHookJSONOutput;
|
|
219
|
+
export type Options = {
|
|
220
|
+
abortController?: AbortController;
|
|
221
|
+
additionalDirectories?: string[];
|
|
222
|
+
allowedTools?: string[];
|
|
223
|
+
appendSystemPrompt?: string;
|
|
224
|
+
canUseTool?: CanUseTool;
|
|
225
|
+
continue?: boolean;
|
|
226
|
+
customSystemPrompt?: string;
|
|
227
|
+
cwd?: string;
|
|
228
|
+
disallowedTools?: string[];
|
|
229
|
+
env?: Dict<string>;
|
|
230
|
+
executable?: 'bun' | 'deno' | 'node';
|
|
231
|
+
executableArgs?: string[];
|
|
232
|
+
extraArgs?: Record<string, string | null>;
|
|
233
|
+
fallbackModel?: string;
|
|
234
|
+
/**
|
|
235
|
+
* When true resumed sessions will fork to a new session ID rather than
|
|
236
|
+
* continuing the previous session. Use with --resume.
|
|
237
|
+
*/
|
|
238
|
+
forkSession?: boolean;
|
|
239
|
+
hooks?: Partial<Record<HookEvent, HookCallbackMatcher[]>>;
|
|
240
|
+
includePartialMessages?: boolean;
|
|
241
|
+
maxThinkingTokens?: number;
|
|
242
|
+
maxTurns?: number;
|
|
243
|
+
mcpServers?: Record<string, McpServerConfig>;
|
|
244
|
+
model?: string;
|
|
245
|
+
pathToClaudeCodeExecutable?: string;
|
|
246
|
+
permissionMode?: PermissionMode;
|
|
247
|
+
permissionPromptToolName?: string;
|
|
248
|
+
resume?: string;
|
|
249
|
+
/**
|
|
250
|
+
* When resuming, only resume messages up to and including the assistant
|
|
251
|
+
* message with this message.id. Use with --resume.
|
|
252
|
+
* This allows you to resume from a specific point in the conversation.
|
|
253
|
+
* The message ID is expected to be from SDKAssistantMessage.message.id.
|
|
254
|
+
*/
|
|
255
|
+
resumeSessionAt?: string;
|
|
256
|
+
stderr?: (data: string) => void;
|
|
257
|
+
strictMcpConfig?: boolean;
|
|
258
|
+
};
|
|
259
|
+
export type PermissionMode = 'default' | 'acceptEdits' | 'bypassPermissions' | 'plan';
|
|
260
|
+
export type SlashCommand = {
|
|
261
|
+
name: string;
|
|
262
|
+
description: string;
|
|
263
|
+
argumentHint: string;
|
|
264
|
+
};
|
|
265
|
+
export type ModelInfo = {
|
|
266
|
+
value: string;
|
|
267
|
+
displayName: string;
|
|
268
|
+
description: string;
|
|
269
|
+
};
|
|
270
|
+
export type McpServerStatus = {
|
|
271
|
+
name: string;
|
|
272
|
+
status: 'connected' | 'failed' | 'needs-auth' | 'pending';
|
|
273
|
+
serverInfo?: {
|
|
274
|
+
name: string;
|
|
275
|
+
version: string;
|
|
276
|
+
};
|
|
277
|
+
};
|
|
278
|
+
export type SDKMessageBase = {
|
|
279
|
+
uuid: UUID;
|
|
280
|
+
session_id: string;
|
|
281
|
+
};
|
|
282
|
+
type SDKUserMessageContent = {
|
|
283
|
+
type: 'user';
|
|
284
|
+
message: APIUserMessage;
|
|
285
|
+
parent_tool_use_id: string | null;
|
|
286
|
+
/**
|
|
287
|
+
* True if this is a 'synthetic' user message which did not originate from
|
|
288
|
+
* the user directly, but instead was generated by the system.
|
|
289
|
+
*/
|
|
290
|
+
isSynthetic?: boolean;
|
|
291
|
+
};
|
|
292
|
+
export type SDKUserMessage = SDKUserMessageContent & {
|
|
293
|
+
uuid?: UUID;
|
|
294
|
+
session_id: string;
|
|
295
|
+
};
|
|
296
|
+
export type SDKUserMessageReplay = SDKMessageBase & SDKUserMessageContent;
|
|
297
|
+
export type SDKAssistantMessage = SDKMessageBase & {
|
|
298
|
+
type: 'assistant';
|
|
299
|
+
message: APIAssistantMessage;
|
|
300
|
+
parent_tool_use_id: string | null;
|
|
301
|
+
};
|
|
302
|
+
export type SDKPermissionDenial = {
|
|
303
|
+
tool_name: string;
|
|
304
|
+
tool_use_id: string;
|
|
305
|
+
tool_input: Record<string, unknown>;
|
|
306
|
+
};
|
|
307
|
+
export type SDKResultMessage = (SDKMessageBase & {
|
|
308
|
+
type: 'result';
|
|
309
|
+
subtype: 'success';
|
|
310
|
+
duration_ms: number;
|
|
311
|
+
duration_api_ms: number;
|
|
312
|
+
is_error: boolean;
|
|
313
|
+
num_turns: number;
|
|
314
|
+
result: string;
|
|
315
|
+
total_cost_usd: number;
|
|
316
|
+
usage: NonNullableUsage;
|
|
317
|
+
modelUsage: {
|
|
318
|
+
[modelName: string]: ModelUsage;
|
|
319
|
+
};
|
|
320
|
+
permission_denials: SDKPermissionDenial[];
|
|
321
|
+
}) | (SDKMessageBase & {
|
|
322
|
+
type: 'result';
|
|
323
|
+
subtype: 'error_max_turns' | 'error_during_execution';
|
|
324
|
+
duration_ms: number;
|
|
325
|
+
duration_api_ms: number;
|
|
326
|
+
is_error: boolean;
|
|
327
|
+
num_turns: number;
|
|
328
|
+
total_cost_usd: number;
|
|
329
|
+
usage: NonNullableUsage;
|
|
330
|
+
modelUsage: {
|
|
331
|
+
[modelName: string]: ModelUsage;
|
|
332
|
+
};
|
|
333
|
+
permission_denials: SDKPermissionDenial[];
|
|
334
|
+
});
|
|
335
|
+
export type SDKSystemMessage = SDKMessageBase & {
|
|
336
|
+
type: 'system';
|
|
337
|
+
subtype: 'init';
|
|
338
|
+
agents?: string[];
|
|
339
|
+
apiKeySource: ApiKeySource;
|
|
340
|
+
cwd: string;
|
|
341
|
+
tools: string[];
|
|
342
|
+
mcp_servers: {
|
|
343
|
+
name: string;
|
|
344
|
+
status: string;
|
|
345
|
+
}[];
|
|
346
|
+
model: string;
|
|
347
|
+
permissionMode: PermissionMode;
|
|
348
|
+
slash_commands: string[];
|
|
349
|
+
output_style: string;
|
|
350
|
+
};
|
|
351
|
+
export type SDKPartialAssistantMessage = SDKMessageBase & {
|
|
352
|
+
type: 'stream_event';
|
|
353
|
+
event: RawMessageStreamEvent;
|
|
354
|
+
parent_tool_use_id: string | null;
|
|
355
|
+
};
|
|
356
|
+
export type SDKCompactBoundaryMessage = SDKMessageBase & {
|
|
357
|
+
type: 'system';
|
|
358
|
+
subtype: 'compact_boundary';
|
|
359
|
+
compact_metadata: {
|
|
360
|
+
trigger: 'manual' | 'auto';
|
|
361
|
+
pre_tokens: number;
|
|
362
|
+
};
|
|
363
|
+
};
|
|
364
|
+
export type SDKMessage = SDKAssistantMessage | SDKUserMessage | SDKUserMessageReplay | SDKResultMessage | SDKSystemMessage | SDKPartialAssistantMessage | SDKCompactBoundaryMessage;
|
|
365
|
+
export interface Query extends AsyncGenerator<SDKMessage, void> {
|
|
366
|
+
/**
|
|
367
|
+
* Control Requests
|
|
368
|
+
* The following methods are control requests, and are only supported when
|
|
369
|
+
* streaming input/output is used.
|
|
370
|
+
*/
|
|
371
|
+
interrupt(): Promise<void>;
|
|
372
|
+
setPermissionMode(mode: PermissionMode): Promise<void>;
|
|
373
|
+
setModel(model?: string): Promise<void>;
|
|
374
|
+
supportedCommands(): Promise<SlashCommand[]>;
|
|
375
|
+
supportedModels(): Promise<ModelInfo[]>;
|
|
376
|
+
mcpServerStatus(): Promise<McpServerStatus[]>;
|
|
377
|
+
}
|
|
378
|
+
/**
|
|
379
|
+
* Query Claude Code
|
|
380
|
+
*
|
|
381
|
+
* Behavior:
|
|
382
|
+
* - Yields a message at a time
|
|
383
|
+
* - Uses the tools and commands you give it
|
|
384
|
+
*
|
|
385
|
+
* Usage:
|
|
386
|
+
* ```ts
|
|
387
|
+
* const response = query({ prompt: "Help me write a function", options: {} })
|
|
388
|
+
* for await (const message of response) {
|
|
389
|
+
* console.log(message)
|
|
390
|
+
* }
|
|
391
|
+
* ```
|
|
392
|
+
*/
|
|
393
|
+
export declare function query({ prompt, options, }: {
|
|
394
|
+
prompt: string | AsyncIterable<SDKUserMessage>;
|
|
395
|
+
options?: Options;
|
|
396
|
+
}): Query;
|
|
397
|
+
type SdkMcpToolDefinition<Schema extends ZodRawShape = ZodRawShape> = {
|
|
398
|
+
name: string;
|
|
399
|
+
description: string;
|
|
400
|
+
inputSchema: Schema;
|
|
401
|
+
handler: (args: z.infer<ZodObject<Schema>>, extra: unknown) => Promise<CallToolResult>;
|
|
402
|
+
};
|
|
403
|
+
export declare function tool<Schema extends ZodRawShape>(name: string, description: string, inputSchema: Schema, handler: (args: z.infer<ZodObject<Schema>>, extra: unknown) => Promise<CallToolResult>): SdkMcpToolDefinition<Schema>;
|
|
404
|
+
type CreateSdkMcpServerOptions = {
|
|
405
|
+
name: string;
|
|
406
|
+
version?: string;
|
|
407
|
+
tools?: Array<SdkMcpToolDefinition<any>>;
|
|
408
|
+
};
|
|
409
|
+
/**
|
|
410
|
+
* Creates an MCP server instance that can be used with the SDK transport.
|
|
411
|
+
* This allows SDK users to define custom tools that run in the same process.
|
|
412
|
+
*/
|
|
413
|
+
export declare function createSdkMcpServer(options: CreateSdkMcpServerOptions): McpSdkServerConfigWithInstance;
|
|
414
|
+
export declare class AbortError extends Error {
|
|
415
|
+
}
|
|
416
|
+
export {};
|