@ai-sdk/harness-claude-code 1.0.179 → 1.0.181
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 +20 -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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ai-sdk/harness-claude-code",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.181",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -26,9 +26,9 @@
|
|
|
26
26
|
}
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@ai-sdk/harness": "1.0.
|
|
30
|
-
"@ai-sdk/provider": "4.0.
|
|
31
|
-
"@ai-sdk/provider-utils": "5.0.
|
|
29
|
+
"@ai-sdk/harness": "1.0.177",
|
|
30
|
+
"@ai-sdk/provider": "4.0.37",
|
|
31
|
+
"@ai-sdk/provider-utils": "5.0.76",
|
|
32
32
|
"ws": "^8.21.0"
|
|
33
33
|
},
|
|
34
34
|
"peerDependencies": {
|
package/src/bridge/index.ts
CHANGED
|
@@ -937,6 +937,7 @@ async function runTurn(start: StartMessage, turn: BridgeTurn): Promise<void> {
|
|
|
937
937
|
...permissionOptions,
|
|
938
938
|
...(Object.keys(settings).length > 0 ? { settings } : {}),
|
|
939
939
|
mcpServers,
|
|
940
|
+
settingSources: ['user'],
|
|
940
941
|
cwd: workdir,
|
|
941
942
|
abortSignal: abortCtl.signal,
|
|
942
943
|
},
|
package/src/claude-code-auth.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { execFileSync } from 'node:child_process';
|
|
1
|
+
import { execFileSync, execSync } from 'node:child_process';
|
|
2
2
|
import { readFileSync } from 'node:fs';
|
|
3
3
|
import { homedir } from 'node:os';
|
|
4
4
|
import { join } from 'node:path';
|
|
@@ -169,7 +169,10 @@ function pickAnthropic({
|
|
|
169
169
|
* it. The `claude` CLI uses this hook to fetch credentials from password
|
|
170
170
|
* managers and similar tools; mirroring it here lets users with that
|
|
171
171
|
* setup run the harness without having to set `ANTHROPIC_API_KEY`
|
|
172
|
-
* explicitly.
|
|
172
|
+
* explicitly. It preserves existing helper commands by using `sh` from
|
|
173
|
+
* PATH when available. If `sh` cannot be found, it uses the system shell:
|
|
174
|
+
* `/bin/sh` on macOS and Linux, `cmd.exe` on Windows. Only a missing shell
|
|
175
|
+
* triggers fallback, so a helper that fails is never executed twice.
|
|
173
176
|
*/
|
|
174
177
|
function readApiKeyHelper(): string | undefined {
|
|
175
178
|
const home = homedir();
|
|
@@ -189,10 +192,27 @@ function readApiKeyHelper(): string | undefined {
|
|
|
189
192
|
const command = settings.apiKeyHelper;
|
|
190
193
|
if (typeof command !== 'string' || command.length === 0) return undefined;
|
|
191
194
|
try {
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
195
|
+
let output: string;
|
|
196
|
+
try {
|
|
197
|
+
output = execFileSync('sh', ['-c', command], {
|
|
198
|
+
encoding: 'utf8',
|
|
199
|
+
stdio: ['ignore', 'pipe', 'ignore'],
|
|
200
|
+
windowsHide: true,
|
|
201
|
+
});
|
|
202
|
+
} catch (error) {
|
|
203
|
+
if (
|
|
204
|
+
!(error instanceof Error) ||
|
|
205
|
+
!('code' in error) ||
|
|
206
|
+
error.code !== 'ENOENT'
|
|
207
|
+
) {
|
|
208
|
+
return undefined;
|
|
209
|
+
}
|
|
210
|
+
output = execSync(command, {
|
|
211
|
+
encoding: 'utf8',
|
|
212
|
+
stdio: ['ignore', 'pipe', 'ignore'],
|
|
213
|
+
windowsHide: true,
|
|
214
|
+
});
|
|
215
|
+
}
|
|
196
216
|
const trimmed = output.trim();
|
|
197
217
|
return trimmed.length > 0 ? trimmed : undefined;
|
|
198
218
|
} catch {
|