@ai-sdk/harness-claude-code 1.0.179 → 1.0.180
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/CHANGELOG.md +14 -0
- package/dist/bridge/index.mjs +1 -0
- package/dist/bridge/index.mjs.map +1 -1
- package/dist/index.js +30 -11
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
- package/src/bridge/index.ts +1 -0
- package/src/claude-code-auth.ts +26 -6
package/dist/index.js
CHANGED
|
@@ -4,7 +4,7 @@ import { SandboxChannel, applyCredentialForwarding, classifyDiskLog, createBridg
|
|
|
4
4
|
import { generateId, isRecord, safeParseJSON, tool } from "@ai-sdk/provider-utils";
|
|
5
5
|
import { WebSocket } from "ws";
|
|
6
6
|
import { z } from "zod/v4";
|
|
7
|
-
import { execFileSync } from "node:child_process";
|
|
7
|
+
import { execFileSync, execSync } from "node:child_process";
|
|
8
8
|
import { readFileSync } from "node:fs";
|
|
9
9
|
import { homedir } from "node:os";
|
|
10
10
|
import { chmod, mkdir, readFile, rename, writeFile } from "node:fs/promises";
|
|
@@ -112,7 +112,10 @@ function pickAnthropic({ processEnv, readApiKey }) {
|
|
|
112
112
|
* it. The `claude` CLI uses this hook to fetch credentials from password
|
|
113
113
|
* managers and similar tools; mirroring it here lets users with that
|
|
114
114
|
* setup run the harness without having to set `ANTHROPIC_API_KEY`
|
|
115
|
-
* explicitly.
|
|
115
|
+
* explicitly. It preserves existing helper commands by using `sh` from
|
|
116
|
+
* PATH when available. If `sh` cannot be found, it uses the system shell:
|
|
117
|
+
* `/bin/sh` on macOS and Linux, `cmd.exe` on Windows. Only a missing shell
|
|
118
|
+
* triggers fallback, so a helper that fails is never executed twice.
|
|
116
119
|
*/
|
|
117
120
|
function readApiKeyHelper() {
|
|
118
121
|
const home = homedir();
|
|
@@ -132,14 +135,30 @@ function readApiKeyHelper() {
|
|
|
132
135
|
const command = settings.apiKeyHelper;
|
|
133
136
|
if (typeof command !== "string" || command.length === 0) return void 0;
|
|
134
137
|
try {
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
"
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
138
|
+
let output;
|
|
139
|
+
try {
|
|
140
|
+
output = execFileSync("sh", ["-c", command], {
|
|
141
|
+
encoding: "utf8",
|
|
142
|
+
stdio: [
|
|
143
|
+
"ignore",
|
|
144
|
+
"pipe",
|
|
145
|
+
"ignore"
|
|
146
|
+
],
|
|
147
|
+
windowsHide: true
|
|
148
|
+
});
|
|
149
|
+
} catch (error) {
|
|
150
|
+
if (!(error instanceof Error) || !("code" in error) || error.code !== "ENOENT") return;
|
|
151
|
+
output = execSync(command, {
|
|
152
|
+
encoding: "utf8",
|
|
153
|
+
stdio: [
|
|
154
|
+
"ignore",
|
|
155
|
+
"pipe",
|
|
156
|
+
"ignore"
|
|
157
|
+
],
|
|
158
|
+
windowsHide: true
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
const trimmed = output.trim();
|
|
143
162
|
return trimmed.length > 0 ? trimmed : void 0;
|
|
144
163
|
} catch {
|
|
145
164
|
return;
|
|
@@ -326,7 +345,7 @@ const startMessageSchema = harnessV1BridgeStartBaseSchema.extend({
|
|
|
326
345
|
z.discriminatedUnion("type", [startMessageSchema, ...harnessV1BridgeInboundCommandSchemas]);
|
|
327
346
|
//#endregion
|
|
328
347
|
//#region src/version.ts
|
|
329
|
-
const VERSION = "1.0.
|
|
348
|
+
const VERSION = "1.0.180";
|
|
330
349
|
//#endregion
|
|
331
350
|
//#region src/claude-code-harness.ts
|
|
332
351
|
/**
|