@harness-sdk/harnessd 0.0.0 → 0.0.2

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 (83) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +64 -2
  3. package/dist/accounts.d.ts +66 -0
  4. package/dist/accounts.d.ts.map +1 -0
  5. package/dist/accounts.js +166 -0
  6. package/dist/accounts.js.map +1 -0
  7. package/dist/bin.d.ts +3 -0
  8. package/dist/bin.d.ts.map +1 -0
  9. package/dist/bin.js +19 -0
  10. package/dist/bin.js.map +1 -0
  11. package/dist/channel.d.ts +56 -0
  12. package/dist/channel.d.ts.map +1 -0
  13. package/dist/channel.js +356 -0
  14. package/dist/channel.js.map +1 -0
  15. package/dist/claude.d.ts +41 -0
  16. package/dist/claude.d.ts.map +1 -0
  17. package/dist/claude.js +152 -0
  18. package/dist/claude.js.map +1 -0
  19. package/dist/cli.d.ts +13 -0
  20. package/dist/cli.d.ts.map +1 -0
  21. package/dist/cli.js +413 -0
  22. package/dist/cli.js.map +1 -0
  23. package/dist/config.d.ts +56 -0
  24. package/dist/config.d.ts.map +1 -0
  25. package/dist/config.js +161 -0
  26. package/dist/config.js.map +1 -0
  27. package/dist/daemon.d.ts +37 -0
  28. package/dist/daemon.d.ts.map +1 -0
  29. package/dist/daemon.js +300 -0
  30. package/dist/daemon.js.map +1 -0
  31. package/dist/launchd.d.ts +18 -0
  32. package/dist/launchd.d.ts.map +1 -0
  33. package/dist/launchd.js +91 -0
  34. package/dist/launchd.js.map +1 -0
  35. package/dist/log.d.ts +3 -0
  36. package/dist/log.d.ts.map +1 -0
  37. package/dist/log.js +17 -0
  38. package/dist/log.js.map +1 -0
  39. package/dist/prompts.d.ts +53 -0
  40. package/dist/prompts.d.ts.map +1 -0
  41. package/dist/prompts.js +171 -0
  42. package/dist/prompts.js.map +1 -0
  43. package/dist/service.d.ts +37 -0
  44. package/dist/service.d.ts.map +1 -0
  45. package/dist/service.js +71 -0
  46. package/dist/service.js.map +1 -0
  47. package/dist/setup.d.ts +37 -0
  48. package/dist/setup.d.ts.map +1 -0
  49. package/dist/setup.js +121 -0
  50. package/dist/setup.js.map +1 -0
  51. package/dist/system.d.ts +6 -0
  52. package/dist/system.d.ts.map +1 -0
  53. package/dist/system.js +16 -0
  54. package/dist/system.js.map +1 -0
  55. package/dist/systemd.d.ts +14 -0
  56. package/dist/systemd.d.ts.map +1 -0
  57. package/dist/systemd.js +62 -0
  58. package/dist/systemd.js.map +1 -0
  59. package/dist/terminal.d.ts +11 -0
  60. package/dist/terminal.d.ts.map +1 -0
  61. package/dist/terminal.js +36 -0
  62. package/dist/terminal.js.map +1 -0
  63. package/dist/watchdog.d.ts +83 -0
  64. package/dist/watchdog.d.ts.map +1 -0
  65. package/dist/watchdog.js +236 -0
  66. package/dist/watchdog.js.map +1 -0
  67. package/package.json +55 -6
  68. package/src/accounts.ts +242 -0
  69. package/src/bin.ts +24 -0
  70. package/src/channel.ts +461 -0
  71. package/src/claude.ts +249 -0
  72. package/src/cli.ts +633 -0
  73. package/src/config.ts +281 -0
  74. package/src/daemon.ts +379 -0
  75. package/src/launchd.ts +131 -0
  76. package/src/log.ts +17 -0
  77. package/src/prompts.ts +255 -0
  78. package/src/service.ts +145 -0
  79. package/src/setup.ts +188 -0
  80. package/src/system.ts +11 -0
  81. package/src/systemd.ts +78 -0
  82. package/src/terminal.ts +33 -0
  83. package/src/watchdog.ts +318 -0
@@ -0,0 +1,91 @@
1
+ import { system } from "./system.js";
2
+ import { accessSync, constants, existsSync, mkdirSync, realpathSync, rmSync, writeFileSync } from "node:fs";
3
+ import { homedir } from "node:os";
4
+ import { delimiter, dirname, join } from "node:path";
5
+ // src/launchd.ts
6
+ const xml = (value) => value.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
7
+ /**
8
+ * The node the service starts: the first `node` on the PATH that is this node (a symlink such as Homebrew's
9
+ * /opt/homebrew/bin/node), so an upgrade that removes the versioned folder `process.execPath` points into doesn't leave
10
+ * harnessd unable to start. None that is this one: `process.execPath`.
11
+ */
12
+ const stableNode = (execPath = process.execPath, path = process.env.PATH ?? "") => {
13
+ let real;
14
+ try {
15
+ real = realpathSync(execPath);
16
+ } catch {
17
+ return execPath;
18
+ }
19
+ for (const dir of path.split(delimiter)) {
20
+ if (!dir.startsWith("/")) continue;
21
+ const candidate = join(dir, "node");
22
+ try {
23
+ accessSync(candidate, constants.X_OK);
24
+ if (realpathSync(candidate) === real) return candidate;
25
+ } catch {}
26
+ }
27
+ return execPath;
28
+ };
29
+ /** The entry's lines that name harnessd's state folder: what tells one harnessd's entry from another's. */
30
+ const plistFolder = (home) => ` <key>WorkingDirectory</key>\n <string>${xml(home)}</string>`;
31
+ /** A LaunchAgent in the user's own folder, or for a boot service a LaunchDaemon. */
32
+ const plistPath = (label, boot = false) => boot ? `/Library/LaunchDaemons/${label}.plist` : join(homedir(), "Library", "LaunchAgents", `${label}.plist`);
33
+ /** The launchd entry: `node <bin> run` at login (with `user`: at boot, as that user) and after any exit. */
34
+ const plistOf = (o) => `<?xml version="1.0" encoding="UTF-8"?>
35
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
36
+ <plist version="1.0">
37
+ <dict>
38
+ <key>Label</key>
39
+ <string>${xml(o.label)}</string>
40
+ ${o.user === void 0 ? "" : ` <key>UserName</key>\n <string>${xml(o.user)}</string>\n`} <key>ProgramArguments</key>
41
+ <array>
42
+ <string>${xml(o.node)}</string>
43
+ <string>${xml(o.bin)}</string>
44
+ <string>run</string>
45
+ </array>
46
+ <key>EnvironmentVariables</key>
47
+ <dict>
48
+ ${Object.entries(o.env).map(([key, value]) => ` <key>${xml(key)}</key>\n <string>${xml(value)}</string>`).join("\n")}
49
+ </dict>
50
+ ${plistFolder(o.paths.home)}
51
+ <key>RunAtLoad</key>
52
+ <true/>
53
+ <key>KeepAlive</key>
54
+ <true/>
55
+ <key>ExitTimeOut</key>
56
+ <integer>30</integer>
57
+ <key>ProcessType</key>
58
+ <string>Interactive</string>
59
+ <key>StandardOutPath</key>
60
+ <string>${xml(o.paths.serviceLog)}</string>
61
+ <key>StandardErrorPath</key>
62
+ <string>${xml(o.paths.serviceLog)}</string>
63
+ </dict>
64
+ </plist>
65
+ `;
66
+ const domain = (boot) => boot ? "system" : `gui/${process.getuid()}`;
67
+ const launchctl = (...args) => system("launchctl", args);
68
+ const loaded = (label, boot) => launchctl("print", `${domain(boot)}/${label}`).status === 0;
69
+ /** Writes the launchd entry and (re)loads it, which starts harnessd. */
70
+ const load = async (label, plist, boot) => {
71
+ mkdirSync(dirname(plistPath(label, boot)), { recursive: true });
72
+ if (loaded(label, boot)) launchctl("bootout", `${domain(boot)}/${label}`);
73
+ for (let i = 0; loaded(label, boot) && i < 400; i++) await new Promise((resolve) => setTimeout(resolve, 100));
74
+ writeFileSync(plistPath(label, boot), plist, { mode: 420 });
75
+ const result = launchctl("bootstrap", domain(boot), plistPath(label, boot));
76
+ if (result.status !== 0) throw new Error(`launchctl bootstrap failed: ${(result.stderr || result.stdout).trim()}`);
77
+ };
78
+ /** Stops harnessd (it stops Claude Code first) and removes the launchd entry. */
79
+ const unload = (label, boot) => {
80
+ if (loaded(label, boot)) {
81
+ const result = launchctl("bootout", `${domain(boot)}/${label}`);
82
+ if (result.status !== 0) throw new Error(`launchctl bootout failed: ${(result.stderr || result.stdout).trim()}`);
83
+ }
84
+ const plist = plistPath(label, boot);
85
+ const had = existsSync(plist);
86
+ rmSync(plist, { force: true });
87
+ return had;
88
+ };
89
+ export { load, plistFolder, plistOf, plistPath, stableNode, unload };
90
+
91
+ //# sourceMappingURL=launchd.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"launchd.js","names":[],"sources":["../src/launchd.ts"],"sourcesContent":["import {\n accessSync,\n constants,\n existsSync,\n mkdirSync,\n realpathSync,\n rmSync,\n writeFileSync,\n} from \"node:fs\";\nimport { homedir } from \"node:os\";\nimport { delimiter, dirname, join } from \"node:path\";\nimport type { Service } from \"./service\";\nimport { system } from \"./system\";\n\nconst xml = (value: string) =>\n value.replace(/&/g, \"&amp;\").replace(/</g, \"&lt;\").replace(/>/g, \"&gt;\");\n\n/**\n * The node the service starts: the first `node` on the PATH that is this node (a symlink such as Homebrew's\n * /opt/homebrew/bin/node), so an upgrade that removes the versioned folder `process.execPath` points into doesn't leave\n * harnessd unable to start. None that is this one: `process.execPath`.\n */\nexport const stableNode = (\n execPath = process.execPath,\n path = process.env.PATH ?? \"\",\n) => {\n let real: string;\n try {\n real = realpathSync(execPath);\n } catch {\n return execPath;\n }\n for (const dir of path.split(delimiter)) {\n if (!dir.startsWith(\"/\")) continue;\n const candidate = join(dir, \"node\");\n try {\n accessSync(candidate, constants.X_OK);\n if (realpathSync(candidate) === real) return candidate;\n } catch {}\n }\n return execPath;\n};\n\n/** The entry's lines that name harnessd's state folder: what tells one harnessd's entry from another's. */\nexport const plistFolder = (home: string) =>\n ` <key>WorkingDirectory</key>\\n <string>${xml(home)}</string>`;\n\n/** A LaunchAgent in the user's own folder, or for a boot service a LaunchDaemon. */\nexport const plistPath = (label: string, boot = false) =>\n boot\n ? `/Library/LaunchDaemons/${label}.plist`\n : join(homedir(), \"Library\", \"LaunchAgents\", `${label}.plist`);\n\n/** The launchd entry: `node <bin> run` at login (with `user`: at boot, as that user) and after any exit. */\nexport const plistOf = (\n o: Service.Spec,\n) => `<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n<plist version=\"1.0\">\n<dict>\n <key>Label</key>\n <string>${xml(o.label)}</string>\n${o.user === undefined ? \"\" : ` <key>UserName</key>\\n <string>${xml(o.user)}</string>\\n`} <key>ProgramArguments</key>\n <array>\n <string>${xml(o.node)}</string>\n <string>${xml(o.bin)}</string>\n <string>run</string>\n </array>\n <key>EnvironmentVariables</key>\n <dict>\n${Object.entries(o.env)\n .map(\n ([key, value]) =>\n ` <key>${xml(key)}</key>\\n <string>${xml(value)}</string>`,\n )\n .join(\"\\n\")}\n </dict>\n${plistFolder(o.paths.home)}\n <key>RunAtLoad</key>\n <true/>\n <key>KeepAlive</key>\n <true/>\n <key>ExitTimeOut</key>\n <integer>30</integer>\n <key>ProcessType</key>\n <string>Interactive</string>\n <key>StandardOutPath</key>\n <string>${xml(o.paths.serviceLog)}</string>\n <key>StandardErrorPath</key>\n <string>${xml(o.paths.serviceLog)}</string>\n</dict>\n</plist>\n`;\n\nconst domain = (boot: boolean) =>\n boot ? \"system\" : `gui/${process.getuid!()}`;\n\nconst launchctl = (...args: string[]) => system(\"launchctl\", args);\n\nconst loaded = (label: string, boot: boolean) =>\n launchctl(\"print\", `${domain(boot)}/${label}`).status === 0;\n\n/** Writes the launchd entry and (re)loads it, which starts harnessd. */\nexport const load = async (label: string, plist: string, boot: boolean) => {\n mkdirSync(dirname(plistPath(label, boot)), { recursive: true });\n if (loaded(label, boot)) launchctl(\"bootout\", `${domain(boot)}/${label}`);\n // bootout returns while the old harnessd still stops Claude Code; a bootstrap before it is gone fails\n for (let i = 0; loaded(label, boot) && i < 400; i++)\n await new Promise((resolve) => setTimeout(resolve, 100));\n writeFileSync(plistPath(label, boot), plist, { mode: 0o644 });\n const result = launchctl(\"bootstrap\", domain(boot), plistPath(label, boot));\n if (result.status !== 0)\n throw new Error(\n `launchctl bootstrap failed: ${(result.stderr || result.stdout).trim()}`,\n );\n};\n\n/** Stops harnessd (it stops Claude Code first) and removes the launchd entry. */\nexport const unload = (label: string, boot: boolean) => {\n if (loaded(label, boot)) {\n const result = launchctl(\"bootout\", `${domain(boot)}/${label}`);\n if (result.status !== 0)\n throw new Error(\n `launchctl bootout failed: ${(result.stderr || result.stdout).trim()}`,\n );\n }\n const plist = plistPath(label, boot);\n const had = existsSync(plist);\n rmSync(plist, { force: true });\n return had;\n};\n"],"mappings":";;;;;AAcA,MAAM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AG,SAAmB,OAAO,aAAa,IAAI;AAEjE,MAAM,UAAU,OAAe,SAC7B,UAAU,SAAS,GAAG,OAAO,IAAI,EAAE,GAAG,OAAO,CAAC,CAAC,WAAW;;AAG5D,MAAa,OAAO,OAAO,OAAe,OAAe,SAAkB;CACzE,UAAU,QAAQ,UAAU,OAAO,IAAI,CAAC,GAAG,EAAE,WAAW,KAAK,CAAC;CAC9D,IAAI,OAAO,OAAO,IAAI,GAAG,UAAU,WAAW,GAAG,OAAO,IAAI,EAAE,GAAG,OAAO;CAExE,KAAK,IAAI,IAAI,GAAG,OAAO,OAAO,IAAI,KAAK,IAAI,KAAK,KAC9C,MAAM,IAAI,SAAS,YAAY,WAAW,SAAS,GAAG,CAAC;CACzD,cAAc,UAAU,OAAO,IAAI,GAAG,OAAO,EAAE,MAAM,IAAM,CAAC;CAC5D,MAAM,SAAS,UAAU,aAAa,OAAO,IAAI,GAAG,UAAU,OAAO,IAAI,CAAC;CAC1E,IAAI,OAAO,WAAW,GACpB,MAAM,IAAI,MACR,gCAAgC,OAAO,UAAU,OAAO,OAAA,CAAQ,KAAK,GACvE;AACJ;;AAGA,MAAa,UAAU,OAAe,SAAkB;CACtD,IAAI,OAAO,OAAO,IAAI,GAAG;EACvB,MAAM,SAAS,UAAU,WAAW,GAAG,OAAO,IAAI,EAAE,GAAG,OAAO;EAC9D,IAAI,OAAO,WAAW,GACpB,MAAM,IAAI,MACR,8BAA8B,OAAO,UAAU,OAAO,OAAA,CAAQ,KAAK,GACrE;CACJ;CACA,MAAM,QAAQ,UAAU,OAAO,IAAI;CACnC,MAAM,MAAM,WAAW,KAAK;CAC5B,OAAO,OAAO,EAAE,OAAO,KAAK,CAAC;CAC7B,OAAO;AACT"}
package/dist/log.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ /** Appends timestamped lines to `file`, keeping one older file (`.1`) past 5 MB. */
2
+ export declare const logTo: (file: string, prefix?: string) => (line: string) => void;
3
+ //# sourceMappingURL=log.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"log.d.ts","sourceRoot":"","sources":["../src/log.ts"],"names":[],"mappings":"AAKA,oFAAoF;AACpF,eAAO,MAAM,KAAK,GACf,MAAM,MAAM,EAAE,eAAW,MACzB,MAAM,MAAM,SAQZ,CAAC"}
package/dist/log.js ADDED
@@ -0,0 +1,17 @@
1
+ import { appendFileSync, mkdirSync, renameSync, statSync } from "node:fs";
2
+ import { dirname } from "node:path";
3
+ // src/log.ts
4
+ const MAX_BYTES = 5242880;
5
+ /** Appends timestamped lines to `file`, keeping one older file (`.1`) past 5 MB. */
6
+ const logTo = (file, prefix = "") => (line) => {
7
+ try {
8
+ mkdirSync(dirname(file), { recursive: true });
9
+ try {
10
+ if (statSync(file).size > MAX_BYTES) renameSync(file, `${file}.1`);
11
+ } catch {}
12
+ appendFileSync(file, `${(/* @__PURE__ */ new Date()).toISOString()} ${prefix}${line}\n`);
13
+ } catch {}
14
+ };
15
+ export { logTo };
16
+
17
+ //# sourceMappingURL=log.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"log.js","names":[],"sources":["../src/log.ts"],"sourcesContent":["import { appendFileSync, mkdirSync, renameSync, statSync } from \"node:fs\";\nimport { dirname } from \"node:path\";\n\nconst MAX_BYTES = 5 * 1024 * 1024;\n\n/** Appends timestamped lines to `file`, keeping one older file (`.1`) past 5 MB. */\nexport const logTo =\n (file: string, prefix = \"\") =>\n (line: string) => {\n try {\n mkdirSync(dirname(file), { recursive: true });\n try {\n if (statSync(file).size > MAX_BYTES) renameSync(file, `${file}.1`);\n } catch {}\n appendFileSync(file, `${new Date().toISOString()} ${prefix}${line}\\n`);\n } catch {}\n };\n"],"mappings":";;;AAGA,MAAM,YAAY;;AAGlB,MAAa,SACV,MAAc,SAAS,QACvB,SAAiB;CAChB,IAAI;EACF,UAAU,QAAQ,IAAI,GAAG,EAAE,WAAW,KAAK,CAAC;EAC5C,IAAI;GACF,IAAI,SAAS,IAAI,CAAC,CAAC,OAAO,WAAW,WAAW,MAAM,GAAG,KAAK,GAAG;EACnE,QAAQ,CAAC;EACT,eAAe,MAAM,oBAAG,IAAI,KAAK,EAAA,CAAE,YAAY,EAAE,GAAG,SAAS,KAAK,GAAG;CACvE,QAAQ,CAAC;AACX"}
@@ -0,0 +1,53 @@
1
+ export declare namespace Prompts {
2
+ /** A screen where Claude Code waits for an answer before it goes on. */
3
+ type Prompt = {
4
+ readonly name: string;
5
+ /** Matches the end of the screen, read without its whitespace. */
6
+ readonly shows: RegExp;
7
+ /** How the option harnessd picks starts, or "" where Enter is the answer. Absent: only a person can answer, and `harnessd status` says so. */
8
+ readonly pick?: string;
9
+ /** Answered only for a start whose arguments turn permission prompts off; otherwise a person answers. */
10
+ readonly forSkippedPermissions?: true;
11
+ /** What this screen asks about, read from the screen as drawn: it follows the name, as `<name>: <subject>`. */
12
+ readonly subject?: (screen: readonly string[]) => string | undefined;
13
+ };
14
+ type Found = {
15
+ readonly prompt: Prompt;
16
+ /** The prompt's name, with what it asks about when the screen says. */
17
+ readonly name: string;
18
+ /** What to type, when harnessd answers this prompt. */
19
+ readonly keys?: string;
20
+ };
21
+ type Options = {
22
+ /** Types into Claude Code's terminal. */
23
+ readonly write: (keys: string) => void;
24
+ readonly log: (line: string) => void;
25
+ readonly cols: number;
26
+ readonly rows: number;
27
+ readonly quietMs?: number;
28
+ };
29
+ type Watcher = {
30
+ /** Claude Code's terminal output. */
31
+ readonly push: (data: string) => void;
32
+ readonly resize: (cols: number, rows: number) => void;
33
+ /** A new start of Claude Code: an empty screen. `skipsPermissions`: its arguments turn permission prompts off. */
34
+ readonly reset: (start?: {
35
+ skipsPermissions?: boolean;
36
+ }) => void;
37
+ /** The prompt Claude Code waits at for a person, if any. */
38
+ readonly waitingOn: () => string | undefined;
39
+ /** Whether this start's screen said managed settings keep harnessd's channels out. */
40
+ readonly channelsRefused: () => boolean;
41
+ };
42
+ }
43
+ /** The prompts of Claude Code 2.1 that stop a start nobody watches. */
44
+ export declare const PROMPTS: readonly Prompts.Prompt[];
45
+ /** The prompt a screen ends with, and the keys that answer it. */
46
+ export declare const findPrompt: (screen: readonly string[], prompts?: readonly Prompts.Prompt[]) => Prompts.Found | undefined;
47
+ /** What harnessd says when Claude Code refuses its channels. */
48
+ export declare const CHANNELS_REFUSED = "Claude Code refused harnessd's channels: managed settings block channels (channelsEnabled isn't true), so their events are dropped. Whoever manages Claude Code's settings for this organization or this computer has to set channelsEnabled; harnessd leaves them alone.";
49
+ /** Claude Code's start notice when a Team or Enterprise organization's (or this Mac's) managed settings keep channels out. */
50
+ export declare const channelsRefused: (screen: readonly string[]) => boolean;
51
+ /** Reads Claude Code's screen as its output arrives and answers the prompts harnessd knows. */
52
+ export declare const promptWatcher: (options: Prompts.Options) => Prompts.Watcher;
53
+ //# sourceMappingURL=prompts.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prompts.d.ts","sourceRoot":"","sources":["../src/prompts.ts"],"names":[],"mappings":"AAEA,yBAAiB,OAAO,CAAC;IACvB,wEAAwE;IACxE,KAAY,MAAM,GAAG;QACnB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;QACtB,kEAAkE;QAClE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;QACvB,8IAA8I;QAC9I,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;QACvB,yGAAyG;QACzG,QAAQ,CAAC,qBAAqB,CAAC,EAAE,IAAI,CAAC;QACtC,+GAA+G;QAC/G,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,KAAK,MAAM,GAAG,SAAS,CAAC;KACtE,CAAC;IAEF,KAAY,KAAK,GAAG;QAClB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;QACxB,uEAAuE;QACvE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;QACtB,uDAAuD;QACvD,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;KACxB,CAAC;IAEF,KAAY,O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AAM,aAAa,GAAI,SAAS,OAAO,CAAC,OAAO,KAAG,OAAO,CAAC,OA0EhE,CAAC"}
@@ -0,0 +1,171 @@
1
+ import xterm from "@xterm/headless";
2
+ // src/prompts.ts
3
+ const CONFIRM = "Entertoconfirm·Esctocancel$";
4
+ /** The prompts of Claude Code 2.1 that stop a start nobody watches. */
5
+ const PROMPTS = [
6
+ {
7
+ name: "the text style",
8
+ shows: /Choosethetextstylethatlooksbestwithyourterminal[^]*Syntaxtheme:[^\n]*$/,
9
+ pick: ""
10
+ },
11
+ {
12
+ name: "the security notes",
13
+ shows: /Securitynotes:[^]*PressEntertocontinue…?$/,
14
+ pick: ""
15
+ },
16
+ {
17
+ name: "trust in the agent's folder",
18
+ shows: new RegExp(`Accessingworkspace:[^]*Yes,Itrustthisfolder\\n${CONFIRM}`),
19
+ pick: "Yes,Itrustthisfolder"
20
+ },
21
+ {
22
+ name: "running without permission prompts",
23
+ shows: new RegExp(`ClaudeCoderunninginBypassPermissionsmode[^]*Yes,Iaccept\\n${CONFIRM}`),
24
+ pick: "Yes,Iaccept",
25
+ forSkippedPermissions: true
26
+ },
27
+ {
28
+ name: "loading harnessd's channels",
29
+ shows: new RegExp(`WARNING:Loadingdevelopmentchannels[^]*\\nChannels:plugin:harnessd@inline\\n❯?1\\.Iamusingthisforlocaldevelopment[^]*${CONFIRM}`),
30
+ pick: "Iamusingthisforlocaldevelopment"
31
+ },
32
+ {
33
+ name: "the API key in its environment",
34
+ shows: new RegExp(`DetectedacustomAPIkeyinyourenvironment[^]*DoyouwanttousethisAPIkey\\?[^]*${CONFIRM}`),
35
+ pick: "Yes"
36
+ },
37
+ {
38
+ name: "CLAUDE.md imports from outside the folder",
39
+ shows: /AllowexternalCLAUDE\.mdfileimports\?[^]*Yes,allowexternalimports\nEntertoconfirm·Esctodisable$/,
40
+ pick: "Yes,allowexternalimports"
41
+ },
42
+ {
43
+ name: "what to do at its usage limit",
44
+ shows: new RegExp(`Whatdoyouwanttodo\\?\\n❯?1\\.Stopandwaitforlimittoreset[^]*${CONFIRM}`),
45
+ pick: "Waithere,thencontinueautomatically"
46
+ },
47
+ {
48
+ name: "the new autocompact default",
49
+ shows: /Autocompactnowdefaultsto\w+tokens\n[^]*Apply\(allmodels\)\n[^]*Entertoconfirm·Esctoclose$/,
50
+ pick: "Apply(allmodels)"
51
+ },
52
+ {
53
+ name: "a sign-in",
54
+ shows: /Selectloginmethod:(\n❯?\d\.[^\n]*)+$/
55
+ },
56
+ {
57
+ name: "permission",
58
+ shows: /\nDoyouwantto[^\n]*\?\n❯?1\.Yes\n[^]*\nEsctocancel·Tabtoamend$/,
59
+ subject: (screen) => {
60
+ const rule = screen.findLastIndex((line) => /^─{10,}$/.test(line.trim()));
61
+ return screen.slice(rule + 1).map((line) => line.trim()).find((line) => line !== "");
62
+ }
63
+ },
64
+ {
65
+ name: "a question harnessd doesn't know",
66
+ shows: /\nEntertoconfirm·Escto\w+$/
67
+ }
68
+ ];
69
+ const CURSOR = "❯";
70
+ const DOWN = "\x1B[B";
71
+ const UP = "\x1B[A";
72
+ /** The prompt a screen ends with, and the keys that answer it. */
73
+ const findPrompt = (screen, prompts = PROMPTS) => {
74
+ const lines = screen.map((line) => line.replace(/\s+/g, "")).filter((line) => line !== "");
75
+ const text = lines.join("\n");
76
+ const prompt = prompts.find((p) => p.shows.test(text));
77
+ if (!prompt) return void 0;
78
+ const subject = prompt.subject?.(screen);
79
+ const name = subject ? `${prompt.name}: ${subject}` : prompt.name;
80
+ if (prompt.pick === void 0) return {
81
+ prompt,
82
+ name
83
+ };
84
+ if (prompt.pick === "") return {
85
+ prompt,
86
+ name,
87
+ keys: "\r"
88
+ };
89
+ const cursor = lines.findLastIndex((line) => line.startsWith(CURSOR));
90
+ const option = lines.findLastIndex((line) => line.replace(CURSOR, "").replace(/^\d+\./, "").startsWith(prompt.pick));
91
+ if (cursor === -1 || option === -1) return {
92
+ prompt,
93
+ name
94
+ };
95
+ return {
96
+ prompt,
97
+ name,
98
+ keys: `${(option > cursor ? DOWN : UP).repeat(Math.abs(option - cursor))}\r`
99
+ };
100
+ };
101
+ /** What harnessd says when Claude Code refuses its channels. */
102
+ const CHANNELS_REFUSED = "Claude Code refused harnessd's channels: managed settings block channels (channelsEnabled isn't true), so their events are dropped. Whoever manages Claude Code's settings for this organization or this computer has to set channelsEnabled; harnessd leaves them alone.";
103
+ /** Claude Code's start notice when a Team or Enterprise organization's (or this Mac's) managed settings keep channels out. */
104
+ const channelsRefused = (screen) => /blockedbyorgpolicy\([^)]*plugin:harnessd@inline/.test(screen.map((line) => line.replace(/\s+/g, "")).join(""));
105
+ const QUIET_MS = 500;
106
+ const MAX_ANSWERS = 3;
107
+ /** Reads Claude Code's screen as its output arrives and answers the prompts harnessd knows. */
108
+ const promptWatcher = (options) => {
109
+ const term = new xterm.Terminal({
110
+ cols: options.cols,
111
+ rows: options.rows,
112
+ scrollback: 0,
113
+ allowProposedApi: true
114
+ });
115
+ const answers = /* @__PURE__ */ new Map();
116
+ let waiting;
117
+ let refused = false;
118
+ let skipsPermissions = false;
119
+ let timer;
120
+ const screen = () => {
121
+ const buffer = term.buffer.active;
122
+ return Array.from({ length: term.rows }, (_, row) => buffer.getLine(buffer.viewportY + row)?.translateToString(true) ?? "");
123
+ };
124
+ const wait = (name) => {
125
+ if (waiting === name) return;
126
+ waiting = name;
127
+ options.log(`Claude Code waits for an answer (${name}): harnessd attach, then answer it`);
128
+ };
129
+ const check = () => {
130
+ const lines = screen();
131
+ if (!refused && channelsRefused(lines)) {
132
+ refused = true;
133
+ options.log(CHANNELS_REFUSED);
134
+ }
135
+ const found = findPrompt(lines);
136
+ if (!found) {
137
+ waiting = void 0;
138
+ return;
139
+ }
140
+ const { name } = found;
141
+ const answered = answers.get(name) ?? 0;
142
+ if (found.keys === void 0 || answered >= MAX_ANSWERS || found.prompt.forSkippedPermissions && !skipsPermissions) return wait(name);
143
+ answers.set(name, answered + 1);
144
+ waiting = void 0;
145
+ options.log(`answered Claude Code's prompt: ${name}`);
146
+ options.write(found.keys);
147
+ };
148
+ return {
149
+ push: (data) => {
150
+ clearTimeout(timer);
151
+ term.write(data, () => {
152
+ clearTimeout(timer);
153
+ timer = setTimeout(check, options.quietMs ?? QUIET_MS);
154
+ });
155
+ },
156
+ resize: (cols, rows) => term.resize(cols, rows),
157
+ reset: (start) => {
158
+ skipsPermissions = start?.skipsPermissions ?? false;
159
+ clearTimeout(timer);
160
+ term.reset();
161
+ answers.clear();
162
+ waiting = void 0;
163
+ refused = false;
164
+ },
165
+ waitingOn: () => waiting,
166
+ channelsRefused: () => refused
167
+ };
168
+ };
169
+ export { CHANNELS_REFUSED, PROMPTS, channelsRefused, findPrompt, promptWatcher };
170
+
171
+ //# sourceMappingURL=prompts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prompts.js","names":[],"sources":["../src/prompts.ts"],"sourcesContent":["import xterm from \"@xterm/headless\";\n\nexport namespace Prompts {\n /** A screen where Claude Code waits for an answer before it goes on. */\n export type Prompt = {\n readonly name: string;\n /** Matches the end of the screen, read without its whitespace. */\n readonly shows: RegExp;\n /** How the option harnessd picks starts, or \"\" where Enter is the answer. Absent: only a person can answer, and `harnessd status` says so. */\n readonly pick?: string;\n /** Answered only for a start whose arguments turn permission prompts off; otherwise a person answers. */\n readonly forSkippedPermissions?: true;\n /** What this screen asks about, read from the screen as drawn: it follows the name, as `<name>: <subject>`. */\n readonly subject?: (screen: readonly string[]) => string | undefined;\n };\n\n export type Found = {\n readonly prompt: Prompt;\n /** The prompt's name, with what it asks about when the screen says. */\n readonly name: string;\n /** What to type, when harnessd answers this prompt. */\n readonly keys?: string;\n };\n\n export type Options = {\n /** Types into Claude Code's terminal. */\n readonly write: (keys: string) => void;\n readonly log: (line: string) => void;\n readonly cols: number;\n readonly rows: number;\n readonly quietMs?: number;\n };\n\n export type Watcher = {\n /** Claude Code's terminal output. */\n readonly push: (data: string) => void;\n readonly resize: (cols: number, rows: number) => void;\n /** A new start of Claude Code: an empty screen. `skipsPermissions`: its arguments turn permission prompts off. */\n readonly reset: (start?: { skipsPermissions?: boolean }) => void;\n /** The prompt Claude Code waits at for a person, if any. */\n readonly waitingOn: () => string | undefined;\n /** Whether this start's screen said managed settings keep harnessd's channels out. */\n readonly channelsRefused: () => boolean;\n };\n}\n\nconst CONFIRM = \"Entertoconfirm·Esctocancel$\";\n\n/** The prompts of Claude Code 2.1 that stop a start nobody watches. */\nexport const PROMPTS: readonly Prompts.Prompt[] = [\n {\n name: \"the text style\",\n shows:\n /Choosethetextstylethatlooksbestwithyourterminal[^]*Syntaxtheme:[^\\n]*$/,\n pick: \"\",\n },\n {\n name: \"the security notes\",\n shows: /Securitynotes:[^]*PressEntertocontinue…?$/,\n pick: \"\",\n },\n {\n name: \"trust in the agent's folder\",\n shows: new RegExp(\n `Accessingworkspace:[^]*Yes,Itrustthisfolder\\\\n${CONFIRM}`,\n ),\n pick: \"Yes,Itrustthisfolder\",\n },\n {\n name: \"running without permission prompts\",\n shows: new RegExp(\n `ClaudeCoderunninginBypassPermissionsmode[^]*Yes,Iaccept\\\\n${CONFIRM}`,\n ),\n pick: \"Yes,Iaccept\",\n forSkippedPermissions: true,\n },\n {\n // shown at every start with --dangerously-load-development-channels; only harnessd's own plugin is answered for\n name: \"loading harnessd's channels\",\n shows: new RegExp(\n `WARNING:Loadingdevelopmentchannels[^]*\\\\nChannels:plugin:harnessd@inline\\\\n❯?1\\\\.Iamusingthisforlocaldevelopment[^]*${CONFIRM}`,\n ),\n pick: \"Iamusingthisforlocaldevelopment\",\n },\n {\n name: \"the API key in its environment\",\n shows: new RegExp(\n `DetectedacustomAPIkeyinyourenvironment[^]*DoyouwanttousethisAPIkey\\\\?[^]*${CONFIRM}`,\n ),\n pick: \"Yes\",\n },\n {\n name: \"CLAUDE.md imports from outside the folder\",\n shows:\n /AllowexternalCLAUDE\\.mdfileimports\\?[^]*Yes,allowexternalimports\\nEntertoconfirm·Esctodisable$/,\n pick: \"Yes,allowexternalimports\",\n },\n {\n name: \"what to do at its usage limit\",\n shows: new RegExp(\n `Whatdoyouwanttodo\\\\?\\\\n❯?1\\\\.Stopandwaitforlimittoreset[^]*${CONFIRM}`,\n ),\n pick: \"Waithere,thencontinueautomatically\",\n },\n {\n // shown once per account\n name: \"the new autocompact default\",\n shows:\n /Autocompactnowdefaultsto\\w+tokens\\n[^]*Apply\\(allmodels\\)\\n[^]*Entertoconfirm·Esctoclose$/,\n pick: \"Apply(allmodels)\",\n },\n { name: \"a sign-in\", shows: /Selectloginmethod:(\\n❯?\\d\\.[^\\n]*)+$/ },\n {\n // a tool asks before it acts (\"Bash command\", \"Create file\"…): only a person approves it\n name: \"permission\",\n shows: /\\nDoyouwantto[^\\n]*\\?\\n❯?1\\.Yes\\n[^]*\\nEsctocancel·Tabtoamend$/,\n subject: (screen) => {\n const rule = screen.findLastIndex((line) => /^─{10,}$/.test(line.trim()));\n return screen\n .slice(rule + 1)\n .map((line) => line.trim())\n .find((line) => line !== \"\");\n },\n },\n {\n name: \"a question harnessd doesn't know\",\n shows: /\\nEntertoconfirm·Escto\\w+$/,\n },\n];\n\nconst CURSOR = \"❯\";\nconst DOWN = \"\\x1b[B\";\nconst UP = \"\\x1b[A\";\n\n/** The prompt a screen ends with, and the keys that answer it. */\nexport const findPrompt = (\n screen: readonly string[],\n prompts: readonly Prompts.Prompt[] = PROMPTS,\n): Prompts.Found | undefined => {\n const lines = screen\n .map((line) => line.replace(/\\s+/g, \"\"))\n .filter((line) => line !== \"\");\n const text = lines.join(\"\\n\");\n const prompt = prompts.find((p) => p.shows.test(text));\n if (!prompt) return undefined;\n const subject = prompt.subject?.(screen);\n const name = subject ? `${prompt.name}: ${subject}` : prompt.name;\n if (prompt.pick === undefined) return { prompt, name };\n if (prompt.pick === \"\") return { prompt, name, keys: \"\\r\" };\n const cursor = lines.findLastIndex((line) => line.startsWith(CURSOR));\n const option = lines.findLastIndex((line) =>\n line\n .replace(CURSOR, \"\")\n .replace(/^\\d+\\./, \"\")\n .startsWith(prompt.pick!),\n );\n // an option list harnessd can't read is left to a person\n if (cursor === -1 || option === -1) return { prompt, name };\n return {\n prompt,\n name,\n keys: `${(option > cursor ? DOWN : UP).repeat(Math.abs(option - cursor))}\\r`,\n };\n};\n\n/** What harnessd says when Claude Code refuses its channels. */\nexport const CHANNELS_REFUSED =\n \"Claude Code refused harnessd's channels: managed settings block channels (channelsEnabled isn't true), so their events are dropped. Whoever manages Claude Code's settings for this organization or this computer has to set channelsEnabled; harnessd leaves them alone.\";\n\n/** Claude Code's start notice when a Team or Enterprise organization's (or this Mac's) managed settings keep channels out. */\nexport const channelsRefused = (screen: readonly string[]) =>\n /blockedbyorgpolicy\\([^)]*plugin:harnessd@inline/.test(\n screen.map((line) => line.replace(/\\s+/g, \"\")).join(\"\"),\n );\n\nconst QUIET_MS = 500;\n// a prompt still there after this many answers isn't taking them\nconst MAX_ANSWERS = 3;\n\n/** Reads Claude Code's screen as its output arrives and answers the prompts harnessd knows. */\nexport const promptWatcher = (options: Prompts.Options): Prompts.Watcher => {\n const term = new xterm.Terminal({\n cols: options.cols,\n rows: options.rows,\n scrollback: 0,\n allowProposedApi: true,\n });\n const answers = new Map<string, number>();\n let waiting: string | undefined;\n let refused = false;\n let skipsPermissions = false;\n let timer: ReturnType<typeof setTimeout> | undefined;\n\n const screen = () => {\n const buffer = term.buffer.active;\n return Array.from(\n { length: term.rows },\n (_, row) =>\n buffer.getLine(buffer.viewportY + row)?.translateToString(true) ?? \"\",\n );\n };\n const wait = (name: string) => {\n if (waiting === name) return;\n waiting = name;\n options.log(\n `Claude Code waits for an answer (${name}): harnessd attach, then answer it`,\n );\n };\n const check = () => {\n const lines = screen();\n if (!refused && channelsRefused(lines)) {\n refused = true;\n options.log(CHANNELS_REFUSED);\n }\n const found = findPrompt(lines);\n if (!found) {\n waiting = undefined;\n return;\n }\n const { name } = found;\n const answered = answers.get(name) ?? 0;\n if (\n found.keys === undefined ||\n answered >= MAX_ANSWERS ||\n (found.prompt.forSkippedPermissions && !skipsPermissions)\n )\n return wait(name);\n answers.set(name, answered + 1);\n waiting = undefined;\n options.log(`answered Claude Code's prompt: ${name}`);\n options.write(found.keys);\n };\n\n return {\n push: (data) => {\n clearTimeout(timer);\n // the screen is read once the output has gone quiet, so a half-drawn prompt isn't answered\n term.write(data, () => {\n clearTimeout(timer);\n timer = setTimeout(check, options.quietMs ?? QUIET_MS);\n });\n },\n resize: (cols, rows) => term.resize(cols, rows),\n reset: (start) => {\n skipsPermissions = start?.skipsPermissions ?? false;\n clearTimeout(timer);\n term.reset();\n answers.clear();\n waiting = undefined;\n refused = false;\n },\n waitingOn: () => waiting,\n channelsRefused: () => refused,\n };\n};\n"],"mappings":";;AA8CA,MAAM,UAAU;;AAGhB,MAAa,UAAqC;CAChD;EACE,MAAM;EACN,OACE;EACF,MAAM;CACR;CACA;EACE,MAAM;EACN,OAAO;EACP,MAAM;CACR;CACA;EACE,MAAM;EACN,OAAO,IAAI,OACT,iDAAiD,SACnD;EACA,MAAM;CACR;CACA;EACE,MAAM;EACN,OAAO,IAAI,OACT,6DAA6D,SAC/D;EACA,MAAM;EACN,uBAAuB;CACzB;CACA;EAEE,MAAM;EACN,OAAO,IAAI,OACT,uHAAuH,SACzH;EACA,MAAM;CACR;CACA;EACE,MAAM;EACN,OAAO,IAAI,OACT,4EAA4E,SAC9E;EACA,MAAM;CACR;CACA;EACE,MAAM;EACN,OACE;EACF,MAAM;CACR;CACA;EACE,MAAM;EACN,OAAO,IAAI,OACT,8DAA8D,SAChE;EACA,MAAM;CACR;CACA;EAEE,MAAM;EACN,OACE;EACF,MAAM;CACR;CACA;EAAE,MAAM;EAAa,OAAO;CAAuC;CACnE;EAEE,MAAM;EACN,OAAO;EACP,UAAU,WAAW;GACnB,MAAM,OAAO,OAAO,eAAe,SAAS,WAAW,KAAK,KAAK,KAAK,CAAC,CAAC;GACxE,OAAO,OACJ,MAAM,OAAO,CAAC,CAAC,CACf,KAAK,SAAS,KAAK,KAAK,CAAC,CAAC,CAC1B,MAAM,SAA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B;GAC9C,aAAa,KAAK;GAClB,KAAK,MAAM;GACX,QAAQ,MAAM;GACd,UAAU,KAAA;GACV,UAAU;EACZ;EACA,iBAAiB;EACjB,uBAAuB;CACzB;AACF"}
@@ -0,0 +1,37 @@
1
+ import type { Harnessd } from "./config.js";
2
+ export declare namespace Service {
3
+ /** What the system's service manager starts: `node <bin> run`, with this environment. */
4
+ type Spec = {
5
+ readonly label: string;
6
+ readonly node: string;
7
+ readonly bin: string;
8
+ readonly env: Readonly<Record<string, string>>;
9
+ readonly paths: Harnessd.Paths;
10
+ /** A boot service that runs as this user, installed by root. Without it: the installing user's login item. */
11
+ readonly user?: string;
12
+ };
13
+ type User = {
14
+ readonly name: string;
15
+ readonly uid: number;
16
+ readonly gid: number;
17
+ readonly home: string;
18
+ };
19
+ }
20
+ export declare const supportedPlatform: (platform?: string) => void;
21
+ /** Where the service's file goes: a login item's in the user's home, a boot service's in the system's folder. */
22
+ export declare const servicePath: (label: string, boot: boolean, platform?: string) => string;
23
+ /**
24
+ * The installed service of one kind that runs harnessd in this state folder, whatever its label: the same folder
25
+ * reached through HARNESSD_HOME has another label than through the default paths.
26
+ */
27
+ export declare const serviceIn: (home: string, boot: boolean, platform?: string, dir?: string) => string | undefined;
28
+ export declare const serviceText: (spec: Service.Spec, platform?: string) => string;
29
+ /** Registers harnessd with launchd or systemd and starts it. */
30
+ export declare const installService: (spec: Service.Spec) => Promise<void>;
31
+ /** Stops harnessd and removes its service; false when it wasn't installed. */
32
+ export declare const removeService: (label: string, boot: boolean) => boolean;
33
+ /** The user a boot service runs as, looked up by name: under sudo this process's own home is root's. */
34
+ export declare const lookUpUser: (name: string) => Service.User;
35
+ /** Runs `write` as `user`, so the files root makes in the user's home are the user's. */
36
+ export declare const asUser: <T>(user: Service.User | undefined, write: () => T) => T;
37
+ //# sourceMappingURL=service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../src/service.ts"],"names":[],"mappings":"AAAA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,wGAAwG;AACxG,eAAO,MAAM,UAAU,GAAI,MAAM,MAAM,KAAG,OAAO,CAAC,IAgBjD,CAAC;AAEF,yFAAyF;AACzF,eAAO,MAAM,MAAM,GAAI,CAAC,EACtB,MAAM,OAAO,CAAC,IAAI,GAAG,SAAS,EAC9B,OAAO,MAAM,CAAC,KACb,CAUF,CAAC"}
@@ -0,0 +1,71 @@
1
+ import { system } from "./system.js";
2
+ import { load, plistFolder, plistOf, plistPath, unload } from "./launchd.js";
3
+ import { disable, enable, unitFolder, unitOf, unitPath } from "./systemd.js";
4
+ import { readFileSync, readdirSync } from "node:fs";
5
+ import { dirname, join } from "node:path";
6
+ // src/service.ts
7
+ const on = (platform, mac, linux) => {
8
+ if (platform === "darwin") return mac();
9
+ if (platform === "linux") return linux();
10
+ throw new Error("harnessd runs on macOS (it starts with launchd) and on Linux (with systemd).");
11
+ };
12
+ const supportedPlatform = (platform = process.platform) => on(platform, () => {}, () => {});
13
+ /** Where the service's file goes: a login item's in the user's home, a boot service's in the system's folder. */
14
+ const servicePath = (label, boot, platform = process.platform) => on(platform, () => plistPath(label, boot), () => unitPath(label, boot));
15
+ /**
16
+ * The installed service of one kind that runs harnessd in this state folder, whatever its label: the same folder
17
+ * reached through HARNESSD_HOME has another label than through the default paths.
18
+ */
19
+ const serviceIn = (home, boot, platform = process.platform, dir = dirname(servicePath("dev.harnessd", boot, platform))) => {
20
+ const folder = `${on(platform, () => plistFolder(home), () => unitFolder(home))}\n`;
21
+ let names = [];
22
+ try {
23
+ names = readdirSync(dir);
24
+ } catch {}
25
+ return names.filter((name) => /^(dev\.)?harnessd.*\.(plist|service)$/.test(name)).map((name) => join(dir, name)).find((file) => {
26
+ try {
27
+ return readFileSync(file, "utf8").includes(folder);
28
+ } catch {
29
+ return false;
30
+ }
31
+ });
32
+ };
33
+ const serviceText = (spec, platform = process.platform) => on(platform, () => plistOf(spec), () => unitOf(spec));
34
+ /** Registers harnessd with launchd or systemd and starts it. */
35
+ const installService = async (spec) => on(process.platform, () => load(spec.label, plistOf(spec), spec.user !== void 0), async () => enable(spec.label, unitOf(spec), spec.user !== void 0));
36
+ /** Stops harnessd and removes its service; false when it wasn't installed. */
37
+ const removeService = (label, boot) => on(process.platform, () => unload(label, boot), () => disable(label, boot));
38
+ /** The user a boot service runs as, looked up by name: under sudo this process's own home is root's. */
39
+ const lookUpUser = (name) => {
40
+ const said = (file, args) => {
41
+ const result = system(file, args);
42
+ return result.status === 0 ? result.stdout.trim() : "";
43
+ };
44
+ const known = /^[A-Za-z_][A-Za-z0-9_.-]*$/.test(name);
45
+ const uid = known ? said("id", ["-u", name]) : "";
46
+ const gid = known ? said("id", ["-g", name]) : "";
47
+ const home = known ? said("/bin/sh", ["-c", `echo ~${name}`]) : "";
48
+ if (!uid || !gid || !home.startsWith("/")) throw new Error(`No user ${name} on this computer.`);
49
+ if (uid === "0") throw new Error("Claude Code doesn't run without permission prompts as root: name another user with --user <name>.");
50
+ return {
51
+ name,
52
+ uid: Number(uid),
53
+ gid: Number(gid),
54
+ home
55
+ };
56
+ };
57
+ /** Runs `write` as `user`, so the files root makes in the user's home are the user's. */
58
+ const asUser = (user, write) => {
59
+ if (!user || process.getuid?.() !== 0) return write();
60
+ process.setegid(user.gid);
61
+ process.seteuid(user.uid);
62
+ try {
63
+ return write();
64
+ } finally {
65
+ process.seteuid(0);
66
+ process.setegid(0);
67
+ }
68
+ };
69
+ export { asUser, installService, lookUpUser, removeService, serviceIn, servicePath, serviceText, supportedPlatform };
70
+
71
+ //# sourceMappingURL=service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"service.js","names":[],"sources":["../src/service.ts"],"sourcesContent":["import type { Harnessd } from \"./config\";\nimport { readdirSync, readFileSync } from \"node:fs\";\nimport { dirname, join } from \"node:path\";\nimport { load, plistFolder, plistOf, plistPath, unload } from \"./launchd\";\nimport { disable, enable, unitFolder, unitOf, unitPath } from \"./systemd\";\nimport { system } from \"./system\";\n\nexport namespace Service {\n /** What the system's service manager starts: `node <bin> run`, with this environment. */\n export type Spec = {\n readonly label: string;\n readonly node: string;\n readonly bin: string;\n readonly env: Readonly<Record<string, string>>;\n readonly paths: Harnessd.Paths;\n /** A boot service that runs as this user, installed by root. Without it: the installing user's login item. */\n readonly user?: string;\n };\n\n export type User = {\n readonly name: string;\n readonly uid: number;\n readonly gid: number;\n readonly home: string;\n };\n}\n\nconst on = <T>(platform: string, mac: () => T, linux: () => T): T => {\n if (platform === \"darwin\") return mac();\n if (platform === \"linux\") return linux();\n throw new Error(\n \"harnessd runs on macOS (it starts with launchd) and on Linux (with systemd).\",\n );\n};\n\nexport const supportedPlatform = (platform: string = process.platform) =>\n on(\n platform,\n () => {},\n () => {},\n );\n\n/** Where the service's file goes: a login item's in the user's home, a boot service's in the system's folder. */\nexport const servicePath = (\n label: string,\n boot: boolean,\n platform: string = process.platform,\n) =>\n on(\n platform,\n () => plistPath(label, boot),\n () => unitPath(label, boot),\n );\n\n/**\n * The installed service of one kind that runs harnessd in this state folder, whatever its label: the same folder\n * reached through HARNESSD_HOME has another label than through the default paths.\n */\nexport const serviceIn = (\n home: string,\n boot: boolean,\n platform: string = process.platform,\n dir = dirname(servicePath(\"dev.harnessd\", boot, platform)),\n) => {\n const folder = `${on(\n platform,\n () => plistFolder(home),\n () => unitFolder(home),\n )}\\n`;\n let names: string[] = [];\n try {\n names = readdirSync(dir);\n } catch {}\n return names\n .filter((name) => /^(dev\\.)?harnessd.*\\.(plist|service)$/.test(name))\n .map((name) => join(dir, name))\n .find((file) => {\n try {\n return readFileSync(file, \"utf8\").includes(folder);\n } catch {\n return false;\n }\n });\n};\n\nexport const serviceText = (\n spec: Service.Spec,\n platform: string = process.platform,\n) =>\n on(\n platform,\n () => plistOf(spec),\n () => unitOf(spec),\n );\n\n/** Registers harnessd with launchd or systemd and starts it. */\nexport const installService = async (spec: Service.Spec) =>\n on(\n process.platform,\n () => load(spec.label, plistOf(spec), spec.user !== undefined),\n async () => enable(spec.label, unitOf(spec), spec.user !== undefined),\n );\n\n/** Stops harnessd and removes its service; false when it wasn't installed. */\nexport const removeService = (label: string, boot: boolean) =>\n on(\n process.platform,\n () => unload(label, boot),\n () => disable(label, boot),\n );\n\n/** The user a boot service runs as, looked up by name: under sudo this process's own home is root's. */\nexport const lookUpUser = (name: string): Service.User => {\n const said = (file: string, args: string[]) => {\n const result = system(file, args);\n return result.status === 0 ? result.stdout.trim() : \"\";\n };\n const known = /^[A-Za-z_][A-Za-z0-9_.-]*$/.test(name);\n const uid = known ? said(\"id\", [\"-u\", name]) : \"\";\n const gid = known ? said(\"id\", [\"-g\", name]) : \"\";\n const home = known ? said(\"/bin/sh\", [\"-c\", `echo ~${name}`]) : \"\";\n if (!uid || !gid || !home.startsWith(\"/\"))\n throw new Error(`No user ${name} on this computer.`);\n if (uid === \"0\")\n throw new Error(\n \"Claude Code doesn't run without permission prompts as root: name another user with --user <name>.\",\n );\n return { name, uid: Number(uid), gid: Number(gid), home };\n};\n\n/** Runs `write` as `user`, so the files root makes in the user's home are the user's. */\nexport const asUser = <T>(\n user: Service.User | undefined,\n write: () => T,\n): T => {\n if (!user || process.getuid?.() !== 0) return write();\n process.setegid!(user.gid);\n process.seteuid!(user.uid);\n try {\n return write();\n } finally {\n process.seteuid!(0);\n process.setegid!(0);\n }\n};\n"],"mappings":";;;;;;AA2BA,MAAM,MAAS,UAAkB,KAAc,UAAsB;CACnE,IAAI,aAAa,UAAU,OAAO,IAAI;CACtC,IAAI,aAAa,SAAS,OAAO,MAAM;CACvC,MAAM,IAAI,MACR,8EACF;AACF;AAEA,MAAa,qBAAqB,WAAmB,QAAQ,aAC3D,GACE,gBACM,CAAC,SACD,CAAC,CACT;;AAGF,MAAa,eACX,OACA,MACA,WAAmB,QAAQ,aAE3B,GACE,gBACM,UAAU,OAAO,IAAI,SACrB,SAAS,OAAO,IAAI,CAC5B;;;;;AAMF,MAAa,aACX,MACA,MACA,WAAmB,QAAQ,UAC3B,MAAM,QAAQ,YAAY,gBAAgB,MAAM,QAA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,OAAO,CAAC,KAAK,WAAW,GAAG,GACtC,MAAM,IAAI,MAAM,WAAW,KAAK,mBAAmB;CACrD,IAAI,QAAQ,KACV,MAAM,IAAI,MACR,mGACF;CACF,OAAO;EAAE;EAAM,KAAK,OAAO,GAAG;EAAG,KAAK,OAAO,GAAG;EAAG;CAAK;AAC1D;;AAGA,MAAa,UACX,MACA,UACM;CACN,IAAI,CAAC,QAAQ,QAAQ,SAAS,MAAM,GAAG,OAAO,MAAM;CACpD,QAAQ,QAAS,KAAK,GAAG;CACzB,QAAQ,QAAS,KAAK,GAAG;CACzB,IAAI;EACF,OAAO,MAAM;CACf,UAAU;EACR,QAAQ,QAAS,CAAC;EAClB,QAAQ,QAAS,CAAC;CACpB;AACF"}
@@ -0,0 +1,37 @@
1
+ import { type Harnessd } from "./config.js";
2
+ import { type Service } from "./service.js";
3
+ export declare namespace Setup {
4
+ /** The person at `harnessd service install`; none when it runs from a script. */
5
+ type Terminal = {
6
+ readonly confirm: (question: string) => Promise<boolean>;
7
+ readonly line: (question: string) => Promise<string>;
8
+ };
9
+ }
10
+ /** Anthropic's installer for Claude Code. */
11
+ export declare const INSTALLER = "curl -fsSL https://claude.ai/install.sh | bash";
12
+ export declare const ttyTerminal: () => Setup.Terminal | undefined;
13
+ /** The `claude` on the PATH or where Anthropic's installer puts it; none: installs it with `install`, or after a yes on the terminal. */
14
+ export declare const ensureClaude: (o: {
15
+ terminal: Setup.Terminal | undefined;
16
+ user: Service.User | undefined;
17
+ /** `--install-claude`: runs the installer without asking. */
18
+ install?: boolean | undefined;
19
+ }) => Promise<string>;
20
+ /**
21
+ * Checks that Claude Code is signed in the way the service can use, and offers the sign-in on the terminal: Claude
22
+ * Code's own for a login item, a `claude setup-token` token for a boot service and for Linux without a desktop.
23
+ * Without a sign-in it throws what to run; with `skip` it asks nothing and resolves to that instead. Resolves to
24
+ * nothing when Claude Code is signed in, or when a prestart command may sign it in.
25
+ */
26
+ export declare const ensureSignedIn: (o: {
27
+ claude: string;
28
+ paths: Harnessd.Paths;
29
+ /** The environment the service starts harnessd with. */
30
+ env: Readonly<Record<string, string>>;
31
+ user: Service.User | undefined;
32
+ terminal: Setup.Terminal | undefined;
33
+ /** `--skip-sign-in`: the install goes on without a sign-in. */
34
+ skip?: boolean | undefined;
35
+ platform?: string;
36
+ }) => Promise<string | undefined>;
37
+ //# sourceMappingURL=setup.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"setup.d.ts","sourceRoot":"","sources":["../src/setup.ts"],"names":[],"mappings":"AAMA,OAAO,EAAc,KAAK,QAAQ,EAAE,oBAAiB;AACrD,OAAO,EAAU,KAAK,OAAO,EAAE,qBAAkB;AAEjD,yBAAiB,KAAK,CAAC;IACrB,iFAAiF;IACjF,KAAY,QAAQ,GAAG;QACrB,QAAQ,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;QACzD,QAAQ,CAAC,IAAI,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;KACtD,CAAC;CACH;AAED,6CAA6C;AAC7C,eAAO,MAAM,SAAS,mDAAmD,CAAC;AAE1E,eAAO,MAAM,WAAW,QAAO,KAAK,CAAC,QAAQ,GAAG,SAkB/C,CAAC;AAMF,yIAAyI;AACzI,eAAO,MAAM,YAAY,GAAU,GAAG;IACpC,QAAQ,EAAE,KAAK,CAAC,QAAQ,GAAG,SAAS,CAAC;IACrC,IAAI,EAAE,OAAO,CAAC,IAAI,GAAG,SAAS,CAAC;IAC/B,6DAA6D;IAC7D,OAAO,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;CAC/B,oBAgCA,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,cAAc,GAAU,GAAG;IACtC,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,QAAQ,CAAC,KAAK,CAAC;IACtB,wDAAwD;IACxD,GAAG,EAAE,QAAQ,CAAC,MAA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