@ai-sdk/harness-claude-code 1.0.65 → 1.0.66
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 +7 -0
- package/README.md +13 -0
- package/dist/bridge/index.mjs +32 -32
- package/dist/bridge/index.mjs.map +1 -1
- package/dist/index.d.ts +5 -0
- package/dist/index.js +7 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/bridge/index.ts +10 -62
- package/src/bridge/tool-filtering.ts +58 -0
- package/src/claude-code-bridge-protocol.ts +1 -0
- package/src/claude-code-harness.ts +11 -0
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import type { StartMessage } from '../claude-code-bridge-protocol';
|
|
2
|
+
|
|
3
|
+
type BuiltinToolFiltering = StartMessage['builtinToolFiltering'];
|
|
4
|
+
|
|
5
|
+
const PUBLIC_TO_NATIVE: Readonly<Record<string, string>> = {
|
|
6
|
+
read: 'Read',
|
|
7
|
+
write: 'Write',
|
|
8
|
+
edit: 'Edit',
|
|
9
|
+
bash: 'Bash',
|
|
10
|
+
glob: 'Glob',
|
|
11
|
+
grep: 'Grep',
|
|
12
|
+
webSearch: 'WebSearch',
|
|
13
|
+
WebFetch: 'WebFetch',
|
|
14
|
+
NotebookEdit: 'NotebookEdit',
|
|
15
|
+
TodoWrite: 'TodoWrite',
|
|
16
|
+
Agent: 'Agent',
|
|
17
|
+
TaskCreate: 'TaskCreate',
|
|
18
|
+
TaskGet: 'TaskGet',
|
|
19
|
+
TaskUpdate: 'TaskUpdate',
|
|
20
|
+
TaskList: 'TaskList',
|
|
21
|
+
TaskStop: 'TaskStop',
|
|
22
|
+
TaskOutput: 'TaskOutput',
|
|
23
|
+
Monitor: 'Monitor',
|
|
24
|
+
ListMcpResources: 'ListMcpResources',
|
|
25
|
+
ReadMcpResource: 'ReadMcpResource',
|
|
26
|
+
ExitPlanMode: 'ExitPlanMode',
|
|
27
|
+
EnterWorktree: 'EnterWorktree',
|
|
28
|
+
ExitWorktree: 'ExitWorktree',
|
|
29
|
+
AskUserQuestion: 'AskUserQuestion',
|
|
30
|
+
Skill: 'Skill',
|
|
31
|
+
ToolSearch: 'ToolSearch',
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
const PUBLIC_TOOL_NAMES = Object.keys(PUBLIC_TO_NATIVE);
|
|
35
|
+
|
|
36
|
+
function toNativeName(toolName: string): string {
|
|
37
|
+
return PUBLIC_TO_NATIVE[toolName] ?? toolName;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export function resolveNativeTools(
|
|
41
|
+
toolFiltering: BuiltinToolFiltering,
|
|
42
|
+
): string[] | undefined {
|
|
43
|
+
if (toolFiltering == null || toolFiltering.mode === 'deny') return undefined;
|
|
44
|
+
return toolFiltering.toolNames.map(name => toNativeName(name));
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export function resolveInactiveNativeTools(
|
|
48
|
+
toolFiltering: BuiltinToolFiltering,
|
|
49
|
+
): string[] {
|
|
50
|
+
if (toolFiltering == null) return [];
|
|
51
|
+
const inactiveToolNames =
|
|
52
|
+
toolFiltering.mode === 'allow'
|
|
53
|
+
? PUBLIC_TOOL_NAMES.filter(
|
|
54
|
+
name => !toolFiltering.toolNames.includes(name),
|
|
55
|
+
)
|
|
56
|
+
: toolFiltering.toolNames;
|
|
57
|
+
return inactiveToolNames.map(name => toNativeName(name));
|
|
58
|
+
}
|
|
@@ -33,6 +33,7 @@ const thinkingSchema = z.discriminatedUnion('type', [
|
|
|
33
33
|
export const startMessageSchema = harnessV1BridgeStartBaseSchema.extend({
|
|
34
34
|
thinking: thinkingSchema,
|
|
35
35
|
maxTurns: z.number().optional(),
|
|
36
|
+
env: z.record(z.string(), z.string()).optional(),
|
|
36
37
|
skills: z.array(z.string()).optional(),
|
|
37
38
|
// Resume signal. When true, the bridge passes `{ continue: true }` to the
|
|
38
39
|
// Claude SDK so the in-workdir thread state is rehydrated. The host sets this
|
|
@@ -73,6 +73,11 @@ export type ClaudeCodeHarnessSettings = {
|
|
|
73
73
|
* back to the caller. Unset means the CLI's default.
|
|
74
74
|
*/
|
|
75
75
|
readonly maxTurns?: number;
|
|
76
|
+
/**
|
|
77
|
+
* Environment variables for the Claude Code process. These values are
|
|
78
|
+
* merged over the sandbox bridge process environment.
|
|
79
|
+
*/
|
|
80
|
+
readonly env?: Readonly<Record<string, string>>;
|
|
76
81
|
/**
|
|
77
82
|
* Controls extended-thinking behavior and whether reasoning is summarized or
|
|
78
83
|
* omitted. Defaults to `{ type: 'adaptive', display: 'summarized' }`.
|
|
@@ -549,6 +554,7 @@ export function createClaudeCode(
|
|
|
549
554
|
proc: undefined,
|
|
550
555
|
model: settings.model,
|
|
551
556
|
maxTurns: settings.maxTurns,
|
|
557
|
+
env: settings.env,
|
|
552
558
|
thinking,
|
|
553
559
|
isResume: true,
|
|
554
560
|
continueOnFirstPrompt: false,
|
|
@@ -719,6 +725,7 @@ export function createClaudeCode(
|
|
|
719
725
|
proc,
|
|
720
726
|
model: settings.model,
|
|
721
727
|
maxTurns: settings.maxTurns,
|
|
728
|
+
env: settings.env,
|
|
722
729
|
thinking,
|
|
723
730
|
isResume: respawnStrategy !== undefined,
|
|
724
731
|
continueOnFirstPrompt: respawnStrategy !== undefined,
|
|
@@ -961,6 +968,7 @@ function createSession({
|
|
|
961
968
|
proc,
|
|
962
969
|
model,
|
|
963
970
|
maxTurns,
|
|
971
|
+
env,
|
|
964
972
|
thinking,
|
|
965
973
|
isResume,
|
|
966
974
|
continueOnFirstPrompt,
|
|
@@ -979,6 +987,7 @@ function createSession({
|
|
|
979
987
|
proc: Experimental_SandboxProcess | undefined;
|
|
980
988
|
model: string | undefined;
|
|
981
989
|
maxTurns: number | undefined;
|
|
990
|
+
env: Readonly<Record<string, string>> | undefined;
|
|
982
991
|
thinking: ClaudeCodeThinkingConfig;
|
|
983
992
|
isResume: boolean;
|
|
984
993
|
continueOnFirstPrompt: boolean;
|
|
@@ -1169,6 +1178,7 @@ function createSession({
|
|
|
1169
1178
|
})),
|
|
1170
1179
|
model,
|
|
1171
1180
|
maxTurns,
|
|
1181
|
+
...(env !== undefined ? { env } : {}),
|
|
1172
1182
|
thinking,
|
|
1173
1183
|
...(skills.length > 0
|
|
1174
1184
|
? { skills: skills.map(skill => skill.name) }
|
|
@@ -1221,6 +1231,7 @@ function createSession({
|
|
|
1221
1231
|
})),
|
|
1222
1232
|
model,
|
|
1223
1233
|
maxTurns,
|
|
1234
|
+
...(env !== undefined ? { env } : {}),
|
|
1224
1235
|
thinking,
|
|
1225
1236
|
...(skills.length > 0
|
|
1226
1237
|
? { skills: skills.map(skill => skill.name) }
|