edge-book 0.18.1 → 0.18.3

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 +29 -1
  2. package/package.json +1 -1
package/dist/edge-book.js CHANGED
@@ -2597,6 +2597,21 @@ var NOTIFY_POLICIES = {
2597
2597
  dedup_key: env.message_id
2598
2598
  };
2599
2599
  },
2600
+ post_publish: async (env, store) => {
2601
+ const post = env.body.post;
2602
+ if (!post) return null;
2603
+ const name = await peerName(store, env.from_agent_id) || env.from_agent_id;
2604
+ const postType = typeof post.post_type === "string" ? post.post_type : "post";
2605
+ const raw = typeof post.body === "string" ? post.body : typeof post.text === "string" ? post.text : post.body != null ? JSON.stringify(post.body) : "";
2606
+ const preview = raw.length > 280 ? `${raw.slice(0, 279)}\u2026` : raw;
2607
+ return {
2608
+ kind: "post_publish",
2609
+ from_id: env.from_agent_id,
2610
+ from_name: await peerName(store, env.from_agent_id),
2611
+ message: preview ? `${name} (${postType}): ${preview}` : `${name} sent a ${postType}.`,
2612
+ dedup_key: env.message_id
2613
+ };
2614
+ },
2600
2615
  object_share: async (env, store) => {
2601
2616
  const body = env.body;
2602
2617
  const name = await peerName(store, env.from_agent_id) || env.from_agent_id;
@@ -7265,10 +7280,23 @@ next: ${result.next_action}`, json: result };
7265
7280
  const action = args.shift();
7266
7281
  if (action === "send") {
7267
7282
  const deliver = takeBoolFlag(args, "--deliver");
7283
+ const hostUrl = parseHost(args, ctx);
7268
7284
  const peer = requireArg(args.shift(), "peer-agent-id");
7269
7285
  const body = requireArg(takeFlag(args, "--body"), "--body");
7270
7286
  const envelope = await store.sendPrivilegedMessage(peer, { text: body });
7271
- if (deliver) return { text: await deliverToPeer(store, envelope, peer), json: envelope };
7287
+ if (deliver) {
7288
+ try {
7289
+ return { text: await deliverToPeer(store, envelope, peer), json: envelope };
7290
+ } catch (err) {
7291
+ if (!(err instanceof EdgeBookError) || err.code !== "no_route") throw err;
7292
+ const outcome = await deliverViaMailboxRecorded(
7293
+ envelope,
7294
+ { home, host: hostUrl, socketFactory: ctx.socketFactory },
7295
+ (id) => `Sent message to ${peer} over the mailbox (host id ${id})`
7296
+ );
7297
+ return { text: outcome.text, json: envelope };
7298
+ }
7299
+ }
7272
7300
  return { text: JSON.stringify(envelope, null, 2), json: envelope };
7273
7301
  }
7274
7302
  if (action === "receive") {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "edge-book",
3
- "version": "0.18.1",
3
+ "version": "0.18.3",
4
4
  "description": "Run your own Edge Book agent and connect it to the hosted reader.",
5
5
  "license": "MIT",
6
6
  "type": "module",