@ouro.bot/friends 0.1.0-alpha.4 → 0.1.0-alpha.5

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 (36) hide show
  1. package/README.md +66 -6
  2. package/changelog.json +6 -0
  3. package/dist/a2a-client/a2a-message.d.ts +39 -0
  4. package/dist/a2a-client/a2a-message.js +54 -0
  5. package/dist/a2a-client/adapter.d.ts +97 -0
  6. package/dist/a2a-client/adapter.js +114 -0
  7. package/dist/a2a-client/agent-card.d.ts +50 -0
  8. package/dist/a2a-client/agent-card.js +32 -0
  9. package/dist/a2a-client/did-key.d.ts +38 -0
  10. package/dist/a2a-client/did-key.js +120 -0
  11. package/dist/a2a-client/did-verifier.d.ts +109 -0
  12. package/dist/a2a-client/did-verifier.js +163 -0
  13. package/dist/a2a-client/did-web.d.ts +26 -0
  14. package/dist/a2a-client/did-web.js +140 -0
  15. package/dist/a2a-client/index.d.ts +23 -0
  16. package/dist/a2a-client/index.js +72 -0
  17. package/dist/a2a-client/jcs.d.ts +5 -0
  18. package/dist/a2a-client/jcs.js +84 -0
  19. package/dist/a2a-client/reachability.d.ts +22 -0
  20. package/dist/a2a-client/reachability.js +17 -0
  21. package/dist/a2a-client/seal.d.ts +47 -0
  22. package/dist/a2a-client/seal.js +95 -0
  23. package/dist/a2a-client/sealed-envelope.d.ts +55 -0
  24. package/dist/a2a-client/sealed-envelope.js +94 -0
  25. package/dist/a2a-client/sign.d.ts +42 -0
  26. package/dist/a2a-client/sign.js +87 -0
  27. package/dist/a2a-client/sodium.d.ts +5 -0
  28. package/dist/a2a-client/sodium.js +19 -0
  29. package/dist/agent-peer.js +5 -1
  30. package/dist/{a2a → mailbox}/index.js +10 -3
  31. package/dist/mcp/bin.js +0 -0
  32. package/dist/store-file.d.ts +6 -2
  33. package/dist/store-file.js +28 -5
  34. package/dist/types.d.ts +22 -7
  35. package/package.json +15 -6
  36. /package/dist/{a2a → mailbox}/index.d.ts +0 -0
@@ -190,30 +190,43 @@ class FileFriendStore {
190
190
  const meta = raw;
191
191
  if (typeof meta.bundleName !== "string")
192
192
  return undefined;
193
+ // Mailbox is top-level on AgentMeta since the phase-8 demote. Read the
194
+ // top-level `meta.mailbox` first; if absent, MIGRATE-ON-READ from a legacy
195
+ // alpha.4 record that nested it under `a2a.mailbox`. schemaVersion stays 1;
196
+ // every legacy record reads clean.
197
+ const a2aRaw = meta.a2a && typeof meta.a2a === "object" && !Array.isArray(meta.a2a)
198
+ ? meta.a2a
199
+ : undefined;
200
+ const mailbox = this.normalizeMailbox(meta.mailbox) ??
201
+ (a2aRaw ? this.normalizeMailbox(a2aRaw.mailbox) : undefined);
202
+ const a2a = this.normalizeA2AMeta(meta.a2a);
193
203
  return {
194
204
  bundleName: meta.bundleName,
195
205
  familiarity: typeof meta.familiarity === "number" ? meta.familiarity : 0,
196
206
  sharedMissions: Array.isArray(meta.sharedMissions) ? meta.sharedMissions : [],
197
207
  outcomes: Array.isArray(meta.outcomes) ? meta.outcomes : [],
198
- ...(this.normalizeA2AMeta(meta.a2a) ? { a2a: this.normalizeA2AMeta(meta.a2a) } : {}),
208
+ ...(a2a ? { a2a } : {}),
209
+ ...(mailbox ? { mailbox } : {}),
199
210
  };
200
211
  }
201
212
  normalizeA2AMeta(raw) {
202
213
  if (!raw || typeof raw !== "object" || Array.isArray(raw))
203
214
  return undefined;
204
215
  const meta = raw;
205
- const mailbox = this.normalizeMailbox(meta.mailbox);
216
+ const relay = this.normalizeRelay(meta.relay);
206
217
  const a2a = {
207
218
  ...(typeof meta.cardUrl === "string" ? { cardUrl: meta.cardUrl } : {}),
208
219
  ...(typeof meta.endpointUrl === "string" ? { endpointUrl: meta.endpointUrl } : {}),
209
220
  ...(typeof meta.agentId === "string" ? { agentId: meta.agentId } : {}),
210
221
  ...(typeof meta.protocolVersion === "string" ? { protocolVersion: meta.protocolVersion } : {}),
211
- ...(mailbox ? { mailbox } : {}),
222
+ ...(relay ? { relay } : {}),
223
+ ...(typeof meta.did === "string" ? { did: meta.did } : {}),
212
224
  };
213
225
  return Object.keys(a2a).length > 0 ? a2a : undefined;
214
226
  }
215
- /** Preserve an additive a2a.mailbox coord only when both fields are strings;
216
- * otherwise drop it (absent ⇒ unchanged — the additive guarantee). */
227
+ /** Preserve the top-level mailbox coord only when both fields are strings;
228
+ * otherwise drop it (absent ⇒ unchanged — the additive guarantee). Also used to
229
+ * migrate a legacy nested `a2a.mailbox`. */
217
230
  normalizeMailbox(raw) {
218
231
  if (!raw || typeof raw !== "object" || Array.isArray(raw))
219
232
  return undefined;
@@ -222,6 +235,16 @@ class FileFriendStore {
222
235
  return undefined;
223
236
  return { repo: m.repo, selfOutboxAgentId: m.selfOutboxAgentId };
224
237
  }
238
+ /** Preserve an additive a2a.relay coord only when both fields are strings;
239
+ * otherwise drop it (absent ⇒ unchanged — the additive guarantee). */
240
+ normalizeRelay(raw) {
241
+ if (!raw || typeof raw !== "object" || Array.isArray(raw))
242
+ return undefined;
243
+ const r = raw;
244
+ if (typeof r.url !== "string" || typeof r.handle !== "string")
245
+ return undefined;
246
+ return { url: r.url, handle: r.handle };
247
+ }
225
248
  async readJson(filePath) {
226
249
  try {
227
250
  const raw = await fsPromises.readFile(filePath, "utf-8");
package/dist/types.d.ts CHANGED
@@ -113,14 +113,29 @@ export interface AgentMeta {
113
113
  endpointUrl?: string;
114
114
  agentId?: string;
115
115
  protocolVersion?: string;
116
- /** Optional A2A git-mailbox coordinates (brick two). The mailbox is a
117
- * dedicated PRIVATE repo holding only in-flight envelopes; `selfOutboxAgentId`
118
- * is the dir THIS peer writes its outbox under. Absent on records that don't
119
- * use the git-mailbox transport. */
120
- mailbox?: {
121
- repo: string;
122
- selfOutboxAgentId: string;
116
+ /** Optional friends-relay coordinates (phase 8). When a peer has no directly
117
+ * reachable A2A `endpointUrl`, the host delivers via the UNTRUSTED relay at
118
+ * `url`, addressing the peer by its opaque `handle`. The relay carries only
119
+ * ciphertext (the E2E sign-then-seal overlay) — it never sees content. Absent
120
+ * on peers reachable directly or only via the git-mailbox fallback. */
121
+ relay?: {
122
+ url: string;
123
+ handle: string;
123
124
  };
125
+ /** The peer's pinned DID (phase 8 — `did:key:…` or `did:web:…`). `agentId ===
126
+ * did` (the DID is the cross-agent identity primary key); pinned on first
127
+ * contact (TOFU) and verified on every use thereafter. Absent until the peer
128
+ * presents a DID-bearing proof. */
129
+ did?: string;
130
+ };
131
+ /** Optional git-mailbox FALLBACK coordinates (the demoted no-endpoint transport;
132
+ * see src/mailbox/). The mailbox is a dedicated PRIVATE repo holding only
133
+ * in-flight envelopes; `selfOutboxAgentId` is the dir THIS peer writes its outbox
134
+ * under. Top-level since phase 8's demote (was nested under `a2a` in alpha.4 —
135
+ * legacy records migrate-on-read). Absent on peers that don't use the fallback. */
136
+ mailbox?: {
137
+ repo: string;
138
+ selfOutboxAgentId: string;
124
139
  };
125
140
  }
126
141
  export interface FriendRecord {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ouro.bot/friends",
3
- "version": "0.1.0-alpha.4",
3
+ "version": "0.1.0-alpha.5",
4
4
  "description": "The who's-who / identity / relationship substrate for agents — trust ladder (family/friend/acquaintance/stranger), multi-party and multi-agent, consumed via the FriendStore interface + FriendResolver.",
5
5
  "license": "Apache-2.0",
6
6
  "main": "dist/index.js",
@@ -14,9 +14,13 @@
14
14
  "types": "./dist/mcp/index.d.ts",
15
15
  "default": "./dist/mcp/index.js"
16
16
  },
17
- "./a2a": {
18
- "types": "./dist/a2a/index.d.ts",
19
- "default": "./dist/a2a/index.js"
17
+ "./mailbox": {
18
+ "types": "./dist/mailbox/index.d.ts",
19
+ "default": "./dist/mailbox/index.js"
20
+ },
21
+ "./a2a-client": {
22
+ "types": "./dist/a2a-client/index.d.ts",
23
+ "default": "./dist/a2a-client/index.js"
20
24
  }
21
25
  },
22
26
  "bin": {
@@ -29,6 +33,7 @@
29
33
  "type": "commonjs",
30
34
  "scripts": {
31
35
  "build": "tsc",
36
+ "postbuild": "node -e \"require('fs').chmodSync('dist/mcp/bin.js', 0o755)\"",
32
37
  "prepare": "npm run build",
33
38
  "pretest": "npm run build",
34
39
  "pretest:coverage": "npm run build",
@@ -37,10 +42,11 @@
37
42
  "lint": "eslint src/",
38
43
  "typecheck": "tsc --noEmit",
39
44
  "example:cross-agent-moat": "npm run build && tsx examples/cross-agent-moat.ts",
40
- "example:a2a-git-mailbox": "npm run build && tsx examples/a2a-git-mailbox.ts",
45
+ "example:mailbox-fallback": "npm run build && tsx examples/mailbox-fallback.ts",
41
46
  "example:cross-agent-mission-memory": "npm run build && tsx examples/cross-agent-mission-memory.ts",
42
47
  "example:cross-agent-standing": "npm run build && tsx examples/cross-agent-standing.ts",
43
48
  "example:cross-agent-coordination": "npm run build && tsx examples/cross-agent-coordination.ts",
49
+ "example:cross-agent-a2a-relay": "npm run build && tsx examples/cross-agent-a2a-relay.ts",
44
50
  "release:bump": "node scripts/release-bump.cjs",
45
51
  "release:preflight": "node scripts/release-preflight.cjs",
46
52
  "release:trust:check": "node scripts/npm-trusted-publishers.cjs check",
@@ -54,8 +60,11 @@
54
60
  "publishConfig": {
55
61
  "access": "public"
56
62
  },
57
- "dependencies": {},
63
+ "dependencies": {
64
+ "libsodium-wrappers": "0.8.4"
65
+ },
58
66
  "devDependencies": {
67
+ "@types/libsodium-wrappers": "0.8.2",
59
68
  "@types/node": "^22.0.0",
60
69
  "@vitest/coverage-v8": "^4.1.8",
61
70
  "eslint": "^10.0.2",
File without changes