@anthropic-ai/claude-code 1.0.35 → 1.0.36
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 +621 -618
- package/package.json +1 -1
- package/sdk.d.ts +1 -1
- package/sdk.mjs +19 -5
- package/vendor/claude-code.vsix +0 -0
package/package.json
CHANGED
package/sdk.d.ts
CHANGED
package/sdk.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
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
2
|
|
|
3
|
-
// Version: 1.0.
|
|
3
|
+
// Version: 1.0.36
|
|
4
4
|
|
|
5
5
|
// src/entrypoints/sdk.ts
|
|
6
6
|
import { spawn } from "child_process";
|
|
@@ -68,10 +68,11 @@ async function* query({
|
|
|
68
68
|
}
|
|
69
69
|
args.push("--fallback-model", fallbackModel);
|
|
70
70
|
}
|
|
71
|
-
if (
|
|
72
|
-
|
|
71
|
+
if (typeof prompt === "string") {
|
|
72
|
+
args.push("--print", prompt.trim());
|
|
73
|
+
} else {
|
|
74
|
+
args.push("--input-format", "stream-json");
|
|
73
75
|
}
|
|
74
|
-
args.push("--print", prompt.trim());
|
|
75
76
|
if (!existsSync(pathToClaudeCodeExecutable)) {
|
|
76
77
|
throw new ReferenceError(`Claude Code executable not found at ${pathToClaudeCodeExecutable}. Is options.pathToClaudeCodeExecutable set?`);
|
|
77
78
|
}
|
|
@@ -84,7 +85,11 @@ async function* query({
|
|
|
84
85
|
...process.env
|
|
85
86
|
}
|
|
86
87
|
});
|
|
87
|
-
|
|
88
|
+
if (typeof prompt === "string") {
|
|
89
|
+
child.stdin.end();
|
|
90
|
+
} else {
|
|
91
|
+
streamToStdin(prompt, child.stdin, abortController);
|
|
92
|
+
}
|
|
88
93
|
if (process.env.DEBUG) {
|
|
89
94
|
child.stderr.on("data", (data) => {
|
|
90
95
|
console.error("Claude Code stderr:", data.toString());
|
|
@@ -136,6 +141,15 @@ async function* query({
|
|
|
136
141
|
}
|
|
137
142
|
}
|
|
138
143
|
}
|
|
144
|
+
async function streamToStdin(stream, stdin, abortController) {
|
|
145
|
+
for await (const message of stream) {
|
|
146
|
+
if (abortController.signal.aborted)
|
|
147
|
+
break;
|
|
148
|
+
stdin.write(JSON.stringify(message) + `
|
|
149
|
+
`);
|
|
150
|
+
}
|
|
151
|
+
stdin.end();
|
|
152
|
+
}
|
|
139
153
|
function logDebug(message) {
|
|
140
154
|
if (process.env.DEBUG) {
|
|
141
155
|
console.debug(message);
|
package/vendor/claude-code.vsix
CHANGED
|
Binary file
|