@hasna/events 0.1.13 → 0.1.15

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.
package/LICENSE CHANGED
@@ -1,17 +1,202 @@
1
- Apache License
2
- Version 2.0, January 2004
3
- http://www.apache.org/licenses/
4
1
 
5
- Copyright 2026 Hasna
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
6
5
 
7
- Licensed under the Apache License, Version 2.0 (the "License");
8
- you may not use this file except in compliance with the License.
9
- You may obtain a copy of the License at
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
10
7
 
11
- http://www.apache.org/licenses/LICENSE-2.0
8
+ 1. Definitions.
12
9
 
13
- Unless required by applicable law or agreed to in writing, software
14
- distributed under the License is distributed on an "AS IS" BASIS,
15
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
- See the License for the specific language governing permissions and
17
- limitations under the License.
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright 2026 Hasna
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
package/README.md CHANGED
@@ -8,7 +8,49 @@ This package is local-first. By default it stores JSON files under `~/.hasna/eve
8
8
  - `events.json`
9
9
  - `deliveries.json`
10
10
 
11
- Override the data directory with `HASNA_EVENTS_DIR`, `HASNA_EVENTS_HOME`, or the CLI `--dir` flag.
11
+ The CLI `--dir` flag has highest precedence, followed by `HASNA_EVENTS_DIR`,
12
+ then the legacy `HASNA_EVENTS_HOME` fallback.
13
+
14
+ ## Storage Runtime Contract
15
+
16
+ The default compatibility runtime is local JSON files. It does not use local
17
+ SQLite, remote Postgres, S3, AWS infrastructure, or live cloud mutation. Apps
18
+ that require cross-process idempotency and restart-safe webhook delivery should
19
+ use the opt-in durable spool and SQLite broker described below.
20
+
21
+ ```ts
22
+ import { getEventsStatus } from "@hasna/events";
23
+
24
+ const status = await getEventsStatus();
25
+
26
+ console.log(status.storage);
27
+ // {
28
+ // mode: "local-files",
29
+ // localFiles: true,
30
+ // localSqlite: false,
31
+ // remote: false,
32
+ // postgres: false,
33
+ // s3: false,
34
+ // aws: false,
35
+ // idempotency: "best-effort-local",
36
+ // replayCursors: true
37
+ // }
38
+ ```
39
+
40
+ Cloud-backed stores should implement the same `EventsStore` interface and, for
41
+ durable event-bus use, the optional `appendEventOnce` and `listEventsPage`
42
+ methods. `appendEventOnce` is the storage-layer hook for atomic idempotency by
43
+ `id` or `dedupeKey`, such as a Postgres unique constraint or equivalent
44
+ provider guarantee. `listEventsPage` returns an opaque cursor page for bounded
45
+ replay. The local JSON store implements these hooks for deterministic local
46
+ tests, but its idempotency is best-effort local file behavior, not a
47
+ cross-process database lock.
48
+
49
+ Remote Postgres/S3/AWS adapters should keep credentials and infrastructure
50
+ provisioning outside this package configuration, report their storage mode in
51
+ `status.storage`, and avoid emitting live external deliveries during store
52
+ tests. Creating buckets, databases, secrets, migrations, or production data
53
+ changes is an explicit deployment/approval step, not part of this local runtime.
12
54
 
13
55
  ## Install
14
56
 
@@ -16,7 +58,8 @@ Override the data directory with `HASNA_EVENTS_DIR`, `HASNA_EVENTS_HOME`, or the
16
58
  bun add @hasna/events
17
59
  ```
18
60
 
19
- This package is not published by this repository setup step. Apps can also depend on the local workspace path while the rollout is in progress.
61
+ The core CLI and durable SQLite broker require Bun 1.0 or newer. The isolated
62
+ `@hasna/events/durable-spool` producer export supports Node 20 or newer.
20
63
 
21
64
  ## Event Envelope
22
65
 
@@ -42,21 +85,74 @@ await events.emit({
42
85
  });
43
86
  ```
44
87
 
45
- Envelope fields are:
88
+ Only `source` and `type` are required inputs. `id` defaults to a UUID, `time`
89
+ to the current ISO timestamp, `severity` to `info`, `data` and `metadata` to
90
+ empty objects, and `schemaVersion` to `1.0`. `subject`, `message`, and
91
+ `dedupeKey` are optional.
92
+
93
+ `source` should be the emitting app or bounded context. `type` should use dot
94
+ notation such as `ticket.created`, `repo.synced`, or `check.failed`. Emission
95
+ deduplicates by either an explicit `id` or `dedupeKey` by default; a duplicate
96
+ is neither stored nor delivered again. Library callers can pass
97
+ `{ dedupe: false }` to store a duplicate intentionally.
98
+
99
+ ## Package Entry Points
100
+
101
+ The root export includes the client, types, storage, filtering, signing,
102
+ transports, and catalog APIs. Focused entry points are also available:
103
+
104
+ - `@hasna/events/storage`
105
+ - `@hasna/events/signing`
106
+ - `@hasna/events/filter`
107
+ - `@hasna/events/transports`
108
+ - `@hasna/events/catalog`
109
+ - `@hasna/events/commander`
110
+ - `@hasna/events/cli`
111
+
112
+ ## Typed Event Catalog (Distribution Events)
113
+
114
+ `@hasna/events/catalog` binds well-known envelope `type` strings to the
115
+ `@hasna/contracts` schema ids their `data` payloads mirror, and provides an
116
+ OPT-IN emit-time validator hook.
117
+
118
+ Distribution event types (`DISTRIBUTION_EVENT_TYPES`):
119
+
120
+ | Event type | Contracts schema (`data` mirror) |
121
+ | --- | --- |
122
+ | `release.published` | `hasna.release.v1` |
123
+ | `release.rollout.started` | `hasna.rollout_record.v1` |
124
+ | `release.rollout.completed` | `hasna.rollout_record.v1` |
125
+ | `release.rollout.failed` | `hasna.rollout_record.v1` |
126
+ | `app.installed` | `hasna.rollout_record.v1` |
127
+ | `announcement.sent` | `hasna.announcement.v1` |
128
+ | `feedback.created` | `hasna.feedback.v1` |
129
+ | `feedback.triaged` | `hasna.feedback.v1` |
130
+
131
+ ```ts
132
+ import { EventsClient, EventTypeCatalog, registerDistributionEventTypes } from "@hasna/events";
133
+
134
+ const catalog = registerDistributionEventTypes(new EventTypeCatalog());
135
+ const client = new EventsClient({ catalog, validateCatalogTypes: true });
136
+
137
+ // Registered type with an invalid payload throws EventValidationError
138
+ // BEFORE the event is stored or delivered.
139
+ await client.emit({
140
+ source: "open-publish",
141
+ type: "release.published",
142
+ data: { appId: "open-todos" },
143
+ });
144
+ ```
145
+
146
+ Validation is fully backward compatible:
46
147
 
47
- - `id`
48
- - `source`
49
- - `type`
50
- - `time`
51
- - `subject`
52
- - `severity`
53
- - `data`
54
- - `message`
55
- - `dedupeKey`
56
- - `schemaVersion`
57
- - `metadata`
148
+ - It is OFF by default (`validateCatalogTypes` defaults to `false`).
149
+ - Unregistered/free-form event types ALWAYS pass, even when validation is on.
150
+ - A per-emit `validate` option overrides the client setting in both directions.
58
151
 
59
- `source` should be the emitting app or bounded context. `type` should use dot notation such as `ticket.created`, `repo.synced`, or `check.failed`.
152
+ Payload types (`ReleasePublishedData`, `RolloutData`, `AppInstalledData`,
153
+ `AnnouncementSentData`, `FeedbackCreatedData`, `FeedbackTriagedData`) are
154
+ dependency-free structural mirrors of the contracts schemas; this package does
155
+ not depend on `@hasna/contracts` at runtime.
60
156
 
61
157
  ## OpenAutomations Trigger Ingress
62
158
 
@@ -123,7 +219,11 @@ await events.addChannel({
123
219
  });
124
220
  ```
125
221
 
126
- Filters support `*` wildcards and nested `data` or `metadata` paths.
222
+ All matchers inside one filter are ANDed. Multiple filters on a channel are
223
+ ORed. A channel with no filters accepts every event, while a disabled channel
224
+ accepts none. String matchers support `*` and `**`; `data` and `metadata`
225
+ matchers also support nested or literal dotted keys, primitive array-member
226
+ matching, typed values, and negative matchers.
127
227
 
128
228
  ## Webhook Transport
129
229
 
@@ -131,10 +231,19 @@ Webhook delivery sends a `POST` with the event envelope as JSON.
131
231
 
132
232
  Headers:
133
233
 
234
+ - `Content-Type: application/json`
235
+ - `User-Agent: @hasna/events`
134
236
  - `X-Hasna-Event-Id`
135
237
  - `X-Hasna-Event-Type`
136
238
  - `X-Hasna-Timestamp`
137
- - `X-Hasna-Signature` when `webhook.secret` is configured
239
+ - `X-Hasna-Signature` when `webhook.secret` or `webhook.secretRef` resolves
240
+
241
+ `X-Hasna-Timestamp` is the current delivery-attempt time and is what the HMAC
242
+ signs. The envelope `time` in the JSON body remains the original event time, so
243
+ delayed imports and retries receive fresh replay-window signatures without
244
+ rewriting domain history.
245
+ Custom webhook headers whose names begin with `X-Hasna-` are rejected so channel
246
+ configuration cannot replace signed delivery metadata.
138
247
 
139
248
  Signatures use HMAC-SHA256 over:
140
249
 
@@ -160,6 +269,113 @@ const ok = verifyWebhookSignature(secret, timestamp, body, signature);
160
269
  Pass an explicit `toleranceMs` when a consumer needs a tighter or wider replay
161
270
  window.
162
271
 
272
+ ## Durable Node Producer And Bun Delivery Worker
273
+
274
+ `@hasna/events/durable-spool` is the producer boundary for Node 20+ apps. It
275
+ has no Bun runtime import and performs no network access. Each enqueue writes a
276
+ mode-0600 temporary file, fsyncs it, hard-links it without replacement to an
277
+ identity-keyed final name, removes the temporary file, and fsyncs the inbox
278
+ directory. Concurrent producers with the same `dedupeKey` converge on one
279
+ immutable record.
280
+
281
+ ```ts
282
+ import { DurableEventSpool } from "@hasna/events/durable-spool";
283
+
284
+ const spool = new DurableEventSpool({ dataDir: process.env.HASNA_EVENTS_DIR! });
285
+ await spool.enqueue({
286
+ id: "notes:note:123:created",
287
+ source: "notes",
288
+ type: "note.created",
289
+ time: "2026-08-06T12:00:00.000Z",
290
+ subject: "note:123",
291
+ dedupeKey: "notes:note:123:created",
292
+ schemaVersion: "notes.v1",
293
+ data: {
294
+ noteId: "123",
295
+ createdAt: "2026-08-06T12:00:00.000Z",
296
+ originMachine: "station03",
297
+ },
298
+ metadata: {},
299
+ });
300
+ ```
301
+
302
+ `@hasna/events/durable` is Bun-only because it uses `bun:sqlite`. The broker
303
+ imports committed spool records into an event and matching-channel outbox in a
304
+ SQLite `BEGIN IMMEDIATE` transaction, then removes the spool record. SQLite WAL,
305
+ unique event/dedupe identities, unique event/channel jobs, bounded leases, and
306
+ persisted retry timestamps make separate workers and process restarts safe.
307
+ Producer spool records and broker event rows apply the default sensitive-key
308
+ redaction. Each outbox row additionally applies its channel's `redact.paths`
309
+ before the payload is persisted or delivered.
310
+ The broker initializes schema v1 only from an empty version-0 application
311
+ schema. Existing v1 databases must match the complete columns, constraints,
312
+ foreign keys, and indexes; malformed or newer schemas are rejected unchanged.
313
+
314
+ ```ts
315
+ import { DurableEventsBroker } from "@hasna/events/durable";
316
+
317
+ const broker = new DurableEventsBroker({ dataDir: process.env.HASNA_EVENTS_DIR! });
318
+ broker.addChannel({
319
+ id: "notes-created",
320
+ enabled: false,
321
+ transport: "webhook",
322
+ filters: [{ source: "notes", type: "note.created" }],
323
+ webhook: {
324
+ url: "https://example.com/events/notes",
325
+ secretRef: "env:HASNA_NOTES_WEBHOOK_SECRET",
326
+ },
327
+ retry: { maxAttempts: 5, backoffMs: 1_000, multiplier: 2 },
328
+ });
329
+
330
+ broker.importSpool();
331
+ await broker.drain();
332
+ broker.close();
333
+ ```
334
+
335
+ Durable SQLite channels reject inline `webhook.secret` values. The default
336
+ resolver supports `env:VARIABLE_NAME`; callers can inject a vault-backed
337
+ resolver. Resolved credential values are used only to sign the in-memory HTTP
338
+ request and are never stored in channel configuration, the outbox, delivery
339
+ history, or status output.
340
+
341
+ Any HTTP 2xx response acknowledges delivery. The receiver therefore must return
342
+ 2xx only after durably enqueueing the event and must deduplicate by `dedupeKey`
343
+ or `id`. Non-2xx responses, timeouts, and unresolved runtime secrets follow the
344
+ persisted retry schedule. Exhausted jobs remain `dead`; an operator can call
345
+ `retryDead({ eventId, channelId, limit })` or use `events durable retry-dead`
346
+ without creating a second event/channel outbox identity.
347
+
348
+ The Bun CLI exposes the same operator boundary:
349
+
350
+ ```bash
351
+ events --dir "$HASNA_EVENTS_DIR" durable channel https://example.com/events/notes \
352
+ --id notes-created --source notes --type note.created \
353
+ --secret-ref env:HASNA_NOTES_WEBHOOK_SECRET --disabled
354
+
355
+ events --dir "$HASNA_EVENTS_DIR" durable drain --limit 100
356
+ events --dir "$HASNA_EVENTS_DIR" durable work --limit 100
357
+ events --dir "$HASNA_EVENTS_DIR" durable retry-dead --limit 100
358
+ events --dir "$HASNA_EVENTS_DIR" durable status
359
+ ```
360
+
361
+ `durable drain` imports and processes one bounded batch, then exits. Enqueueing
362
+ alone never performs network delivery. `durable work` is the long-running Bun
363
+ worker: it watches only the durable spool inbox, debounces file events, imports
364
+ and drains immediately, wakes at the next persisted retry timestamp, and runs a
365
+ low-frequency bounded reconciliation in case a filesystem notification was
366
+ missed. It never watches Apple Notes or note files. SIGTERM and SIGINT stop it
367
+ cleanly. Each worker claims only the job it is about to dispatch, and only the
368
+ current lease owner can settle it. Delivery is still at-least-once: if a request
369
+ outlives its lease, another worker may retry it, so receivers must deduplicate by
370
+ `dedupeKey` or `id`. This package change does not install, start, or enable a
371
+ runner; a canary deployment must supervise one `durable work` process explicitly.
372
+
373
+ Webhook requests time out after 15 seconds unless `webhook.timeoutMs` is set.
374
+ Non-2xx responses and network failures are recorded as failed attempts. The
375
+ compatibility JSON delivery path stores response bodies truncated after 4,096
376
+ characters; durable delivery intentionally omits response bodies, stdout, and
377
+ stderr from its outbox and delivery history.
378
+
163
379
  ## Command Transport
164
380
 
165
381
  Command channels run a local process and pass the event on stdin and environment variables.
@@ -194,19 +410,28 @@ Environment variables:
194
410
  - `HASNA_EVENT_SCHEMA_VERSION`
195
411
  - `HASNA_EVENT_JSON`
196
412
 
197
- The transport type union already reserves `email`, `sse`, and `mcp-relay` for later implementations.
413
+ Command processes time out after 15 seconds unless `command.timeoutMs` is set.
414
+ Their stdout and stderr are stored on the delivery attempt and truncated after
415
+ 4,096 characters. A zero exit code succeeds; other exits or signals fail.
416
+
417
+ Both implemented transports use one attempt by default. Channel retry policy
418
+ can increase `maxAttempts`; failed attempts back off from 250 ms by a default
419
+ multiplier of 2 unless overridden. The transport type union reserves `email`,
420
+ `sse`, and `mcp-relay`, but the CLI refuses to configure them and direct
421
+ dispatch currently records them as skipped.
198
422
 
199
423
  ## Redaction
200
424
 
201
425
  Events scrub obvious sensitive keys such as `secret`, `token`, `password`,
202
- `apiKey`, and `authorization` before local storage and delivery by default.
426
+ `apiKey`, `api_key`, `api-key`, and `authorization` recursively before local
427
+ storage and delivery by default.
203
428
  Callers that intentionally need raw local payloads can pass:
204
429
 
205
430
  ```ts
206
431
  await events.emit(input, { redactSensitiveData: false });
207
432
  ```
208
433
 
209
- Use channel-level paths for config-only redaction:
434
+ Use channel-level paths for per-channel delivery redaction:
210
435
 
211
436
  ```ts
212
437
  await events.addChannel({
@@ -235,6 +460,12 @@ const events = new EventsClient({
235
460
 
236
461
  The package exposes `events` and `hasna-events`.
237
462
 
463
+ Global options must come before the command group:
464
+
465
+ ```bash
466
+ events --dir /tmp/events --json status
467
+ ```
468
+
238
469
  ```bash
239
470
  events channels add https://example.com/channels/hasna \
240
471
  --id ops \
@@ -245,13 +476,16 @@ events channels add https://example.com/channels/hasna \
245
476
 
246
477
  events channels list
247
478
  events channels test ops
479
+ events channels match ops
248
480
  events channels remove ops
249
481
  ```
250
482
 
251
483
  Field filters can match nested `data` or `metadata` values. Plain
252
484
  `--data`/`--metadata` values are strings, which keeps ids and slugs such as
253
485
  `001` intact. Use `--data-json` or `--metadata-json` for typed JSON predicates.
254
- Dot paths access nested object keys; dots inside key names are not escaped yet.
486
+ Dot paths check both nested object keys and literal dotted keys; there is no
487
+ syntax to distinguish between those two forms yet. A negative predicate also
488
+ matches when its field is absent.
255
489
  When the actual event value is an array, string filters match any primitive
256
490
  array member, which is useful for tag routing such as `data.tags=auto:route`.
257
491
  Use `path!=value` or `path!=json` for negative predicates such as
@@ -305,21 +539,35 @@ events events emit ticket.created \
305
539
  --data '{"ticketId":123}'
306
540
 
307
541
  events events list --limit 20
542
+ events events list --source tickets --type ticket.created
308
543
  events events replay --type ticket.created
544
+ events events replay --type ticket.created --dry-run --limit 100
545
+ events events replay --type ticket.created --cursor "$NEXT_CURSOR" --limit 100
309
546
  events events replay --dry-run
310
547
  ```
311
548
 
312
- Machine-readable status:
549
+ Replay cursors are opaque and tied to the same filter set (`--id`, `--source`,
550
+ and `--type`) used to produce them. Use the `nextCursor` returned by the
551
+ previous JSON replay response rather than constructing cursor strings in
552
+ callers. A replay without `--limit` or `--cursor` processes all matching events;
553
+ use those flags when callers need bounded page-by-page replay.
554
+
555
+ Machine-readable status (global flags precede `status`):
313
556
 
314
557
  ```bash
315
- events status --json
558
+ events --json status
316
559
  ```
317
560
 
318
- The status contract reports event, channel, delivery, file, and transport counts
319
- only. It does not include event payloads, webhook signing secrets, command
320
- environment values, or channel targets.
561
+ The status contract reports storage runtime, event, channel, delivery, file, and
562
+ transport metadata only. It does not include event payloads, webhook signing
563
+ secrets, command environment values, or channel targets.
321
564
 
322
565
  Use `--json` for script-friendly output and `--dir <path>` for isolated data.
566
+ The standalone `events events list` command has no implicit row cap. Commands
567
+ registered into another Commander program with `registerEventsCommands` default
568
+ to the 100 most recent rows, accept a host override, and use `--limit 0` to list
569
+ all rows. The embedded emitter also supports `--no-dedupe`; the standalone CLI
570
+ does not currently expose that library option.
323
571
 
324
572
  ## App Integration Pattern
325
573