@joe-broadhead/messaging 0.7.0 → 0.8.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 (97) hide show
  1. package/CHANGELOG.md +259 -2
  2. package/dist/bin/messaging-mcp.js +5484 -3858
  3. package/dist/bin/messaging-relay.js +4728 -1136
  4. package/dist/bin/messaging.js +4616 -2807
  5. package/dist/bin/messagingd.js +16451 -9444
  6. package/dist/lib/modules/core/agent/operations.js +19 -327
  7. package/dist/lib/modules/core/agent/present.js +15 -55
  8. package/dist/lib/modules/core/agent-tools.js +46 -143
  9. package/dist/lib/modules/core/consent.js +1 -1
  10. package/dist/lib/modules/core/conversation/context.js +80 -0
  11. package/dist/lib/modules/core/conversation/event.js +125 -0
  12. package/dist/lib/modules/core/conversation/guest-invitation.js +42 -0
  13. package/dist/lib/modules/core/conversation/ids.js +38 -0
  14. package/dist/lib/modules/core/conversation/link.js +35 -0
  15. package/dist/lib/modules/core/conversation/log.js +988 -0
  16. package/dist/lib/modules/core/conversation/ratchet.js +243 -0
  17. package/dist/lib/modules/core/conversation/request-log.js +158 -0
  18. package/dist/lib/modules/core/conversation/request-seal.js +41 -0
  19. package/dist/lib/modules/core/conversation/requests.js +87 -0
  20. package/dist/lib/modules/core/conversation/seal.js +251 -0
  21. package/dist/lib/modules/core/conversation-agent-tools.js +69 -0
  22. package/dist/lib/modules/core/federation/directory-proof.js +83 -0
  23. package/dist/lib/modules/core/federation/proof-state.js +167 -0
  24. package/dist/lib/modules/core/federation/roster-proof.js +74 -0
  25. package/dist/lib/modules/core/index.js +16 -2
  26. package/dist/lib/modules/core/jelly-host.js +5 -5
  27. package/dist/lib/modules/core/schema/common.js +85 -3
  28. package/dist/lib/modules/core/schema/consent.js +5 -4
  29. package/dist/lib/modules/core/schema/contact-request.js +22 -0
  30. package/dist/lib/modules/core/schema/conv-frames.js +94 -0
  31. package/dist/lib/modules/core/schema/conversation.js +326 -0
  32. package/dist/lib/modules/core/schema/envelope.js +8 -24
  33. package/dist/lib/modules/core/schema/errors.js +42 -2
  34. package/dist/lib/modules/core/schema/guest-invitation.js +13 -0
  35. package/dist/lib/modules/core/schema/index.js +6 -0
  36. package/dist/lib/modules/core/schema/ipc/consent.js +13 -9
  37. package/dist/lib/modules/core/schema/ipc/conversation-views.js +80 -0
  38. package/dist/lib/modules/core/schema/ipc/conversations.js +128 -0
  39. package/dist/lib/modules/core/schema/ipc/device.js +2 -0
  40. package/dist/lib/modules/core/schema/ipc/jelly.js +3 -38
  41. package/dist/lib/modules/core/schema/ipc/shapes.js +14 -72
  42. package/dist/lib/modules/core/schema/ipc/surfaces.js +12 -195
  43. package/dist/lib/modules/core/schema/ipc/tasks.js +31 -0
  44. package/dist/lib/modules/core/schema/ipc.js +18 -44
  45. package/dist/lib/modules/core/testing.js +1 -0
  46. package/dist/lib/modules/core/version.js +1 -1
  47. package/dist/lib/modules/ipc/client.js +10 -2
  48. package/dist/lib/modules/ipc/server.js +14 -5
  49. package/dist/lib/modules/ipc/testing.js +13 -23
  50. package/dist/spec/messaging-v1.md +835 -380
  51. package/dist/third-party-notices.md +1 -1
  52. package/dist/third-party.json +1 -1
  53. package/dist/types/core/agent/operations.d.ts +5 -52
  54. package/dist/types/core/agent/present.d.ts +6 -21
  55. package/dist/types/core/agent-tools.d.ts +277 -438
  56. package/dist/types/core/conversation/context.d.ts +56 -0
  57. package/dist/types/core/conversation/event.d.ts +36 -0
  58. package/dist/types/core/conversation/guest-invitation.d.ts +8 -0
  59. package/dist/types/core/conversation/ids.d.ts +18 -0
  60. package/dist/types/core/conversation/link.d.ts +16 -0
  61. package/dist/types/core/conversation/log.d.ts +157 -0
  62. package/dist/types/core/conversation/ratchet.d.ts +95 -0
  63. package/dist/types/core/conversation/request-log.d.ts +24 -0
  64. package/dist/types/core/conversation/request-seal.d.ts +6 -0
  65. package/dist/types/core/conversation/requests.d.ts +14 -0
  66. package/dist/types/core/conversation/seal.d.ts +70 -0
  67. package/dist/types/core/conversation-agent-tools.d.ts +918 -0
  68. package/dist/types/core/federation/directory-proof.d.ts +8 -0
  69. package/dist/types/core/federation/proof-state.d.ts +114 -0
  70. package/dist/types/core/federation/roster-proof.d.ts +7 -0
  71. package/dist/types/core/index.d.ts +15 -3
  72. package/dist/types/core/jelly-host.d.ts +1 -1
  73. package/dist/types/core/schema/common.d.ts +85 -4
  74. package/dist/types/core/schema/consent.d.ts +7 -7
  75. package/dist/types/core/schema/contact-request.d.ts +264 -0
  76. package/dist/types/core/schema/conv-frames.d.ts +1200 -0
  77. package/dist/types/core/schema/conversation.d.ts +2803 -0
  78. package/dist/types/core/schema/envelope.d.ts +89 -130
  79. package/dist/types/core/schema/errors.d.ts +40 -0
  80. package/dist/types/core/schema/guest-invitation.d.ts +51 -0
  81. package/dist/types/core/schema/index.d.ts +6 -0
  82. package/dist/types/core/schema/ipc/consent.d.ts +89 -49
  83. package/dist/types/core/schema/ipc/conversation-views.d.ts +1023 -0
  84. package/dist/types/core/schema/ipc/conversations.d.ts +3987 -0
  85. package/dist/types/core/schema/ipc/device.d.ts +10 -0
  86. package/dist/types/core/schema/ipc/jelly.d.ts +2 -105
  87. package/dist/types/core/schema/ipc/shapes.d.ts +16 -95
  88. package/dist/types/core/schema/ipc/surfaces.d.ts +28 -424
  89. package/dist/types/core/schema/ipc/tasks.d.ts +208 -0
  90. package/dist/types/core/schema/ipc.d.ts +2684 -523
  91. package/dist/types/core/schema/relay.d.ts +20 -4
  92. package/dist/types/core/testing.d.ts +1 -0
  93. package/dist/types/core/version.d.ts +1 -1
  94. package/dist/types/ipc/client.d.ts +4 -1
  95. package/dist/types/ipc/server.d.ts +10 -1
  96. package/dist/types/ipc/testing.d.ts +21 -8
  97. package/package.json +1 -1
@@ -68,6 +68,7 @@ export declare const NackFrame: z.ZodObject<{
68
68
  refused: "refused";
69
69
  declined: "declined";
70
70
  request_required: "request_required";
71
+ peer_outdated: "peer_outdated";
71
72
  rate_limited: "rate_limited";
72
73
  loop_guard: "loop_guard";
73
74
  too_large: "too_large";
@@ -84,6 +85,8 @@ export declare const NackFrame: z.ZodObject<{
84
85
  binding_invalid: "binding_invalid";
85
86
  jelly_unavailable: "jelly_unavailable";
86
87
  log_conflict: "log_conflict";
88
+ conv_conflict: "conv_conflict";
89
+ stale_epoch: "stale_epoch";
87
90
  device_limit: "device_limit";
88
91
  admission_required: "admission_required";
89
92
  admission_invalid: "admission_invalid";
@@ -98,6 +101,7 @@ export declare const NackFrame: z.ZodObject<{
98
101
  ticket_invalid: "ticket_invalid";
99
102
  daemon_unavailable: "daemon_unavailable";
100
103
  daemon_mismatch: "daemon_mismatch";
104
+ store_refused: "store_refused";
101
105
  internal: "internal";
102
106
  }>;
103
107
  message: z.ZodString;
@@ -269,6 +273,7 @@ export declare const ErrorFrame: z.ZodObject<{
269
273
  refused: "refused";
270
274
  declined: "declined";
271
275
  request_required: "request_required";
276
+ peer_outdated: "peer_outdated";
272
277
  rate_limited: "rate_limited";
273
278
  loop_guard: "loop_guard";
274
279
  too_large: "too_large";
@@ -285,6 +290,8 @@ export declare const ErrorFrame: z.ZodObject<{
285
290
  binding_invalid: "binding_invalid";
286
291
  jelly_unavailable: "jelly_unavailable";
287
292
  log_conflict: "log_conflict";
293
+ conv_conflict: "conv_conflict";
294
+ stale_epoch: "stale_epoch";
288
295
  device_limit: "device_limit";
289
296
  admission_required: "admission_required";
290
297
  admission_invalid: "admission_invalid";
@@ -299,6 +306,7 @@ export declare const ErrorFrame: z.ZodObject<{
299
306
  ticket_invalid: "ticket_invalid";
300
307
  daemon_unavailable: "daemon_unavailable";
301
308
  daemon_mismatch: "daemon_mismatch";
309
+ store_refused: "store_refused";
302
310
  internal: "internal";
303
311
  }>;
304
312
  message: z.ZodString;
@@ -344,6 +352,7 @@ export declare const RelayToClient: z.ZodDiscriminatedUnion<[z.ZodObject<{
344
352
  refused: "refused";
345
353
  declined: "declined";
346
354
  request_required: "request_required";
355
+ peer_outdated: "peer_outdated";
347
356
  rate_limited: "rate_limited";
348
357
  loop_guard: "loop_guard";
349
358
  too_large: "too_large";
@@ -360,6 +369,8 @@ export declare const RelayToClient: z.ZodDiscriminatedUnion<[z.ZodObject<{
360
369
  binding_invalid: "binding_invalid";
361
370
  jelly_unavailable: "jelly_unavailable";
362
371
  log_conflict: "log_conflict";
372
+ conv_conflict: "conv_conflict";
373
+ stale_epoch: "stale_epoch";
363
374
  device_limit: "device_limit";
364
375
  admission_required: "admission_required";
365
376
  admission_invalid: "admission_invalid";
@@ -374,6 +385,7 @@ export declare const RelayToClient: z.ZodDiscriminatedUnion<[z.ZodObject<{
374
385
  ticket_invalid: "ticket_invalid";
375
386
  daemon_unavailable: "daemon_unavailable";
376
387
  daemon_mismatch: "daemon_mismatch";
388
+ store_refused: "store_refused";
377
389
  internal: "internal";
378
390
  }>;
379
391
  message: z.ZodString;
@@ -540,6 +552,7 @@ export declare const RelayToClient: z.ZodDiscriminatedUnion<[z.ZodObject<{
540
552
  refused: "refused";
541
553
  declined: "declined";
542
554
  request_required: "request_required";
555
+ peer_outdated: "peer_outdated";
543
556
  rate_limited: "rate_limited";
544
557
  loop_guard: "loop_guard";
545
558
  too_large: "too_large";
@@ -556,6 +569,8 @@ export declare const RelayToClient: z.ZodDiscriminatedUnion<[z.ZodObject<{
556
569
  binding_invalid: "binding_invalid";
557
570
  jelly_unavailable: "jelly_unavailable";
558
571
  log_conflict: "log_conflict";
572
+ conv_conflict: "conv_conflict";
573
+ stale_epoch: "stale_epoch";
559
574
  device_limit: "device_limit";
560
575
  admission_required: "admission_required";
561
576
  admission_invalid: "admission_invalid";
@@ -570,6 +585,7 @@ export declare const RelayToClient: z.ZodDiscriminatedUnion<[z.ZodObject<{
570
585
  ticket_invalid: "ticket_invalid";
571
586
  daemon_unavailable: "daemon_unavailable";
572
587
  daemon_mismatch: "daemon_mismatch";
588
+ store_refused: "store_refused";
573
589
  internal: "internal";
574
590
  }>;
575
591
  message: z.ZodString;
@@ -737,9 +753,9 @@ export declare const SendFrame: z.ZodObject<{
737
753
  realm: z.ZodString;
738
754
  type: z.ZodEnum<{
739
755
  message: "message";
740
- "task.cancel": "task.cancel";
741
756
  receipt: "receipt";
742
757
  presence: "presence";
758
+ "task.cancel": "task.cancel";
743
759
  "task.status": "task.status";
744
760
  "task.artifact": "task.artifact";
745
761
  }>;
@@ -794,9 +810,9 @@ export declare const PresenceFrame: z.ZodObject<{
794
810
  realm: z.ZodString;
795
811
  type: z.ZodEnum<{
796
812
  message: "message";
797
- "task.cancel": "task.cancel";
798
813
  receipt: "receipt";
799
814
  presence: "presence";
815
+ "task.cancel": "task.cancel";
800
816
  "task.status": "task.status";
801
817
  "task.artifact": "task.artifact";
802
818
  }>;
@@ -1004,9 +1020,9 @@ export declare const ClientToRelay: z.ZodDiscriminatedUnion<[z.ZodObject<{
1004
1020
  realm: z.ZodString;
1005
1021
  type: z.ZodEnum<{
1006
1022
  message: "message";
1007
- "task.cancel": "task.cancel";
1008
1023
  receipt: "receipt";
1009
1024
  presence: "presence";
1025
+ "task.cancel": "task.cancel";
1010
1026
  "task.status": "task.status";
1011
1027
  "task.artifact": "task.artifact";
1012
1028
  }>;
@@ -1059,9 +1075,9 @@ export declare const ClientToRelay: z.ZodDiscriminatedUnion<[z.ZodObject<{
1059
1075
  realm: z.ZodString;
1060
1076
  type: z.ZodEnum<{
1061
1077
  message: "message";
1062
- "task.cancel": "task.cancel";
1063
1078
  receipt: "receipt";
1064
1079
  presence: "presence";
1080
+ "task.cancel": "task.cancel";
1065
1081
  "task.status": "task.status";
1066
1082
  "task.artifact": "task.artifact";
1067
1083
  }>;
@@ -7,6 +7,7 @@ export { encodeTicket } from "./roster.js";
7
7
  export { grantHash } from "./delegation.js";
8
8
  export { signJellyToken } from "./directory/jelly-issuer.js";
9
9
  export { jellyHostDouble, type JellyHostDouble } from "./jelly-host-double.js";
10
+ export { sealConvMetaWith, sealConvMsgWith, sealConvStateWith, sealKeyShareWith, type ShareRandomness } from "./conversation/seal.js";
10
11
  /**
11
12
  * Narrows a result whose `kind` tells its shape (`item.read`, `conv.read`) to the expected kind, and
12
13
  * throws with both kinds named otherwise: `client.call("item.read", p).then(asKind("received"))`.
@@ -3,4 +3,4 @@
3
3
  * its IPC hello and a client compares it with its own (spec §8.2). A test keeps it equal to the
4
4
  * root package.json.
5
5
  */
6
- export declare const VERSION = "0.7.0";
6
+ export declare const VERSION = "0.8.0";
@@ -1,4 +1,4 @@
1
- import { IpcEvent, IpcHello, MessagingError, type IpcMethod, type IpcParams, type IpcResult } from "../core/index.js";
1
+ import { IpcEvent, IpcHello, MessagingError, type IpcMethod, type IpcParams, type IpcResult, type ConversationMethod, type ConversationParams, type ConversationResult } from "../core/index.js";
2
2
  import { type SocketTier } from "./paths.js";
3
3
  export interface ClientOptions {
4
4
  /** Explicit socket path (on Windows, the pipe pointer file). Defaults to the `tier` socket of `home`. */
@@ -76,6 +76,9 @@ export declare class MessagingClient {
76
76
  get daemon(): IpcHello;
77
77
  get closed(): boolean;
78
78
  call<M extends IpcMethod>(method: M, params: IpcParams<M>, options?: CallOptions): Promise<IpcResult<M>>;
79
+ /** The staged conversation contract. Use only with a server that opted into it, until cut-over. */
80
+ callConversation<M extends ConversationMethod>(method: M, params: ConversationParams<M>, options?: CallOptions): Promise<ConversationResult<M>>;
81
+ private callWith;
79
82
  onEvent(listener: (event: IpcEvent) => void): () => void;
80
83
  onClose(listener: (error?: Error) => void): () => void;
81
84
  close(): void;
@@ -1,5 +1,5 @@
1
1
  import type { z } from "zod";
2
- import { IpcEvent, type IpcMethod, type IpcMethods, type IpcResult } from "../core/index.js";
2
+ import { IpcEvent, type IpcMethod, type IpcMethods, type IpcResult, type ConversationMethod, type ConversationParams, type ConversationResult } from "../core/index.js";
3
3
  import { type SocketTier } from "./paths.js";
4
4
  export interface ConnectionContext {
5
5
  /** Unique across every server in this process, so a daemon with two sockets can key state by it. */
@@ -34,6 +34,11 @@ export type Handler<M extends IpcMethod> = (params: z.output<IpcMethods[M]["para
34
34
  export type Handlers = {
35
35
  [M in IpcMethod]?: Handler<M>;
36
36
  };
37
+ /** Handler types for the opt-in conversation contract test server. */
38
+ export type ConversationHandler<M extends ConversationMethod> = (params: ConversationParams<M>, ctx: ConnectionContext, authority: CallAuthority | undefined) => Promise<ConversationResult<M>> | ConversationResult<M>;
39
+ export type ConversationHandlers = {
40
+ [M in ConversationMethod]?: ConversationHandler<M>;
41
+ };
37
42
  export interface IpcServerOptions {
38
43
  socketPath: string;
39
44
  /**
@@ -92,3 +97,7 @@ export interface IpcServer {
92
97
  * `group` is refused there: Node cannot give a pipe to a group.
93
98
  */
94
99
  export declare function createIpcServer(options: IpcServerOptions): Promise<IpcServer>;
100
+ /** Used only by the test entry: never changes the real daemon's method table. */
101
+ export declare function createConversationIpcServerForTesting(options: Omit<IpcServerOptions, "handlers" | "authorize"> & {
102
+ handlers: ConversationHandlers;
103
+ }): Promise<IpcServer>;
@@ -1,8 +1,8 @@
1
1
  import type net from "node:net";
2
- import { type IpcEvent, type IpcMethod } from "../core/index.js";
2
+ import { CONVERSATION_METHODS, type ConversationMethod, type IpcEvent, type IpcMethod } from "../core/index.js";
3
3
  import { MessagingClient } from "./client.js";
4
4
  import { type SocketTier } from "./paths.js";
5
- import { type Handler, type Handlers } from "./server.js";
5
+ import { type ConversationHandler, type ConversationHandlers, type Handler, type Handlers } from "./server.js";
6
6
  /**
7
7
  * `@messaging/ipc/testing`: helpers for tests only. Production code never imports this entry point.
8
8
  *
@@ -26,8 +26,8 @@ export declare function listenAt(server: net.Server, socketPath: string, { pid }
26
26
  export declare function rawEndpoint(socketPath: string): string;
27
27
  /** A deterministic ULID for test fixtures: `ulid(7)` is `01JC0000000000000000000007`. */
28
28
  export declare function ulid(n: number): string;
29
- /** Polls `predicate` every 10 ms until it holds; throws after `timeoutMs`. */
30
- export declare function until(predicate: () => boolean, timeoutMs?: number, what?: string): Promise<void>;
29
+ /** Polls state with no notification; the enclosing test's timeout is the single bound. Legacy timeout and label are ignored. */
30
+ export declare function until(predicate: () => boolean, _timeoutMs?: number, _what?: string): Promise<void>;
31
31
  /** One call the fake received: the method and a copy of its parsed params, taken before its handler ran. */
32
32
  export interface Recorded {
33
33
  method: IpcMethod;
@@ -35,6 +35,7 @@ export interface Recorded {
35
35
  }
36
36
  export type Params<M extends IpcMethod> = Parameters<Handler<M>>[0];
37
37
  export interface RecordingDaemonOptions {
38
+ methods?: never;
38
39
  /** Handlers by method; `handle` adds or replaces one later. Every other method is refused with `forbidden`. */
39
40
  handlers?: Handlers;
40
41
  /** Prefix of the temp home the fake creates (and removes on `close`). */
@@ -69,10 +70,6 @@ export interface RecordingDaemon {
69
70
  handle<M extends IpcMethod>(method: M, handler: Handler<M>): void;
70
71
  /** `IpcServer.publish`: to every connection that subscribed to the event's key (key-less: to all of them). */
71
72
  publish(event: IpcEvent): void;
72
- /** A `conv` event to the connections whose `conv.subscribe` succeeded, as messagingd sends it. */
73
- conv(event: Extract<IpcEvent, {
74
- type: "conv";
75
- }>): void;
76
73
  /** A client on the agent socket, or the `admin` one. */
77
74
  connect(tier?: SocketTier): Promise<MessagingClient>;
78
75
  /** Open connections on both sockets. */
@@ -86,4 +83,20 @@ export interface RecordingDaemon {
86
83
  /** `stop`, and remove the temp home the fake created. */
87
84
  close(): Promise<void>;
88
85
  }
86
+ export interface ConversationRecordingDaemonOptions extends Omit<RecordingDaemonOptions, "handlers" | "methods"> {
87
+ /** Opt into the full conversation contract, including staged methods, instead of the live table. */
88
+ methods: typeof CONVERSATION_METHODS;
89
+ handlers?: ConversationHandlers;
90
+ }
91
+ export interface ConversationRecordingDaemon extends Omit<RecordingDaemon, "calls" | "methods" | "callsTo" | "last" | "handle"> {
92
+ readonly calls: {
93
+ method: ConversationMethod;
94
+ params: Record<string, unknown>;
95
+ }[];
96
+ methods(): ConversationMethod[];
97
+ callsTo<M extends ConversationMethod>(method: M): Parameters<ConversationHandler<M>>[0][];
98
+ last<M extends ConversationMethod>(method: M): Parameters<ConversationHandler<M>>[0] | undefined;
99
+ handle<M extends ConversationMethod>(method: M, handler: ConversationHandler<M>): void;
100
+ }
89
101
  export declare function recordingDaemon(options?: RecordingDaemonOptions): Promise<RecordingDaemon>;
102
+ export declare function recordingDaemon(options: ConversationRecordingDaemonOptions): Promise<ConversationRecordingDaemon>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@joe-broadhead/messaging",
3
- "version": "0.7.0",
3
+ "version": "0.8.0",
4
4
  "description": "Messaging: the relay, the per-machine daemon and its CLI, and the MCP server as bundled single files, plus the client libraries and the protocol spec. Zero dependencies.",
5
5
  "type": "module",
6
6
  "license": "MIT",