@kybernesis/buzz 0.9.10 → 0.9.12
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/dist/cli.js +62 -0
- package/dist/extension/_manifest.json +2 -2
- package/dist/profile.d.ts +2 -0
- package/package.json +3 -3
package/dist/cli.js
CHANGED
|
@@ -44,6 +44,31 @@ function flag(name) {
|
|
|
44
44
|
const at = process.argv.indexOf(`--${name}`);
|
|
45
45
|
return at === -1 ? undefined : process.argv[at + 1];
|
|
46
46
|
}
|
|
47
|
+
/** The `.agent` identity this directory's agent was connected to, if any. */
|
|
48
|
+
function identityDidFromFile() {
|
|
49
|
+
const file = process.env.ARP_IDENTITY_FILE ?? join(process.cwd(), ".eve", "arp-identity.json");
|
|
50
|
+
if (!existsSync(file))
|
|
51
|
+
return null;
|
|
52
|
+
try {
|
|
53
|
+
const parsed = JSON.parse(readFileSync(file, "utf8"));
|
|
54
|
+
return typeof parsed.did === "string" && parsed.did.startsWith("did:web:") ? parsed.did : null;
|
|
55
|
+
}
|
|
56
|
+
catch {
|
|
57
|
+
return null;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
/** The name's public profile document, served from the name's own address. */
|
|
61
|
+
async function fetchAgentIdProfile(sld) {
|
|
62
|
+
const suffix = process.env.AGENTID_MIRROR_SUFFIX ?? ".agent.arp.run";
|
|
63
|
+
const url = `https://${sld}${suffix.startsWith(".") ? suffix : `.${suffix}`}/.well-known/agent-profile.json`;
|
|
64
|
+
const res = await fetch(url, { headers: { accept: "application/json" }, signal: AbortSignal.timeout(10_000) });
|
|
65
|
+
if (!res.ok) {
|
|
66
|
+
console.error(`\n ${sld}.agent has no profile document yet (${res.status} from ${url}).\n`);
|
|
67
|
+
process.exit(1);
|
|
68
|
+
}
|
|
69
|
+
const doc = (await res.json());
|
|
70
|
+
return { name: doc.name ?? sld, description: doc.description ?? "", picture: doc.picture ?? null, nip05: doc.nip05 ?? null };
|
|
71
|
+
}
|
|
47
72
|
/**
|
|
48
73
|
* Say who this agent is, in every community it belongs to.
|
|
49
74
|
*
|
|
@@ -63,9 +88,46 @@ async function setProfile() {
|
|
|
63
88
|
console.log();
|
|
64
89
|
return;
|
|
65
90
|
}
|
|
91
|
+
// AgentID: the agent's `.agent` name is the source of truth for how it
|
|
92
|
+
// presents itself. `--from-agentid` reads the name's public profile document
|
|
93
|
+
// and publishes it as this key's kind-0 — name, description, picture and
|
|
94
|
+
// the NIP-05 handle that nostr clients verify against the name itself. The
|
|
95
|
+
// Buzz key never leaves this host; ARP Cloud only publishes the document.
|
|
96
|
+
if (process.argv.includes("--from-agentid")) {
|
|
97
|
+
const did = flag("from-agentid") && !flag("from-agentid").startsWith("--") ? flag("from-agentid") : identityDidFromFile();
|
|
98
|
+
if (!did) {
|
|
99
|
+
console.error("\n Which name? kybernesis-buzz profile --from-agentid <name>.agent\n (or run it from the agent's directory, where .eve/arp-identity.json says who it is)\n");
|
|
100
|
+
process.exit(1);
|
|
101
|
+
}
|
|
102
|
+
const sld = did.replace(/^did:web:/, "").replace(/\.agent$/, "").toLowerCase();
|
|
103
|
+
const doc = await fetchAgentIdProfile(sld);
|
|
104
|
+
const wanted = {
|
|
105
|
+
name: sld,
|
|
106
|
+
display_name: doc.name,
|
|
107
|
+
...(doc.description ? { about: doc.description } : {}),
|
|
108
|
+
...(doc.picture ? { picture: doc.picture } : {}),
|
|
109
|
+
...(doc.nip05 ? { nip05: doc.nip05 } : {}),
|
|
110
|
+
bot: true,
|
|
111
|
+
};
|
|
112
|
+
let published = 0;
|
|
113
|
+
for (const url of urls) {
|
|
114
|
+
try {
|
|
115
|
+
await profile.write(url, key, wanted);
|
|
116
|
+
console.log(` ✓ ${url}`);
|
|
117
|
+
published += 1;
|
|
118
|
+
}
|
|
119
|
+
catch (error) {
|
|
120
|
+
const why = error.message;
|
|
121
|
+
console.log(why.includes("not a relay member") ? ` · ${url} — not a member yet, so nothing to be known as there` : ` ✕ ${url} — ${why}`);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
console.log(published > 0 ? `\n ${doc.name} (${sld}.agent) is ${key.npub.slice(0, 20)}… — profile taken from the name.\n` : "\n Nothing published — invite this key to a community first.\n");
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
66
127
|
const name = flag("name");
|
|
67
128
|
if (!name) {
|
|
68
129
|
console.error("usage: kybernesis-buzz profile --name <name> [--about …] [--picture <file|url>]");
|
|
130
|
+
console.error(" or: kybernesis-buzz profile --from-agentid [<name>.agent]");
|
|
69
131
|
console.error(" or: kybernesis-buzz profile --copy-from <wss://…>");
|
|
70
132
|
process.exit(1);
|
|
71
133
|
}
|
package/dist/profile.d.ts
CHANGED
|
@@ -21,6 +21,8 @@ export type Profile = {
|
|
|
21
21
|
about?: string;
|
|
22
22
|
/** A URL. Relays store the address, never the image. */
|
|
23
23
|
picture?: string;
|
|
24
|
+
/** NIP-05 handle, e.g. `_@kyber.agent` — verified by the name's own NIP-05 document. */
|
|
25
|
+
nip05?: string;
|
|
24
26
|
/** Says plainly that this is an agent. Clients use it; so should we. */
|
|
25
27
|
bot?: boolean;
|
|
26
28
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kybernesis/buzz",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.12",
|
|
4
4
|
"description": "Put an eve agent in a Buzz workspace as a member: per-speaker verified identity resolved through the control plane, self-service identity linking, presence, typing and seen signals.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
@@ -50,11 +50,11 @@
|
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
52
|
"@types/node": "24.x",
|
|
53
|
-
"eve": "^0.
|
|
53
|
+
"eve": "^0.51.1",
|
|
54
54
|
"typescript": "7.0.2"
|
|
55
55
|
},
|
|
56
56
|
"peerDependencies": {
|
|
57
|
-
"eve": ">=0.
|
|
57
|
+
"eve": ">=0.51.0 <0.52.0"
|
|
58
58
|
},
|
|
59
59
|
"engines": {
|
|
60
60
|
"node": ">=20"
|