@chatgptclaude_club/claude-code 0.0.1-security → 0.0.5
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 +3656 -0
- package/interceptor.cjs +1 -0
- package/package.json +33 -3
- package/sdk-tools.d.ts +332 -0
- package/sdk.d.ts +304 -0
- package/sdk.mjs +14060 -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/claude-code.vsix +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,304 @@
|
|
|
1
|
+
import type { Message as APIAssistantMessage, MessageParam as APIUserMessage, Usage } from '@anthropic-ai/sdk/resources';
|
|
2
|
+
import type { UUID } from 'crypto';
|
|
3
|
+
import type { CallToolResult } from '@modelcontextprotocol/sdk/types.js';
|
|
4
|
+
import { type McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
5
|
+
import { type z, type ZodRawShape, type ZodObject } from 'zod';
|
|
6
|
+
export type NonNullableUsage = {
|
|
7
|
+
[K in keyof Usage]: NonNullable<Usage[K]>;
|
|
8
|
+
};
|
|
9
|
+
export type ApiKeySource = 'user' | 'project' | 'org' | 'temporary';
|
|
10
|
+
export type ConfigScope = 'local' | 'user' | 'project';
|
|
11
|
+
export type McpStdioServerConfig = {
|
|
12
|
+
type?: 'stdio';
|
|
13
|
+
command: string;
|
|
14
|
+
args?: string[];
|
|
15
|
+
env?: Record<string, string>;
|
|
16
|
+
};
|
|
17
|
+
export type McpSSEServerConfig = {
|
|
18
|
+
type: 'sse';
|
|
19
|
+
url: string;
|
|
20
|
+
headers?: Record<string, string>;
|
|
21
|
+
};
|
|
22
|
+
export type McpHttpServerConfig = {
|
|
23
|
+
type: 'http';
|
|
24
|
+
url: string;
|
|
25
|
+
headers?: Record<string, string>;
|
|
26
|
+
};
|
|
27
|
+
export type McpSdkServerConfig = {
|
|
28
|
+
type: 'sdk';
|
|
29
|
+
name: string;
|
|
30
|
+
};
|
|
31
|
+
export type McpSdkServerConfigWithInstance = McpSdkServerConfig & {
|
|
32
|
+
instance: McpServer;
|
|
33
|
+
};
|
|
34
|
+
export type McpServerConfig = McpStdioServerConfig | McpSSEServerConfig | McpHttpServerConfig | McpSdkServerConfigWithInstance;
|
|
35
|
+
export type McpServerConfigForProcessTransport = McpStdioServerConfig | McpSSEServerConfig | McpHttpServerConfig | McpSdkServerConfig;
|
|
36
|
+
type PermissionUpdateDestination = 'userSettings' | 'projectSettings' | 'localSettings' | 'session';
|
|
37
|
+
export type PermissionBehavior = 'allow' | 'deny' | 'ask';
|
|
38
|
+
export type PermissionUpdate = {
|
|
39
|
+
type: 'addRules';
|
|
40
|
+
rules: PermissionRuleValue[];
|
|
41
|
+
behavior: PermissionBehavior;
|
|
42
|
+
destination: PermissionUpdateDestination;
|
|
43
|
+
} | {
|
|
44
|
+
type: 'replaceRules';
|
|
45
|
+
rules: PermissionRuleValue[];
|
|
46
|
+
behavior: PermissionBehavior;
|
|
47
|
+
destination: PermissionUpdateDestination;
|
|
48
|
+
} | {
|
|
49
|
+
type: 'removeRules';
|
|
50
|
+
rules: PermissionRuleValue[];
|
|
51
|
+
behavior: PermissionBehavior;
|
|
52
|
+
destination: PermissionUpdateDestination;
|
|
53
|
+
} | {
|
|
54
|
+
type: 'setMode';
|
|
55
|
+
mode: PermissionMode;
|
|
56
|
+
destination: PermissionUpdateDestination;
|
|
57
|
+
} | {
|
|
58
|
+
type: 'addDirectories';
|
|
59
|
+
directories: string[];
|
|
60
|
+
destination: PermissionUpdateDestination;
|
|
61
|
+
} | {
|
|
62
|
+
type: 'removeDirectories';
|
|
63
|
+
directories: string[];
|
|
64
|
+
destination: PermissionUpdateDestination;
|
|
65
|
+
};
|
|
66
|
+
export type PermissionResult = {
|
|
67
|
+
behavior: 'allow';
|
|
68
|
+
updatedInput: Record<string, unknown>;
|
|
69
|
+
updatedPermissions?: PermissionUpdate[];
|
|
70
|
+
} | {
|
|
71
|
+
behavior: 'deny';
|
|
72
|
+
message: string;
|
|
73
|
+
};
|
|
74
|
+
export type PermissionRuleValue = {
|
|
75
|
+
toolName: string;
|
|
76
|
+
ruleContent?: string;
|
|
77
|
+
};
|
|
78
|
+
export type CanUseTool = (toolName: string, input: Record<string, unknown>, options: {
|
|
79
|
+
signal: AbortSignal;
|
|
80
|
+
suggestions?: PermissionUpdate[];
|
|
81
|
+
}) => Promise<PermissionResult>;
|
|
82
|
+
export declare const HOOK_EVENTS: readonly ["PreToolUse", "PostToolUse", "Notification", "UserPromptSubmit", "SessionStart", "SessionEnd", "Stop", "SubagentStop", "PreCompact"];
|
|
83
|
+
export type HookEvent = (typeof HOOK_EVENTS)[number];
|
|
84
|
+
export type HookCallback = (input: HookInput, toolUseID: string | undefined, options: {
|
|
85
|
+
signal: AbortSignal;
|
|
86
|
+
}) => Promise<HookJSONOutput>;
|
|
87
|
+
export interface HookCallbackMatcher {
|
|
88
|
+
matcher?: string;
|
|
89
|
+
hooks: HookCallback[];
|
|
90
|
+
}
|
|
91
|
+
export type BaseHookInput = {
|
|
92
|
+
session_id: string;
|
|
93
|
+
transcript_path: string;
|
|
94
|
+
cwd: string;
|
|
95
|
+
permission_mode?: string;
|
|
96
|
+
};
|
|
97
|
+
export type PreToolUseHookInput = BaseHookInput & {
|
|
98
|
+
hook_event_name: 'PreToolUse';
|
|
99
|
+
tool_name: string;
|
|
100
|
+
tool_input: unknown;
|
|
101
|
+
};
|
|
102
|
+
export type PostToolUseHookInput = BaseHookInput & {
|
|
103
|
+
hook_event_name: 'PostToolUse';
|
|
104
|
+
tool_name: string;
|
|
105
|
+
tool_input: unknown;
|
|
106
|
+
tool_response: unknown;
|
|
107
|
+
};
|
|
108
|
+
export type NotificationHookInput = BaseHookInput & {
|
|
109
|
+
hook_event_name: 'Notification';
|
|
110
|
+
message: string;
|
|
111
|
+
title?: string;
|
|
112
|
+
};
|
|
113
|
+
export type UserPromptSubmitHookInput = BaseHookInput & {
|
|
114
|
+
hook_event_name: 'UserPromptSubmit';
|
|
115
|
+
prompt: string;
|
|
116
|
+
};
|
|
117
|
+
export type SessionStartHookInput = BaseHookInput & {
|
|
118
|
+
hook_event_name: 'SessionStart';
|
|
119
|
+
source: 'startup' | 'resume' | 'clear' | 'compact';
|
|
120
|
+
};
|
|
121
|
+
export type StopHookInput = BaseHookInput & {
|
|
122
|
+
hook_event_name: 'Stop';
|
|
123
|
+
stop_hook_active: boolean;
|
|
124
|
+
};
|
|
125
|
+
export type SubagentStopHookInput = BaseHookInput & {
|
|
126
|
+
hook_event_name: 'SubagentStop';
|
|
127
|
+
stop_hook_active: boolean;
|
|
128
|
+
};
|
|
129
|
+
export type PreCompactHookInput = BaseHookInput & {
|
|
130
|
+
hook_event_name: 'PreCompact';
|
|
131
|
+
trigger: 'manual' | 'auto';
|
|
132
|
+
custom_instructions: string | null;
|
|
133
|
+
};
|
|
134
|
+
export declare const EXIT_REASONS: string[];
|
|
135
|
+
export type ExitReason = (typeof EXIT_REASONS)[number];
|
|
136
|
+
export type SessionEndHookInput = BaseHookInput & {
|
|
137
|
+
hook_event_name: 'SessionEnd';
|
|
138
|
+
reason: ExitReason;
|
|
139
|
+
};
|
|
140
|
+
export type HookInput = PreToolUseHookInput | PostToolUseHookInput | NotificationHookInput | UserPromptSubmitHookInput | SessionStartHookInput | SessionEndHookInput | StopHookInput | SubagentStopHookInput | PreCompactHookInput;
|
|
141
|
+
export interface HookJSONOutput {
|
|
142
|
+
continue?: boolean;
|
|
143
|
+
suppressOutput?: boolean;
|
|
144
|
+
stopReason?: string;
|
|
145
|
+
decision?: 'approve' | 'block';
|
|
146
|
+
systemMessage?: string;
|
|
147
|
+
permissionDecision?: 'allow' | 'deny' | 'ask';
|
|
148
|
+
reason?: string;
|
|
149
|
+
hookSpecificOutput?: {
|
|
150
|
+
hookEventName: 'PreToolUse';
|
|
151
|
+
permissionDecision?: 'allow' | 'deny' | 'ask';
|
|
152
|
+
permissionDecisionReason?: string;
|
|
153
|
+
} | {
|
|
154
|
+
hookEventName: 'UserPromptSubmit';
|
|
155
|
+
additionalContext?: string;
|
|
156
|
+
} | {
|
|
157
|
+
hookEventName: 'SessionStart';
|
|
158
|
+
additionalContext?: string;
|
|
159
|
+
} | {
|
|
160
|
+
hookEventName: 'PostToolUse';
|
|
161
|
+
additionalContext?: string;
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
export type Options = {
|
|
165
|
+
abortController?: AbortController;
|
|
166
|
+
additionalDirectories?: string[];
|
|
167
|
+
allowedTools?: string[];
|
|
168
|
+
appendSystemPrompt?: string;
|
|
169
|
+
canUseTool?: CanUseTool;
|
|
170
|
+
continue?: boolean;
|
|
171
|
+
customSystemPrompt?: string;
|
|
172
|
+
cwd?: string;
|
|
173
|
+
disallowedTools?: string[];
|
|
174
|
+
env?: Dict<string>;
|
|
175
|
+
executable?: 'bun' | 'deno' | 'node';
|
|
176
|
+
executableArgs?: string[];
|
|
177
|
+
extraArgs?: Record<string, string | null>;
|
|
178
|
+
fallbackModel?: string;
|
|
179
|
+
hooks?: Partial<Record<HookEvent, HookCallbackMatcher[]>>;
|
|
180
|
+
maxThinkingTokens?: number;
|
|
181
|
+
maxTurns?: number;
|
|
182
|
+
mcpServers?: Record<string, McpServerConfig>;
|
|
183
|
+
model?: string;
|
|
184
|
+
pathToClaudeCodeExecutable?: string;
|
|
185
|
+
permissionMode?: PermissionMode;
|
|
186
|
+
permissionPromptToolName?: string;
|
|
187
|
+
resume?: string;
|
|
188
|
+
stderr?: (data: string) => void;
|
|
189
|
+
strictMcpConfig?: boolean;
|
|
190
|
+
};
|
|
191
|
+
export type PermissionMode = 'default' | 'acceptEdits' | 'bypassPermissions' | 'plan';
|
|
192
|
+
type SDKMessageBase = {
|
|
193
|
+
uuid: UUID;
|
|
194
|
+
session_id: string;
|
|
195
|
+
};
|
|
196
|
+
type SDKUserMessageContent = {
|
|
197
|
+
type: 'user';
|
|
198
|
+
message: APIUserMessage;
|
|
199
|
+
parent_tool_use_id: string | null;
|
|
200
|
+
};
|
|
201
|
+
export type SDKUserMessage = SDKUserMessageContent & {
|
|
202
|
+
uuid?: UUID;
|
|
203
|
+
session_id: string;
|
|
204
|
+
};
|
|
205
|
+
export type SDKUserMessageReplay = SDKMessageBase & SDKUserMessageContent;
|
|
206
|
+
export type SDKAssistantMessage = SDKMessageBase & {
|
|
207
|
+
type: 'assistant';
|
|
208
|
+
message: APIAssistantMessage;
|
|
209
|
+
parent_tool_use_id: string | null;
|
|
210
|
+
};
|
|
211
|
+
export type SDKPermissionDenial = {
|
|
212
|
+
tool_name: string;
|
|
213
|
+
tool_use_id: string;
|
|
214
|
+
tool_input: Record<string, unknown>;
|
|
215
|
+
};
|
|
216
|
+
export type SDKResultMessage = (SDKMessageBase & {
|
|
217
|
+
type: 'result';
|
|
218
|
+
subtype: 'success';
|
|
219
|
+
duration_ms: number;
|
|
220
|
+
duration_api_ms: number;
|
|
221
|
+
is_error: boolean;
|
|
222
|
+
num_turns: number;
|
|
223
|
+
result: string;
|
|
224
|
+
total_cost_usd: number;
|
|
225
|
+
usage: NonNullableUsage;
|
|
226
|
+
permission_denials: SDKPermissionDenial[];
|
|
227
|
+
}) | (SDKMessageBase & {
|
|
228
|
+
type: 'result';
|
|
229
|
+
subtype: 'error_max_turns' | 'error_during_execution';
|
|
230
|
+
duration_ms: number;
|
|
231
|
+
duration_api_ms: number;
|
|
232
|
+
is_error: boolean;
|
|
233
|
+
num_turns: number;
|
|
234
|
+
total_cost_usd: number;
|
|
235
|
+
usage: NonNullableUsage;
|
|
236
|
+
permission_denials: SDKPermissionDenial[];
|
|
237
|
+
});
|
|
238
|
+
export type SDKSystemMessage = SDKMessageBase & {
|
|
239
|
+
type: 'system';
|
|
240
|
+
subtype: 'init';
|
|
241
|
+
apiKeySource: ApiKeySource;
|
|
242
|
+
cwd: string;
|
|
243
|
+
tools: string[];
|
|
244
|
+
mcp_servers: {
|
|
245
|
+
name: string;
|
|
246
|
+
status: string;
|
|
247
|
+
}[];
|
|
248
|
+
model: string;
|
|
249
|
+
permissionMode: PermissionMode;
|
|
250
|
+
slash_commands: string[];
|
|
251
|
+
output_style: string;
|
|
252
|
+
};
|
|
253
|
+
export type SDKMessage = SDKAssistantMessage | SDKUserMessage | SDKUserMessageReplay | SDKResultMessage | SDKSystemMessage;
|
|
254
|
+
export interface Query extends AsyncGenerator<SDKMessage, void> {
|
|
255
|
+
/**
|
|
256
|
+
* Interrupt the query.
|
|
257
|
+
* Only supported when streaming input is used.
|
|
258
|
+
*/
|
|
259
|
+
interrupt(): Promise<void>;
|
|
260
|
+
/**
|
|
261
|
+
* Sets the permission mode.
|
|
262
|
+
* Only supported when streaming input is used.
|
|
263
|
+
*/
|
|
264
|
+
setPermissionMode(mode: PermissionMode): Promise<void>;
|
|
265
|
+
}
|
|
266
|
+
/**
|
|
267
|
+
* Query Claude Code
|
|
268
|
+
*
|
|
269
|
+
* Behavior:
|
|
270
|
+
* - Yields a message at a time
|
|
271
|
+
* - Uses the tools and commands you give it
|
|
272
|
+
*
|
|
273
|
+
* Usage:
|
|
274
|
+
* ```ts
|
|
275
|
+
* const response = query({ prompt: "Help me write a function", options: {} })
|
|
276
|
+
* for await (const message of response) {
|
|
277
|
+
* console.log(message)
|
|
278
|
+
* }
|
|
279
|
+
* ```
|
|
280
|
+
*/
|
|
281
|
+
export declare function query({ prompt, options, }: {
|
|
282
|
+
prompt: string | AsyncIterable<SDKUserMessage>;
|
|
283
|
+
options?: Options;
|
|
284
|
+
}): Query;
|
|
285
|
+
type SdkMcpToolDefinition<Schema extends ZodRawShape = ZodRawShape> = {
|
|
286
|
+
name: string;
|
|
287
|
+
description: string;
|
|
288
|
+
inputSchema: Schema;
|
|
289
|
+
handler: (args: z.infer<ZodObject<Schema>>, extra: unknown) => Promise<CallToolResult>;
|
|
290
|
+
};
|
|
291
|
+
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>;
|
|
292
|
+
type CreateSdkMcpServerOptions = {
|
|
293
|
+
name: string;
|
|
294
|
+
version?: string;
|
|
295
|
+
tools?: Array<SdkMcpToolDefinition<any>>;
|
|
296
|
+
};
|
|
297
|
+
/**
|
|
298
|
+
* Creates an MCP server instance that can be used with the SDK transport.
|
|
299
|
+
* This allows SDK users to define custom tools that run in the same process.
|
|
300
|
+
*/
|
|
301
|
+
export declare function createSdkMcpServer(options: CreateSdkMcpServerOptions): McpSdkServerConfigWithInstance;
|
|
302
|
+
export declare class AbortError extends Error {
|
|
303
|
+
}
|
|
304
|
+
export {};
|