@eloxiv/daemon 0.0.0-stage → 0.1.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.
Files changed (119) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +6 -2
  3. package/dist/Acp.d.ts +8 -0
  4. package/dist/Acp.d.ts.map +1 -0
  5. package/dist/Acp.js +268 -0
  6. package/dist/Acp.js.map +1 -0
  7. package/dist/Canonical.d.ts +3 -0
  8. package/dist/Canonical.d.ts.map +1 -0
  9. package/dist/Canonical.js +12 -0
  10. package/dist/Canonical.js.map +1 -0
  11. package/dist/Client.d.ts +102 -0
  12. package/dist/Client.d.ts.map +1 -0
  13. package/dist/Client.js +482 -0
  14. package/dist/Client.js.map +1 -0
  15. package/dist/Commands.d.ts +85 -0
  16. package/dist/Commands.d.ts.map +1 -0
  17. package/dist/Commands.js +370 -0
  18. package/dist/Commands.js.map +1 -0
  19. package/dist/Config.d.ts +74 -0
  20. package/dist/Config.d.ts.map +1 -0
  21. package/dist/Config.js +126 -0
  22. package/dist/Config.js.map +1 -0
  23. package/dist/Daemon.d.ts +243 -0
  24. package/dist/Daemon.d.ts.map +1 -0
  25. package/dist/Daemon.js +965 -0
  26. package/dist/Daemon.js.map +1 -0
  27. package/dist/Harness.d.ts +133 -0
  28. package/dist/Harness.d.ts.map +1 -0
  29. package/dist/Harness.js +734 -0
  30. package/dist/Harness.js.map +1 -0
  31. package/dist/Http.d.ts +15 -0
  32. package/dist/Http.d.ts.map +1 -0
  33. package/dist/Http.js +548 -0
  34. package/dist/Http.js.map +1 -0
  35. package/dist/KernelLink.d.ts +145 -0
  36. package/dist/KernelLink.d.ts.map +1 -0
  37. package/dist/KernelLink.js +109 -0
  38. package/dist/KernelLink.js.map +1 -0
  39. package/dist/LocalAuth.d.ts +99 -0
  40. package/dist/LocalAuth.d.ts.map +1 -0
  41. package/dist/LocalAuth.js +225 -0
  42. package/dist/LocalAuth.js.map +1 -0
  43. package/dist/Main.d.ts +51 -0
  44. package/dist/Main.d.ts.map +1 -0
  45. package/dist/Main.js +219 -0
  46. package/dist/Main.js.map +1 -0
  47. package/dist/PersonSession.d.ts +49 -0
  48. package/dist/PersonSession.d.ts.map +1 -0
  49. package/dist/PersonSession.js +173 -0
  50. package/dist/PersonSession.js.map +1 -0
  51. package/dist/Secrets.d.ts +21 -0
  52. package/dist/Secrets.d.ts.map +1 -0
  53. package/dist/Secrets.js +204 -0
  54. package/dist/Secrets.js.map +1 -0
  55. package/dist/SecureUrl.d.ts +11 -0
  56. package/dist/SecureUrl.d.ts.map +1 -0
  57. package/dist/SecureUrl.js +23 -0
  58. package/dist/SecureUrl.js.map +1 -0
  59. package/dist/State.d.ts +77 -0
  60. package/dist/State.d.ts.map +1 -0
  61. package/dist/State.js +38 -0
  62. package/dist/State.js.map +1 -0
  63. package/dist/Terminals.d.ts +49 -0
  64. package/dist/Terminals.d.ts.map +1 -0
  65. package/dist/Terminals.js +203 -0
  66. package/dist/Terminals.js.map +1 -0
  67. package/dist/bin-node.d.ts +2 -0
  68. package/dist/bin-node.d.ts.map +1 -0
  69. package/dist/bin-node.js +4 -0
  70. package/dist/bin-node.js.map +1 -0
  71. package/dist/bin.d.ts +2 -0
  72. package/dist/bin.d.ts.map +1 -0
  73. package/dist/bin.js +4 -0
  74. package/dist/bin.js.map +1 -0
  75. package/dist/index.d.ts +18 -0
  76. package/dist/index.d.ts.map +1 -0
  77. package/dist/index.js +18 -0
  78. package/dist/index.js.map +1 -0
  79. package/dist/runtime/bun.d.ts +11 -0
  80. package/dist/runtime/bun.d.ts.map +1 -0
  81. package/dist/runtime/bun.js +20 -0
  82. package/dist/runtime/bun.js.map +1 -0
  83. package/dist/runtime/node.d.ts +11 -0
  84. package/dist/runtime/node.d.ts.map +1 -0
  85. package/dist/runtime/node.js +21 -0
  86. package/dist/runtime/node.js.map +1 -0
  87. package/dist/testing.d.ts +25 -0
  88. package/dist/testing.d.ts.map +1 -0
  89. package/dist/testing.js +27 -0
  90. package/dist/testing.js.map +1 -0
  91. package/fixtures/claude-code-env-vars.txt +409 -0
  92. package/fixtures/fake-acp-agent.mjs +222 -0
  93. package/fixtures/fake-harness.mjs +299 -0
  94. package/fixtures/recorded/claude-code.jsonl +7 -0
  95. package/fixtures/recorded/codex.jsonl +6 -0
  96. package/package.json +64 -3
  97. package/scripts/build-sidecar.ts +86 -0
  98. package/src/Acp.ts +292 -0
  99. package/src/Canonical.ts +9 -0
  100. package/src/Client.ts +590 -0
  101. package/src/Commands.ts +427 -0
  102. package/src/Config.ts +179 -0
  103. package/src/Daemon.ts +1092 -0
  104. package/src/Harness.ts +839 -0
  105. package/src/Http.ts +563 -0
  106. package/src/KernelLink.ts +197 -0
  107. package/src/LocalAuth.ts +301 -0
  108. package/src/Main.ts +281 -0
  109. package/src/PersonSession.ts +203 -0
  110. package/src/Secrets.ts +226 -0
  111. package/src/SecureUrl.ts +21 -0
  112. package/src/State.ts +109 -0
  113. package/src/Terminals.ts +227 -0
  114. package/src/bin-node.ts +4 -0
  115. package/src/bin.ts +4 -0
  116. package/src/index.ts +17 -0
  117. package/src/runtime/bun.ts +29 -0
  118. package/src/runtime/node.ts +30 -0
  119. package/src/testing.ts +43 -0
@@ -0,0 +1,49 @@
1
+ /** Terminals open at once, per daemon. */
2
+ export declare const MAX_TERMINALS = 8;
3
+ /** A terminal no client has watched for this long is closed (ms). */
4
+ export declare const TERMINAL_IDLE_MS: number;
5
+ type Listener = (event: {
6
+ readonly type: "output";
7
+ readonly data: string;
8
+ } | {
9
+ readonly type: "exit";
10
+ readonly code: number | null;
11
+ }) => void;
12
+ export declare class TerminalError extends Error {
13
+ readonly status: 403 | 404 | 429;
14
+ constructor(status: 403 | 404 | 429, message: string);
15
+ }
16
+ /** Whether terminals here get a pseudo-terminal (Bun) or pipes (Node). */
17
+ export declare const ptyAvailable: () => boolean;
18
+ export declare class Terminals {
19
+ #private;
20
+ constructor(onChange: (terminal: {
21
+ id: string;
22
+ startedAt: string;
23
+ endedAt: string | null;
24
+ pty: boolean;
25
+ }) => void);
26
+ /** Open a shell in `cwd` for the client `owner`. */
27
+ open(owner: string, input: {
28
+ readonly cwd: string;
29
+ readonly cols: number;
30
+ readonly rows: number;
31
+ }): {
32
+ id: `${string}-${string}-${string}-${string}-${string}`;
33
+ pty: boolean;
34
+ };
35
+ list(owner: string): {
36
+ id: string;
37
+ pty: boolean;
38
+ startedAt: string;
39
+ }[];
40
+ write(owner: string, id: string, data: string): void;
41
+ resize(owner: string, id: string, cols: number, rows: number): void;
42
+ /** Watch a terminal: its backlog first, then what follows; the returned function stops watching. */
43
+ watch(owner: string, id: string, listener: Listener): () => void;
44
+ close(owner: string, id: string): void;
45
+ /** Close every terminal (the daemon stops). */
46
+ closeAll(): void;
47
+ }
48
+ export {};
49
+ //# sourceMappingURL=Terminals.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Terminals.d.ts","sourceRoot":"","sources":["../src/Terminals.ts"],"names":[],"mappings":"AAeA,0CAA0C;AAC1C,eAAO,MAAM,aAAa,IAAI,CAAA;AAG9B,qEAAqE;AACrE,eAAO,MAAM,gBAAgB,QAAc,CAAA;AAE3C,KAAK,QAAQ,GAAG,CACd,KAAK,EAAE;IAAE,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,KAChH,IAAI,CAAA;AAsBT,qBAAa,aAAc,SAAQ,KAAK;IACtC,QAAQ,CAAC,MAAM,EAAE,GAAG,GAAG,GAAG,GAAG,GAAG,CAAA;IAChC,YAAY,MAAM,EAAE,GAAG,GAAG,GAAG,GAAG,GAAG,EAAE,OAAO,EAAE,MAAM,EAGnD;CACF;AAID,0EAA0E;AAC1E,eAAO,MAAM,YAAY,eAAiD,CAAA;AAM1E,qBAAa,SAAS;;IAKpB,YAAY,QAAQ,EAAE,CAAC,QAAQ,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;QAAC,GAAG,EAAE,OAAO,CAAA;KAAE,KAAK,IAAI,EAgBhH;IAED,oDAAoD;IACpD,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE;QAAE,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;KAAE;;;MAgFhG;IASD,IAAI,CAAC,KAAK,EAAE,MAAM;;;;QAIjB;IAED,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,QAE5C;IAED,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,QAE3D;IAED,oGAAoG;IACpG,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,GAAG,MAAM,IAAI,CAQ/D;IAED,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAE9B;IAiBD,+CAA+C;IAC/C,QAAQ,SAIP;CACF"}
@@ -0,0 +1,203 @@
1
+ /**
2
+ * Terminal sessions for the person's local clients (DeviceControl): an interactive shell in the daemon's workspace,
3
+ * its output streamed to the client that opened it and its input written by that client only. On Bun the shell
4
+ * runs in a pseudo-terminal (`Bun.spawn`'s `terminal`); on Node, which has none built in, it runs with pipes
5
+ * (`pty: false`: no line editing or full-screen programs).
6
+ *
7
+ * Off unless the daemon serves terminal commands (`--allow-commands terminal`, with a workspace). The shell runs as
8
+ * the daemon's OS user with the harnesses' environment allow-list (no credentials), in its own process group, which
9
+ * is killed when the terminal is closed, when its shell exits, when no client has watched it for ten minutes, and
10
+ * when the daemon stops.
11
+ */
12
+ import { spawn } from "node:child_process";
13
+ import { randomUUID } from "node:crypto";
14
+ import { harnessEnv } from "./Harness.js";
15
+ /** Terminals open at once, per daemon. */
16
+ export const MAX_TERMINALS = 8;
17
+ /** Output kept for a client that (re)attaches (characters). */
18
+ const BACKLOG = 64 * 1024;
19
+ /** A terminal no client has watched for this long is closed (ms). */
20
+ export const TERMINAL_IDLE_MS = 10 * 60_000;
21
+ export class TerminalError extends Error {
22
+ status;
23
+ constructor(status, message) {
24
+ super(message);
25
+ this.status = status;
26
+ }
27
+ }
28
+ const bunSpawn = globalThis.Bun;
29
+ /** Whether terminals here get a pseudo-terminal (Bun) or pipes (Node). */
30
+ export const ptyAvailable = () => typeof bunSpawn?.Terminal === "function";
31
+ /** Every daemon's terminals in this process, closed when the process exits (their shells are process groups). */
32
+ const everyTerminals = new Set();
33
+ let exitHook = false;
34
+ export class Terminals {
35
+ #open = new Map();
36
+ #sweep;
37
+ #onChange;
38
+ constructor(onChange) {
39
+ this.#onChange = onChange;
40
+ this.#sweep = setInterval(() => {
41
+ const now = Date.now();
42
+ for (const terminal of this.#open.values()) {
43
+ if (terminal.listeners.size === 0 && now - terminal.idleSince > TERMINAL_IDLE_MS)
44
+ this.#end(terminal);
45
+ }
46
+ }, 60_000);
47
+ this.#sweep.unref();
48
+ everyTerminals.add(this);
49
+ if (!exitHook) {
50
+ exitHook = true;
51
+ process.once("exit", () => {
52
+ for (const terminals of everyTerminals)
53
+ terminals.closeAll();
54
+ });
55
+ }
56
+ }
57
+ /** Open a shell in `cwd` for the client `owner`. */
58
+ open(owner, input) {
59
+ if (this.#open.size >= MAX_TERMINALS)
60
+ throw new TerminalError(429, `At most ${MAX_TERMINALS} terminals are open at once`);
61
+ const id = randomUUID();
62
+ const windows = process.platform === "win32";
63
+ const shell = windows ? "cmd.exe" : "/bin/sh";
64
+ const env = harnessEnv({ TERM: "xterm-256color" });
65
+ const terminal = {
66
+ id,
67
+ owner,
68
+ pty: ptyAvailable(),
69
+ startedAt: new Date().toISOString(),
70
+ write: () => { },
71
+ resize: () => { },
72
+ kill: () => { },
73
+ backlog: "",
74
+ exited: undefined,
75
+ listeners: new Set(),
76
+ idleSince: Date.now(),
77
+ };
78
+ const emit = (data) => {
79
+ terminal.backlog = (terminal.backlog + data).slice(-BACKLOG);
80
+ for (const listener of terminal.listeners)
81
+ listener({ type: "output", data });
82
+ };
83
+ const exited = (code) => {
84
+ if (terminal.exited !== undefined)
85
+ return;
86
+ terminal.exited = { code };
87
+ for (const listener of terminal.listeners)
88
+ listener({ type: "exit", code });
89
+ this.#end(terminal);
90
+ };
91
+ if (terminal.pty) {
92
+ const decoder = new TextDecoder();
93
+ const proc = bunSpawn.spawn([shell], {
94
+ cwd: input.cwd,
95
+ env,
96
+ terminal: {
97
+ cols: input.cols,
98
+ rows: input.rows,
99
+ data: (_t, data) => emit(decoder.decode(data, { stream: true })),
100
+ },
101
+ });
102
+ Object.assign(terminal, {
103
+ write: (data) => proc.terminal.write(data),
104
+ resize: (cols, rows) => proc.terminal.resize(cols, rows),
105
+ kill: () => {
106
+ try {
107
+ process.kill(-proc.pid, "SIGKILL");
108
+ }
109
+ catch {
110
+ proc.kill("SIGKILL");
111
+ }
112
+ proc.terminal.close();
113
+ },
114
+ });
115
+ void proc.exited.then((code) => exited(code));
116
+ }
117
+ else {
118
+ const child = spawn(shell, windows ? [] : ["-i"], {
119
+ cwd: input.cwd,
120
+ env,
121
+ stdio: ["pipe", "pipe", "pipe"],
122
+ detached: !windows,
123
+ });
124
+ child.stdout.setEncoding("utf8").on("data", emit);
125
+ child.stderr.setEncoding("utf8").on("data", emit);
126
+ child.on("error", () => exited(null));
127
+ child.on("close", (code) => exited(code));
128
+ Object.assign(terminal, {
129
+ write: (data) => child.stdin.write(data),
130
+ kill: () => {
131
+ try {
132
+ if (!windows && child.pid !== undefined)
133
+ process.kill(-child.pid, "SIGKILL");
134
+ else
135
+ child.kill("SIGKILL");
136
+ }
137
+ catch {
138
+ // Already gone.
139
+ }
140
+ },
141
+ });
142
+ }
143
+ this.#open.set(id, terminal);
144
+ this.#onChange({ id, startedAt: terminal.startedAt, endedAt: null, pty: terminal.pty });
145
+ return { id, pty: terminal.pty };
146
+ }
147
+ /** The terminal `id` if `owner` opened it (anyone else: not found). */
148
+ #owned(owner, id) {
149
+ const terminal = this.#open.get(id);
150
+ if (terminal === undefined || terminal.owner !== owner)
151
+ throw new TerminalError(404, "No such terminal");
152
+ return terminal;
153
+ }
154
+ list(owner) {
155
+ return [...this.#open.values()]
156
+ .filter((terminal) => terminal.owner === owner)
157
+ .map(({ id, pty, startedAt }) => ({ id, pty, startedAt }));
158
+ }
159
+ write(owner, id, data) {
160
+ this.#owned(owner, id).write(data);
161
+ }
162
+ resize(owner, id, cols, rows) {
163
+ this.#owned(owner, id).resize(cols, rows);
164
+ }
165
+ /** Watch a terminal: its backlog first, then what follows; the returned function stops watching. */
166
+ watch(owner, id, listener) {
167
+ const terminal = this.#owned(owner, id);
168
+ if (terminal.backlog.length > 0)
169
+ listener({ type: "output", data: terminal.backlog });
170
+ terminal.listeners.add(listener);
171
+ return () => {
172
+ terminal.listeners.delete(listener);
173
+ terminal.idleSince = Date.now();
174
+ };
175
+ }
176
+ close(owner, id) {
177
+ this.#end(this.#owned(owner, id));
178
+ }
179
+ #end(terminal) {
180
+ if (!this.#open.delete(terminal.id))
181
+ return;
182
+ terminal.kill();
183
+ if (terminal.exited === undefined) {
184
+ terminal.exited = { code: null };
185
+ for (const listener of terminal.listeners)
186
+ listener({ type: "exit", code: null });
187
+ }
188
+ this.#onChange({
189
+ id: terminal.id,
190
+ startedAt: terminal.startedAt,
191
+ endedAt: new Date().toISOString(),
192
+ pty: terminal.pty,
193
+ });
194
+ }
195
+ /** Close every terminal (the daemon stops). */
196
+ closeAll() {
197
+ clearInterval(this.#sweep);
198
+ everyTerminals.delete(this);
199
+ for (const terminal of Array.from(this.#open.values()))
200
+ this.#end(terminal);
201
+ }
202
+ }
203
+ //# sourceMappingURL=Terminals.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Terminals.js","sourceRoot":"","sources":["../src/Terminals.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,EAAE,KAAK,EAAqB,MAAM,oBAAoB,CAAA;AAC7D,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AACxC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAEzC,0CAA0C;AAC1C,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,CAAA;AAC9B,+DAA+D;AAC/D,MAAM,OAAO,GAAG,EAAE,GAAG,IAAI,CAAA;AACzB,qEAAqE;AACrE,MAAM,CAAC,MAAM,gBAAgB,GAAG,EAAE,GAAG,MAAM,CAAA;AA0B3C,MAAM,OAAO,aAAc,SAAQ,KAAK;IAC7B,MAAM,CAAiB;IAChC,YAAY,MAAuB,EAAE,OAAe;QAClD,KAAK,CAAC,OAAO,CAAC,CAAA;QACd,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;IACtB,CAAC;CACF;AAED,MAAM,QAAQ,GAAI,UAA6F,CAAC,GAAG,CAAA;AAEnH,0EAA0E;AAC1E,MAAM,CAAC,MAAM,YAAY,GAAG,GAAG,EAAE,CAAC,OAAO,QAAQ,EAAE,QAAQ,KAAK,UAAU,CAAA;AAE1E,iHAAiH;AACjH,MAAM,cAAc,GAAG,IAAI,GAAG,EAAa,CAAA;AAC3C,IAAI,QAAQ,GAAG,KAAK,CAAA;AAEpB,MAAM,OAAO,SAAS;IACX,KAAK,GAAG,IAAI,GAAG,EAAoB,CAAA;IACnC,MAAM,CAAgC;IACtC,SAAS,CAA6F;IAE/G,YAAY,QAAqG;QAC/G,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAA;QACzB,IAAI,CAAC,MAAM,GAAG,WAAW,CAAC,GAAG,EAAE;YAC7B,MAA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CAAC,QAAQ,CAAC,CAAA;IAC7E,CAAC;CACF"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=bin-node.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bin-node.d.ts","sourceRoot":"","sources":["../src/bin-node.ts"],"names":[],"mappings":""}
@@ -0,0 +1,4 @@
1
+ /** Run the daemon on Node (fallback): `node --conditions=@eloxiv/source src/bin-node.ts`. */
2
+ import { runMain } from "./runtime/node.js";
3
+ runMain();
4
+ //# sourceMappingURL=bin-node.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bin-node.js","sourceRoot":"","sources":["../src/bin-node.ts"],"names":[],"mappings":"AAAA,6FAA6F;AAC7F,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAA;AAE3C,OAAO,EAAE,CAAA"}
package/dist/bin.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=bin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bin.d.ts","sourceRoot":"","sources":["../src/bin.ts"],"names":[],"mappings":""}
package/dist/bin.js ADDED
@@ -0,0 +1,4 @@
1
+ /** The sidecar entry point, compiled by `build:sidecar` with `bun build --compile`. */
2
+ import { runMain } from "./runtime/bun.js";
3
+ runMain();
4
+ //# sourceMappingURL=bin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bin.js","sourceRoot":"","sources":["../src/bin.ts"],"names":[],"mappings":"AAAA,uFAAuF;AACvF,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAA;AAE1C,OAAO,EAAE,CAAA"}
@@ -0,0 +1,18 @@
1
+ /**
2
+ * The Eloxiv device daemon: pairing with the kernel and custody of the device credential, a loopback relay for
3
+ * local clients and harnesses, local agent harnesses (Claude Code, Codex) on the person's own subscriptions,
4
+ * and a headless runner. Ships as a Bun-compiled sidecar binary (`build:sidecar`); `runtime/bun` and
5
+ * `runtime/node` run it in process.
6
+ */
7
+ export * from "./Client.ts";
8
+ export * from "./Config.ts";
9
+ export * from "./Daemon.ts";
10
+ export * from "./Harness.ts";
11
+ export * from "./Http.ts";
12
+ export * from "./KernelLink.ts";
13
+ export * from "./LocalAuth.ts";
14
+ export * from "./Main.ts";
15
+ export * from "./PersonSession.ts";
16
+ export * from "./Secrets.ts";
17
+ export * from "./State.ts";
18
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA;AAC3B,cAAc,cAAc,CAAA;AAC5B,cAAc,WAAW,CAAA;AACzB,cAAc,iBAAiB,CAAA;AAC/B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,WAAW,CAAA;AACzB,cAAc,oBAAoB,CAAA;AAClC,cAAc,cAAc,CAAA;AAC5B,cAAc,YAAY,CAAA"}
package/dist/index.js ADDED
@@ -0,0 +1,18 @@
1
+ /**
2
+ * The Eloxiv device daemon: pairing with the kernel and custody of the device credential, a loopback relay for
3
+ * local clients and harnesses, local agent harnesses (Claude Code, Codex) on the person's own subscriptions,
4
+ * and a headless runner. Ships as a Bun-compiled sidecar binary (`build:sidecar`); `runtime/bun` and
5
+ * `runtime/node` run it in process.
6
+ */
7
+ export * from "./Client.js";
8
+ export * from "./Config.js";
9
+ export * from "./Daemon.js";
10
+ export * from "./Harness.js";
11
+ export * from "./Http.js";
12
+ export * from "./KernelLink.js";
13
+ export * from "./LocalAuth.js";
14
+ export * from "./Main.js";
15
+ export * from "./PersonSession.js";
16
+ export * from "./Secrets.js";
17
+ export * from "./State.js";
18
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA;AAC3B,cAAc,cAAc,CAAA;AAC5B,cAAc,WAAW,CAAA;AACzB,cAAc,iBAAiB,CAAA;AAC/B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,WAAW,CAAA;AACzB,cAAc,oBAAoB,CAAA;AAClC,cAAc,cAAc,CAAA;AAC5B,cAAc,YAAY,CAAA"}
@@ -0,0 +1,11 @@
1
+ import type { SyncSqliteDatabase } from "@eloxiv/client/storage";
2
+ import { type DaemonConfig } from "../Config.ts";
3
+ import type { Daemon } from "../Daemon.ts";
4
+ /** This runtime's synchronous SQLite (`bun:sqlite`), for LocalClient's replica; loaded only when a `clientApp` is served. */
5
+ export declare const openSqlite: (path: string) => SyncSqliteDatabase;
6
+ export declare const serverLayer: (config: Pick<DaemonConfig, "port"> & Partial<Pick<DaemonConfig, "headless" | "kernelUrl" | "name">>, daemon: Daemon) => import("effect/Layer").Layer<import("effect/http/HttpServer").HttpServer, import("effect/http/HttpServerError").ServeError, never>;
7
+ /** Run the daemon on this runtime: the generic sidecar, or an app's own with a `clientApp` (decision 14). */
8
+ export declare const runMain: (argv?: ReadonlyArray<string>, env?: Record<string, string | undefined>, options?: {
9
+ readonly clientApp?: import("../Client.ts").ClientApp | undefined;
10
+ }) => void;
11
+ //# sourceMappingURL=bun.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bun.d.ts","sourceRoot":"","sources":["../../src/runtime/bun.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAA;AAEhE,OAAO,EAAY,KAAK,YAAY,EAAE,MAAM,cAAc,CAAA;AAC1D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAG1C,6HAA6H;AAC7H,eAAO,MAAM,UAAU,SAAU,MAAM,KAAG,kBAKzC,CAAA;AAED,eAAO,MAAM,WAAW,WACd,IAAI,CAAC,YAAY,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,YAAY,EAAE,UAAU,GAAG,WAAW,GAAG,MAAM,CAAC,CAAC,UAC3F,MAAM,uIAC0F,CAAA;AAE1G,6GAA6G;AAC7G,eAAO,MAAM,OAAO;;UAIlB,CAAA"}
@@ -0,0 +1,20 @@
1
+ /** Run the daemon on Bun: the runtime the sidecar binary is compiled for. */
2
+ // Each module on its own: the package's index also loads the Redis client, which the daemon never uses.
3
+ import * as BunHttpServer from "@effect/platform-bun/BunHttpServer";
4
+ import * as BunRuntime from "@effect/platform-bun/BunRuntime";
5
+ import { createRequire } from "node:module";
6
+ import { HOSTNAME } from "../Config.js";
7
+ import { daemonLayer, mainFor, runnerOf } from "../Main.js";
8
+ /** This runtime's synchronous SQLite (`bun:sqlite`), for LocalClient's replica; loaded only when a `clientApp` is served. */
9
+ export const openSqlite = (path) => {
10
+ const { Database } = createRequire(import.meta.url)("bun:sqlite");
11
+ return new Database(path);
12
+ };
13
+ export const serverLayer = (config, daemon) => daemonLayer(BunHttpServer.layer({ hostname: HOSTNAME, port: config.port }), daemon, runnerOf(config));
14
+ /** Run the daemon on this runtime: the generic sidecar, or an app's own with a `clientApp` (decision 14). */
15
+ export const runMain = mainFor({
16
+ serverLayer: (config, daemon) => serverLayer(config, daemon),
17
+ runMain: (effect, options) => BunRuntime.runMain(effect, options),
18
+ openSqlite,
19
+ });
20
+ //# sourceMappingURL=bun.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bun.js","sourceRoot":"","sources":["../../src/runtime/bun.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAC7E,wGAAwG;AACxG,OAAO,KAAK,aAAa,MAAM,oCAAoC,CAAA;AACnE,OAAO,KAAK,UAAU,MAAM,iCAAiC,CAAA;AAE7D,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAC3C,OAAO,EAAE,QAAQ,EAAqB,MAAM,cAAc,CAAA;AAE1D,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AAE3D,6HAA6H;AAC7H,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,IAAY,EAAsB,EAAE;IAC7D,MAAM,EAAE,QAAQ,EAAE,GAAG,aAAa,CAAC,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,YAAY,CAE/D,CAAA;IACD,OAAO,IAAI,QAAQ,CAAC,IAAI,CAAC,CAAA;AAC3B,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,WAAW,GAAG,CACzB,MAAmG,EACnG,MAAc,EACd,EAAE,CAAC,WAAW,CAAC,aAAa,CAAC,KAAK,CAAC,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,CAAC,EAAE,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAA;AAE1G,6GAA6G;AAC7G,MAAM,CAAC,MAAM,OAAO,GAAG,OAAO,CAAC;IAC7B,WAAW,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,CAAC,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC;IAC5D,OAAO,EAAE,CAAC,MAAM,EAAE,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC;IACjE,UAAU;CACX,CAAC,CAAA"}
@@ -0,0 +1,11 @@
1
+ import type { SyncSqliteDatabase } from "@eloxiv/client/storage";
2
+ import { type DaemonConfig } from "../Config.ts";
3
+ import type { Daemon } from "../Daemon.ts";
4
+ /** This runtime's synchronous SQLite (`node:sqlite`), for LocalClient's replica; loaded only when a `clientApp` is served. */
5
+ export declare const openSqlite: (path: string) => SyncSqliteDatabase;
6
+ export declare const serverLayer: (config: Pick<DaemonConfig, "port"> & Partial<Pick<DaemonConfig, "headless" | "kernelUrl" | "name">>, daemon: Daemon) => import("effect/Layer").Layer<import("effect/http/HttpServer").HttpServer, import("effect/http/HttpServerError").ServeError, never>;
7
+ /** Run the daemon on this runtime: the generic sidecar, or an app's own with a `clientApp` (decision 14). */
8
+ export declare const runMain: (argv?: ReadonlyArray<string>, env?: Record<string, string | undefined>, options?: {
9
+ readonly clientApp?: import("../Client.ts").ClientApp | undefined;
10
+ }) => void;
11
+ //# sourceMappingURL=node.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../../src/runtime/node.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAA;AAEhE,OAAO,EAAY,KAAK,YAAY,EAAE,MAAM,cAAc,CAAA;AAC1D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAG1C,8HAA8H;AAC9H,eAAO,MAAM,UAAU,SAAU,MAAM,KAAG,kBAKzC,CAAA;AAED,eAAO,MAAM,WAAW,WACd,IAAI,CAAC,YAAY,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,YAAY,EAAE,UAAU,GAAG,WAAW,GAAG,MAAM,CAAC,CAAC,UAC3F,MAAM,uIACqG,CAAA;AAErH,6GAA6G;AAC7G,eAAO,MAAM,OAAO;;UAIlB,CAAA"}
@@ -0,0 +1,21 @@
1
+ /** Run the daemon on Node: the fallback runtime, kept working by CI. */
2
+ import { createServer } from "node:http";
3
+ // Each module on its own: the package's index also loads the Redis client, which the daemon never uses.
4
+ import * as NodeHttpServer from "@effect/platform-node/NodeHttpServer";
5
+ import * as NodeRuntime from "@effect/platform-node/NodeRuntime";
6
+ import { createRequire } from "node:module";
7
+ import { HOSTNAME } from "../Config.js";
8
+ import { daemonLayer, mainFor, runnerOf } from "../Main.js";
9
+ /** This runtime's synchronous SQLite (`node:sqlite`), for LocalClient's replica; loaded only when a `clientApp` is served. */
10
+ export const openSqlite = (path) => {
11
+ const { DatabaseSync } = createRequire(import.meta.url)("node:sqlite");
12
+ return new DatabaseSync(path);
13
+ };
14
+ export const serverLayer = (config, daemon) => daemonLayer(NodeHttpServer.layer(createServer, { host: HOSTNAME, port: config.port }), daemon, runnerOf(config));
15
+ /** Run the daemon on this runtime: the generic sidecar, or an app's own with a `clientApp` (decision 14). */
16
+ export const runMain = mainFor({
17
+ serverLayer: (config, daemon) => serverLayer(config, daemon),
18
+ runMain: (effect, options) => NodeRuntime.runMain(effect, options),
19
+ openSqlite,
20
+ });
21
+ //# sourceMappingURL=node.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"node.js","sourceRoot":"","sources":["../../src/runtime/node.ts"],"names":[],"mappings":"AAAA,wEAAwE;AACxE,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AACxC,wGAAwG;AACxG,OAAO,KAAK,cAAc,MAAM,sCAAsC,CAAA;AACtE,OAAO,KAAK,WAAW,MAAM,mCAAmC,CAAA;AAEhE,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAC3C,OAAO,EAAE,QAAQ,EAAqB,MAAM,cAAc,CAAA;AAE1D,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AAE3D,8HAA8H;AAC9H,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,IAAY,EAAsB,EAAE;IAC7D,MAAM,EAAE,YAAY,EAAE,GAAG,aAAa,CAAC,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,aAAa,CAEpE,CAAA;IACD,OAAO,IAAI,YAAY,CAAC,IAAI,CAAC,CAAA;AAC/B,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,WAAW,GAAG,CACzB,MAAmG,EACnG,MAAc,EACd,EAAE,CAAC,WAAW,CAAC,cAAc,CAAC,KAAK,CAAC,YAAY,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,CAAC,EAAE,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAA;AAErH,6GAA6G;AAC7G,MAAM,CAAC,MAAM,OAAO,GAAG,OAAO,CAAC;IAC7B,WAAW,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,CAAC,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC;IAC5D,OAAO,EAAE,CAAC,MAAM,EAAE,OAAO,EAAE,EAAE,CAAC,WAAW,CAAC,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC;IAClE,UAAU;CACX,CAAC,CAAA"}
@@ -0,0 +1,25 @@
1
+ /**
2
+ * For tests and conformance kits: the fake harness binary, which speaks Claude Code's and Codex's stream
3
+ * formats (recorded from real runs, `fixtures/recorded/`) and calls tools through the daemon's MCP relay, so no
4
+ * subscription is needed.
5
+ */
6
+ import type { HarnessKind } from "@eloxiv/contracts";
7
+ import type { Daemon } from "./Daemon.ts";
8
+ import type { HarnessConfig } from "./Harness.ts";
9
+ /** The daemon's server layer on `port` (0: any free port) for this runtime (Bun or Node). */
10
+ export declare const serverLayerFor: (port: number, daemon: Daemon) => Promise<import("effect/Layer").Layer<import("effect/http/HttpServer").HttpServer, import("effect/http/HttpServerError").ServeError, never>>;
11
+ /** `fixtures/fake-harness.mjs`, resolved from both `src` and `dist`. */
12
+ export declare const fakeHarnessPath: string;
13
+ /** `fixtures/fake-acp-agent.mjs`: an Agent Client Protocol agent that runs the same prompt scripts. */
14
+ export declare const fakeAcpAgentPath: string;
15
+ /** The recorded real outputs (`claude-code.jsonl`, `codex.jsonl`). */
16
+ export declare const recordedStreamPath: (kind: HarnessKind) => string;
17
+ /**
18
+ * Harness configs that run the fake harness on this runtime (Bun or Node) for every kind: the CLIs' streams for
19
+ * Claude Code and Codex, the fake ACP agent for OpenCode (not tools-only, as OpenCode is not) and for a configured ACP
20
+ * agent the person declared tools-only.
21
+ */
22
+ export declare const fakeHarnesses: () => Record<HarnessKind, HarnessConfig>;
23
+ /** This runtime's synchronous SQLite opener (`bun:sqlite` or `node:sqlite`), for a daemon serving LocalClient. */
24
+ export declare const runtimeSqlite: () => Promise<typeof import("./runtime/node.ts").openSqlite>;
25
+ //# sourceMappingURL=testing.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"testing.d.ts","sourceRoot":"","sources":["../src/testing.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAEpD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACzC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AAEjD,6FAA6F;AAC7F,eAAO,MAAM,cAAc,SAAgB,MAAM,UAAU,MAAM,gJAIhE,CAAA;AAED,wEAAwE;AACxE,eAAO,MAAM,eAAe,QAA0E,CAAA;AAEtG,uGAAuG;AACvG,eAAO,MAAM,gBAAgB,QAA4E,CAAA;AAEzG,sEAAsE;AACtE,eAAO,MAAM,kBAAkB,SAAU,WAAW,WAC2B,CAAA;AAE/E;;;;GAIG;AACH,eAAO,MAAM,aAAa,QAAO,MAAM,CAAC,WAAW,EAAE,aAAa,CAKhE,CAAA;AAEF,kHAAkH;AAClH,eAAO,MAAM,aAAa,8DAEX,CAAA"}
@@ -0,0 +1,27 @@
1
+ import { fileURLToPath } from "node:url";
2
+ /** The daemon's server layer on `port` (0: any free port) for this runtime (Bun or Node). */
3
+ export const serverLayerFor = async (port, daemon) => {
4
+ const runtime = typeof process.versions["bun"] === "string" ? await import("./runtime/bun.js") : await import("./runtime/node.js");
5
+ return runtime.serverLayer({ port }, daemon);
6
+ };
7
+ /** `fixtures/fake-harness.mjs`, resolved from both `src` and `dist`. */
8
+ export const fakeHarnessPath = fileURLToPath(new URL("../fixtures/fake-harness.mjs", import.meta.url));
9
+ /** `fixtures/fake-acp-agent.mjs`: an Agent Client Protocol agent that runs the same prompt scripts. */
10
+ export const fakeAcpAgentPath = fileURLToPath(new URL("../fixtures/fake-acp-agent.mjs", import.meta.url));
11
+ /** The recorded real outputs (`claude-code.jsonl`, `codex.jsonl`). */
12
+ export const recordedStreamPath = (kind) => fileURLToPath(new URL(`../fixtures/recorded/${kind}.jsonl`, import.meta.url));
13
+ /**
14
+ * Harness configs that run the fake harness on this runtime (Bun or Node) for every kind: the CLIs' streams for
15
+ * Claude Code and Codex, the fake ACP agent for OpenCode (not tools-only, as OpenCode is not) and for a configured ACP
16
+ * agent the person declared tools-only.
17
+ */
18
+ export const fakeHarnesses = () => ({
19
+ "claude-code": { kind: "claude-code", command: [process.execPath, fakeHarnessPath] },
20
+ codex: { kind: "codex", command: [process.execPath, fakeHarnessPath] },
21
+ opencode: { kind: "opencode", command: [process.execPath, fakeAcpAgentPath], protocol: "acp", toolsOnly: false },
22
+ acp: { kind: "acp", command: [process.execPath, fakeAcpAgentPath], protocol: "acp", toolsOnly: true },
23
+ });
24
+ /** This runtime's synchronous SQLite opener (`bun:sqlite` or `node:sqlite`), for a daemon serving LocalClient. */
25
+ export const runtimeSqlite = async () => (typeof process.versions["bun"] === "string" ? await import("./runtime/bun.js") : await import("./runtime/node.js"))
26
+ .openSqlite;
27
+ //# sourceMappingURL=testing.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"testing.js","sourceRoot":"","sources":["../src/testing.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AAIxC,6FAA6F;AAC7F,MAAM,CAAC,MAAM,cAAc,GAAG,KAAK,EAAE,IAAY,EAAE,MAAc,EAAE,EAAE;IACnE,MAAM,OAAO,GACX,OAAO,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,MAAM,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC,MAAM,MAAM,CAAC,mBAAmB,CAAC,CAAA;IACpH,OAAO,OAAO,CAAC,WAAW,CAAC,EAAE,IAAI,EAAE,EAAE,MAAM,CAAC,CAAA;AAC9C,CAAC,CAAA;AAED,wEAAwE;AACxE,MAAM,CAAC,MAAM,eAAe,GAAG,aAAa,CAAC,IAAI,GAAG,CA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