@classytic/arc 2.38.0 → 2.41.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 (196) hide show
  1. package/dist/{BaseController-CYaDvmOB.mjs → BaseController-DYJRZ0EJ.mjs} +114 -24
  2. package/dist/{EventTransport-Cx60_s-6.d.mts → EventTransport-CbUKDzZZ.d.mts} +33 -0
  3. package/dist/{EventTransport-Gq7JWbWw.mjs → EventTransport-n7qO5Cz3.mjs} +22 -2
  4. package/dist/{HookSystem-C0ikzqQf.mjs → HookSystem-CxvZBo77.mjs} +2 -2
  5. package/dist/{ResourceRegistry-DPcX--zk.mjs → ResourceRegistry-Cu7uTJp9.mjs} +2 -2
  6. package/dist/{actionPermissions-jlFZ1it4.mjs → actionPermissions-DPwPWPOV.mjs} +7 -6
  7. package/dist/audit/index.d.mts +2 -2
  8. package/dist/audit/index.mjs +10 -3
  9. package/dist/auth/audit.mjs +1 -1
  10. package/dist/auth/index.d.mts +2 -2
  11. package/dist/auth/index.mjs +12 -6
  12. package/dist/auth/redis-session.mjs +1 -1
  13. package/dist/{authorizationDecision-BP8GHtjc.mjs → authorizationDecision-2YY_Kaj1.mjs} +2 -2
  14. package/dist/{base-C-NL2fTi.d.mts → base-CxrV1LmG.d.mts} +10 -0
  15. package/dist/{buildHandler-DjXOqIvX.mjs → buildHandler-CUhjGHGZ.mjs} +4 -4
  16. package/dist/cache/index.d.mts +4 -2
  17. package/dist/cache/index.mjs +4 -4
  18. package/dist/{caching-a3ZEcJJs.mjs → caching-DsWDjIxx.mjs} +2 -2
  19. package/dist/cleanup/index.d.mts +2 -2
  20. package/dist/cleanup/index.mjs +21 -5
  21. package/dist/cli/commands/describe.d.mts +1 -1
  22. package/dist/cli/commands/describe.mjs +3 -3
  23. package/dist/cli/commands/docs.mjs +3 -3
  24. package/dist/cli/commands/doctor.mjs +1 -1
  25. package/dist/cli/commands/generate.mjs +2 -2
  26. package/dist/cli/commands/init.mjs +2 -2
  27. package/dist/cli/commands/introspect.mjs +2 -2
  28. package/dist/cli/index.mjs +3 -3
  29. package/dist/{constants-BONghE1Y.mjs → constants-BxLgNFF7.mjs} +1 -1
  30. package/dist/context/index.d.mts +34 -6
  31. package/dist/context/index.mjs +42 -24
  32. package/dist/core/index.d.mts +2 -2
  33. package/dist/core/index.mjs +7 -7
  34. package/dist/{core-8She7FgF.mjs → core-iNGqYerO.mjs} +3 -3
  35. package/dist/{createActionRouter-Bqi6Bhhx.mjs → createActionRouter-BBlbPs3k.mjs} +7 -7
  36. package/dist/{createAggregationRouter-BsYO7ktd.mjs → createAggregationRouter-Dv5SuK2x.mjs} +7 -7
  37. package/dist/createMcpServer-CbDWkZ1T.d.mts +48 -0
  38. package/dist/{defineAggregation-0KBvqEEC.mjs → defineAggregation-UyeurGkp.mjs} +1 -1
  39. package/dist/{defineResource-BMdyRelW.mjs → defineResource-DzGT-2LP.mjs} +20 -22
  40. package/dist/discovery/index.mjs +1 -1
  41. package/dist/docs/index.d.mts +1 -1
  42. package/dist/docs/index.mjs +3 -3
  43. package/dist/{elevation-C6woysGC.mjs → elevation-BF-vhGxY.mjs} +4 -4
  44. package/dist/encryption/index.mjs +3 -3
  45. package/dist/{errorHandler-DI5AN2b5.d.mts → errorHandler--4rSMMvq.d.mts} +7 -1
  46. package/dist/{errorHandler-BdmIWPba.mjs → errorHandler-CIMkCOWm.mjs} +3 -3
  47. package/dist/{errors-2ExmOgIJ.mjs → errors-C_YhELhe.mjs} +1 -1
  48. package/dist/{eventPlugin-DFvHa4Nf.d.mts → eventPlugin-B52abJ8W.d.mts} +1 -1
  49. package/dist/{eventPlugin-DJwpGMzx.mjs → eventPlugin-CmXaPWLv.mjs} +5 -5
  50. package/dist/events/index.d.mts +4 -4
  51. package/dist/events/index.mjs +5 -5
  52. package/dist/events/transports/redis-stream-entry.d.mts +1 -1
  53. package/dist/events/transports/redis-stream-entry.mjs +34 -24
  54. package/dist/events/transports/redis.d.mts +1 -1
  55. package/dist/events/transports/redis.mjs +11 -8
  56. package/dist/factory/index.d.mts +5 -5
  57. package/dist/factory/index.mjs +5 -5
  58. package/dist/{fastify-augmentation-jYA2oHyL.d.mts → fastify-augmentation-Cq2nHVaW.d.mts} +3 -3
  59. package/dist/{fields-Cha2QCKH.mjs → fields-BTyPLHK0.mjs} +1 -1
  60. package/dist/{generate-BUP4Oydg.mjs → generate-D_YmiCNf.mjs} +4 -3
  61. package/dist/{headers-DeXNifVj.mjs → headers-CNECDE6q.mjs} +2 -2
  62. package/dist/{health-Bh0N_FLk.mjs → health-CxQzbJmr.mjs} +10 -2
  63. package/dist/hooks/index.d.mts +1 -1
  64. package/dist/hooks/index.mjs +2 -2
  65. package/dist/idempotency/index.d.mts +1 -1
  66. package/dist/idempotency/index.mjs +4 -4
  67. package/dist/idempotency/redis.d.mts +1 -1
  68. package/dist/idempotency/redis.mjs +1 -1
  69. package/dist/{index-BtYoMip1.d.mts → index-BHdZD8zK.d.mts} +10 -2
  70. package/dist/{index-D2uIUSQk.d.mts → index-CFfLKMH4.d.mts} +2 -2
  71. package/dist/{index-eyg5WEcy.d.mts → index-CbJiYrfv.d.mts} +1 -1
  72. package/dist/{index-BRoDtjek.d.mts → index-D4u76eQW.d.mts} +3 -3
  73. package/dist/{index-B78WZom8.d.mts → index-DHbyPo5j.d.mts} +52 -12
  74. package/dist/index.d.mts +5 -5
  75. package/dist/index.mjs +11 -11
  76. package/dist/{init-Dg_Am2o_.mjs → init-Y2MlSN9n.mjs} +9 -9
  77. package/dist/integrations/event-gateway.d.mts +1 -1
  78. package/dist/integrations/event-gateway.mjs +2 -2
  79. package/dist/integrations/index.d.mts +2 -2
  80. package/dist/integrations/index.mjs +1 -1
  81. package/dist/integrations/jobs/index.d.mts +1 -1
  82. package/dist/integrations/jobs/index.mjs +2 -2
  83. package/dist/integrations/mcp/index.d.mts +4 -47
  84. package/dist/integrations/mcp/index.mjs +2 -2
  85. package/dist/integrations/mcp/testing.d.mts +22 -2
  86. package/dist/integrations/mcp/testing.mjs +55 -33
  87. package/dist/integrations/streamline.mjs +3 -3
  88. package/dist/integrations/webhooks.d.mts +2 -2
  89. package/dist/integrations/webhooks.mjs +3 -3
  90. package/dist/integrations/websocket-pushref-redis.d.mts +1 -1
  91. package/dist/integrations/websocket-pushref-redis.mjs +1 -1
  92. package/dist/integrations/websocket-redis.mjs +1 -1
  93. package/dist/integrations/websocket.mjs +24 -6
  94. package/dist/{interface-DYPVscCU.mjs → interface-BIpgzbZl.mjs} +1 -1
  95. package/dist/{jsonBody-DVui0uJl.mjs → jsonBody-Cq9KYl2Z.mjs} +2 -2
  96. package/dist/{keys-BSuxGS-B.mjs → keys-Cmv4cBRa.mjs} +1 -1
  97. package/dist/{loadResources-CNd1DWnK.mjs → loadResources-CblF7xt2.mjs} +2 -2
  98. package/dist/{loadResourcesFromEntry-DNj8cpiY.mjs → loadResourcesFromEntry-99fIMC3p.mjs} +2 -2
  99. package/dist/logger/index.mjs +1 -1
  100. package/dist/{mcpPlugin-KWsezMx7.mjs → mcpPlugin-xF3Gw-HW.mjs} +75 -31
  101. package/dist/{memory-BiPVaCPg.mjs → memory-CpDZ9NPw.mjs} +2 -2
  102. package/dist/{metrics-CsWaIVTa.mjs → metrics-BaKnq8ag.mjs} +2 -2
  103. package/dist/middleware/index.d.mts +1 -1
  104. package/dist/middleware/index.mjs +3 -3
  105. package/dist/migrations/index.mjs +2 -2
  106. package/dist/{module-BQXHxMEk.mjs → module-BkQEesNQ.mjs} +1 -1
  107. package/dist/{multipartBody-u6VrS_iH.mjs → multipartBody-C92aJ8am.mjs} +1 -1
  108. package/dist/{openapi-Dxc8RLy_.mjs → openapi-C3LFRzPq.mjs} +6 -6
  109. package/dist/outbox-admin/index.d.mts +2 -2
  110. package/dist/outbox-admin/index.mjs +4 -4
  111. package/dist/{outbox-module-CQXu_O6o.d.mts → outbox-module-BHdUnuuK.d.mts} +15 -2
  112. package/dist/{outbox-module-DyIqA5vo.mjs → outbox-module-dsCyLxXH.mjs} +43 -21
  113. package/dist/permissions/index.d.mts +2 -2
  114. package/dist/permissions/index.mjs +5 -5
  115. package/dist/{permissions-H7Zcb82Z.mjs → permissions-DiHXy8Ck.mjs} +12 -6
  116. package/dist/{pipe-SunhEaZ6.mjs → pipe-CBVmUJ-j.mjs} +2 -2
  117. package/dist/pipeline/index.d.mts +1 -1
  118. package/dist/pipeline/index.mjs +2 -2
  119. package/dist/plugins/index.d.mts +7 -37
  120. package/dist/plugins/index.mjs +34 -22
  121. package/dist/plugins/response-cache.mjs +9 -2
  122. package/dist/plugins/tracing-entry.mjs +2 -2
  123. package/dist/{pluralize-Da7IT_qJ.mjs → pluralize-2_U6QZQg.mjs} +1 -1
  124. package/dist/{preloadResources-DlhH81py.mjs → preloadResources-Bbp4QJ8V.mjs} +82 -26
  125. package/dist/{preloadResources-BbBkNkqK.d.mts → preloadResources-CjS2OfpU.d.mts} +14 -9
  126. package/dist/presets/filesUpload.d.mts +2 -2
  127. package/dist/presets/filesUpload.mjs +5 -5
  128. package/dist/presets/index.d.mts +2 -2
  129. package/dist/presets/index.mjs +2 -2
  130. package/dist/presets/multiTenant.d.mts +38 -1
  131. package/dist/presets/multiTenant.mjs +24 -6
  132. package/dist/presets/search.d.mts +2 -2
  133. package/dist/presets/search.mjs +2 -2
  134. package/dist/{presets-CNyfaxGL.mjs → presets-BdlugYTc.mjs} +4 -4
  135. package/dist/{projection-DSfEoooA.mjs → projection-Uvgp-EEj.mjs} +2 -2
  136. package/dist/{queryCachePlugin-oTsmVyEQ.mjs → queryCachePlugin-B5F09bYr.mjs} +11 -5
  137. package/dist/rateLimitKey-CK-EU2L8.mjs +41 -0
  138. package/dist/{realtime-CPmjjgqd.mjs → realtime-FnnD0n3Z.mjs} +9 -9
  139. package/dist/{redis-CduhKsJi.d.mts → redis-Bzi1y3F9.d.mts} +10 -2
  140. package/dist/{redis-stream-eh0eOtjh.d.mts → redis-stream-BPKscsTB.d.mts} +12 -7
  141. package/dist/{registerRoute-XvcI_3sh.mjs → registerRoute-DRsSHPSM.mjs} +6 -6
  142. package/dist/registry/index.d.mts +2 -2
  143. package/dist/registry/index.mjs +3 -3
  144. package/dist/{registry-UFEJQN8R.mjs → registry-D3y8VEJ1.mjs} +2 -2
  145. package/dist/{renewingLease-DuRGVOMe.mjs → renewingLease-B3VYh5aU.mjs} +1 -1
  146. package/dist/{replyHelpers-BHebarf0.mjs → replyHelpers-DPHsdw-5.mjs} +2 -2
  147. package/dist/{requestContext-DpmntRZy.mjs → requestContext-cSVKnYPk.mjs} +1 -1
  148. package/dist/{rolldown-runtime-Add2L50I.mjs → rolldown-runtime-DjDuyglE.mjs} +1 -1
  149. package/dist/{runtimeCapabilities-D793Pxci.mjs → runtimeCapabilities-DSA_dH1_.mjs} +31 -5
  150. package/dist/{schedules-DthM8Qag.mjs → schedules-BktJb3Y3.mjs} +8 -4
  151. package/dist/{schemaConverter-Db-MMsH6.mjs → schemaConverter-BLCSmNbr.mjs} +1 -1
  152. package/dist/{schemaIR-CIXShch7.mjs → schemaIR-K16Bb5BX.mjs} +2 -2
  153. package/dist/schemas/index.mjs +1 -1
  154. package/dist/scim/index.mjs +2 -2
  155. package/dist/scope/index.mjs +5 -5
  156. package/dist/{scope-D03sk17n.mjs → scope-jSxuBTFM.mjs} +4 -4
  157. package/dist/{simpleEqualityMatcher-B7qVjQBv.mjs → simpleEqualityMatcher-BiOnyflP.mjs} +1 -1
  158. package/dist/{sse-D4MYqkic.mjs → sse-CH7Slxc1.mjs} +5 -5
  159. package/dist/{sseStream-BuMNPR6r.mjs → sseStream-CN-Lh1Tu.mjs} +2 -2
  160. package/dist/{store-helpers-CIF4RG8s.mjs → store-helpers-9DX9-1j_.mjs} +1 -1
  161. package/dist/{streaming-DkpW1HwJ.mjs → streaming-dvppnxsr.mjs} +1 -1
  162. package/dist/{subscribe-helpers-CBZOi6pk.mjs → subscribe-helpers-AVYPgqTl.mjs} +2 -2
  163. package/dist/sync/changelog.mjs +1 -1
  164. package/dist/testing/cleanupStoreContract.mjs +1 -1
  165. package/dist/testing/index.d.mts +5 -5
  166. package/dist/testing/index.mjs +10 -10
  167. package/dist/testing/outboxStoreContract.mjs +14 -3
  168. package/dist/testing/storageContract.mjs +1 -1
  169. package/dist/{transactionContext-DMmvcfdo.mjs → transactionContext-DCWMI6hV.mjs} +1 -1
  170. package/dist/{typeGuards-DHTnEs5X.mjs → typeGuards-D7tHFdH6.mjs} +1 -1
  171. package/dist/types/index.d.mts +2 -2
  172. package/dist/types/index.mjs +1 -1
  173. package/dist/types/storage.mjs +1 -1
  174. package/dist/{types-BqLyyH0o.mjs → types-CDy3-zw1.mjs} +4 -4
  175. package/dist/{types-LQFwC37d.d.mts → types-CWQn9-IC.d.mts} +46 -1
  176. package/dist/{types-BRU-Kd3t.d.mts → types-DfVDvkdP.d.mts} +20 -2
  177. package/dist/usage/index.d.mts +58 -2
  178. package/dist/usage/index.mjs +0 -0
  179. package/dist/{userHelpers-CXySQFRg.mjs → userHelpers-DDMOZ_Pm.mjs} +1 -1
  180. package/dist/utils/index.d.mts +110 -8
  181. package/dist/utils/index.mjs +12 -12
  182. package/dist/{utils-BbGG8XNT.mjs → utils-B-zj_b__.mjs} +61 -12
  183. package/dist/{validate-CidSeUrx.mjs → validate-R0G_JrnK.mjs} +2 -2
  184. package/dist/{versioning-B843jOYX.d.mts → versioning-D6JIK8Tk.d.mts} +58 -2
  185. package/dist/{versioning-C2r0eOZ4.mjs → versioning-DuVWcu-F.mjs} +3 -3
  186. package/dist/workScope-BhsWde4k.mjs +41 -0
  187. package/package.json +574 -565
  188. package/skills/arc/SKILL.md +8 -4
  189. package/skills/arc/references/mcp.md +20 -0
  190. package/skills/arc/references/production.md +94 -9
  191. package/skills/arc/references/testing.md +0 -12
  192. package/skills/arc-code-review/references/anti-patterns.md +1 -1
  193. package/skills/arc-code-review/references/migration-recipes.md +0 -60
  194. package/skills/arc-code-review/references/mongokit-migration.md +0 -27
  195. package/skills/arc-module-publishing/references/package-manifest.md +3 -1
  196. package/dist/rateLimitKey-CewdR-m6.mjs +0 -15
@@ -1,18 +1,18 @@
1
- /*! @classytic/arc v2.38.0 | MIT | https://classytic.com */
2
- import { r as evaluatePermissionDecision } from "./authorizationDecision-BP8GHtjc.mjs";
3
- import { p as isArcError, t as ArcError } from "./errors-2ExmOgIJ.mjs";
4
- import { n as requireSingleHeaderValue } from "./headers-DeXNifVj.mjs";
5
- import { b as isElevated, c as getOrgId, g as getUserId, x as isMember } from "./types-BqLyyH0o.mjs";
6
- import { t as BaseController } from "./BaseController-CYaDvmOB.mjs";
7
- import { a as resolveEffectiveRoles, t as applyFieldReadPermissions } from "./fields-Cha2QCKH.mjs";
8
- import { t as buildRequestScopeProjection } from "./projection-DSfEoooA.mjs";
9
- import { i as resolvePipelineSteps, t as resolveActionPermission } from "./actionPermissions-jlFZ1it4.mjs";
10
- import { t as executePipeline } from "./pipe-SunhEaZ6.mjs";
11
- import { t as pluralize } from "./pluralize-Da7IT_qJ.mjs";
12
- import { t as createIdempotencyResult } from "./interface-DYPVscCU.mjs";
13
- import { r as shouldRejectAdditionalProperties, t as normalizeSchemaIR } from "./schemaIR-CIXShch7.mjs";
14
- import { n as validateAggregations } from "./validate-CidSeUrx.mjs";
15
- import { n as executeAggregation } from "./buildHandler-DjXOqIvX.mjs";
1
+ /*! @classytic/arc v2.41.0 | MIT | https://classytic.com */
2
+ import { r as evaluatePermissionDecision } from "./authorizationDecision-2YY_Kaj1.mjs";
3
+ import { p as isArcError, t as ArcError } from "./errors-C_YhELhe.mjs";
4
+ import { n as requireSingleHeaderValue } from "./headers-CNECDE6q.mjs";
5
+ import { b as isElevated, c as getOrgId, g as getUserId, x as isMember } from "./types-CDy3-zw1.mjs";
6
+ import { t as BaseController } from "./BaseController-DYJRZ0EJ.mjs";
7
+ import { a as resolveEffectiveRoles, t as applyFieldReadPermissions } from "./fields-BTyPLHK0.mjs";
8
+ import { t as buildRequestScopeProjection } from "./projection-Uvgp-EEj.mjs";
9
+ import { i as resolvePipelineSteps, t as resolveActionPermission } from "./actionPermissions-DPwPWPOV.mjs";
10
+ import { t as executePipeline } from "./pipe-CBVmUJ-j.mjs";
11
+ import { t as pluralize } from "./pluralize-2_U6QZQg.mjs";
12
+ import { t as createIdempotencyResult } from "./interface-BIpgzbZl.mjs";
13
+ import { r as shouldRejectAdditionalProperties, t as normalizeSchemaIR } from "./schemaIR-K16Bb5BX.mjs";
14
+ import { n as validateAggregations } from "./validate-R0G_JrnK.mjs";
15
+ import { n as executeAggregation } from "./buildHandler-CUhjGHGZ.mjs";
16
16
  import { isHttpError, toErrorContract } from "@classytic/repo-core/errors";
17
17
  import { createHash, randomUUID } from "node:crypto";
18
18
  import fp from "fastify-plugin";
@@ -50,7 +50,7 @@ import { z } from "zod";
50
50
  * @returns McpServer instance (not yet connected to a transport)
51
51
  */
52
52
  async function createMcpServer(config, authRef) {
53
- const { McpServer } = await import("@modelcontextprotocol/sdk/server/mcp.js");
53
+ const { McpServer } = await import("@modelcontextprotocol/server");
54
54
  const server = new McpServer({
55
55
  name: config.name,
56
56
  version: config.version ?? "1.0.0"
@@ -130,25 +130,39 @@ function registerTool(server, tool, authRef) {
130
130
  const config = {};
131
131
  if (tool.title) config.title = tool.title;
132
132
  if (tool.description) config.description = tool.description;
133
+ /**
134
+ * Flat SHAPES are passed straight through. v2's `registerTool` carries a
135
+ * `ZodRawShape` overload and auto-wraps it in `z.object()` itself, so arc's
136
+ * host-facing ergonomic (`{ name: z.string() }`) needs no adaptation layer.
137
+ *
138
+ * arc's own MIGRATION-V2 notes claimed v2 "requires z.object(), raw shapes no
139
+ * longer accepted" and a wrap was written here on that basis. That was true of
140
+ * the PRE-ALPHA and is not true of 2.0.0 — checked against the shipped
141
+ * overloads. Wrapping anyway would have been arc maintaining an adapter for a
142
+ * conversion the SDK already owns.
143
+ */
133
144
  if (tool.inputSchema) config.inputSchema = tool.inputSchema;
134
145
  if (tool.outputSchema) config.outputSchema = tool.outputSchema;
135
146
  if (tool.annotations) config.annotations = tool.annotations;
136
- srv.registerTool(tool.name, config, (input, extra) => {
147
+ srv.registerTool(tool.name, config, (input, mcpCtx) => {
137
148
  const ctx = {
138
149
  session: authRef?.current ?? null,
150
+ /**
151
+ * v2 exposes logging as `ctx.mcpReq.log(level, message)` — the SDK builds
152
+ * the `notifications/message` envelope and correlates it to the in-flight
153
+ * request. v1 handed over a raw `sendNotification` that arc had to frame
154
+ * itself; that hand-framed envelope carried no request id, so a log line
155
+ * from a tool arrived uncorrelated.
156
+ *
157
+ * Still best-effort: a transport that has already closed must not turn a
158
+ * successful tool call into a failed one.
159
+ */
139
160
  log: async (level, message) => {
140
161
  try {
141
- const notify = extra?.sendNotification;
142
- if (notify) await notify({
143
- method: "notifications/message",
144
- params: {
145
- level,
146
- data: message
147
- }
148
- });
162
+ await (mcpCtx?.mcpReq)?.log?.(level, message);
149
163
  } catch {}
150
164
  },
151
- extra
165
+ extra: mcpCtx
152
166
  };
153
167
  return tool.handler(input, ctx);
154
168
  });
@@ -2035,7 +2049,7 @@ function resourceToTools(resource, config = {}) {
2035
2049
  */
2036
2050
  function registerSchemaResources(server, resources, overrides) {
2037
2051
  const srv = server;
2038
- srv.resource("schemas", "arc://schemas", {
2052
+ srv.registerResource("schemas", "arc://schemas", {
2039
2053
  title: "Arc Resource Schemas",
2040
2054
  description: "All available resources",
2041
2055
  mimeType: "application/json"
@@ -2053,7 +2067,7 @@ function registerSchemaResources(server, resources, overrides) {
2053
2067
  for (const r of resources) {
2054
2068
  const uri = `arc://schemas/${r.name}`;
2055
2069
  const schemaOpts = r.schemaOptions;
2056
- srv.resource(`schema-${r.name}`, uri, {
2070
+ srv.registerResource(`schema-${r.name}`, uri, {
2057
2071
  title: `${r.displayName} Schema`,
2058
2072
  description: `Schema for ${r.displayName}`,
2059
2073
  mimeType: "application/json"
@@ -2181,7 +2195,7 @@ var McpSessionCache = class {
2181
2195
  closeTransport(entry) {
2182
2196
  try {
2183
2197
  const transport = entry.transport;
2184
- if (transport && typeof transport.close === "function") transport.close();
2198
+ if (transport && typeof transport.close === "function") Promise.resolve(transport.close()).catch(() => {});
2185
2199
  } catch {}
2186
2200
  }
2187
2201
  };
@@ -2219,9 +2233,9 @@ var McpSessionCache = class {
2219
2233
  const mcpPluginImpl = async (fastify, options) => {
2220
2234
  let StreamableHTTPServerTransport;
2221
2235
  try {
2222
- StreamableHTTPServerTransport = (await import("@modelcontextprotocol/sdk/server/streamableHttp.js")).StreamableHTTPServerTransport;
2236
+ StreamableHTTPServerTransport = (await import("@modelcontextprotocol/node")).NodeStreamableHTTPServerTransport;
2223
2237
  } catch {
2224
- throw new Error("@modelcontextprotocol/sdk is required for MCP support. Install it: npm install @modelcontextprotocol/sdk");
2238
+ throw new Error("@modelcontextprotocol/server and @modelcontextprotocol/node are required for MCP support. Install them: npm install @modelcontextprotocol/server @modelcontextprotocol/node");
2225
2239
  }
2226
2240
  try {
2227
2241
  await import("zod");
@@ -2286,6 +2300,36 @@ const mcpPluginImpl = async (fastify, options) => {
2286
2300
  const more = allTools.length > 5 ? ` (+${allTools.length - 5} more)` : "";
2287
2301
  fastify.log.warn(`[arc/mcp] MCP server registered at "${prefix}" with auth DISABLED. Anyone who can reach this URL has full access to ${allTools.length} tools across ${enabledResources.length} resources: ${toolList}${more}. Pass \`auth: betterAuthInstance\` or \`auth: async (headers) => ...\` to gate access. Safe only for stdio transports, local development, or explicitly-public read-only APIs.`);
2288
2302
  }
2303
+ const rebindOption = options.dnsRebindingProtection;
2304
+ if (rebindOption === void 0 ? options.auth === false : rebindOption !== false) {
2305
+ const { validateHostHeader, validateOriginHeader, localhostAllowedHostnames } = await import("@modelcontextprotocol/server");
2306
+ const cfg = rebindOption === void 0 || rebindOption === false ? {} : rebindOption;
2307
+ const allowedHosts = cfg.allowedHosts ?? localhostAllowedHostnames();
2308
+ const allowedOrigins = cfg.allowedOrigins ?? allowedHosts;
2309
+ const healthPath = `${prefix}/health`;
2310
+ fastify.addHook("onRequest", async (request, reply) => {
2311
+ if (!request.url.startsWith(prefix)) return;
2312
+ if (request.url.split("?")[0] === healthPath) return;
2313
+ const host = validateHostHeader(request.headers.host, allowedHosts);
2314
+ if (!host.ok) return reply.code(403).send({
2315
+ jsonrpc: "2.0",
2316
+ error: {
2317
+ code: -32e3,
2318
+ message: host.message
2319
+ },
2320
+ id: null
2321
+ });
2322
+ const origin = validateOriginHeader(request.headers.origin, allowedOrigins);
2323
+ if (!origin.ok) return reply.code(403).send({
2324
+ jsonrpc: "2.0",
2325
+ error: {
2326
+ code: -32e3,
2327
+ message: origin.message
2328
+ },
2329
+ id: null
2330
+ });
2331
+ });
2332
+ }
2289
2333
  fastify.get(`${prefix}/health`, async (request, reply) => {
2290
2334
  const liveness = {
2291
2335
  status: "ok",
@@ -1,5 +1,5 @@
1
- /*! @classytic/arc v2.38.0 | MIT | https://classytic.com */
2
- import { t as __exportAll } from "./rolldown-runtime-Add2L50I.mjs";
1
+ /*! @classytic/arc v2.41.0 | MIT | https://classytic.com */
2
+ import { t as __exportAll } from "./rolldown-runtime-DjDuyglE.mjs";
3
3
  //#region src/cache/memory.ts
4
4
  var memory_exports = /* @__PURE__ */ __exportAll({ MemoryCacheStore: () => MemoryCacheStore });
5
5
  /**
@@ -1,5 +1,5 @@
1
- /*! @classytic/arc v2.38.0 | MIT | https://classytic.com */
2
- import { t as __exportAll } from "./rolldown-runtime-Add2L50I.mjs";
1
+ /*! @classytic/arc v2.41.0 | MIT | https://classytic.com */
2
+ import { t as __exportAll } from "./rolldown-runtime-DjDuyglE.mjs";
3
3
  import fp from "fastify-plugin";
4
4
  //#region src/plugins/metrics.ts
5
5
  var metrics_exports = /* @__PURE__ */ __exportAll({
@@ -1,5 +1,5 @@
1
1
 
2
- import { I as MiddlewareHandler, L as RequestWithExtras, Q as MiddlewareConfig } from "../index-B78WZom8.mjs";
2
+ import { I as MiddlewareHandler, L as RequestWithExtras, Q as MiddlewareConfig } from "../index-DHbyPo5j.mjs";
3
3
  import { RouteHandlerMethod } from "fastify";
4
4
  //#region src/middleware/middleware.d.ts
5
5
  interface NamedMiddleware {
@@ -1,6 +1,6 @@
1
- /*! @classytic/arc v2.38.0 | MIT | https://classytic.com */
2
- import { t as CRUD_OPERATIONS } from "../constants-BONghE1Y.mjs";
3
- import { t as multipartBody } from "../multipartBody-u6VrS_iH.mjs";
1
+ /*! @classytic/arc v2.41.0 | MIT | https://classytic.com */
2
+ import { t as CRUD_OPERATIONS } from "../constants-BxLgNFF7.mjs";
3
+ import { t as multipartBody } from "../multipartBody-C92aJ8am.mjs";
4
4
  //#region src/middleware/middleware.ts
5
5
  /**
6
6
  * Named Middleware — Priority-based, conditional middleware execution.
@@ -1,5 +1,5 @@
1
- /*! @classytic/arc v2.38.0 | MIT | https://classytic.com */
2
- import { t as startRenewingLease } from "../renewingLease-DuRGVOMe.mjs";
1
+ /*! @classytic/arc v2.41.0 | MIT | https://classytic.com */
2
+ import { t as startRenewingLease } from "../renewingLease-B3VYh5aU.mjs";
3
3
  import { createHash, randomUUID } from "node:crypto";
4
4
  //#region src/migrations/index.ts
5
5
  /**
@@ -1,4 +1,4 @@
1
- /*! @classytic/arc v2.38.0 | MIT | https://classytic.com */
1
+ /*! @classytic/arc v2.41.0 | MIT | https://classytic.com */
2
2
  //#region src/factory/module/index.ts
3
3
  /**
4
4
  * Identity helper for authoring a typed module — mirrors `defineResource`.
@@ -1,4 +1,4 @@
1
- /*! @classytic/arc v2.38.0 | MIT | https://classytic.com */
1
+ /*! @classytic/arc v2.41.0 | MIT | https://classytic.com */
2
2
  import sjson from "secure-json-parse";
3
3
  //#region src/middleware/multipartBody.ts
4
4
  const DEFAULT_MAX_FILE_SIZE = 10485760;
@@ -1,9 +1,9 @@
1
- /*! @classytic/arc v2.38.0 | MIT | https://classytic.com */
2
- import { n as getUserRoles } from "./userHelpers-CXySQFRg.mjs";
3
- import { n as convertRouteSchema } from "./schemaConverter-Db-MMsH6.mjs";
4
- import { t as resolveActionPermission } from "./actionPermissions-jlFZ1it4.mjs";
5
- import { t as pluralize } from "./pluralize-Da7IT_qJ.mjs";
6
- import { t as buildActionBodySchema } from "./createActionRouter-Bqi6Bhhx.mjs";
1
+ /*! @classytic/arc v2.41.0 | MIT | https://classytic.com */
2
+ import { n as getUserRoles } from "./userHelpers-DDMOZ_Pm.mjs";
3
+ import { n as convertRouteSchema } from "./schemaConverter-BLCSmNbr.mjs";
4
+ import { t as resolveActionPermission } from "./actionPermissions-DPwPWPOV.mjs";
5
+ import { t as pluralize } from "./pluralize-2_U6QZQg.mjs";
6
+ import { t as buildActionBodySchema } from "./createActionRouter-BBlbPs3k.mjs";
7
7
  import fp from "fastify-plugin";
8
8
  //#region src/docs/openapi/canonical-schemas.ts
9
9
  /**
@@ -1,6 +1,6 @@
1
1
 
2
- import { l as PermissionCheck } from "../base-C-NL2fTi.mjs";
3
- import { t as ArcModule } from "../types-BRU-Kd3t.mjs";
2
+ import { l as PermissionCheck } from "../base-CxrV1LmG.mjs";
3
+ import { t as ArcModule } from "../types-DfVDvkdP.mjs";
4
4
  import { OutboxStore } from "@classytic/primitives/outbox";
5
5
  //#region src/outbox-admin/module.d.ts
6
6
  /**
@@ -1,7 +1,7 @@
1
- /*! @classytic/arc v2.38.0 | MIT | https://classytic.com */
2
- import { i as NotFoundError, u as ValidationError } from "../errors-2ExmOgIJ.mjs";
3
- import { t as defineResource } from "../defineResource-BMdyRelW.mjs";
4
- import { n as getModuleExports, t as defineModule } from "../module-BQXHxMEk.mjs";
1
+ /*! @classytic/arc v2.41.0 | MIT | https://classytic.com */
2
+ import { i as NotFoundError, u as ValidationError } from "../errors-C_YhELhe.mjs";
3
+ import { t as defineResource } from "../defineResource-DzGT-2LP.mjs";
4
+ import { n as getModuleExports, t as defineModule } from "../module-BkQEesNQ.mjs";
5
5
  //#region src/outbox-admin/module.ts
6
6
  /**
7
7
  * Strip the domain payload and the stack unless explicitly opted in.
@@ -1,6 +1,6 @@
1
1
 
2
- import { a as EventTransport, n as DomainEvent, t as DeadLetteredEvent } from "./EventTransport-Cx60_s-6.mjs";
3
- import { t as ArcModule } from "./types-BRU-Kd3t.mjs";
2
+ import { a as EventTransport, n as DomainEvent, t as DeadLetteredEvent } from "./EventTransport-CbUKDzZZ.mjs";
3
+ import { t as ArcModule } from "./types-DfVDvkdP.mjs";
4
4
  import { FastifyInstance } from "fastify";
5
5
  import { MemoryOutboxStore } from "@classytic/primitives/memory-outbox";
6
6
  import { OutboxFailurePolicy, OutboxStore, OutboxWriteOptions } from "@classytic/primitives/outbox";
@@ -372,6 +372,19 @@ interface OutboxModuleExports {
372
372
  store: OutboxStore;
373
373
  /** The relay, for a host that wants to drain on demand (tests, admin actions). */
374
374
  relay: EventOutbox;
375
+ /**
376
+ * Ask for a relay pass SOON, without waiting for the interval. Coalesced:
377
+ * any number of calls before the pass runs produce ONE pass. Never throws
378
+ * and returns nothing — a unit of work calls this after commit so a row it
379
+ * just wrote is delivered in milliseconds rather than up to `relayEveryMs`
380
+ * later. Safe under concurrency: the store's lease and fence token make an
381
+ * extra pass a no-op, not a double publish.
382
+ *
383
+ * Calling from inside a request does NOT put the pass in that request's
384
+ * scope: a pass drains whatever is pending, which is other requests' rows.
385
+ * The pass runs scope-free, so each event opens its own (see `runWorkScope`).
386
+ */
387
+ requestDrain: () => void;
375
388
  }
376
389
  /**
377
390
  * Compose the outbox as a module.
@@ -1,7 +1,8 @@
1
- /*! @classytic/arc v2.38.0 | MIT | https://classytic.com */
2
- import { t as transactionContext } from "./transactionContext-DMmvcfdo.mjs";
3
- import { i as resolveEventTransport } from "./EventTransport-Gq7JWbWw.mjs";
4
- import { n as createSafeGetOne, t as createIsDuplicateKeyError } from "./store-helpers-CIF4RG8s.mjs";
1
+ /*! @classytic/arc v2.41.0 | MIT | https://classytic.com */
2
+ import { t as transactionContext } from "./transactionContext-DCWMI6hV.mjs";
3
+ import { n as requestContext } from "./requestContext-cSVKnYPk.mjs";
4
+ import { i as resolveEventTransport } from "./EventTransport-n7qO5Cz3.mjs";
5
+ import { n as createSafeGetOne, t as createIsDuplicateKeyError } from "./store-helpers-9DX9-1j_.mjs";
5
6
  import { and, anyOf, eq, lte, ne, or } from "@classytic/repo-core/filter";
6
7
  import { randomBytes } from "node:crypto";
7
8
  import { InvalidOutboxEventError, OutboxOwnershipError } from "@classytic/primitives/outbox";
@@ -807,25 +808,46 @@ function createOutboxModule(options) {
807
808
  * module exists to prevent, arrived at from the other side.
808
809
  */
809
810
  if (transport === void 0) throw new Error(`Outbox module "${name}" could not resolve an event transport, so its relay would tick forever without publishing while the store grows. Register arc's events plugin (it is on by default — check \`arcPlugins.events !== false\`), or pass an explicit \`transport\` to \`createOutboxModule\`. Note the outbox needs the RAW EventTransport, not the \`fastify.events\` facade: the facade takes \`(type, payload, meta?)\` and fails open, which would acknowledge rows whose publish actually failed.`);
811
+ const relay = new EventOutbox({
812
+ store,
813
+ transport,
814
+ ...options.batchSize !== void 0 ? { batchSize: options.batchSize } : {},
815
+ ...options.leaseMs !== void 0 ? { leaseMs: options.leaseMs } : {},
816
+ consumerId: options.consumerId ?? mintConsumerId(name),
817
+ onError: options.onError ?? ((info) => {
818
+ fastify.log.error({
819
+ err: info.error,
820
+ kind: info.kind,
821
+ ...info.event?.meta.id !== void 0 ? { eventId: info.event.meta.id } : {},
822
+ ...info.event?.type !== void 0 ? { eventType: info.event.type } : {}
823
+ }, `outbox relay "${name}" failed`);
824
+ }),
825
+ ...options.failurePolicy !== void 0 ? { failurePolicy: options.failurePolicy } : {},
826
+ ...options.sessionProvider === false ? {} : { sessionProvider: options.sessionProvider ?? (() => transactionContext.get()) }
827
+ });
828
+ /**
829
+ * One pass per burst of requests. `drainQueued` stays true from the
830
+ * first request until the pass STARTS, so a request landing mid-pass
831
+ * schedules the next one — a row written during a pass is never left
832
+ * waiting for the interval.
833
+ */
834
+ let drainQueued = false;
835
+ const requestDrain = () => {
836
+ if (drainQueued) return;
837
+ drainQueued = true;
838
+ setImmediate(() => {
839
+ drainQueued = false;
840
+ requestContext.storage.exit(() => {
841
+ relay.relayBatch().catch((err) => {
842
+ fastify.log.error({ err }, `outbox relay "${name}" requested drain failed`);
843
+ });
844
+ });
845
+ });
846
+ };
810
847
  exports = {
811
848
  store,
812
- relay: new EventOutbox({
813
- store,
814
- transport,
815
- ...options.batchSize !== void 0 ? { batchSize: options.batchSize } : {},
816
- ...options.leaseMs !== void 0 ? { leaseMs: options.leaseMs } : {},
817
- consumerId: options.consumerId ?? mintConsumerId(name),
818
- onError: options.onError ?? ((info) => {
819
- fastify.log.error({
820
- err: info.error,
821
- kind: info.kind,
822
- ...info.event?.meta.id !== void 0 ? { eventId: info.event.meta.id } : {},
823
- ...info.event?.type !== void 0 ? { eventType: info.event.type } : {}
824
- }, `outbox relay "${name}" failed`);
825
- }),
826
- ...options.failurePolicy !== void 0 ? { failurePolicy: options.failurePolicy } : {},
827
- ...options.sessionProvider === false ? {} : { sessionProvider: options.sessionProvider ?? (() => transactionContext.get()) }
828
- })
849
+ relay,
850
+ requestDrain
829
851
  };
830
852
  return exports;
831
853
  },
@@ -1,5 +1,5 @@
1
1
 
2
- import { c as DataPolicy, d as UserBase, l as PermissionCheck, m as normalizeRoles, p as getUserRoles, s as AuthorizationDecision, u as PermissionContext } from "../base-C-NL2fTi.mjs";
2
+ import { c as DataPolicy, d as UserBase, l as PermissionCheck, m as normalizeRoles, p as getUserRoles, s as AuthorizationDecision, u as PermissionContext } from "../base-CxrV1LmG.mjs";
3
3
  import { a as applyFieldWritePermissions, i as applyFieldReadPermissions, n as FieldPermissionMap, o as fields, r as FieldPermissionType, s as resolveEffectiveRoles, t as FieldPermission } from "../fields-I_EeRWND.mjs";
4
- import { $ as requireAuth, A as RequireGrantOptions, B as ConnectEventsOptions, C as requireServiceScope, D as GRANT_MODES, E as createRoleHierarchy, F as PermissionRequirement, G as createOrgPermissions, H as DynamicPermissionMatrixConfig, I as collectPublicSurface, J as allowPublic, K as allOf, L as describePermission, M as requireGrant, N as conjoinPolicyFilters, O as GrantMode, P as AccessExplanation, Q as not, R as describePermissionMap, S as requireScopeContext, T as RoleHierarchy, U as PermissionEventBus, V as DynamicPermissionMatrix, W as createDynamicPermissionMatrix, X as deny, Y as anyOf, Z as denyAll, _ as publicReadAdminWrite, a as PermissionMatrixRegistry, at as scopeOf, b as requireOrgMembership, c as introspectModule, ct as evaluatePermissionDecision, d as authenticated, dt as RequireMandateOptions, et as requireOwnership, f as fullPublic, ft as requireAgentScope, g as publicRead, h as presets_d_exports, i as PermissionMatrixOptions, it as when, j as modeSatisfies, k as GrantResolution, l as introspectRegistry, lt as normalizeToDecision, m as permissionMatrix, mt as requireMandate, n as PermissionEntryType, nt as requireRoles, o as buildPermissionMatrix, ot as PermissionCheckReturn, p as ownerWithAdminBypass, pt as requireDPoP, q as allow, r as PermissionMatrix, rt as roles, s as introspectCheck, st as applyAuthorizationDecision, t as PermissionEntry, tt as requirePlatformRole, u as adminOnly, ut as RequireAgentScopeOptions, v as readOnly, w as requireTeamMembership, x as requireOrgRole, y as requireOrgInScope, z as explainAccess } from "../index-BtYoMip1.mjs";
4
+ import { $ as requireAuth, A as RequireGrantOptions, B as ConnectEventsOptions, C as requireServiceScope, D as GRANT_MODES, E as createRoleHierarchy, F as PermissionRequirement, G as createOrgPermissions, H as DynamicPermissionMatrixConfig, I as collectPublicSurface, J as allowPublic, K as allOf, L as describePermission, M as requireGrant, N as conjoinPolicyFilters, O as GrantMode, P as AccessExplanation, Q as not, R as describePermissionMap, S as requireScopeContext, T as RoleHierarchy, U as PermissionEventBus, V as DynamicPermissionMatrix, W as createDynamicPermissionMatrix, X as deny, Y as anyOf, Z as denyAll, _ as publicReadAdminWrite, a as PermissionMatrixRegistry, at as scopeOf, b as requireOrgMembership, c as introspectModule, ct as evaluatePermissionDecision, d as authenticated, dt as RequireMandateOptions, et as requireOwnership, f as fullPublic, ft as requireAgentScope, g as publicRead, h as presets_d_exports, i as PermissionMatrixOptions, it as when, j as modeSatisfies, k as GrantResolution, l as introspectRegistry, lt as normalizeToDecision, m as permissionMatrix, mt as requireMandate, n as PermissionEntryType, nt as requireRoles, o as buildPermissionMatrix, ot as PermissionCheckReturn, p as ownerWithAdminBypass, pt as requireDPoP, q as allow, r as PermissionMatrix, rt as roles, s as introspectCheck, st as applyAuthorizationDecision, t as PermissionEntry, tt as requirePlatformRole, u as adminOnly, ut as RequireAgentScopeOptions, v as readOnly, w as requireTeamMembership, x as requireOrgRole, y as requireOrgInScope, z as explainAccess } from "../index-BHdZD8zK.mjs";
5
5
  export { type AccessExplanation, type AuthorizationDecision, type ConnectEventsOptions, type DataPolicy, type DynamicPermissionMatrix, type DynamicPermissionMatrixConfig, type FieldPermission, type FieldPermissionMap, type FieldPermissionType, GRANT_MODES, type GrantMode, type GrantResolution, type PermissionCheck, type PermissionCheckReturn, type PermissionContext, type PermissionEntry, type PermissionEntryType, type PermissionEventBus, type PermissionMatrix, type PermissionMatrixOptions, type PermissionMatrixRegistry, type PermissionRequirement, type RequireAgentScopeOptions, type RequireGrantOptions, type RequireMandateOptions, type RoleHierarchy, type UserBase, adminOnly, allOf, allow, allowPublic, anyOf, applyAuthorizationDecision, applyFieldReadPermissions, applyFieldWritePermissions, authenticated, buildPermissionMatrix, collectPublicSurface, conjoinPolicyFilters, createDynamicPermissionMatrix, createOrgPermissions, createRoleHierarchy, deny, denyAll, describePermission, describePermissionMap, evaluatePermissionDecision, explainAccess, fields, fullPublic, getUserRoles, introspectCheck, introspectModule, introspectRegistry, modeSatisfies, normalizeRoles, normalizeToDecision, not, ownerWithAdminBypass, permissionMatrix, presets_d_exports as permissions, publicRead, publicReadAdminWrite, readOnly, requireAgentScope, requireAuth, requireDPoP, requireGrant, requireMandate, requireOrgInScope, requireOrgMembership, requireOrgRole, requireOwnership, requirePlatformRole, requireRoles, requireScopeContext, requireServiceScope, requireTeamMembership, resolveEffectiveRoles, roles, scopeOf, when };
@@ -1,6 +1,6 @@
1
- /*! @classytic/arc v2.38.0 | MIT | https://classytic.com */
2
- import { a as conjoinPolicyFilters, i as normalizeToDecision, r as evaluatePermissionDecision, t as applyAuthorizationDecision } from "../authorizationDecision-BP8GHtjc.mjs";
3
- import { n as getUserRoles, r as normalizeRoles } from "../userHelpers-CXySQFRg.mjs";
4
- import { a as resolveEffectiveRoles, i as fields, n as applyFieldWritePermissions, t as applyFieldReadPermissions } from "../fields-Cha2QCKH.mjs";
5
- import { A as requireAgentScope, B as requireAuth, C as createOrgPermissions, D as requireScopeContext, E as requireOrgRole, F as allowPublic, G as when, H as requirePlatformRole, I as anyOf, K as scopeOf, L as deny, M as requireMandate, N as allOf, O as requireServiceScope, P as allow, R as denyAll, S as createDynamicPermissionMatrix, T as requireOrgMembership, U as requireRoles, V as requireOwnership, W as roles, _ as requireGrant, a as adminOnly, b as describePermissionMap, c as ownerWithAdminBypass, d as publicRead, f as publicReadAdminWrite, g as modeSatisfies, h as GRANT_MODES, i as introspectRegistry, j as requireDPoP, k as requireTeamMembership, l as permissionMatrix, m as createRoleHierarchy, n as introspectCheck, o as authenticated, p as readOnly, r as introspectModule, s as fullPublic, t as buildPermissionMatrix, u as presets_exports, v as collectPublicSurface, w as requireOrgInScope, x as explainAccess, y as describePermission, z as not } from "../permissions-H7Zcb82Z.mjs";
1
+ /*! @classytic/arc v2.41.0 | MIT | https://classytic.com */
2
+ import { a as conjoinPolicyFilters, i as normalizeToDecision, r as evaluatePermissionDecision, t as applyAuthorizationDecision } from "../authorizationDecision-2YY_Kaj1.mjs";
3
+ import { n as getUserRoles, r as normalizeRoles } from "../userHelpers-DDMOZ_Pm.mjs";
4
+ import { a as resolveEffectiveRoles, i as fields, n as applyFieldWritePermissions, t as applyFieldReadPermissions } from "../fields-BTyPLHK0.mjs";
5
+ import { A as requireAgentScope, B as requireAuth, C as createOrgPermissions, D as requireScopeContext, E as requireOrgRole, F as allowPublic, G as when, H as requirePlatformRole, I as anyOf, K as scopeOf, L as deny, M as requireMandate, N as allOf, O as requireServiceScope, P as allow, R as denyAll, S as createDynamicPermissionMatrix, T as requireOrgMembership, U as requireRoles, V as requireOwnership, W as roles, _ as requireGrant, a as adminOnly, b as describePermissionMap, c as ownerWithAdminBypass, d as publicRead, f as publicReadAdminWrite, g as modeSatisfies, h as GRANT_MODES, i as introspectRegistry, j as requireDPoP, k as requireTeamMembership, l as permissionMatrix, m as createRoleHierarchy, n as introspectCheck, o as authenticated, p as readOnly, r as introspectModule, s as fullPublic, t as buildPermissionMatrix, u as presets_exports, v as collectPublicSurface, w as requireOrgInScope, x as explainAccess, y as describePermission, z as not } from "../permissions-DiHXy8Ck.mjs";
6
6
  export { GRANT_MODES, adminOnly, allOf, allow, allowPublic, anyOf, applyAuthorizationDecision, applyFieldReadPermissions, applyFieldWritePermissions, authenticated, buildPermissionMatrix, collectPublicSurface, conjoinPolicyFilters, createDynamicPermissionMatrix, createOrgPermissions, createRoleHierarchy, deny, denyAll, describePermission, describePermissionMap, evaluatePermissionDecision, explainAccess, fields, fullPublic, getUserRoles, introspectCheck, introspectModule, introspectRegistry, modeSatisfies, normalizeRoles, normalizeToDecision, not, ownerWithAdminBypass, permissionMatrix, presets_exports as permissions, publicRead, publicReadAdminWrite, readOnly, requireAgentScope, requireAuth, requireDPoP, requireGrant, requireMandate, requireOrgInScope, requireOrgMembership, requireOrgRole, requireOwnership, requirePlatformRole, requireRoles, requireScopeContext, requireServiceScope, requireTeamMembership, resolveEffectiveRoles, roles, scopeOf, when };
@@ -1,10 +1,11 @@
1
- /*! @classytic/arc v2.38.0 | MIT | https://classytic.com */
2
- import { t as __exportAll } from "./rolldown-runtime-Add2L50I.mjs";
1
+ /*! @classytic/arc v2.41.0 | MIT | https://classytic.com */
2
+ import { t as __exportAll } from "./rolldown-runtime-DjDuyglE.mjs";
3
3
  import { arcLog } from "./logger/index.mjs";
4
- import { a as conjoinPolicyFilters, i as normalizeToDecision } from "./authorizationDecision-BP8GHtjc.mjs";
5
- import { n as getUserRoles } from "./userHelpers-CXySQFRg.mjs";
6
- import { C as isService, S as isOrgInScope, a as getDPoPJkt, b as isElevated, d as getScopeContext, f as getScopeContextMap, g as getUserId, m as getTeamId, n as PUBLIC_SCOPE, o as getMandate, p as getServiceScopes, u as getRequestScope, v as hasOrgAccess, x as isMember } from "./types-BqLyyH0o.mjs";
7
- import { t as MemoryCacheStore } from "./memory-BiPVaCPg.mjs";
4
+ import { a as conjoinPolicyFilters, i as normalizeToDecision } from "./authorizationDecision-2YY_Kaj1.mjs";
5
+ import { n as getUserRoles } from "./userHelpers-DDMOZ_Pm.mjs";
6
+ import { C as isService, S as isOrgInScope, a as getDPoPJkt, b as isElevated, d as getScopeContext, f as getScopeContextMap, g as getUserId, m as getTeamId, n as PUBLIC_SCOPE, o as getMandate, p as getServiceScopes, u as getRequestScope, v as hasOrgAccess, x as isMember } from "./types-CDy3-zw1.mjs";
7
+ import { n as declareRuntimeCapability } from "./runtimeCapabilities-DSA_dH1_.mjs";
8
+ import { t as MemoryCacheStore } from "./memory-CpDZ9NPw.mjs";
8
9
  import { randomUUID } from "node:crypto";
9
10
  //#region src/permissions/context.ts
10
11
  /**
@@ -871,6 +872,11 @@ function createDynamicPermissionMatrix(config) {
871
872
  maxEntries: config.cache?.maxEntries ?? 1e3
872
873
  }) : void 0;
873
874
  const cacheStore = config.cacheStore ?? internalStore;
875
+ if (config.fastify && cacheStore) declareRuntimeCapability(config.fastify, {
876
+ subsystem: "permissions.dynamic-cache",
877
+ durability: internalStore ? "memory" : "shared",
878
+ detail: "internal MemoryCacheStore: a role change invalidates on this replica only"
879
+ });
874
880
  const trackedKeys = /* @__PURE__ */ new Set();
875
881
  const orgKeyIndex = /* @__PURE__ */ new Map();
876
882
  const maxTrackedKeys = config.cache?.maxEntries ?? 1e4;
@@ -1,5 +1,5 @@
1
- /*! @classytic/arc v2.38.0 | MIT | https://classytic.com */
2
- import { r as ForbiddenError } from "./errors-2ExmOgIJ.mjs";
1
+ /*! @classytic/arc v2.41.0 | MIT | https://classytic.com */
2
+ import { r as ForbiddenError } from "./errors-C_YhELhe.mjs";
3
3
  //#region src/pipeline/pipe.ts
4
4
  /**
5
5
  * Compose pipeline steps into an ordered array.
@@ -1,5 +1,5 @@
1
1
 
2
- import { Ct as PipelineStep, Fn as IControllerResponse, St as PipelineContext, _t as Guard, bt as OperationFilter, vt as Interceptor, wt as Transform, xt as PipelineConfig, yt as NextFunction } from "../index-B78WZom8.mjs";
2
+ import { Ct as PipelineStep, Fn as IControllerResponse, St as PipelineContext, _t as Guard, bt as OperationFilter, vt as Interceptor, wt as Transform, xt as PipelineConfig, yt as NextFunction } from "../index-DHbyPo5j.mjs";
3
3
  //#region src/pipeline/guard.d.ts
4
4
  interface GuardOptions {
5
5
  operations?: OperationFilter;
@@ -1,5 +1,5 @@
1
- /*! @classytic/arc v2.38.0 | MIT | https://classytic.com */
2
- import { n as pipe, t as executePipeline } from "../pipe-SunhEaZ6.mjs";
1
+ /*! @classytic/arc v2.41.0 | MIT | https://classytic.com */
2
+ import { n as pipe, t as executePipeline } from "../pipe-CBVmUJ-j.mjs";
3
3
  //#region src/pipeline/guard.ts
4
4
  /**
5
5
  * Create a named guard.
@@ -1,10 +1,10 @@
1
1
 
2
- import { t as AnyRecord } from "../base-C-NL2fTi.mjs";
3
- import { At as RouteDefinition, J as PresetHook, Q as MiddlewareConfig, et as RouteSchemaOptions } from "../index-B78WZom8.mjs";
4
- import { i as errorHandlerPlugin, n as ErrorMapper, r as defaultIsDuplicateKeyError, t as ErrorHandlerOptions } from "../errorHandler-DI5AN2b5.mjs";
5
- import { _ as HealthCheck, b as healthPlugin, f as ScheduleDefinition, g as schedulesPlugin, h as _default$8, m as SchedulesPluginOptions, p as ScheduleStats, v as HealthOptions, y as _default$3 } from "../types-BRU-Kd3t.mjs";
6
- import { a as arcCorePlugin, i as _default, n as ArcCorePluginOptions, r as PluginMeta, t as ArcCore } from "../fastify-augmentation-jYA2oHyL.mjs";
7
- import { _ as CachingRule, a as MetricsCollector, c as metricsPlugin, d as _default$6, f as realtimePlugin, g as CachingOptions, h as ssePlugin, i as MetricEntry, l as ChangeOperation, m as _default$9, n as _default$10, o as MetricsOptions, p as SSEOptions, r as versioningPlugin, s as _default$4, t as VersioningOptions, u as RealtimeOptions, v as _default$1, y as cachingPlugin } from "../versioning-B843jOYX.mjs";
2
+ import { t as AnyRecord } from "../base-CxrV1LmG.mjs";
3
+ import { At as RouteDefinition, J as PresetHook, Q as MiddlewareConfig, et as RouteSchemaOptions } from "../index-DHbyPo5j.mjs";
4
+ import { i as errorHandlerPlugin, n as ErrorMapper, r as defaultIsDuplicateKeyError, t as ErrorHandlerOptions } from "../errorHandler--4rSMMvq.mjs";
5
+ import { _ as HealthCheck, b as healthPlugin, f as ScheduleDefinition, g as schedulesPlugin, h as _default$8, m as SchedulesPluginOptions, p as ScheduleStats, v as HealthOptions, y as _default$3 } from "../types-DfVDvkdP.mjs";
6
+ import { a as arcCorePlugin, i as _default, n as ArcCorePluginOptions, r as PluginMeta, t as ArcCore } from "../fastify-augmentation-Cq2nHVaW.mjs";
7
+ import { C as gracefulShutdownPlugin, S as _default$2, _ as CachingRule, a as MetricsCollector, b as GracefulShutdownOptions, c as metricsPlugin, d as _default$6, f as realtimePlugin, g as CachingOptions, h as ssePlugin, i as MetricEntry, l as ChangeOperation, m as _default$9, n as _default$10, o as MetricsOptions, p as SSEOptions, r as versioningPlugin, s as _default$4, t as VersioningOptions, u as RealtimeOptions, v as _default$1, x as ShutdownState, y as cachingPlugin } from "../versioning-D6JIK8Tk.mjs";
8
8
  import { t as TracingOptions } from "../tracing-Dro5eH6j.mjs";
9
9
  import { PaginatedResult } from "@classytic/repo-core/pagination";
10
10
  import { FastifyInstance, FastifyPluginAsync } from "fastify";
@@ -59,36 +59,6 @@ interface ArcPlugin<TRootOpts extends AnyRecord = AnyRecord, TResourceOpts exten
59
59
  */
60
60
  declare function createPlugin<TRootOpts extends AnyRecord = AnyRecord, TResourceOpts extends AnyRecord = AnyRecord>(name: string, definition: CreatePluginDefinition<TRootOpts, TResourceOpts>): ArcPlugin<TRootOpts, TResourceOpts>;
61
61
  //#endregion
62
- //#region src/plugins/gracefulShutdown.d.ts
63
- interface GracefulShutdownOptions {
64
- /** Maximum time to wait for graceful shutdown in ms (default: 30000) */
65
- timeout?: number;
66
- /** Custom cleanup function called before exit */
67
- onShutdown?: () => Promise<void> | void;
68
- /** Signals to handle (default: ['SIGTERM', 'SIGINT']) */
69
- signals?: NodeJS.Signals[];
70
- /** Whether to log shutdown events (default: true) */
71
- logEvents?: boolean;
72
- /**
73
- * Called when shutdown times out or encounters an error.
74
- * Defaults to `process.exit(1)` — appropriate for production but dangerous in:
75
- * - **Tests**: kills the test runner. Pass `() => {}` or `() => { throw … }`.
76
- * - **Shared runtimes** (e.g., serverless): may kill unrelated handlers.
77
- *
78
- * @param reason - `'timeout'` if shutdown exceeded `timeout` ms,
79
- * `'error'` if `onShutdown` or `fastify.close()` threw.
80
- */
81
- onForceExit?: (reason: "timeout" | "error") => void;
82
- }
83
- declare const gracefulShutdownPlugin: FastifyPluginAsync<GracefulShutdownOptions>;
84
- declare module "fastify" {
85
- interface FastifyInstance {
86
- /** Trigger graceful shutdown manually */
87
- shutdown: () => Promise<void>;
88
- }
89
- }
90
- declare const _default$2: FastifyPluginAsync<GracefulShutdownOptions>;
91
- //#endregion
92
62
  //#region src/plugins/pressure.d.ts
93
63
  /**
94
64
  * One measurable source of load, normalised by whoever owns it.
@@ -253,4 +223,4 @@ declare function createRequestIdGenerator(opts?: Pick<RequestIdOptions, "header"
253
223
  declare const requestIdPlugin: FastifyPluginAsync<RequestIdOptions>;
254
224
  declare const _default$7: FastifyPluginAsync<RequestIdOptions>;
255
225
  //#endregion
256
- export { type ArcCore, type ArcCorePluginOptions, type ArcPlugin, type CachingOptions, type CachingRule, type ChangeOperation, type CreatePluginDefinition, type ErrorHandlerOptions, type ErrorMapper, type GracefulShutdownOptions, type HealthCheck, type HealthOptions, type MetricEntry, type MetricsCollector, type MetricsOptions, type PluginMeta, type PluginResourceResult, type PressureApi, type PressureOptions, type PressureSignal, type PressureSnapshot, type PressureState, type PressureThresholds, type RealtimeOptions, type RequestIdOptions, type SSEOptions, type ScheduleDefinition, type ScheduleStats, type SchedulesPluginOptions, type TracingOptions, type VersioningOptions, _default as arcCorePlugin, arcCorePlugin as arcCorePluginFn, _default$1 as cachingPlugin, cachingPlugin as cachingPluginFn, createPlugin, createRequestIdGenerator, defaultIsDuplicateKeyError, errorHandlerPlugin, errorHandlerPlugin as errorHandlerPluginFn, _default$2 as gracefulShutdownPlugin, gracefulShutdownPlugin as gracefulShutdownPluginFn, _default$3 as healthPlugin, healthPlugin as healthPluginFn, _default$4 as metricsPlugin, metricsPlugin as metricsPluginFn, _default$5 as pressurePlugin, pressurePlugin as pressurePluginFn, _default$6 as realtimePlugin, realtimePlugin as realtimePluginFn, replyHelpersPlugin, _default$7 as requestIdPlugin, requestIdPlugin as requestIdPluginFn, sanitizeRequestId, _default$8 as schedulesPlugin, schedulesPlugin as schedulesPluginFn, _default$9 as ssePlugin, ssePlugin as ssePluginFn, _default$10 as versioningPlugin, versioningPlugin as versioningPluginFn };
226
+ export { type ArcCore, type ArcCorePluginOptions, type ArcPlugin, type CachingOptions, type CachingRule, type ChangeOperation, type CreatePluginDefinition, type ErrorHandlerOptions, type ErrorMapper, type GracefulShutdownOptions, type HealthCheck, type HealthOptions, type MetricEntry, type MetricsCollector, type MetricsOptions, type PluginMeta, type PluginResourceResult, type PressureApi, type PressureOptions, type PressureSignal, type PressureSnapshot, type PressureState, type PressureThresholds, type RealtimeOptions, type RequestIdOptions, type SSEOptions, type ScheduleDefinition, type ScheduleStats, type SchedulesPluginOptions, type ShutdownState, type TracingOptions, type VersioningOptions, _default as arcCorePlugin, arcCorePlugin as arcCorePluginFn, _default$1 as cachingPlugin, cachingPlugin as cachingPluginFn, createPlugin, createRequestIdGenerator, defaultIsDuplicateKeyError, errorHandlerPlugin, errorHandlerPlugin as errorHandlerPluginFn, _default$2 as gracefulShutdownPlugin, gracefulShutdownPlugin as gracefulShutdownPluginFn, _default$3 as healthPlugin, healthPlugin as healthPluginFn, _default$4 as metricsPlugin, metricsPlugin as metricsPluginFn, _default$5 as pressurePlugin, pressurePlugin as pressurePluginFn, _default$6 as realtimePlugin, realtimePlugin as realtimePluginFn, replyHelpersPlugin, _default$7 as requestIdPlugin, requestIdPlugin as requestIdPluginFn, sanitizeRequestId, _default$8 as schedulesPlugin, schedulesPlugin as schedulesPluginFn, _default$9 as ssePlugin, ssePlugin as ssePluginFn, _default$10 as versioningPlugin, versioningPlugin as versioningPluginFn };