edge-book 0.8.0 → 0.8.1

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 (2) hide show
  1. package/dist/edge-book.js +31 -25
  2. package/package.json +1 -1
package/dist/edge-book.js CHANGED
@@ -175,6 +175,15 @@ function resolveFieldVisibility(profile, field) {
175
175
  function resolveSocialVisibility(profile, label) {
176
176
  return profile.visibility?.[label] ?? profile.visibility?.["*"] ?? "friends";
177
177
  }
178
+ function projectProfileFields(profile, includeField) {
179
+ const out = {};
180
+ if (profile.name && includeField(resolveFieldVisibility(profile, "name"))) out.name = profile.name;
181
+ if (profile.bio && includeField(resolveFieldVisibility(profile, "bio"))) out.bio = profile.bio;
182
+ if (profile.location && includeField(resolveFieldVisibility(profile, "location"))) out.location = profile.location;
183
+ const socials = (profile.socials ?? []).filter((s) => includeField(resolveSocialVisibility(profile, s.label)));
184
+ if (socials.length) out.socials = socials;
185
+ return out;
186
+ }
178
187
  function computeLifecycle(expiresAt, hard, current) {
179
188
  if (current === "expired" || current === "cancelled" || current === "tombstoned") {
180
189
  return current;
@@ -287,15 +296,9 @@ var EdgeBookStore = class {
287
296
  if (config.relay_url) transports.push({ mode: "relay", endpoint: config.relay_url });
288
297
  const caps = Object.values(await this.capabilities()).map((c) => ({ name: c.name, version: c.version, summary: c.summary, status: c.status }));
289
298
  const prof = defaultProfile(identity);
290
- const pubInclude = (field) => resolveFieldVisibility(prof, field) === "public";
291
- const pubSocials = (prof.socials ?? []).filter((s) => resolveSocialVisibility(prof, s.label) === "public");
292
- const publicProfile = {
293
- ...prof.name && pubInclude("name") ? { name: prof.name } : {},
294
- ...prof.bio && pubInclude("bio") ? { bio: prof.bio } : {},
295
- ...prof.location && pubInclude("location") ? { location: prof.location } : {},
296
- ...pubSocials.length ? { socials: pubSocials } : {}
297
- };
298
- const publicName = prof.name && pubInclude("name") ? prof.name : void 0;
299
+ const publicFields = projectProfileFields(prof, (v) => v === "public");
300
+ const publicProfile = { ...publicFields };
301
+ const publicName = publicFields.name;
299
302
  const unsigned = {
300
303
  schema: "openclaw-agent-card/0.1",
301
304
  agent_id: identity.agent_id,
@@ -326,18 +329,12 @@ var EdgeBookStore = class {
326
329
  async buildFriendProfile() {
327
330
  const identity = await this.identity();
328
331
  const profile = defaultProfile(identity);
329
- const include = (field) => resolveFieldVisibility(profile, field) !== "off";
330
- const socials = (profile.socials ?? []).filter(
331
- (s) => resolveSocialVisibility(profile, s.label) !== "off"
332
- );
332
+ const friendFields = projectProfileFields(profile, (v) => v !== "off");
333
333
  const unsigned = {
334
334
  schema: "openclaw-friend-profile/0.1",
335
335
  agent_id: identity.agent_id,
336
336
  profile_version: profile.profile_version ?? 1,
337
- ...profile.name && include("name") ? { name: profile.name } : {},
338
- ...profile.bio && include("bio") ? { bio: profile.bio } : {},
339
- ...profile.location && include("location") ? { location: profile.location } : {},
340
- ...socials.length ? { socials } : {},
337
+ ...friendFields,
341
338
  issued_at: now()
342
339
  };
343
340
  return { ...unsigned, signature: signPayload(unsigned, identity.private_key_pem) };
@@ -4400,7 +4397,7 @@ function usage() {
4400
4397
  Usage:
4401
4398
  edge-book init [--home <dir>] [--handle <handle>] [--name <agent name>] [--owner <human owner>]
4402
4399
  edge-book profile show [--home <dir>]
4403
- edge-book profile set [--name <you>] [--bio <text>] [--location <text>] [--social label=value ...] [--agent-name <display>] [--home <dir>]
4400
+ edge-book profile set [--name <human name>] [--agent-name <agent display name>] [--bio <text>] [--location <text>] [--social label=value ...] [--owner <legacy alias>] [--share-owner|--no-share-owner] [--home <dir>]
4404
4401
  edge-book profile visibility <field>=friends|public|off ... [--home <dir>]
4405
4402
 
4406
4403
  Hosted reader:
@@ -4767,13 +4764,22 @@ next: ${result.next_action}`, json: result };
4767
4764
  }
4768
4765
  if (action === "pending") {
4769
4766
  const pending = await store.pendingFriendRequests();
4770
- const json = pending.map((c) => ({
4771
- agent_id: c.peer_agent_id,
4772
- display_name: c.display_name,
4773
- note: "",
4774
- // note isn't persisted on the contact; read from inbox if needed
4775
- contact_created_at: c.created_at
4776
- }));
4767
+ const inbox = await store.inbox();
4768
+ const json = pending.map((c) => {
4769
+ const matchingEnvelopes = inbox.filter(
4770
+ (env) => env.type === "friend_request" && env.from_agent_id === c.peer_agent_id
4771
+ );
4772
+ const latest = matchingEnvelopes.length ? matchingEnvelopes.reduce((a, b) => a.created_at >= b.created_at ? a : b) : void 0;
4773
+ const note = latest ? latest.body.note ?? "" : "";
4774
+ const requested_at = latest?.created_at ?? "";
4775
+ return {
4776
+ agent_id: c.peer_agent_id,
4777
+ display_name: c.display_name,
4778
+ note,
4779
+ requested_at,
4780
+ contact_created_at: c.created_at
4781
+ };
4782
+ });
4777
4783
  const text = json.length ? json.map((p) => `${p.agent_id} ${p.display_name}`).join("\n") : "No pending friend requests.";
4778
4784
  return { text, json };
4779
4785
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "edge-book",
3
- "version": "0.8.0",
3
+ "version": "0.8.1",
4
4
  "description": "Run your own Edge Book agent and connect it to the hosted reader.",
5
5
  "license": "MIT",
6
6
  "type": "module",