@antasphere/chassis-server 1.1.0 → 1.2.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 (172) hide show
  1. package/dist/api/apikeys.d.ts +4 -1
  2. package/dist/api/apikeys.d.ts.map +1 -1
  3. package/dist/api/apikeys.js +11 -1
  4. package/dist/api/apikeys.js.map +1 -1
  5. package/dist/api/create-api.d.ts +3 -0
  6. package/dist/api/create-api.d.ts.map +1 -1
  7. package/dist/api/create-api.js +8 -3
  8. package/dist/api/create-api.js.map +1 -1
  9. package/dist/api/invitations.d.ts.map +1 -1
  10. package/dist/api/invitations.js +6 -0
  11. package/dist/api/invitations.js.map +1 -1
  12. package/dist/api/members.d.ts +5 -2
  13. package/dist/api/members.d.ts.map +1 -1
  14. package/dist/api/members.js +1 -0
  15. package/dist/api/members.js.map +1 -1
  16. package/dist/api/projects.d.ts +3 -0
  17. package/dist/api/projects.d.ts.map +1 -1
  18. package/dist/api/projects.js +13 -1
  19. package/dist/api/projects.js.map +1 -1
  20. package/dist/api/webhooks.d.ts +24 -0
  21. package/dist/api/webhooks.d.ts.map +1 -0
  22. package/dist/api/webhooks.js +170 -0
  23. package/dist/api/webhooks.js.map +1 -0
  24. package/dist/boot.d.ts.map +1 -1
  25. package/dist/boot.js +47 -4
  26. package/dist/boot.js.map +1 -1
  27. package/dist/email/index.d.ts +1 -0
  28. package/dist/email/index.d.ts.map +1 -1
  29. package/dist/email/index.js +1 -0
  30. package/dist/email/index.js.map +1 -1
  31. package/dist/env.d.ts +9 -0
  32. package/dist/env.d.ts.map +1 -1
  33. package/dist/env.js +11 -0
  34. package/dist/env.js.map +1 -1
  35. package/dist/identity/demo-pass-rules.d.ts.map +1 -1
  36. package/dist/identity/demo-pass-rules.js +6 -1
  37. package/dist/identity/demo-pass-rules.js.map +1 -1
  38. package/dist/identity/hub-reconcile.d.ts +2 -2
  39. package/dist/identity/hub-reconcile.d.ts.map +1 -1
  40. package/dist/identity/hub-reconcile.js.map +1 -1
  41. package/dist/index.d.ts +2 -1
  42. package/dist/index.d.ts.map +1 -1
  43. package/dist/jobs/index.d.ts +1 -1
  44. package/dist/jobs/index.d.ts.map +1 -1
  45. package/dist/jobs/index.js.map +1 -1
  46. package/dist/jobs/pgboss.d.ts +34 -0
  47. package/dist/jobs/pgboss.d.ts.map +1 -1
  48. package/dist/jobs/pgboss.js +32 -9
  49. package/dist/jobs/pgboss.js.map +1 -1
  50. package/dist/mcp/index.d.ts +1 -0
  51. package/dist/mcp/index.d.ts.map +1 -1
  52. package/dist/mcp/index.js +1 -0
  53. package/dist/mcp/index.js.map +1 -1
  54. package/dist/mcp/server.d.ts +1 -1
  55. package/dist/mcp/server.d.ts.map +1 -1
  56. package/dist/mcp/server.js +11 -2
  57. package/dist/mcp/server.js.map +1 -1
  58. package/dist/mcp/tool-kit.d.ts +2 -0
  59. package/dist/mcp/tool-kit.d.ts.map +1 -1
  60. package/dist/mcp/tool-kit.js +5 -1
  61. package/dist/mcp/tool-kit.js.map +1 -1
  62. package/dist/mcp/webhooks.d.ts +16 -0
  63. package/dist/mcp/webhooks.d.ts.map +1 -0
  64. package/dist/mcp/webhooks.js +226 -0
  65. package/dist/mcp/webhooks.js.map +1 -0
  66. package/dist/members/removal.d.ts +10 -2
  67. package/dist/members/removal.d.ts.map +1 -1
  68. package/dist/members/removal.js +3 -0
  69. package/dist/members/removal.js.map +1 -1
  70. package/dist/middleware/idempotency.d.ts.map +1 -1
  71. package/dist/middleware/idempotency.js +3 -1
  72. package/dist/middleware/idempotency.js.map +1 -1
  73. package/dist/middleware/scopes.d.ts +9 -1
  74. package/dist/middleware/scopes.d.ts.map +1 -1
  75. package/dist/middleware/scopes.js +8 -1
  76. package/dist/middleware/scopes.js.map +1 -1
  77. package/dist/secret-box.d.ts +10 -0
  78. package/dist/secret-box.d.ts.map +1 -0
  79. package/dist/secret-box.js +87 -0
  80. package/dist/secret-box.js.map +1 -0
  81. package/dist/testing/helpers.d.ts +8 -0
  82. package/dist/testing/helpers.d.ts.map +1 -1
  83. package/dist/testing/helpers.js.map +1 -1
  84. package/dist/tool-definition.d.ts +24 -0
  85. package/dist/tool-definition.d.ts.map +1 -1
  86. package/dist/tool-definition.js.map +1 -1
  87. package/dist/webhooks/catalog.d.ts +80 -0
  88. package/dist/webhooks/catalog.d.ts.map +1 -0
  89. package/dist/webhooks/catalog.js +134 -0
  90. package/dist/webhooks/catalog.js.map +1 -0
  91. package/dist/webhooks/index.d.ts +9 -0
  92. package/dist/webhooks/index.d.ts.map +1 -0
  93. package/dist/webhooks/index.js +9 -0
  94. package/dist/webhooks/index.js.map +1 -0
  95. package/dist/webhooks/jobs.d.ts +12 -0
  96. package/dist/webhooks/jobs.d.ts.map +1 -0
  97. package/dist/webhooks/jobs.js +77 -0
  98. package/dist/webhooks/jobs.js.map +1 -0
  99. package/dist/webhooks/mail.d.ts +24 -0
  100. package/dist/webhooks/mail.d.ts.map +1 -0
  101. package/dist/webhooks/mail.js +21 -0
  102. package/dist/webhooks/mail.js.map +1 -0
  103. package/dist/webhooks/match.d.ts +22 -0
  104. package/dist/webhooks/match.d.ts.map +1 -0
  105. package/dist/webhooks/match.js +40 -0
  106. package/dist/webhooks/match.js.map +1 -0
  107. package/dist/webhooks/safe-fetch.d.ts +94 -0
  108. package/dist/webhooks/safe-fetch.d.ts.map +1 -0
  109. package/dist/webhooks/safe-fetch.js +263 -0
  110. package/dist/webhooks/safe-fetch.js.map +1 -0
  111. package/dist/webhooks/service.d.ts +245 -0
  112. package/dist/webhooks/service.d.ts.map +1 -0
  113. package/dist/webhooks/service.js +861 -0
  114. package/dist/webhooks/service.js.map +1 -0
  115. package/dist/webhooks/signing.d.ts +40 -0
  116. package/dist/webhooks/signing.d.ts.map +1 -0
  117. package/dist/webhooks/signing.js +108 -0
  118. package/dist/webhooks/signing.js.map +1 -0
  119. package/dist/webhooks/tx-send.d.ts +31 -0
  120. package/dist/webhooks/tx-send.d.ts.map +1 -0
  121. package/dist/webhooks/tx-send.js +22 -0
  122. package/dist/webhooks/tx-send.js.map +1 -0
  123. package/package.json +7 -3
  124. package/src/api/apikeys.ts +12 -1
  125. package/src/api/create-api.ts +17 -3
  126. package/src/api/invitations.ts +6 -0
  127. package/src/api/members.ts +6 -2
  128. package/src/api/projects.ts +16 -1
  129. package/src/api/webhooks.ts +205 -0
  130. package/src/boot.ts +48 -4
  131. package/src/email/index.ts +1 -0
  132. package/src/env.ts +11 -0
  133. package/src/identity/demo-pass-rules.ts +6 -1
  134. package/src/identity/hub-reconcile.ts +2 -2
  135. package/src/index.ts +13 -1
  136. package/src/jobs/index.ts +1 -0
  137. package/src/jobs/pgboss.ts +71 -9
  138. package/src/mcp/index.ts +1 -0
  139. package/src/mcp/server.ts +10 -2
  140. package/src/mcp/tool-kit.ts +7 -1
  141. package/src/mcp/webhooks.ts +370 -0
  142. package/src/members/removal.ts +21 -1
  143. package/src/middleware/idempotency.ts +3 -1
  144. package/src/middleware/scopes.ts +14 -0
  145. package/src/secret-box.ts +93 -0
  146. package/src/testing/helpers.ts +8 -0
  147. package/src/tool-definition.ts +29 -0
  148. package/src/webhooks/catalog.ts +205 -0
  149. package/src/webhooks/index.ts +58 -0
  150. package/src/webhooks/jobs.ts +92 -0
  151. package/src/webhooks/mail.ts +48 -0
  152. package/src/webhooks/match.ts +52 -0
  153. package/src/webhooks/safe-fetch.ts +335 -0
  154. package/src/webhooks/service.ts +1089 -0
  155. package/src/webhooks/signing.ts +132 -0
  156. package/src/webhooks/tx-send.ts +53 -0
  157. package/test/host/drizzle/0002_webhooks.sql +49 -0
  158. package/test/host/drizzle/meta/0002_snapshot.json +3952 -0
  159. package/test/host/drizzle/meta/_journal.json +8 -1
  160. package/test/host/identity.ts +6 -1
  161. package/test/host/minimal-host.ts +2 -1
  162. package/test/host/minimal-tool.ts +32 -4
  163. package/test/integration/mcp-webhooks.test.ts +360 -0
  164. package/test/integration/webhooks.test.ts +1684 -0
  165. package/test/unit/secret-box.test.ts +124 -0
  166. package/test/unit/tx-send.test.ts +23 -0
  167. package/test/unit/webhook-catalog.test.ts +151 -0
  168. package/test/unit/webhook-env.test.ts +60 -0
  169. package/test/unit/webhook-jobs.test.ts +92 -0
  170. package/test/unit/webhook-match.test.ts +81 -0
  171. package/test/unit/webhook-safe-fetch.test.ts +330 -0
  172. package/test/unit/webhook-signing.test.ts +169 -0
@@ -0,0 +1,245 @@
1
+ import type PgBoss from 'pg-boss';
2
+ import { Counter } from 'prom-client';
3
+ import { type Db, type DbConn, type WebhookDeliveryRow, type WebhookEndpointRow } from '@antasphere/chassis-db';
4
+ import type { ToolIdentity, WebhookDelivery, WebhookEndpoint, WebhookEndpointCreate, WebhookEndpointUpdate } from '@antasphere/chassis-contract';
5
+ import type { Logger } from '../logger.js';
6
+ import type { EmailDriver } from '../email/driver.js';
7
+ import type { MailBrand } from '../email/shell.js';
8
+ import type { EventBus } from '../platform/events.js';
9
+ import { type WebhookCatalogIndex, type WebhookSubjectValue } from './catalog.js';
10
+ import { type SafeFetchOptions, type SafeFetchPolicy } from './safe-fetch.js';
11
+ /**
12
+ * Outbound webhooks (PRDCT-3482): the chassis's machinery, tool-neutral.
13
+ *
14
+ * EMIT: a domain write calls `emit(tx, …)` INSIDE its own transaction; one
15
+ * pg-boss job (the event's envelope) is written by the same connection, so
16
+ * the event is durable with the write and never exists for a rolled-back
17
+ * one. A per-replica cache of "does any enabled endpoint of this workspace
18
+ * want this type" (`listenerTtlMs`) makes an emit nobody listens to cost
19
+ * one map lookup: a view with no endpoint costs no job.
20
+ *
21
+ * FAN-OUT (`webhook-events`): the event is matched against the workspace's
22
+ * enabled endpoints (type, then filters); one `webhook_deliveries` row and
23
+ * one delivery job per match, in one transaction.
24
+ *
25
+ * DELIVERY (`webhook-deliveries`): the envelope is signed (Standard
26
+ * Webhooks, two signatures during a rotation overlap) and POSTed through the
27
+ * guarded fetch. A 2xx is `delivered`; anything else fails the job, which
28
+ * pg-boss retries on the queue's budget (ten retries from thirty seconds,
29
+ * about eight and a half hours), then moves to `webhook-deliveries-held`:
30
+ * the row is marked `held`, logged, counted, and queued again an hour later
31
+ * with the whole budget once more, round after round, until the receiver
32
+ * takes it or the endpoint is disabled. A streak of
33
+ * `disableAfterFailures` failures spanning `disableAfterMs` switches the
34
+ * endpoint off and mails its creator once.
35
+ *
36
+ * The secret is stored sealed (`secret-box.ts`, info `chassis:webhook-endpoint`)
37
+ * and shown once, at creation and at rotation.
38
+ */
39
+ export declare const WEBHOOK_EVENTS_QUEUE = "webhook-events";
40
+ export declare const WEBHOOK_DELIVERIES_QUEUE = "webhook-deliveries";
41
+ export declare const WEBHOOK_DELIVERIES_HELD_QUEUE = "webhook-deliveries-held";
42
+ export declare const WEBHOOK_PURGE_QUEUE = "webhook-purge";
43
+ /** The HKDF info of the endpoints' secret box: never the idempotency one. */
44
+ export declare const WEBHOOK_SECRET_BOX_INFO = "chassis:webhook-endpoint";
45
+ export interface WebhookDials {
46
+ /** Delivery retries before a hold (pg-boss `retryLimit`). */
47
+ retryLimit: number;
48
+ /** The first retry's delay in seconds, doubled each time. */
49
+ retryDelaySeconds: number;
50
+ /** How long a held delivery waits before its next round. */
51
+ heldDelaySeconds: number;
52
+ /** The failure streak that switches an endpoint off… */
53
+ disableAfterFailures: number;
54
+ /** …once it has lasted this long. */
55
+ disableAfterMs: number;
56
+ /** How long "anyone listening?" is remembered per workspace and replica. */
57
+ listenerTtlMs: number;
58
+ /** How long the previous secret keeps signing after a rotation. */
59
+ previousSecretOverlapMs: number;
60
+ /** The guarded fetch's timeout. */
61
+ timeoutMs: number;
62
+ }
63
+ export declare const DEFAULT_WEBHOOK_DIALS: WebhookDials;
64
+ /** What `emit` takes: the workspace, the type, the subjects by KEY, the data. */
65
+ export interface WebhookEmit {
66
+ workspaceId: string;
67
+ type: string;
68
+ subjects?: Readonly<Record<string, WebhookSubjectValue>>;
69
+ data: Record<string, unknown>;
70
+ }
71
+ /** The job the fan-out queue carries: the event as the envelope will say it (minus `attempt`). */
72
+ export interface WebhookEventJob {
73
+ id: string;
74
+ type: string;
75
+ occurredAt: string;
76
+ workspaceId: string;
77
+ /** By subject KEY (`project`), the envelope writes them under each subject's FIELD. */
78
+ subjects: Record<string, WebhookSubjectValue>;
79
+ data: Record<string, unknown>;
80
+ }
81
+ export interface WebhookDeliveryJob {
82
+ deliveryId: string;
83
+ }
84
+ /** The emitter a tool's services receive (`ServiceCore.webhooks`). */
85
+ export interface WebhookEmitter {
86
+ /**
87
+ * Record that something happened, inside the caller's transaction (or on
88
+ * a plain handle, for a write the chassis does not own). Answers the
89
+ * event id, or null when no endpoint of the workspace listens to the type,
90
+ * or the data does not match the declared schema (logged, never thrown:
91
+ * a webhook must never break the write it reports).
92
+ */
93
+ emit(conn: DbConn, event: WebhookEmit): Promise<string | null>;
94
+ /**
95
+ * Whether any enabled endpoint of the workspace subscribes to the type:
96
+ * the cheap exit a tool takes BEFORE it computes the facts of an event
97
+ * that is frequent and costs something to describe (a view). Cached per
98
+ * replica; `emit` runs the same check itself.
99
+ */
100
+ wants(workspaceId: string, type: string): Promise<boolean>;
101
+ }
102
+ export interface WebhookServiceDeps {
103
+ db: Db;
104
+ logger: Logger;
105
+ authSecret: string;
106
+ identity: ToolIdentity;
107
+ version: string;
108
+ policy: SafeFetchPolicy;
109
+ email: EmailDriver;
110
+ brand: MailBrand;
111
+ publicBaseUrl: string;
112
+ catalog: WebhookCatalogIndex;
113
+ dials?: Partial<WebhookDials> | undefined;
114
+ /** Test seams of the guarded fetch (a lookup, a transport). */
115
+ fetchOptions?: SafeFetchOptions | undefined;
116
+ now?: () => Date;
117
+ }
118
+ export declare class WebhookRefusedError extends Error {
119
+ readonly code: 'url_refused' | 'not_found' | 'unknown_event' | 'unknown_subject';
120
+ constructor(code: 'url_refused' | 'not_found' | 'unknown_event' | 'unknown_subject', message: string);
121
+ }
122
+ /**
123
+ * Thrown by an attempt that did not run because the endpoint already holds
124
+ * its share of this replica's pollers (`MAX_IN_FLIGHT_PER_ENDPOINT`): the
125
+ * worker puts the job back in the queue a moment later, its retry budget
126
+ * untouched, so one dead receiver can never take every slot (verifier
127
+ * round 2, MJ-R2-1).
128
+ */
129
+ export declare class WebhookDeliveryDeferred extends Error {
130
+ readonly deliveryId: string;
131
+ constructor(deliveryId: string);
132
+ }
133
+ /** How many attempts one endpoint may have in flight on one replica at once. */
134
+ export declare const MAX_IN_FLIGHT_PER_ENDPOINT = 2;
135
+ /** Thrown by a retryable attempt that failed, so pg-boss retries the job. */
136
+ export declare class WebhookDeliveryFailed extends Error {
137
+ readonly deliveryId: string;
138
+ constructor(deliveryId: string, message: string);
139
+ }
140
+ export declare class WebhookService implements WebhookEmitter {
141
+ private readonly deps;
142
+ readonly dials: WebhookDials;
143
+ readonly promMetrics: Counter<string>[];
144
+ private readonly box;
145
+ private readonly listeners;
146
+ private readonly deliveries;
147
+ private readonly held;
148
+ private readonly disabled;
149
+ private readonly now;
150
+ /** Filled by boot once pg-boss exists (`attach`); the jobs are declared before it. */
151
+ private boss;
152
+ /** Attempts in flight per endpoint on this replica (the per-endpoint bound). */
153
+ private readonly inFlight;
154
+ constructor(deps: WebhookServiceDeps);
155
+ attach(boss: PgBoss): void;
156
+ get catalog(): WebhookCatalogIndex;
157
+ emit(conn: DbConn, event: WebhookEmit): Promise<string | null>;
158
+ /** Does any enabled endpoint of the workspace subscribe to this type? Cached per replica. */
159
+ wants(workspaceId: string, type: string): Promise<boolean>;
160
+ private loadListeners;
161
+ /** Forget the cached answer of a workspace (every write of its endpoints calls it). */
162
+ invalidateListeners(workspaceId: string): void;
163
+ /**
164
+ * The chassis's own events, bridged from the in-process bus: fired after
165
+ * the write committed, so never for a rolled-back one, and at most once
166
+ * per replica that saw it. The events emitted inside a transaction the
167
+ * chassis owns (projects) do not pass here.
168
+ */
169
+ bindBus(events: EventBus): void;
170
+ /** One delivery row and one delivery job per endpoint that wants the event; answers how many. */
171
+ fanOut(job: WebhookEventJob): Promise<number>;
172
+ /** The envelope as the receiver reads it (without `attempt`, stamped at each send). */
173
+ private envelopeOf;
174
+ private queueDelivery;
175
+ /**
176
+ * One attempt of a delivery. `retryable` (the queue's worker): a failure
177
+ * throws `WebhookDeliveryFailed` so pg-boss retries. Not retryable (the
178
+ * test ping, run inline): a failure marks the row `failed` and answers it.
179
+ * Answers the row as it is after the attempt.
180
+ */
181
+ attempt(deliveryId: string, opts: {
182
+ retryable: boolean;
183
+ }): Promise<WebhookDeliveryRow | null>;
184
+ private finish;
185
+ /** Put a delivery back in the queue after `inSeconds` (a deferred attempt). */
186
+ requeue(deliveryId: string, inSeconds: number): Promise<void>;
187
+ /**
188
+ * The held queue's work: mark the row held and queue it again after the
189
+ * hold, in ONE transaction, so a re-send that fails leaves the row pending
190
+ * and the held job's own retry finds it again (the chassis suite's round 1:
191
+ * a row marked held outside the transaction was never re-driven once its
192
+ * send had failed). A row already delivered, failed or gone is left alone.
193
+ */
194
+ hold(deliveryId: string): Promise<void>;
195
+ private mailDisabled;
196
+ /** The nightly purge: deliveries older than `retentionDays`, in bounded batches. */
197
+ purge(retentionDays: number): Promise<number>;
198
+ /** The URL rule at registration (the address itself is judged at every delivery). */
199
+ checkUrl(url: string): void;
200
+ /**
201
+ * The subscription is checked against the catalog at registration
202
+ * (verifier round 1, MN1): an exact type must be declared, a family must
203
+ * have at least one declared type, `*` is always right; every filter key
204
+ * must be a declared subject. A typo would otherwise subscribe to nothing,
205
+ * silently.
206
+ */
207
+ checkSubscription(events: readonly string[] | undefined, filters: Record<string, string[]> | undefined): void;
208
+ create(workspaceId: string, createdBy: string, input: WebhookEndpointCreate): Promise<{
209
+ endpoint: WebhookEndpoint;
210
+ secret: string;
211
+ }>;
212
+ get(workspaceId: string, id: string): Promise<WebhookEndpoint | null>;
213
+ list(workspaceId: string, cursor: string | undefined, limit: number): Promise<{
214
+ webhooks: WebhookEndpoint[];
215
+ nextCursor: string | null;
216
+ }>;
217
+ /** Endpoints of the workspace, for the plan limit's count hook. */
218
+ count(workspaceId: string): Promise<number>;
219
+ update(workspaceId: string, id: string, patch: WebhookEndpointUpdate): Promise<WebhookEndpoint | null>;
220
+ remove(workspaceId: string, id: string): Promise<WebhookEndpoint | null>;
221
+ rotateSecret(workspaceId: string, id: string): Promise<{
222
+ endpoint: WebhookEndpoint;
223
+ secret: string;
224
+ previousSecretExpiresAt: string;
225
+ } | null>;
226
+ /** A signed `webhook.ping`, attempted inline, once; the row says how it went. */
227
+ test(workspaceId: string, id: string, sentBy: string | null): Promise<WebhookDelivery | null>;
228
+ listDeliveries(workspaceId: string, id: string, query: {
229
+ cursor?: string | undefined;
230
+ limit: number;
231
+ status?: WebhookDeliveryRow['status'] | undefined;
232
+ }): Promise<{
233
+ deliveries: WebhookDelivery[];
234
+ nextCursor: string | null;
235
+ } | null>;
236
+ getDelivery(workspaceId: string, id: string, deliveryId: string): Promise<WebhookDelivery | null>;
237
+ /** The same event queued again for the endpoint, as a new row (the event id unchanged: the receiver's dedupe key). */
238
+ redeliver(workspaceId: string, id: string, deliveryId: string): Promise<WebhookDelivery | null>;
239
+ private row;
240
+ private deliveryRow;
241
+ private requireBoss;
242
+ }
243
+ export declare function endpointToWire(row: WebhookEndpointRow): WebhookEndpoint;
244
+ export declare function deliveryToWire(row: WebhookDeliveryRow): WebhookDelivery;
245
+ //# sourceMappingURL=service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../src/webhooks/service.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACtC,OAAO,EAML,KAAK,EAAE,EACP,KAAK,MAAM,EACX,KAAK,kBAAkB,EACvB,KAAK,kBAAkB,EACxB,MAAM,wBAAwB,CAAC;AAChC,OAAO,KAAK,EACV,YAAY,EACZ,eAAe,EACf,eAAe,EACf,qBAAqB,EACrB,qBAAqB,EACtB,MAAM,8BAA8B,CAAC;AACtC,OAAO,KAAK,EAAE,MAAM,EAAE,M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