@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
@@ -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";
@@ -85,6 +86,7 @@ export declare const NackFrame: z.ZodObject<{
85
86
  jelly_unavailable: "jelly_unavailable";
86
87
  log_conflict: "log_conflict";
87
88
  conv_conflict: "conv_conflict";
89
+ conflict: "conflict";
88
90
  stale_epoch: "stale_epoch";
89
91
  device_limit: "device_limit";
90
92
  admission_required: "admission_required";
@@ -272,6 +274,7 @@ export declare const ErrorFrame: z.ZodObject<{
272
274
  refused: "refused";
273
275
  declined: "declined";
274
276
  request_required: "request_required";
277
+ peer_outdated: "peer_outdated";
275
278
  rate_limited: "rate_limited";
276
279
  loop_guard: "loop_guard";
277
280
  too_large: "too_large";
@@ -289,6 +292,7 @@ export declare const ErrorFrame: z.ZodObject<{
289
292
  jelly_unavailable: "jelly_unavailable";
290
293
  log_conflict: "log_conflict";
291
294
  conv_conflict: "conv_conflict";
295
+ conflict: "conflict";
292
296
  stale_epoch: "stale_epoch";
293
297
  device_limit: "device_limit";
294
298
  admission_required: "admission_required";
@@ -350,6 +354,7 @@ export declare const RelayToClient: z.ZodDiscriminatedUnion<[z.ZodObject<{
350
354
  refused: "refused";
351
355
  declined: "declined";
352
356
  request_required: "request_required";
357
+ peer_outdated: "peer_outdated";
353
358
  rate_limited: "rate_limited";
354
359
  loop_guard: "loop_guard";
355
360
  too_large: "too_large";
@@ -367,6 +372,7 @@ export declare const RelayToClient: z.ZodDiscriminatedUnion<[z.ZodObject<{
367
372
  jelly_unavailable: "jelly_unavailable";
368
373
  log_conflict: "log_conflict";
369
374
  conv_conflict: "conv_conflict";
375
+ conflict: "conflict";
370
376
  stale_epoch: "stale_epoch";
371
377
  device_limit: "device_limit";
372
378
  admission_required: "admission_required";
@@ -549,6 +555,7 @@ export declare const RelayToClient: z.ZodDiscriminatedUnion<[z.ZodObject<{
549
555
  refused: "refused";
550
556
  declined: "declined";
551
557
  request_required: "request_required";
558
+ peer_outdated: "peer_outdated";
552
559
  rate_limited: "rate_limited";
553
560
  loop_guard: "loop_guard";
554
561
  too_large: "too_large";
@@ -566,6 +573,7 @@ export declare const RelayToClient: z.ZodDiscriminatedUnion<[z.ZodObject<{
566
573
  jelly_unavailable: "jelly_unavailable";
567
574
  log_conflict: "log_conflict";
568
575
  conv_conflict: "conv_conflict";
576
+ conflict: "conflict";
569
577
  stale_epoch: "stale_epoch";
570
578
  device_limit: "device_limit";
571
579
  admission_required: "admission_required";
@@ -749,9 +757,9 @@ export declare const SendFrame: z.ZodObject<{
749
757
  realm: z.ZodString;
750
758
  type: z.ZodEnum<{
751
759
  message: "message";
752
- "task.cancel": "task.cancel";
753
760
  receipt: "receipt";
754
761
  presence: "presence";
762
+ "task.cancel": "task.cancel";
755
763
  "task.status": "task.status";
756
764
  "task.artifact": "task.artifact";
757
765
  }>;
@@ -806,9 +814,9 @@ export declare const PresenceFrame: z.ZodObject<{
806
814
  realm: z.ZodString;
807
815
  type: z.ZodEnum<{
808
816
  message: "message";
809
- "task.cancel": "task.cancel";
810
817
  receipt: "receipt";
811
818
  presence: "presence";
819
+ "task.cancel": "task.cancel";
812
820
  "task.status": "task.status";
813
821
  "task.artifact": "task.artifact";
814
822
  }>;
@@ -1016,9 +1024,9 @@ export declare const ClientToRelay: z.ZodDiscriminatedUnion<[z.ZodObject<{
1016
1024
  realm: z.ZodString;
1017
1025
  type: z.ZodEnum<{
1018
1026
  message: "message";
1019
- "task.cancel": "task.cancel";
1020
1027
  receipt: "receipt";
1021
1028
  presence: "presence";
1029
+ "task.cancel": "task.cancel";
1022
1030
  "task.status": "task.status";
1023
1031
  "task.artifact": "task.artifact";
1024
1032
  }>;
@@ -1071,9 +1079,9 @@ export declare const ClientToRelay: z.ZodDiscriminatedUnion<[z.ZodObject<{
1071
1079
  realm: z.ZodString;
1072
1080
  type: z.ZodEnum<{
1073
1081
  message: "message";
1074
- "task.cancel": "task.cancel";
1075
1082
  receipt: "receipt";
1076
1083
  presence: "presence";
1084
+ "task.cancel": "task.cancel";
1077
1085
  "task.status": "task.status";
1078
1086
  "task.artifact": "task.artifact";
1079
1087
  }>;
@@ -7,7 +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, sealKeySharesWith, type ShareRandomness } from "./conversation/seal.js";
10
+ export { sealConvMetaWith, sealConvMsgWith, sealConvStateWith, sealKeyShareWith, type ShareRandomness } from "./conversation/seal.js";
11
11
  /**
12
12
  * Narrows a result whose `kind` tells its shape (`item.read`, `conv.read`) to the expected kind, and
13
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.1";
6
+ export declare const VERSION = "0.9.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. */
@@ -20,6 +20,12 @@ export interface ConnectionContext {
20
20
  export interface CallAuthority {
21
21
  readonly scope: "action" | "host";
22
22
  readonly expiresAt: number;
23
+ /**
24
+ * The grant's `dev` and `mbr` (Jelly's device and member), as signed by the host. They give no authority; an action
25
+ * token rendered under them is bound to them (spec §8.2, "Action tokens").
26
+ */
27
+ readonly dev?: string | undefined;
28
+ readonly mbr?: string | undefined;
23
29
  }
24
30
  /** One call as `authorize` sees it: before its params are parsed, with the request's `grant` member. */
25
31
  export interface AuthorizeCall {
@@ -34,6 +40,11 @@ export type Handler<M extends IpcMethod> = (params: z.output<IpcMethods[M]["para
34
40
  export type Handlers = {
35
41
  [M in IpcMethod]?: Handler<M>;
36
42
  };
43
+ /** Handler types for the opt-in conversation contract test server. */
44
+ export type ConversationHandler<M extends ConversationMethod> = (params: ConversationParams<M>, ctx: ConnectionContext, authority: CallAuthority | undefined) => Promise<ConversationResult<M>> | ConversationResult<M>;
45
+ export type ConversationHandlers = {
46
+ [M in ConversationMethod]?: ConversationHandler<M>;
47
+ };
37
48
  export interface IpcServerOptions {
38
49
  socketPath: string;
39
50
  /**
@@ -92,3 +103,7 @@ export interface IpcServer {
92
103
  * `group` is refused there: Node cannot give a pipe to a group.
93
104
  */
94
105
  export declare function createIpcServer(options: IpcServerOptions): Promise<IpcServer>;
106
+ /** Used only by the test entry: never changes the real daemon's method table. */
107
+ export declare function createConversationIpcServerForTesting(options: Omit<IpcServerOptions, "handlers" | "authorize"> & {
108
+ handlers: ConversationHandlers;
109
+ }): 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.1",
3
+ "version": "0.9.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",