@notation/factory-claude 0.1.3 → 0.1.5
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/implementations/runtime.ts +4 -1
- package/package.json +3 -3
- package/runtime/runner.ts +31 -0
- package/runtime/setup.sh +5 -0
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import { readFileSync } from "node:fs";
|
|
2
2
|
import type { Runtime } from "@notation/factory";
|
|
3
3
|
|
|
4
|
-
/** Claude Code. `setup` installs its CLI, `claude`, in a container's image.
|
|
4
|
+
/** Claude Code. `setup` installs its CLI, `claude`, in a container's image, and `runner` is how the runner runs it. Both are read lazily: an outpost's config, which has no filesystem, never touches them. */
|
|
5
5
|
export const runtime: Runtime = {
|
|
6
6
|
id: "claude",
|
|
7
7
|
get setup() {
|
|
8
8
|
return readFileSync(new URL("../runtime/setup.sh", import.meta.url), "utf8");
|
|
9
9
|
},
|
|
10
|
+
get runner() {
|
|
11
|
+
return readFileSync(new URL("../runtime/runner.ts", import.meta.url), "utf8");
|
|
12
|
+
},
|
|
10
13
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@notation/factory-claude",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.5",
|
|
4
4
|
"author": "Daniel Grant",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -24,9 +24,9 @@
|
|
|
24
24
|
"valibot": "^1.1.0"
|
|
25
25
|
},
|
|
26
26
|
"peerDependencies": {
|
|
27
|
-
"@notation/factory": "^0.1.
|
|
27
|
+
"@notation/factory": "^0.1.5"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
|
-
"@notation/factory": "0.1.
|
|
30
|
+
"@notation/factory": "0.1.5"
|
|
31
31
|
}
|
|
32
32
|
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { homedir } from "node:os";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
import type { RuntimeRunner } from "@notation/factory";
|
|
4
|
+
|
|
5
|
+
/** How the runner runs Claude Code. Containers import it with no packages, so it imports only Node's. */
|
|
6
|
+
const claude: RuntimeRunner = {
|
|
7
|
+
command: "claude",
|
|
8
|
+
name: "Claude Code",
|
|
9
|
+
transcripts: join(homedir(), ".claude", "projects"),
|
|
10
|
+
args: async (run, { systemPrompt }) => {
|
|
11
|
+
const { agent } = run;
|
|
12
|
+
const args = ["-p", run.conversation.prompt, "--output-format", "json", "--dangerously-skip-permissions"];
|
|
13
|
+
if (typeof agent.model === "string") args.push("--model", agent.model);
|
|
14
|
+
if (typeof agent.effort === "string") args.push("--effort", agent.effort);
|
|
15
|
+
args.push("--append-system-prompt", systemPrompt);
|
|
16
|
+
if (agent.settings) args.push("--settings", JSON.stringify(agent.settings));
|
|
17
|
+
return args;
|
|
18
|
+
},
|
|
19
|
+
resume: (sessionId) => ["--resume", sessionId],
|
|
20
|
+
parse: (stdout) => {
|
|
21
|
+
try {
|
|
22
|
+
const output = JSON.parse(stdout) as { result?: string; is_error?: boolean; session_id?: string };
|
|
23
|
+
return { result: output.result, isError: output.is_error, sessionId: output.session_id };
|
|
24
|
+
} catch {
|
|
25
|
+
return undefined;
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
env: { DISABLE_AUTOUPDATER: "1" },
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export default claude;
|
package/runtime/setup.sh
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
# Installs Claude Code system-wide. Runs as root at image build. The
|
|
2
2
|
# installer puts claude in root's home, which the factory user can't read.
|
|
3
3
|
set -e
|
|
4
|
+
if ! command -v curl >/dev/null 2>&1; then
|
|
5
|
+
apt-get update
|
|
6
|
+
apt-get install -y --no-install-recommends ca-certificates curl
|
|
7
|
+
rm -rf /var/lib/apt/lists/*
|
|
8
|
+
fi
|
|
4
9
|
curl -fsSL https://claude.ai/install.sh | bash
|
|
5
10
|
install -m 0755 "$(readlink -f /root/.local/bin/claude)" /usr/local/bin/claude
|
|
6
11
|
rm -rf /root/.local /root/.claude /root/.claude.json
|