edge-book 0.1.2 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +674 -0
- package/dist/edge-book.js +470 -10
- package/index.js +73 -0
- package/package.json +4 -2
package/index.js
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { definePluginEntry } from "openclaw/plugin-sdk/plugin-entry";
|
|
2
|
+
import { DEFAULT_DIALOUT_HOST, EdgeBookDialoutClient, handleCli } from "./dist/edge-book.js";
|
|
3
|
+
|
|
4
|
+
function resolveHome(api) {
|
|
5
|
+
const configured = api?.pluginConfig?.home;
|
|
6
|
+
if (typeof configured === "string" && configured.trim()) return configured.trim();
|
|
7
|
+
return process.env.EDGE_BOOK_HOME || undefined;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
function resolveHost(api) {
|
|
11
|
+
const configured = api?.pluginConfig?.host;
|
|
12
|
+
if (typeof configured === "string" && configured.trim()) return configured.trim();
|
|
13
|
+
return process.env.EDGE_BOOK_HOST || DEFAULT_DIALOUT_HOST;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function autoDialoutEnabled(api) {
|
|
17
|
+
const configured = api?.pluginConfig?.autoDialout;
|
|
18
|
+
if (configured === false || configured === "false" || configured === "off") return false;
|
|
19
|
+
if (process.env.EDGE_BOOK_DIALOUT === "off" || process.env.EDGE_BOOK_DIALOUT === "false") return false;
|
|
20
|
+
return true;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export default definePluginEntry({
|
|
24
|
+
id: "edge-book",
|
|
25
|
+
name: "Edge Book",
|
|
26
|
+
description: "Local-first agent friendship, contact graph, capability grants, and two-agent harness.",
|
|
27
|
+
register(api) {
|
|
28
|
+
let managedClient = null;
|
|
29
|
+
let stoodDown = false;
|
|
30
|
+
|
|
31
|
+
async function startManaged() {
|
|
32
|
+
if (managedClient || !autoDialoutEnabled(api) || stoodDown) return;
|
|
33
|
+
const home = resolveHome(api);
|
|
34
|
+
const host = resolveHost(api);
|
|
35
|
+
await handleCli(["init"], { home, defaultHost: host, textOnly: true });
|
|
36
|
+
console.warn(`[edge-book] Enabling hosted dial-out to ${host}. The host can read this agent's Edge Book graph while connected.`);
|
|
37
|
+
managedClient = new EdgeBookDialoutClient({
|
|
38
|
+
home,
|
|
39
|
+
host,
|
|
40
|
+
onStandDown: (frame) => {
|
|
41
|
+
stoodDown = true;
|
|
42
|
+
managedClient = null;
|
|
43
|
+
console.warn(`[edge-book] Hosted dial-out stood down by host (${frame.type || "stand_down"}). Run edge-book pair to reconnect.`);
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
await managedClient.start();
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
api.registerCommand({
|
|
50
|
+
name: "edge-book",
|
|
51
|
+
description: "Manage Edge Book identity, Agent Card, contacts, friendship, and harness.",
|
|
52
|
+
acceptsArgs: true,
|
|
53
|
+
handler: async (ctx) => {
|
|
54
|
+
const args = ctx.args?.trim() ? ctx.args.trim().split(/\s+/) : ["help"];
|
|
55
|
+
if (args[0] === "pair") stoodDown = false;
|
|
56
|
+
const result = await handleCli(args, { home: resolveHome(api), defaultHost: resolveHost(api), textOnly: true });
|
|
57
|
+
if (args[0] === "pair") await startManaged();
|
|
58
|
+
return { text: result.text };
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
api.registerService({
|
|
63
|
+
id: "edge-book-managed-dialout",
|
|
64
|
+
start: async () => {
|
|
65
|
+
await startManaged();
|
|
66
|
+
},
|
|
67
|
+
stop: async () => {
|
|
68
|
+
if (managedClient) await managedClient.stop();
|
|
69
|
+
managedClient = null;
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "edge-book",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Run your own Edge Book agent and connect it to the hosted reader.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
"build": "tsup",
|
|
12
12
|
"test": "node --test test/*.test.ts",
|
|
13
13
|
"harness": "node bin/edge-book.js harness two-agent",
|
|
14
|
+
"harness:e2e": "node scripts/convergence-e2e.ts",
|
|
14
15
|
"prepublishOnly": "npm run build"
|
|
15
16
|
},
|
|
16
17
|
"openclaw": {
|
|
@@ -28,6 +29,7 @@
|
|
|
28
29
|
},
|
|
29
30
|
"files": [
|
|
30
31
|
"dist",
|
|
32
|
+
"index.js",
|
|
31
33
|
"README.md"
|
|
32
34
|
],
|
|
33
35
|
"engines": {
|
|
@@ -35,7 +37,7 @@
|
|
|
35
37
|
},
|
|
36
38
|
"repository": {
|
|
37
39
|
"type": "git",
|
|
38
|
-
"url": "git+https://github.com/
|
|
40
|
+
"url": "git+https://github.com/antonyevans/edge-book-cli.git"
|
|
39
41
|
},
|
|
40
42
|
"peerDependencies": {
|
|
41
43
|
"openclaw": ">=2026.5.22"
|