@addai/node 0.8.2 → 0.10.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.
- package/README.md +96 -96
- package/dist/autostart-mac.js +30 -30
- package/dist/autostart-win.js +50 -50
- package/dist/cli.js +32 -34
- package/dist/config.d.ts +1 -0
- package/dist/config.js +18 -3
- package/dist/heartbeat.js +46 -0
- package/dist/index.d.ts +6 -2
- package/dist/index.js +7 -7
- package/dist/open-browser.d.ts +1 -0
- package/dist/open-browser.js +42 -0
- package/dist/pair-destination.d.ts +20 -0
- package/dist/pair-destination.js +59 -0
- package/dist/pairing.d.ts +4 -2
- package/dist/pairing.js +64 -16
- package/dist/request-pump.d.ts +1 -0
- package/dist/request-pump.js +9 -0
- package/dist/tui/dashboard.d.ts +2 -0
- package/dist/tui/dashboard.js +60 -2
- package/dist/tui/pair.d.ts +33 -0
- package/dist/tui/pair.js +178 -0
- package/dist/unpair.d.ts +20 -0
- package/dist/unpair.js +71 -0
- package/package.json +60 -60
- package/scripts/fix-pty-helper.js +28 -28
- package/scripts/precompact-capture.js +292 -292
- package/scripts/probe-tui.mjs +122 -122
- package/scripts/smoke-test.sh +74 -74
package/dist/unpair.js
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Disconnecting a node from +Ai.
|
|
3
|
+
//
|
|
4
|
+
// Shared by `ainode unpair` and the console's disconnect key, because the two
|
|
5
|
+
// must not drift: this is the one action that takes work away from people, and
|
|
6
|
+
// a version of it that forgets to cancel in-flight runs would leave whoever
|
|
7
|
+
// was waiting on them waiting forever.
|
|
8
|
+
//
|
|
9
|
+
// The server soft-disables rather than deletes: the runtime row, its history
|
|
10
|
+
// and its chats all survive, the token is scrubbed, and the status becomes
|
|
11
|
+
// 'unpaired'. Reconnect on the AiNodes page mints a fresh code and the same
|
|
12
|
+
// machine comes back as itself. That is worth saying out loud in the prompt —
|
|
13
|
+
// someone who believes this is permanent will not press it when they should.
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.describeDisconnect = describeDisconnect;
|
|
16
|
+
exports.summariseDisconnect = summariseDisconnect;
|
|
17
|
+
exports.disconnectNode = disconnectNode;
|
|
18
|
+
const supabase_client_1 = require("./supabase-client");
|
|
19
|
+
const store_1 = require("./store");
|
|
20
|
+
const plural = (n, word) => `${n} ${word}${n === 1 ? '' : 's'}`;
|
|
21
|
+
/** The question to ask before doing it. */
|
|
22
|
+
function describeDisconnect(inflight) {
|
|
23
|
+
const cost = inflight > 0
|
|
24
|
+
? `This cancels ${plural(inflight, 'run')} still in flight. `
|
|
25
|
+
: '';
|
|
26
|
+
return `${cost}The node keeps its history and can reconnect later.`;
|
|
27
|
+
}
|
|
28
|
+
/** What to say once it is done. */
|
|
29
|
+
function summariseDisconnect(r) {
|
|
30
|
+
if (!r.ok)
|
|
31
|
+
return `Could not disconnect: ${r.error ?? 'unknown error'}`;
|
|
32
|
+
if (r.serverFailed) {
|
|
33
|
+
// Honest about the half that worked: this machine has forgotten its
|
|
34
|
+
// pairing, but +Ai still lists the node as paired until it is removed
|
|
35
|
+
// there. Saying only "disconnected" leaves that to be discovered — and
|
|
36
|
+
// saying it without the reason leaves nobody able to act on it, which is
|
|
37
|
+
// how a transient 4s RPC timeout and a revoked grant look identical.
|
|
38
|
+
const why = r.error ? ` (${r.error})` : '';
|
|
39
|
+
return `Disconnected on this machine, but +Ai could not be told${why}. Remove the node there too.`;
|
|
40
|
+
}
|
|
41
|
+
const tail = r.cancelled > 0 ? ` ${plural(r.cancelled, 'run')} cancelled.` : '';
|
|
42
|
+
return `Disconnected from +Ai.${tail}`;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Tell +Ai, then forget the pairing locally.
|
|
46
|
+
*
|
|
47
|
+
* Local cleanup happens even when the server call fails. A node whose token
|
|
48
|
+
* the user has decided to abandon should not keep using it because the network
|
|
49
|
+
* was down at the wrong moment — and the alternative, refusing to disconnect,
|
|
50
|
+
* strands them on a machine they may be trying to hand back.
|
|
51
|
+
*/
|
|
52
|
+
async function disconnectNode() {
|
|
53
|
+
if (!(0, store_1.isPaired)())
|
|
54
|
+
return { ok: false, cancelled: 0, error: 'this node is not paired' };
|
|
55
|
+
const token = (0, store_1.readPairing)()?.daemonToken;
|
|
56
|
+
if (!token)
|
|
57
|
+
return { ok: false, cancelled: 0, error: 'this node is not paired' };
|
|
58
|
+
let cancelled = 0;
|
|
59
|
+
let serverFailed = false;
|
|
60
|
+
let serverError;
|
|
61
|
+
try {
|
|
62
|
+
const r = await (0, supabase_client_1.rpc)('runtime_self_unpair', { p_token: token });
|
|
63
|
+
cancelled = r?.cancelled_requests ?? 0;
|
|
64
|
+
}
|
|
65
|
+
catch (err) {
|
|
66
|
+
serverFailed = true;
|
|
67
|
+
serverError = err?.message || String(err);
|
|
68
|
+
}
|
|
69
|
+
(0, store_1.clearPairing)();
|
|
70
|
+
return { ok: true, cancelled, serverFailed, error: serverError };
|
|
71
|
+
}
|
package/package.json
CHANGED
|
@@ -1,60 +1,60 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@addai/node",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "Daemon that pairs a machine with your +Ai account and runs Claude / Codex / Kimi / Gemini agents on its behalf. Reachable via Supabase from Vault, Entity Studio, or any other +Ai surface.",
|
|
5
|
-
"license": "MIT",
|
|
6
|
-
"keywords": [
|
|
7
|
-
"addai",
|
|
8
|
-
"entity-studio",
|
|
9
|
-
"claude",
|
|
10
|
-
"codex",
|
|
11
|
-
"kimi",
|
|
12
|
-
"gemini",
|
|
13
|
-
"agent",
|
|
14
|
-
"daemon",
|
|
15
|
-
"supabase",
|
|
16
|
-
"mcp"
|
|
17
|
-
],
|
|
18
|
-
"repository": {
|
|
19
|
-
"type": "git",
|
|
20
|
-
"url": "git+https://github.com/just-AddAi/addai-entity-runtime.git"
|
|
21
|
-
},
|
|
22
|
-
"homepage": "https://github.com/just-AddAi/addai-entity-runtime#readme",
|
|
23
|
-
"bugs": {
|
|
24
|
-
"url": "https://github.com/just-AddAi/addai-entity-runtime/issues"
|
|
25
|
-
},
|
|
26
|
-
"type": "commonjs",
|
|
27
|
-
"main": "dist/index.js",
|
|
28
|
-
"bin": {
|
|
29
|
-
"ainode": "dist/cli.js"
|
|
30
|
-
},
|
|
31
|
-
"publishConfig": {
|
|
32
|
-
"access": "public"
|
|
33
|
-
},
|
|
34
|
-
"files": [
|
|
35
|
-
"dist",
|
|
36
|
-
"scripts",
|
|
37
|
-
"README.md"
|
|
38
|
-
],
|
|
39
|
-
"scripts": {
|
|
40
|
-
"build": "tsc -p tsconfig.json",
|
|
41
|
-
"start": "node dist/cli.js",
|
|
42
|
-
"dev": "tsc -p tsconfig.json && node dist/cli.js",
|
|
43
|
-
"test": "npm run build && node --test test/*.test.mjs",
|
|
44
|
-
"clean": "node -e \"fs.rmSync('dist',{recursive:true,force:true})\"",
|
|
45
|
-
"postinstall": "node scripts/fix-pty-helper.js",
|
|
46
|
-
"prepublishOnly": "npm run build"
|
|
47
|
-
},
|
|
48
|
-
"engines": {
|
|
49
|
-
"node": ">=18"
|
|
50
|
-
},
|
|
51
|
-
"dependencies": {
|
|
52
|
-
"node-pty": "^1.1.0",
|
|
53
|
-
"ws": "^8.21.1"
|
|
54
|
-
},
|
|
55
|
-
"devDependencies": {
|
|
56
|
-
"@types/node": "^20.0.0",
|
|
57
|
-
"@types/ws": "^8.18.1",
|
|
58
|
-
"typescript": "^5.6.0"
|
|
59
|
-
}
|
|
60
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@addai/node",
|
|
3
|
+
"version": "0.10.0",
|
|
4
|
+
"description": "Daemon that pairs a machine with your +Ai account and runs Claude / Codex / Kimi / Gemini agents on its behalf. Reachable via Supabase from Vault, Entity Studio, or any other +Ai surface.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"keywords": [
|
|
7
|
+
"addai",
|
|
8
|
+
"entity-studio",
|
|
9
|
+
"claude",
|
|
10
|
+
"codex",
|
|
11
|
+
"kimi",
|
|
12
|
+
"gemini",
|
|
13
|
+
"agent",
|
|
14
|
+
"daemon",
|
|
15
|
+
"supabase",
|
|
16
|
+
"mcp"
|
|
17
|
+
],
|
|
18
|
+
"repository": {
|
|
19
|
+
"type": "git",
|
|
20
|
+
"url": "git+https://github.com/just-AddAi/addai-entity-runtime.git"
|
|
21
|
+
},
|
|
22
|
+
"homepage": "https://github.com/just-AddAi/addai-entity-runtime#readme",
|
|
23
|
+
"bugs": {
|
|
24
|
+
"url": "https://github.com/just-AddAi/addai-entity-runtime/issues"
|
|
25
|
+
},
|
|
26
|
+
"type": "commonjs",
|
|
27
|
+
"main": "dist/index.js",
|
|
28
|
+
"bin": {
|
|
29
|
+
"ainode": "dist/cli.js"
|
|
30
|
+
},
|
|
31
|
+
"publishConfig": {
|
|
32
|
+
"access": "public"
|
|
33
|
+
},
|
|
34
|
+
"files": [
|
|
35
|
+
"dist",
|
|
36
|
+
"scripts",
|
|
37
|
+
"README.md"
|
|
38
|
+
],
|
|
39
|
+
"scripts": {
|
|
40
|
+
"build": "tsc -p tsconfig.json",
|
|
41
|
+
"start": "node dist/cli.js",
|
|
42
|
+
"dev": "tsc -p tsconfig.json && node dist/cli.js",
|
|
43
|
+
"test": "npm run build && node --test test/*.test.mjs",
|
|
44
|
+
"clean": "node -e \"fs.rmSync('dist',{recursive:true,force:true})\"",
|
|
45
|
+
"postinstall": "node scripts/fix-pty-helper.js",
|
|
46
|
+
"prepublishOnly": "npm run build"
|
|
47
|
+
},
|
|
48
|
+
"engines": {
|
|
49
|
+
"node": ">=18"
|
|
50
|
+
},
|
|
51
|
+
"dependencies": {
|
|
52
|
+
"node-pty": "^1.1.0",
|
|
53
|
+
"ws": "^8.21.1"
|
|
54
|
+
},
|
|
55
|
+
"devDependencies": {
|
|
56
|
+
"@types/node": "^20.0.0",
|
|
57
|
+
"@types/ws": "^8.18.1",
|
|
58
|
+
"typescript": "^5.6.0"
|
|
59
|
+
}
|
|
60
|
+
}
|
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
// node-pty ships POSIX prebuilds whose `spawn-helper` binary can lose its
|
|
3
|
-
// executable bit when the npm tarball is extracted. macOS node-pty
|
|
4
|
-
// posix_spawn()s that helper, so without +x every PTY spawn dies with
|
|
5
|
-
// "posix_spawnp failed." — see src/pty-helper.ts for the full story.
|
|
6
|
-
//
|
|
7
|
-
// This used to hunt for <pkg>/node_modules/node-pty by hand, a path that
|
|
8
|
-
// only exists when node-pty is NESTED. npm hoists it to the tree root under
|
|
9
|
-
// npx, so the fix silently did nothing on exactly the installs that needed
|
|
10
|
-
// it. The real logic now lives in the daemon (dist/pty-helper.js) and
|
|
11
|
-
// resolves the package the way Node does. The daemon also repairs at boot,
|
|
12
|
-
// so if dist isn't built yet (a source checkout installing before its first
|
|
13
|
-
// build) we exit quietly instead of duplicating the logic here.
|
|
14
|
-
|
|
15
|
-
let mod;
|
|
16
|
-
try {
|
|
17
|
-
mod = require('../dist/pty-helper.js');
|
|
18
|
-
} catch {
|
|
19
|
-
process.exit(0);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
try {
|
|
23
|
-
const line = mod.describeRepair(mod.ensurePtyHelperExecutable());
|
|
24
|
-
if (line) process.stdout.write(`[entities-runtime] ${line}\n`);
|
|
25
|
-
} catch (err) {
|
|
26
|
-
process.stderr.write(`[entities-runtime] pty helper check failed: ${err.message}\n`);
|
|
27
|
-
}
|
|
28
|
-
process.exit(0);
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// node-pty ships POSIX prebuilds whose `spawn-helper` binary can lose its
|
|
3
|
+
// executable bit when the npm tarball is extracted. macOS node-pty
|
|
4
|
+
// posix_spawn()s that helper, so without +x every PTY spawn dies with
|
|
5
|
+
// "posix_spawnp failed." — see src/pty-helper.ts for the full story.
|
|
6
|
+
//
|
|
7
|
+
// This used to hunt for <pkg>/node_modules/node-pty by hand, a path that
|
|
8
|
+
// only exists when node-pty is NESTED. npm hoists it to the tree root under
|
|
9
|
+
// npx, so the fix silently did nothing on exactly the installs that needed
|
|
10
|
+
// it. The real logic now lives in the daemon (dist/pty-helper.js) and
|
|
11
|
+
// resolves the package the way Node does. The daemon also repairs at boot,
|
|
12
|
+
// so if dist isn't built yet (a source checkout installing before its first
|
|
13
|
+
// build) we exit quietly instead of duplicating the logic here.
|
|
14
|
+
|
|
15
|
+
let mod;
|
|
16
|
+
try {
|
|
17
|
+
mod = require('../dist/pty-helper.js');
|
|
18
|
+
} catch {
|
|
19
|
+
process.exit(0);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
try {
|
|
23
|
+
const line = mod.describeRepair(mod.ensurePtyHelperExecutable());
|
|
24
|
+
if (line) process.stdout.write(`[entities-runtime] ${line}\n`);
|
|
25
|
+
} catch (err) {
|
|
26
|
+
process.stderr.write(`[entities-runtime] pty helper check failed: ${err.message}\n`);
|
|
27
|
+
}
|
|
28
|
+
process.exit(0);
|