@forwardimpact/libharness 1.2.0 → 1.2.1
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/package.json +1 -1
- package/src/agent-runner.js +20 -2
- package/src/claude-code-executable.js +44 -0
- package/src/index.js +1 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@forwardimpact/libharness",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.1",
|
|
4
4
|
"description": "Autonomous agent team harness — coordinate a lead and participant agents in one async session, with eval, benchmark, and trace tooling to prove the changes worked.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"orchestration",
|
package/src/agent-runner.js
CHANGED
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
import { AGENT_MODEL } from "@forwardimpact/libutil/models";
|
|
10
|
+
import { resolveClaudeCodeExecutable } from "./claude-code-executable.js";
|
|
10
11
|
|
|
11
12
|
const DEFAULT_ALLOWED_TOOLS = ["Bash", "Read", "Glob", "Grep", "Write", "Edit"];
|
|
12
13
|
|
|
@@ -56,6 +57,10 @@ export class AgentRunner {
|
|
|
56
57
|
* @param {string|object} [deps.systemPrompt] - SDK system prompt (string replaces default; {type:'preset', preset:'claude_code', append} appends)
|
|
57
58
|
* @param {string[]} [deps.disallowedTools] - Tools to explicitly remove from the model's context
|
|
58
59
|
* @param {Record<string, object>} [deps.mcpServers] - MCP server configs to pass to the SDK query
|
|
60
|
+
* @param {string} [deps.pathToClaudeCodeExecutable] - Absolute path to the
|
|
61
|
+
* native `claude` CLI the SDK should spawn. Set for compiled fit-* binaries,
|
|
62
|
+
* which can't self-resolve the SDK's platform optional dependency; omitted
|
|
63
|
+
* from source runs so the SDK resolves its own version-matched binary.
|
|
59
64
|
* @param {object} deps.redactor
|
|
60
65
|
* @param {import("@forwardimpact/libutil/runtime").Runtime} [deps.runtime] -
|
|
61
66
|
* Ambient collaborators. Only `proc.env` is read (to record Skill
|
|
@@ -79,6 +84,9 @@ export class AgentRunner {
|
|
|
79
84
|
this.systemPrompt = deps.systemPrompt ?? null;
|
|
80
85
|
this.disallowedTools = deps.disallowedTools ?? [];
|
|
81
86
|
this.mcpServers = deps.mcpServers ?? null;
|
|
87
|
+
// Optional; read only through a truthy guard in #callOptions, so an absent
|
|
88
|
+
// value stays undefined rather than needing a `?? null` default.
|
|
89
|
+
this.pathToClaudeCodeExecutable = deps.pathToClaudeCodeExecutable;
|
|
82
90
|
this.taskAmend = deps.taskAmend ?? null;
|
|
83
91
|
this.sessionId = null;
|
|
84
92
|
/** @type {AbortController|null} */
|
|
@@ -158,6 +166,9 @@ export class AgentRunner {
|
|
|
158
166
|
}),
|
|
159
167
|
...(this.systemPrompt && { systemPrompt: this.systemPrompt }),
|
|
160
168
|
...(this.mcpServers && { mcpServers: this.mcpServers }),
|
|
169
|
+
...(this.pathToClaudeCodeExecutable && {
|
|
170
|
+
pathToClaudeCodeExecutable: this.pathToClaudeCodeExecutable,
|
|
171
|
+
}),
|
|
161
172
|
};
|
|
162
173
|
}
|
|
163
174
|
|
|
@@ -250,7 +261,14 @@ export class AgentRunner {
|
|
|
250
261
|
}
|
|
251
262
|
}
|
|
252
263
|
|
|
253
|
-
/**
|
|
264
|
+
/**
|
|
265
|
+
* Factory function — wires real dependencies. Resolves the native `claude`
|
|
266
|
+
* executable for compiled fit-* binaries so the SDK doesn't fail to find its
|
|
267
|
+
* own platform optional dependency; an explicit `deps` value overrides it.
|
|
268
|
+
*/
|
|
254
269
|
export function createAgentRunner(deps) {
|
|
255
|
-
return new AgentRunner(
|
|
270
|
+
return new AgentRunner({
|
|
271
|
+
pathToClaudeCodeExecutable: resolveClaudeCodeExecutable(),
|
|
272
|
+
...deps,
|
|
273
|
+
});
|
|
256
274
|
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Resolve the Claude Code CLI the Agent SDK should spawn.
|
|
3
|
+
*
|
|
4
|
+
* `query()` spawns a native `claude` binary that the SDK resolves from its own
|
|
5
|
+
* platform-specific optional dependency (`@anthropic-ai/claude-agent-sdk-<platform>`).
|
|
6
|
+
* `bun build --compile` bundles the SDK's JavaScript but not that separate
|
|
7
|
+
* native package — it is not part of the import graph — so a compiled fit-*
|
|
8
|
+
* binary can't self-resolve it and `query()` throws "Native CLI binary for
|
|
9
|
+
* <platform> not found".
|
|
10
|
+
*
|
|
11
|
+
* In a compiled binary we point the SDK at the standalone `claude` on PATH,
|
|
12
|
+
* installed beside fit-harness by the bootstrap action's `fit-install.sh`.
|
|
13
|
+
* Running from source keeps `node_modules`, where the SDK resolves its own
|
|
14
|
+
* version-matched binary, so there we return undefined and defer to the SDK.
|
|
15
|
+
*/
|
|
16
|
+
import { LIBCLI_IS_COMPILED } from "@forwardimpact/libcli";
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* @param {object} [deps]
|
|
20
|
+
* @param {(cmd: string) => string | null | undefined} [deps.which] -
|
|
21
|
+
* PATH resolver (injected for testing).
|
|
22
|
+
* @param {boolean} [deps.isCompiled] -
|
|
23
|
+
* Whether this is a `bun --compile` binary (injected for testing).
|
|
24
|
+
* @returns {string | undefined} absolute path to `claude`, or undefined to
|
|
25
|
+
* defer resolution to the SDK.
|
|
26
|
+
*/
|
|
27
|
+
export function resolveClaudeCodeExecutable({
|
|
28
|
+
which = defaultWhich,
|
|
29
|
+
isCompiled = LIBCLI_IS_COMPILED,
|
|
30
|
+
} = {}) {
|
|
31
|
+
if (!isCompiled) return undefined;
|
|
32
|
+
return which("claude") ?? undefined;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* A compiled fit-* binary runs under the Bun runtime, which exposes a
|
|
37
|
+
* synchronous PATH resolver. The `typeof` guard keeps this safe under Node too.
|
|
38
|
+
*/
|
|
39
|
+
function defaultWhich(cmd) {
|
|
40
|
+
if (typeof Bun !== "undefined" && typeof Bun.which === "function") {
|
|
41
|
+
return Bun.which(cmd);
|
|
42
|
+
}
|
|
43
|
+
return null;
|
|
44
|
+
}
|
package/src/index.js
CHANGED
|
@@ -11,6 +11,7 @@ export {
|
|
|
11
11
|
pickTraceArtifact,
|
|
12
12
|
} from "./trace-github.js";
|
|
13
13
|
export { AgentRunner, createAgentRunner } from "./agent-runner.js";
|
|
14
|
+
export { resolveClaudeCodeExecutable } from "./claude-code-executable.js";
|
|
14
15
|
export {
|
|
15
16
|
composeProfilePrompt,
|
|
16
17
|
composeLeadPrompt,
|