@notation/factory-claude 0.1.7 → 0.2.0

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.
Files changed (2) hide show
  1. package/package.json +3 -3
  2. package/runtime/runner.ts +14 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@notation/factory-claude",
3
- "version": "0.1.7",
3
+ "version": "0.2.0",
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.7"
27
+ "@notation/factory": "^0.2.0"
28
28
  },
29
29
  "devDependencies": {
30
- "@notation/factory": "0.1.7"
30
+ "@notation/factory": "0.2.0"
31
31
  }
32
32
  }
package/runtime/runner.ts CHANGED
@@ -1,7 +1,19 @@
1
- import { homedir } from "node:os";
1
+ import { mkdtempSync, writeFileSync } from "node:fs";
2
+ import { homedir, tmpdir } from "node:os";
2
3
  import { join } from "node:path";
3
4
  import type { RuntimeRunner } from "@notation/factory";
4
5
 
6
+ // Claude Code removes CLAUDE_CODE_OAUTH_TOKEN from the commands the agent runs, so
7
+ // a `claude` started by one of them isn't signed in. Claude Code runs CLAUDE_ENV_FILE
8
+ // before each command, so exporting the token there puts it back.
9
+ function envFile(): Record<string, string> {
10
+ const token = process.env.CLAUDE_CODE_OAUTH_TOKEN;
11
+ if (!token) return {};
12
+ const file = join(mkdtempSync(join(tmpdir(), "claude-env-")), "env.sh");
13
+ writeFileSync(file, `export CLAUDE_CODE_OAUTH_TOKEN='${token.replaceAll("'", "'\\''")}'\n`, { mode: 0o600 });
14
+ return { CLAUDE_ENV_FILE: file };
15
+ }
16
+
5
17
  /** How the runner runs Claude Code. Containers import it with no packages, so it imports only Node's. */
6
18
  const claude: RuntimeRunner = {
7
19
  command: "claude",
@@ -25,7 +37,7 @@ const claude: RuntimeRunner = {
25
37
  return undefined;
26
38
  }
27
39
  },
28
- env: { DISABLE_AUTOUPDATER: "1" },
40
+ env: { DISABLE_AUTOUPDATER: "1", ...envFile() },
29
41
  };
30
42
 
31
43
  export default claude;