@ai-sdk/harness-claude-code 1.0.172 → 1.0.174
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 +19 -0
- package/dist/bridge/index.mjs +19 -0
- package/dist/bridge/index.mjs.map +1 -1
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +13 -2
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
- package/src/bridge/index.ts +26 -0
- package/src/claude-code-bridge-protocol.ts +6 -0
- package/src/claude-code-harness.ts +13 -0
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.174",
|
|
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.170",
|
|
30
|
+
"@ai-sdk/provider": "4.0.35",
|
|
31
|
+
"@ai-sdk/provider-utils": "5.0.72",
|
|
32
32
|
"ws": "^8.21.0"
|
|
33
33
|
},
|
|
34
34
|
"peerDependencies": {
|
package/src/bridge/index.ts
CHANGED
|
@@ -373,6 +373,23 @@ function createPermissionSettings(input: {
|
|
|
373
373
|
};
|
|
374
374
|
}
|
|
375
375
|
|
|
376
|
+
/**
|
|
377
|
+
* Claude Code picks a model's output limit, system prompt and default effort
|
|
378
|
+
* from its own reading of the model id, and misreads AI Gateway ids with a
|
|
379
|
+
* dotted version such as `anthropic/claude-opus-5.5`. `modelOverrides` maps
|
|
380
|
+
* the id Claude Code expects (`claude-opus-5-5`) to the gateway id, which
|
|
381
|
+
* stays the id sent to the gateway.
|
|
382
|
+
*/
|
|
383
|
+
function createGatewayModelOverrides(
|
|
384
|
+
model: string | undefined,
|
|
385
|
+
): Record<string, string> | undefined {
|
|
386
|
+
if (!model?.startsWith('anthropic/')) return undefined;
|
|
387
|
+
// Claude Code matches the value against the model id, suffix included, so a
|
|
388
|
+
// suffix such as `[1m]` stays on the value.
|
|
389
|
+
const id = model.slice('anthropic/'.length).replace(/\[[^\]]*\]$/, '');
|
|
390
|
+
return id.includes('.') ? { [id.replace(/\./g, '-')]: model } : undefined;
|
|
391
|
+
}
|
|
392
|
+
|
|
376
393
|
function needsHostApproval(input: {
|
|
377
394
|
toolName: string;
|
|
378
395
|
permissionMode: 'allow-reads' | 'allow-edits' | 'allow-all';
|
|
@@ -650,6 +667,7 @@ async function runTurn(start: StartMessage, turn: BridgeTurn): Promise<void> {
|
|
|
650
667
|
approvalRequestedToolUseIds: streamEventState.approvalRequestedToolUseIds,
|
|
651
668
|
emittedToolCallIds: streamEventState.emittedToolCallIds,
|
|
652
669
|
});
|
|
670
|
+
const modelOverrides = createGatewayModelOverrides(start.model);
|
|
653
671
|
const deferredToolUseIds = new Set<string>();
|
|
654
672
|
const approvalPreToolUseHook = createApprovalPreToolUseHook({
|
|
655
673
|
permissionMode,
|
|
@@ -658,6 +676,13 @@ async function runTurn(start: StartMessage, turn: BridgeTurn): Promise<void> {
|
|
|
658
676
|
deferredToolUseIds,
|
|
659
677
|
nativeToolCallNames: streamEventState.nativeToolCallNames,
|
|
660
678
|
});
|
|
679
|
+
const settings = {
|
|
680
|
+
...(permissionOptions.settings as Record<string, unknown> | undefined),
|
|
681
|
+
...(start.skillOverrides !== undefined
|
|
682
|
+
? { skillOverrides: start.skillOverrides }
|
|
683
|
+
: {}),
|
|
684
|
+
...(modelOverrides ? { modelOverrides } : {}),
|
|
685
|
+
};
|
|
661
686
|
const questionPreToolUseHook = createQuestionPreToolUseHook({
|
|
662
687
|
turn,
|
|
663
688
|
emit,
|
|
@@ -754,6 +779,7 @@ async function runTurn(start: StartMessage, turn: BridgeTurn): Promise<void> {
|
|
|
754
779
|
? { continue: true }
|
|
755
780
|
: {}),
|
|
756
781
|
...permissionOptions,
|
|
782
|
+
...(Object.keys(settings).length > 0 ? { settings } : {}),
|
|
757
783
|
mcpServers,
|
|
758
784
|
cwd: workdir,
|
|
759
785
|
abortSignal: abortCtl.signal,
|
|
@@ -31,12 +31,18 @@ const thinkingSchema = z.discriminatedUnion('type', [
|
|
|
31
31
|
z.object({ type: z.literal('disabled') }),
|
|
32
32
|
]);
|
|
33
33
|
|
|
34
|
+
const skillOverridesSchema = z.record(
|
|
35
|
+
z.string(),
|
|
36
|
+
z.enum(['on', 'name-only', 'user-invocable-only', 'off']),
|
|
37
|
+
);
|
|
38
|
+
|
|
34
39
|
export const startMessageSchema = harnessV1BridgeStartBaseSchema.extend({
|
|
35
40
|
prompt: harnessPromptContentSchema,
|
|
36
41
|
instructions: z.string().optional(),
|
|
37
42
|
thinking: thinkingSchema,
|
|
38
43
|
effort: z.enum(['low', 'medium', 'high', 'xhigh', 'max']).optional(),
|
|
39
44
|
maxTurns: z.number().optional(),
|
|
45
|
+
skillOverrides: skillOverridesSchema.optional(),
|
|
40
46
|
maxBudgetUsd: z.number().optional(),
|
|
41
47
|
strictMcpConfig: z.boolean().optional(),
|
|
42
48
|
questionTimeoutMs: z.number().optional(),
|
|
@@ -121,6 +121,13 @@ export type ClaudeCodeHarnessSettings = {
|
|
|
121
121
|
* back to the caller. Unset means the CLI's default.
|
|
122
122
|
*/
|
|
123
123
|
readonly maxTurns?: number;
|
|
124
|
+
/**
|
|
125
|
+
* Overrides how named skills are exposed to Claude Code. Unspecified skills
|
|
126
|
+
* retain their Claude Code defaults.
|
|
127
|
+
*/
|
|
128
|
+
readonly skillOverrides?: Readonly<
|
|
129
|
+
Record<string, 'on' | 'name-only' | 'user-invocable-only' | 'off'>
|
|
130
|
+
>;
|
|
124
131
|
/**
|
|
125
132
|
* Maximum estimated spend in USD for each Claude query. When it is exceeded,
|
|
126
133
|
* the query stops and the turn ends with an error. Unset means no limit.
|
|
@@ -1096,6 +1103,7 @@ export function createClaudeCode(
|
|
|
1096
1103
|
// sandbox is left running, stopped, or destroyed.
|
|
1097
1104
|
proc: undefined,
|
|
1098
1105
|
maxTurns: settings.maxTurns,
|
|
1106
|
+
skillOverrides: settings.skillOverrides,
|
|
1099
1107
|
maxBudgetUsd: settings.maxBudgetUsd,
|
|
1100
1108
|
strictMcpConfig: settings.strictMcpConfig,
|
|
1101
1109
|
questionTimeoutMs: settings.questionTimeoutMs,
|
|
@@ -1271,6 +1279,7 @@ export function createClaudeCode(
|
|
|
1271
1279
|
finishListenerAttachment,
|
|
1272
1280
|
proc,
|
|
1273
1281
|
maxTurns: settings.maxTurns,
|
|
1282
|
+
skillOverrides: settings.skillOverrides,
|
|
1274
1283
|
maxBudgetUsd: settings.maxBudgetUsd,
|
|
1275
1284
|
strictMcpConfig: settings.strictMcpConfig,
|
|
1276
1285
|
questionTimeoutMs: settings.questionTimeoutMs,
|
|
@@ -1323,6 +1332,7 @@ function createSession({
|
|
|
1323
1332
|
finishListenerAttachment,
|
|
1324
1333
|
proc,
|
|
1325
1334
|
maxTurns,
|
|
1335
|
+
skillOverrides,
|
|
1326
1336
|
maxBudgetUsd,
|
|
1327
1337
|
strictMcpConfig,
|
|
1328
1338
|
questionTimeoutMs,
|
|
@@ -1356,6 +1366,7 @@ function createSession({
|
|
|
1356
1366
|
/** Undefined on `attach` — the live bridge was spawned by another process. */
|
|
1357
1367
|
proc: Experimental_SandboxProcess | undefined;
|
|
1358
1368
|
maxTurns: number | undefined;
|
|
1369
|
+
skillOverrides: ClaudeCodeHarnessSettings['skillOverrides'];
|
|
1359
1370
|
maxBudgetUsd: number | undefined;
|
|
1360
1371
|
strictMcpConfig: boolean | undefined;
|
|
1361
1372
|
questionTimeoutMs: number | undefined;
|
|
@@ -1644,6 +1655,7 @@ function createSession({
|
|
|
1644
1655
|
: {}),
|
|
1645
1656
|
model: promptOpts.model,
|
|
1646
1657
|
maxTurns,
|
|
1658
|
+
...(skillOverrides !== undefined ? { skillOverrides } : {}),
|
|
1647
1659
|
...(maxBudgetUsd !== undefined ? { maxBudgetUsd } : {}),
|
|
1648
1660
|
...(strictMcpConfig !== undefined ? { strictMcpConfig } : {}),
|
|
1649
1661
|
...(questionTimeoutMs !== undefined ? { questionTimeoutMs } : {}),
|
|
@@ -1722,6 +1734,7 @@ function createSession({
|
|
|
1722
1734
|
: {}),
|
|
1723
1735
|
model: continueOpts.model,
|
|
1724
1736
|
maxTurns,
|
|
1737
|
+
...(skillOverrides !== undefined ? { skillOverrides } : {}),
|
|
1725
1738
|
...(maxBudgetUsd !== undefined ? { maxBudgetUsd } : {}),
|
|
1726
1739
|
...(strictMcpConfig !== undefined ? { strictMcpConfig } : {}),
|
|
1727
1740
|
...(questionTimeoutMs !== undefined ? { questionTimeoutMs } : {}),
|