@joe-broadhead/messaging 0.0.0-stage → 0.7.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 (257) hide show
  1. package/CHANGELOG.md +175 -0
  2. package/LICENSE +21 -0
  3. package/NOTICE +12 -0
  4. package/README.md +36 -2
  5. package/dist/bin/messaging-mcp.js +25887 -0
  6. package/dist/bin/messaging-relay.js +19014 -0
  7. package/dist/bin/messaging.js +14732 -0
  8. package/dist/bin/messagingd.js +28682 -0
  9. package/dist/lib/core-testing.js +1 -0
  10. package/dist/lib/core.js +1 -0
  11. package/dist/lib/ipc-testing.js +1 -0
  12. package/dist/lib/ipc.js +1 -0
  13. package/dist/lib/modules/core/address.js +42 -0
  14. package/dist/lib/modules/core/agent/operations.js +595 -0
  15. package/dist/lib/modules/core/agent/present.js +244 -0
  16. package/dist/lib/modules/core/agent/text.js +79 -0
  17. package/dist/lib/modules/core/agent-tools.js +458 -0
  18. package/dist/lib/modules/core/b64u.js +20 -0
  19. package/dist/lib/modules/core/cards.js +55 -0
  20. package/dist/lib/modules/core/check.js +20 -0
  21. package/dist/lib/modules/core/consent.js +199 -0
  22. package/dist/lib/modules/core/contact-card.js +74 -0
  23. package/dist/lib/modules/core/delegation.js +174 -0
  24. package/dist/lib/modules/core/directory/device-log.js +258 -0
  25. package/dist/lib/modules/core/directory/epoch.js +103 -0
  26. package/dist/lib/modules/core/directory/handle.js +29 -0
  27. package/dist/lib/modules/core/directory/jelly-device.js +204 -0
  28. package/dist/lib/modules/core/directory/jelly-issuer.js +12 -0
  29. package/dist/lib/modules/core/directory/jelly-token.js +305 -0
  30. package/dist/lib/modules/core/directory/keys-statement.js +43 -0
  31. package/dist/lib/modules/core/directory/link.js +81 -0
  32. package/dist/lib/modules/core/directory/merkle-log.js +250 -0
  33. package/dist/lib/modules/core/directory/person-view.js +197 -0
  34. package/dist/lib/modules/core/directory/person.js +40 -0
  35. package/dist/lib/modules/core/directory/realm.js +59 -0
  36. package/dist/lib/modules/core/directory/smt.js +266 -0
  37. package/dist/lib/modules/core/envelope.js +320 -0
  38. package/dist/lib/modules/core/hash.js +5 -0
  39. package/dist/lib/modules/core/head.js +27 -0
  40. package/dist/lib/modules/core/identity.js +71 -0
  41. package/dist/lib/modules/core/index.js +44 -0
  42. package/dist/lib/modules/core/jcs.js +96 -0
  43. package/dist/lib/modules/core/jelly-host-double.js +35 -0
  44. package/dist/lib/modules/core/jelly-host.js +211 -0
  45. package/dist/lib/modules/core/keys.js +79 -0
  46. package/dist/lib/modules/core/peer-text.js +563 -0
  47. package/dist/lib/modules/core/realm.js +1 -0
  48. package/dist/lib/modules/core/roster.js +454 -0
  49. package/dist/lib/modules/core/schema/a2a.js +85 -0
  50. package/dist/lib/modules/core/schema/common.js +254 -0
  51. package/dist/lib/modules/core/schema/consent.js +120 -0
  52. package/dist/lib/modules/core/schema/delegation.js +58 -0
  53. package/dist/lib/modules/core/schema/directory-frames.js +270 -0
  54. package/dist/lib/modules/core/schema/directory.js +169 -0
  55. package/dist/lib/modules/core/schema/envelope.js +211 -0
  56. package/dist/lib/modules/core/schema/errors.js +65 -0
  57. package/dist/lib/modules/core/schema/index.js +15 -0
  58. package/dist/lib/modules/core/schema/ipc/consent.js +181 -0
  59. package/dist/lib/modules/core/schema/ipc/device.js +276 -0
  60. package/dist/lib/modules/core/schema/ipc/jelly.js +189 -0
  61. package/dist/lib/modules/core/schema/ipc/shapes.js +185 -0
  62. package/dist/lib/modules/core/schema/ipc/surfaces.js +223 -0
  63. package/dist/lib/modules/core/schema/ipc.js +451 -0
  64. package/dist/lib/modules/core/schema/jelly.js +122 -0
  65. package/dist/lib/modules/core/schema/realm.js +27 -0
  66. package/dist/lib/modules/core/schema/relay.js +112 -0
  67. package/dist/lib/modules/core/schema/roster.js +126 -0
  68. package/dist/lib/modules/core/sign.js +43 -0
  69. package/dist/lib/modules/core/task.js +37 -0
  70. package/dist/lib/modules/core/testing.js +20 -0
  71. package/dist/lib/modules/core/ulid.js +36 -0
  72. package/dist/lib/modules/core/version.js +6 -0
  73. package/dist/lib/modules/core/wire.js +255 -0
  74. package/dist/lib/modules/ipc/client.js +289 -0
  75. package/dist/lib/modules/ipc/framing.js +33 -0
  76. package/dist/lib/modules/ipc/index.js +6 -0
  77. package/dist/lib/modules/ipc/paths.js +102 -0
  78. package/dist/lib/modules/ipc/pipes.js +65 -0
  79. package/dist/lib/modules/ipc/rpc.js +8 -0
  80. package/dist/lib/modules/ipc/server.js +317 -0
  81. package/dist/lib/modules/ipc/testing.js +145 -0
  82. package/dist/lib/modules/ipc/trust.js +166 -0
  83. package/dist/lib/modules/ipc/windows-acl.js +275 -0
  84. package/dist/lib/modules/vendor/zod/index.js +7 -0
  85. package/dist/lib/modules/vendor/zod/v4/classic/checks.js +1 -0
  86. package/dist/lib/modules/vendor/zod/v4/classic/coerce.js +17 -0
  87. package/dist/lib/modules/vendor/zod/v4/classic/compat.js +31 -0
  88. package/dist/lib/modules/vendor/zod/v4/classic/deep-partial.js +13 -0
  89. package/dist/lib/modules/vendor/zod/v4/classic/errors.js +57 -0
  90. package/dist/lib/modules/vendor/zod/v4/classic/external.js +17 -0
  91. package/dist/lib/modules/vendor/zod/v4/classic/from-json-schema.js +881 -0
  92. package/dist/lib/modules/vendor/zod/v4/classic/in-out.js +36 -0
  93. package/dist/lib/modules/vendor/zod/v4/classic/iso.js +15 -0
  94. package/dist/lib/modules/vendor/zod/v4/classic/parse.js +16 -0
  95. package/dist/lib/modules/vendor/zod/v4/classic/schemas.js +1535 -0
  96. package/dist/lib/modules/vendor/zod/v4/core/api.js +1107 -0
  97. package/dist/lib/modules/vendor/zod/v4/core/checks.js +516 -0
  98. package/dist/lib/modules/vendor/zod/v4/core/compile.js +1866 -0
  99. package/dist/lib/modules/vendor/zod/v4/core/core.js +141 -0
  100. package/dist/lib/modules/vendor/zod/v4/core/doc.js +38 -0
  101. package/dist/lib/modules/vendor/zod/v4/core/errors.js +267 -0
  102. package/dist/lib/modules/vendor/zod/v4/core/index.js +19 -0
  103. package/dist/lib/modules/vendor/zod/v4/core/json-schema-generator.js +99 -0
  104. package/dist/lib/modules/vendor/zod/v4/core/json-schema-processors.js +843 -0
  105. package/dist/lib/modules/vendor/zod/v4/core/json-schema.js +1 -0
  106. package/dist/lib/modules/vendor/zod/v4/core/memoizer.js +311 -0
  107. package/dist/lib/modules/vendor/zod/v4/core/parse.js +175 -0
  108. package/dist/lib/modules/vendor/zod/v4/core/regexes.js +156 -0
  109. package/dist/lib/modules/vendor/zod/v4/core/registries.js +51 -0
  110. package/dist/lib/modules/vendor/zod/v4/core/schemas.js +2636 -0
  111. package/dist/lib/modules/vendor/zod/v4/core/to-json-schema.js +651 -0
  112. package/dist/lib/modules/vendor/zod/v4/core/util.js +873 -0
  113. package/dist/lib/modules/vendor/zod/v4/core/versions.js +5 -0
  114. package/dist/lib/modules/vendor/zod/v4/core/visit.js +169 -0
  115. package/dist/lib/modules/vendor/zod/v4/locales/ar.js +111 -0
  116. package/dist/lib/modules/vendor/zod/v4/locales/az.js +110 -0
  117. package/dist/lib/modules/vendor/zod/v4/locales/be.js +168 -0
  118. package/dist/lib/modules/vendor/zod/v4/locales/bg.js +125 -0
  119. package/dist/lib/modules/vendor/zod/v4/locales/bn.js +113 -0
  120. package/dist/lib/modules/vendor/zod/v4/locales/ca.js +112 -0
  121. package/dist/lib/modules/vendor/zod/v4/locales/ckb.js +133 -0
  122. package/dist/lib/modules/vendor/zod/v4/locales/cs.js +116 -0
  123. package/dist/lib/modules/vendor/zod/v4/locales/da.js +120 -0
  124. package/dist/lib/modules/vendor/zod/v4/locales/de.js +113 -0
  125. package/dist/lib/modules/vendor/zod/v4/locales/el.js +112 -0
  126. package/dist/lib/modules/vendor/zod/v4/locales/en.js +125 -0
  127. package/dist/lib/modules/vendor/zod/v4/locales/eo.js +114 -0
  128. package/dist/lib/modules/vendor/zod/v4/locales/es.js +136 -0
  129. package/dist/lib/modules/vendor/zod/v4/locales/fa.js +119 -0
  130. package/dist/lib/modules/vendor/zod/v4/locales/fi.js +117 -0
  131. package/dist/lib/modules/vendor/zod/v4/locales/fr-CA.js +112 -0
  132. package/dist/lib/modules/vendor/zod/v4/locales/fr.js +129 -0
  133. package/dist/lib/modules/vendor/zod/v4/locales/gu.js +113 -0
  134. package/dist/lib/modules/vendor/zod/v4/locales/he.js +221 -0
  135. package/dist/lib/modules/vendor/zod/v4/locales/hi.js +111 -0
  136. package/dist/lib/modules/vendor/zod/v4/locales/hr.js +126 -0
  137. package/dist/lib/modules/vendor/zod/v4/locales/hu.js +113 -0
  138. package/dist/lib/modules/vendor/zod/v4/locales/hy.js +158 -0
  139. package/dist/lib/modules/vendor/zod/v4/locales/id.js +111 -0
  140. package/dist/lib/modules/vendor/zod/v4/locales/index.js +63 -0
  141. package/dist/lib/modules/vendor/zod/v4/locales/is.js +114 -0
  142. package/dist/lib/modules/vendor/zod/v4/locales/it.js +113 -0
  143. package/dist/lib/modules/vendor/zod/v4/locales/ja.js +112 -0
  144. package/dist/lib/modules/vendor/zod/v4/locales/ka.js +117 -0
  145. package/dist/lib/modules/vendor/zod/v4/locales/kh.js +5 -0
  146. package/dist/lib/modules/vendor/zod/v4/locales/km.js +115 -0
  147. package/dist/lib/modules/vendor/zod/v4/locales/kn.js +116 -0
  148. package/dist/lib/modules/vendor/zod/v4/locales/ko.js +116 -0
  149. package/dist/lib/modules/vendor/zod/v4/locales/lt.js +207 -0
  150. package/dist/lib/modules/vendor/zod/v4/locales/mk.js +114 -0
  151. package/dist/lib/modules/vendor/zod/v4/locales/ms.js +112 -0
  152. package/dist/lib/modules/vendor/zod/v4/locales/ne.js +111 -0
  153. package/dist/lib/modules/vendor/zod/v4/locales/nl.js +115 -0
  154. package/dist/lib/modules/vendor/zod/v4/locales/nn.js +113 -0
  155. package/dist/lib/modules/vendor/zod/v4/locales/no.js +113 -0
  156. package/dist/lib/modules/vendor/zod/v4/locales/ota.js +114 -0
  157. package/dist/lib/modules/vendor/zod/v4/locales/pl.js +114 -0
  158. package/dist/lib/modules/vendor/zod/v4/locales/ps.js +119 -0
  159. package/dist/lib/modules/vendor/zod/v4/locales/pt-BR.js +143 -0
  160. package/dist/lib/modules/vendor/zod/v4/locales/pt.js +142 -0
  161. package/dist/lib/modules/vendor/zod/v4/locales/ro.js +122 -0
  162. package/dist/lib/modules/vendor/zod/v4/locales/ru.js +168 -0
  163. package/dist/lib/modules/vendor/zod/v4/locales/sk.js +116 -0
  164. package/dist/lib/modules/vendor/zod/v4/locales/sl.js +114 -0
  165. package/dist/lib/modules/vendor/zod/v4/locales/sv.js +115 -0
  166. package/dist/lib/modules/vendor/zod/v4/locales/ta.js +115 -0
  167. package/dist/lib/modules/vendor/zod/v4/locales/tg.js +117 -0
  168. package/dist/lib/modules/vendor/zod/v4/locales/th.js +115 -0
  169. package/dist/lib/modules/vendor/zod/v4/locales/tk.js +107 -0
  170. package/dist/lib/modules/vendor/zod/v4/locales/tr.js +110 -0
  171. package/dist/lib/modules/vendor/zod/v4/locales/ua.js +5 -0
  172. package/dist/lib/modules/vendor/zod/v4/locales/uk.js +113 -0
  173. package/dist/lib/modules/vendor/zod/v4/locales/ur.js +115 -0
  174. package/dist/lib/modules/vendor/zod/v4/locales/uz.js +113 -0
  175. package/dist/lib/modules/vendor/zod/v4/locales/vi.js +113 -0
  176. package/dist/lib/modules/vendor/zod/v4/locales/yo.js +112 -0
  177. package/dist/lib/modules/vendor/zod/v4/locales/zh-CN.js +114 -0
  178. package/dist/lib/modules/vendor/zod/v4/locales/zh-TW.js +112 -0
  179. package/dist/lib/testing-jelly-id.js +1219 -0
  180. package/dist/lib/zod.js +1 -0
  181. package/dist/spec/messaging-v1.md +3426 -0
  182. package/dist/third-party-notices.md +239 -0
  183. package/dist/third-party.json +88 -0
  184. package/dist/types/core/address.d.ts +16 -0
  185. package/dist/types/core/agent/operations.d.ts +129 -0
  186. package/dist/types/core/agent/present.d.ts +57 -0
  187. package/dist/types/core/agent/text.d.ts +62 -0
  188. package/dist/types/core/agent-tools.d.ts +948 -0
  189. package/dist/types/core/b64u.d.ts +6 -0
  190. package/dist/types/core/cards.d.ts +21 -0
  191. package/dist/types/core/check.d.ts +10 -0
  192. package/dist/types/core/consent.d.ts +132 -0
  193. package/dist/types/core/contact-card.d.ts +34 -0
  194. package/dist/types/core/delegation.d.ts +71 -0
  195. package/dist/types/core/directory/device-log.d.ts +119 -0
  196. package/dist/types/core/directory/epoch.d.ts +53 -0
  197. package/dist/types/core/directory/handle.d.ts +11 -0
  198. package/dist/types/core/directory/jelly-device.d.ts +88 -0
  199. package/dist/types/core/directory/jelly-issuer.d.ts +8 -0
  200. package/dist/types/core/directory/jelly-token.d.ts +116 -0
  201. package/dist/types/core/directory/keys-statement.d.ts +22 -0
  202. package/dist/types/core/directory/link.d.ts +36 -0
  203. package/dist/types/core/directory/merkle-log.d.ts +40 -0
  204. package/dist/types/core/directory/person-view.d.ts +90 -0
  205. package/dist/types/core/directory/person.d.ts +8 -0
  206. package/dist/types/core/directory/realm.d.ts +23 -0
  207. package/dist/types/core/directory/smt.d.ts +52 -0
  208. package/dist/types/core/envelope.d.ts +68 -0
  209. package/dist/types/core/hash.d.ts +2 -0
  210. package/dist/types/core/head.d.ts +34 -0
  211. package/dist/types/core/identity.d.ts +35 -0
  212. package/dist/types/core/index.d.ts +38 -0
  213. package/dist/types/core/jcs.d.ts +12 -0
  214. package/dist/types/core/jelly-host-double.d.ts +21 -0
  215. package/dist/types/core/jelly-host.d.ts +86 -0
  216. package/dist/types/core/keys.d.ts +16 -0
  217. package/dist/types/core/peer-text.d.ts +87 -0
  218. package/dist/types/core/realm.d.ts +36 -0
  219. package/dist/types/core/roster.d.ts +146 -0
  220. package/dist/types/core/schema/a2a.d.ts +251 -0
  221. package/dist/types/core/schema/common.d.ts +272 -0
  222. package/dist/types/core/schema/consent.d.ts +140 -0
  223. package/dist/types/core/schema/delegation.d.ts +58 -0
  224. package/dist/types/core/schema/directory-frames.d.ts +1301 -0
  225. package/dist/types/core/schema/directory.d.ts +375 -0
  226. package/dist/types/core/schema/envelope.d.ts +750 -0
  227. package/dist/types/core/schema/errors.d.ts +104 -0
  228. package/dist/types/core/schema/index.d.ts +15 -0
  229. package/dist/types/core/schema/ipc/consent.d.ts +555 -0
  230. package/dist/types/core/schema/ipc/device.d.ts +729 -0
  231. package/dist/types/core/schema/ipc/jelly.d.ts +501 -0
  232. package/dist/types/core/schema/ipc/shapes.d.ts +411 -0
  233. package/dist/types/core/schema/ipc/surfaces.d.ts +674 -0
  234. package/dist/types/core/schema/ipc.d.ts +3131 -0
  235. package/dist/types/core/schema/jelly.d.ts +160 -0
  236. package/dist/types/core/schema/realm.d.ts +38 -0
  237. package/dist/types/core/schema/relay.d.ts +1122 -0
  238. package/dist/types/core/schema/roster.d.ts +347 -0
  239. package/dist/types/core/sign.d.ts +13 -0
  240. package/dist/types/core/task.d.ts +6 -0
  241. package/dist/types/core/testing.d.ts +18 -0
  242. package/dist/types/core/ulid.d.ts +5 -0
  243. package/dist/types/core/version.d.ts +6 -0
  244. package/dist/types/core/wire.d.ts +14 -0
  245. package/dist/types/ipc/client.d.ts +85 -0
  246. package/dist/types/ipc/framing.d.ts +12 -0
  247. package/dist/types/ipc/index.d.ts +6 -0
  248. package/dist/types/ipc/paths.d.ts +39 -0
  249. package/dist/types/ipc/pipes.d.ts +16 -0
  250. package/dist/types/ipc/rpc.d.ts +13 -0
  251. package/dist/types/ipc/server.d.ts +94 -0
  252. package/dist/types/ipc/testing.d.ts +89 -0
  253. package/dist/types/ipc/trust.d.ts +49 -0
  254. package/dist/types/ipc/windows-acl.d.ts +56 -0
  255. package/dist/types/testing/jelly-id.d.ts +518 -0
  256. package/dist/types/zod.d.ts +1 -0
  257. package/package.json +77 -4
@@ -0,0 +1,347 @@
1
+ /**
2
+ * The team roster: an append-only, hash-chained log of signed entries.
3
+ * The relay sequences appends; every machine verifies the whole chain itself.
4
+ *
5
+ * hash(entry) = SHA-256(UTF-8(JCS(entry))), base64url, over the full entry including sig
6
+ * sig = Ed25519(by, DOMAIN.roster + JCS(entry without sig))
7
+ * team id = hash(genesis)
8
+ * proof = Ed25519(invite seed, DOMAIN.invite + JCS({team, inviteId, member})) (invite.redeem)
9
+ *
10
+ * Authority rules (enforced by `Roster.apply`):
11
+ * genesis seq 0, prev null, by = founder.machine, founder.role = admin
12
+ * member.add by a current admin; machine not already a member; (person, label) not used by a current member
13
+ * member.remove by a current admin, or by the member itself (leave); never the last admin
14
+ * member.role by a current admin; never demotes the last admin
15
+ * member.rekey by the member itself or a current admin; the machine is a current member (never a
16
+ * removed one); replaces only that member's `enc`
17
+ * invite.create by a current admin; expires − ts ≤ LIMITS.ttlMs
18
+ * invite.redeem by the joining machine (by = member.machine); invite open and unexpired at entry ts;
19
+ * proof verifies under the invite's invitePub; member.person and role match the invite;
20
+ * (person, label) not used by a current member. Single use.
21
+ * invite.revoke by a current admin
22
+ * Every admitted member key (genesis founder, member.add, redeem member) and every invitePub must be a
23
+ * canonical Ed25519 encoding of a point that is not of small order.
24
+ * A removed machine can never rejoin with the same key; it must generate a new identity.
25
+ * Inviting or adding an existing person adds another machine for that person, under another label.
26
+ */
27
+ import { z } from "zod";
28
+ export declare const Member: z.ZodObject<{
29
+ machine: z.ZodString;
30
+ enc: z.ZodString;
31
+ person: z.ZodString;
32
+ role: z.ZodEnum<{
33
+ admin: "admin";
34
+ member: "member";
35
+ }>;
36
+ label: z.ZodString;
37
+ }, z.core.$strip>;
38
+ export type Member = z.infer<typeof Member>;
39
+ export declare const GenesisEntry: z.ZodObject<{
40
+ prev: z.ZodNull;
41
+ kind: z.ZodLiteral<"genesis">;
42
+ body: z.ZodObject<{
43
+ name: z.ZodString;
44
+ founder: z.ZodObject<{
45
+ machine: z.ZodString;
46
+ enc: z.ZodString;
47
+ person: z.ZodString;
48
+ role: z.ZodEnum<{
49
+ admin: "admin";
50
+ member: "member";
51
+ }>;
52
+ label: z.ZodString;
53
+ }, z.core.$strip>;
54
+ }, z.core.$strip>;
55
+ v: z.ZodLiteral<"messaging/1">;
56
+ seq: z.ZodNumber;
57
+ ts: z.ZodNumber;
58
+ by: z.ZodString;
59
+ sig: z.ZodString;
60
+ }, z.core.$strip>;
61
+ export declare const MemberAddEntry: z.ZodObject<{
62
+ kind: z.ZodLiteral<"member.add">;
63
+ body: z.ZodObject<{
64
+ machine: z.ZodString;
65
+ enc: z.ZodString;
66
+ person: z.ZodString;
67
+ role: z.ZodEnum<{
68
+ admin: "admin";
69
+ member: "member";
70
+ }>;
71
+ label: z.ZodString;
72
+ }, z.core.$strip>;
73
+ team: z.ZodString;
74
+ prev: z.ZodString;
75
+ v: z.ZodLiteral<"messaging/1">;
76
+ seq: z.ZodNumber;
77
+ ts: z.ZodNumber;
78
+ by: z.ZodString;
79
+ sig: z.ZodString;
80
+ }, z.core.$strip>;
81
+ export declare const MemberRemoveEntry: z.ZodObject<{
82
+ kind: z.ZodLiteral<"member.remove">;
83
+ body: z.ZodObject<{
84
+ machine: z.ZodString;
85
+ reason: z.ZodOptional<z.ZodString>;
86
+ }, z.core.$strip>;
87
+ team: z.ZodString;
88
+ prev: z.ZodString;
89
+ v: z.ZodLiteral<"messaging/1">;
90
+ seq: z.ZodNumber;
91
+ ts: z.ZodNumber;
92
+ by: z.ZodString;
93
+ sig: z.ZodString;
94
+ }, z.core.$strip>;
95
+ export declare const MemberRoleEntry: z.ZodObject<{
96
+ kind: z.ZodLiteral<"member.role">;
97
+ body: z.ZodObject<{
98
+ machine: z.ZodString;
99
+ role: z.ZodEnum<{
100
+ admin: "admin";
101
+ member: "member";
102
+ }>;
103
+ }, z.core.$strip>;
104
+ team: z.ZodString;
105
+ prev: z.ZodString;
106
+ v: z.ZodLiteral<"messaging/1">;
107
+ seq: z.ZodNumber;
108
+ ts: z.ZodNumber;
109
+ by: z.ZodString;
110
+ sig: z.ZodString;
111
+ }, z.core.$strip>;
112
+ /**
113
+ * Replaces a member's X25519 encryption key. Senders seal to the new `enc` once they have
114
+ * applied this entry; the member keeps its previous key long enough to open what was sealed before (spec §4).
115
+ */
116
+ export declare const MemberRekeyEntry: z.ZodObject<{
117
+ kind: z.ZodLiteral<"member.rekey">;
118
+ body: z.ZodObject<{
119
+ machine: z.ZodString;
120
+ enc: z.ZodString;
121
+ }, z.core.$strip>;
122
+ team: z.ZodString;
123
+ prev: z.ZodString;
124
+ v: z.ZodLiteral<"messaging/1">;
125
+ seq: z.ZodNumber;
126
+ ts: z.ZodNumber;
127
+ by: z.ZodString;
128
+ sig: z.ZodString;
129
+ }, z.core.$strip>;
130
+ export declare const InviteCreateEntry: z.ZodObject<{
131
+ kind: z.ZodLiteral<"invite.create">;
132
+ body: z.ZodObject<{
133
+ inviteId: z.ZodString;
134
+ invitePub: z.ZodString;
135
+ person: z.ZodString;
136
+ expires: z.ZodNumber;
137
+ }, z.core.$strip>;
138
+ team: z.ZodString;
139
+ prev: z.ZodString;
140
+ v: z.ZodLiteral<"messaging/1">;
141
+ seq: z.ZodNumber;
142
+ ts: z.ZodNumber;
143
+ by: z.ZodString;
144
+ sig: z.ZodString;
145
+ }, z.core.$strip>;
146
+ export declare const InviteRedeemEntry: z.ZodObject<{
147
+ kind: z.ZodLiteral<"invite.redeem">;
148
+ body: z.ZodObject<{
149
+ inviteId: z.ZodString;
150
+ proof: z.ZodString;
151
+ member: z.ZodObject<{
152
+ machine: z.ZodString;
153
+ enc: z.ZodString;
154
+ person: z.ZodString;
155
+ role: z.ZodEnum<{
156
+ admin: "admin";
157
+ member: "member";
158
+ }>;
159
+ label: z.ZodString;
160
+ }, z.core.$strip>;
161
+ }, z.core.$strip>;
162
+ team: z.ZodString;
163
+ prev: z.ZodString;
164
+ v: z.ZodLiteral<"messaging/1">;
165
+ seq: z.ZodNumber;
166
+ ts: z.ZodNumber;
167
+ by: z.ZodString;
168
+ sig: z.ZodString;
169
+ }, z.core.$strip>;
170
+ export declare const InviteRevokeEntry: z.ZodObject<{
171
+ kind: z.ZodLiteral<"invite.revoke">;
172
+ body: z.ZodObject<{
173
+ inviteId: z.ZodString;
174
+ }, z.core.$strip>;
175
+ team: z.ZodString;
176
+ prev: z.ZodString;
177
+ v: z.ZodLiteral<"messaging/1">;
178
+ seq: z.ZodNumber;
179
+ ts: z.ZodNumber;
180
+ by: z.ZodString;
181
+ sig: z.ZodString;
182
+ }, z.core.$strip>;
183
+ export declare const RosterEntry: z.ZodDiscriminatedUnion<[z.ZodObject<{
184
+ prev: z.ZodNull;
185
+ kind: z.ZodLiteral<"genesis">;
186
+ body: z.ZodObject<{
187
+ name: z.ZodString;
188
+ founder: z.ZodObject<{
189
+ machine: z.ZodString;
190
+ enc: z.ZodString;
191
+ person: z.ZodString;
192
+ role: z.ZodEnum<{
193
+ admin: "admin";
194
+ member: "member";
195
+ }>;
196
+ label: z.ZodString;
197
+ }, z.core.$strip>;
198
+ }, z.core.$strip>;
199
+ v: z.ZodLiteral<"messaging/1">;
200
+ seq: z.ZodNumber;
201
+ ts: z.ZodNumber;
202
+ by: z.ZodString;
203
+ sig: z.ZodString;
204
+ }, z.core.$strip>, z.ZodObject<{
205
+ kind: z.ZodLiteral<"member.add">;
206
+ body: z.ZodObject<{
207
+ machine: z.ZodString;
208
+ enc: z.ZodString;
209
+ person: z.ZodString;
210
+ role: z.ZodEnum<{
211
+ admin: "admin";
212
+ member: "member";
213
+ }>;
214
+ label: z.ZodString;
215
+ }, z.core.$strip>;
216
+ team: z.ZodString;
217
+ prev: z.ZodString;
218
+ v: z.ZodLiteral<"messaging/1">;
219
+ seq: z.ZodNumber;
220
+ ts: z.ZodNumber;
221
+ by: z.ZodString;
222
+ sig: z.ZodString;
223
+ }, z.core.$strip>, z.ZodObject<{
224
+ kind: z.ZodLiteral<"member.remove">;
225
+ body: z.ZodObject<{
226
+ machine: z.ZodString;
227
+ reason: z.ZodOptional<z.ZodString>;
228
+ }, z.core.$strip>;
229
+ team: z.ZodString;
230
+ prev: z.ZodString;
231
+ v: z.ZodLiteral<"messaging/1">;
232
+ seq: z.ZodNumber;
233
+ ts: z.ZodNumber;
234
+ by: z.ZodString;
235
+ sig: z.ZodString;
236
+ }, z.core.$strip>, z.ZodObject<{
237
+ kind: z.ZodLiteral<"member.role">;
238
+ body: z.ZodObject<{
239
+ machine: z.ZodString;
240
+ role: z.ZodEnum<{
241
+ admin: "admin";
242
+ member: "member";
243
+ }>;
244
+ }, z.core.$strip>;
245
+ team: z.ZodString;
246
+ prev: z.ZodString;
247
+ v: z.ZodLiteral<"messaging/1">;
248
+ seq: z.ZodNumber;
249
+ ts: z.ZodNumber;
250
+ by: z.ZodString;
251
+ sig: z.ZodString;
252
+ }, z.core.$strip>, z.ZodObject<{
253
+ kind: z.ZodLiteral<"member.rekey">;
254
+ body: z.ZodObject<{
255
+ machine: z.ZodString;
256
+ enc: z.ZodString;
257
+ }, z.core.$strip>;
258
+ team: z.ZodString;
259
+ prev: z.ZodString;
260
+ v: z.ZodLiteral<"messaging/1">;
261
+ seq: z.ZodNumber;
262
+ ts: z.ZodNumber;
263
+ by: z.ZodString;
264
+ sig: z.ZodString;
265
+ }, z.core.$strip>, z.ZodObject<{
266
+ kind: z.ZodLiteral<"invite.create">;
267
+ body: z.ZodObject<{
268
+ inviteId: z.ZodString;
269
+ invitePub: z.ZodString;
270
+ person: z.ZodString;
271
+ expires: z.ZodNumber;
272
+ }, z.core.$strip>;
273
+ team: z.ZodString;
274
+ prev: z.ZodString;
275
+ v: z.ZodLiteral<"messaging/1">;
276
+ seq: z.ZodNumber;
277
+ ts: z.ZodNumber;
278
+ by: z.ZodString;
279
+ sig: z.ZodString;
280
+ }, z.core.$strip>, z.ZodObject<{
281
+ kind: z.ZodLiteral<"invite.redeem">;
282
+ body: z.ZodObject<{
283
+ inviteId: z.ZodString;
284
+ proof: z.ZodString;
285
+ member: z.ZodObject<{
286
+ machine: z.ZodString;
287
+ enc: z.ZodString;
288
+ person: z.ZodString;
289
+ role: z.ZodEnum<{
290
+ admin: "admin";
291
+ member: "member";
292
+ }>;
293
+ label: z.ZodString;
294
+ }, z.core.$strip>;
295
+ }, z.core.$strip>;
296
+ team: z.ZodString;
297
+ prev: z.ZodString;
298
+ v: z.ZodLiteral<"messaging/1">;
299
+ seq: z.ZodNumber;
300
+ ts: z.ZodNumber;
301
+ by: z.ZodString;
302
+ sig: z.ZodString;
303
+ }, z.core.$strip>, z.ZodObject<{
304
+ kind: z.ZodLiteral<"invite.revoke">;
305
+ body: z.ZodObject<{
306
+ inviteId: z.ZodString;
307
+ }, z.core.$strip>;
308
+ team: z.ZodString;
309
+ prev: z.ZodString;
310
+ v: z.ZodLiteral<"messaging/1">;
311
+ seq: z.ZodNumber;
312
+ ts: z.ZodNumber;
313
+ by: z.ZodString;
314
+ sig: z.ZodString;
315
+ }, z.core.$strip>], "kind">;
316
+ export type RosterEntry = z.infer<typeof RosterEntry>;
317
+ export type GenesisEntry = z.infer<typeof GenesisEntry>;
318
+ export type MemberAddEntry = z.infer<typeof MemberAddEntry>;
319
+ export type MemberRemoveEntry = z.infer<typeof MemberRemoveEntry>;
320
+ export type MemberRoleEntry = z.infer<typeof MemberRoleEntry>;
321
+ export type MemberRekeyEntry = z.infer<typeof MemberRekeyEntry>;
322
+ export type InviteCreateEntry = z.infer<typeof InviteCreateEntry>;
323
+ export type InviteRedeemEntry = z.infer<typeof InviteRedeemEntry>;
324
+ export type InviteRevokeEntry = z.infer<typeof InviteRevokeEntry>;
325
+ export type RosterKind = RosterEntry["kind"];
326
+ export declare const RosterHead: z.ZodObject<{
327
+ seq: z.ZodNumber;
328
+ hash: z.ZodString;
329
+ }, z.core.$strip>;
330
+ export type RosterHead = z.infer<typeof RosterHead>;
331
+ /**
332
+ * Invite ticket, shared out of band. Encoded as `messaging1.` + base64url(UTF-8(JCS(ticket))).
333
+ * `secret` is the invite seed: a 32-byte Ed25519 private key (RFC 8032 seed) whose public key is the
334
+ * invite's `invitePub`. The joiner signs its redeem proof with it; the seed never leaves the ticket.
335
+ */
336
+ export declare const InviteTicket: z.ZodObject<{
337
+ v: z.ZodLiteral<"messaging/1">;
338
+ team: z.ZodString;
339
+ name: z.ZodString;
340
+ relay: z.ZodString;
341
+ inviteId: z.ZodString;
342
+ secret: z.ZodString;
343
+ person: z.ZodString;
344
+ expires: z.ZodNumber;
345
+ }, z.core.$strip>;
346
+ export type InviteTicket = z.infer<typeof InviteTicket>;
347
+ export declare const TICKET_PREFIX: "messaging1.";
@@ -0,0 +1,13 @@
1
+ import { type KeyObject } from "node:crypto";
2
+ import type { Identity } from "./identity.js";
3
+ import type { MachineId } from "./schema/common.js";
4
+ /** The exact bytes signed: UTF-8(domain) || UTF-8(JCS(value)). Throws `invalid_request` for non-I-JSON. */
5
+ export declare function signingInput(domain: string, value: unknown): Uint8Array;
6
+ /** Ed25519 signature (base64url) over `domain` + JCS(value). Use a `DOMAIN` prefix. Throws only MessagingError. */
7
+ export declare function sign(identity: Identity, domain: string, value: unknown): string;
8
+ /** `sign` with a bare Ed25519 private key, such as an invite seed. */
9
+ export declare function signWith(key: KeyObject, domain: string, value: unknown): string;
10
+ /** True only for a valid signature by `machine`. Never throws: malformed keys, values or signatures are false. */
11
+ export declare function verify(machine: MachineId, domain: string, value: unknown, sig: string): boolean;
12
+ /** `verify` over bytes from `signingInput`. Never throws. */
13
+ export declare function verifyInput(machine: MachineId, input: Uint8Array, sig: string): boolean;
@@ -0,0 +1,6 @@
1
+ import { type TaskState } from "./schema/a2a.js";
2
+ /** The task state machine in spec §6.3. Unknown states never transition. */
3
+ export declare function canTransition(from: TaskState, to: TaskState): boolean;
4
+ export declare function isTerminal(state: TaskState): boolean;
5
+ /** INPUT_REQUIRED or AUTH_REQUIRED: waiting on the requester. */
6
+ export declare function isInterrupted(state: TaskState): boolean;
@@ -0,0 +1,18 @@
1
+ /**
2
+ * `@messaging/core/testing`: helpers for test vectors and tests that need fixed randomness or envelopes a
3
+ * conforming sender never makes. Never import this from production code.
4
+ */
5
+ export { sealEnvelopeWith, sealPlaintext, type SealRandomness } from "./envelope.js";
6
+ export { encodeTicket } from "./roster.js";
7
+ export { grantHash } from "./delegation.js";
8
+ export { signJellyToken } from "./directory/jelly-issuer.js";
9
+ export { jellyHostDouble, type JellyHostDouble } from "./jelly-host-double.js";
10
+ /**
11
+ * Narrows a result whose `kind` tells its shape (`item.read`, `conv.read`) to the expected kind, and
12
+ * throws with both kinds named otherwise: `client.call("item.read", p).then(asKind("received"))`.
13
+ */
14
+ export declare function asKind<K extends string>(kind: K): <T extends {
15
+ kind: string;
16
+ }>(result: T) => Extract<T, {
17
+ kind: K;
18
+ }>;
@@ -0,0 +1,5 @@
1
+ /**
2
+ * A ULID for `now` (default `Date.now()`), with 80 fresh random bits per id. Ids sort by millisecond,
3
+ * but ids from one millisecond are in random order, so no id predicts another (spec §2).
4
+ */
5
+ export declare function ulid(now?: number): string;
@@ -0,0 +1,6 @@
1
+ /**
2
+ * The release version every Messaging package ships at (they release together). A daemon names it in
3
+ * its IPC hello and a client compares it with its own (spec §8.2). A test keeps it equal to the
4
+ * root package.json.
5
+ */
6
+ export declare const VERSION = "0.7.0";
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Parses JSON text that came from outside the process: a relay frame, an IPC line, a decrypted body,
3
+ * an invite ticket. It returns exactly what `JSON.parse` returns, after a single linear, iterative
4
+ * (never recursive) scan that throws `invalid_request` for:
5
+ * - text that is not RFC 8259 JSON;
6
+ * - an object with two members of the same name, compared after unescaping;
7
+ * - arrays and objects nested deeper than `LIMITS.jsonDepth`, before anything is built;
8
+ * - a string or member name with a lone surrogate, raw or escaped;
9
+ * - more than `maxBytes` UTF-8 bytes, when `maxBytes` is given.
10
+ * Error messages give the reason and an offset, never the text, and chain no `cause`.
11
+ */
12
+ export declare function parseWire(text: string, options?: {
13
+ maxBytes?: number;
14
+ }): unknown;
@@ -0,0 +1,85 @@
1
+ import { IpcEvent, IpcHello, MessagingError, type IpcMethod, type IpcParams, type IpcResult } from "../core/index.js";
2
+ import { type SocketTier } from "./paths.js";
3
+ export interface ClientOptions {
4
+ /** Explicit socket path (on Windows, the pipe pointer file). Defaults to the `tier` socket of `home`. */
5
+ socketPath?: string;
6
+ home?: string;
7
+ /** Which of the daemon's sockets to use without `socketPath`; default `agent` (spec §8.2). */
8
+ tier?: SocketTier;
9
+ /**
10
+ * The daemon's own uid, trusted besides this user to own `run/` and the socket, when `messagingd` runs
11
+ * as its own user. Defaults to `MESSAGING_DAEMON_UID`.
12
+ */
13
+ daemonUid?: number;
14
+ connectTimeoutMs?: number;
15
+ /** Default per-call timeout. */
16
+ callTimeoutMs?: number;
17
+ /** The release the daemon must be; this build's `VERSION` unless a test says otherwise. */
18
+ version?: string;
19
+ /**
20
+ * How long to wait for the hello once connected; at least 5 s by default, apart from the connect
21
+ * timeout, so a daemon that is only busy is not taken for another version.
22
+ */
23
+ helloTimeoutMs?: number;
24
+ }
25
+ /**
26
+ * `daemon_mismatch`: the daemon on the socket is another release or IPC protocol, or did not say
27
+ * which (spec §8.2). `hello` is what it said, when it said anything this client can read.
28
+ */
29
+ export declare class DaemonMismatchError extends MessagingError {
30
+ readonly hello?: IpcHello | undefined;
31
+ constructor(message: string, hello?: IpcHello | undefined);
32
+ }
33
+ export interface CallOptions {
34
+ signal?: AbortSignal;
35
+ timeoutMs?: number;
36
+ /** An action grant (`jelly-act+jwt`) for a daemon under a Jelly host (spec §8.11), sent as the request's `grant`. */
37
+ grant?: string;
38
+ }
39
+ /** Non-Messaging JSON-RPC failure (schema, unknown method, internal). */
40
+ export declare class IpcRpcError extends Error {
41
+ readonly rpcCode: number;
42
+ constructor(rpcCode: number, message: string);
43
+ }
44
+ /**
45
+ * One connection to the local daemon. It does not reconnect; watch `onClose` and connect again.
46
+ * Results are validated against the contract; malformed events are dropped.
47
+ */
48
+ export declare class MessagingClient {
49
+ private readonly socket;
50
+ private readonly callTimeoutMs;
51
+ private readonly pending;
52
+ private readonly eventListeners;
53
+ private readonly closeListeners;
54
+ private nextId;
55
+ private isClosed;
56
+ private greeting?;
57
+ /** The daemon's hello: the first line on the connection (spec §8.2). */
58
+ private readonly greeted;
59
+ private daemonHello?;
60
+ private constructor();
61
+ /**
62
+ * Connects to the daemon and reads its hello before anything else. A daemon of another release or
63
+ * IPC protocol, or one that does not say which within `helloTimeoutMs`, fails with
64
+ * `daemon_mismatch` (`DaemonMismatchError`, with the remedy in its message) and the connection is
65
+ * closed. The socket's directory must be private (a real directory owned by this
66
+ * user, or by the configured daemon uid, that no group or other user can write) and the socket owned
67
+ * by one of them; otherwise this fails with `forbidden`, because whoever can write that directory can
68
+ * stand in for the daemon.
69
+ *
70
+ * On Windows (spec §8.2, "Windows") `socketPath` is the pointer file that names the daemon's pipe. It and its
71
+ * directory must be private by ACL; the client connects to the pipe it names, and refuses (`forbidden`) a
72
+ * hello whose `pid` is not the pointer's.
73
+ */
74
+ static connect(options?: ClientOptions): Promise<MessagingClient>;
75
+ /** What the daemon said when this connection opened: its release, IPC protocol and pid. */
76
+ get daemon(): IpcHello;
77
+ get closed(): boolean;
78
+ call<M extends IpcMethod>(method: M, params: IpcParams<M>, options?: CallOptions): Promise<IpcResult<M>>;
79
+ onEvent(listener: (event: IpcEvent) => void): () => void;
80
+ onClose(listener: (error?: Error) => void): () => void;
81
+ close(): void;
82
+ private receive;
83
+ private settle;
84
+ private shutdown;
85
+ }
@@ -0,0 +1,12 @@
1
+ /** Splits a byte stream into newline-delimited lines, enforcing a per-line byte limit. */
2
+ export declare class LineDecoder {
3
+ private readonly maxBytes;
4
+ private pending;
5
+ constructor(maxBytes: number);
6
+ /** Returns complete lines. Throws `LineTooLongError` once a line exceeds the limit. */
7
+ push(chunk: string): string[];
8
+ }
9
+ export declare class LineTooLongError extends Error {
10
+ constructor(maxBytes: number);
11
+ }
12
+ export declare function encodeLine(value: unknown): string;
@@ -0,0 +1,6 @@
1
+ export { DaemonMismatchError, MessagingClient, IpcRpcError, type CallOptions } from "./client.js";
2
+ export { createIpcServer, type AuthorizeCall, type CallAuthority, type IpcServer, type Handlers, type Handler, type ConnectionContext } from "./server.js";
3
+ export { configuredDaemonUid, daemonEnv, IS_WINDOWS, messagingHome, socketPath, type SocketTier } from "./paths.js";
4
+ export { RPC } from "./rpc.js";
5
+ export { adoptPrivateDir, openNoFollow, privacyProblem, trustedOwners } from "./trust.js";
6
+ export { aclProblem } from "./windows-acl.js";
@@ -0,0 +1,39 @@
1
+ /** macOS limits sun_path to 104 bytes including the terminator. */
2
+ export declare const MAX_SOCKET_PATH_BYTES = 103;
3
+ /**
4
+ * Windows: the daemon's endpoints are named pipes found through pointer files (`pipes.ts`), its directories
5
+ * and files are private by ACL (`windows-acl.ts`), and there are no POSIX signals.
6
+ */
7
+ export declare const IS_WINDOWS: boolean;
8
+ /** `$MESSAGING_HOME`, else `~/.messaging`. */
9
+ export declare function messagingHome(env?: NodeJS.ProcessEnv): string;
10
+ /**
11
+ * The daemon's two sockets (spec §8.2, "Two sockets"): `agent` (`run/agent.sock`) serves only
12
+ * `AGENT_METHODS`, for agent-facing clients (the plugin's server part, MCP); `admin`
13
+ * (`run/admin.sock`) serves every method, for people (the `messaging` CLI and the `/messaging` TUI).
14
+ */
15
+ export type SocketTier = "agent" | "admin";
16
+ /**
17
+ * Where a client finds the `tier` endpoint of the daemon of `home`: the socket `run/<tier>.sock`, or on Windows
18
+ * the pointer file `run\<tier>.pipe` that names the tier's pipe (spec §8.2, "Windows").
19
+ */
20
+ export declare function socketPath(home: string, tier: SocketTier): string;
21
+ /**
22
+ * `MESSAGING_DAEMON_UID`: the uid a client also trusts to own the daemon's `run/` directory and socket,
23
+ * when `messagingd` runs as its own user (spec §8.2). Unset: only this process's own user. POSIX only: on
24
+ * Windows a set value is `invalid_request`.
25
+ */
26
+ export declare function configuredDaemonUid(env?: NodeJS.ProcessEnv, windows?: boolean): number | undefined;
27
+ /**
28
+ * Environment variables a client passes through when it starts the long-lived daemon (`messaging daemon
29
+ * start`, the OpenCode plugin's autostart). Provider API keys, cloud credentials, tokens and
30
+ * NODE_OPTIONS, which could preload code into the daemon, stay behind.
31
+ */
32
+ export declare const DAEMON_ENV: readonly string[];
33
+ /**
34
+ * Also passed on Windows: the variables Windows programs need to run at all (`SystemRoot`: Winsock and the
35
+ * crypto provider fail without it), find the user's profile and temp directories, and run system tools.
36
+ */
37
+ export declare const DAEMON_ENV_WINDOWS: readonly string[];
38
+ /** The daemon environment: the `DAEMON_ENV` part of `env` (and on Windows `DAEMON_ENV_WINDOWS`), plus `MESSAGING_HOME`. */
39
+ export declare function daemonEnv(env: Readonly<Record<string, string | undefined>>, home: string, windows?: boolean): Record<string, string>;
@@ -0,0 +1,16 @@
1
+ import type { SocketTier } from "./paths.js";
2
+ /** The only pipe names a client connects to. */
3
+ export declare const PIPE_NAME: RegExp;
4
+ export interface PipePointer {
5
+ pipe: string;
6
+ pid: number;
7
+ }
8
+ /** A fresh, unpredictable pipe name for one server of `tier`. */
9
+ export declare function newPipeName(tier: SocketTier): string;
10
+ /** Writes the pointer atomically: a temp file beside it (inheriting the directory's ACL), renamed over it. */
11
+ export declare function writePointer(path: string, pointer: PipePointer): void;
12
+ /**
13
+ * Reads a pointer file: `daemon_unavailable` when it is missing, `forbidden` when it is not exactly
14
+ * `{pipe, pid}` with a pipe name of the shape `newPipeName` makes.
15
+ */
16
+ export declare function readPointer(path: string): PipePointer;
@@ -0,0 +1,13 @@
1
+ /** Standard JSON-RPC 2.0 error codes. Messaging errors use MESSAGING_ERROR_RPC_CODE from @messaging/core. */
2
+ export declare const RPC: {
3
+ readonly parseError: -32700;
4
+ readonly invalidRequest: -32600;
5
+ readonly methodNotFound: -32601;
6
+ readonly invalidParams: -32602;
7
+ readonly internalError: -32603;
8
+ };
9
+ export interface RpcErrorObject {
10
+ code: number;
11
+ message: string;
12
+ data?: unknown;
13
+ }