@joe-broadhead/messaging 0.7.1 → 0.9.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.
Files changed (94) hide show
  1. package/CHANGELOG.md +364 -2
  2. package/dist/bin/messaging-mcp.js +5498 -4338
  3. package/dist/bin/messaging-relay.js +8626 -5540
  4. package/dist/bin/messaging.js +4492 -3158
  5. package/dist/bin/messagingd.js +19672 -12412
  6. package/dist/lib/modules/core/agent/operations.js +19 -327
  7. package/dist/lib/modules/core/agent/present.js +20 -55
  8. package/dist/lib/modules/core/agent-tools.js +35 -139
  9. package/dist/lib/modules/core/consent.js +54 -14
  10. package/dist/lib/modules/core/contact-card.js +3 -3
  11. package/dist/lib/modules/core/conversation/event.js +29 -4
  12. package/dist/lib/modules/core/conversation/guest-invitation.js +42 -0
  13. package/dist/lib/modules/core/conversation/log.js +287 -65
  14. package/dist/lib/modules/core/conversation/request-log.js +158 -0
  15. package/dist/lib/modules/core/conversation/request-seal.js +41 -0
  16. package/dist/lib/modules/core/conversation/requests.js +87 -0
  17. package/dist/lib/modules/core/conversation/seal.js +90 -37
  18. package/dist/lib/modules/core/conversation-agent-tools.js +69 -0
  19. package/dist/lib/modules/core/federation/directory-proof.js +83 -0
  20. package/dist/lib/modules/core/federation/proof-state.js +167 -0
  21. package/dist/lib/modules/core/federation/roster-proof.js +74 -0
  22. package/dist/lib/modules/core/index.js +9 -4
  23. package/dist/lib/modules/core/jelly-host.js +8 -5
  24. package/dist/lib/modules/core/schema/common.js +33 -5
  25. package/dist/lib/modules/core/schema/consent.js +23 -5
  26. package/dist/lib/modules/core/schema/contact-request.js +22 -0
  27. package/dist/lib/modules/core/schema/conv-frames.js +101 -0
  28. package/dist/lib/modules/core/schema/conversation.js +67 -33
  29. package/dist/lib/modules/core/schema/directory-frames.js +8 -3
  30. package/dist/lib/modules/core/schema/envelope.js +8 -24
  31. package/dist/lib/modules/core/schema/errors.js +7 -5
  32. package/dist/lib/modules/core/schema/guest-invitation.js +13 -0
  33. package/dist/lib/modules/core/schema/index.js +5 -0
  34. package/dist/lib/modules/core/schema/ipc/consent.js +97 -18
  35. package/dist/lib/modules/core/schema/ipc/conversation-views.js +87 -0
  36. package/dist/lib/modules/core/schema/ipc/conversations.js +132 -0
  37. package/dist/lib/modules/core/schema/ipc/device.js +9 -0
  38. package/dist/lib/modules/core/schema/ipc/jelly.js +17 -45
  39. package/dist/lib/modules/core/schema/ipc/shapes.js +74 -73
  40. package/dist/lib/modules/core/schema/ipc/surfaces.js +12 -195
  41. package/dist/lib/modules/core/schema/ipc/tasks.js +31 -0
  42. package/dist/lib/modules/core/schema/ipc.js +68 -46
  43. package/dist/lib/modules/core/testing.js +1 -1
  44. package/dist/lib/modules/core/version.js +1 -1
  45. package/dist/lib/modules/ipc/client.js +10 -2
  46. package/dist/lib/modules/ipc/server.js +14 -5
  47. package/dist/lib/modules/ipc/testing.js +13 -23
  48. package/dist/spec/messaging-v1.md +854 -445
  49. package/dist/third-party-notices.md +1 -1
  50. package/dist/third-party.json +1 -1
  51. package/dist/types/core/agent/operations.d.ts +5 -52
  52. package/dist/types/core/agent/present.d.ts +6 -21
  53. package/dist/types/core/agent-tools.d.ts +295 -442
  54. package/dist/types/core/consent.d.ts +30 -7
  55. package/dist/types/core/contact-card.d.ts +3 -3
  56. package/dist/types/core/conversation/event.d.ts +6 -6
  57. package/dist/types/core/conversation/guest-invitation.d.ts +8 -0
  58. package/dist/types/core/conversation/log.d.ts +28 -13
  59. package/dist/types/core/conversation/request-log.d.ts +24 -0
  60. package/dist/types/core/conversation/request-seal.d.ts +6 -0
  61. package/dist/types/core/conversation/requests.d.ts +14 -0
  62. package/dist/types/core/conversation/seal.d.ts +32 -9
  63. package/dist/types/core/conversation-agent-tools.d.ts +939 -0
  64. package/dist/types/core/federation/directory-proof.d.ts +8 -0
  65. package/dist/types/core/federation/proof-state.d.ts +114 -0
  66. package/dist/types/core/federation/roster-proof.d.ts +7 -0
  67. package/dist/types/core/index.d.ts +11 -6
  68. package/dist/types/core/jelly-host.d.ts +1 -1
  69. package/dist/types/core/schema/common.d.ts +33 -6
  70. package/dist/types/core/schema/consent.d.ts +29 -8
  71. package/dist/types/core/schema/contact-request.d.ts +264 -0
  72. package/dist/types/core/schema/conv-frames.d.ts +1204 -0
  73. package/dist/types/core/schema/conversation.d.ts +1410 -264
  74. package/dist/types/core/schema/directory-frames.d.ts +8 -3
  75. package/dist/types/core/schema/envelope.d.ts +85 -130
  76. package/dist/types/core/schema/errors.d.ts +5 -1
  77. package/dist/types/core/schema/guest-invitation.d.ts +51 -0
  78. package/dist/types/core/schema/index.d.ts +5 -0
  79. package/dist/types/core/schema/ipc/consent.d.ts +464 -62
  80. package/dist/types/core/schema/ipc/conversation-views.d.ts +1199 -0
  81. package/dist/types/core/schema/ipc/conversations.d.ts +4355 -0
  82. package/dist/types/core/schema/ipc/device.d.ts +10 -0
  83. package/dist/types/core/schema/ipc/jelly.d.ts +16 -111
  84. package/dist/types/core/schema/ipc/shapes.d.ts +211 -95
  85. package/dist/types/core/schema/ipc/surfaces.d.ts +26 -427
  86. package/dist/types/core/schema/ipc/tasks.d.ts +210 -0
  87. package/dist/types/core/schema/ipc.d.ts +3859 -890
  88. package/dist/types/core/schema/relay.d.ts +12 -4
  89. package/dist/types/core/testing.d.ts +1 -1
  90. package/dist/types/core/version.d.ts +1 -1
  91. package/dist/types/ipc/client.d.ts +4 -1
  92. package/dist/types/ipc/server.d.ts +16 -1
  93. package/dist/types/ipc/testing.d.ts +21 -8
  94. package/package.json +1 -1
@@ -1,10 +1,10 @@
1
1
  import { mkdtempSync, rmSync } from "node:fs";
2
2
  import { tmpdir } from "node:os";
3
3
  import { join } from "node:path";
4
- import { IPC_METHODS, MessagingError } from "../core/index.js";
4
+ import { CONVERSATION_METHODS, IPC_METHODS, MessagingError } from "../core/index.js";
5
5
  import { MessagingClient } from "./client.js";
6
6
  import { IS_WINDOWS, MAX_SOCKET_PATH_BYTES, socketPath as socketOf } from "./paths.js";
7
- import { createIpcServer } from "./server.js";
7
+ import { createConversationIpcServerForTesting, createIpcServer } from "./server.js";
8
8
  import { newPipeName, readPointer, writePointer } from "./pipes.js";
9
9
  import { securePrivate } from "./windows-acl.js";
10
10
  /**
@@ -55,36 +55,30 @@ export function rawEndpoint(socketPath) {
55
55
  export function ulid(n) {
56
56
  return `01JC${String(n).padStart(22, "0")}`;
57
57
  }
58
- /** Polls `predicate` every 10 ms until it holds; throws after `timeoutMs`. */
59
- export async function until(predicate, timeoutMs = 3_000, what = "condition") {
60
- const deadline = Date.now() + timeoutMs;
58
+ /** Polls state with no notification; the enclosing test's timeout is the single bound. Legacy timeout and label are ignored. */
59
+ export async function until(predicate, _timeoutMs, _what = "condition") {
61
60
  while (!predicate()) {
62
- if (Date.now() > deadline)
63
- throw new Error(`timed out waiting for ${what}`);
64
- await new Promise((resolve) => setTimeout(resolve, 10));
61
+ await new Promise((resolve) => setTimeout(resolve, 10).unref());
65
62
  }
66
63
  }
67
64
  export async function recordingDaemon(options = {}) {
65
+ const conversationMode = "methods" in options && options.methods !== undefined;
66
+ if (conversationMode && options.methods !== CONVERSATION_METHODS)
67
+ throw new TypeError("recordingDaemon: unsupported method table");
68
68
  const owned = options.at === undefined;
69
69
  const dir = options.at?.dir ?? tempSocketPath(options.prefix).dir;
70
70
  const socketPath = socketOf(dir, "agent");
71
71
  const adminSocketPath = socketOf(dir, "admin");
72
72
  const handlers = { ...options.handlers };
73
73
  const calls = [];
74
- const convSubscribers = new Set();
75
74
  const dispatch = {};
76
- for (const method of Object.keys(IPC_METHODS)) {
75
+ for (const method of Object.keys(conversationMode ? CONVERSATION_METHODS : IPC_METHODS)) {
77
76
  dispatch[method] = async (params, ctx) => {
78
77
  calls.push({ method, params: structuredClone(params) });
79
78
  const handler = handlers[method];
80
79
  if (!handler)
81
80
  throw new MessagingError("forbidden", `fake daemon: no handler for ${method}`);
82
- const result = await handler(params, ctx);
83
- if (method === "conv.subscribe") {
84
- convSubscribers.add(ctx);
85
- ctx.signal.addEventListener("abort", () => convSubscribers.delete(ctx));
86
- }
87
- return result;
81
+ return handler(params, ctx);
88
82
  };
89
83
  }
90
84
  let servers;
@@ -92,8 +86,9 @@ export async function recordingDaemon(options = {}) {
92
86
  if (servers)
93
87
  return;
94
88
  const version = options.version === undefined ? {} : { version: options.version };
95
- const agent = await createIpcServer({ socketPath, tier: "agent", handlers: dispatch, ...version });
96
- const admin = await createIpcServer({ socketPath: adminSocketPath, tier: "admin", handlers: dispatch, ...version }).catch(async (error) => {
89
+ const serve = conversationMode ? createConversationIpcServerForTesting : createIpcServer;
90
+ const agent = await serve({ socketPath, tier: "agent", handlers: dispatch, ...version });
91
+ const admin = await serve({ socketPath: adminSocketPath, tier: "admin", handlers: dispatch, ...version }).catch(async (error) => {
97
92
  await agent.close();
98
93
  throw error;
99
94
  });
@@ -116,17 +111,12 @@ export async function recordingDaemon(options = {}) {
116
111
  callsTo,
117
112
  last: (method) => callsTo(method).at(-1),
118
113
  handle: (method, handler) => {
119
- ;
120
114
  handlers[method] = handler;
121
115
  },
122
116
  publish: (event) => {
123
117
  for (const server of servers ?? [])
124
118
  server.publish(event);
125
119
  },
126
- conv: (event) => {
127
- for (const ctx of convSubscribers)
128
- ctx.notify(event);
129
- },
130
120
  connect: (tier = "agent") => MessagingClient.connect({ socketPath: tier === "agent" ? socketPath : adminSocketPath, connectTimeoutMs: 500 }),
131
121
  connections: () => (servers ?? []).reduce((sum, server) => sum + server.connections(), 0),
132
122
  start,