@agenticprimitives/fabric 0.0.0-alpha.4 → 0.0.0-alpha.41

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 (198) hide show
  1. package/CLAUDE.md +28 -35
  2. package/README.md +18 -16
  3. package/dist/adoption.d.ts +79 -0
  4. package/dist/adoption.d.ts.map +1 -0
  5. package/dist/adoption.js +95 -0
  6. package/dist/adoption.js.map +1 -0
  7. package/dist/case-emissions.d.ts +95 -0
  8. package/dist/case-emissions.d.ts.map +1 -0
  9. package/dist/case-emissions.js +208 -0
  10. package/dist/case-emissions.js.map +1 -0
  11. package/dist/case-machine.d.ts +28 -2
  12. package/dist/case-machine.d.ts.map +1 -1
  13. package/dist/case-machine.js +34 -7
  14. package/dist/case-machine.js.map +1 -1
  15. package/dist/cloudflare/authority-verdict-cache.d.ts +28 -1
  16. package/dist/cloudflare/authority-verdict-cache.d.ts.map +1 -1
  17. package/dist/cloudflare/authority-verdict-cache.js +32 -1
  18. package/dist/cloudflare/authority-verdict-cache.js.map +1 -1
  19. package/dist/cloudflare/exchange-store.d.ts +20 -1
  20. package/dist/cloudflare/exchange-store.d.ts.map +1 -1
  21. package/dist/cloudflare/exchange-store.js +26 -4
  22. package/dist/cloudflare/exchange-store.js.map +1 -1
  23. package/dist/cloudflare/index.d.ts +7 -4
  24. package/dist/cloudflare/index.d.ts.map +1 -1
  25. package/dist/cloudflare/index.js +8 -2
  26. package/dist/cloudflare/index.js.map +1 -1
  27. package/dist/cloudflare/interaction-store.d.ts +81 -0
  28. package/dist/cloudflare/interaction-store.d.ts.map +1 -0
  29. package/dist/cloudflare/interaction-store.js +281 -0
  30. package/dist/cloudflare/interaction-store.js.map +1 -0
  31. package/dist/cloudflare/orchestration-runtime.d.ts +19 -5
  32. package/dist/cloudflare/orchestration-runtime.d.ts.map +1 -1
  33. package/dist/cloudflare/orchestration-runtime.js +11 -6
  34. package/dist/cloudflare/orchestration-runtime.js.map +1 -1
  35. package/dist/cloudflare/principal-gateway-do.d.ts +360 -30
  36. package/dist/cloudflare/principal-gateway-do.d.ts.map +1 -1
  37. package/dist/cloudflare/principal-gateway-do.js +580 -58
  38. package/dist/cloudflare/principal-gateway-do.js.map +1 -1
  39. package/dist/cloudflare/receipt-signer.d.ts.map +1 -1
  40. package/dist/cloudflare/receipt-signer.js +6 -3
  41. package/dist/cloudflare/receipt-signer.js.map +1 -1
  42. package/dist/cloudflare/sql-vault.d.ts.map +1 -1
  43. package/dist/cloudflare/sql-vault.js +56 -0
  44. package/dist/cloudflare/sql-vault.js.map +1 -1
  45. package/dist/cloudflare/vault-exchange-store.d.ts +47 -0
  46. package/dist/cloudflare/vault-exchange-store.d.ts.map +1 -0
  47. package/dist/cloudflare/vault-exchange-store.js +135 -0
  48. package/dist/cloudflare/vault-exchange-store.js.map +1 -0
  49. package/dist/cloudflare/vault-interaction-store.d.ts +44 -0
  50. package/dist/cloudflare/vault-interaction-store.d.ts.map +1 -0
  51. package/dist/cloudflare/vault-interaction-store.js +259 -0
  52. package/dist/cloudflare/vault-interaction-store.js.map +1 -0
  53. package/dist/communicative-act.d.ts +24 -1
  54. package/dist/communicative-act.d.ts.map +1 -1
  55. package/dist/communicative-act.js +28 -0
  56. package/dist/communicative-act.js.map +1 -1
  57. package/dist/delivery-envelope.d.ts.map +1 -1
  58. package/dist/delivery-envelope.js +0 -1
  59. package/dist/delivery-envelope.js.map +1 -1
  60. package/dist/email/index.d.ts +79 -0
  61. package/dist/email/index.d.ts.map +1 -0
  62. package/dist/email/index.js +91 -0
  63. package/dist/email/index.js.map +1 -0
  64. package/dist/enum-retirement.d.ts +43 -0
  65. package/dist/enum-retirement.d.ts.map +1 -0
  66. package/dist/enum-retirement.js +93 -0
  67. package/dist/enum-retirement.js.map +1 -0
  68. package/dist/exchange-record.d.ts +35 -4
  69. package/dist/exchange-record.d.ts.map +1 -1
  70. package/dist/exchange-record.js.map +1 -1
  71. package/dist/exchange-reducer.d.ts +32 -4
  72. package/dist/exchange-reducer.d.ts.map +1 -1
  73. package/dist/exchange-reducer.js +75 -1
  74. package/dist/exchange-reducer.js.map +1 -1
  75. package/dist/exchange-state.d.ts +30 -8
  76. package/dist/exchange-state.d.ts.map +1 -1
  77. package/dist/exchange-state.js +12 -10
  78. package/dist/exchange-state.js.map +1 -1
  79. package/dist/inbox-doc.d.ts +2 -2
  80. package/dist/inbox-doc.d.ts.map +1 -1
  81. package/dist/inbox-doc.js.map +1 -1
  82. package/dist/inbox-projection.d.ts +2 -2
  83. package/dist/inbox-projection.d.ts.map +1 -1
  84. package/dist/inbox-projection.js.map +1 -1
  85. package/dist/inbox-revision.d.ts +42 -0
  86. package/dist/inbox-revision.d.ts.map +1 -0
  87. package/dist/inbox-revision.js +57 -0
  88. package/dist/inbox-revision.js.map +1 -0
  89. package/dist/index.d.ts +26 -3
  90. package/dist/index.d.ts.map +1 -1
  91. package/dist/index.js +40 -2
  92. package/dist/index.js.map +1 -1
  93. package/dist/interaction-machines.d.ts +136 -0
  94. package/dist/interaction-machines.d.ts.map +1 -0
  95. package/dist/interaction-machines.js +174 -0
  96. package/dist/interaction-machines.js.map +1 -0
  97. package/dist/interaction-profile.d.ts +136 -0
  98. package/dist/interaction-profile.d.ts.map +1 -0
  99. package/dist/interaction-profile.js +212 -0
  100. package/dist/interaction-profile.js.map +1 -0
  101. package/dist/interaction-record.d.ts +168 -0
  102. package/dist/interaction-record.d.ts.map +1 -0
  103. package/dist/interaction-record.js +108 -0
  104. package/dist/interaction-record.js.map +1 -0
  105. package/dist/interactions/grant-scopes.d.ts +21 -0
  106. package/dist/interactions/grant-scopes.d.ts.map +1 -0
  107. package/dist/interactions/grant-scopes.js +88 -0
  108. package/dist/interactions/grant-scopes.js.map +1 -0
  109. package/dist/interactions/index.d.ts +1 -0
  110. package/dist/interactions/index.d.ts.map +1 -1
  111. package/dist/interactions/index.js +3 -0
  112. package/dist/interactions/index.js.map +1 -1
  113. package/dist/interactions/machine.d.ts +2 -2
  114. package/dist/interactions/machine.d.ts.map +1 -1
  115. package/dist/interactions/machine.js +2 -2
  116. package/dist/interactions/machine.js.map +1 -1
  117. package/dist/interactions/open-case.d.ts +60 -0
  118. package/dist/interactions/open-case.d.ts.map +1 -0
  119. package/dist/interactions/open-case.js +83 -0
  120. package/dist/interactions/open-case.js.map +1 -0
  121. package/dist/interactions/store.d.ts +9 -0
  122. package/dist/interactions/store.d.ts.map +1 -1
  123. package/dist/interactions/store.js +57 -2
  124. package/dist/interactions/store.js.map +1 -1
  125. package/dist/messaging/board.d.ts +4 -4
  126. package/dist/messaging/board.d.ts.map +1 -1
  127. package/dist/messaging/board.js +2 -2
  128. package/dist/messaging/board.js.map +1 -1
  129. package/dist/messaging/consult-routing.d.ts +103 -23
  130. package/dist/messaging/consult-routing.d.ts.map +1 -1
  131. package/dist/messaging/consult-routing.js +157 -47
  132. package/dist/messaging/consult-routing.js.map +1 -1
  133. package/dist/messaging/consult.d.ts +4 -0
  134. package/dist/messaging/consult.d.ts.map +1 -1
  135. package/dist/messaging/consult.js +3 -1
  136. package/dist/messaging/consult.js.map +1 -1
  137. package/dist/messaging/conversation-interaction.d.ts +66 -0
  138. package/dist/messaging/conversation-interaction.d.ts.map +1 -0
  139. package/dist/messaging/conversation-interaction.js +139 -0
  140. package/dist/messaging/conversation-interaction.js.map +1 -0
  141. package/dist/messaging/conversation.d.ts +69 -1
  142. package/dist/messaging/conversation.d.ts.map +1 -1
  143. package/dist/messaging/conversation.js +131 -0
  144. package/dist/messaging/conversation.js.map +1 -1
  145. package/dist/messaging/delivery.d.ts +2 -2
  146. package/dist/messaging/delivery.d.ts.map +1 -1
  147. package/dist/messaging/delivery.js +8 -1
  148. package/dist/messaging/delivery.js.map +1 -1
  149. package/dist/messaging/envelope.d.ts +7 -3
  150. package/dist/messaging/envelope.d.ts.map +1 -1
  151. package/dist/messaging/envelope.js +18 -1
  152. package/dist/messaging/envelope.js.map +1 -1
  153. package/dist/messaging/hash.d.ts +8 -2
  154. package/dist/messaging/hash.d.ts.map +1 -1
  155. package/dist/messaging/hash.js +6 -0
  156. package/dist/messaging/hash.js.map +1 -1
  157. package/dist/messaging/inbox-assistant.d.ts +16 -4
  158. package/dist/messaging/inbox-assistant.d.ts.map +1 -1
  159. package/dist/messaging/inbox-assistant.js +27 -4
  160. package/dist/messaging/inbox-assistant.js.map +1 -1
  161. package/dist/messaging/index.d.ts +7 -3
  162. package/dist/messaging/index.d.ts.map +1 -1
  163. package/dist/messaging/index.js +11 -2
  164. package/dist/messaging/index.js.map +1 -1
  165. package/dist/messaging/outbound-message.d.ts +42 -0
  166. package/dist/messaging/outbound-message.d.ts.map +1 -0
  167. package/dist/messaging/outbound-message.js +64 -0
  168. package/dist/messaging/outbound-message.js.map +1 -0
  169. package/dist/messaging/projector.d.ts +3 -3
  170. package/dist/messaging/projector.d.ts.map +1 -1
  171. package/dist/messaging/projector.js.map +1 -1
  172. package/dist/messaging/receipts.d.ts +3 -3
  173. package/dist/messaging/receipts.d.ts.map +1 -1
  174. package/dist/messaging/receipts.js.map +1 -1
  175. package/dist/messaging/rules.d.ts +10 -3
  176. package/dist/messaging/rules.d.ts.map +1 -1
  177. package/dist/messaging/rules.js +8 -1
  178. package/dist/messaging/rules.js.map +1 -1
  179. package/dist/messaging/store.d.ts +4 -4
  180. package/dist/messaging/store.d.ts.map +1 -1
  181. package/dist/messaging/store.js +5 -3
  182. package/dist/messaging/store.js.map +1 -1
  183. package/dist/messaging/types.d.ts +30 -0
  184. package/dist/messaging/types.d.ts.map +1 -1
  185. package/dist/messaging/types.js +3 -0
  186. package/dist/messaging/types.js.map +1 -1
  187. package/dist/messaging/vault-store.d.ts +2 -2
  188. package/dist/messaging/vault-store.d.ts.map +1 -1
  189. package/dist/messaging/vault-store.js +8 -0
  190. package/dist/messaging/vault-store.js.map +1 -1
  191. package/dist/protocol-binding.d.ts +71 -0
  192. package/dist/protocol-binding.d.ts.map +1 -0
  193. package/dist/protocol-binding.js +0 -0
  194. package/dist/protocol-binding.js.map +1 -0
  195. package/dist/record-catalog.d.ts.map +1 -1
  196. package/dist/record-catalog.js +12 -0
  197. package/dist/record-catalog.js.map +1 -1
  198. package/package.json +28 -15
@@ -0,0 +1,259 @@
1
+ // The VAULT-BACKED `InteractionStore` (spec 316 §0b, ADR-0055 amendment, audit G-2).
2
+ //
3
+ // Same residency decision as the exchange store, for the same reason: **each party holds their own copy**.
4
+ // An Interaction is a governed situation with participants, and each participant's vault holds their view
5
+ // of it. No single system of record; no copy authoritative over another. A rebuild is therefore a
6
+ // SINGLE-VAULT read — recovery never waits on a counterparty being reachable, willing, or still extant.
7
+ //
8
+ // SIX FAMILIES, ONE INDEX. Interactions, decisions, commitments, inbox entries, context snapshots and
9
+ // protocol bindings each get their own vault resource; one `interaction.index` document carries the ids.
10
+ // Six index documents would mean six writes to keep in step and six ways for them to drift.
11
+ //
12
+ // THE TWO INVARIANTS OF THE DO-LOCAL STORE ARE PRESERVED EXACTLY, because they are about immutability and
13
+ // they do not become negotiable when the backing store changes:
14
+ //
15
+ // 1. A ContextSnapshot is CONTENT-ADDRESSED and the digest is verified before storing. A forged snapshot
16
+ // is refused at the door rather than detected later. Re-putting a verified digest that is already
17
+ // present is a no-op — that is what content-addressing means.
18
+ // 2. Every transition goes THROUGH its machine. This store never assigns a state, so "the creditor
19
+ // discharges, not the debtor" cannot be bypassed by writing the row. A rejected transition writes
20
+ // NOTHING: persisting it "for the audit trail" would make the machine advisory.
21
+ //
22
+ // It confers nothing. Persisting a commitment does not make it owed; persisting a decision authorizes
23
+ // nothing (ADR-0041).
24
+ import { verifyContextSnapshot } from '../interaction-record.js';
25
+ import { applyInteractionTransition, applyDecisionTransition, applyCommitmentTransition, applyInboxTransition, } from '../interaction-machines.js';
26
+ import { bindingKey, resolveInteractionByBinding, } from '../protocol-binding.js';
27
+ import { guardPutOverTerminal } from './interaction-store.js';
28
+ export const INTERACTION_INDEX_RESOURCE = 'interaction.index';
29
+ export const interactionResource = (id) => `interaction:${String(id)}`;
30
+ export const decisionResource = (id) => `interaction.decision:${id}`;
31
+ export const commitmentResource = (id) => `interaction.commitment:${id}`;
32
+ export const snapshotResource = (digest) => `interaction.snapshot:${digest}`;
33
+ export const inboxEntryResource = (viewer, exchangeId) => `interaction.inbox:${viewer.toLowerCase()}:${exchangeId}`;
34
+ /** States an obligation is still live in. `discharged`/`breached`/`void` are ended, differently. */
35
+ const OPEN_COMMITMENT_STATES = new Set(['proposed', 'active', 'fulfilment-claimed']);
36
+ const EMPTY = {
37
+ version: 1, interactions: [], decisions: [], commitments: [], snapshots: [], inboxEntries: [], bindings: {},
38
+ };
39
+ export function createVaultInteractionStore(vault, owner, cache) {
40
+ const readIndex = async () => {
41
+ const obj = await vault.read({ owner, resource: INTERACTION_INDEX_RESOURCE });
42
+ return { ...EMPTY, ...(obj?.data ?? {}) };
43
+ };
44
+ const writeIndex = async (mutate) => {
45
+ const next = mutate(await readIndex());
46
+ await vault.write({ owner, resource: INTERACTION_INDEX_RESOURCE, data: next, classification: 'internal' });
47
+ };
48
+ /** WRITE-THROUGH. The vault first — the durable fact — then the index, then the DO-local cache. A crash
49
+ * after the first leaves a cache that can be re-derived; the reverse order leaves one that cannot. */
50
+ const save = async (resource, data, index) => {
51
+ await vault.write({ owner, resource, data, classification: 'internal' });
52
+ if (index)
53
+ await writeIndex(index);
54
+ cache?.put(resource, data);
55
+ };
56
+ const load = async (resource) => {
57
+ const hit = cache?.get(resource);
58
+ // A cache hit is the SAME answer the vault holds, not a second mechanism (ADR-0013).
59
+ if (hit)
60
+ return hit;
61
+ const obj = await vault.read({ owner, resource });
62
+ return obj?.data ?? null;
63
+ };
64
+ const addOnce = (list, id) => (list.includes(id) ? list : [...list, id]);
65
+ const store = {
66
+ // ── Interactions ────────────────────────────────────────────────────────────────────────────────
67
+ // A put never replaces an ENDED record (spec 445 §3.4, audit DATB-6) — here the write would land in
68
+ // the owner's vault, the record itself. The read-then-write is sound only inside the single-writer
69
+ // DO. `transition*` below still writes through these methods: a machine only ever advances a
70
+ // non-terminal record, so the guard never refuses a legitimate transition.
71
+ async putInteraction(record) {
72
+ const existing = await this.getInteraction(record.interactionId);
73
+ if (guardPutOverTerminal('interaction', String(record.interactionId), existing, record, (r) => r.lifecycleState) === 'skip')
74
+ return;
75
+ await save(interactionResource(record.interactionId), record, (i) => ({
76
+ ...i, interactions: addOnce(i.interactions, String(record.interactionId)),
77
+ }));
78
+ },
79
+ async getInteraction(id) {
80
+ return load(interactionResource(id));
81
+ },
82
+ async listInteractions() {
83
+ const idx = await readIndex();
84
+ const all = await Promise.all(idx.interactions.map((id) => this.getInteraction(id)));
85
+ return all.filter((r) => r !== null);
86
+ },
87
+ async transitionInteraction(id, event) {
88
+ const record = await this.getInteraction(id);
89
+ if (!record)
90
+ return null;
91
+ const result = applyInteractionTransition(lifecycleOf(record), event);
92
+ // Fail-closed: a rejection leaves the record exactly as it was.
93
+ if (result.ok) {
94
+ await this.putInteraction({
95
+ ...record, lifecycleState: result.next.state, updatedAt: event.at, rev: record.rev + 1,
96
+ });
97
+ }
98
+ return result;
99
+ },
100
+ // ── Protocol bindings ───────────────────────────────────────────────────────────────────────────
101
+ async bindProtocolTo(id, binding) {
102
+ const key = bindingKey(binding.protocol, binding.field, binding.value);
103
+ await writeIndex((i) => ({
104
+ ...i,
105
+ // Appended, never de-duplicated across interactions: a correlator naming two interactions IS the
106
+ // ambiguity, and collapsing it here would answer an ambiguous question with a confident wrong one.
107
+ bindings: { ...i.bindings, [key]: [...(i.bindings[key] ?? []), String(id)] },
108
+ }));
109
+ },
110
+ async resolveByBinding(protocol, field, value) {
111
+ const idx = await readIndex();
112
+ const key = bindingKey(protocol, field, value);
113
+ // Reuses the in-memory resolver so every backing store agrees on what "ambiguous" means.
114
+ return resolveInteractionByBinding(new Map([[key, (idx.bindings[key] ?? [])]]), protocol, field, value);
115
+ },
116
+ // ── Context snapshots (content-addressed) ───────────────────────────────────────────────────────
117
+ async putContextSnapshot(snapshot) {
118
+ // Verified BEFORE storing. A snapshot whose digest does not match its bytes is not evidence, and
119
+ // storing it would make a later verification failure look like tampering rather than corruption.
120
+ if (!(await verifyContextSnapshot(snapshot)))
121
+ return { ok: false, reason: 'digest-mismatch' };
122
+ if (await load(snapshotResource(snapshot.digest))) {
123
+ // Digest verified and already present ⇒ the content is the same. Two parties observing one
124
+ // context legitimately store it twice; the stored bytes win.
125
+ return { ok: true, stored: 'identical' };
126
+ }
127
+ await save(snapshotResource(snapshot.digest), snapshot, (i) => ({
128
+ ...i, snapshots: addOnce(i.snapshots, snapshot.digest),
129
+ }));
130
+ return { ok: true, stored: 'new' };
131
+ },
132
+ async getContextSnapshot(digest) {
133
+ return load(snapshotResource(digest));
134
+ },
135
+ // ── Decisions ───────────────────────────────────────────────────────────────────────────────────
136
+ async putDecision(record) {
137
+ const existing = await this.getDecision(record.decisionId);
138
+ if (guardPutOverTerminal('decision', record.decisionId, existing, record, (r) => r.state) === 'skip')
139
+ return;
140
+ await save(decisionResource(record.decisionId), record, (i) => ({
141
+ ...i, decisions: addOnce(i.decisions, record.decisionId),
142
+ }));
143
+ },
144
+ async getDecision(id) {
145
+ return load(decisionResource(id));
146
+ },
147
+ async transitionDecision(id, event) {
148
+ const record = await this.getDecision(id);
149
+ if (!record)
150
+ return null;
151
+ const result = applyDecisionTransition(record, event);
152
+ if (result.ok)
153
+ await this.putDecision(result.next);
154
+ return result;
155
+ },
156
+ // ── Commitments ─────────────────────────────────────────────────────────────────────────────────
157
+ async putCommitment(record) {
158
+ const existing = await this.getCommitment(record.commitmentId);
159
+ if (guardPutOverTerminal('commitment', record.commitmentId, existing, record, (r) => r.state) === 'skip')
160
+ return;
161
+ await save(commitmentResource(record.commitmentId), record, (i) => ({
162
+ ...i, commitments: addOnce(i.commitments, record.commitmentId),
163
+ }));
164
+ },
165
+ async getCommitment(id) {
166
+ return load(commitmentResource(id));
167
+ },
168
+ async listOpenCommitments() {
169
+ const idx = await readIndex();
170
+ const all = await Promise.all(idx.commitments.map((id) => this.getCommitment(id)));
171
+ // Filtered on the RECORD's state, never on a state cached in the index. "What is still owed" is
172
+ // machine-owned, and an index that answered it from its own copy could report an obligation as open
173
+ // after the creditor discharged it — the exact confusion the six machines exist to prevent.
174
+ return all
175
+ .filter((r) => r !== null && OPEN_COMMITMENT_STATES.has(r.state))
176
+ .sort((a, b) => b.updatedAt.localeCompare(a.updatedAt));
177
+ },
178
+ async transitionCommitment(id, event) {
179
+ const record = await this.getCommitment(id);
180
+ if (!record)
181
+ return null;
182
+ const result = applyCommitmentTransition(record, event);
183
+ if (result.ok)
184
+ await this.putCommitment(result.next);
185
+ return result;
186
+ },
187
+ // ── Inbox entries ───────────────────────────────────────────────────────────────────────────────
188
+ async putInboxEntry(entry) {
189
+ const viewer = String(entry.viewer).toLowerCase();
190
+ await save(inboxEntryResource(viewer, entry.exchangeId), entry, (i) => ({
191
+ ...i,
192
+ inboxEntries: i.inboxEntries.some((e) => e.viewer === viewer && e.exchangeId === entry.exchangeId)
193
+ ? i.inboxEntries
194
+ : [...i.inboxEntries, { viewer, exchangeId: entry.exchangeId }],
195
+ }));
196
+ },
197
+ async getInboxEntry(viewer, exchangeId) {
198
+ return load(inboxEntryResource(String(viewer), exchangeId));
199
+ },
200
+ async transitionInbox(viewer, exchangeId, event) {
201
+ const entry = await this.getInboxEntry(viewer, exchangeId);
202
+ if (!entry)
203
+ return null;
204
+ const result = applyInboxTransition(entry, event);
205
+ if (result.ok)
206
+ await this.putInboxEntry(result.next);
207
+ return result;
208
+ },
209
+ // ── Rebuild ─────────────────────────────────────────────────────────────────────────────────────
210
+ async rebuild() {
211
+ cache?.clear();
212
+ const idx = await readIndex();
213
+ const missing = [];
214
+ const recovered = {
215
+ interactions: 0, decisions: 0, commitments: 0, snapshots: 0, inboxEntries: 0,
216
+ };
217
+ const pull = async (family, resource) => {
218
+ const obj = await vault.read({ owner, resource });
219
+ if (!obj?.data) {
220
+ missing.push(resource);
221
+ return;
222
+ }
223
+ cache?.put(resource, obj.data);
224
+ recovered[family] = (recovered[family] ?? 0) + 1;
225
+ };
226
+ for (const id of idx.interactions)
227
+ await pull('interactions', interactionResource(id));
228
+ for (const id of idx.decisions)
229
+ await pull('decisions', decisionResource(id));
230
+ for (const id of idx.commitments)
231
+ await pull('commitments', commitmentResource(id));
232
+ for (const d of idx.snapshots)
233
+ await pull('snapshots', snapshotResource(d));
234
+ for (const e of idx.inboxEntries)
235
+ await pull('inboxEntries', inboxEntryResource(e.viewer, e.exchangeId));
236
+ return { recovered, missing };
237
+ },
238
+ };
239
+ return store;
240
+ }
241
+ /**
242
+ * The lifecycle facet of a stored interaction, for the machine to operate on.
243
+ *
244
+ * `principal` and `participations` are NOT optional decoration. The interaction machine decides who may
245
+ * drive a transition from them, so a facet that omitted them would hand the machine an interaction with
246
+ * no participants and no custodian — every transition rejected, for a reason that reads like a state-model
247
+ * problem. (Which is how this was found: the first version dropped both and the legal-transition test
248
+ * failed while the rejection tests still "passed".)
249
+ */
250
+ function lifecycleOf(record) {
251
+ return {
252
+ interactionId: record.interactionId,
253
+ state: record.lifecycleState,
254
+ principal: record.principal,
255
+ participations: record.participations,
256
+ updatedAt: record.updatedAt,
257
+ };
258
+ }
259
+ //# sourceMappingURL=vault-interaction-store.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vault-interaction-store.js","sourceRoot":"","sources":["../../src/cloudflare/vault-interaction-store.ts"],"names":[],"mappings":"AAAA,qFAAqF;AACrF,EAAE;AACF,2GAA2G;AAC3G,0GAA0G;AAC1G,kGAAkG;AAClG,wGAAwG;AACxG,EAAE;AACF,sGAAsG;AACtG,yGAAyG;AACzG,4FAA4F;AAC5F,EAAE;AACF,0GAA0G;AAC1G,gEAAgE;AAChE,EAAE;AACF,2GAA2G;AAC3G,uGAAuG;AACvG,mEAAmE;AACnE,qGAAqG;AACrG,uGAAuG;AACvG,qFAAqF;AACrF,EAAE;AACF,sGAAsG;AACtG,sBAAsB;AAKtB,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OA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9E,KAAK,MAAM,EAAE,IAAI,GAAG,CAAC,WAAW;gBAAE,MAAM,IAAI,CAAC,aAAa,EAAE,kBAAkB,CAAC,EAAE,CAAC,CAAC,CAAC;YACpF,KAAK,MAAM,CAAC,IAAI,GAAG,CAAC,SAAS;gBAAE,MAAM,IAAI,CAAC,WAAW,EAAE,gBAAgB,CAAC,CAAC,CAAC,CAAC,CAAC;YAC5E,KAAK,MAAM,CAAC,IAAI,GAAG,CAAC,YAAY;gBAAE,MAAM,IAAI,CAAC,cAAc,EAAE,kBAAkB,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC;YAEzG,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,CAAC;QAChC,CAAC;KACF,CAAC;IAEF,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;;;;;;;GAQG;AACH,SAAS,WAAW,CAAC,MAA2B;IAC9C,OAAO;QACL,aAAa,EAAE,MAAM,CAAC,aAAa;QACnC,KAAK,EAAE,MAAM,CAAC,cAAc;QAC5B,SAAS,EAAE,MAAM,CAAC,SAAS;QAC3B,cAAc,EAAE,MAAM,CAAC,cAAc;QACrC,SAAS,EAAE,MAAM,CAAC,SAAS;KAC5B,CAAC;AACJ,CAAC"}
@@ -1,5 +1,5 @@
1
1
  import type { CanonicalAgentId } from '@agenticprimitives/types';
2
- import type { Hex32, MessageId, MessageKind } from './messaging/index.js';
2
+ import type { Hex32, MessageId, MessageKind, MessageEnvelopeV1, AnyMessageEnvelope } from './messaging/index.js';
3
3
  import type { VaultRef } from '@agenticprimitives/vault';
4
4
  export type Performative = 'INFORM' | 'QUERY' | 'REQUEST' | 'PROPOSE' | 'COUNTER' | 'ACCEPT' | 'REJECT' | 'NOTIFY' | 'ACKNOWLEDGE' | 'ISSUE' | 'RETRACT' | 'SUBSCRIBE' | 'UNSUBSCRIBE';
5
5
  /** A by-reference pointer at a piece of semantic content an act expresses or carries — a Situation, a
@@ -38,6 +38,29 @@ export interface CommunicativeActV1 {
38
38
  /** The message this act responds to, if any. */
39
39
  inRespondsTo?: MessageId;
40
40
  }
41
+ /**
42
+ * The performative of ANY envelope — the dual-read seam (spec 340 W9).
43
+ *
44
+ * V2 states it; V1 derives it. One mechanism per version, never a fallback chain: a V2 envelope is
45
+ * never re-derived from a kind it does not have, and a V1 envelope never invents a `performative`
46
+ * field (ADR-0013).
47
+ */
48
+ export declare function performativeOf(envelope: AnyMessageEnvelope, act?: CommunicativeActV1): Performative;
49
+ /**
50
+ * Is this an ORIGINAL message rather than a reply?
51
+ *
52
+ * THE READER THAT FOUND A LATENT BUG. The auto-reply gate was `kind !== 'plain'`, which excluded
53
+ * `response` — so the assistant never replied to a reply. Under V2 that exclusion evaporates, because
54
+ * `plain` and `response` BOTH map to `INFORM` and are indistinguishable by performative alone. A naive
55
+ * translation to `performative === 'INFORM'` would have made the assistant start answering replies,
56
+ * i.e. answering itself.
57
+ *
58
+ * The fix is not to keep the taxonomy. It is that `inReplyTo` — the causal edge — was always the thing
59
+ * that actually distinguished them, and the enum had been standing in for it. Expressing the rule as
60
+ * "an original message has no antecedent" is both correct under V1 and correct under V2, and it says
61
+ * what the rule means instead of naming a label that implied it.
62
+ */
63
+ export declare function isOriginalMessage(envelope: Pick<MessageEnvelopeV1, 'inReplyTo'>): boolean;
41
64
  /**
42
65
  * The TOTAL `MessageKind` → `Performative` derivation for V1 envelopes (spec 324 §9). Exhaustive: every
43
66
  * `MessageKind` maps. A `response` refines to the act's performative when it is one of the response family
@@ -1 +1 @@
1
- {"version":3,"file":"communicative-act.d.ts","sourceRoot":"","sources":["../src/communicative-act.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAC1E,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAEzD,MAAM,M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AAkB,GAAG,YAAY,CAEnG;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,IAAI,CAAC,iBAAiB,EAAE,WAAW,CAAC,GAAG,OAAO,CAEzF;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,WAAW,EAAE,GAAG,CAAC,EAAE,kBAAkB,GAAG,YAAY,CAmB7F"}
@@ -8,6 +8,34 @@
8
8
  // V1 envelopes carry no native performative, so for legacy/communication envelopes the performative is DERIVED
9
9
  // from `MessageKind` via one TOTAL mapping (`performativeForKind`, golden-vectored). A future `ap.exchange.v2`
10
10
  // envelope carries `performative`/`actor`/`principal` natively.
11
+ import { isEnvelopeV2 } from './messaging/index.js';
12
+ /**
13
+ * The performative of ANY envelope — the dual-read seam (spec 340 W9).
14
+ *
15
+ * V2 states it; V1 derives it. One mechanism per version, never a fallback chain: a V2 envelope is
16
+ * never re-derived from a kind it does not have, and a V1 envelope never invents a `performative`
17
+ * field (ADR-0013).
18
+ */
19
+ export function performativeOf(envelope, act) {
20
+ return isEnvelopeV2(envelope) ? envelope.performative : performativeForKind(envelope.kind, act);
21
+ }
22
+ /**
23
+ * Is this an ORIGINAL message rather than a reply?
24
+ *
25
+ * THE READER THAT FOUND A LATENT BUG. The auto-reply gate was `kind !== 'plain'`, which excluded
26
+ * `response` — so the assistant never replied to a reply. Under V2 that exclusion evaporates, because
27
+ * `plain` and `response` BOTH map to `INFORM` and are indistinguishable by performative alone. A naive
28
+ * translation to `performative === 'INFORM'` would have made the assistant start answering replies,
29
+ * i.e. answering itself.
30
+ *
31
+ * The fix is not to keep the taxonomy. It is that `inReplyTo` — the causal edge — was always the thing
32
+ * that actually distinguished them, and the enum had been standing in for it. Expressing the rule as
33
+ * "an original message has no antecedent" is both correct under V1 and correct under V2, and it says
34
+ * what the rule means instead of naming a label that implied it.
35
+ */
36
+ export function isOriginalMessage(envelope) {
37
+ return envelope.inReplyTo === undefined;
38
+ }
11
39
  /**
12
40
  * The TOTAL `MessageKind` → `Performative` derivation for V1 envelopes (spec 324 §9). Exhaustive: every
13
41
  * `MessageKind` maps. A `response` refines to the act's performative when it is one of the response family
@@ -1 +1 @@
1
- {"version":3,"file":"communicative-act.js","sourceRoot":"","sources":["../src/communicative-act.ts"],"names":[],"mappings":"AAAA,mGAAmG;AACnG,4GAA4G;AAC5G,8GAA8G;AAC9G,4GAA4G;AAC5G,8GAA8G;AAC9G,iEAAiE;AACjE,EAAE;AACF,+GAA+G;AAC/G,+GAA+G;AAC/G,gEAAgE;AAiDhE;;;;GAIG;AACH,MAAM,UAAU,mBAAmB,CAAC,IAAiB,EAAE,GAAwB;IAC7E,QAAQ,IAAI,EAAE,CAAC;QACb,KAAK,OAAO;YACV,OAAO,QAAQ,CAAC;QAClB,KAAK,SAAS;YACZ,OAAO,SAAS,CAAC;QACnB,KAAK,UAAU,CAAC,CAAC,CAAC;YAChB,MAAM,CAAC,GAAG,GAAG,EAAE,YAAY,CAAC;YAC5B,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,KAAK,QAAQ,IAAI,CAAC,KAAK,SAAS,IAAI,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC;QAC9F,CAAC;QACD,KAAK,qBAAqB;YACxB,OAAO,OAAO,CAAC;QACjB,KAAK,SAAS;YACZ,OAAO,aAAa,CAAC;QACvB,KAAK,QAAQ;YACX,OAAO,QAAQ,CAAC;QAClB,KAAK,WAAW;YACd,OAAO,SAAS,CAAC;IACrB,CAAC;AACH,CAAC"}
1
+ {"version":3,"file":"communicative-act.js","sourceRoot":"","sources":["../src/communicative-act.ts"],"names":[],"mappings":"AAAA,mGAAmG;AACnG,4GAA4G;AAC5G,8GAA8G;AAC9G,4GAA4G;AAC5G,8GAA8G;AAC9G,iEAAiE;AACjE,EAAE;AACF,+GAA+G;AAC/G,+GAA+G;AAC/G,gEAAgE;AAIhE,OAAO,EAAE,YA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AsB,CAAC;AAE3F,MAAM,WAAW,kBAAkB;IACjC,OAAO,EAAE,yBAAyB,CAAC;IACnC,UAAU,EAAE,UAAU,GAAG,MAAM,CAAC;IAChC,+FAA+F;IAC/F,QAAQ,EAAE,gBAAgB,CAAC;IAC3B,4GAA4G;IAC5G,WAAW,EAAE,gBAAgB,CAAC;IAC9B,SAAS,EAAE,gBAAgB,CAAC;IAC5B,EAAE,EAAE,MAAM,CAAC;IACX,qEAAqE;IACrE,KAAK,EAAE,MAAM,CAAC;CACf;AAED,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,IAAI,CAAC,kBAAkB,EAAE,SAAS,CAAC,GAAG,kBAAkB,CAGpG;AAED,MAAM,MAAM,iBAAiB,GAAG;IAAE,EAAE,EAAE,IAAI,CAAA;CAAE,GAAG;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAE7E;;;;;GAKG;AACH,wBAAgB,qBAAqB,CACnC,QAAQ,EAAE,kBAAkB,EAC5B,IAAI,EAAE;IAAE,SAAS,EAAE,gBAAgB,CAAA;CAAE,GACpC,iBAAiB,CAQnB;AAED;oEACoE;AACpE,wBAAgB,wBAAwB,CACtC,QAAQ,EAAE,kBAAkB,EAC5B,IAAI,EAAE;IAAE,IAAI,EAAE,aAAa,CAAC;IAAC,EAAE,EAAE,MAAM,CAAA;CAAE,GACxC,gBAAgB,CAclB"}
@@ -29,7 +29,6 @@ export function deliveryToExchangeRecord(delivery, opts) {
29
29
  return {
30
30
  version: 'ap.exchange.v1',
31
31
  exchangeId: delivery.exchangeId,
32
- kind: e.kind,
33
32
  tier: opts.tier,
34
33
  principal: delivery.toGateway,
35
34
  parties: { from: e.from, to: e.to },
@@ -1 +1 @@
1
- {"version":3,"file":"delivery-envelope.js","sourceRoot":"","sources":["../src/delivery-envelope.ts"],"names":[],"mappings":"AA0BA,MAAM,UAAU,qBAAqB,CAAC,KAA0C;IAC9E,IAAI,CAAC,KAAK,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,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,oBAAoB,EAAE,CAAC;IACnF,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,WAAW,EAAE,KAAK,KAAK,CAAC;QAAE,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,eAAe,EAAE,CAAC;IAChG,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,CAAC;AACtB,CAAC;AAED;oEACoE;AACpE,MAAM,UAAU,wBAAwB,CACtC,QAA4B,EAC5B,IAAyC;IAEzC,MAAM,CAAC,GAAG,QAAQ,CAAC,QAAQ,CAAC;IAC5B,OAAO;QACL,OAAO,EAAE,gBAAgB;QACzB,UAAU,EAAE,QAAQ,CAAC,UAAwB;QAC7C,IAAI,EAAE,IAAI,CAAC,IAAI;QACf,SAAS,EAAE,QAAQ,CAAC,SAAS;QAC7B,OAAO,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE;QACnC,IAAI,EAAE,WAAW;QACjB,SAAS,EAAE,CAAC,CAAC,CAAC;QACd,MAAM,EAAE,EAAE;QACV,GAAG,EAAE,CAAC;QACN,SAAS,EAAE,IAAI,CAAC,EAAE;KACnB,CAAC;AACJ,CAAC"}
@@ -0,0 +1,79 @@
1
+ /** What a provider needs to send one message. Deliberately small — no attachments, no templates. */
2
+ export interface OutboundEmailV1 {
3
+ to: string;
4
+ subject: string;
5
+ text: string;
6
+ /** Optional HTML alternative. Providers that cannot send it fall back to `text`. */
7
+ html?: string;
8
+ /** Set when this mail continues a conversation, so replies thread in the recipient's mail client. */
9
+ inReplyTo?: string;
10
+ }
11
+ export interface EmailSendResultV1 {
12
+ ok: boolean;
13
+ /** The provider's own id for the message, when it gives one — kept so a thread can cite it. */
14
+ messageId?: string;
15
+ error?: string;
16
+ /** Which provider actually sent it. Recorded, because "the email went" is a different fact per rail. */
17
+ via?: string;
18
+ }
19
+ /**
20
+ * THE PORT. One method, and the implementations are leaves.
21
+ *
22
+ * `available` is separate from `send` on purpose: a surface must be able to say "email is not set up
23
+ * here" BEFORE offering somebody an email invitation, rather than accepting the address and failing.
24
+ */
25
+ export interface EmailSenderPort {
26
+ readonly name: string;
27
+ available(): boolean;
28
+ send(msg: OutboundEmailV1): Promise<EmailSendResultV1>;
29
+ }
30
+ /**
31
+ * TWO INTEGRATIONS, ONE PORT — the first that is available sends.
32
+ *
33
+ * Not a fallback chain (ADR-0013): the order is a DEPLOYMENT PREFERENCE stated once, and a provider that
34
+ * is configured but fails returns an error rather than handing the message to the next one. Sending the
35
+ * same mail twice because the first attempt's response was slow is worse than not sending it.
36
+ */
37
+ export declare function firstAvailableSender(senders: readonly EmailSenderPort[]): EmailSenderPort | null;
38
+ /** An inbound message, already parsed. The adapter does the MIME; this is what the inbox needs. */
39
+ export interface InboundEmailV1 {
40
+ /** What the mail was sent TO — the only routable fact in it. */
41
+ to: string;
42
+ /** What it CLAIMS to be from. Unverified by construction; shown as a claim, never resolved as identity. */
43
+ from: string;
44
+ subject: string;
45
+ text: string;
46
+ /** Provider message id, for de-duplication and for citing the mail this message came from. */
47
+ messageId?: string;
48
+ /** Names only. An attachment is announced, never admitted (rule 4). */
49
+ attachments?: Array<{
50
+ name: string;
51
+ size?: number;
52
+ contentType?: string;
53
+ }>;
54
+ }
55
+ /** The handle an address routes to: `alice@faithnet.me` → `alice`. Empty when the zone is not ours. */
56
+ export declare function handleFromAddress(address: string, zones: readonly string[]): string;
57
+ /** Is this a well-formed address at all? Shape only — nothing here says a mailbox exists. */
58
+ export declare function isEmailAddress(v: string): boolean;
59
+ export declare const EMAIL_BODY_LIMIT = 16000;
60
+ /**
61
+ * An inbound email as the message a thread will hold.
62
+ *
63
+ * WHAT IT KEEPS: the words, who it says it is from, what it was about, and what came with it BY NAME.
64
+ * WHAT IT REFUSES: anything past the cap (truncated, and it says so — a body silently cut in half is a
65
+ * message that misleads), and every attachment's content.
66
+ *
67
+ * The result is deliberately plain text: a thread that renders remote HTML from an unverified sender is
68
+ * a phishing surface with a nice font.
69
+ */
70
+ export declare function inboundEmailToMessage(mail: InboundEmailV1): {
71
+ bodyText: string;
72
+ subject: string;
73
+ claimedFrom: string;
74
+ };
75
+ export declare const EMAIL_ADDRESS_LIMIT = 320;
76
+ export declare const EMAIL_SUBJECT_LIMIT = 300;
77
+ export declare const EMAIL_ATTACHMENT_NAME_LIMIT = 120;
78
+ export declare const EMAIL_ATTACHMENT_NAMES_LIMIT = 20;
79
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/email/index.ts"],"names":[],"mappings":"AAwBA,oGAAoG;AACpG,MAAM,WAAW,eAAe;IAC9B,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,oFAAoF;IACpF,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,qGAAqG;IACrG,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,iBAAiB;IAChC,EAAE,EAAE,OAAO,CAAC;IACZ,+FAA+F;IAC/F,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,wGAAwG;IACxG,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED;;;;;GAKG;AACH,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,SAAS,IAAI,OAAO,CAAC;IACrB,IAAI,CAAC,GAAG,EAAE,eAAe,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;CACxD;AAED;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,SAAS,eAAe,EAAE,GAAG,eAAe,GAAG,IAAI,CAEhG;AAED,mGAAmG;AACnG,MAAM,WAAW,cAAc;IAC7B,gEAAgE;IAChE,EAAE,EAAE,MAAM,CAAC;IACX,2GAA2G;IAC3G,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,8FAA8F;IAC9F,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,uEAAuE;IACvE,WAAW,CAAC,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,WAAW,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CAC5E;AAED,uGAAuG;AACvG,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM,CAQnF;AAED,6FAA6F;AAC7F,wBAAgB,cAAc,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO,CAEjD;AAED,eAAO,MAAM,gBAAgB,QAAS,CAAC;AAEvC;;;;;;;;;GASG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,cAAc,GAAG;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,CAAA;CAAE,CAqBtH;AAED,eAAO,MAAM,mBAAmB,MAAM,CAAC;AACvC,eAAO,MAAM,mBAAmB,MAAM,CAAC;AACvC,eAAO,MAAM,2BAA2B,MAAM,CAAC;AAC/C,eAAO,MAAM,4BAA4B,KAAK,CAAC"}
@@ -0,0 +1,91 @@
1
+ // EMAIL AS A CHANNEL INTO THE INBOX — spec 365.
2
+ //
3
+ // A person's agent should be reachable by the address they already have, and an email they send or
4
+ // receive should land in the SAME thread as everything else they say to that person. Two mailboxes for
5
+ // one relationship is how half a conversation goes missing.
6
+ //
7
+ // FOUR RULES, and the whole design is these:
8
+ //
9
+ // 1. AN EMAIL IS NOT AUTHORITY (spec 309 §4.2). Inbound mail creates a MESSAGE and can never trigger
10
+ // an act. Nobody sends an email that moves money; the acts a person can take from a thread are the
11
+ // ones their own surface offers them, under their own mandate.
12
+ // 2. THE SENDER IS AN UNVERIFIED CLAIM. `From:` is a header anyone can write, so routing is done by
13
+ // the address the mail was SENT TO (`<handle>@<zone>` → the naming service → an agent), never by
14
+ // who it says it is from. The claim travels with the message, labelled as a claim.
15
+ // 3. PARSE IN MEMORY, STORE IN THE VAULT (spec 362 §6.2). The raw message is read into a message body
16
+ // the owner's vault holds and is never written to a serving-plane store — a mailbox is exactly the
17
+ // kind of durable private record ADR-0055 keeps out of DO storage.
18
+ // 4. BOUNDED, ALWAYS. A body has a size cap and attachments are named, not admitted: an inbox that
19
+ // accepts whatever arrives is a way to fill somebody's vault from the outside.
20
+ //
21
+ // The SENDER PORT is here and the providers are not: a transport is a leaf binding that depends inward
22
+ // (ADR-0057), and this package must not know whether the deployment sends through an HTTP API or a
23
+ // platform binding.
24
+ /**
25
+ * TWO INTEGRATIONS, ONE PORT — the first that is available sends.
26
+ *
27
+ * Not a fallback chain (ADR-0013): the order is a DEPLOYMENT PREFERENCE stated once, and a provider that
28
+ * is configured but fails returns an error rather than handing the message to the next one. Sending the
29
+ * same mail twice because the first attempt's response was slow is worse than not sending it.
30
+ */
31
+ export function firstAvailableSender(senders) {
32
+ return senders.find((s) => s.available()) ?? null;
33
+ }
34
+ /** The handle an address routes to: `alice@faithnet.me` → `alice`. Empty when the zone is not ours. */
35
+ export function handleFromAddress(address, zones) {
36
+ const at = address.trim().toLowerCase();
37
+ const m = /^([^@\s]+)@([^@\s]+)$/.exec(at);
38
+ if (!m)
39
+ return '';
40
+ const [, local = '', domain = ''] = m;
41
+ if (!zones.some((z) => domain === z.toLowerCase() || domain.endsWith(`.${z.toLowerCase()}`)))
42
+ return '';
43
+ // Plus-addressing is the person's own tag, not part of who they are: `alice+bills@` is alice.
44
+ return (local.split('+')[0] ?? '').trim();
45
+ }
46
+ /** Is this a well-formed address at all? Shape only — nothing here says a mailbox exists. */
47
+ export function isEmailAddress(v) {
48
+ return /^[^@\s]+@[^@\s]+\.[^@\s]+$/.test(v.trim());
49
+ }
50
+ export const EMAIL_BODY_LIMIT = 16_000;
51
+ /**
52
+ * An inbound email as the message a thread will hold.
53
+ *
54
+ * WHAT IT KEEPS: the words, who it says it is from, what it was about, and what came with it BY NAME.
55
+ * WHAT IT REFUSES: anything past the cap (truncated, and it says so — a body silently cut in half is a
56
+ * message that misleads), and every attachment's content.
57
+ *
58
+ * The result is deliberately plain text: a thread that renders remote HTML from an unverified sender is
59
+ * a phishing surface with a nice font.
60
+ */
61
+ export function inboundEmailToMessage(mail) {
62
+ const body = (mail.text ?? '').trim();
63
+ const truncated = body.length > EMAIL_BODY_LIMIT;
64
+ const kept = truncated ? `${body.slice(0, EMAIL_BODY_LIMIT)}\n\n[…] this email was longer than ${EMAIL_BODY_LIMIT} characters and the rest was not kept.` : body;
65
+ // Header-derived strings are the sender's and go onto single lines the reader trusts — the trailer
66
+ // most of all (audit DATA-30). One line each, bounded; a line break in `from` would otherwise let
67
+ // the sender write text AFTER "not a verified agent".
68
+ const from = oneLine(mail.from, EMAIL_ADDRESS_LIMIT);
69
+ const files = (mail.attachments ?? []).map((a) => oneLine(a.name, EMAIL_ATTACHMENT_NAME_LIMIT)).filter(Boolean);
70
+ const named = files.slice(0, EMAIL_ATTACHMENT_NAMES_LIMIT);
71
+ const more = files.length - named.length;
72
+ const noted = files.length
73
+ ? `\n\n${files.length === 1 ? 'It came with a file' : `It came with ${files.length} files`}, which were not saved: ${named.join(', ')}${more > 0 ? `, and ${more} more` : ''}.`
74
+ : '';
75
+ return {
76
+ subject: oneLine(mail.subject, EMAIL_SUBJECT_LIMIT) || '(no subject)',
77
+ claimedFrom: from,
78
+ // WHO IT SAYS IT IS FROM, said as a claim. A person reading this must not be able to mistake an
79
+ // email address for a verified identity — that mistake is the whole of email fraud.
80
+ bodyText: `${kept}${noted}\n\n— sent by email from ${from} (an email address, not a verified agent)`,
81
+ };
82
+ }
83
+ export const EMAIL_ADDRESS_LIMIT = 320;
84
+ export const EMAIL_SUBJECT_LIMIT = 300;
85
+ export const EMAIL_ATTACHMENT_NAME_LIMIT = 120;
86
+ export const EMAIL_ATTACHMENT_NAMES_LIMIT = 20;
87
+ /** A header value as one bounded line: line breaks and control characters become spaces. */
88
+ function oneLine(v, max) {
89
+ return String(v ?? '').replace(/[\u0000-\u001f\u007f-\u009f\u2028\u2029]+/g, ' ').replace(/\s+/g, ' ').trim().slice(0, max);
90
+ }
91
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/email/index.ts"],"names":[],"mappings":"AAAA,gDAAgD;AAChD,EAAE;AACF,mGAAmG;AACnG,uGAAuG;AACvG,4DAA4D;AAC5D,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,uGAAuG;AACvG,wGAAwG;AACxG,oEAAoE;AACpE,sGAAsG;AACtG,sGAAsG;AACtG,wFAAwF;AACxF,wGAAwG;AACxG,wGAAwG;AACxG,wEAAwE;AACxE,qGAAqG;AACrG,oFAAoF;AACpF,EAAE;AACF,uGAAuG;AACvG,mGAAmG;AACnG,oBAAoB;AAkCpB;;;;;;GAMG;AACH,MAAM,UAAU,oBAAoB,CAAC,OAAmC;IACtE,OAAO,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,SAAS,EAAE,CAAC,IAAI,IAAI,CAAC;AACpD,CAAC;AAgBD,uGAAuG;AACvG,MAAM,UAAU,iBAAiB,CAAC,OAAe,EAAE,KAAwB;IACzE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IACxC,MAAM,CAAC,GAAG,uBAAuB,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAC3C,IAAI,CAAC,CAAC;QAAE,OAAO,EAAE,CAAC;IAClB,MAAM,CAAC,EAAE,KAAK,GAAG,EAAE,EAAE,M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,CAAC,CAAC;AAC9H,CAAC"}
@@ -0,0 +1,43 @@
1
+ import type { MessageKind } from './messaging/index.js';
2
+ import type { CaseState } from './exchange-state.js';
3
+ import type { ProfileVersion } from './interaction-record.js';
4
+ /**
5
+ * Every `MessageKind` (still the ENVELOPE's, see the header), mapped to the profile that replaces it.
6
+ *
7
+ * `Record<MessageKind, …>` rather than a lookup function: adding a `MessageKind` without deciding its
8
+ * profile then fails the build, which is the only way a "total" mapping stays total.
9
+ *
10
+ * Three of the seven collapse onto `direct`, and that is the finding rather than laziness. `plain`,
11
+ * `system` and `tombstone` were never different KINDS of interaction — they are a message, a message
12
+ * from the substrate, and a deletion marker. They differed in rendering, not in what was permitted,
13
+ * which is exactly the kind of distinction an interaction-type enum should not have been carrying.
14
+ */
15
+ export declare const PROFILE_FOR_MESSAGE_KIND: Record<MessageKind, ProfileVersion>;
16
+ /** Which of the six machines each `CaseState` actually belongs to. */
17
+ export type OwningMachine = 'execution' | 'decision' | 'commitment';
18
+ /**
19
+ * Every `CaseState`, mapped to the machine that owns it.
20
+ *
21
+ * THE POINT OF THIS TABLE: the eleven states were never one machine's. `denied` is a DECISION,
22
+ * `completed` is an EXECUTION outcome, and `revoked` is what happens to a COMMITMENT — three
23
+ * different questions with three different signers, answered by one field. That is why a case could
24
+ * be `denied` and a commitment still outstanding with nowhere to say so.
25
+ *
26
+ * `issued` and `approved` are the two that look ambiguous and are not: approving is a decision,
27
+ * issuing is work performed under it. Reading `approved` as execution progress is precisely the
28
+ * "deciding is not doing" collapse.
29
+ */
30
+ export declare const MACHINE_FOR_CASE_STATE: Record<CaseState, OwningMachine>;
31
+ /**
32
+ * How many distinct machines the single `CaseState` field stands in for.
33
+ *
34
+ * It was THREE, and that number was the whole argument for W10b-3. It is now ONE, and this function is
35
+ * kept — rather than deleted along with the states — precisely so that claim stays falsifiable: if
36
+ * anyone re-adds a decision-shaped or commitment-shaped member to `CaseState`, they must give it a home
37
+ * in the table above, and this count moves off 1 and the test fails.
38
+ *
39
+ * A cleanup is not finished when the code compiles; it is finished when re-introducing the thing you
40
+ * removed is caught automatically.
41
+ */
42
+ export declare function machinesSpannedByCaseState(): number;
43
+ //# sourceMappingURL=enum-retirement.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"enum-retirement.d.ts","sourceRoot":"","sources":["../src/enum-retirement.ts"],"names":[],"mappings":"AA8BA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAG9D;;;;;;;;;;GAUG;AACH,eAAO,MAAM,wBAAwB,EAAE,MAAM,CAAC,WAAW,EAAE,cAAc,CAcxE,CAAC;AAEF,sEAAsE;AACtE,MAAM,MAAM,aAAa,GAAG,WAAW,GAAG,UAAU,GAAG,YAAY,CAAC;AAEpE;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,sBAAsB,EAAE,MAAM,CAAC,SAAS,EAAE,aAAa,CASnE,CAAC;AAEF;;;;;;;;;;GAUG;AACH,wBAAgB,0BAA0B,IAAI,MAAM,CAEnD"}