@ai-sdk/harness-claude-code 1.0.180 → 1.0.183
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 +27 -0
- package/dist/bridge/index.mjs +72 -9
- package/dist/bridge/index.mjs.map +1 -1
- package/dist/bridge/package.json +3 -3
- package/dist/bridge/pnpm-lockfile.yaml +146 -141
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +19 -17
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
- package/src/bridge/index.ts +1 -1
- package/src/bridge/package.json +3 -3
- package/src/claude-code-harness.ts +23 -21
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.183",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -26,17 +26,17 @@
|
|
|
26
26
|
}
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@ai-sdk/harness": "1.0.
|
|
29
|
+
"@ai-sdk/harness": "1.0.179",
|
|
30
30
|
"@ai-sdk/provider": "4.0.37",
|
|
31
|
-
"@ai-sdk/provider-utils": "5.0.
|
|
31
|
+
"@ai-sdk/provider-utils": "5.0.78",
|
|
32
32
|
"ws": "^8.21.0"
|
|
33
33
|
},
|
|
34
34
|
"peerDependencies": {
|
|
35
35
|
"zod": "^3.25.76 || ^4.1.8"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
|
-
"@anthropic-ai/claude-agent-sdk": "0.3.
|
|
39
|
-
"@modelcontextprotocol/sdk": "1.32.
|
|
38
|
+
"@anthropic-ai/claude-agent-sdk": "0.3.319",
|
|
39
|
+
"@modelcontextprotocol/sdk": "1.32.2",
|
|
40
40
|
"@types/node": "22.19.19",
|
|
41
41
|
"@types/ws": "^8.5.13",
|
|
42
42
|
"@vercel/ai-tsconfig": "0.0.0",
|
package/src/bridge/index.ts
CHANGED
|
@@ -939,7 +939,7 @@ async function runTurn(start: StartMessage, turn: BridgeTurn): Promise<void> {
|
|
|
939
939
|
mcpServers,
|
|
940
940
|
settingSources: ['user'],
|
|
941
941
|
cwd: workdir,
|
|
942
|
-
|
|
942
|
+
abortController: abortCtl,
|
|
943
943
|
},
|
|
944
944
|
};
|
|
945
945
|
let deferredToolUseId = start.deferredToolUseId;
|
package/src/bridge/package.json
CHANGED
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
"private": true,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"dependencies": {
|
|
7
|
-
"@anthropic-ai/claude-agent-sdk": "0.3.
|
|
8
|
-
"@anthropic-ai/claude-code": "2.1.
|
|
9
|
-
"@modelcontextprotocol/sdk": "1.32.
|
|
7
|
+
"@anthropic-ai/claude-agent-sdk": "0.3.319",
|
|
8
|
+
"@anthropic-ai/claude-code": "2.1.319",
|
|
9
|
+
"@modelcontextprotocol/sdk": "1.32.2",
|
|
10
10
|
"ws": "8.21.0",
|
|
11
11
|
"zod": "4.4.3"
|
|
12
12
|
}
|
|
@@ -26,7 +26,8 @@ import {
|
|
|
26
26
|
applyCredentialForwarding,
|
|
27
27
|
classifyDiskLog,
|
|
28
28
|
resolveSandboxCredentialEnvironment,
|
|
29
|
-
|
|
29
|
+
BRIDGE_AUTH_PUBLIC_KEY_ENV,
|
|
30
|
+
createBridgeAuthKeyPair,
|
|
30
31
|
createBridgeWebSocketConnect,
|
|
31
32
|
experimental_createBridgeUserMessageSubmitter,
|
|
32
33
|
createBridgeErrorHandler,
|
|
@@ -43,6 +44,7 @@ import {
|
|
|
43
44
|
shellQuote,
|
|
44
45
|
validateBridgeSandboxSettings,
|
|
45
46
|
warnCredentialBrokeringUnavailable,
|
|
47
|
+
warnMintBridgeTokenIgnored,
|
|
46
48
|
waitForBridgeReady,
|
|
47
49
|
writeSkills,
|
|
48
50
|
type BridgeHello,
|
|
@@ -217,9 +219,10 @@ export type ClaudeCodeHarnessSettings = {
|
|
|
217
219
|
* contain connection details, so avoid logging it as is.
|
|
218
220
|
*/
|
|
219
221
|
readonly onDebug?: (event: SandboxChannelDebugEvent) => void;
|
|
222
|
+
// TODO: Remove in the next major version.
|
|
220
223
|
/**
|
|
221
|
-
*
|
|
222
|
-
*
|
|
224
|
+
* @deprecated Sandbox bridge authentication now uses adapter-generated
|
|
225
|
+
* Ed25519 keys. This setting is ignored and emits a warning.
|
|
223
226
|
*/
|
|
224
227
|
readonly mintBridgeToken?: HarnessV1MintBridgeTokenCallback;
|
|
225
228
|
};
|
|
@@ -870,7 +873,7 @@ const CLAUDE_CODE_BUILTIN_TOOLS = {
|
|
|
870
873
|
*/
|
|
871
874
|
const claudeCodeBridgeCoordsSchema = z.object({
|
|
872
875
|
port: z.number(),
|
|
873
|
-
|
|
876
|
+
privateKey: z.string(),
|
|
874
877
|
lastSeenEventId: z.number(),
|
|
875
878
|
startId: z.string().optional(),
|
|
876
879
|
sandboxId: z.string().optional(),
|
|
@@ -906,6 +909,10 @@ type ClaudeCodeBridgeCoords = z.infer<typeof claudeCodeBridgeCoordsSchema>;
|
|
|
906
909
|
export function createClaudeCode(
|
|
907
910
|
settings: ClaudeCodeHarnessSettings = {},
|
|
908
911
|
): HarnessV1<typeof CLAUDE_CODE_BUILTIN_TOOLS> {
|
|
912
|
+
warnMintBridgeTokenIgnored({
|
|
913
|
+
harnessId: 'claude-code',
|
|
914
|
+
mintBridgeToken: settings.mintBridgeToken,
|
|
915
|
+
});
|
|
909
916
|
if (
|
|
910
917
|
settings.mcpServers != null &&
|
|
911
918
|
Object.prototype.hasOwnProperty.call(settings.mcpServers, 'harness-tools')
|
|
@@ -934,10 +941,8 @@ export function createClaudeCode(
|
|
|
934
941
|
const sandboxId = 'id' in sandboxSession ? sandboxSession.id : undefined;
|
|
935
942
|
validateBridgeSandboxSettings({
|
|
936
943
|
sandboxSession,
|
|
937
|
-
sandboxId,
|
|
938
944
|
portOverride: settings.port,
|
|
939
945
|
portEndpointOverride: settings.portEndpoint,
|
|
940
|
-
mintBridgeToken: settings.mintBridgeToken,
|
|
941
946
|
});
|
|
942
947
|
const lifecycleState = startOpts.continueFrom ?? startOpts.resumeFrom;
|
|
943
948
|
const isResume = lifecycleState != null;
|
|
@@ -1076,7 +1081,7 @@ export function createClaudeCode(
|
|
|
1076
1081
|
* Rung 1 — ATTACH. When lifecycle state carries live bridge coordinates,
|
|
1077
1082
|
* try to reopen a socket to the still-running bridge. Parked sessions wait
|
|
1078
1083
|
* for the next `start`; suspended turns request replay of everything past
|
|
1079
|
-
* the persisted cursor. No spawn, no fresh
|
|
1084
|
+
* the persisted cursor. No spawn, no fresh key (the existing bridge
|
|
1080
1085
|
* still authorises the persisted one). If the bridge is gone the open
|
|
1081
1086
|
* throws and we fall through to a spawn-based recovery.
|
|
1082
1087
|
*/
|
|
@@ -1086,11 +1091,11 @@ export function createClaudeCode(
|
|
|
1086
1091
|
sandboxSession,
|
|
1087
1092
|
port: coords.port,
|
|
1088
1093
|
portEndpointOverride: settings.portEndpoint,
|
|
1089
|
-
token: coords.token,
|
|
1090
1094
|
});
|
|
1091
1095
|
const attachChannel: ClaudeCodeChannel = new SandboxChannel({
|
|
1092
1096
|
connect: createBridgeWebSocketConnect({
|
|
1093
1097
|
endpoint: attachEndpoint,
|
|
1098
|
+
privateKey: coords.privateKey,
|
|
1094
1099
|
webSocketConstructor: WebSocket,
|
|
1095
1100
|
onHello,
|
|
1096
1101
|
}),
|
|
@@ -1136,7 +1141,7 @@ export function createClaudeCode(
|
|
|
1136
1141
|
continueOnFirstPrompt: false,
|
|
1137
1142
|
rerunContinue: false,
|
|
1138
1143
|
bridgePort: coords.port,
|
|
1139
|
-
|
|
1144
|
+
bridgePrivateKey: coords.privateKey,
|
|
1140
1145
|
sandboxId,
|
|
1141
1146
|
sandboxCredentialEnvironment,
|
|
1142
1147
|
debug: startOpts.observability?.debug,
|
|
@@ -1183,12 +1188,9 @@ export function createClaudeCode(
|
|
|
1183
1188
|
sandboxSession,
|
|
1184
1189
|
portOverride: settings.port,
|
|
1185
1190
|
});
|
|
1186
|
-
const
|
|
1187
|
-
settings.mintBridgeToken == null
|
|
1188
|
-
? createBridgeToken()
|
|
1189
|
-
: settings.mintBridgeToken(sandboxId!);
|
|
1191
|
+
const bridgeAuth = createBridgeAuthKeyPair();
|
|
1190
1192
|
const env = {
|
|
1191
|
-
|
|
1193
|
+
[BRIDGE_AUTH_PUBLIC_KEY_ENV]: bridgeAuth.publicKey,
|
|
1192
1194
|
BRIDGE_WS_PORT: String(port),
|
|
1193
1195
|
...(respawnStrategy === 'replay'
|
|
1194
1196
|
? { BRIDGE_REPLAY_FROM_DISK: '1' }
|
|
@@ -1198,7 +1200,7 @@ export function createClaudeCode(
|
|
|
1198
1200
|
/*
|
|
1199
1201
|
* On a fresh start the workdir and bridge-state directory must be
|
|
1200
1202
|
* created. The env is sent fresh on every spawn —
|
|
1201
|
-
*
|
|
1203
|
+
* the bridge authentication key pair rotates per start.
|
|
1202
1204
|
*/
|
|
1203
1205
|
if (respawnStrategy === undefined) {
|
|
1204
1206
|
await toolSafeSandboxSession.run({
|
|
@@ -1258,12 +1260,12 @@ export function createClaudeCode(
|
|
|
1258
1260
|
sandboxSession,
|
|
1259
1261
|
port: boundPort,
|
|
1260
1262
|
portEndpointOverride: settings.portEndpoint,
|
|
1261
|
-
token,
|
|
1262
1263
|
});
|
|
1263
1264
|
|
|
1264
1265
|
const channel: ClaudeCodeChannel = new SandboxChannel({
|
|
1265
1266
|
connect: createBridgeWebSocketConnect({
|
|
1266
1267
|
endpoint: bridgeEndpoint,
|
|
1268
|
+
privateKey: bridgeAuth.privateKey,
|
|
1267
1269
|
webSocketConstructor: WebSocket,
|
|
1268
1270
|
openRetryTimeoutMs: timeoutMs,
|
|
1269
1271
|
startAbortSignal: startOpts.abortSignal,
|
|
@@ -1326,7 +1328,7 @@ export function createClaudeCode(
|
|
|
1326
1328
|
}
|
|
1327
1329
|
: {}),
|
|
1328
1330
|
bridgePort: boundPort,
|
|
1329
|
-
|
|
1331
|
+
bridgePrivateKey: bridgeAuth.privateKey,
|
|
1330
1332
|
sandboxId,
|
|
1331
1333
|
sandboxCredentialEnvironment,
|
|
1332
1334
|
debug: startOpts.observability?.debug,
|
|
@@ -1375,7 +1377,7 @@ function createSession({
|
|
|
1375
1377
|
rerunContinue,
|
|
1376
1378
|
deferredToolUseId,
|
|
1377
1379
|
bridgePort,
|
|
1378
|
-
|
|
1380
|
+
bridgePrivateKey,
|
|
1379
1381
|
sandboxId,
|
|
1380
1382
|
sandboxCredentialEnvironment,
|
|
1381
1383
|
debug,
|
|
@@ -1423,7 +1425,7 @@ function createSession({
|
|
|
1423
1425
|
*/
|
|
1424
1426
|
deferredToolUseId?: string;
|
|
1425
1427
|
bridgePort: number;
|
|
1426
|
-
|
|
1428
|
+
bridgePrivateKey: string;
|
|
1427
1429
|
sandboxId: string | undefined;
|
|
1428
1430
|
sandboxCredentialEnvironment: Record<string, string> | undefined;
|
|
1429
1431
|
debug: HarnessV1DebugConfig | undefined;
|
|
@@ -1968,7 +1970,7 @@ function createSession({
|
|
|
1968
1970
|
: { sandboxCredentialEnvironment }),
|
|
1969
1971
|
bridge: {
|
|
1970
1972
|
port: bridgePort,
|
|
1971
|
-
|
|
1973
|
+
privateKey: bridgePrivateKey,
|
|
1972
1974
|
lastSeenEventId,
|
|
1973
1975
|
...(activeStartId == null ? {} : { startId: activeStartId }),
|
|
1974
1976
|
...(sandboxId == null ? {} : { sandboxId }),
|
|
@@ -2128,7 +2130,7 @@ function createSession({
|
|
|
2128
2130
|
: { sandboxCredentialEnvironment }),
|
|
2129
2131
|
bridge: {
|
|
2130
2132
|
port: bridgePort,
|
|
2131
|
-
|
|
2133
|
+
privateKey: bridgePrivateKey,
|
|
2132
2134
|
lastSeenEventId,
|
|
2133
2135
|
...(activeStartId == null ? {} : { startId: activeStartId }),
|
|
2134
2136
|
...(sandboxId == null ? {} : { sandboxId }),
|