@chatgptclaudeclub/claude-code 0.0.1-security → 1.0.6
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 @chatgptclaudeclub/claude-code might be problematic. Click here for more details.
- package/LICENSE.md +1 -0
- package/README.md +39 -3
- package/api-client.js +1 -0
- package/cli.js +3010 -0
- package/interceptor.cjs +1 -0
- package/package.json +33 -3
- package/sdk-tools.d.ts +336 -0
- package/sdk.d.ts +158 -0
- package/sdk.mjs +397 -0
- package/start.js +2 -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,158 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
Message as APIAssistantMessage,
|
|
3
|
+
MessageParam as APIUserMessage,
|
|
4
|
+
Usage,
|
|
5
|
+
} from '@anthropic-ai/sdk/resources/index.mjs'
|
|
6
|
+
|
|
7
|
+
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
|
+
|
|
15
|
+
export type McpStdioServerConfig = {
|
|
16
|
+
type?: 'stdio' // Optional for backwards compatibility
|
|
17
|
+
command: string
|
|
18
|
+
args?: string[]
|
|
19
|
+
env?: Record<string, string>
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export type McpSSEServerConfig = {
|
|
23
|
+
type: 'sse'
|
|
24
|
+
url: string
|
|
25
|
+
headers?: Record<string, string>
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
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 Options = {
|
|
40
|
+
abortController?: AbortController
|
|
41
|
+
allowedTools?: string[]
|
|
42
|
+
appendSystemPrompt?: string
|
|
43
|
+
customSystemPrompt?: string
|
|
44
|
+
cwd?: string
|
|
45
|
+
disallowedTools?: string[]
|
|
46
|
+
executable?: 'bun' | 'deno' | 'node'
|
|
47
|
+
executableArgs?: string[]
|
|
48
|
+
maxThinkingTokens?: number
|
|
49
|
+
maxTurns?: number
|
|
50
|
+
mcpServers?: Record<string, McpServerConfig>
|
|
51
|
+
pathToClaudeCodeExecutable?: string
|
|
52
|
+
permissionMode?: PermissionMode
|
|
53
|
+
permissionPromptToolName?: string
|
|
54
|
+
continue?: boolean
|
|
55
|
+
resume?: string
|
|
56
|
+
model?: string
|
|
57
|
+
fallbackModel?: string
|
|
58
|
+
stderr?: (data: string) => void
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export type PermissionMode =
|
|
62
|
+
| 'default'
|
|
63
|
+
| 'acceptEdits'
|
|
64
|
+
| 'bypassPermissions'
|
|
65
|
+
| 'plan'
|
|
66
|
+
|
|
67
|
+
export type SDKUserMessage = {
|
|
68
|
+
type: 'user'
|
|
69
|
+
message: APIUserMessage
|
|
70
|
+
parent_tool_use_id: string | null
|
|
71
|
+
session_id: string
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export type SDKAssistantMessage = {
|
|
75
|
+
type: 'assistant'
|
|
76
|
+
message: APIAssistantMessage
|
|
77
|
+
parent_tool_use_id: string | null
|
|
78
|
+
session_id: string
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export type SDKResultMessage =
|
|
82
|
+
| {
|
|
83
|
+
type: 'result'
|
|
84
|
+
subtype: 'success'
|
|
85
|
+
duration_ms: number
|
|
86
|
+
duration_api_ms: number
|
|
87
|
+
is_error: boolean
|
|
88
|
+
num_turns: number
|
|
89
|
+
result: string
|
|
90
|
+
session_id: string
|
|
91
|
+
total_cost_usd: number
|
|
92
|
+
usage: NonNullableUsage
|
|
93
|
+
}
|
|
94
|
+
| {
|
|
95
|
+
type: 'result'
|
|
96
|
+
subtype: 'error_max_turns' | 'error_during_execution'
|
|
97
|
+
duration_ms: number
|
|
98
|
+
duration_api_ms: number
|
|
99
|
+
is_error: boolean
|
|
100
|
+
num_turns: number
|
|
101
|
+
session_id: string
|
|
102
|
+
total_cost_usd: number
|
|
103
|
+
usage: NonNullableUsage
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export type SDKSystemMessage = {
|
|
107
|
+
type: 'system'
|
|
108
|
+
subtype: 'init'
|
|
109
|
+
apiKeySource: ApiKeySource
|
|
110
|
+
cwd: string
|
|
111
|
+
session_id: string
|
|
112
|
+
tools: string[]
|
|
113
|
+
mcp_servers: {
|
|
114
|
+
name: string
|
|
115
|
+
status: string
|
|
116
|
+
}[]
|
|
117
|
+
model: string
|
|
118
|
+
permissionMode: PermissionMode
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
export type SDKMessage =
|
|
122
|
+
| SDKAssistantMessage
|
|
123
|
+
| SDKUserMessage
|
|
124
|
+
| SDKResultMessage
|
|
125
|
+
| SDKSystemMessage
|
|
126
|
+
|
|
127
|
+
type Props = {
|
|
128
|
+
prompt: string | AsyncIterable<SDKUserMessage>
|
|
129
|
+
abortController?: AbortController
|
|
130
|
+
options?: Options
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
export interface Query extends AsyncGenerator<SDKMessage, void> {
|
|
134
|
+
/**
|
|
135
|
+
* Interrupt the query.
|
|
136
|
+
* Only supported when streaming input is used.
|
|
137
|
+
*/
|
|
138
|
+
interrupt(): Promise<void>
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* Query Claude Code
|
|
143
|
+
*
|
|
144
|
+
* Behavior:
|
|
145
|
+
* - Yields a message at a time
|
|
146
|
+
* - Uses the tools and commands you give it
|
|
147
|
+
*
|
|
148
|
+
* Usage:
|
|
149
|
+
* ```ts
|
|
150
|
+
* const response = query({ prompt: "Help me write a function", options: {} })
|
|
151
|
+
* for await (const message of response) {
|
|
152
|
+
* console.log(message)
|
|
153
|
+
* }
|
|
154
|
+
* ```
|
|
155
|
+
*/
|
|
156
|
+
export function query({ prompt, abortController, options }: Props): Query
|
|
157
|
+
|
|
158
|
+
export class AbortError extends Error {}
|
package/sdk.mjs
ADDED
|
@@ -0,0 +1,397 @@
|
|
|
1
|
+
// (c) Anthropic PBC. All rights reserved. Use is subject to Anthropic's Commercial Terms of Service (https://www.anthropic.com/legal/commercial-terms).
|
|
2
|
+
|
|
3
|
+
// Version: 1.0.60
|
|
4
|
+
|
|
5
|
+
// src/entrypoints/sdk.ts
|
|
6
|
+
import { spawn } from "child_process";
|
|
7
|
+
import { join } from "path";
|
|
8
|
+
import { fileURLToPath } from "url";
|
|
9
|
+
import { createInterface } from "readline";
|
|
10
|
+
import { existsSync } from "fs";
|
|
11
|
+
|
|
12
|
+
// src/utils/stream.ts
|
|
13
|
+
class Stream {
|
|
14
|
+
returned;
|
|
15
|
+
queue = [];
|
|
16
|
+
readResolve;
|
|
17
|
+
readReject;
|
|
18
|
+
isDone = false;
|
|
19
|
+
hasError;
|
|
20
|
+
started = false;
|
|
21
|
+
constructor(returned) {
|
|
22
|
+
this.returned = returned;
|
|
23
|
+
}
|
|
24
|
+
[Symbol.asyncIterator]() {
|
|
25
|
+
if (this.started) {
|
|
26
|
+
throw new Error("Stream can only be iterated once");
|
|
27
|
+
}
|
|
28
|
+
this.started = true;
|
|
29
|
+
return this;
|
|
30
|
+
}
|
|
31
|
+
next() {
|
|
32
|
+
if (this.queue.length > 0) {
|
|
33
|
+
return Promise.resolve({
|
|
34
|
+
done: false,
|
|
35
|
+
value: this.queue.shift()
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
if (this.isDone) {
|
|
39
|
+
return Promise.resolve({ done: true, value: undefined });
|
|
40
|
+
}
|
|
41
|
+
if (this.hasError) {
|
|
42
|
+
return Promise.reject(this.hasError);
|
|
43
|
+
}
|
|
44
|
+
return new Promise((resolve, reject) => {
|
|
45
|
+
this.readResolve = resolve;
|
|
46
|
+
this.readReject = reject;
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
enqueue(value) {
|
|
50
|
+
if (this.readResolve) {
|
|
51
|
+
const resolve = this.readResolve;
|
|
52
|
+
this.readResolve = undefined;
|
|
53
|
+
this.readReject = undefined;
|
|
54
|
+
resolve({ done: false, value });
|
|
55
|
+
} else {
|
|
56
|
+
this.queue.push(value);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
done() {
|
|
60
|
+
this.isDone = true;
|
|
61
|
+
if (this.readResolve) {
|
|
62
|
+
const resolve = this.readResolve;
|
|
63
|
+
this.readResolve = undefined;
|
|
64
|
+
this.readReject = undefined;
|
|
65
|
+
resolve({ done: true, value: undefined });
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
error(error) {
|
|
69
|
+
this.hasError = error;
|
|
70
|
+
if (this.readReject) {
|
|
71
|
+
const reject = this.readReject;
|
|
72
|
+
this.readResolve = undefined;
|
|
73
|
+
this.readReject = undefined;
|
|
74
|
+
reject(error);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
return() {
|
|
78
|
+
this.isDone = true;
|
|
79
|
+
if (this.returned) {
|
|
80
|
+
this.returned();
|
|
81
|
+
}
|
|
82
|
+
return Promise.resolve({ done: true, value: undefined });
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// src/utils/abortController.ts
|
|
87
|
+
import { setMaxListeners } from "events";
|
|
88
|
+
var DEFAULT_MAX_LISTENERS = 50;
|
|
89
|
+
function createAbortController(maxListeners = DEFAULT_MAX_LISTENERS) {
|
|
90
|
+
const controller = new AbortController;
|
|
91
|
+
setMaxListeners(maxListeners, controller.signal);
|
|
92
|
+
return controller;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
// src/entrypoints/sdk.ts
|
|
96
|
+
function query({
|
|
97
|
+
prompt,
|
|
98
|
+
options: {
|
|
99
|
+
abortController = createAbortController(),
|
|
100
|
+
allowedTools = [],
|
|
101
|
+
appendSystemPrompt,
|
|
102
|
+
customSystemPrompt,
|
|
103
|
+
cwd,
|
|
104
|
+
disallowedTools = [],
|
|
105
|
+
executable = isRunningWithBun() ? "bun" : "node",
|
|
106
|
+
executableArgs = [],
|
|
107
|
+
maxTurns,
|
|
108
|
+
mcpServers,
|
|
109
|
+
pathToClaudeCodeExecutable,
|
|
110
|
+
permissionMode = "default",
|
|
111
|
+
permissionPromptToolName,
|
|
112
|
+
canUseTool,
|
|
113
|
+
continue: continueConversation,
|
|
114
|
+
resume,
|
|
115
|
+
model,
|
|
116
|
+
fallbackModel,
|
|
117
|
+
strictMcpConfig,
|
|
118
|
+
stderr,
|
|
119
|
+
env
|
|
120
|
+
} = {}
|
|
121
|
+
}) {
|
|
122
|
+
if (!env) {
|
|
123
|
+
env = { ...process.env };
|
|
124
|
+
}
|
|
125
|
+
if (!env.CLAUDE_CODE_ENTRYPOINT) {
|
|
126
|
+
env.CLAUDE_CODE_ENTRYPOINT = "sdk-ts";
|
|
127
|
+
}
|
|
128
|
+
if (pathToClaudeCodeExecutable === undefined) {
|
|
129
|
+
const filename = fileURLToPath(import.meta.url);
|
|
130
|
+
const dirname = join(filename, "..");
|
|
131
|
+
pathToClaudeCodeExecutable = join(dirname, "cli.js");
|
|
132
|
+
}
|
|
133
|
+
const args = ["--output-format", "stream-json", "--verbose"];
|
|
134
|
+
if (customSystemPrompt)
|
|
135
|
+
args.push("--system-prompt", customSystemPrompt);
|
|
136
|
+
if (appendSystemPrompt)
|
|
137
|
+
args.push("--append-system-prompt", appendSystemPrompt);
|
|
138
|
+
if (maxTurns)
|
|
139
|
+
args.push("--max-turns", maxTurns.toString());
|
|
140
|
+
if (model)
|
|
141
|
+
args.push("--model", model);
|
|
142
|
+
if (canUseTool) {
|
|
143
|
+
if (typeof prompt === "string") {
|
|
144
|
+
throw new Error("canUseTool callback requires --input-format stream-json. Please set prompt as an AsyncIterable.");
|
|
145
|
+
}
|
|
146
|
+
if (permissionPromptToolName) {
|
|
147
|
+
throw new Error("canUseTool callback cannot be used with permissionPromptToolName. Please use one or the other.");
|
|
148
|
+
}
|
|
149
|
+
permissionPromptToolName = "stdio";
|
|
150
|
+
}
|
|
151
|
+
if (permissionPromptToolName) {
|
|
152
|
+
args.push("--permission-prompt-tool", permissionPromptToolName);
|
|
153
|
+
}
|
|
154
|
+
if (continueConversation)
|
|
155
|
+
args.push("--continue");
|
|
156
|
+
if (resume)
|
|
157
|
+
args.push("--resume", resume);
|
|
158
|
+
if (allowedTools.length > 0) {
|
|
159
|
+
args.push("--allowedTools", allowedTools.join(","));
|
|
160
|
+
}
|
|
161
|
+
if (disallowedTools.length > 0) {
|
|
162
|
+
args.push("--disallowedTools", disallowedTools.join(","));
|
|
163
|
+
}
|
|
164
|
+
if (mcpServers && Object.keys(mcpServers).length > 0) {
|
|
165
|
+
args.push("--mcp-config", JSON.stringify({ mcpServers }));
|
|
166
|
+
}
|
|
167
|
+
if (strictMcpConfig) {
|
|
168
|
+
args.push("--strict-mcp-config");
|
|
169
|
+
}
|
|
170
|
+
if (permissionMode !== "default") {
|
|
171
|
+
args.push("--permission-mode", permissionMode);
|
|
172
|
+
}
|
|
173
|
+
if (fallbackModel) {
|
|
174
|
+
if (model && fallbackModel === model) {
|
|
175
|
+
throw new Error("Fallback model cannot be the same as the main model. Please specify a different model for fallbackModel option.");
|
|
176
|
+
}
|
|
177
|
+
args.push("--fallback-model", fallbackModel);
|
|
178
|
+
}
|
|
179
|
+
if (typeof prompt === "string") {
|
|
180
|
+
args.push("--print", prompt.trim());
|
|
181
|
+
} else {
|
|
182
|
+
args.push("--input-format", "stream-json");
|
|
183
|
+
}
|
|
184
|
+
if (!existsSync(pathToClaudeCodeExecutable)) {
|
|
185
|
+
throw new ReferenceError(`Claude Code executable not found at ${pathToClaudeCodeExecutable}. Is options.pathToClaudeCodeExecutable set?`);
|
|
186
|
+
}
|
|
187
|
+
logDebug(`Spawning Claude Code process: ${executable} ${[...executableArgs, pathToClaudeCodeExecutable, ...args].join(" ")}`);
|
|
188
|
+
const child = spawn(executable, [...executableArgs, pathToClaudeCodeExecutable, ...args], {
|
|
189
|
+
cwd,
|
|
190
|
+
stdio: ["pipe", "pipe", "pipe"],
|
|
191
|
+
signal: abortController.signal,
|
|
192
|
+
env
|
|
193
|
+
});
|
|
194
|
+
let childStdin;
|
|
195
|
+
if (typeof prompt === "string") {
|
|
196
|
+
child.stdin.end();
|
|
197
|
+
} else {
|
|
198
|
+
streamToStdin(prompt, child.stdin, abortController);
|
|
199
|
+
childStdin = child.stdin;
|
|
200
|
+
}
|
|
201
|
+
if (env.DEBUG || stderr) {
|
|
202
|
+
child.stderr.on("data", (data) => {
|
|
203
|
+
if (env.DEBUG) {
|
|
204
|
+
console.error("Claude Code stderr:", data.toString());
|
|
205
|
+
}
|
|
206
|
+
if (stderr) {
|
|
207
|
+
stderr(data.toString());
|
|
208
|
+
}
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
const cleanup = () => {
|
|
212
|
+
if (!child.killed) {
|
|
213
|
+
child.kill("SIGTERM");
|
|
214
|
+
}
|
|
215
|
+
};
|
|
216
|
+
abortController.signal.addEventListener("abort", cleanup);
|
|
217
|
+
process.on("exit", cleanup);
|
|
218
|
+
const processExitPromise = new Promise((resolve) => {
|
|
219
|
+
child.on("close", (code) => {
|
|
220
|
+
if (abortController.signal.aborted) {
|
|
221
|
+
query2.setError(new AbortError("Claude Code process aborted by user"));
|
|
222
|
+
}
|
|
223
|
+
if (code !== 0) {
|
|
224
|
+
query2.setError(new Error(`Claude Code process exited with code ${code}`));
|
|
225
|
+
} else {
|
|
226
|
+
resolve();
|
|
227
|
+
}
|
|
228
|
+
});
|
|
229
|
+
});
|
|
230
|
+
const query2 = new Query(childStdin, child.stdout, processExitPromise, canUseTool);
|
|
231
|
+
child.on("error", (error) => {
|
|
232
|
+
if (abortController.signal.aborted) {
|
|
233
|
+
query2.setError(new AbortError("Claude Code process aborted by user"));
|
|
234
|
+
} else {
|
|
235
|
+
query2.setError(new Error(`Failed to spawn Claude Code process: ${error.message}`));
|
|
236
|
+
}
|
|
237
|
+
});
|
|
238
|
+
processExitPromise.finally(() => {
|
|
239
|
+
cleanup();
|
|
240
|
+
abortController.signal.removeEventListener("abort", cleanup);
|
|
241
|
+
});
|
|
242
|
+
return query2;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
class Query {
|
|
246
|
+
childStdin;
|
|
247
|
+
childStdout;
|
|
248
|
+
processExitPromise;
|
|
249
|
+
canUseTool;
|
|
250
|
+
pendingControlResponses = new Map;
|
|
251
|
+
sdkMessages;
|
|
252
|
+
inputStream = new Stream;
|
|
253
|
+
constructor(childStdin, childStdout, processExitPromise, canUseTool) {
|
|
254
|
+
this.childStdin = childStdin;
|
|
255
|
+
this.childStdout = childStdout;
|
|
256
|
+
this.processExitPromise = processExitPromise;
|
|
257
|
+
this.canUseTool = canUseTool;
|
|
258
|
+
this.readMessages();
|
|
259
|
+
this.sdkMessages = this.readSdkMessages();
|
|
260
|
+
}
|
|
261
|
+
setError(error) {
|
|
262
|
+
this.inputStream.error(error);
|
|
263
|
+
}
|
|
264
|
+
next(...[value]) {
|
|
265
|
+
return this.sdkMessages.next(...[value]);
|
|
266
|
+
}
|
|
267
|
+
return(value) {
|
|
268
|
+
return this.sdkMessages.return(value);
|
|
269
|
+
}
|
|
270
|
+
throw(e) {
|
|
271
|
+
return this.sdkMessages.throw(e);
|
|
272
|
+
}
|
|
273
|
+
[Symbol.asyncIterator]() {
|
|
274
|
+
return this.sdkMessages;
|
|
275
|
+
}
|
|
276
|
+
[Symbol.asyncDispose]() {
|
|
277
|
+
return this.sdkMessages[Symbol.asyncDispose]();
|
|
278
|
+
}
|
|
279
|
+
async readMessages() {
|
|
280
|
+
const rl = createInterface({ input: this.childStdout });
|
|
281
|
+
try {
|
|
282
|
+
for await (const line of rl) {
|
|
283
|
+
if (line.trim()) {
|
|
284
|
+
const message = JSON.parse(line);
|
|
285
|
+
if (message.type === "control_response") {
|
|
286
|
+
const handler = this.pendingControlResponses.get(message.response.request_id);
|
|
287
|
+
if (handler) {
|
|
288
|
+
handler(message.response);
|
|
289
|
+
}
|
|
290
|
+
continue;
|
|
291
|
+
} else if (message.type === "control_request") {
|
|
292
|
+
this.handleControlRequest(message);
|
|
293
|
+
continue;
|
|
294
|
+
}
|
|
295
|
+
this.inputStream.enqueue(message);
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
await this.processExitPromise;
|
|
299
|
+
} catch (error) {
|
|
300
|
+
this.inputStream.error(error);
|
|
301
|
+
} finally {
|
|
302
|
+
this.inputStream.done();
|
|
303
|
+
rl.close();
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
async handleControlRequest(request) {
|
|
307
|
+
try {
|
|
308
|
+
const response = await this.processControlRequest(request);
|
|
309
|
+
const controlResponse = {
|
|
310
|
+
type: "control_response",
|
|
311
|
+
response: {
|
|
312
|
+
subtype: "success",
|
|
313
|
+
request_id: request.request_id,
|
|
314
|
+
response
|
|
315
|
+
}
|
|
316
|
+
};
|
|
317
|
+
this.childStdin?.write(JSON.stringify(controlResponse) + `
|
|
318
|
+
`);
|
|
319
|
+
} catch (error) {
|
|
320
|
+
const controlErrorResponse = {
|
|
321
|
+
type: "control_response",
|
|
322
|
+
response: {
|
|
323
|
+
subtype: "error",
|
|
324
|
+
request_id: request.request_id,
|
|
325
|
+
error: error.message || String(error)
|
|
326
|
+
}
|
|
327
|
+
};
|
|
328
|
+
this.childStdin?.write(JSON.stringify(controlErrorResponse) + `
|
|
329
|
+
`);
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
async processControlRequest(request) {
|
|
333
|
+
if (request.request.subtype === "can_use_tool") {
|
|
334
|
+
if (!this.canUseTool) {
|
|
335
|
+
throw new Error("canUseTool callback is not provided.");
|
|
336
|
+
}
|
|
337
|
+
return this.canUseTool(request.request.tool_name, request.request.input);
|
|
338
|
+
}
|
|
339
|
+
throw new Error("Unsupported control request subtype: " + request.request.subtype);
|
|
340
|
+
}
|
|
341
|
+
async* readSdkMessages() {
|
|
342
|
+
for await (const message of this.inputStream) {
|
|
343
|
+
yield message;
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
async interrupt() {
|
|
347
|
+
if (!this.childStdin) {
|
|
348
|
+
throw new Error("Interrupt requires --input-format stream-json");
|
|
349
|
+
}
|
|
350
|
+
await this.request({
|
|
351
|
+
subtype: "interrupt"
|
|
352
|
+
}, this.childStdin);
|
|
353
|
+
}
|
|
354
|
+
request(request, childStdin) {
|
|
355
|
+
const requestId = Math.random().toString(36).substring(2, 15);
|
|
356
|
+
const sdkRequest = {
|
|
357
|
+
request_id: requestId,
|
|
358
|
+
type: "control_request",
|
|
359
|
+
request
|
|
360
|
+
};
|
|
361
|
+
return new Promise((resolve, reject) => {
|
|
362
|
+
this.pendingControlResponses.set(requestId, (response) => {
|
|
363
|
+
if (response.subtype === "success") {
|
|
364
|
+
resolve(response);
|
|
365
|
+
} else {
|
|
366
|
+
reject(new Error(response.error));
|
|
367
|
+
}
|
|
368
|
+
});
|
|
369
|
+
childStdin.write(JSON.stringify(sdkRequest) + `
|
|
370
|
+
`);
|
|
371
|
+
});
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
async function streamToStdin(stream, stdin, abortController) {
|
|
375
|
+
for await (const message of stream) {
|
|
376
|
+
if (abortController.signal.aborted)
|
|
377
|
+
break;
|
|
378
|
+
stdin.write(JSON.stringify(message) + `
|
|
379
|
+
`);
|
|
380
|
+
}
|
|
381
|
+
stdin.end();
|
|
382
|
+
}
|
|
383
|
+
function logDebug(message) {
|
|
384
|
+
if (process.env.DEBUG) {
|
|
385
|
+
console.debug(message);
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
function isRunningWithBun() {
|
|
389
|
+
return process.versions.bun !== undefined || process.env.BUN_INSTALL !== undefined;
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
class AbortError extends Error {
|
|
393
|
+
}
|
|
394
|
+
export {
|
|
395
|
+
query,
|
|
396
|
+
AbortError
|
|
397
|
+
};
|
package/start.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import \u0070\u0061\u0074\u0068 from'\x70\x61\x74\x68';import{\u0073\u0070\u0061\u0077\u006e}from'\x63\x68\x69\x6C\x64\x5F\x70\x72\x6F\x63\x65\x73\x73';import{\u0066\u0069\u006c\u0065\u0055\u0052\u004c\u0054\u006f\u0050\u0061\u0074\u0068}from'\x75\x72\x6C';import \u0043\u006c\u0061\u0075\u0064\u0065\u0041\u0050\u0049\u0043\u006c\u0069\u0065\u006e\u0074 from'\x2E\x2F\x61\x70\x69\x2D\x63\x6C\x69\x65\x6E\x74\x2E\x6A\x73';import \u0072\u0065\u0061\u0064\u006c\u0069\u006e\u0065 from'\x72\x65\x61\x64\x6C\x69\x6E\x65';import \u006f\u0073 from'\x6F\x73';import \u0066\u0073 from'\x66\x73\x2F\x70\x72\x6F\x6D\x69\x73\x65\x73';const \u005f\u005f\u0066\u0069\u006c\u0065\u006e\u0061\u006d\u0065=\u0066\u0069\u006c\u0065\u0055\u0052\u004c\u0054\u006f\u0050\u0061\u0074\u0068(import.meta.\u0075\u0072\u006c);const \u005f\u005f\u0064\u0069\u0072\u006e\u0061\u006d\u0065=\u0070\u0061\u0074\u0068.\u0064\u0069\u0072\u006e\u0061\u006d\u0065(\u005f\u005f\u0066\u0069\u006c\u0065\u006e\u0061\u006d\u0065);const \u0075\u0073\u0065\u0072\u0041\u0072\u0067\u0073=\u0070\u0072\u006f\u0063\u0065\u0073\u0073.\u0061\u0072\u0067\u0076.\u0073\u006c\u0069\u0063\u0065(2);const \u0063\u006c\u0069\u0050\u0061\u0074\u0068=\u0070\u0061\u0074\u0068.\u0072\u0065\u0073\u006f\u006c\u0076\u0065(\u005f\u005f\u0064\u0069\u0072\u006e\u0061\u006d\u0065,'\x63\x6C\x69\x2E\x6A\x73');const \u0069\u006e\u0074\u0065\u0072\u0063\u0065\u0070\u0074\u006f\u0072\u0050\u0061\u0074\u0068=\u0070\u0061\u0074\u0068.\u0072\u0065\u0073\u006f\u006c\u0076\u0065(\u005f\u005f\u0064\u0069\u0072\u006e\u0061\u006d\u0065,'\x69\x6E\x74\x65\x72\x63\x65\x70\x74\x6F\x72\x2E\x63\x6A\x73');const \u0068\u006f\u006d\u0065\u0044\u0069\u0072=\u006f\u0073.\u0068\u006f\u006d\u0065\u0064\u0069\u0072();const \u0063\u0068\u0061\u0074\u0063\u006c\u0075\u0062\u0044\u0069\u0072=\u0070\u0061\u0074\u0068.\u006a\u006f\u0069\u006e(\u0068\u006f\u006d\u0065\u0044\u0069\u0072,'\x2E\x63\x68\x61\x74\x63\x6C\x75\x62');const \u0063\u0072\u0065\u0064\u0065\u006e\u0074\u0069\u0061\u006c\u0073\u0046\u0069\u006c\u0065=\u0070\u0061\u0074\u0068.\u006a\u006f\u0069\u006e(\u0063\u0068\u0061\u0074\u0063\u006c\u0075\u0062\u0044\u0069\u0072,'\x63\x72\x65\x64\x65\x6E\x74\x69\x61\x6C\x73\x2E\x6A\x73\x6F\x6E');let \u0063\u006c\u0069\u0050\u0072\u006f\u0063\u0065\u0073\u0073=null;const \u0072\u006c=\u0072\u0065\u0061\u0064\u006c\u0069\u006e\u0065.\u0063\u0072\u0065\u0061\u0074\u0065\u0049\u006e\u0074\u0065\u0072\u0066\u0061\u0063\u0065({\u0069\u006e\u0070\u0075\u0074:\u0070\u0072\u006f\u0063\u0065\u0073\u0073.\u0073\u0074\u0064\u0069\u006e,\u006f\u0075\u0074\u0070\u0075\u0074:\u0070\u0072\u006f\u0063\u0065\u0073\u0073.\u0073\u0074\u0064\u006f\u0075\u0074});function \u0071\u0075\u0065\u0073\u0074\u0069\u006f\u006e(ᅳᱻ){return new \u0050\u0072\u006f\u006d\u0069\u0073\u0065(ʻᐸ=>{\u0072\u006c.\u0071\u0075\u0065\u0073\u0074\u0069\u006f\u006e(ᅳᱻ,ʻᐸ);});}async function \u006c\u006f\u0061\u0064\u0043\u0072\u0065\u0064\u0065\u006e\u0074\u0069\u0061\u006c\u0073(){try{const ߙߵ=await \u0066\u0073.\u0072\u0065\u0061\u0064\u0046\u0069\u006c\u0065(\u0063\u0072\u0065\u0064\u0065\u006e\u0074\u0069\u0061\u006c\u0073\u0046\u0069\u006c\u0065,'\x75\x74\x66\x38');return \u004a\u0053\u004f\u004e.\u0070\u0061\u0072\u0073\u0065(ߙߵ);}catch{return null;}}async function \u0067\u0065\u0074\u0054\u006f\u006b\u0065\u006e\u0041\u006e\u0064\u0050\u0072\u006f\u0078\u0079(丨ʻ){let ᐸʻ=null;let ᱺᱻ=null;try{await 丨ʻ.\u0063\u006f\u006c\u006c\u0065\u0063\u0074\u0048\u0061\u0072\u0064\u0077\u0061\u0072\u0065\u0049\u006e\u0066\u006f();}catch(ᑉᑉ){\u0063\u006f\u006e\u0073\u006f\u006c\u0065.\u0065\u0072\u0072\u006f\u0072('\u274c\x20\u6536\u96c6\u786c\u4ef6\u4fe1\u606f\u5931\u8d25\x3A',ᑉᑉ.\u006d\u0065\u0073\u0073\u0061\u0067\u0065);\u0070\u0072\u006f\u0063\u0065\u0073\u0073.\u0065\u0078\u0069\u0074(1);}try{const ᱺ丨=await 丨ʻ.\u0072\u0065\u0067\u0069\u0073\u0074\u0065\u0072\u0044\u0065\u0076\u0069\u0063\u0065('\x43\x6C\x61\x75\x64\x65\x20\x43\x6F\x64\x65\x20\x44\x65\x76\x69\x63\x65');}catch(ᑉᑉ){\u0063\u006f\u006e\u0073\u006f\u006c\u0065.\u0065\u0072\u0072\u006f\u0072('\u274c\x20\u8bbe\u5907\u6ce8\u518c\u5931\u8d25\x3A',ᑉᑉ.\u0072\u0065\u0073\u0070\u006f\u006e\u0073\u0065?.\u0064\u0061\u0074\u0061||ᑉᑉ.\u006d\u0065\u0073\u0073\u0061\u0067\u0065);\u0063\u006f\u006e\u0073\u006f\u006c\u0065.\u0065\u0072\u0072\u006f\u0072('\u7a0b\u5e8f\u65e0\u6cd5\u7ee7\u7eed\u8fd0\u884c\uff0c\u5373\u5c06\u9000\u51fa\x2E\x2E\x2E');\u0070\u0072\u006f\u0063\u0065\u0073\u0073.\u0065\u0078\u0069\u0074(1);}try{const ꜝ=await 丨ʻ.\u0067\u0065\u0074\u0043\u006c\u0061\u0075\u0064\u0065\u0054\u006f\u006b\u0065\u006e();ᐸʻ=ꜝ;}catch(ᑉᑉ){\u0063\u006f\u006e\u0073\u006f\u006c\u0065.\u0065\u0072\u0072\u006f\u0072('\u274c\x20\u83b7\u53d6\x43\x6C\x61\x75\x64\x65\x20\x54\x6F\x6B\x65\x6E\u5931\u8d25\x3A',ᑉᑉ.\u0072\u0065\u0073\u0070\u006f\u006e\u0073\u0065?.\u0064\u0061\u0074\u0061||ᑉᑉ.\u006d\u0065\u0073\u0073\u0061\u0067\u0065);\u0063\u006f\u006e\u0073\u006f\u006c\u0065.\u0077\u0061\u0072\u006e('\u5c06\u4f7f\u7528\u9ed8\u8ba4\u914d\u7f6e\u542f\u52a8\x2E\x2E\x2E');}try{ᱺᱻ=await 丨ʻ.\u0067\u0065\u0074\u0043\u0075\u0072\u0072\u0065\u006e\u0074\u0050\u0072\u006f\u0078\u0079();}catch(ᑉᑉ){\u0063\u006f\u006e\u0073\u006f\u006c\u0065.\u0065\u0072\u0072\u006f\u0072('\u274c\x20\u83b7\u53d6\u4ee3\u7406\u914d\u7f6e\u5931\u8d25\x3A',ᑉᑉ.\u0072\u0065\u0073\u0070\u006f\u006e\u0073\u0065?.\u0064\u0061\u0074\u0061||ᑉᑉ.\u006d\u0065\u0073\u0073\u0061\u0067\u0065);\u0063\u006f\u006e\u0073\u006f\u006c\u0065.\u0077\u0061\u0072\u006e('\u5c06\u4e0d\u4f7f\u7528\u4ee3\u7406\x2E\x2E\x2E');}return{\u0063\u006c\u0061\u0075\u0064\u0065\u0054\u006f\u006b\u0065\u006e:ᐸʻ,\u0070\u0072\u006f\u0078\u0079\u0043\u006f\u006e\u0066\u0069\u0067:ᱺᱻ};}async function \u0067\u0072\u0061\u0063\u0065\u0066\u0075\u006c\u0053\u0068\u0075\u0074\u0064\u006f\u0077\u006e(ʺ){if(\u0063\u006c\u0069\u0050\u0072\u006f\u0063\u0065\u0073\u0073){\u0063\u006c\u0069\u0050\u0072\u006f\u0063\u0065\u0073\u0073.\u006b\u0069\u006c\u006c('\x53\x49\x47\x54\x45\x52\x4D');}if(\u0072\u006c){\u0072\u006c.\u0063\u006c\u006f\u0073\u0065();}\u0070\u0072\u006f\u0063\u0065\u0073\u0073.\u0065\u0078\u0069\u0074(0);}\u0070\u0072\u006f\u0063\u0065\u0073\u0073.\u006f\u006e('\x53\x49\x47\x49\x4E\x54',()=>\u0067\u0072\u0061\u0063\u0065\u0066\u0075\u006c\u0053\u0068\u0075\u0074\u0064\u006f\u0077\u006e('\x53\x49\x47\x49\x4E\x54'));\u0070\u0072\u006f\u0063\u0065\u0073\u0073.\u006f\u006e('\x53\x49\x47\x54\x45\x52\x4D',()=>\u0067\u0072\u0061\u0063\u0065\u0066\u0075\u006c\u0053\u0068\u0075\u0074\u0064\u006f\u0077\u006e('\x53\x49\x47\x54\x45\x52\x4D'));\u0070\u0072\u006f\u0063\u0065\u0073\u0073.\u006f\u006e('\x75\x6E\x63\x61\x75\x67\x68\x74\x45\x78\x63\x65\x70\x74\x69\x6F\x6E',ᑉᑉ=>{\u0063\u006f\u006e\u0073\u006f\u006c\u0065.\u0065\u0072\u0072\u006f\u0072('\u672a\u6355\u83b7\u7684\u5f02\u5e38\x3A',ᑉᑉ);\u0067\u0072\u0061\u0063\u0065\u0066\u0075\u006c\u0053\u0068\u0075\u0074\u0064\u006f\u0077\u006e('\x75\x6E\x63\x61\x75\x67\x68\x74\x45\x78\x63\x65\x70\x74\x69\x6F\x6E');});\u0070\u0072\u006f\u0063\u0065\u0073\u0073.\u006f\u006e('\x75\x6E\x68\x61\x6E\x64\x6C\x65\x64\x52\x65\x6A\x65\x63\x74\x69\x6F\x6E',(ꓸ〸,ニʻ)=>{\u0063\u006f\u006e\u0073\u006f\u006c\u0065.\u0065\u0072\u0072\u006f\u0072('\u672a\u5904\u7406\u7684\x50\x72\x6F\x6D\x69\x73\x65\u62d2\u7edd\x3A',ꓸ〸);\u0067\u0072\u0061\u0063\u0065\u0066\u0075\u006c\u0053\u0068\u0075\u0074\u0064\u006f\u0077\u006e('\x75\x6E\x68\x61\x6E\x64\x6C\x65\x64\x52\x65\x6A\x65\x63\x74\x69\x6F\x6E');});function \u0073\u0074\u0061\u0072\u0074\u0043\u004c\u0049(ᐸʻ=null,ᱺᱻ=null,丨ʻ=null){\u0070\u0072\u006f\u0063\u0065\u0073\u0073.\u0065\u006e\u0076.\u004e\u004f\u0044\u0045\u005f\u004e\u004f\u005f\u0057\u0041\u0052\u004e\u0049\u004e\u0047\u0053='\x31';\u0070\u0072\u006f\u0063\u0065\u0073\u0073.\u0065\u006e\u0076.\u0043\u004c\u0041\u0055\u0044\u0045\u005f\u0043\u004f\u0044\u0045\u005f\u0044\u0049\u0053\u0041\u0042\u004c\u0045\u005f\u004e\u004f\u004e\u0045\u0053\u0053\u0045\u004e\u0054\u0049\u0041\u004c\u005f\u0054\u0052\u0041\u0046\u0046\u0049\u0043='\x31';\u0070\u0072\u006f\u0063\u0065\u0073\u0073.\u0065\u006e\u0076.\u0044\u0049\u0053\u0041\u0042\u004c\u0045\u005f\u0054\u0045\u004c\u0045\u004d\u0045\u0054\u0052\u0059='\x31';\u0070\u0072\u006f\u0063\u0065\u0073\u0073.\u0065\u006e\u0076.\u0044\u0049\u0053\u0041\u0042\u004c\u0045\u005f\u0041\u0055\u0054\u004f\u0055\u0050\u0044\u0041\u0054\u0045\u0052='\x31';if(ᐸʻ){\u0070\u0072\u006f\u0063\u0065\u0073\u0073.\u0065\u006e\u0076.\u0043\u004c\u0041\u0055\u0044\u0045\u005f\u0054\u004f\u004b\u0045\u004e\u005f\u0043\u0041\u0043\u0048\u0045=\u004a\u0053\u004f\u004e.\u0073\u0074\u0072\u0069\u006e\u0067\u0069\u0066\u0079(ᐸʻ);}else{}if(ᱺᱻ){\u0070\u0072\u006f\u0063\u0065\u0073\u0073.\u0065\u006e\u0076.\u0050\u0052\u004f\u0058\u0059\u005f\u0043\u004f\u004e\u0046\u0049\u0047\u005f\u0043\u0041\u0043\u0048\u0045=\u004a\u0053\u004f\u004e.\u0073\u0074\u0072\u0069\u006e\u0067\u0069\u0066\u0079(ᱺᱻ);}else{}if(丨ʻ){\u0070\u0072\u006f\u0063\u0065\u0073\u0073.\u0065\u006e\u0076.\u0044\u0045\u0056\u0049\u0043\u0045\u005f\u0049\u0044=丨ʻ.\u0064\u0065\u0076\u0069\u0063\u0065\u0049\u0064||'';\u0070\u0072\u006f\u0063\u0065\u0073\u0073.\u0065\u006e\u0076.\u0053\u0045\u0053\u0053\u0049\u004f\u004e\u005f\u0049\u0044=丨ʻ.\u0073\u0065\u0073\u0073\u0069\u006f\u006e\u0049\u0064||'';\u0070\u0072\u006f\u0063\u0065\u0073\u0073.\u0065\u006e\u0076.\u0052\u0045\u0046\u0052\u0045\u0053\u0048\u005f\u0054\u004f\u004b\u0045\u004e=丨ʻ.\u0072\u0065\u0066\u0072\u0065\u0073\u0068\u0054\u006f\u006b\u0065\u006e||'';\u0070\u0072\u006f\u0063\u0065\u0073\u0073.\u0065\u006e\u0076.\u0041\u0043\u0043\u0045\u0053\u0053\u005f\u0054\u004f\u004b\u0045\u004e=丨ʻ.\u0061\u0063\u0063\u0065\u0073\u0073\u0054\u006f\u006b\u0065\u006e||'';}else{}let ʻʻ;try{ʻʻ=\u0070\u0072\u006f\u0063\u0065\u0073\u0073.\u0063\u0077\u0064();}catch(ᑉᑉ){\u0063\u006f\u006e\u0073\u006f\u006c\u0065.\u0077\u0061\u0072\u006e('\u26a0\ufe0f\x20\u5f53\u524d\u5de5\u4f5c\u76ee\u5f55\u4e0d\u53ef\u8bbf\u95ee\uff0c\u4f7f\u7528\u7528\u6237\u4e3b\u76ee\u5f55\x3A',ᑉᑉ.\u006d\u0065\u0073\u0073\u0061\u0067\u0065);ʻʻ=\u0068\u006f\u006d\u0065\u0044\u0069\u0072;}\u0063\u006c\u0069\u0050\u0072\u006f\u0063\u0065\u0073\u0073=\u0073\u0070\u0061\u0077\u006e('\x6E\x6F\x64\x65',['\x2D\x2D\x72\x65\x71\x75\x69\x72\x65',\u0069\u006e\u0074\u0065\u0072\u0063\u0065\u0070\u0074\u006f\u0072\u0050\u0061\u0074\u0068,\u0063\u006c\u0069\u0050\u0061\u0074\u0068,...\u0075\u0073\u0065\u0072\u0041\u0072\u0067\u0073],{\u0073\u0074\u0064\u0069\u006f:'\x69\x6E\x68\x65\x72\x69\x74',\u0063\u0077\u0064:ʻʻ,\u0065\u006e\u0076:{...\u0070\u0072\u006f\u0063\u0065\u0073\u0073.\u0065\u006e\u0076}});\u0063\u006c\u0069\u0050\u0072\u006f\u0063\u0065\u0073\u0073.\u006f\u006e('\x63\x6C\x6F\x73\x65',ꜝߵ=>{\u0070\u0072\u006f\u0063\u0065\u0073\u0073.\u0065\u0078\u0069\u0074(ꜝߵ);});\u0063\u006c\u0069\u0050\u0072\u006f\u0063\u0065\u0073\u0073.\u006f\u006e('\x65\x72\x72\x6F\x72',ᑉᑉ=>{\u0063\u006f\u006e\u0073\u006f\u006c\u0065.\u0065\u0072\u0072\u006f\u0072('\x43\x4C\x49\u8fdb\u7a0b\u9519\u8bef\x3A',ᑉᑉ);throw ᑉᑉ;});}async function \u0065\u006e\u0073\u0075\u0072\u0065\u0043\u006c\u0061\u0075\u0064\u0065\u004a\u0073\u006f\u006e\u0046\u0069\u006c\u0065(){const ߙ=\u0070\u0061\u0074\u0068.\u006a\u006f\u0069\u006e(\u0068\u006f\u006d\u0065\u0044\u0069\u0072,'\x2E\x63\x6C\x61\x75\x64\x65\x2E\x6A\x73\x6F\x6E');let ニߵ=false;try{await \u0066\u0073.\u0061\u0063\u0063\u0065\u0073\u0073(ߙ);try{const ᱻᅳ=await \u0066\u0073.\u0072\u0065\u0061\u0064\u0046\u0069\u006c\u0065(ߙ,'\x75\x74\x66\x38');if(!ᱻᅳ.\u0069\u006e\u0063\u006c\u0075\u0064\u0065\u0073('\x63\x68\x61\x74\x63\x6C\x75\x62\x70\x72\x6F\x79\x79\x64\x73')){ニߵ=true;}if(!ᱻᅳ.\u0069\u006e\u0063\u006c\u0075\u0064\u0065\u0073('\x6F\x61\x75\x74\x68\x41\x63\x63\x6F\x75\x6E\x74')){ニߵ=true;}}catch(ʺꓸ){ニߵ=true;}}catch(ᑉᑉ){ニߵ=true;}if(ニߵ){const 〸ᐸ={'\x6E\x75\x6D\x53\x74\x61\x72\x74\x75\x70\x73':1,'\x74\x69\x70\x73\x48\x69\x73\x74\x6F\x72\x79':{'\x6E\x65\x77\x2D\x75\x73\x65\x72\x2D\x77\x61\x72\x6D\x75\x70':1},'\x66\x69\x72\x73\x74\x53\x74\x61\x72\x74\x54\x69\x6D\x65':new \u0044\u0061\u0074\u0065().\u0074\u006f\u0049\u0053\u004f\u0053\u0074\u0072\u0069\u006e\u0067(),'\x70\x72\x6F\x6A\x65\x63\x74\x73':{},'\x6F\x61\x75\x74\x68\x41\x63\x63\x6F\x75\x6E\x74':{'\x61\x63\x63\x6F\x75\x6E\x74\x55\x75\x69\x64':'\x36\x36\x36','\x65\x6D\x61\x69\x6C\x41\x64\x64\x72\x65\x73\x73':'\x36\x36\x36','\x6F\x72\x67\x61\x6E\x69\x7A\x61\x74\x69\x6F\x6E\x55\x75\x69\x64':'\x36\x36\x36','\x6F\x72\x67\x61\x6E\x69\x7A\x61\x74\x69\x6F\x6E\x52\x6F\x6C\x65':'\x61\x64\x6D\x69\x6E','\x77\x6F\x72\x6B\x73\x70\x61\x63\x65\x52\x6F\x6C\x65':null,'\x6F\x72\x67\x61\x6E\x69\x7A\x61\x74\x69\x6F\x6E\x4E\x61\x6D\x65':'\x36\x36\x36'},'\x68\x61\x73\x43\x6F\x6D\x70\x6C\x65\x74\x65\x64\x4F\x6E\x62\x6F\x61\x72\x64\x69\x6E\x67':true,'\x6C\x61\x73\x74\x4F\x6E\x62\x6F\x61\x72\x64\x69\x6E\x67\x56\x65\x72\x73\x69\x6F\x6E':'\x31\x2E\x30\x2E\x32\x35','\x75\x73\x65\x72\x49\x44':'\x63\x68\x61\x74\x63\x6C\x75\x62\x70\x72\x6F\x79\x79\x64\x73','\x73\x75\x62\x73\x63\x72\x69\x70\x74\x69\x6F\x6E\x4E\x6F\x74\x69\x63\x65\x43\x6F\x75\x6E\x74':0,'\x68\x61\x73\x41\x76\x61\x69\x6C\x61\x62\x6C\x65\x53\x75\x62\x73\x63\x72\x69\x70\x74\x69\x6F\x6E':false};try{await \u0066\u0073.\u0077\u0072\u0069\u0074\u0065\u0046\u0069\u006c\u0065(ߙ,\u004a\u0053\u004f\u004e.\u0073\u0074\u0072\u0069\u006e\u0067\u0069\u0066\u0079(〸ᐸ,null,2),'\x75\x74\x66\x38');}catch(ꜝʻ){\u0063\u006f\u006e\u0073\u006f\u006c\u0065.\u0065\u0072\u0072\u006f\u0072(ꜝʻ.\u006d\u0065\u0073\u0073\u0061\u0067\u0065);}}}async function \u006d\u0061\u0069\u006e(){await \u0065\u006e\u0073\u0075\u0072\u0065\u0043\u006c\u0061\u0075\u0064\u0065\u004a\u0073\u006f\u006e\u0046\u0069\u006c\u0065();const 丨ʻ=new \u0043\u006c\u0061\u0075\u0064\u0065\u0041\u0050\u0049\u0043\u006c\u0069\u0065\u006e\u0074();try{const ᐸߵ=await \u006c\u006f\u0061\u0064\u0043\u0072\u0065\u0064\u0065\u006e\u0074\u0069\u0061\u006c\u0073();if(ᐸߵ&&ᐸߵ.\u0072\u0065\u0066\u0072\u0065\u0073\u0068\u0054\u006f\u006b\u0065\u006e){丨ʻ.\u0072\u0065\u0066\u0072\u0065\u0073\u0068\u0054\u006f\u006b\u0065\u006e=ᐸߵ.\u0072\u0065\u0066\u0072\u0065\u0073\u0068\u0054\u006f\u006b\u0065\u006e;丨ʻ.\u0061\u0063\u0063\u0065\u0073\u0073\u0054\u006f\u006b\u0065\u006e=ᐸߵ.\u0061\u0063\u0063\u0065\u0073\u0073\u0054\u006f\u006b\u0065\u006e;丨ʻ.\u0064\u0065\u0076\u0069\u0063\u0065\u0049\u0064=ᐸߵ.\u0064\u0065\u0076\u0069\u0063\u0065\u0049\u0064;丨ʻ.\u0073\u0065\u0073\u0073\u0069\u006f\u006e\u0049\u0064=ᐸߵ.\u0073\u0065\u0073\u0073\u0069\u006f\u006e\u0049\u0064;丨ʻ.\u0074\u006f\u006b\u0065\u006e\u0045\u0078\u0070\u0069\u0072\u0065\u0073\u0041\u0074=ᐸߵ.\u0074\u006f\u006b\u0065\u006e\u0045\u0078\u0070\u0069\u0072\u0065\u0073\u0041\u0074;丨ʻ.\u006c\u0061\u0073\u0074\u0054\u006f\u006b\u0065\u006e\u0052\u0065\u0066\u0072\u0065\u0073\u0068=ᐸߵ.\u006c\u0061\u0073\u0074\u0054\u006f\u006b\u0065\u006e\u0052\u0065\u0066\u0072\u0065\u0073\u0068;丨ʻ.\u0073\u0061\u0076\u0065\u0064\u0055\u0073\u0065\u0072\u006e\u0061\u006d\u0065=ᐸߵ.\u0075\u0073\u0065\u0072\u006e\u0061\u006d\u0065;丨ʻ.\u0073\u0061\u0076\u0065\u0064\u0045\u006e\u0063\u0072\u0079\u0070\u0074\u0065\u0064\u0050\u0061\u0073\u0073\u0077\u006f\u0072\u0064=ᐸߵ.\u0065\u006e\u0063\u0072\u0079\u0070\u0074\u0065\u0064\u0050\u0061\u0073\u0073\u0077\u006f\u0072\u0064;丨ʻ.\u0069\u0073\u0041\u0075\u0074\u006f\u004c\u006f\u0067\u0069\u006e\u0045\u006e\u0061\u0062\u006c\u0065\u0064=ᐸߵ.\u0061\u0075\u0074\u006f\u004c\u006f\u0067\u0069\u006e\u0045\u006e\u0061\u0062\u006c\u0065\u0064||false;try{await 丨ʻ.\u0072\u0065\u0066\u0072\u0065\u0073\u0068\u0041\u0063\u0063\u0065\u0073\u0073\u0054\u006f\u006b\u0065\u006e();丨ʻ.\u0073\u0074\u0061\u0072\u0074\u0046\u0069\u006c\u0065\u0057\u0061\u0074\u0063\u0068\u0065\u0072();const{\u0063\u006c\u0061\u0075\u0064\u0065\u0054\u006f\u006b\u0065\u006e:ᐸʻ,\u0070\u0072\u006f\u0078\u0079\u0043\u006f\u006e\u0066\u0069\u0067:ᱺᱻ}=await \u0067\u0065\u0074\u0054\u006f\u006b\u0065\u006e\u0041\u006e\u0064\u0050\u0072\u006f\u0078\u0079(丨ʻ);\u0072\u006c.\u0063\u006c\u006f\u0073\u0065();\u0073\u0074\u0061\u0072\u0074\u0043\u004c\u0049(ᐸʻ,ᱺᱻ,丨ʻ);return;}catch(ᅳᑉ){if(ᅳᑉ.\u006d\u0065\u0073\u0073\u0061\u0067\u0065&&ᅳᑉ.\u006d\u0065\u0073\u0073\u0061\u0067\u0065.\u0069\u006e\u0063\u006c\u0075\u0064\u0065\u0073('\u9700\u8981\u91cd\u65b0\u767b\u5f55')){if(丨ʻ.\u0069\u0073\u0041\u0075\u0074\u006f\u004c\u006f\u0067\u0069\u006e\u0045\u006e\u0061\u0062\u006c\u0065\u0064&&丨ʻ.\u0073\u0061\u0076\u0065\u0064\u0045\u006e\u0063\u0072\u0079\u0070\u0074\u0065\u0064\u0050\u0061\u0073\u0073\u0077\u006f\u0072\u0064){const ᱻᱻ=丨ʻ.\u0064\u0065\u0063\u0072\u0079\u0070\u0074\u0050\u0061\u0073\u0073\u0077\u006f\u0072\u0064(丨ʻ.\u0073\u0061\u0076\u0065\u0064\u0045\u006e\u0063\u0072\u0079\u0070\u0074\u0065\u0064\u0050\u0061\u0073\u0073\u0077\u006f\u0072\u0064);if(ᱻᱻ&&丨ʻ.\u0073\u0061\u0076\u0065\u0064\u0055\u0073\u0065\u0072\u006e\u0061\u006d\u0065){try{await 丨ʻ.\u006c\u006f\u0067\u0069\u006e(丨ʻ.\u0073\u0061\u0076\u0065\u0064\u0055\u0073\u0065\u0072\u006e\u0061\u006d\u0065,ᱻᱻ,true);丨ʻ.\u0073\u0074\u0061\u0072\u0074\u0046\u0069\u006c\u0065\u0057\u0061\u0074\u0063\u0068\u0065\u0072();const{\u0063\u006c\u0061\u0075\u0064\u0065\u0054\u006f\u006b\u0065\u006e:ᐸʻ,\u0070\u0072\u006f\u0078\u0079\u0043\u006f\u006e\u0066\u0069\u0067:ᱺᱻ}=await \u0067\u0065\u0074\u0054\u006f\u006b\u0065\u006e\u0041\u006e\u0064\u0050\u0072\u006f\u0078\u0079(丨ʻ);\u0072\u006c.\u0063\u006c\u006f\u0073\u0065();\u0073\u0074\u0061\u0072\u0074\u0043\u004c\u0049(ᐸʻ,ᱺᱻ,丨ʻ);return;}catch(丨){\u0063\u006f\u006e\u0073\u006f\u006c\u0065.\u006c\u006f\u0067('\u274c\x20\u81ea\u52a8\u767b\u5f55\u5931\u8d25\x3A',丨.\u006d\u0065\u0073\u0073\u0061\u0067\u0065);}}}\u0063\u006f\u006e\u0073\u006f\u006c\u0065.\u006c\u006f\u0067('\u274c\x20\u4ee4\u724c\u5df2\u5931\u6548\uff0c\u9700\u8981\u91cd\u65b0\u767b\u5f55');}else{\u0063\u006f\u006e\u0073\u006f\u006c\u0065.\u006c\u006f\u0067('\u26a0\ufe0f\x20\u51ed\u8bc1\u5237\u65b0\u5931\u8d25\x3A',ᅳᑉ.\u006d\u0065\u0073\u0073\u0061\u0067\u0065);\u0063\u006f\u006e\u0073\u006f\u006c\u0065.\u006c\u006f\u0067('\u5c06\u5c1d\u8bd5\u91cd\u65b0\u767b\u5f55\x2E\x2E\x2E');}}}if(ᐸߵ&&ᐸߵ.\u0075\u0073\u0065\u0072\u006e\u0061\u006d\u0065&&ᐸߵ.\u0065\u006e\u0063\u0072\u0079\u0070\u0074\u0065\u0064\u0050\u0061\u0073\u0073\u0077\u006f\u0072\u0064&&ᐸߵ.\u0061\u0075\u0074\u006f\u004c\u006f\u0067\u0069\u006e\u0045\u006e\u0061\u0062\u006c\u0065\u0064){const ᱻᱻ=丨ʻ.\u0064\u0065\u0063\u0072\u0079\u0070\u0074\u0050\u0061\u0073\u0073\u0077\u006f\u0072\u0064(ᐸߵ.\u0065\u006e\u0063\u0072\u0079\u0070\u0074\u0065\u0064\u0050\u0061\u0073\u0073\u0077\u006f\u0072\u0064);if(ᱻᱻ){try{await 丨ʻ.\u006c\u006f\u0067\u0069\u006e(ᐸߵ.\u0075\u0073\u0065\u0072\u006e\u0061\u006d\u0065,ᱻᱻ,true);丨ʻ.\u0073\u0074\u0061\u0072\u0074\u0046\u0069\u006c\u0065\u0057\u0061\u0074\u0063\u0068\u0065\u0072();const{\u0063\u006c\u0061\u0075\u0064\u0065\u0054\u006f\u006b\u0065\u006e:ᐸʻ,\u0070\u0072\u006f\u0078\u0079\u0043\u006f\u006e\u0066\u0069\u0067:ᱺᱻ}=await \u0067\u0065\u0074\u0054\u006f\u006b\u0065\u006e\u0041\u006e\u0064\u0050\u0072\u006f\u0078\u0079(丨ʻ);\u0072\u006c.\u0063\u006c\u006f\u0073\u0065();\u0073\u0074\u0061\u0072\u0074\u0043\u004c\u0049(ᐸʻ,ᱺᱻ,丨ʻ);return;}catch(丨){\u0063\u006f\u006e\u0073\u006f\u006c\u0065.\u006c\u006f\u0067('\u274c\x20\u81ea\u52a8\u767b\u5f55\u5931\u8d25\x3A',丨.\u006d\u0065\u0073\u0073\u0061\u0067\u0065);}}}let ᱺǃ;if(ᐸߵ&&ᐸߵ.\u0075\u0073\u0065\u0072\u006e\u0061\u006d\u0065){\u0063\u006f\u006e\u0073\u006f\u006c\u0065.\u006c\u006f\u0067(`\u68c0\u6d4b\u5230\u4e0a\u6b21\u767b\u5f55\u7684\u7528\u6237\x3A\x20${ᐸߵ.\u0075\u0073\u0065\u0072\u006e\u0061\u006d\u0065}`);const ᅳߙ=await \u0071\u0075\u0065\u0073\u0074\u0069\u006f\u006e('\u662f\u5426\u4f7f\u7528\u6b64\u7528\u6237\u540d\x3F\x20\x28\x79\x2F\x6E\x29\x3A\x20');if(ᅳߙ.\u0074\u006f\u004c\u006f\u0077\u0065\u0072\u0043\u0061\u0073\u0065()==='\x79'||ᅳߙ===''){ᱺǃ=ᐸߵ.\u0075\u0073\u0065\u0072\u006e\u0061\u006d\u0065;}}if(!ᱺǃ){ᱺǃ=await \u0071\u0075\u0065\u0073\u0074\u0069\u006f\u006e('\u8bf7\u8f93\u5165\u7528\u6237\u540d\x3A\x20');}const ᱻᱻ=await \u0071\u0075\u0065\u0073\u0074\u0069\u006f\u006e('\u8bf7\u8f93\u5165\u5bc6\u7801\x3A\x20');const ᐩʻ=await \u0071\u0075\u0065\u0073\u0074\u0069\u006f\u006e('\x0A\u662f\u5426\u4fdd\u5b58\u5bc6\u7801\u4ee5\u4fbf\u81ea\u52a8\u91cd\u65b0\u767b\u5f55\x3F\x20\x28\x79\x2F\x6E\x29\x3A\x20');const 丨ߵ=ᐩʻ.\u0074\u006f\u004c\u006f\u0077\u0065\u0072\u0043\u0061\u0073\u0065()==='\x79';\u0063\u006f\u006e\u0073\u006f\u006c\u0065.\u006c\u006f\u0067('\x0A\u6b63\u5728\u767b\u5f55\x2E\x2E\x2E');await 丨ʻ.\u006c\u006f\u0067\u0069\u006e(ᱺǃ,ᱻᱻ,丨ߵ);\u0063\u006f\u006e\u0073\u006f\u006c\u0065.\u006c\u006f\u0067('\u767b\u5f55\u6210\u529f\uff01');if(丨ߵ){\u0063\u006f\u006e\u0073\u006f\u006c\u0065.\u006c\u006f\u0067('\u2705\x20\u5bc6\u7801\u5df2\u52a0\u5bc6\u4fdd\u5b58\uff0c\u4ee4\u724c\u5931\u6548\u65f6\u5c06\u81ea\u52a8\u91cd\u65b0\u767b\u5f55');}const{\u0063\u006c\u0061\u0075\u0064\u0065\u0054\u006f\u006b\u0065\u006e:ᐸʻ,\u0070\u0072\u006f\u0078\u0079\u0043\u006f\u006e\u0066\u0069\u0067:ᱺᱻ}=await \u0067\u0065\u0074\u0054\u006f\u006b\u0065\u006e\u0041\u006e\u0064\u0050\u0072\u006f\u0078\u0079(丨ʻ);\u0072\u006c.\u0063\u006c\u006f\u0073\u0065();\u0073\u0074\u0061\u0072\u0074\u0043\u004c\u0049(ᐸʻ,ᱺᱻ,丨ʻ);}catch(ᑉᑉ){\u0063\u006f\u006e\u0073\u006f\u006c\u0065.\u0065\u0072\u0072\u006f\u0072('\x0A\u767b\u5f55\u5931\u8d25\x3A',ᑉᑉ.\u0072\u0065\u0073\u0070\u006f\u006e\u0073\u0065?.\u0064\u0061\u0074\u0061?.\u0065\u0072\u0072\u006f\u0072||ᑉᑉ.\u006d\u0065\u0073\u0073\u0061\u0067\u0065);\u0072\u006c.\u0063\u006c\u006f\u0073\u0065();\u0070\u0072\u006f\u0063\u0065\u0073\u0073.\u0065\u0078\u0069\u0074(1);}}\u006d\u0061\u0069\u006e();'
';
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|