@addai/node 0.4.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 (133) hide show
  1. package/README.md +96 -0
  2. package/dist/agent-auth.d.ts +9 -0
  3. package/dist/agent-auth.js +96 -0
  4. package/dist/attachments.d.ts +20 -0
  5. package/dist/attachments.js +164 -0
  6. package/dist/capabilities.d.ts +64 -0
  7. package/dist/capabilities.js +406 -0
  8. package/dist/claude-binary.d.ts +16 -0
  9. package/dist/claude-binary.js +145 -0
  10. package/dist/claude-config.d.ts +11 -0
  11. package/dist/claude-config.js +144 -0
  12. package/dist/claude-print.d.ts +35 -0
  13. package/dist/claude-print.js +312 -0
  14. package/dist/claude-spawn.d.ts +40 -0
  15. package/dist/claude-spawn.js +220 -0
  16. package/dist/cli.d.ts +2 -0
  17. package/dist/cli.js +137 -0
  18. package/dist/codex-binary.d.ts +4 -0
  19. package/dist/codex-binary.js +70 -0
  20. package/dist/codex-spawn.d.ts +47 -0
  21. package/dist/codex-spawn.js +320 -0
  22. package/dist/command-runner.d.ts +9 -0
  23. package/dist/command-runner.js +592 -0
  24. package/dist/config.d.ts +7 -0
  25. package/dist/config.js +38 -0
  26. package/dist/control-server.d.ts +5 -0
  27. package/dist/control-server.js +292 -0
  28. package/dist/diskguard.d.ts +96 -0
  29. package/dist/diskguard.js +435 -0
  30. package/dist/error-classify.d.ts +20 -0
  31. package/dist/error-classify.js +159 -0
  32. package/dist/events.d.ts +26 -0
  33. package/dist/events.js +97 -0
  34. package/dist/gemini-binary.d.ts +4 -0
  35. package/dist/gemini-binary.js +64 -0
  36. package/dist/gemini-spawn.d.ts +52 -0
  37. package/dist/gemini-spawn.js +369 -0
  38. package/dist/git-identity.d.ts +18 -0
  39. package/dist/git-identity.js +104 -0
  40. package/dist/grok-binary.d.ts +4 -0
  41. package/dist/grok-binary.js +70 -0
  42. package/dist/grok-spawn.d.ts +41 -0
  43. package/dist/grok-spawn.js +495 -0
  44. package/dist/guardrails.d.ts +32 -0
  45. package/dist/guardrails.js +125 -0
  46. package/dist/hang-watchdog.d.ts +17 -0
  47. package/dist/hang-watchdog.js +48 -0
  48. package/dist/harness-registry.d.ts +55 -0
  49. package/dist/harness-registry.js +180 -0
  50. package/dist/heartbeat.d.ts +13 -0
  51. package/dist/heartbeat.js +95 -0
  52. package/dist/index.d.ts +12 -0
  53. package/dist/index.js +440 -0
  54. package/dist/install.d.ts +63 -0
  55. package/dist/install.js +467 -0
  56. package/dist/jsonl-tail.d.ts +20 -0
  57. package/dist/jsonl-tail.js +192 -0
  58. package/dist/kimi-binary.d.ts +4 -0
  59. package/dist/kimi-binary.js +68 -0
  60. package/dist/kimi-spawn.d.ts +47 -0
  61. package/dist/kimi-spawn.js +319 -0
  62. package/dist/lockfile.d.ts +30 -0
  63. package/dist/lockfile.js +169 -0
  64. package/dist/mcp-config.d.ts +23 -0
  65. package/dist/mcp-config.js +133 -0
  66. package/dist/memory-capture.d.ts +20 -0
  67. package/dist/memory-capture.js +45 -0
  68. package/dist/memory-pack.d.ts +34 -0
  69. package/dist/memory-pack.js +171 -0
  70. package/dist/model-filter.d.ts +4 -0
  71. package/dist/model-filter.js +34 -0
  72. package/dist/node-health.d.ts +18 -0
  73. package/dist/node-health.js +74 -0
  74. package/dist/pairing.d.ts +20 -0
  75. package/dist/pairing.js +129 -0
  76. package/dist/paths.d.ts +9 -0
  77. package/dist/paths.js +48 -0
  78. package/dist/precompact-hook.d.ts +27 -0
  79. package/dist/precompact-hook.js +136 -0
  80. package/dist/projects.d.ts +25 -0
  81. package/dist/projects.js +255 -0
  82. package/dist/prompt-keystrokes.d.ts +3 -0
  83. package/dist/prompt-keystrokes.js +56 -0
  84. package/dist/pty-helper.d.ts +26 -0
  85. package/dist/pty-helper.js +156 -0
  86. package/dist/request-pump.d.ts +12 -0
  87. package/dist/request-pump.js +249 -0
  88. package/dist/run-retry.d.ts +28 -0
  89. package/dist/run-retry.js +81 -0
  90. package/dist/self-update.d.ts +75 -0
  91. package/dist/self-update.js +192 -0
  92. package/dist/session-runner.d.ts +130 -0
  93. package/dist/session-runner.js +2271 -0
  94. package/dist/sleep-detector.d.ts +11 -0
  95. package/dist/sleep-detector.js +32 -0
  96. package/dist/state-migrate.d.ts +8 -0
  97. package/dist/state-migrate.js +91 -0
  98. package/dist/store.d.ts +5 -0
  99. package/dist/store.js +82 -0
  100. package/dist/supabase-client.d.ts +15 -0
  101. package/dist/supabase-client.js +119 -0
  102. package/dist/time-context.d.ts +10 -0
  103. package/dist/time-context.js +71 -0
  104. package/dist/tokens.d.ts +4 -0
  105. package/dist/tokens.js +33 -0
  106. package/dist/tui/app.d.ts +35 -0
  107. package/dist/tui/app.js +82 -0
  108. package/dist/tui/console-capture.d.ts +13 -0
  109. package/dist/tui/console-capture.js +62 -0
  110. package/dist/tui/dashboard.d.ts +42 -0
  111. package/dist/tui/dashboard.js +205 -0
  112. package/dist/tui/data.d.ts +57 -0
  113. package/dist/tui/data.js +62 -0
  114. package/dist/tui/harnesses.d.ts +16 -0
  115. package/dist/tui/harnesses.js +354 -0
  116. package/dist/tui/render.d.ts +21 -0
  117. package/dist/tui/render.js +116 -0
  118. package/dist/tui/requests.d.ts +18 -0
  119. package/dist/tui/requests.js +127 -0
  120. package/dist/tui/run.d.ts +13 -0
  121. package/dist/tui/run.js +178 -0
  122. package/dist/tui/transcript.d.ts +39 -0
  123. package/dist/tui/transcript.js +234 -0
  124. package/dist/tui.d.ts +1 -0
  125. package/dist/tui.js +314 -0
  126. package/dist/types.d.ts +65 -0
  127. package/dist/types.js +3 -0
  128. package/dist/win.d.ts +67 -0
  129. package/dist/win.js +317 -0
  130. package/package.json +60 -0
  131. package/scripts/fix-pty-helper.js +28 -0
  132. package/scripts/precompact-capture.js +292 -0
  133. package/scripts/smoke-test.sh +74 -0
package/dist/tui.js ADDED
@@ -0,0 +1,314 @@
1
+ "use strict";
2
+ // `entities-runtime harnesses` — interactive harness manager in the
3
+ // Claude Code terminal idiom: alt-screen, rounded panels, dim chrome,
4
+ // ❯ selection, braille spinner, ⏺ status dots. Hand-rolled ANSI — the
5
+ // daemon deliberately has no TUI framework dependency.
6
+ //
7
+ // Local actions hand the real terminal to the harness CLI itself (there
8
+ // is nothing to bridge when you're already at the machine): install
9
+ // streams npm output into a panel; login leaves the alt screen, runs the
10
+ // CLI's own login flow attached to your TTY, then re-probes on return.
11
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
12
+ if (k2 === undefined) k2 = k;
13
+ var desc = Object.getOwnPropertyDescriptor(m, k);
14
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
15
+ desc = { enumerable: true, get: function() { return m[k]; } };
16
+ }
17
+ Object.defineProperty(o, k2, desc);
18
+ }) : (function(o, m, k, k2) {
19
+ if (k2 === undefined) k2 = k;
20
+ o[k2] = m[k];
21
+ }));
22
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
23
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
24
+ }) : function(o, v) {
25
+ o["default"] = v;
26
+ });
27
+ var __importStar = (this && this.__importStar) || (function () {
28
+ var ownKeys = function(o) {
29
+ ownKeys = Object.getOwnPropertyNames || function (o) {
30
+ var ar = [];
31
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
32
+ return ar;
33
+ };
34
+ return ownKeys(o);
35
+ };
36
+ return function (mod) {
37
+ if (mod && mod.__esModule) return mod;
38
+ var result = {};
39
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
40
+ __setModuleDefault(result, mod);
41
+ return result;
42
+ };
43
+ })();
44
+ Object.defineProperty(exports, "__esModule", { value: true });
45
+ exports.runHarnessesTui = runHarnessesTui;
46
+ const child_process_1 = require("child_process");
47
+ const readline = __importStar(require("readline"));
48
+ const capabilities_1 = require("./capabilities");
49
+ const win_1 = require("./win");
50
+ const fs = __importStar(require("fs"));
51
+ const os = __importStar(require("os"));
52
+ const path = __importStar(require("path"));
53
+ const harness_registry_1 = require("./harness-registry");
54
+ /* ── ansi helpers ────────────────────────────────────────────────────── */
55
+ const ESC = '\x1b[';
56
+ const dim = (s) => `${ESC}2m${s}${ESC}22m`;
57
+ const bold = (s) => `${ESC}1m${s}${ESC}22m`;
58
+ const fg = (n, s) => `${ESC}38;5;${n}m${s}${ESC}39m`;
59
+ const green = (s) => fg(114, s);
60
+ const yellow = (s) => fg(179, s);
61
+ const grey = (s) => fg(244, s);
62
+ const cyan = (s) => fg(80, s);
63
+ const altOn = () => process.stdout.write(`${ESC}?1049h${ESC}?25l`);
64
+ const altOff = () => process.stdout.write(`${ESC}?1049l${ESC}?25h`);
65
+ const home = () => process.stdout.write(`${ESC}H${ESC}2J`);
66
+ const SPIN = ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'];
67
+ const width = () => Math.min(process.stdout.columns || 100, 110);
68
+ function panel(title, lines) {
69
+ const w = width() - 2;
70
+ const strip = (s) => s.replace(/\x1b\[[0-9;]*m/g, '');
71
+ const top = `${dim('╭─')} ${bold(title)} ${dim('─'.repeat(Math.max(1, w - strip(title).length - 4)) + '╮')}`;
72
+ const body = lines.map(l => {
73
+ const pad = Math.max(0, w - 2 - strip(l).length);
74
+ return `${dim('│')} ${l}${' '.repeat(pad)} ${dim('│')}`;
75
+ });
76
+ const bottom = dim(`╰${'─'.repeat(w)}╯`);
77
+ return [top, ...body, bottom].join('\n');
78
+ }
79
+ function dot(p) {
80
+ if (!p?.available)
81
+ return grey('⏺');
82
+ return p.authed ? green('⏺') : yellow('⏺');
83
+ }
84
+ function actionFor(id, p) {
85
+ if (!p?.available)
86
+ return (0, harness_registry_1.isInstallable)(id) ? 'install' : 'how to install';
87
+ if (!p.authed)
88
+ return 'log in';
89
+ return harness_registry_1.HARNESSES[id].logout ? 'log out' : 'ok';
90
+ }
91
+ function row(id, p, selected) {
92
+ const spec = harness_registry_1.HARNESSES[id];
93
+ const name = spec.label.padEnd(13);
94
+ const ver = (p?.version ? `v${p.version}` : '—').padEnd(12).slice(0, 12);
95
+ const who = (p?.authed
96
+ ? `${p.account ?? p.accountKind ?? 'logged in'}${p.plan ? ` · ${p.plan}` : ''}`
97
+ : p?.available ? 'not logged in' : 'not installed').padEnd(28).slice(0, 28);
98
+ const models = `${p?.models?.length ?? 0} models`.padEnd(10);
99
+ const efforts = spec.efforts.length ? spec.efforts.join('/') : '—';
100
+ const act = actionFor(id, p);
101
+ const actTxt = act === 'ok' ? green('✓') : act === 'log out' ? dim('↵ log out') : cyan(`↵ ${act}`);
102
+ const line = `${dot(p)} ${name} ${dim(ver)} ${who} ${dim(models)} ${dim(efforts.padEnd(26).slice(0, 26))} ${actTxt}`;
103
+ return selected ? `${cyan('❯')} ${bold(line)}` : ` ${line}`;
104
+ }
105
+ function render(st) {
106
+ home();
107
+ const lines = [];
108
+ if (!st.caps) {
109
+ lines.push(`${cyan(SPIN[st.spin % SPIN.length])} probing installed harnesses…`);
110
+ }
111
+ else {
112
+ lines.push(dim(' harness version account models efforts'));
113
+ harness_registry_1.HARNESS_IDS.forEach((id, i) => lines.push(row(id, st.caps[id], i === st.sel)));
114
+ }
115
+ if (st.busy)
116
+ lines.push('', `${cyan(SPIN[st.spin % SPIN.length])} ${st.busy}`);
117
+ if (st.log.length) {
118
+ lines.push('');
119
+ st.log.slice(-8).forEach(l => lines.push(dim(l.slice(0, width() - 8))));
120
+ }
121
+ if (st.note)
122
+ lines.push('', st.note);
123
+ process.stdout.write(panel('Harnesses', lines) + '\n');
124
+ process.stdout.write(dim(' ↑/↓ move · ↵ install / log in · r refresh · q quit\n'));
125
+ }
126
+ /* ── actions ─────────────────────────────────────────────────────────── */
127
+ async function installSelected(st, id, redraw) {
128
+ const spec = harness_registry_1.HARNESSES[id];
129
+ if (!(0, harness_registry_1.isInstallable)(id)) {
130
+ st.note = yellow(`${spec.label}: ${spec.login.instructions}`);
131
+ return;
132
+ }
133
+ st.busy = `installing ${spec.label} (npm i -g ${spec.npmPackage})`;
134
+ st.log = [];
135
+ redraw();
136
+ const inv = (0, win_1.resolveCliInvocation)('npm', ['install', '-g', spec.npmPackage]);
137
+ await new Promise(resolve => {
138
+ const child = (0, child_process_1.spawn)(inv.file, inv.args, { env: process.env });
139
+ const onChunk = (b) => {
140
+ st.log.push(...b.toString('utf8').split('\n').filter(Boolean));
141
+ redraw();
142
+ };
143
+ child.stdout?.on('data', onChunk);
144
+ child.stderr?.on('data', onChunk);
145
+ child.on('exit', code => {
146
+ st.busy = null;
147
+ st.note = code === 0 ? green(`✓ ${spec.label} installed`) : fg(203, `✗ npm exited ${code}`);
148
+ resolve();
149
+ });
150
+ child.on('error', err => { st.busy = null; st.note = fg(203, `✗ ${err.message}`); resolve(); });
151
+ });
152
+ }
153
+ function logoutSelected(id) {
154
+ const spec = harness_registry_1.HARNESSES[id];
155
+ if (!spec.logout)
156
+ return `${spec.label} can only be logged out on the device`;
157
+ if (spec.logout.cmd) {
158
+ const bin = spec.findBinary();
159
+ if (!bin)
160
+ return `${spec.label} is not installed`;
161
+ const inv = (0, win_1.resolveCliInvocation)(bin, spec.logout.cmd);
162
+ const res = (0, child_process_1.spawnSync)(inv.file, inv.args, { stdio: 'ignore', env: process.env, timeout: 60_000 });
163
+ if (res.status !== 0)
164
+ return `logout exited with code ${res.status ?? '?'}`;
165
+ }
166
+ for (const rel of spec.logout.files ?? []) {
167
+ try {
168
+ fs.rmSync(path.join(os.homedir(), rel), { force: true });
169
+ }
170
+ catch { /* best effort */ }
171
+ }
172
+ for (const [rel, varName] of spec.logout.envStrip ?? []) {
173
+ const envPath = path.join(os.homedir(), rel);
174
+ try {
175
+ const body = fs.readFileSync(envPath, 'utf8');
176
+ fs.writeFileSync(envPath, body.split('\n').filter(l => !l.startsWith(`${varName}=`)).join('\n'), { mode: 0o600 });
177
+ }
178
+ catch { /* nothing to strip */ }
179
+ }
180
+ return null;
181
+ }
182
+ function loginSelected(id) {
183
+ const spec = harness_registry_1.HARNESSES[id];
184
+ const bin = spec.findBinary();
185
+ if (!bin)
186
+ return `${spec.label} is not installed`;
187
+ // Hand the real terminal to the CLI — leave the alt screen first.
188
+ altOff();
189
+ console.log(cyan(`\n— ${spec.label} login —`));
190
+ console.log(dim(spec.login.instructions) + '\n');
191
+ const args = spec.login.strategy === 'pty-url-code' ? (spec.login.loginArgs ?? []) : [];
192
+ const inv = (0, win_1.resolveCliInvocation)(bin, args);
193
+ const res = (0, child_process_1.spawnSync)(inv.file, inv.args, { stdio: 'inherit', env: process.env });
194
+ altOn();
195
+ return res.status === 0 ? null : `login exited with code ${res.status ?? '?'}`;
196
+ }
197
+ /* ── entry ───────────────────────────────────────────────────────────── */
198
+ async function plainStatus() {
199
+ const caps = await (0, capabilities_1.probeCapabilities)();
200
+ for (const id of harness_registry_1.HARNESS_IDS) {
201
+ const p = caps[id];
202
+ const state = !p?.available ? 'not installed' : p.authed ? `authed (${p.account ?? p.accountKind ?? '?'})` : 'not logged in';
203
+ console.log(`${id.padEnd(8)} ${(p?.version ?? '—').padEnd(12)} ${state}`);
204
+ }
205
+ }
206
+ async function runHarnessesTui() {
207
+ if (!process.stdout.isTTY || !process.stdin.isTTY) {
208
+ await plainStatus();
209
+ return;
210
+ }
211
+ const st = { caps: null, sel: 0, spin: 0, busy: null, log: [], note: null, confirmLogout: null };
212
+ const redraw = () => render(st);
213
+ altOn();
214
+ readline.emitKeypressEvents(process.stdin);
215
+ process.stdin.setRawMode(true);
216
+ process.stdin.resume();
217
+ const spinTimer = setInterval(() => { st.spin++; if (st.busy || !st.caps)
218
+ redraw(); }, 90);
219
+ const quit = () => {
220
+ clearInterval(spinTimer);
221
+ process.stdin.setRawMode(false);
222
+ process.stdin.pause();
223
+ altOff();
224
+ process.exit(0);
225
+ };
226
+ const reprobe = async () => {
227
+ st.caps = null;
228
+ redraw();
229
+ st.caps = await (0, capabilities_1.probeCapabilities)();
230
+ redraw();
231
+ };
232
+ let acting = false;
233
+ process.stdin.on('keypress', (_str, key) => {
234
+ void (async () => {
235
+ if (!key || acting)
236
+ return;
237
+ if (key.name === 'q' || (key.ctrl && key.name === 'c')) {
238
+ quit();
239
+ return;
240
+ }
241
+ if (!st.caps)
242
+ return;
243
+ if (st.confirmLogout) {
244
+ const target = st.confirmLogout;
245
+ st.confirmLogout = null;
246
+ if (key.name === 'y') {
247
+ acting = true;
248
+ try {
249
+ const err = logoutSelected(target);
250
+ st.note = err ? fg(203, `✗ ${err}`) : green(`✓ ${harness_registry_1.HARNESSES[target].label} logged out`);
251
+ await reprobe();
252
+ }
253
+ finally {
254
+ acting = false;
255
+ }
256
+ }
257
+ else {
258
+ st.note = dim('logout cancelled');
259
+ redraw();
260
+ }
261
+ return;
262
+ }
263
+ if (key.name === 'up' || key.name === 'k') {
264
+ st.sel = (st.sel + harness_registry_1.HARNESS_IDS.length - 1) % harness_registry_1.HARNESS_IDS.length;
265
+ redraw();
266
+ return;
267
+ }
268
+ if (key.name === 'down' || key.name === 'j') {
269
+ st.sel = (st.sel + 1) % harness_registry_1.HARNESS_IDS.length;
270
+ redraw();
271
+ return;
272
+ }
273
+ if (key.name === 'r') {
274
+ await reprobe();
275
+ return;
276
+ }
277
+ if (key.name !== 'return')
278
+ return;
279
+ const id = harness_registry_1.HARNESS_IDS[st.sel];
280
+ const p = st.caps[id];
281
+ acting = true;
282
+ try {
283
+ if (!p?.available) {
284
+ await installSelected(st, id, redraw);
285
+ await reprobe();
286
+ }
287
+ else if (!p.authed) {
288
+ const err = loginSelected(id);
289
+ st.note = err ? fg(203, `✗ ${err}`) : green('✓ login flow finished — verifying…');
290
+ await reprobe();
291
+ const now = st.caps?.[id];
292
+ if (now?.authed)
293
+ st.note = green(`✓ ${harness_registry_1.HARNESSES[id].label} logged in as ${now.account ?? now.accountKind ?? '?'}`);
294
+ else if (!err)
295
+ st.note = yellow(`${harness_registry_1.HARNESSES[id].label} still reports unauthenticated`);
296
+ redraw();
297
+ }
298
+ else if (harness_registry_1.HARNESSES[id].logout) {
299
+ st.confirmLogout = id;
300
+ st.note = yellow(`log out of ${harness_registry_1.HARNESSES[id].label}? press y to confirm`);
301
+ redraw();
302
+ }
303
+ else {
304
+ st.note = green(`${harness_registry_1.HARNESSES[id].label} is installed and logged in.`);
305
+ redraw();
306
+ }
307
+ }
308
+ finally {
309
+ acting = false;
310
+ }
311
+ })();
312
+ });
313
+ await reprobe();
314
+ }
@@ -0,0 +1,65 @@
1
+ export type RuntimePermissionMode = 'default' | 'plan' | 'dontAsk' | 'acceptEdits' | 'auto' | 'bypassPermissions';
2
+ export type RuntimeEffortLevel = 'low' | 'medium' | 'high' | 'xhigh' | 'max';
3
+ export type RuntimeAgent = 'claude' | 'claude-tui' | 'codex' | 'kimi' | 'gemini' | 'grok' | 'claude-bypass';
4
+ export type RuntimeAgentMode = 'tui' | 'print';
5
+ /** Normalized event emitted by a running Claude / Codex session. */
6
+ export type RuntimeEvent = {
7
+ type: 'ready';
8
+ } | {
9
+ type: 'assistant_text';
10
+ delta: string;
11
+ } | {
12
+ type: 'thinking';
13
+ delta: string;
14
+ } | {
15
+ type: 'tool_use';
16
+ id: string;
17
+ name: string;
18
+ input: unknown;
19
+ } | {
20
+ type: 'tool_result';
21
+ id: string;
22
+ content: unknown;
23
+ isError: boolean;
24
+ } | {
25
+ type: 'turn_complete';
26
+ usage?: Record<string, unknown>;
27
+ stopReason?: string;
28
+ } | {
29
+ type: 'error';
30
+ code: string;
31
+ message: string;
32
+ } | {
33
+ type: 'session_end';
34
+ reason: 'client_close' | 'claude_exit' | 'endpoint_deleted' | 'timeout';
35
+ exitCode?: number;
36
+ } | {
37
+ type: `claude:${string}`;
38
+ raw: Record<string, unknown>;
39
+ } | {
40
+ type: `kimi:${string}`;
41
+ raw: Record<string, unknown>;
42
+ } | {
43
+ type: `gemini:${string}`;
44
+ raw: Record<string, unknown>;
45
+ } | {
46
+ type: `grok:${string}`;
47
+ raw: Record<string, unknown>;
48
+ };
49
+ /** Local in-memory bookkeeping for a session this daemon is currently running. */
50
+ export interface RuntimeActiveSession {
51
+ id: string;
52
+ requestId: string;
53
+ startedAt: number;
54
+ promptsSent: number;
55
+ bytesIn: number;
56
+ bytesOut: number;
57
+ }
58
+ /** Daemon pairing state persisted under ~/.ainode/state.json. */
59
+ export interface RuntimePairingState {
60
+ runtimeId: string;
61
+ daemonToken: string;
62
+ supabaseUrl: string;
63
+ supabaseAnonKey: string;
64
+ pairedAt: number;
65
+ }
package/dist/types.js ADDED
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ // Types shared by all runtime modules.
3
+ Object.defineProperty(exports, "__esModule", { value: true });
package/dist/win.d.ts ADDED
@@ -0,0 +1,67 @@
1
+ export declare const IS_WINDOWS: boolean;
2
+ /** `where <name>` on win32. Returns the best hit (.exe > .cmd > .bat) or
3
+ * null. Extensionless hits (git-bash shims) are skipped — CreateProcess
4
+ * can't run them. */
5
+ export declare function whereLookup(name: string): string | null;
6
+ /** Standard npm global-shim locations for a CLI on win32. */
7
+ export declare function npmShimCandidates(name: string): string[];
8
+ /**
9
+ * Cross-platform CLI discovery: PATH probe first, then platform-specific
10
+ * candidate paths. Returns null when not installed — callers surface an
11
+ * install hint. NOT cached here; each finder module keeps its own cache.
12
+ */
13
+ export declare function findCliBinary(name: string, opts?: {
14
+ posixCandidates?: string[];
15
+ win32Candidates?: string[];
16
+ }): string | null;
17
+ export interface CliInvocation {
18
+ file: string;
19
+ args: string[];
20
+ }
21
+ /**
22
+ * Turn a (binary, args) pair into something Node can actually spawn on this
23
+ * platform. POSIX: identity. win32: `.cmd`/`.bat` npm shims are resolved to
24
+ * the node script they wrap and run via process.execPath — never through
25
+ * cmd.exe, because args carry raw prompt text. `.exe` passes through.
26
+ *
27
+ * Throws with a descriptive message when a shim can't be resolved — callers
28
+ * already route spawn errors into a clean per-request failure.
29
+ */
30
+ export declare function resolveCliInvocation(bin: string, args: string[]): CliInvocation;
31
+ /**
32
+ * Kill an agent child process. POSIX: SIGINT (graceful — CLIs flush and
33
+ * exit). win32: `taskkill /T /F` — Node's SIGINT emulation is a hard
34
+ * TerminateProcess on the one process anyway, and /T also reaps the MCP
35
+ * server grandchildren that would otherwise be orphaned.
36
+ */
37
+ export declare function killProcessTree(proc: {
38
+ pid?: number | undefined;
39
+ kill(signal?: NodeJS.Signals): boolean | void;
40
+ }): void;
41
+ /**
42
+ * Rewrite a stdio MCP server command for the platform. On native Windows,
43
+ * registry commands like `npx` are npm .cmd shims that the agent CLIs
44
+ * (claude.exe, codex, grok…) can't CreateProcess directly — the documented
45
+ * fix is a `cmd /c` wrapper. MCP commands + args come from the trusted
46
+ * registry (not chat text), so cmd.exe here is acceptable. `.exe` commands
47
+ * pass through untouched. POSIX: identity.
48
+ */
49
+ export declare function wrapMcpCommandForPlatform(command: string, args: string[]): {
50
+ command: string;
51
+ args: string[];
52
+ };
53
+ /**
54
+ * renameSync with win32 EPERM/EBUSY retries (antivirus / another process
55
+ * briefly holding the target open), falling back to copy+unlink. POSIX
56
+ * behaves exactly like fs.renameSync.
57
+ */
58
+ export declare function safeRenameSync(from: string, to: string): void;
59
+ /**
60
+ * Bridge a host file into a sandbox dir: symlink where possible, copy where
61
+ * not (win32 file symlinks need admin/Developer Mode). maxCopyBytes guards
62
+ * against duplicating something huge when we fall back to copying.
63
+ */
64
+ export declare function linkOrCopyFile(real: string, dest: string, maxCopyBytes?: number): void;
65
+ /** Directory link that works unprivileged on win32 ('junction' is ignored
66
+ * by Node on POSIX, where a normal symlink is created). */
67
+ export declare function linkDir(real: string, dest: string): void;