@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
@@ -0,0 +1,8 @@
1
+ import type { JellyKey } from "../directory/jelly-token.js";
2
+ import { type ForeignVerifyInput, type ForeignVerifyResult } from "./proof-state.js";
3
+ /** Key resolution is trusted issuer configuration, never keys embedded in a foreign response.
4
+ * `options.heads` may only shrink the recent-head working window (tests exercise eviction with a
5
+ * few heads); it never exceeds FOREIGN_BUDGET.heads. */
6
+ export declare function verifyForeignDirectory(input: ForeignVerifyInput, key: (kid: string) => JellyKey | undefined, options?: {
7
+ heads?: number;
8
+ }): ForeignVerifyResult;
@@ -0,0 +1,114 @@
1
+ export declare const FOREIGN_LIMITS: {
2
+ readonly fetchMs: number;
3
+ readonly headMs: number;
4
+ readonly futureMs: number;
5
+ };
6
+ /** Internal work budgets, independent of transport limits. `heads` bounds the recent-head
7
+ * working window only; the caller's durable archive retains observations beyond it. */
8
+ export declare const FOREIGN_BUDGET: {
9
+ readonly proofBytes: 1048576;
10
+ readonly stateBytes: 4194304;
11
+ readonly nodes: 32768;
12
+ readonly depth: 32;
13
+ readonly rosterEntries: 1024;
14
+ readonly rotations: 64;
15
+ readonly consistency: 64;
16
+ readonly heads: 1024;
17
+ };
18
+ export declare class ForeignInputError extends Error {
19
+ constructor();
20
+ }
21
+ /** Bound traversal before canonicalization allocates/sorts the complete value. No accessors run. */
22
+ export declare function checkForeignValue(value: unknown, maxBytes?: number): void;
23
+ export declare function admitForeignProof(proof: unknown, kind: "directory" | "roster"): void;
24
+ export interface ForeignSubject {
25
+ readonly realm: string;
26
+ readonly person: string;
27
+ }
28
+ export interface ForeignPin {
29
+ readonly kind: "directory" | "roster";
30
+ readonly realm: string;
31
+ /** DirectoryRealmConfig, or { genesis: the pinned genesis hash }. Never supplied by a proof. */
32
+ readonly root: unknown;
33
+ }
34
+ export interface ForeignHead {
35
+ readonly position: number;
36
+ readonly hash: string;
37
+ readonly issuedAt: number;
38
+ readonly expiresAt: number;
39
+ }
40
+ export interface ForeignDevice {
41
+ readonly signingKey: string;
42
+ readonly encryptionKey?: string | undefined;
43
+ readonly keyVersion: number;
44
+ /** Last non-self replacement, retained even after a subsequent self rotation. */
45
+ readonly review: string | null;
46
+ }
47
+ export interface VerifiedForeignRealm {
48
+ readonly realm: string;
49
+ readonly pinDigest: string;
50
+ readonly head: ForeignHead;
51
+ /** Private verifier state. Only previously verified results may supply this. */
52
+ readonly cursor: unknown;
53
+ }
54
+ export interface VerifiedForeignIdentity {
55
+ readonly subject: ForeignSubject;
56
+ readonly head: ForeignHead;
57
+ readonly devices: readonly ForeignDevice[];
58
+ readonly removed: readonly string[];
59
+ readonly erased: boolean;
60
+ readonly proofDigest: string;
61
+ readonly cursor: unknown;
62
+ }
63
+ export interface ForeignVerifyInput {
64
+ readonly pin: ForeignPin;
65
+ readonly subject: ForeignSubject;
66
+ readonly proof: unknown;
67
+ readonly now: number;
68
+ readonly realm?: VerifiedForeignRealm | undefined;
69
+ readonly known?: VerifiedForeignIdentity | undefined;
70
+ /** A locally verified historical observation, looked up in the caller's durable archive. */
71
+ readonly observedHead?: ForeignHead | undefined;
72
+ }
73
+ export interface ForeignVerifiedState {
74
+ readonly realm: VerifiedForeignRealm;
75
+ readonly identity: VerifiedForeignIdentity;
76
+ }
77
+ export type ForeignVerifyResult = ({
78
+ readonly ok: true;
79
+ } & ForeignVerifiedState) | {
80
+ readonly ok: false;
81
+ readonly reason: "stale";
82
+ readonly verified: ForeignVerifiedState;
83
+ readonly evidence: {
84
+ readonly code: string;
85
+ readonly digest: string;
86
+ };
87
+ } | {
88
+ readonly ok: false;
89
+ readonly reason: "invalid" | "root" | "rollback" | "fork";
90
+ readonly evidence: {
91
+ readonly code: string;
92
+ readonly digest: string;
93
+ readonly compatible?: true;
94
+ };
95
+ };
96
+ export declare class ForeignProofError extends Error {
97
+ readonly reason: Extract<ForeignVerifyResult, {
98
+ ok: false;
99
+ }>["reason"];
100
+ readonly code: string;
101
+ readonly compatible: boolean;
102
+ constructor(reason: Extract<ForeignVerifyResult, {
103
+ ok: false;
104
+ }>["reason"], code: string, compatible?: boolean);
105
+ }
106
+ export declare function requireProof(condition: boolean, code: string, reason?: ForeignProofError["reason"], compatible?: boolean): asserts condition;
107
+ export declare function proofDigest(value: unknown): string;
108
+ export declare function proofFailure(error: unknown, proof: unknown): ForeignVerifyResult;
109
+ /** Expiry changes key eligibility, never the authenticated history we must retain. */
110
+ export declare function verifiedProof(verified: ForeignVerifiedState, now: number): ForeignVerifyResult;
111
+ export declare function checkContext(input: ForeignVerifyInput, kind: ForeignPin["kind"]): void;
112
+ export declare function checkHeadTime(head: ForeignHead, now: number): void;
113
+ /** Caller clock only. A future local fetch time (including clock rollback) fails closed. */
114
+ export declare function foreignFresh(head: ForeignHead, fetchedAt: number, now: number): boolean;
@@ -0,0 +1,7 @@
1
+ import { type ForeignVerifyInput, type ForeignVerifyResult } from "./proof-state.js";
2
+ /** Internal until X3-2/3 supplies the normative contract. */
3
+ export declare const DOMAIN: {
4
+ readonly rosterCheckpoint: "messaging/1/federation/roster-checkpoint\n";
5
+ };
6
+ /** Full history only; the caller has separately authorized its disclosure. */
7
+ export declare function verifyForeignRoster(input: ForeignVerifyInput): ForeignVerifyResult;
@@ -1,8 +1,13 @@
1
1
  export * from "./schema/index.js";
2
+ export * from "./conversation-agent-tools.js";
2
3
  export { b64u } from "./b64u.js";
3
4
  export { VERSION } from "./version.js";
4
5
  export { canonicalize } from "./jcs.js";
5
6
  export { parseWire } from "./wire.js";
7
+ export * from "./conversation/requests.js";
8
+ export * from "./conversation/request-log.js";
9
+ export * from "./conversation/request-seal.js";
10
+ export * from "./conversation/guest-invitation.js";
6
11
  export { sha256 } from "./hash.js";
7
12
  export { ulid } from "./ulid.js";
8
13
  export { Identity, IdentityFile, generateIdentity, exportIdentity, importIdentity } from "./identity.js";
@@ -26,20 +31,20 @@ export { MerkleLog, merkleLeafHash, verifyConsistency, verifyInclusion } from ".
26
31
  export { MAP_DEPTH, SparseMerkleTree, TOMBSTONE, emptyMapHash, mapKey, mapRootFromProof, mapValue, verifyMapProof } from "./directory/smt.js";
27
32
  export { parseAddress, formatAddress, type ParsedAddress } from "./address.js";
28
33
  export { decodeAdmitCard, decodeTeamCard, encodeAdmitCard, encodeTeamCard, type AdmitCard, type TeamCard, } from "./cards.js";
29
- export { decide, effectivePolicy, grantSubjectKey, levelsOf, preferGrant, resignGrant, restrictingLevels, signConsentGrant, verifyConsentGrant, wideningLevels, type ConsentClass, type ConsentDecision, type ConsentGrantArgs, type DecideArgs, type EffectivePolicy, type Inbound, type Relation, } from "./consent.js";
34
+ export { decide, effectivePolicy, grantSubjectKey, levelsOf, preferGrant, reachChoices, reachGrant, resignGrant, restrictingLevels, signConsentGrant, verifyConsentGrant, wideningLevels, type ConsentClass, type ConsentDecision, type ConsentGrantArgs, type DecideArgs, type EffectivePolicy, type Inbound, type ReachChoices, type Relation, } from "./consent.js";
30
35
  export { cardCan, signContactCard, verifyContactCard, type ContactCardArgs } from "./contact-card.js";
31
36
  export { createGrant, verifyChain, type GrantArgs, type ChainHop, type ChainContext, type VerifiedChain } from "./delegation.js";
32
37
  export { canTransition, isTerminal, isInterrupted } from "./task.js";
33
38
  export { TERMINAL_STATES } from "./schema/a2a.js";
34
39
  export { cleanPeerText, createFence, terminalSafe, displayWidth, HOST_TAGS, PEER_FENCE_TAG, PEER_DATA_NOTICE, provenanceOf, type CleanOptions, type Fence, type FenceAttributes, type FenceOptions, type TerminalOptions } from "./peer-text.js";
35
- export { AgentTool, TOOL_VERBS, TOOL_DESCRIPTIONS, ToolExpect, UNTRUSTED_SENTENCE, TOOL_REMEDIES, STORE_REFUSED_REMEDIES, DONE_STATES, TaskStateName, ToolErrorBody, ToolFiles, a2aTaskState, conversationOf, decodeToolCursor, encodeToolCursor, formatToolAddress, parseToolAddress, taskStateName, toolErrorBody, toolName, type ToolAddress, type ToolAuthor, type ToolChain, type ToolConsent, type ToolCursor, type ToolInput, type ToolOutput, type ToolPart, type ToolTask, type ToolVerb, } from "./agent-tools.js";
36
- export { Operations, type CallSession, type ChatAccess, type OperationsContext, type OperationsHooks, type SendPlan, type ToolLink, } from "./agent/operations.js";
37
- export { agentCan, consentOf, conversationOfPeer, followUpRead, isoOf, presentAgent, presentConvEntry, presentInboxItem, presentLine, presentMail, presentSent, presentTask, presentTaskItem, presentTaskView, } from "./agent/present.js";
40
+ export { AgentTool, TOOL_VERBS, TOOL_DESCRIPTIONS, ToolExpect, UNTRUSTED_SENTENCE, TOOL_REMEDIES, STORE_REFUSED_REMEDIES, DONE_STATES, TaskStateName, ToolErrorBody, ToolFiles, a2aTaskState, formatToolAddress, parseToolAddress, taskStateName, toolErrorBody, toolName, type ToolAddress, type ToolAuthor, type ToolChain, type ToolConsent, type ToolInput, type ToolOutput, type ToolPart, type ToolTask, type ToolVerb, } from "./agent-tools.js";
41
+ export { Operations, type CallSession, type ChatAccess, type OperationsContext, type OperationsHooks, type ToolLink, } from "./agent/operations.js";
42
+ export { agentCan, consentOf, followUpRead, isoOf, presentAgent, presentInboxItem, presentTaskEnvelope, presentTask, presentTaskItem, presentTaskView, } from "./agent/present.js";
38
43
  export { chainPath, compact, delegated, delegationPrompt, EXPECT_TEXT, isSafeId, messageAttributes, validatedAddress, type SessionAddressParts, type ToolFramer, } from "./agent/text.js";
39
44
  export { dmConvId, selfConvId, participantOf, participantPerson, participantAgent } from "./conversation/ids.js";
40
45
  export { admitConvEvent, convEntryHash, convEventDigest, convEventHeader, convEventSigned, convGenesisHash, convLinkHash, signConvEvent, verifyConvEvent, } from "./conversation/event.js";
41
46
  export { chainStep, ReceiverChains, ReceiverChainsState, SenderChain, SenderChainState } from "./conversation/ratchet.js";
42
- export { openConvMeta, openConvMsg, openKeyShares, sealConvMeta, sealConvMsg, sealKeyShares, type ShareRecipient, type UnsealedKeys, type UnsealedMsg, } from "./conversation/seal.js";
43
- export { ConvLog, type ConvApplyOptions, type ConvExpiredEntry, type ConvLiveChecks, type ConvMessage, type ConvParticipant, type ConvSnapshot, type ConvVote, } from "./conversation/log.js";
47
+ export { openConvMeta, openConvMsg, openConvState, openKeyShares, sealConvMeta, sealConvMsg, sealConvState, sealKeyShare, type ShareRecipient, type UnsealedKeys, type UnsealedMsg, type UnsealedOpEvent, type UnsealedStateOp, } from "./conversation/seal.js";
48
+ export { ConvLog, type ConvApplyOptions, type ConvLiveChecks, type ConvMessage, type ConvParticipant, type ConvSnapshot, type ConvVote, } from "./conversation/log.js";
44
49
  export { checkVia, currentLinks, linkReader } from "./conversation/link.js";
45
50
  export { CONTEXT_DEFAULTS, contextKindOf, matchContextRule, resolveContext, seatReads, type ContextConv, type ContextDecision, } from "./conversation/context.js";
@@ -15,7 +15,7 @@ export declare const JELLY_HOST_SKEW_S = 5;
15
15
  export type ActionClass = "view" | "chat" | "local";
16
16
  /**
17
17
  * The class a method grant must name in `cls` for each human- and admin-tier method (spec §8.11): `chat` for
18
- * `person.send`, `conv.markRead` and `notice.ack`, `view` for the read-only human-tier methods, `local` for every
18
+ * line mutations and `notice.ack`, `view` for the read-only human-tier methods, `local` for every
19
19
  * other. A plugin's `jelly` declaration gives each action and read the same class; a test there checks one against
20
20
  * the other.
21
21
  */
@@ -54,12 +54,20 @@ export declare const DOMAIN: {
54
54
  readonly convMsg: "messaging/1/conv-msg";
55
55
  /** Conversations (spec §16.5): HKDF `info` for a sender chain's next chain key. */
56
56
  readonly convChain: "messaging/1/conv-chain";
57
+ readonly request: "messaging/1/contact-request\n";
58
+ readonly requestContent: "messaging/1/contact-request-content\n";
59
+ readonly requestDigest: "messaging/1/contact-request-digest\n";
60
+ readonly requestDecision: "messaging/1/contact-request-decision\n";
61
+ readonly contactAuthorization: "messaging/1/contact-authorization\n";
62
+ readonly guestInvitation: "messaging/1/guest-invitation\n";
57
63
  };
58
64
  /** A2A extension and binding URIs owned by Messaging. */
59
65
  export declare const URI: {
60
66
  readonly binding: "urn:messaging:binding:relay:v1";
61
67
  readonly provenance: "urn:messaging:ext:provenance:v1";
62
68
  readonly presence: "urn:messaging:ext:presence:v1";
69
+ /** An `AUTH_REQUIRED` status message's `metadata[URI.signIn]`: `{tool}`, the tool whose sign-in the task waits on (spec §6.2). */
70
+ readonly signIn: "urn:messaging:ext:sign-in:v1";
63
71
  };
64
72
  export declare const Base64Url: z.ZodString;
65
73
  /** Any 32-byte value in base64url, e.g. a raw public key. */
@@ -81,8 +89,6 @@ export declare const HostedPersonId: z.ZodString;
81
89
  export declare const PersonId: z.ZodUnion<readonly [z.ZodString, z.ZodString]>;
82
90
  /** A channel's name (spec §6.8). Unique among the channels one machine holds, not across the team. */
83
91
  export declare const ChannelName: z.ZodString;
84
- /** A chat room (spec §6.8): `dm:<person>` for a direct human message, `channel:<name>` for a channel. */
85
- export declare const RoomRef: z.ZodString;
86
92
  export declare const SessionName: z.ZodString;
87
93
  export declare const MachineLabel: z.ZodString;
88
94
  export declare const TeamName: z.ZodString;
@@ -90,7 +96,7 @@ export declare const TeamName: z.ZodString;
90
96
  export declare const AgentKind: z.ZodString;
91
97
  /**
92
98
  * The agent kind of the human `messaging` command line (spec §8.2, §8.3): never kept or expired on
93
- * disconnect, refused as a task executor, and the only sender of group addresses.
99
+ * disconnect and refused as a task executor. No sender can use group addresses.
94
100
  */
95
101
  export declare const CLI_AGENT = "cli";
96
102
  /** Milliseconds since the Unix epoch. */
@@ -141,6 +147,8 @@ export declare const LIMITS: {
141
147
  readonly plaintextBytes: 262144;
142
148
  /** Max characters in a single text part. */
143
149
  readonly textPartChars: 65536;
150
+ /** Existing model-visible per-part cap, shared with fenced conversation events. */
151
+ readonly toolTextChars: 32768;
144
152
  /** Max parts in one message. */
145
153
  readonly partsPerMessage: 16;
146
154
  /** Default and max envelope TTL, and the max invite lifetime (`expires − ts`). */
@@ -292,12 +300,32 @@ export declare const LIMITS: {
292
300
  readonly rekeyScheduleMs: number;
293
301
  /** Max chain keys in one sealed key share, and in one `keys` sync of the `self` conversation. */
294
302
  readonly keyShares: 512;
295
- /** Max recipient devices one `keys` event seals to; a larger share is split over several events. */
296
- readonly keySharesPerEvent: 500;
297
303
  /** Max agents one event's `wake` hint names. */
298
304
  readonly wakeHints: 5;
299
305
  /** Max context rules a person holds (spec §16.8). */
300
306
  readonly contextRules: 500;
307
+ /** Relay (spec §7, "Conversation frames"): appends one device makes to one conversation, a burst of this many... */
308
+ readonly convAppendBurst: 20;
309
+ /** ...refilled at this many a minute. */
310
+ readonly convAppendsPerMinute: 60;
311
+ /** Appends to one conversation from all its devices, a minute (burst and refill). */
312
+ readonly convAppendsPerConvPerMinute: 600;
313
+ /** `rekey` ops with a cause the log cannot prove (`device`, `schedule`) per device per conversation, an hour. */
314
+ readonly convRekeysPerHour: 4;
315
+ /** Conversations one device takes part in, through its person (create, add and join refuse past it). */
316
+ readonly convsPerDevice: 5000;
317
+ /** Conversations one device creates, an hour (burst and refill). */
318
+ readonly convCreatesPerHour: 60;
319
+ /** Key-share events in one `conv.share` frame. */
320
+ readonly convSharesPerFrame: 100;
321
+ /** Key shares one sender device holds at the relay for one recipient device in one conversation. */
322
+ readonly convSharesPerPair: 256;
323
+ /** Key shares one device sends to one conversation, a burst of this many, refilled per minute. */
324
+ readonly convSharesPerMinute: 10000;
325
+ /** Entries (and shares) in one `conv.entries` reply. */
326
+ readonly convFetchEntries: 500;
327
+ /** Conversations named in one `conv.head`, and heads in one `conv.heads` reply. */
328
+ readonly convHeads: 500;
301
329
  };
302
330
  /**
303
331
  * True for a relay URL a client may connect to: `wss://`, or `ws://` to a loopback host (`localhost`,
@@ -315,7 +343,6 @@ export type PersonName = z.infer<typeof PersonName>;
315
343
  export type HostedPersonId = z.infer<typeof HostedPersonId>;
316
344
  export type PersonId = z.infer<typeof PersonId>;
317
345
  export type ChannelName = z.infer<typeof ChannelName>;
318
- export type RoomRef = z.infer<typeof RoomRef>;
319
346
  export type SessionName = z.infer<typeof SessionName>;
320
347
  export type MachineLabel = z.infer<typeof MachineLabel>;
321
348
  export type Millis = z.infer<typeof Millis>;
@@ -19,23 +19,39 @@ export declare const AgentMailLevel: z.ZodEnum<{
19
19
  export type AgentMailLevel = z.infer<typeof AgentMailLevel>;
20
20
  /** Mail and tasks from the subject or their agents to the person's agents: `request` holds each one for the person to answer. */
21
21
  export declare const AskLevel: z.ZodEnum<{
22
- open: "open";
23
22
  request: "request";
23
+ open: "open";
24
24
  no: "no";
25
25
  }>;
26
26
  export type AskLevel = z.infer<typeof AskLevel>;
27
- /** Whom a grant is about: one person, or every member of one channel (by its id). */
27
+ /**
28
+ * The relations a reach choice is about (spec §6.9, "Reach choices"): `outside`, the people of other orgs (`contact`
29
+ * and `stranger`), whose `chat` the person's "Who can message you" sets; `org`, the person's teammates, whose `ask`
30
+ * their "How agents may ask yours" sets.
31
+ */
32
+ export declare const GrantRelation: z.ZodEnum<{
33
+ org: "org";
34
+ outside: "outside";
35
+ }>;
36
+ export type GrantRelation = z.infer<typeof GrantRelation>;
37
+ /** Whom a grant is about: one person, the verified participants of one conversation, or one relation (a reach choice). */
28
38
  export declare const GrantSubject: z.ZodUnion<readonly [z.ZodObject<{
29
39
  person: z.ZodUnion<readonly [z.ZodString, z.ZodString]>;
30
40
  }, z.core.$strict>, z.ZodObject<{
31
- channel: z.ZodString;
41
+ conv: z.ZodString;
42
+ }, z.core.$strict>, z.ZodObject<{
43
+ relation: z.ZodEnum<{
44
+ org: "org";
45
+ outside: "outside";
46
+ }>;
32
47
  }, z.core.$strict>]>;
33
48
  export type GrantSubject = z.infer<typeof GrantSubject>;
34
49
  /**
35
50
  * A grant, signed by `by`, a device of `person`: `sig = Ed25519(by, "messaging/1/grant\n" || JCS(grant without sig))`.
36
51
  * Every level is optional: an absent level is the default for the relation (spec §6.9, "Effective policy"), and a
37
52
  * grant with none is a clear. `trustedUntil` needs `ask: "open"` and is at most `ts + LIMITS.trustMaxMs`. A channel
38
- * grant sets only `ask` and `agentMail`. A grant about the person themself sets only `discoverable`.
53
+ * grant sets only `ask` and `agentMail`. A grant about the person themself sets only `discoverable`. A relation
54
+ * grant (a reach choice) sets only `chat` (`open` or `blocked`) for `outside`, and only `ask` for `org`.
39
55
  * `resignedAt` marks a grant re-signed by another device of the person (spec §6.9, "Signers"); it keeps `id` and
40
56
  * `ts`.
41
57
  */
@@ -49,7 +65,12 @@ export declare const ConsentGrant: z.ZodObject<{
49
65
  subject: z.ZodUnion<readonly [z.ZodObject<{
50
66
  person: z.ZodUnion<readonly [z.ZodString, z.ZodString]>;
51
67
  }, z.core.$strict>, z.ZodObject<{
52
- channel: z.ZodString;
68
+ conv: z.ZodString;
69
+ }, z.core.$strict>, z.ZodObject<{
70
+ relation: z.ZodEnum<{
71
+ org: "org";
72
+ outside: "outside";
73
+ }>;
53
74
  }, z.core.$strict>]>;
54
75
  chat: z.ZodOptional<z.ZodEnum<{
55
76
  open: "open";
@@ -61,8 +82,8 @@ export declare const ConsentGrant: z.ZodObject<{
61
82
  blocked: "blocked";
62
83
  }>>;
63
84
  ask: z.ZodOptional<z.ZodEnum<{
64
- open: "open";
65
85
  request: "request";
86
+ open: "open";
66
87
  no: "no";
67
88
  }>>;
68
89
  trustedUntil: z.ZodOptional<z.ZodNumber>;
@@ -93,8 +114,8 @@ export declare const CardCan: z.ZodObject<{
93
114
  chat: z.ZodBoolean;
94
115
  agentMail: z.ZodBoolean;
95
116
  ask: z.ZodEnum<{
96
- open: "open";
97
117
  request: "request";
118
+ open: "open";
98
119
  no: "no";
99
120
  }>;
100
121
  trustedUntil: z.ZodOptional<z.ZodNumber>;
@@ -119,8 +140,8 @@ export declare const ContactCard: z.ZodObject<{
119
140
  chat: z.ZodBoolean;
120
141
  agentMail: z.ZodBoolean;
121
142
  ask: z.ZodEnum<{
122
- open: "open";
123
143
  request: "request";
144
+ open: "open";
124
145
  no: "no";
125
146
  }>;
126
147
  trustedUntil: z.ZodOptional<z.ZodNumber>;
@@ -0,0 +1,264 @@
1
+ /** Portable same-realm contact requests (spec §16.11). All proofs are strict and domain-separated. */
2
+ import { z } from "zod";
3
+ export declare const RequestDescriptor: z.ZodObject<{
4
+ id: z.ZodString;
5
+ issuedAt: z.ZodNumber;
6
+ expiresAt: z.ZodNumber;
7
+ commitment: z.ZodString;
8
+ by: z.ZodString;
9
+ sig: z.ZodString;
10
+ v: z.ZodLiteral<"messaging/1">;
11
+ realm: z.ZodString;
12
+ cid: z.ZodString;
13
+ from: z.ZodUnion<readonly [z.ZodString, z.ZodString]>;
14
+ to: z.ZodUnion<readonly [z.ZodString, z.ZodString]>;
15
+ }, z.core.$strict>;
16
+ export type RequestDescriptor = z.infer<typeof RequestDescriptor>;
17
+ export declare const RequestOpening: z.ZodObject<{
18
+ salt: z.ZodString;
19
+ text: z.ZodString;
20
+ }, z.core.$strict>;
21
+ export type RequestOpening = z.infer<typeof RequestOpening>;
22
+ export declare const PortableRequest: z.ZodObject<{
23
+ descriptor: z.ZodObject<{
24
+ id: z.ZodString;
25
+ issuedAt: z.ZodNumber;
26
+ expiresAt: z.ZodNumber;
27
+ commitment: z.ZodString;
28
+ by: z.ZodString;
29
+ sig: z.ZodString;
30
+ v: z.ZodLiteral<"messaging/1">;
31
+ realm: z.ZodString;
32
+ cid: z.ZodString;
33
+ from: z.ZodUnion<readonly [z.ZodString, z.ZodString]>;
34
+ to: z.ZodUnion<readonly [z.ZodString, z.ZodString]>;
35
+ }, z.core.$strict>;
36
+ opening: z.ZodObject<{
37
+ salt: z.ZodString;
38
+ text: z.ZodString;
39
+ }, z.core.$strict>;
40
+ }, z.core.$strict>;
41
+ export type PortableRequest = z.infer<typeof PortableRequest>;
42
+ /** A block is conveyed as decline. The first valid terminal answer is sequenced in the recipient mailbox. */
43
+ export declare const RequestDecision: z.ZodObject<{
44
+ id: z.ZodString;
45
+ descriptor: z.ZodString;
46
+ answer: z.ZodEnum<{
47
+ accept: "accept";
48
+ decline: "decline";
49
+ }>;
50
+ at: z.ZodNumber;
51
+ by: z.ZodString;
52
+ sig: z.ZodString;
53
+ v: z.ZodLiteral<"messaging/1">;
54
+ realm: z.ZodString;
55
+ cid: z.ZodString;
56
+ from: z.ZodUnion<readonly [z.ZodString, z.ZodString]>;
57
+ to: z.ZodUnion<readonly [z.ZodString, z.ZodString]>;
58
+ }, z.core.$strict>;
59
+ export type RequestDecision = z.infer<typeof RequestDecision>;
60
+ export declare const RequestActivation: z.ZodObject<{
61
+ descriptor: z.ZodObject<{
62
+ id: z.ZodString;
63
+ issuedAt: z.ZodNumber;
64
+ expiresAt: z.ZodNumber;
65
+ commitment: z.ZodString;
66
+ by: z.ZodString;
67
+ sig: z.ZodString;
68
+ v: z.ZodLiteral<"messaging/1">;
69
+ realm: z.ZodString;
70
+ cid: z.ZodString;
71
+ from: z.ZodUnion<readonly [z.ZodString, z.ZodString]>;
72
+ to: z.ZodUnion<readonly [z.ZodString, z.ZodString]>;
73
+ }, z.core.$strict>;
74
+ decision: z.ZodObject<{
75
+ id: z.ZodString;
76
+ descriptor: z.ZodString;
77
+ answer: z.ZodEnum<{
78
+ accept: "accept";
79
+ decline: "decline";
80
+ }>;
81
+ at: z.ZodNumber;
82
+ by: z.ZodString;
83
+ sig: z.ZodString;
84
+ v: z.ZodLiteral<"messaging/1">;
85
+ realm: z.ZodString;
86
+ cid: z.ZodString;
87
+ from: z.ZodUnion<readonly [z.ZodString, z.ZodString]>;
88
+ to: z.ZodUnion<readonly [z.ZodString, z.ZodString]>;
89
+ }, z.core.$strict>;
90
+ }, z.core.$strict>;
91
+ export type RequestActivation = z.infer<typeof RequestActivation>;
92
+ /** Existing contacts authorize the exact human DM on both sides, under their current local grants. */
93
+ export declare const ContactAuthorization: z.ZodObject<{
94
+ at: z.ZodNumber;
95
+ by: z.ZodString;
96
+ sig: z.ZodString;
97
+ v: z.ZodLiteral<"messaging/1">;
98
+ realm: z.ZodString;
99
+ cid: z.ZodString;
100
+ from: z.ZodUnion<readonly [z.ZodString, z.ZodString]>;
101
+ to: z.ZodUnion<readonly [z.ZodString, z.ZodString]>;
102
+ }, z.core.$strict>;
103
+ export type ContactAuthorization = z.infer<typeof ContactAuthorization>;
104
+ export declare const ActivationProof: z.ZodUnion<readonly [z.ZodObject<{
105
+ descriptor: z.ZodObject<{
106
+ id: z.ZodString;
107
+ issuedAt: z.ZodNumber;
108
+ expiresAt: z.ZodNumber;
109
+ commitment: z.ZodString;
110
+ by: z.ZodString;
111
+ sig: z.ZodString;
112
+ v: z.ZodLiteral<"messaging/1">;
113
+ realm: z.ZodString;
114
+ cid: z.ZodString;
115
+ from: z.ZodUnion<readonly [z.ZodString, z.ZodString]>;
116
+ to: z.ZodUnion<readonly [z.ZodString, z.ZodString]>;
117
+ }, z.core.$strict>;
118
+ decision: z.ZodObject<{
119
+ id: z.ZodString;
120
+ descriptor: z.ZodString;
121
+ answer: z.ZodEnum<{
122
+ accept: "accept";
123
+ decline: "decline";
124
+ }>;
125
+ at: z.ZodNumber;
126
+ by: z.ZodString;
127
+ sig: z.ZodString;
128
+ v: z.ZodLiteral<"messaging/1">;
129
+ realm: z.ZodString;
130
+ cid: z.ZodString;
131
+ from: z.ZodUnion<readonly [z.ZodString, z.ZodString]>;
132
+ to: z.ZodUnion<readonly [z.ZodString, z.ZodString]>;
133
+ }, z.core.$strict>;
134
+ }, z.core.$strict>, z.ZodObject<{
135
+ contacts: z.ZodTuple<[z.ZodObject<{
136
+ at: z.ZodNumber;
137
+ by: z.ZodString;
138
+ sig: z.ZodString;
139
+ v: z.ZodLiteral<"messaging/1">;
140
+ realm: z.ZodString;
141
+ cid: z.ZodString;
142
+ from: z.ZodUnion<readonly [z.ZodString, z.ZodString]>;
143
+ to: z.ZodUnion<readonly [z.ZodString, z.ZodString]>;
144
+ }, z.core.$strict>, z.ZodObject<{
145
+ at: z.ZodNumber;
146
+ by: z.ZodString;
147
+ sig: z.ZodString;
148
+ v: z.ZodLiteral<"messaging/1">;
149
+ realm: z.ZodString;
150
+ cid: z.ZodString;
151
+ from: z.ZodUnion<readonly [z.ZodString, z.ZodString]>;
152
+ to: z.ZodUnion<readonly [z.ZodString, z.ZodString]>;
153
+ }, z.core.$strict>], null>;
154
+ }, z.core.$strict>]>;
155
+ export type ActivationProof = z.infer<typeof ActivationProof>;
156
+ export declare const RequestImport: z.ZodObject<{
157
+ opening: z.ZodObject<{
158
+ salt: z.ZodString;
159
+ text: z.ZodString;
160
+ }, z.core.$strict>;
161
+ descriptor: z.ZodObject<{
162
+ id: z.ZodString;
163
+ issuedAt: z.ZodNumber;
164
+ expiresAt: z.ZodNumber;
165
+ commitment: z.ZodString;
166
+ by: z.ZodString;
167
+ sig: z.ZodString;
168
+ v: z.ZodLiteral<"messaging/1">;
169
+ realm: z.ZodString;
170
+ cid: z.ZodString;
171
+ from: z.ZodUnion<readonly [z.ZodString, z.ZodString]>;
172
+ to: z.ZodUnion<readonly [z.ZodString, z.ZodString]>;
173
+ }, z.core.$strict>;
174
+ decision: z.ZodObject<{
175
+ id: z.ZodString;
176
+ descriptor: z.ZodString;
177
+ answer: z.ZodEnum<{
178
+ accept: "accept";
179
+ decline: "decline";
180
+ }>;
181
+ at: z.ZodNumber;
182
+ by: z.ZodString;
183
+ sig: z.ZodString;
184
+ v: z.ZodLiteral<"messaging/1">;
185
+ realm: z.ZodString;
186
+ cid: z.ZodString;
187
+ from: z.ZodUnion<readonly [z.ZodString, z.ZodString]>;
188
+ to: z.ZodUnion<readonly [z.ZodString, z.ZodString]>;
189
+ }, z.core.$strict>;
190
+ t: z.ZodLiteral<"request.import">;
191
+ }, z.core.$strict>;
192
+ export type RequestImport = z.infer<typeof RequestImport>;
193
+ /** No opening or request text is sent to the relay. */
194
+ export declare const RequestSettleFrame: z.ZodObject<{
195
+ descriptor: z.ZodObject<{
196
+ id: z.ZodString;
197
+ issuedAt: z.ZodNumber;
198
+ expiresAt: z.ZodNumber;
199
+ commitment: z.ZodString;
200
+ by: z.ZodString;
201
+ sig: z.ZodString;
202
+ v: z.ZodLiteral<"messaging/1">;
203
+ realm: z.ZodString;
204
+ cid: z.ZodString;
205
+ from: z.ZodUnion<readonly [z.ZodString, z.ZodString]>;
206
+ to: z.ZodUnion<readonly [z.ZodString, z.ZodString]>;
207
+ }, z.core.$strict>;
208
+ decision: z.ZodObject<{
209
+ id: z.ZodString;
210
+ descriptor: z.ZodString;
211
+ answer: z.ZodEnum<{
212
+ accept: "accept";
213
+ decline: "decline";
214
+ }>;
215
+ at: z.ZodNumber;
216
+ by: z.ZodString;
217
+ sig: z.ZodString;
218
+ v: z.ZodLiteral<"messaging/1">;
219
+ realm: z.ZodString;
220
+ cid: z.ZodString;
221
+ from: z.ZodUnion<readonly [z.ZodString, z.ZodString]>;
222
+ to: z.ZodUnion<readonly [z.ZodString, z.ZodString]>;
223
+ }, z.core.$strict>;
224
+ t: z.ZodLiteral<"request.settle">;
225
+ req: z.ZodString;
226
+ }, z.core.$strict>;
227
+ export declare const RequestStateFrame: z.ZodObject<{
228
+ t: z.ZodLiteral<"request.state">;
229
+ req: z.ZodString;
230
+ descriptor: z.ZodObject<{
231
+ id: z.ZodString;
232
+ issuedAt: z.ZodNumber;
233
+ expiresAt: z.ZodNumber;
234
+ commitment: z.ZodString;
235
+ by: z.ZodString;
236
+ sig: z.ZodString;
237
+ v: z.ZodLiteral<"messaging/1">;
238
+ realm: z.ZodString;
239
+ cid: z.ZodString;
240
+ from: z.ZodUnion<readonly [z.ZodString, z.ZodString]>;
241
+ to: z.ZodUnion<readonly [z.ZodString, z.ZodString]>;
242
+ }, z.core.$strict>;
243
+ }, z.core.$strict>;
244
+ export declare const RequestSettledFrame: z.ZodObject<{
245
+ t: z.ZodLiteral<"request.settled">;
246
+ req: z.ZodString;
247
+ id: z.ZodString;
248
+ decision: z.ZodOptional<z.ZodObject<{
249
+ id: z.ZodString;
250
+ descriptor: z.ZodString;
251
+ answer: z.ZodEnum<{
252
+ accept: "accept";
253
+ decline: "decline";
254
+ }>;
255
+ at: z.ZodNumber;
256
+ by: z.ZodString;
257
+ sig: z.ZodString;
258
+ v: z.ZodLiteral<"messaging/1">;
259
+ realm: z.ZodString;
260
+ cid: z.ZodString;
261
+ from: z.ZodUnion<readonly [z.ZodString, z.ZodString]>;
262
+ to: z.ZodUnion<readonly [z.ZodString, z.ZodString]>;
263
+ }, z.core.$strict>>;
264
+ }, z.core.$strict>;