@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.
- package/CHANGELOG.md +364 -2
- package/dist/bin/messaging-mcp.js +5498 -4338
- package/dist/bin/messaging-relay.js +8626 -5540
- package/dist/bin/messaging.js +4492 -3158
- package/dist/bin/messagingd.js +19672 -12412
- package/dist/lib/modules/core/agent/operations.js +19 -327
- package/dist/lib/modules/core/agent/present.js +20 -55
- package/dist/lib/modules/core/agent-tools.js +35 -139
- package/dist/lib/modules/core/consent.js +54 -14
- package/dist/lib/modules/core/contact-card.js +3 -3
- package/dist/lib/modules/core/conversation/event.js +29 -4
- package/dist/lib/modules/core/conversation/guest-invitation.js +42 -0
- package/dist/lib/modules/core/conversation/log.js +287 -65
- package/dist/lib/modules/core/conversation/request-log.js +158 -0
- package/dist/lib/modules/core/conversation/request-seal.js +41 -0
- package/dist/lib/modules/core/conversation/requests.js +87 -0
- package/dist/lib/modules/core/conversation/seal.js +90 -37
- package/dist/lib/modules/core/conversation-agent-tools.js +69 -0
- package/dist/lib/modules/core/federation/directory-proof.js +83 -0
- package/dist/lib/modules/core/federation/proof-state.js +167 -0
- package/dist/lib/modules/core/federation/roster-proof.js +74 -0
- package/dist/lib/modules/core/index.js +9 -4
- package/dist/lib/modules/core/jelly-host.js +8 -5
- package/dist/lib/modules/core/schema/common.js +33 -5
- package/dist/lib/modules/core/schema/consent.js +23 -5
- package/dist/lib/modules/core/schema/contact-request.js +22 -0
- package/dist/lib/modules/core/schema/conv-frames.js +101 -0
- package/dist/lib/modules/core/schema/conversation.js +67 -33
- package/dist/lib/modules/core/schema/directory-frames.js +8 -3
- package/dist/lib/modules/core/schema/envelope.js +8 -24
- package/dist/lib/modules/core/schema/errors.js +7 -5
- package/dist/lib/modules/core/schema/guest-invitation.js +13 -0
- package/dist/lib/modules/core/schema/index.js +5 -0
- package/dist/lib/modules/core/schema/ipc/consent.js +97 -18
- package/dist/lib/modules/core/schema/ipc/conversation-views.js +87 -0
- package/dist/lib/modules/core/schema/ipc/conversations.js +132 -0
- package/dist/lib/modules/core/schema/ipc/device.js +9 -0
- package/dist/lib/modules/core/schema/ipc/jelly.js +17 -45
- package/dist/lib/modules/core/schema/ipc/shapes.js +74 -73
- package/dist/lib/modules/core/schema/ipc/surfaces.js +12 -195
- package/dist/lib/modules/core/schema/ipc/tasks.js +31 -0
- package/dist/lib/modules/core/schema/ipc.js +68 -46
- package/dist/lib/modules/core/testing.js +1 -1
- package/dist/lib/modules/core/version.js +1 -1
- package/dist/lib/modules/ipc/client.js +10 -2
- package/dist/lib/modules/ipc/server.js +14 -5
- package/dist/lib/modules/ipc/testing.js +13 -23
- package/dist/spec/messaging-v1.md +854 -445
- package/dist/third-party-notices.md +1 -1
- package/dist/third-party.json +1 -1
- package/dist/types/core/agent/operations.d.ts +5 -52
- package/dist/types/core/agent/present.d.ts +6 -21
- package/dist/types/core/agent-tools.d.ts +295 -442
- package/dist/types/core/consent.d.ts +30 -7
- package/dist/types/core/contact-card.d.ts +3 -3
- package/dist/types/core/conversation/event.d.ts +6 -6
- package/dist/types/core/conversation/guest-invitation.d.ts +8 -0
- package/dist/types/core/conversation/log.d.ts +28 -13
- package/dist/types/core/conversation/request-log.d.ts +24 -0
- package/dist/types/core/conversation/request-seal.d.ts +6 -0
- package/dist/types/core/conversation/requests.d.ts +14 -0
- package/dist/types/core/conversation/seal.d.ts +32 -9
- package/dist/types/core/conversation-agent-tools.d.ts +939 -0
- package/dist/types/core/federation/directory-proof.d.ts +8 -0
- package/dist/types/core/federation/proof-state.d.ts +114 -0
- package/dist/types/core/federation/roster-proof.d.ts +7 -0
- package/dist/types/core/index.d.ts +11 -6
- package/dist/types/core/jelly-host.d.ts +1 -1
- package/dist/types/core/schema/common.d.ts +33 -6
- package/dist/types/core/schema/consent.d.ts +29 -8
- package/dist/types/core/schema/contact-request.d.ts +264 -0
- package/dist/types/core/schema/conv-frames.d.ts +1204 -0
- package/dist/types/core/schema/conversation.d.ts +1410 -264
- package/dist/types/core/schema/directory-frames.d.ts +8 -3
- package/dist/types/core/schema/envelope.d.ts +85 -130
- package/dist/types/core/schema/errors.d.ts +5 -1
- package/dist/types/core/schema/guest-invitation.d.ts +51 -0
- package/dist/types/core/schema/index.d.ts +5 -0
- package/dist/types/core/schema/ipc/consent.d.ts +464 -62
- package/dist/types/core/schema/ipc/conversation-views.d.ts +1199 -0
- package/dist/types/core/schema/ipc/conversations.d.ts +4355 -0
- package/dist/types/core/schema/ipc/device.d.ts +10 -0
- package/dist/types/core/schema/ipc/jelly.d.ts +16 -111
- package/dist/types/core/schema/ipc/shapes.d.ts +211 -95
- package/dist/types/core/schema/ipc/surfaces.d.ts +26 -427
- package/dist/types/core/schema/ipc/tasks.d.ts +210 -0
- package/dist/types/core/schema/ipc.d.ts +3859 -890
- package/dist/types/core/schema/relay.d.ts +12 -4
- package/dist/types/core/testing.d.ts +1 -1
- package/dist/types/core/version.d.ts +1 -1
- package/dist/types/ipc/client.d.ts +4 -1
- package/dist/types/ipc/server.d.ts +16 -1
- package/dist/types/ipc/testing.d.ts +21 -8
- 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
|
|
59
|
-
export async function until(predicate,
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
96
|
-
const
|
|
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,
|