@graphorin/server 0.6.0 → 0.7.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 (182) hide show
  1. package/CHANGELOG.md +85 -0
  2. package/README.md +6 -6
  3. package/dist/app-audit-binding.d.ts +15 -0
  4. package/dist/app-audit-binding.d.ts.map +1 -0
  5. package/dist/app-audit-binding.js +136 -0
  6. package/dist/app-audit-binding.js.map +1 -0
  7. package/dist/app-daemons.d.ts +29 -0
  8. package/dist/app-daemons.d.ts.map +1 -0
  9. package/dist/app-daemons.js +27 -0
  10. package/dist/app-daemons.js.map +1 -0
  11. package/dist/app-lifecycle.js +272 -0
  12. package/dist/app-lifecycle.js.map +1 -0
  13. package/dist/app-metrics.js +79 -0
  14. package/dist/app-metrics.js.map +1 -0
  15. package/dist/app-middleware.js +92 -0
  16. package/dist/app-middleware.js.map +1 -0
  17. package/dist/app-routes.js +131 -0
  18. package/dist/app-routes.js.map +1 -0
  19. package/dist/app-ws.js +65 -0
  20. package/dist/app-ws.js.map +1 -0
  21. package/dist/app.d.ts +16 -16
  22. package/dist/app.d.ts.map +1 -1
  23. package/dist/app.js +40 -611
  24. package/dist/app.js.map +1 -1
  25. package/dist/commentary/built-in-patterns.d.ts +1 -1
  26. package/dist/commentary/built-in-patterns.js +1 -1
  27. package/dist/commentary/built-in-patterns.js.map +1 -1
  28. package/dist/config.d.ts +100 -1
  29. package/dist/config.d.ts.map +1 -1
  30. package/dist/config.js +30 -2
  31. package/dist/config.js.map +1 -1
  32. package/dist/health/checks.d.ts +15 -1
  33. package/dist/health/checks.d.ts.map +1 -1
  34. package/dist/health/checks.js +21 -0
  35. package/dist/health/checks.js.map +1 -1
  36. package/dist/health/routes.js +1 -1
  37. package/dist/index.d.ts +9 -4
  38. package/dist/index.d.ts.map +1 -1
  39. package/dist/index.js +22 -26
  40. package/dist/index.js.map +1 -1
  41. package/dist/internal/context.d.ts +2 -2
  42. package/dist/internal/wire-error.js +20 -0
  43. package/dist/internal/wire-error.js.map +1 -0
  44. package/dist/lifecycle/pre-bind.d.ts +1 -1
  45. package/dist/metrics/catalog.d.ts.map +1 -1
  46. package/dist/metrics/catalog.js.map +1 -1
  47. package/dist/metrics/tools-bridge.d.ts +15 -0
  48. package/dist/metrics/tools-bridge.d.ts.map +1 -0
  49. package/dist/metrics/tools-bridge.js +103 -0
  50. package/dist/metrics/tools-bridge.js.map +1 -0
  51. package/dist/middleware/audit.d.ts +1 -1
  52. package/dist/middleware/auth.js +1 -1
  53. package/dist/middleware/csrf.js +1 -1
  54. package/dist/middleware/index.js +1 -1
  55. package/dist/middleware/scope.d.ts.map +1 -1
  56. package/dist/middleware/scope.js +44 -4
  57. package/dist/middleware/scope.js.map +1 -1
  58. package/dist/package.js +6 -0
  59. package/dist/package.js.map +1 -0
  60. package/dist/registry/index.d.ts +33 -0
  61. package/dist/registry/index.d.ts.map +1 -1
  62. package/dist/registry/index.js.map +1 -1
  63. package/dist/replay/routes.d.ts +1 -1
  64. package/dist/replay/routes.js +2 -2
  65. package/dist/routes/agents.d.ts.map +1 -1
  66. package/dist/routes/agents.js +64 -18
  67. package/dist/routes/agents.js.map +1 -1
  68. package/dist/routes/auth.js +2 -2
  69. package/dist/routes/auth.js.map +1 -1
  70. package/dist/routes/sessions.js +5 -5
  71. package/dist/routes/sessions.js.map +1 -1
  72. package/dist/routes/tokens.d.ts +1 -1
  73. package/dist/routes/tokens.d.ts.map +1 -1
  74. package/dist/routes/tokens.js +21 -1
  75. package/dist/routes/tokens.js.map +1 -1
  76. package/dist/routes/workflows.d.ts.map +1 -1
  77. package/dist/routes/workflows.js +165 -19
  78. package/dist/routes/workflows.js.map +1 -1
  79. package/dist/runtime/retention.d.ts +105 -0
  80. package/dist/runtime/retention.d.ts.map +1 -0
  81. package/dist/runtime/retention.js +154 -0
  82. package/dist/runtime/retention.js.map +1 -0
  83. package/dist/runtime/run-state.d.ts +2 -0
  84. package/dist/runtime/run-state.d.ts.map +1 -1
  85. package/dist/runtime/run-state.js +34 -2
  86. package/dist/runtime/run-state.js.map +1 -1
  87. package/dist/sse/events.js +3 -4
  88. package/dist/sse/events.js.map +1 -1
  89. package/dist/tools-audit-bridge.d.ts +29 -0
  90. package/dist/tools-audit-bridge.d.ts.map +1 -0
  91. package/dist/tools-audit-bridge.js +103 -0
  92. package/dist/tools-audit-bridge.js.map +1 -0
  93. package/dist/workflows/timer-daemon.d.ts +69 -0
  94. package/dist/workflows/timer-daemon.d.ts.map +1 -0
  95. package/dist/workflows/timer-daemon.js +37 -0
  96. package/dist/workflows/timer-daemon.js.map +1 -0
  97. package/dist/ws/dispatcher.d.ts +1 -1
  98. package/dist/ws/dispatcher.d.ts.map +1 -1
  99. package/dist/ws/dispatcher.js +19 -12
  100. package/dist/ws/dispatcher.js.map +1 -1
  101. package/dist/ws/index.d.ts +2 -2
  102. package/dist/ws/index.js +3 -3
  103. package/dist/ws/replay-buffer.d.ts +35 -1
  104. package/dist/ws/replay-buffer.d.ts.map +1 -1
  105. package/dist/ws/replay-buffer.js +35 -3
  106. package/dist/ws/replay-buffer.js.map +1 -1
  107. package/dist/ws/upgrade.d.ts.map +1 -1
  108. package/dist/ws/upgrade.js +26 -19
  109. package/dist/ws/upgrade.js.map +1 -1
  110. package/package.json +31 -30
  111. package/src/app-audit-binding.ts +227 -0
  112. package/src/app-daemons.ts +73 -0
  113. package/src/app-lifecycle.ts +476 -0
  114. package/src/app-metrics.ts +144 -0
  115. package/src/app-middleware.ts +149 -0
  116. package/src/app-routes.ts +305 -0
  117. package/src/app-ws.ts +111 -0
  118. package/src/app.ts +317 -0
  119. package/src/commentary/audit-bridge.ts +135 -0
  120. package/src/commentary/built-in-patterns.ts +79 -0
  121. package/src/commentary/index.ts +32 -0
  122. package/src/commentary/sanitizer.ts +238 -0
  123. package/src/commentary/types.ts +130 -0
  124. package/src/config.ts +472 -0
  125. package/src/consolidator/daemon.ts +141 -0
  126. package/src/consolidator/index.ts +14 -0
  127. package/src/errors/index.ts +247 -0
  128. package/src/health/checks.ts +322 -0
  129. package/src/health/index.ts +34 -0
  130. package/src/health/routes.ts +154 -0
  131. package/src/index.ts +243 -0
  132. package/src/internal/context.ts +77 -0
  133. package/src/internal/ids.ts +17 -0
  134. package/src/internal/json.ts +47 -0
  135. package/src/internal/wire-error.ts +44 -0
  136. package/src/lifecycle/hooks.ts +66 -0
  137. package/src/lifecycle/index.ts +16 -0
  138. package/src/lifecycle/pre-bind.ts +138 -0
  139. package/src/metrics/catalog.ts +112 -0
  140. package/src/metrics/index.ts +12 -0
  141. package/src/metrics/registry.ts +337 -0
  142. package/src/metrics/tools-bridge.ts +124 -0
  143. package/src/middleware/audit.ts +114 -0
  144. package/src/middleware/auth.ts +195 -0
  145. package/src/middleware/cors.ts +72 -0
  146. package/src/middleware/csrf.ts +98 -0
  147. package/src/middleware/idempotency.ts +336 -0
  148. package/src/middleware/index.ts +38 -0
  149. package/src/middleware/rate-limit.ts +71 -0
  150. package/src/middleware/request-state.ts +79 -0
  151. package/src/middleware/scope.ts +161 -0
  152. package/src/registry/index.ts +278 -0
  153. package/src/replay/index.ts +14 -0
  154. package/src/replay/routes.ts +255 -0
  155. package/src/routes/agents.ts +363 -0
  156. package/src/routes/audit.ts +207 -0
  157. package/src/routes/auth.ts +80 -0
  158. package/src/routes/health.ts +42 -0
  159. package/src/routes/index.ts +16 -0
  160. package/src/routes/mcp.ts +97 -0
  161. package/src/routes/memory.ts +152 -0
  162. package/src/routes/sessions.ts +250 -0
  163. package/src/routes/skills.ts +91 -0
  164. package/src/routes/tokens.ts +166 -0
  165. package/src/routes/workflows.ts +616 -0
  166. package/src/runtime/retention.ts +284 -0
  167. package/src/runtime/run-state.ts +422 -0
  168. package/src/sse/events.ts +303 -0
  169. package/src/sse/index.ts +7 -0
  170. package/src/tools-audit-bridge.ts +120 -0
  171. package/src/triggers/daemon.ts +198 -0
  172. package/src/triggers/index.ts +16 -0
  173. package/src/triggers/routes.ts +139 -0
  174. package/src/workflows/timer-daemon.ts +102 -0
  175. package/src/ws/dispatcher.ts +537 -0
  176. package/src/ws/index.ts +45 -0
  177. package/src/ws/replay-buffer.ts +209 -0
  178. package/src/ws/subjects.ts +162 -0
  179. package/src/ws/ticket.ts +174 -0
  180. package/src/ws/upgrade.ts +507 -0
  181. package/dist/lifecycle/index.js +0 -3
  182. package/dist/routes/index.js +0 -12
@@ -1,5 +1,6 @@
1
1
  import { ConsolidatorDaemon } from "../consolidator/daemon.js";
2
2
  import { TriggersDaemon } from "../triggers/daemon.js";
3
+ import { WorkflowTimerDaemon } from "../workflows/timer-daemon.js";
3
4
  import { GraphorinSqliteStore } from "@graphorin/store-sqlite";
4
5
 
5
6
  //#region src/health/checks.d.ts
@@ -73,7 +74,18 @@ interface ReplayBufferCheck extends BaseHealthCheck {
73
74
  readonly subscriptions?: number;
74
75
  }
75
76
  /** @stable */
76
- type HealthCheck = StorageCheck | EmbedderCheck | SecretsCheck | EncryptionCheck | ConsolidatorCheck | TriggersCheck | ReplayBufferCheck;
77
+ type HealthCheck = StorageCheck | EmbedderCheck | SecretsCheck | EncryptionCheck | ConsolidatorCheck | TriggersCheck | WorkflowTimersCheck | ReplayBufferCheck;
78
+ /** W-032: durable-timer driver health. @stable */
79
+ interface WorkflowTimersCheck {
80
+ readonly status: HealthStatus;
81
+ readonly running: boolean;
82
+ readonly sweeps: number;
83
+ readonly fired: number;
84
+ readonly errors: number;
85
+ readonly lastSweepAt?: string;
86
+ readonly nextWakeAt?: string;
87
+ readonly message?: string;
88
+ }
77
89
  /** @stable */
78
90
  interface HealthChecks {
79
91
  readonly storage?: StorageCheck;
@@ -82,6 +94,7 @@ interface HealthChecks {
82
94
  readonly encryption?: EncryptionCheck;
83
95
  readonly consolidator?: ConsolidatorCheck;
84
96
  readonly triggers?: TriggersCheck;
97
+ readonly workflowTimers?: WorkflowTimersCheck;
85
98
  readonly replayBuffer?: ReplayBufferCheck;
86
99
  }
87
100
  /** @stable */
@@ -93,6 +106,7 @@ interface HealthSummary {
93
106
  interface HealthCheckOptions {
94
107
  readonly store?: GraphorinSqliteStore;
95
108
  readonly triggers?: TriggersDaemon;
109
+ readonly workflowTimers?: WorkflowTimerDaemon;
96
110
  readonly consolidator?: ConsolidatorDaemon;
97
111
  readonly replayBuffer?: ReplayBufferProbe;
98
112
  readonly secretsActive?: string;
@@ -1 +1 @@
1
- {"version":3,"file":"checks.d.ts","names":[],"sources":["../../src/health/checks.ts"],"sourcesContent":[],"mappings":";;;;;;AA2FA;AAOY,UA/EK,iBAAA,CA+EM;EACnB;EACA,SAAA,cAAA,EAAA,MAAA;EACA,SAAA,WAAA,CAAA,EAAA,MAAA;EACA,SAAA,aAAA,CAAA,EAAA,MAAA;;;AAGA,KA9EQ,YAAA,GA8ER,IAAA,GAAA,MAAA,GAAA,MAAA;;AAGa,KA9EL,YAAA,GA8EiB,IAAA,GAAA,UAAA,GAAA,SAAA;;;;;;;;AAOc,UA5E1B,eAAA,CA4E0B;EAI1B,SAAA,MAAA,EA/EE,YAgFA;EAKF,SAAA,OAAA,CAAA,EAAA,MAAkB;;;AAGT,UAnFT,YAAA,SAAqB,eAmFZ,CAAA;EACA,SAAA,YAAA,EAAA,MAAA;EAAiB,SAAA,kBAAA,EAAA,MAAA;EAiBrB,SAAA,gBAAa,CAAA,EAAA,MAAA;;;AAA+B,UA9FjD,aAAA,SAAsB,eA8F2B,CAAA;EAAO,SAAA,WAAA,EAAA,OAAA;EAuHzD,SAAM,KAAA,CAAA,EAAA,MAAS;;;UA/Md,YAAA,SAAqB;;;;UAKrB,eAAA,SAAwB;;;;;UAMxB,iBAAA,SAA0B;;;;;;;;;;;;UAa1B,aAAA,SAAsB;;;;;;;;UAStB,iBAAA,SAA0B;;;;;;KAO/B,WAAA,GACR,eACA,gBACA,eACA,kBACA,oBACA,gBACA;;UAGa,YAAA;qBACI;sBACC;qBACD;wBACG;0BACE;sBACJ;0BACI;;;UAIT,aAAA;mBACE;mBACA;;;UAIF,kBAAA;mBACE;sBACG;0BACI;0BACA;;;;;;;;;;;;;;iBAiBJ,aAAA,UAAuB,qBAAqB,QAAQ;;;;;;iBAuH1D,MAAA,SAAe,eAAe"}
1
+ {"version":3,"file":"checks.d.ts","names":[],"sources":["../../src/health/checks.ts"],"sourcesContent":[],"mappings":";;;;;;;AA4FA;AAOY,UA/EK,iBAAA,CA+EM;EACnB;EACA,SAAA,cAAA,EAAA,MAAA;EACA,SAAA,WAAA,CAAA,EAAA,MAAA;EACA,SAAA,aAAA,CAAA,EAAA,MAAA;;;AAGA,KA9EQ,YAAA,GA8ER,IAAA,GAAA,MAAA,GAAA,MAAA;;AACiB,KA5ET,YAAA,GA4ES,IAAA,GAAA,UAAA,GAAA,SAAA;AAGrB;AAYA;;;;;;AAMsB,UAxFL,eAAA,CAwFK;EACM,SAAA,MAAA,EAxFT,YAwFS;EACF,SAAA,OAAA,CAAA,EAAA,MAAA;;AAI1B;AAMiB,UA9FA,YAAA,SAAqB,eA8FH,CAAA;EAChB,SAAA,YAAA,EAAA,MAAA;EACG,SAAA,kBAAA,EAAA,MAAA;EACM,SAAA,gBAAA,CAAA,EAAA,MAAA;;;AAEe,UA5F1B,aAAA,SAAsB,eA4FI,CAAA;EAiBrB,SAAA,WAAa,EAAA,OAAA;EAAU,SAAA,KAAA,CAAA,EAAA,MAAA;;;AAA4B,UAvGxD,YAAA,SAAqB,eAuGmC,CAAA;EA+IzD,SAAM,WAAA,EAAS,MAAA;;;UAjPd,eAAA,SAAwB;;;;;UAMxB,iBAAA,SAA0B;;;;;;;;;;;;UAa1B,aAAA,SAAsB;;;;;;;;UAStB,iBAAA,SAA0B;;;;;;KAO/B,WAAA,GACR,eACA,gBACA,eACA,kBACA,oBACA,gBACA,sBACA;;UAGa,mBAAA;mBACE;;;;;;;;;;UAWF,YAAA;qBACI;sBACC;qBACD;wBACG;0BACE;sBACJ;4BACM;0BACF;;;UAIT,aAAA;mBACE;mBACA;;;UAIF,kBAAA;mBACE;sBACG;4BACM;0BACF;0BACA;;;;;;;;;;;;;;iBAiBJ,aAAA,UAAuB,qBAAqB,QAAQ;;;;;;iBA+I1D,MAAA,SAAe,eAAe"}
@@ -85,6 +85,27 @@ async function collectHealth(options) {
85
85
  message: err instanceof Error ? err.message : String(err)
86
86
  };
87
87
  }
88
+ if (options.workflowTimers !== void 0) try {
89
+ const status$1 = await options.workflowTimers.status();
90
+ checks.workflowTimers = {
91
+ status: status$1.errors > 0 ? "warn" : "ok",
92
+ running: status$1.running,
93
+ sweeps: status$1.sweeps,
94
+ fired: status$1.fired,
95
+ errors: status$1.errors,
96
+ ...status$1.lastSweepAt !== void 0 ? { lastSweepAt: status$1.lastSweepAt } : {},
97
+ ...status$1.nextWakeAt !== void 0 ? { nextWakeAt: status$1.nextWakeAt } : {}
98
+ };
99
+ } catch (err) {
100
+ checks.workflowTimers = {
101
+ status: "fail",
102
+ running: false,
103
+ sweeps: 0,
104
+ fired: 0,
105
+ errors: 0,
106
+ message: err instanceof Error ? err.message : String(err)
107
+ };
108
+ }
88
109
  if (options.replayBuffer !== void 0) {
89
110
  const probe = options.replayBuffer;
90
111
  checks.replayBuffer = {
@@ -1 +1 @@
1
- {"version":3,"file":"checks.js","names":["checks: {\n -readonly [K in keyof HealthChecks]?: HealthChecks[K];\n }","status","overall: HealthStatus","worst: HealthRollup"],"sources":["../../src/health/checks.ts"],"sourcesContent":["/**\n * Per-subsystem health checks aggregated by `/v1/health`. Every check\n * resolves to `'ok' | 'warn' | 'fail'`; the aggregator promotes the\n * worst status to the top-level rollup.\n *\n * The serialized shape is **flat**: each check carries its detail\n * fields directly on the same object as the `status` discriminator\n * - no nested `detail` wrapper - matching the documented response\n * contract exactly.\n *\n * @packageDocumentation\n */\n\nimport type { GraphorinSqliteStore } from '@graphorin/store-sqlite';\nimport { readWalSize } from '@graphorin/store-sqlite';\nimport type { ConsolidatorDaemon } from '../consolidator/daemon.js';\nimport type { TriggersDaemon } from '../triggers/daemon.js';\n\n/** @stable */\nexport interface ReplayBufferProbe {\n /** Total events buffered across all subjects. Aggregated by the caller. */\n readonly eventsBuffered: number;\n readonly subscribers?: number;\n readonly subscriptions?: number;\n}\n\n/** @stable */\nexport type HealthStatus = 'ok' | 'warn' | 'fail';\n\n/** @stable */\nexport type HealthRollup = 'ok' | 'degraded' | 'failing';\n\n/**\n * Common discriminator carried on every per-subsystem check entry.\n * Concrete shapes extend this with subsystem-specific fields per the\n * documented contract.\n *\n * @stable\n */\nexport interface BaseHealthCheck {\n readonly status: HealthStatus;\n readonly message?: string;\n}\n\n/** @stable */\nexport interface StorageCheck extends BaseHealthCheck {\n readonly walSizeBytes: number;\n readonly warnThresholdBytes: number;\n readonly lastCheckpointAt?: string;\n}\n\n/** @stable */\nexport interface EmbedderCheck extends BaseHealthCheck {\n readonly modelLoaded: boolean;\n readonly model?: string;\n}\n\n/** @stable */\nexport interface SecretsCheck extends BaseHealthCheck {\n readonly activeStore: string;\n}\n\n/** @stable */\nexport interface EncryptionCheck extends BaseHealthCheck {\n readonly enabled: boolean;\n readonly peerDepInstalled: boolean;\n}\n\n/** @stable */\nexport interface ConsolidatorCheck extends BaseHealthCheck {\n readonly tier: string;\n readonly running: boolean;\n readonly paused: boolean;\n readonly queueDepth: number;\n readonly dlqSize: number;\n readonly budgetRemaining: {\n readonly tokens: number;\n readonly costUsd: number;\n };\n}\n\n/** @stable */\nexport interface TriggersCheck extends BaseHealthCheck {\n readonly running: boolean;\n readonly active: number;\n readonly disabled: number;\n readonly deferred: number;\n readonly lastFireAt?: string;\n}\n\n/** @stable */\nexport interface ReplayBufferCheck extends BaseHealthCheck {\n readonly eventsBuffered: number;\n readonly subscribers?: number;\n readonly subscriptions?: number;\n}\n\n/** @stable */\nexport type HealthCheck =\n | StorageCheck\n | EmbedderCheck\n | SecretsCheck\n | EncryptionCheck\n | ConsolidatorCheck\n | TriggersCheck\n | ReplayBufferCheck;\n\n/** @stable */\nexport interface HealthChecks {\n readonly storage?: StorageCheck;\n readonly embedder?: EmbedderCheck;\n readonly secrets?: SecretsCheck;\n readonly encryption?: EncryptionCheck;\n readonly consolidator?: ConsolidatorCheck;\n readonly triggers?: TriggersCheck;\n readonly replayBuffer?: ReplayBufferCheck;\n}\n\n/** @stable */\nexport interface HealthSummary {\n readonly status: HealthRollup;\n readonly checks: HealthChecks;\n}\n\n/** @stable */\nexport interface HealthCheckOptions {\n readonly store?: GraphorinSqliteStore;\n readonly triggers?: TriggersDaemon;\n readonly consolidator?: ConsolidatorDaemon;\n readonly replayBuffer?: ReplayBufferProbe;\n readonly secretsActive?: string;\n readonly encryptionEnabled?: boolean;\n readonly cipherPeerInstalled?: boolean;\n readonly embedderModel?: string;\n readonly embedderLoaded?: boolean;\n /** Highest acceptable WAL size in bytes before warning. Default 50 MB. */\n readonly walWarnThresholdBytes?: number;\n}\n\nconst DEFAULT_WAL_WARN_THRESHOLD_BYTES = 50 * 1024 * 1024;\n\n/**\n * Build the aggregate health summary from runtime probes.\n *\n * @stable\n */\nexport async function collectHealth(options: HealthCheckOptions): Promise<HealthSummary> {\n const checks: {\n -readonly [K in keyof HealthChecks]?: HealthChecks[K];\n } = {};\n\n if (options.store !== undefined) {\n const walSize = readWalSizeSafely(options.store);\n const threshold = options.walWarnThresholdBytes ?? DEFAULT_WAL_WARN_THRESHOLD_BYTES;\n const status: HealthStatus = walSize > threshold ? 'warn' : 'ok';\n checks.storage = {\n status,\n walSizeBytes: walSize,\n warnThresholdBytes: threshold,\n };\n }\n\n if (options.embedderLoaded !== undefined) {\n checks.embedder = {\n status: options.embedderLoaded ? 'ok' : 'warn',\n modelLoaded: options.embedderLoaded,\n ...(options.embedderModel !== undefined ? { model: options.embedderModel } : {}),\n };\n }\n\n if (options.secretsActive !== undefined) {\n checks.secrets = {\n status: 'ok',\n activeStore: options.secretsActive,\n };\n }\n\n if (options.encryptionEnabled !== undefined) {\n // IP-1: a server that is serving this health endpoint with\n // encryption enabled has already opened the store WITH its key at\n // boot (createServer threads the resolved passphrase into\n // createSqliteStore and fails fast otherwise) - that successful\n // keyed open is the factual basis of this check. 'fail' is\n // reserved for an explicit negative cipher-peer probe; the old\n // default blamed a missing peer dep on every encrypted boot.\n const peerDepInstalled = options.cipherPeerInstalled ?? true;\n checks.encryption = {\n status: options.encryptionEnabled && peerDepInstalled === false ? 'fail' : 'ok',\n enabled: options.encryptionEnabled,\n peerDepInstalled,\n };\n }\n\n if (options.consolidator !== undefined) {\n try {\n const status = await options.consolidator.status();\n const overall: HealthStatus = status.dlqSize > 0 ? 'warn' : 'ok';\n checks.consolidator = {\n status: status.paused ? 'warn' : overall,\n tier: status.tier,\n running: status.running,\n paused: status.paused,\n queueDepth: status.queueDepth,\n dlqSize: status.dlqSize,\n budgetRemaining: {\n tokens: status.budget.tokensRemaining,\n costUsd: status.budget.costRemaining,\n },\n };\n } catch (err) {\n checks.consolidator = {\n status: 'fail',\n tier: 'unknown',\n running: false,\n paused: false,\n queueDepth: 0,\n dlqSize: 0,\n budgetRemaining: { tokens: 0, costUsd: 0 },\n message: err instanceof Error ? err.message : String(err),\n };\n }\n }\n\n if (options.triggers !== undefined) {\n try {\n const status = await options.triggers.status();\n checks.triggers = {\n status: 'ok',\n running: status.running,\n active: status.active,\n disabled: status.disabled,\n deferred: status.deferred,\n ...(status.lastFireAt !== undefined ? { lastFireAt: status.lastFireAt } : {}),\n };\n } catch (err) {\n checks.triggers = {\n status: 'fail',\n running: false,\n active: 0,\n disabled: 0,\n deferred: 0,\n message: err instanceof Error ? err.message : String(err),\n };\n }\n }\n\n if (options.replayBuffer !== undefined) {\n const probe = options.replayBuffer;\n checks.replayBuffer = {\n status: 'ok',\n eventsBuffered: probe.eventsBuffered,\n ...(probe.subscribers !== undefined ? { subscribers: probe.subscribers } : {}),\n ...(probe.subscriptions !== undefined ? { subscriptions: probe.subscriptions } : {}),\n };\n }\n\n const status = rollup(checks);\n return Object.freeze({ status, checks: Object.freeze(checks) as HealthChecks });\n}\n\n/**\n * Promote the worst per-check status to the rollup label.\n *\n * @stable\n */\nexport function rollup(checks: HealthChecks): HealthRollup {\n let worst: HealthRollup = 'ok';\n for (const value of Object.values(checks)) {\n if (value === undefined) continue;\n if (value.status === 'fail') return 'failing';\n if (value.status === 'warn') worst = 'degraded';\n }\n return worst;\n}\n\nfunction readWalSizeSafely(store: GraphorinSqliteStore): number {\n try {\n return readWalSize(store.connection);\n } catch {\n return 0;\n }\n}\n"],"mappings":";;;AA2IA,MAAM,mCAAmC,KAAK,OAAO;;;;;;AAOrD,eAAsB,cAAc,SAAqD;CACvF,MAAMA,SAEF,EAAE;AAEN,KAAI,QAAQ,UAAU,QAAW;EAC/B,MAAM,UAAU,kBAAkB,QAAQ,MAAM;EAChD,MAAM,YAAY,QAAQ,yBAAyB;AAEnD,SAAO,UAAU;GACf,QAF2B,UAAU,YAAY,SAAS;GAG1D,cAAc;GACd,oBAAoB;GACrB;;AAGH,KAAI,QAAQ,mBAAmB,OAC7B,QAAO,WAAW;EAChB,QAAQ,QAAQ,iBAAiB,OAAO;EACxC,aAAa,QAAQ;EACrB,GAAI,QAAQ,kBAAkB,SAAY,EAAE,OAAO,QAAQ,eAAe,GAAG,EAAE;EAChF;AAGH,KAAI,QAAQ,kBAAkB,OAC5B,QAAO,UAAU;EACf,QAAQ;EACR,aAAa,QAAQ;EACtB;AAGH,KAAI,QAAQ,sBAAsB,QAAW;EAQ3C,MAAM,mBAAmB,QAAQ,uBAAuB;AACxD,SAAO,aAAa;GAClB,QAAQ,QAAQ,qBAAqB,qBAAqB,QAAQ,SAAS;GAC3E,SAAS,QAAQ;GACjB;GACD;;AAGH,KAAI,QAAQ,iBAAiB,OAC3B,KAAI;EACF,MAAMC,WAAS,MAAM,QAAQ,aAAa,QAAQ;EAClD,MAAMC,UAAwBD,SAAO,UAAU,IAAI,SAAS;AAC5D,SAAO,eAAe;GACpB,QAAQA,SAAO,SAAS,SAAS;GACjC,MAAMA,SAAO;GACb,SAASA,SAAO;GAChB,QAAQA,SAAO;GACf,YAAYA,SAAO;GACnB,SAASA,SAAO;GAChB,iBAAiB;IACf,QAAQA,SAAO,OAAO;IACtB,SAASA,SAAO,OAAO;IACxB;GACF;UACM,KAAK;AACZ,SAAO,eAAe;GACpB,QAAQ;GACR,MAAM;GACN,SAAS;GACT,QAAQ;GACR,YAAY;GACZ,SAAS;GACT,iBAAiB;IAAE,QAAQ;IAAG,SAAS;IAAG;GAC1C,SAAS,eAAe,QAAQ,IAAI,UAAU,OAAO,IAAI;GAC1D;;AAIL,KAAI,QAAQ,aAAa,OACvB,KAAI;EACF,MAAMA,WAAS,MAAM,QAAQ,SAAS,QAAQ;AAC9C,SAAO,WAAW;GAChB,QAAQ;GACR,SAASA,SAAO;GAChB,QAAQA,SAAO;GACf,UAAUA,SAAO;GACjB,UAAUA,SAAO;GACjB,GAAIA,SAAO,eAAe,SAAY,EAAE,YAAYA,SAAO,YAAY,GAAG,EAAE;GAC7E;UACM,KAAK;AACZ,SAAO,WAAW;GAChB,QAAQ;GACR,SAAS;GACT,QAAQ;GACR,UAAU;GACV,UAAU;GACV,SAAS,eAAe,QAAQ,IAAI,UAAU,OAAO,IAAI;GAC1D;;AAIL,KAAI,QAAQ,iBAAiB,QAAW;EACtC,MAAM,QAAQ,QAAQ;AACtB,SAAO,eAAe;GACpB,QAAQ;GACR,gBAAgB,MAAM;GACtB,GAAI,MAAM,gBAAgB,SAAY,EAAE,aAAa,MAAM,aAAa,GAAG,EAAE;GAC7E,GAAI,MAAM,kBAAkB,SAAY,EAAE,eAAe,MAAM,eAAe,GAAG,EAAE;GACpF;;CAGH,MAAM,SAAS,OAAO,OAAO;AAC7B,QAAO,OAAO,OAAO;EAAE;EAAQ,QAAQ,OAAO,OAAO,OAAO;EAAkB,CAAC;;;;;;;AAQjF,SAAgB,OAAO,QAAoC;CACzD,IAAIE,QAAsB;AAC1B,MAAK,MAAM,SAAS,OAAO,OAAO,OAAO,EAAE;AACzC,MAAI,UAAU,OAAW;AACzB,MAAI,MAAM,WAAW,OAAQ,QAAO;AACpC,MAAI,MAAM,WAAW,OAAQ,SAAQ;;AAEvC,QAAO;;AAGT,SAAS,kBAAkB,OAAqC;AAC9D,KAAI;AACF,SAAO,YAAY,MAAM,WAAW;SAC9B;AACN,SAAO"}
1
+ {"version":3,"file":"checks.js","names":["checks: {\n -readonly [K in keyof HealthChecks]?: HealthChecks[K];\n }","status","overall: HealthStatus","worst: HealthRollup"],"sources":["../../src/health/checks.ts"],"sourcesContent":["/**\n * Per-subsystem health checks aggregated by `/v1/health`. Every check\n * resolves to `'ok' | 'warn' | 'fail'`; the aggregator promotes the\n * worst status to the top-level rollup.\n *\n * The serialized shape is **flat**: each check carries its detail\n * fields directly on the same object as the `status` discriminator\n * - no nested `detail` wrapper - matching the documented response\n * contract exactly.\n *\n * @packageDocumentation\n */\n\nimport type { GraphorinSqliteStore } from '@graphorin/store-sqlite';\nimport { readWalSize } from '@graphorin/store-sqlite';\nimport type { ConsolidatorDaemon } from '../consolidator/daemon.js';\nimport type { TriggersDaemon } from '../triggers/daemon.js';\nimport type { WorkflowTimerDaemon } from '../workflows/timer-daemon.js';\n\n/** @stable */\nexport interface ReplayBufferProbe {\n /** Total events buffered across all subjects. Aggregated by the caller. */\n readonly eventsBuffered: number;\n readonly subscribers?: number;\n readonly subscriptions?: number;\n}\n\n/** @stable */\nexport type HealthStatus = 'ok' | 'warn' | 'fail';\n\n/** @stable */\nexport type HealthRollup = 'ok' | 'degraded' | 'failing';\n\n/**\n * Common discriminator carried on every per-subsystem check entry.\n * Concrete shapes extend this with subsystem-specific fields per the\n * documented contract.\n *\n * @stable\n */\nexport interface BaseHealthCheck {\n readonly status: HealthStatus;\n readonly message?: string;\n}\n\n/** @stable */\nexport interface StorageCheck extends BaseHealthCheck {\n readonly walSizeBytes: number;\n readonly warnThresholdBytes: number;\n readonly lastCheckpointAt?: string;\n}\n\n/** @stable */\nexport interface EmbedderCheck extends BaseHealthCheck {\n readonly modelLoaded: boolean;\n readonly model?: string;\n}\n\n/** @stable */\nexport interface SecretsCheck extends BaseHealthCheck {\n readonly activeStore: string;\n}\n\n/** @stable */\nexport interface EncryptionCheck extends BaseHealthCheck {\n readonly enabled: boolean;\n readonly peerDepInstalled: boolean;\n}\n\n/** @stable */\nexport interface ConsolidatorCheck extends BaseHealthCheck {\n readonly tier: string;\n readonly running: boolean;\n readonly paused: boolean;\n readonly queueDepth: number;\n readonly dlqSize: number;\n readonly budgetRemaining: {\n readonly tokens: number;\n readonly costUsd: number;\n };\n}\n\n/** @stable */\nexport interface TriggersCheck extends BaseHealthCheck {\n readonly running: boolean;\n readonly active: number;\n readonly disabled: number;\n readonly deferred: number;\n readonly lastFireAt?: string;\n}\n\n/** @stable */\nexport interface ReplayBufferCheck extends BaseHealthCheck {\n readonly eventsBuffered: number;\n readonly subscribers?: number;\n readonly subscriptions?: number;\n}\n\n/** @stable */\nexport type HealthCheck =\n | StorageCheck\n | EmbedderCheck\n | SecretsCheck\n | EncryptionCheck\n | ConsolidatorCheck\n | TriggersCheck\n | WorkflowTimersCheck\n | ReplayBufferCheck;\n\n/** W-032: durable-timer driver health. @stable */\nexport interface WorkflowTimersCheck {\n readonly status: HealthStatus;\n readonly running: boolean;\n readonly sweeps: number;\n readonly fired: number;\n readonly errors: number;\n readonly lastSweepAt?: string;\n readonly nextWakeAt?: string;\n readonly message?: string;\n}\n\n/** @stable */\nexport interface HealthChecks {\n readonly storage?: StorageCheck;\n readonly embedder?: EmbedderCheck;\n readonly secrets?: SecretsCheck;\n readonly encryption?: EncryptionCheck;\n readonly consolidator?: ConsolidatorCheck;\n readonly triggers?: TriggersCheck;\n readonly workflowTimers?: WorkflowTimersCheck;\n readonly replayBuffer?: ReplayBufferCheck;\n}\n\n/** @stable */\nexport interface HealthSummary {\n readonly status: HealthRollup;\n readonly checks: HealthChecks;\n}\n\n/** @stable */\nexport interface HealthCheckOptions {\n readonly store?: GraphorinSqliteStore;\n readonly triggers?: TriggersDaemon;\n readonly workflowTimers?: WorkflowTimerDaemon;\n readonly consolidator?: ConsolidatorDaemon;\n readonly replayBuffer?: ReplayBufferProbe;\n readonly secretsActive?: string;\n readonly encryptionEnabled?: boolean;\n readonly cipherPeerInstalled?: boolean;\n readonly embedderModel?: string;\n readonly embedderLoaded?: boolean;\n /** Highest acceptable WAL size in bytes before warning. Default 50 MB. */\n readonly walWarnThresholdBytes?: number;\n}\n\nconst DEFAULT_WAL_WARN_THRESHOLD_BYTES = 50 * 1024 * 1024;\n\n/**\n * Build the aggregate health summary from runtime probes.\n *\n * @stable\n */\nexport async function collectHealth(options: HealthCheckOptions): Promise<HealthSummary> {\n const checks: {\n -readonly [K in keyof HealthChecks]?: HealthChecks[K];\n } = {};\n\n if (options.store !== undefined) {\n const walSize = readWalSizeSafely(options.store);\n const threshold = options.walWarnThresholdBytes ?? DEFAULT_WAL_WARN_THRESHOLD_BYTES;\n const status: HealthStatus = walSize > threshold ? 'warn' : 'ok';\n checks.storage = {\n status,\n walSizeBytes: walSize,\n warnThresholdBytes: threshold,\n };\n }\n\n if (options.embedderLoaded !== undefined) {\n checks.embedder = {\n status: options.embedderLoaded ? 'ok' : 'warn',\n modelLoaded: options.embedderLoaded,\n ...(options.embedderModel !== undefined ? { model: options.embedderModel } : {}),\n };\n }\n\n if (options.secretsActive !== undefined) {\n checks.secrets = {\n status: 'ok',\n activeStore: options.secretsActive,\n };\n }\n\n if (options.encryptionEnabled !== undefined) {\n // IP-1: a server that is serving this health endpoint with\n // encryption enabled has already opened the store WITH its key at\n // boot (createServer threads the resolved passphrase into\n // createSqliteStore and fails fast otherwise) - that successful\n // keyed open is the factual basis of this check. 'fail' is\n // reserved for an explicit negative cipher-peer probe; the old\n // default blamed a missing peer dep on every encrypted boot.\n const peerDepInstalled = options.cipherPeerInstalled ?? true;\n checks.encryption = {\n status: options.encryptionEnabled && peerDepInstalled === false ? 'fail' : 'ok',\n enabled: options.encryptionEnabled,\n peerDepInstalled,\n };\n }\n\n if (options.consolidator !== undefined) {\n try {\n const status = await options.consolidator.status();\n const overall: HealthStatus = status.dlqSize > 0 ? 'warn' : 'ok';\n checks.consolidator = {\n status: status.paused ? 'warn' : overall,\n tier: status.tier,\n running: status.running,\n paused: status.paused,\n queueDepth: status.queueDepth,\n dlqSize: status.dlqSize,\n budgetRemaining: {\n tokens: status.budget.tokensRemaining,\n costUsd: status.budget.costRemaining,\n },\n };\n } catch (err) {\n checks.consolidator = {\n status: 'fail',\n tier: 'unknown',\n running: false,\n paused: false,\n queueDepth: 0,\n dlqSize: 0,\n budgetRemaining: { tokens: 0, costUsd: 0 },\n message: err instanceof Error ? err.message : String(err),\n };\n }\n }\n\n if (options.triggers !== undefined) {\n try {\n const status = await options.triggers.status();\n checks.triggers = {\n status: 'ok',\n running: status.running,\n active: status.active,\n disabled: status.disabled,\n deferred: status.deferred,\n ...(status.lastFireAt !== undefined ? { lastFireAt: status.lastFireAt } : {}),\n };\n } catch (err) {\n checks.triggers = {\n status: 'fail',\n running: false,\n active: 0,\n disabled: 0,\n deferred: 0,\n message: err instanceof Error ? err.message : String(err),\n };\n }\n }\n\n if (options.workflowTimers !== undefined) {\n try {\n const status = await options.workflowTimers.status();\n checks.workflowTimers = {\n status: status.errors > 0 ? 'warn' : 'ok',\n running: status.running,\n sweeps: status.sweeps,\n fired: status.fired,\n errors: status.errors,\n ...(status.lastSweepAt !== undefined ? { lastSweepAt: status.lastSweepAt } : {}),\n ...(status.nextWakeAt !== undefined ? { nextWakeAt: status.nextWakeAt } : {}),\n };\n } catch (err) {\n checks.workflowTimers = {\n status: 'fail',\n running: false,\n sweeps: 0,\n fired: 0,\n errors: 0,\n message: err instanceof Error ? err.message : String(err),\n };\n }\n }\n\n if (options.replayBuffer !== undefined) {\n const probe = options.replayBuffer;\n checks.replayBuffer = {\n status: 'ok',\n eventsBuffered: probe.eventsBuffered,\n ...(probe.subscribers !== undefined ? { subscribers: probe.subscribers } : {}),\n ...(probe.subscriptions !== undefined ? { subscriptions: probe.subscriptions } : {}),\n };\n }\n\n const status = rollup(checks);\n return Object.freeze({ status, checks: Object.freeze(checks) as HealthChecks });\n}\n\n/**\n * Promote the worst per-check status to the rollup label.\n *\n * @stable\n */\nexport function rollup(checks: HealthChecks): HealthRollup {\n let worst: HealthRollup = 'ok';\n for (const value of Object.values(checks)) {\n if (value === undefined) continue;\n if (value.status === 'fail') return 'failing';\n if (value.status === 'warn') worst = 'degraded';\n }\n return worst;\n}\n\nfunction readWalSizeSafely(store: GraphorinSqliteStore): number {\n try {\n return readWalSize(store.connection);\n } catch {\n return 0;\n }\n}\n"],"mappings":";;;AA2JA,MAAM,mCAAmC,KAAK,OAAO;;;;;;AAOrD,eAAsB,cAAc,SAAqD;CACvF,MAAMA,SAEF,EAAE;AAEN,KAAI,QAAQ,UAAU,QAAW;EAC/B,MAAM,UAAU,kBAAkB,QAAQ,MAAM;EAChD,MAAM,YAAY,QAAQ,yBAAyB;AAEnD,SAAO,UAAU;GACf,QAF2B,UAAU,YAAY,SAAS;GAG1D,cAAc;GACd,oBAAoB;GACrB;;AAGH,KAAI,QAAQ,mBAAmB,OAC7B,QAAO,WAAW;EAChB,QAAQ,QAAQ,iBAAiB,OAAO;EACxC,aAAa,QAAQ;EACrB,GAAI,QAAQ,kBAAkB,SAAY,EAAE,OAAO,QAAQ,eAAe,GAAG,EAAE;EAChF;AAGH,KAAI,QAAQ,kBAAkB,OAC5B,QAAO,UAAU;EACf,QAAQ;EACR,aAAa,QAAQ;EACtB;AAGH,KAAI,QAAQ,sBAAsB,QAAW;EAQ3C,MAAM,mBAAmB,QAAQ,uBAAuB;AACxD,SAAO,aAAa;GAClB,QAAQ,QAAQ,qBAAqB,qBAAqB,QAAQ,SAAS;GAC3E,SAAS,QAAQ;GACjB;GACD;;AAGH,KAAI,QAAQ,iBAAiB,OAC3B,KAAI;EACF,MAAMC,WAAS,MAAM,QAAQ,aAAa,QAAQ;EAClD,MAAMC,UAAwBD,SAAO,UAAU,IAAI,SAAS;AAC5D,SAAO,eAAe;GACpB,QAAQA,SAAO,SAAS,SAAS;GACjC,MAAMA,SAAO;GACb,SAASA,SAAO;GAChB,QAAQA,SAAO;GACf,YAAYA,SAAO;GACnB,SAASA,SAAO;GAChB,iBAAiB;IACf,QAAQA,SAAO,OAAO;IACtB,SAASA,SAAO,OAAO;IACxB;GACF;UACM,KAAK;AACZ,SAAO,eAAe;GACpB,QAAQ;GACR,MAAM;GACN,SAAS;GACT,QAAQ;GACR,YAAY;GACZ,SAAS;GACT,iBAAiB;IAAE,QAAQ;IAAG,SAAS;IAAG;GAC1C,SAAS,eAAe,QAAQ,IAAI,UAAU,OAAO,IAAI;GAC1D;;AAIL,KAAI,QAAQ,aAAa,OACvB,KAAI;EACF,MAAMA,WAAS,MAAM,QAAQ,SAAS,QAAQ;AAC9C,SAAO,WAAW;GAChB,QAAQ;GACR,SAASA,SAAO;GAChB,QAAQA,SAAO;GACf,UAAUA,SAAO;GACjB,UAAUA,SAAO;GACjB,GAAIA,SAAO,eAAe,SAAY,EAAE,YAAYA,SAAO,YAAY,GAAG,EAAE;GAC7E;UACM,KAAK;AACZ,SAAO,WAAW;GAChB,QAAQ;GACR,SAAS;GACT,QAAQ;GACR,UAAU;GACV,UAAU;GACV,SAAS,eAAe,QAAQ,IAAI,UAAU,OAAO,IAAI;GAC1D;;AAIL,KAAI,QAAQ,mBAAmB,OAC7B,KAAI;EACF,MAAMA,WAAS,MAAM,QAAQ,eAAe,QAAQ;AACpD,SAAO,iBAAiB;GACtB,QAAQA,SAAO,SAAS,IAAI,SAAS;GACrC,SAASA,SAAO;GAChB,QAAQA,SAAO;GACf,OAAOA,SAAO;GACd,QAAQA,SAAO;GACf,GAAIA,SAAO,gBAAgB,SAAY,EAAE,aAAaA,SAAO,aAAa,GAAG,EAAE;GAC/E,GAAIA,SAAO,eAAe,SAAY,EAAE,YAAYA,SAAO,YAAY,GAAG,EAAE;GAC7E;UACM,KAAK;AACZ,SAAO,iBAAiB;GACtB,QAAQ;GACR,SAAS;GACT,QAAQ;GACR,OAAO;GACP,QAAQ;GACR,SAAS,eAAe,QAAQ,IAAI,UAAU,OAAO,IAAI;GAC1D;;AAIL,KAAI,QAAQ,iBAAiB,QAAW;EACtC,MAAM,QAAQ,QAAQ;AACtB,SAAO,eAAe;GACpB,QAAQ;GACR,gBAAgB,MAAM;GACtB,GAAI,MAAM,gBAAgB,SAAY,EAAE,aAAa,MAAM,aAAa,GAAG,EAAE;GAC7E,GAAI,MAAM,kBAAkB,SAAY,EAAE,eAAe,MAAM,eAAe,GAAG,EAAE;GACpF;;CAGH,MAAM,SAAS,OAAO,OAAO;AAC7B,QAAO,OAAO,OAAO;EAAE;EAAQ,QAAQ,OAAO,OAAO,OAAO;EAAkB,CAAC;;;;;;;AAQjF,SAAgB,OAAO,QAAoC;CACzD,IAAIE,QAAsB;AAC1B,MAAK,MAAM,SAAS,OAAO,OAAO,OAAO,EAAE;AACzC,MAAI,UAAU,OAAW;AACzB,MAAI,MAAM,WAAW,OAAQ,QAAO;AACpC,MAAI,MAAM,WAAW,OAAQ,SAAQ;;AAEvC,QAAO;;AAGT,SAAS,kBAAkB,OAAqC;AAC9D,KAAI;AACF,SAAO,YAAY,MAAM,WAAW;SAC9B;AACN,SAAO"}
@@ -1,5 +1,5 @@
1
- import { collectHealth } from "./checks.js";
2
1
  import { createScopeMiddleware } from "../middleware/scope.js";
2
+ import { collectHealth } from "./checks.js";
3
3
  import { Hono } from "hono";
4
4
  import { getSecretsStoreStatus } from "@graphorin/security/secrets";
5
5
 
package/dist/index.d.ts CHANGED
@@ -7,11 +7,13 @@ import { ConsolidatorDaemon, ConsolidatorLike, ConsolidatorStatusLike, CreateCon
7
7
  import "./consolidator/index.js";
8
8
  import { AgentNotFoundError, ConfigInvalidError, GraphorinServerError, GraphorinServerErrorCode, IdempotencyConflictError, IdempotencyKeyRequiredError, LifecycleDoubleStartError, LifecycleNotStartedError, MigrationFailedError, PrebindEncryptionPeerMissingError, PrebindEncryptionRequiredError, PrebindPepperMissingError, PrebindSecretUnresolvableError, RouteHandlerMissingError, ShutdownTimeoutError, WorkflowNotFoundError } from "./errors/index.js";
9
9
  import { CreateTriggersDaemonOptions, TriggersDaemon, TriggersDaemonMetrics, TriggersDaemonStatus, createTriggersDaemon, defaultCatchupPolicy } from "./triggers/daemon.js";
10
+ import { CreateWorkflowTimerDaemonOptions, WorkflowTimerDaemon, WorkflowTimerDaemonStatus, WorkflowTimerDriverLike, createWorkflowTimerDaemon } from "./workflows/timer-daemon.js";
10
11
  import { BaseHealthCheck, ConsolidatorCheck, EmbedderCheck, EncryptionCheck, HealthCheck, HealthCheckOptions, HealthChecks, HealthRollup, HealthStatus, HealthSummary, ReplayBufferCheck, ReplayBufferProbe, SecretsCheck, StorageCheck, TriggersCheck, collectHealth, rollup } from "./health/checks.js";
11
12
  import { RequestToken, ServerRequestState, ServerVariables } from "./internal/context.js";
12
13
  import { LabelSet, MetricKind, MetricRegistry } from "./metrics/registry.js";
13
14
  import { HealthRouteOptions, MetricsRoutesOptions, createExtendedHealthRoutes, createMetricsRoutes, createSecretsHealthRoutes } from "./health/routes.js";
14
15
  import "./health/index.js";
16
+ import { TriggersDaemonInput, WorkflowTimersInput } from "./app-daemons.js";
15
17
  import { BeforeShutdownContext, BeforeStartContext, LifecycleHooks, OnErrorContext, OnReadyContext } from "./lifecycle/hooks.js";
16
18
  import { PreBindResult, RunPreBindOptions, runPreBind } from "./lifecycle/pre-bind.js";
17
19
  import "./lifecycle/index.js";
@@ -36,8 +38,10 @@ import { WorkflowRoutesDeps, createWorkflowRoutes } from "./routes/workflows.js"
36
38
  import "./routes/index.js";
37
39
  import { WsUpgradeOptions, createWsUpgradeEvents } from "./ws/upgrade.js";
38
40
  import "./ws/index.js";
39
- import { CreateServerOptions, GraphorinServer, TriggersDaemonInput, createServer, ensureStoreAuditBinding } from "./app.js";
41
+ import { ensureStoreAuditBinding } from "./app-audit-binding.js";
42
+ import { CreateServerOptions, GraphorinServer, createServer } from "./app.js";
40
43
  import { SERVER_METRIC_NAMES, createServerMetricRegistry } from "./metrics/catalog.js";
44
+ import { syncToolCounters } from "./metrics/tools-bridge.js";
41
45
  import { AuditErrorSink, AuditMiddlewareOptions, HTTP_REQUEST_AUDIT_ACTION, createAuditMiddleware } from "./middleware/audit.js";
42
46
  import { AuthMiddlewareOptions, createAuthMiddleware } from "./middleware/auth.js";
43
47
  import { createCorsMiddleware } from "./middleware/cors.js";
@@ -47,8 +51,10 @@ import { createRateLimitMiddleware } from "./middleware/rate-limit.js";
47
51
  import { RequestStateMiddlewareOptions, createRequestStateMiddleware } from "./middleware/request-state.js";
48
52
  import { ScopeRequirement, createScopeMiddleware } from "./middleware/scope.js";
49
53
  import "./middleware/index.js";
54
+ import { RetentionConfig, RetentionLog, RetentionLogLevel, RetentionStoreLike, ScheduleRetentionOptions, createConsoleRetentionLog, scheduleRetentionSweeps } from "./runtime/retention.js";
50
55
  import { SseRoutesDeps, createSseRoutes } from "./sse/events.js";
51
56
  import "./sse/index.js";
57
+ import { ToolAuditBridge, ToolEventsAuditPolicy, bridgeToolAuditToAudit, toolAuditEventToAuditInput } from "./tools-audit-bridge.js";
52
58
  import { TriggersRoutesDeps, createTriggersRoutes } from "./triggers/routes.js";
53
59
  import "./triggers/index.js";
54
60
 
@@ -81,8 +87,7 @@ import "./triggers/index.js";
81
87
  *
82
88
  * @packageDocumentation
83
89
  */
84
- /** Canonical version constant. Mirrors the `package.json` version. */
85
- declare const VERSION = "0.6.0";
90
+ declare const VERSION: string;
86
91
  //#endregion
87
- export { AgentNotFoundError, type AgentRegistration, AgentRegistry, type AgentRoutesDeps, type AgentSummary, type AuditApi, type AuditErrorSink, type AuditMiddlewareOptions, type AuditRoutesDeps, type AuthMiddlewareOptions, type AuthRoutesDeps, type BareEventFrame, type BaseHealthCheck, type BeforeShutdownContext, type BeforeStartContext, ConfigInvalidError, type ConsolidatorCheck, type ConsolidatorDaemon, type ConsolidatorLike, type ConsolidatorStatusLike, type CreateConsolidatorDaemonOptions, type CreateServerOptions, type CreateTriggersDaemonOptions, DEFAULT_APPLY_TO_EVENTS, DEFAULT_DELIVERY_COMMENTARY_PATTERNS, type DeliveryCommentaryConfig, type DeliveryCommentaryDecision, type DeliveryCommentaryPattern, type DeliveryCommentaryPolicy, type DeliveryCommentaryPolicyConfig, type DeliveryCommentaryReason, type DeliveryCommentarySanitizer, type DeliveryCommentarySink, type DeliveryCommentaryTransport, type EmbedderCheck, type EncryptionCheck, type GraphorinServer, GraphorinServerError, GraphorinServerErrorCode, HTTP_REQUEST_AUDIT_ACTION, type HealthCheck, type HealthCheckOptions, type HealthChecks, type HealthRollup, type HealthRouteOptions, type HealthRoutesDeps, type HealthStatus, type HealthSummary, IdempotencyConflictError, IdempotencyKeyRequiredError, type IdempotencyMiddlewareOptions, type IdempotencyRequireKeyMode, type LabelSet, LifecycleDoubleStartError, type LifecycleHooks, LifecycleNotStartedError, type McpApi, type McpRoutesDeps, type MemoryApi, type MemoryRoutesDeps, type MetricKind, MetricRegistry, type MetricsRoutesOptions, MigrationFailedError, type OnErrorContext, type OnReadyContext, type ParsedSubject, type PreBindResult, PrebindEncryptionPeerMissingError, PrebindEncryptionRequiredError, PrebindPepperMissingError, PrebindSecretUnresolvableError, type ReplayApi, type ReplayBuffer, type ReplayBufferCheck, type ReplayBufferOptions, type ReplayBufferProbe, type ReplayBufferSlice, type ReplayMode, type ReplayResponse, type ReplayRoutesDeps, type RequestStateMiddlewareOptions, type RequestToken, RouteHandlerMissingError, type RunDescriptor, type RunHandle, type RunPreBindOptions, type RunStateSnapshot, RunStateTracker, type RunStatus, SERVER_METRIC_NAMES, type ScopeRequirement, type SecretRefString, type SecretsCheck, type SecretsSource, type ServerAgentLike, type ServerConfigInput, ServerConfigSchema, type ServerConfigSpec, type ServerRequestState, type ServerVariables, type ServerWorkflowLike, type SessionApi, type SessionRoutesDeps, ShutdownTimeoutError, type SkillsApi, type SkillsRoutesDeps, type SseRoutesDeps, type StorageCheck, type SubscribeResult, type TokensRoutesDeps, type TriggersCheck, type TriggersDaemon, type TriggersDaemonInput, type TriggersDaemonMetrics, type TriggersDaemonStatus, type TriggersRoutesDeps, VERSION, WorkflowNotFoundError, type WorkflowRegistration, WorkflowRegistry, type WorkflowRoutesDeps, type WorkflowSummary, type WsDispatcher, type WsDispatcherOptions, type WsDispatcherWarning, type WsSubscriberHandle, type WsSubscriptionSnapshot, type WsTicket, type WsTicketConsumeResult, type WsTicketStore, type WsTicketStoreOptions, type WsUpgradeOptions, collectHealth, createAgentRoutes, createAuditMiddleware, createAuditRoutes, createAuthMiddleware, createAuthRoutes, createConsolidatorDaemon, createCorsMiddleware, createCsrfMiddleware, createDeliveryCommentarySanitizer, createExtendedHealthRoutes, createHealthRoutes, createIdempotencyMiddleware, createMcpRoutes, createMemoryRoutes, createMetricsRoutes, createRateLimitMiddleware, createReplayBuffer, createReplayRoutes, createRequestStateMiddleware, createRunRoutes, createScopeMiddleware, createSecretsHealthRoutes, createServer, createServerMetricRegistry, createSessionRoutes, createSkillsRoutes, createSseRoutes, createTokensRoutes, createTriggersDaemon, createTriggersRoutes, createWorkflowRoutes, createWsDispatcher, createWsTicketStore, createWsUpgradeEvents, defaultCatchupPolicy, defineConfig, ensureStoreAuditBinding, parseServerConfig, requiredScopeFor, rollup, runPreBind, tryParseSubject };
92
+ export { AgentNotFoundError, type AgentRegistration, AgentRegistry, type AgentRoutesDeps, type AgentSummary, type AuditApi, type AuditErrorSink, type AuditMiddlewareOptions, type AuditRoutesDeps, type AuthMiddlewareOptions, type AuthRoutesDeps, type BareEventFrame, type BaseHealthCheck, type BeforeShutdownContext, type BeforeStartContext, ConfigInvalidError, type ConsolidatorCheck, type ConsolidatorDaemon, type ConsolidatorLike, type ConsolidatorStatusLike, type CreateConsolidatorDaemonOptions, type CreateServerOptions, type CreateTriggersDaemonOptions, type CreateWorkflowTimerDaemonOptions, DEFAULT_APPLY_TO_EVENTS, DEFAULT_DELIVERY_COMMENTARY_PATTERNS, type DeliveryCommentaryConfig, type DeliveryCommentaryDecision, type DeliveryCommentaryPattern, type DeliveryCommentaryPolicy, type DeliveryCommentaryPolicyConfig, type DeliveryCommentaryReason, type DeliveryCommentarySanitizer, type DeliveryCommentarySink, type DeliveryCommentaryTransport, type EmbedderCheck, type EncryptionCheck, type GraphorinServer, GraphorinServerError, GraphorinServerErrorCode, HTTP_REQUEST_AUDIT_ACTION, type HealthCheck, type HealthCheckOptions, type HealthChecks, type HealthRollup, type HealthRouteOptions, type HealthRoutesDeps, type HealthStatus, type HealthSummary, IdempotencyConflictError, IdempotencyKeyRequiredError, type IdempotencyMiddlewareOptions, type IdempotencyRequireKeyMode, type LabelSet, LifecycleDoubleStartError, type LifecycleHooks, LifecycleNotStartedError, type McpApi, type McpRoutesDeps, type MemoryApi, type MemoryRoutesDeps, type MetricKind, MetricRegistry, type MetricsRoutesOptions, MigrationFailedError, type OnErrorContext, type OnReadyContext, type ParsedSubject, type PreBindResult, PrebindEncryptionPeerMissingError, PrebindEncryptionRequiredError, PrebindPepperMissingError, PrebindSecretUnresolvableError, type ReplayApi, type ReplayBuffer, type ReplayBufferCheck, type ReplayBufferOptions, type ReplayBufferProbe, type ReplayBufferSlice, type ReplayMode, type ReplayResponse, type ReplayRoutesDeps, type RequestStateMiddlewareOptions, type RequestToken, type RetentionConfig, type RetentionLog, type RetentionLogLevel, type RetentionStoreLike, RouteHandlerMissingError, type RunDescriptor, type RunHandle, type RunPreBindOptions, type RunStateSnapshot, RunStateTracker, type RunStatus, SERVER_METRIC_NAMES, type ScheduleRetentionOptions, type ScopeRequirement, type SecretRefString, type SecretsCheck, type SecretsSource, type ServerAgentLike, type ServerConfigInput, ServerConfigSchema, type ServerConfigSpec, type ServerRequestState, type ServerVariables, type ServerWorkflowLike, type SessionApi, type SessionRoutesDeps, ShutdownTimeoutError, type SkillsApi, type SkillsRoutesDeps, type SseRoutesDeps, type StorageCheck, type SubscribeResult, type TokensRoutesDeps, type ToolAuditBridge, type ToolEventsAuditPolicy, type TriggersCheck, type TriggersDaemon, type TriggersDaemonInput, type TriggersDaemonMetrics, type TriggersDaemonStatus, type TriggersRoutesDeps, VERSION, WorkflowNotFoundError, type WorkflowRegistration, WorkflowRegistry, type WorkflowRoutesDeps, type WorkflowSummary, type WorkflowTimerDaemon, type WorkflowTimerDaemonStatus, type WorkflowTimerDriverLike, type WorkflowTimersInput, type WsDispatcher, type WsDispatcherOptions, type WsDispatcherWarning, type WsSubscriberHandle, type WsSubscriptionSnapshot, type WsTicket, type WsTicketConsumeResult, type WsTicketStore, type WsTicketStoreOptions, type WsUpgradeOptions, bridgeToolAuditToAudit, collectHealth, createAgentRoutes, createAuditMiddleware, createAuditRoutes, createAuthMiddleware, createAuthRoutes, createConsoleRetentionLog, createConsolidatorDaemon, createCorsMiddleware, createCsrfMiddleware, createDeliveryCommentarySanitizer, createExtendedHealthRoutes, createHealthRoutes, createIdempotencyMiddleware, createMcpRoutes, createMemoryRoutes, createMetricsRoutes, createRateLimitMiddleware, createReplayBuffer, createReplayRoutes, createRequestStateMiddleware, createRunRoutes, createScopeMiddleware, createSecretsHealthRoutes, createServer, createServerMetricRegistry, createSessionRoutes, createSkillsRoutes, createSseRoutes, createTokensRoutes, createTriggersDaemon, createTriggersRoutes, createWorkflowRoutes, createWorkflowTimerDaemon, createWsDispatcher, createWsTicketStore, createWsUpgradeEvents, defaultCatchupPolicy, defineConfig, ensureStoreAuditBinding, parseServerConfig, requiredScopeFor, rollup, runPreBind, scheduleRetentionSweeps, syncToolCounters, toolAuditEventToAuditInput, tryParseSubject };
88
93
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":[],"sources":["../src/index.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cA8Ba,OAAA"}
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../src/index.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAgCa"}
package/dist/index.js CHANGED
@@ -1,17 +1,11 @@
1
- import { DEFAULT_APPLY_TO_EVENTS, DEFAULT_DELIVERY_COMMENTARY_PATTERNS } from "./commentary/built-in-patterns.js";
2
- import { createDeliveryCommentarySanitizer } from "./commentary/sanitizer.js";
3
- import "./commentary/index.js";
4
- import { AgentNotFoundError, ConfigInvalidError, GraphorinServerError, IdempotencyConflictError, IdempotencyKeyRequiredError, LifecycleDoubleStartError, LifecycleNotStartedError, MigrationFailedError, PrebindEncryptionPeerMissingError, PrebindEncryptionRequiredError, PrebindPepperMissingError, PrebindSecretUnresolvableError, RouteHandlerMissingError, ShutdownTimeoutError, WorkflowNotFoundError } from "./errors/index.js";
5
- import { ServerConfigSchema, defineConfig, parseServerConfig } from "./config.js";
1
+ import { version } from "./package.js";
6
2
  import { createConsolidatorDaemon } from "./consolidator/daemon.js";
7
- import { collectHealth, rollup } from "./health/checks.js";
8
- import { createScopeMiddleware } from "./middleware/scope.js";
9
- import { createExtendedHealthRoutes, createMetricsRoutes, createSecretsHealthRoutes } from "./health/routes.js";
10
- import "./health/index.js";
11
- import { runPreBind } from "./lifecycle/pre-bind.js";
12
- import "./lifecycle/index.js";
3
+ import { createTriggersDaemon, defaultCatchupPolicy } from "./triggers/daemon.js";
4
+ import { createWorkflowTimerDaemon } from "./workflows/timer-daemon.js";
5
+ import { ensureStoreAuditBinding } from "./app-audit-binding.js";
13
6
  import { MetricRegistry } from "./metrics/registry.js";
14
7
  import { SERVER_METRIC_NAMES, createServerMetricRegistry } from "./metrics/catalog.js";
8
+ import { syncToolCounters } from "./metrics/tools-bridge.js";
15
9
  import { HTTP_REQUEST_AUDIT_ACTION, createAuditMiddleware } from "./middleware/audit.js";
16
10
  import { createAuthMiddleware } from "./middleware/auth.js";
17
11
  import { createCorsMiddleware } from "./middleware/cors.js";
@@ -19,10 +13,12 @@ import { createCsrfMiddleware } from "./middleware/csrf.js";
19
13
  import { createIdempotencyMiddleware } from "./middleware/idempotency.js";
20
14
  import { createRateLimitMiddleware } from "./middleware/rate-limit.js";
21
15
  import { createRequestStateMiddleware } from "./middleware/request-state.js";
22
- import "./middleware/index.js";
23
- import { AgentRegistry, WorkflowRegistry } from "./registry/index.js";
16
+ import { createScopeMiddleware } from "./middleware/scope.js";
17
+ import { collectHealth, rollup } from "./health/checks.js";
18
+ import { createExtendedHealthRoutes, createMetricsRoutes, createSecretsHealthRoutes } from "./health/routes.js";
24
19
  import { createReplayRoutes } from "./replay/routes.js";
25
- import "./replay/index.js";
20
+ import { AgentNotFoundError, ConfigInvalidError, GraphorinServerError, IdempotencyConflictError, IdempotencyKeyRequiredError, LifecycleDoubleStartError, LifecycleNotStartedError, MigrationFailedError, PrebindEncryptionPeerMissingError, PrebindEncryptionRequiredError, PrebindPepperMissingError, PrebindSecretUnresolvableError, RouteHandlerMissingError, ShutdownTimeoutError, WorkflowNotFoundError } from "./errors/index.js";
21
+ import { RunStateTracker } from "./runtime/run-state.js";
26
22
  import { createAgentRoutes, createRunRoutes } from "./routes/agents.js";
27
23
  import { createAuditRoutes } from "./routes/audit.js";
28
24
  import { createAuthRoutes } from "./routes/auth.js";
@@ -33,21 +29,21 @@ import { createSessionRoutes } from "./routes/sessions.js";
33
29
  import { createSkillsRoutes } from "./routes/skills.js";
34
30
  import { createTokensRoutes } from "./routes/tokens.js";
35
31
  import { createWorkflowRoutes } from "./routes/workflows.js";
36
- import "./routes/index.js";
37
- import { RunStateTracker } from "./runtime/run-state.js";
32
+ import { DEFAULT_APPLY_TO_EVENTS, DEFAULT_DELIVERY_COMMENTARY_PATTERNS } from "./commentary/built-in-patterns.js";
33
+ import { createDeliveryCommentarySanitizer } from "./commentary/sanitizer.js";
38
34
  import { createSseRoutes } from "./sse/events.js";
39
- import "./sse/index.js";
40
- import { createTriggersDaemon, defaultCatchupPolicy } from "./triggers/daemon.js";
41
35
  import { createTriggersRoutes } from "./triggers/routes.js";
36
+ import { createWsUpgradeEvents } from "./ws/upgrade.js";
37
+ import { runPreBind } from "./lifecycle/pre-bind.js";
38
+ import { createConsoleRetentionLog, scheduleRetentionSweeps } from "./runtime/retention.js";
39
+ import { bridgeToolAuditToAudit, toolAuditEventToAuditInput } from "./tools-audit-bridge.js";
42
40
  import { createReplayBuffer } from "./ws/replay-buffer.js";
43
41
  import { requiredScopeFor, tryParseSubject } from "./ws/subjects.js";
44
42
  import { createWsDispatcher } from "./ws/dispatcher.js";
45
43
  import { createWsTicketStore } from "./ws/ticket.js";
46
- import { createWsUpgradeEvents } from "./ws/upgrade.js";
47
- import "./ws/index.js";
48
- import { createServer, ensureStoreAuditBinding } from "./app.js";
49
- import "./metrics/index.js";
50
- import "./triggers/index.js";
44
+ import { ServerConfigSchema, defineConfig, parseServerConfig } from "./config.js";
45
+ import { AgentRegistry, WorkflowRegistry } from "./registry/index.js";
46
+ import { createServer } from "./app.js";
51
47
 
52
48
  //#region src/index.ts
53
49
  /**
@@ -78,9 +74,9 @@ import "./triggers/index.js";
78
74
  *
79
75
  * @packageDocumentation
80
76
  */
81
- /** Canonical version constant. Mirrors the `package.json` version. */
82
- const VERSION = "0.6.0";
77
+ /** Canonical version constant, derived from `package.json` at build time. */
78
+ const VERSION = version;
83
79
 
84
80
  //#endregion
85
- export { AgentNotFoundError, AgentRegistry, ConfigInvalidError, DEFAULT_APPLY_TO_EVENTS, DEFAULT_DELIVERY_COMMENTARY_PATTERNS, GraphorinServerError, HTTP_REQUEST_AUDIT_ACTION, IdempotencyConflictError, IdempotencyKeyRequiredError, LifecycleDoubleStartError, LifecycleNotStartedError, MetricRegistry, MigrationFailedError, PrebindEncryptionPeerMissingError, PrebindEncryptionRequiredError, PrebindPepperMissingError, PrebindSecretUnresolvableError, RouteHandlerMissingError, RunStateTracker, SERVER_METRIC_NAMES, ServerConfigSchema, ShutdownTimeoutError, VERSION, WorkflowNotFoundError, WorkflowRegistry, collectHealth, createAgentRoutes, createAuditMiddleware, createAuditRoutes, createAuthMiddleware, createAuthRoutes, createConsolidatorDaemon, createCorsMiddleware, createCsrfMiddleware, createDeliveryCommentarySanitizer, createExtendedHealthRoutes, createHealthRoutes, createIdempotencyMiddleware, createMcpRoutes, createMemoryRoutes, createMetricsRoutes, createRateLimitMiddleware, createReplayBuffer, createReplayRoutes, createRequestStateMiddleware, createRunRoutes, createScopeMiddleware, createSecretsHealthRoutes, createServer, createServerMetricRegistry, createSessionRoutes, createSkillsRoutes, createSseRoutes, createTokensRoutes, createTriggersDaemon, createTriggersRoutes, createWorkflowRoutes, createWsDispatcher, createWsTicketStore, createWsUpgradeEvents, defaultCatchupPolicy, defineConfig, ensureStoreAuditBinding, parseServerConfig, requiredScopeFor, rollup, runPreBind, tryParseSubject };
81
+ export { AgentNotFoundError, AgentRegistry, ConfigInvalidError, DEFAULT_APPLY_TO_EVENTS, DEFAULT_DELIVERY_COMMENTARY_PATTERNS, GraphorinServerError, HTTP_REQUEST_AUDIT_ACTION, IdempotencyConflictError, IdempotencyKeyRequiredError, LifecycleDoubleStartError, LifecycleNotStartedError, MetricRegistry, MigrationFailedError, PrebindEncryptionPeerMissingError, PrebindEncryptionRequiredError, PrebindPepperMissingError, PrebindSecretUnresolvableError, RouteHandlerMissingError, RunStateTracker, SERVER_METRIC_NAMES, ServerConfigSchema, ShutdownTimeoutError, VERSION, WorkflowNotFoundError, WorkflowRegistry, bridgeToolAuditToAudit, collectHealth, createAgentRoutes, createAuditMiddleware, createAuditRoutes, createAuthMiddleware, createAuthRoutes, createConsoleRetentionLog, createConsolidatorDaemon, createCorsMiddleware, createCsrfMiddleware, createDeliveryCommentarySanitizer, createExtendedHealthRoutes, createHealthRoutes, createIdempotencyMiddleware, createMcpRoutes, createMemoryRoutes, createMetricsRoutes, createRateLimitMiddleware, createReplayBuffer, createReplayRoutes, createRequestStateMiddleware, createRunRoutes, createScopeMiddleware, createSecretsHealthRoutes, createServer, createServerMetricRegistry, createSessionRoutes, createSkillsRoutes, createSseRoutes, createTokensRoutes, createTriggersDaemon, createTriggersRoutes, createWorkflowRoutes, createWorkflowTimerDaemon, createWsDispatcher, createWsTicketStore, createWsUpgradeEvents, defaultCatchupPolicy, defineConfig, ensureStoreAuditBinding, parseServerConfig, requiredScopeFor, rollup, runPreBind, scheduleRetentionSweeps, syncToolCounters, toolAuditEventToAuditInput, tryParseSubject };
86
82
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["/**\n * `@graphorin/server` - standalone server runtime for the Graphorin\n * framework.\n *\n * Phase 14a entry point. Ships:\n *\n * - {@link createServer} - the single programmatic entry that wires\n * the Hono app, the auth + scope + idempotency + audit middleware\n * stack, REST endpoints (agents / workflows / sessions / memory /\n * skills / mcp / tokens / audit / health), the lifecycle hooks\n * (`beforeStart` / `onReady` / `beforeShutdown` / `onError`), the\n * pre-bind secrets-resolution + storage-migration runner, and the\n * graceful SIGTERM drain.\n * - {@link defineConfig} + {@link parseServerConfig} - typed\n * configuration loader with a Zod-validated schema; missing fields\n * fall back to documented production-ready defaults.\n * - {@link AgentRegistry} + {@link WorkflowRegistry} - read/write\n * registries the route handlers consult to look up user-defined\n * agents / workflows.\n * - {@link RunStateTracker} - in-memory bookkeeping for in-flight\n * runs (run id, status, AbortController). Phase 14b/c promote the\n * tracker to a SQLite-backed durable variant.\n * - The full middleware factory suite - re-exported from\n * `@graphorin/server/middleware` so operators can compose a custom\n * Hono app on top of the same primitives.\n *\n * @packageDocumentation\n */\n\n/** Canonical version constant. Mirrors the `package.json` version. */\nexport const VERSION = '0.6.0';\n\nexport {\n type CreateServerOptions,\n createServer,\n ensureStoreAuditBinding,\n type GraphorinServer,\n type TriggersDaemonInput,\n} from './app.js';\nexport {\n createDeliveryCommentarySanitizer,\n DEFAULT_APPLY_TO_EVENTS,\n DEFAULT_DELIVERY_COMMENTARY_PATTERNS,\n type DeliveryCommentaryConfig,\n type DeliveryCommentaryDecision,\n type DeliveryCommentaryPattern,\n type DeliveryCommentaryPolicy,\n type DeliveryCommentaryReason,\n type DeliveryCommentarySanitizer,\n type DeliveryCommentarySink,\n type DeliveryCommentaryTransport,\n} from './commentary/index.js';\nexport {\n type DeliveryCommentaryPolicyConfig,\n defineConfig,\n type IdempotencyRequireKeyMode,\n parseServerConfig,\n type SecretRefString,\n type SecretsSource,\n type ServerConfigInput,\n ServerConfigSchema,\n type ServerConfigSpec,\n} from './config.js';\nexport {\n type ConsolidatorDaemon,\n type ConsolidatorLike,\n type ConsolidatorStatusLike,\n type CreateConsolidatorDaemonOptions,\n createConsolidatorDaemon,\n} from './consolidator/index.js';\nexport * from './errors/index.js';\nexport {\n type BaseHealthCheck,\n type ConsolidatorCheck,\n collectHealth,\n createExtendedHealthRoutes,\n createMetricsRoutes,\n createSecretsHealthRoutes,\n type EmbedderCheck,\n type EncryptionCheck,\n type HealthCheck,\n type HealthCheckOptions,\n type HealthChecks,\n type HealthRollup,\n type HealthRouteOptions,\n type HealthStatus,\n type HealthSummary,\n type MetricsRoutesOptions,\n type ReplayBufferCheck,\n type ReplayBufferProbe,\n rollup,\n type SecretsCheck,\n type StorageCheck,\n type TriggersCheck,\n} from './health/index.js';\nexport type { RequestToken, ServerRequestState, ServerVariables } from './internal/context.js';\nexport {\n type BeforeShutdownContext,\n type BeforeStartContext,\n type LifecycleHooks,\n type OnErrorContext,\n type OnReadyContext,\n type PreBindResult,\n type RunPreBindOptions,\n runPreBind,\n} from './lifecycle/index.js';\nexport {\n createServerMetricRegistry,\n type LabelSet,\n type MetricKind,\n MetricRegistry,\n SERVER_METRIC_NAMES,\n} from './metrics/index.js';\nexport {\n type AuditErrorSink,\n type AuditMiddlewareOptions,\n type AuthMiddlewareOptions,\n createAuditMiddleware,\n createAuthMiddleware,\n createCorsMiddleware,\n createCsrfMiddleware,\n createIdempotencyMiddleware,\n createRateLimitMiddleware,\n createRequestStateMiddleware,\n createScopeMiddleware,\n HTTP_REQUEST_AUDIT_ACTION,\n type IdempotencyMiddlewareOptions,\n type RequestStateMiddlewareOptions,\n type ScopeRequirement,\n} from './middleware/index.js';\nexport {\n type AgentRegistration,\n AgentRegistry,\n type AgentSummary,\n type ServerAgentLike,\n type ServerWorkflowLike,\n type WorkflowRegistration,\n WorkflowRegistry,\n type WorkflowSummary,\n} from './registry/index.js';\nexport {\n createReplayRoutes,\n type ReplayApi,\n type ReplayMode,\n type ReplayResponse,\n type ReplayRoutesDeps,\n} from './replay/index.js';\nexport {\n type AgentRoutesDeps,\n type AuditApi,\n type AuditRoutesDeps,\n type AuthRoutesDeps,\n createAgentRoutes,\n createAuditRoutes,\n createAuthRoutes,\n createHealthRoutes,\n createMcpRoutes,\n createMemoryRoutes,\n createRunRoutes,\n createSessionRoutes,\n createSkillsRoutes,\n createTokensRoutes,\n createWorkflowRoutes,\n type HealthRoutesDeps,\n type McpApi,\n type McpRoutesDeps,\n type MemoryApi,\n type MemoryRoutesDeps,\n type SessionApi,\n type SessionRoutesDeps,\n type SkillsApi,\n type SkillsRoutesDeps,\n type TokensRoutesDeps,\n type WorkflowRoutesDeps,\n} from './routes/index.js';\nexport {\n type RunDescriptor,\n type RunHandle,\n type RunStateSnapshot,\n RunStateTracker,\n type RunStatus,\n} from './runtime/run-state.js';\nexport { createSseRoutes, type SseRoutesDeps } from './sse/index.js';\nexport {\n type CreateTriggersDaemonOptions,\n createTriggersDaemon,\n createTriggersRoutes,\n defaultCatchupPolicy,\n type TriggersDaemon,\n type TriggersDaemonMetrics,\n type TriggersDaemonStatus,\n type TriggersRoutesDeps,\n} from './triggers/index.js';\nexport {\n type BareEventFrame,\n createReplayBuffer,\n createWsDispatcher,\n createWsTicketStore,\n createWsUpgradeEvents,\n type ParsedSubject,\n type ReplayBuffer,\n type ReplayBufferOptions,\n type ReplayBufferSlice,\n requiredScopeFor,\n type SubscribeResult,\n tryParseSubject,\n type WsDispatcher,\n type WsDispatcherOptions,\n type WsDispatcherWarning,\n type WsSubscriberHandle,\n type WsSubscriptionSnapshot,\n type WsTicket,\n type WsTicketConsumeResult,\n type WsTicketStore,\n type WsTicketStoreOptions,\n type WsUpgradeOptions,\n} from './ws/index.js';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8BA,MAAa,UAAU"}
1
+ {"version":3,"file":"index.js","names":["VERSION: string","pkg.version"],"sources":["../src/index.ts"],"sourcesContent":["/**\n * `@graphorin/server` - standalone server runtime for the Graphorin\n * framework.\n *\n * Phase 14a entry point. Ships:\n *\n * - {@link createServer} - the single programmatic entry that wires\n * the Hono app, the auth + scope + idempotency + audit middleware\n * stack, REST endpoints (agents / workflows / sessions / memory /\n * skills / mcp / tokens / audit / health), the lifecycle hooks\n * (`beforeStart` / `onReady` / `beforeShutdown` / `onError`), the\n * pre-bind secrets-resolution + storage-migration runner, and the\n * graceful SIGTERM drain.\n * - {@link defineConfig} + {@link parseServerConfig} - typed\n * configuration loader with a Zod-validated schema; missing fields\n * fall back to documented production-ready defaults.\n * - {@link AgentRegistry} + {@link WorkflowRegistry} - read/write\n * registries the route handlers consult to look up user-defined\n * agents / workflows.\n * - {@link RunStateTracker} - in-memory bookkeeping for in-flight\n * runs (run id, status, AbortController). Phase 14b/c promote the\n * tracker to a SQLite-backed durable variant.\n * - The full middleware factory suite - re-exported from\n * `@graphorin/server/middleware` so operators can compose a custom\n * Hono app on top of the same primitives.\n *\n * @packageDocumentation\n */\n\n/** Canonical version constant, derived from `package.json` at build time. */\nimport pkg from '../package.json' with { type: 'json' };\n\nexport const VERSION: string = pkg.version;\n\nexport {\n type CreateServerOptions,\n createServer,\n ensureStoreAuditBinding,\n type GraphorinServer,\n type TriggersDaemonInput,\n type WorkflowTimersInput,\n} from './app.js';\nexport {\n createDeliveryCommentarySanitizer,\n DEFAULT_APPLY_TO_EVENTS,\n DEFAULT_DELIVERY_COMMENTARY_PATTERNS,\n type DeliveryCommentaryConfig,\n type DeliveryCommentaryDecision,\n type DeliveryCommentaryPattern,\n type DeliveryCommentaryPolicy,\n type DeliveryCommentaryReason,\n type DeliveryCommentarySanitizer,\n type DeliveryCommentarySink,\n type DeliveryCommentaryTransport,\n} from './commentary/index.js';\nexport {\n type DeliveryCommentaryPolicyConfig,\n defineConfig,\n type IdempotencyRequireKeyMode,\n parseServerConfig,\n type SecretRefString,\n type SecretsSource,\n type ServerConfigInput,\n ServerConfigSchema,\n type ServerConfigSpec,\n} from './config.js';\nexport {\n type ConsolidatorDaemon,\n type ConsolidatorLike,\n type ConsolidatorStatusLike,\n type CreateConsolidatorDaemonOptions,\n createConsolidatorDaemon,\n} from './consolidator/index.js';\nexport * from './errors/index.js';\nexport {\n type BaseHealthCheck,\n type ConsolidatorCheck,\n collectHealth,\n createExtendedHealthRoutes,\n createMetricsRoutes,\n createSecretsHealthRoutes,\n type EmbedderCheck,\n type EncryptionCheck,\n type HealthCheck,\n type HealthCheckOptions,\n type HealthChecks,\n type HealthRollup,\n type HealthRouteOptions,\n type HealthStatus,\n type HealthSummary,\n type MetricsRoutesOptions,\n type ReplayBufferCheck,\n type ReplayBufferProbe,\n rollup,\n type SecretsCheck,\n type StorageCheck,\n type TriggersCheck,\n} from './health/index.js';\nexport type { RequestToken, ServerRequestState, ServerVariables } from './internal/context.js';\nexport {\n type BeforeShutdownContext,\n type BeforeStartContext,\n type LifecycleHooks,\n type OnErrorContext,\n type OnReadyContext,\n type PreBindResult,\n type RunPreBindOptions,\n runPreBind,\n} from './lifecycle/index.js';\nexport {\n createServerMetricRegistry,\n type LabelSet,\n type MetricKind,\n MetricRegistry,\n SERVER_METRIC_NAMES,\n} from './metrics/index.js';\nexport { syncToolCounters } from './metrics/tools-bridge.js';\nexport {\n type AuditErrorSink,\n type AuditMiddlewareOptions,\n type AuthMiddlewareOptions,\n createAuditMiddleware,\n createAuthMiddleware,\n createCorsMiddleware,\n createCsrfMiddleware,\n createIdempotencyMiddleware,\n createRateLimitMiddleware,\n createRequestStateMiddleware,\n createScopeMiddleware,\n HTTP_REQUEST_AUDIT_ACTION,\n type IdempotencyMiddlewareOptions,\n type RequestStateMiddlewareOptions,\n type ScopeRequirement,\n} from './middleware/index.js';\nexport {\n type AgentRegistration,\n AgentRegistry,\n type AgentSummary,\n type ServerAgentLike,\n type ServerWorkflowLike,\n type WorkflowRegistration,\n WorkflowRegistry,\n type WorkflowSummary,\n} from './registry/index.js';\nexport {\n createReplayRoutes,\n type ReplayApi,\n type ReplayMode,\n type ReplayResponse,\n type ReplayRoutesDeps,\n} from './replay/index.js';\nexport {\n type AgentRoutesDeps,\n type AuditApi,\n type AuditRoutesDeps,\n type AuthRoutesDeps,\n createAgentRoutes,\n createAuditRoutes,\n createAuthRoutes,\n createHealthRoutes,\n createMcpRoutes,\n createMemoryRoutes,\n createRunRoutes,\n createSessionRoutes,\n createSkillsRoutes,\n createTokensRoutes,\n createWorkflowRoutes,\n type HealthRoutesDeps,\n type McpApi,\n type McpRoutesDeps,\n type MemoryApi,\n type MemoryRoutesDeps,\n type SessionApi,\n type SessionRoutesDeps,\n type SkillsApi,\n type SkillsRoutesDeps,\n type TokensRoutesDeps,\n type WorkflowRoutesDeps,\n} from './routes/index.js';\nexport {\n createConsoleRetentionLog,\n type RetentionConfig,\n type RetentionLog,\n type RetentionLogLevel,\n type RetentionStoreLike,\n type ScheduleRetentionOptions,\n scheduleRetentionSweeps,\n} from './runtime/retention.js';\nexport {\n type RunDescriptor,\n type RunHandle,\n type RunStateSnapshot,\n RunStateTracker,\n type RunStatus,\n} from './runtime/run-state.js';\nexport { createSseRoutes, type SseRoutesDeps } from './sse/index.js';\nexport {\n bridgeToolAuditToAudit,\n type ToolAuditBridge,\n type ToolEventsAuditPolicy,\n toolAuditEventToAuditInput,\n} from './tools-audit-bridge.js';\nexport {\n type CreateTriggersDaemonOptions,\n createTriggersDaemon,\n createTriggersRoutes,\n defaultCatchupPolicy,\n type TriggersDaemon,\n type TriggersDaemonMetrics,\n type TriggersDaemonStatus,\n type TriggersRoutesDeps,\n} from './triggers/index.js';\nexport {\n type CreateWorkflowTimerDaemonOptions,\n createWorkflowTimerDaemon,\n type WorkflowTimerDaemon,\n type WorkflowTimerDaemonStatus,\n type WorkflowTimerDriverLike,\n} from './workflows/timer-daemon.js';\nexport {\n type BareEventFrame,\n createReplayBuffer,\n createWsDispatcher,\n createWsTicketStore,\n createWsUpgradeEvents,\n type ParsedSubject,\n type ReplayBuffer,\n type ReplayBufferOptions,\n type ReplayBufferSlice,\n requiredScopeFor,\n type SubscribeResult,\n tryParseSubject,\n type WsDispatcher,\n type WsDispatcherOptions,\n type WsDispatcherWarning,\n type WsSubscriberHandle,\n type WsSubscriptionSnapshot,\n type WsTicket,\n type WsTicketConsumeResult,\n type WsTicketStore,\n type WsTicketStoreOptions,\n type WsUpgradeOptions,\n} from './ws/index.js';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgCA,MAAaA,UAAkBC"}
@@ -20,7 +20,7 @@ type AuthState = {
20
20
  /**
21
21
  * Request-scoped variables surfaced through `c.var` in Hono. The
22
22
  * server's middleware populates these fields incrementally; route
23
- * handlers consume them through {@link getRequestState}.
23
+ * handlers consume them through `getRequestState`.
24
24
  *
25
25
  * @stable
26
26
  */
@@ -39,7 +39,7 @@ interface ServerRequestState {
39
39
  * Authentication / authorization middleware: "populates `c.var.token:
40
40
  * { id, label, scopes, env }`").
41
41
  *
42
- * Read this through {@link getRequestToken} so consumers do not have
42
+ * Read this through `getRequestToken` so consumers do not have
43
43
  * to remember the variable key.
44
44
  *
45
45
  * @stable
@@ -0,0 +1,20 @@
1
+ //#region src/internal/wire-error.ts
2
+ /** Normalize any thrown value into the wire envelope (W-052). */
3
+ function toWireError(err) {
4
+ if (err !== null && typeof err === "object") {
5
+ const rec = err;
6
+ return {
7
+ code: typeof rec.code === "string" && rec.code.length > 0 ? rec.code : typeof rec.kind === "string" && rec.kind.length > 0 ? rec.kind : "unknown",
8
+ message: typeof rec.message === "string" ? rec.message : String(err),
9
+ ...typeof rec.hint === "string" && rec.hint.length > 0 ? { hint: rec.hint } : {}
10
+ };
11
+ }
12
+ return {
13
+ code: "unknown",
14
+ message: String(err)
15
+ };
16
+ }
17
+
18
+ //#endregion
19
+ export { toWireError };
20
+ //# sourceMappingURL=wire-error.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wire-error.js","names":[],"sources":["../../src/internal/wire-error.ts"],"sourcesContent":["/**\n * W-052: machine-readable error envelope for the server boundary.\n *\n * The packages disagree on the error discriminator by history:\n * `@graphorin/agent` / `@graphorin/workflow` use `code`,\n * `@graphorin/tools` / `@graphorin/memory` / `@graphorin/provider` /\n * the server's own errors use `kind`. Renaming either family is a\n * breaking change to no benefit - NORMALIZATION IS THE SERVER\n * BOUNDARY'S JOB. Every wire payload that reports a failure funnels\n * through {@link toWireError}, so clients branch on one stable `code`\n * field (e.g. retry `checkpoint-version-conflict`, abandon\n * `node-execution-failed`) instead of parsing English prose.\n *\n * @packageDocumentation\n */\n\n/** Normalized error envelope for wire payloads. */\nexport interface WireError {\n /** `err.code` if a string, else `err.kind` if a string, else `'unknown'`. */\n readonly code: string;\n readonly message: string;\n /** Operator hint when the source error carries one (`WorkflowError.hint`). */\n readonly hint?: string;\n}\n\n/** Normalize any thrown value into the wire envelope (W-052). */\nexport function toWireError(err: unknown): WireError {\n if (err !== null && typeof err === 'object') {\n const rec = err as { code?: unknown; kind?: unknown; message?: unknown; hint?: unknown };\n const code =\n typeof rec.code === 'string' && rec.code.length > 0\n ? rec.code\n : typeof rec.kind === 'string' && rec.kind.length > 0\n ? rec.kind\n : 'unknown';\n const message = typeof rec.message === 'string' ? rec.message : String(err);\n return {\n code,\n message,\n ...(typeof rec.hint === 'string' && rec.hint.length > 0 ? { hint: rec.hint } : {}),\n };\n }\n return { code: 'unknown', message: String(err) };\n}\n"],"mappings":";;AA0BA,SAAgB,YAAY,KAAyB;AACnD,KAAI,QAAQ,QAAQ,OAAO,QAAQ,UAAU;EAC3C,MAAM,MAAM;AAQZ,SAAO;GACL,MAPA,OAAO,IAAI,SAAS,YAAY,IAAI,KAAK,SAAS,IAC9C,IAAI,OACJ,OAAO,IAAI,SAAS,YAAY,IAAI,KAAK,SAAS,IAChD,IAAI,OACJ;GAIN,SAHc,OAAO,IAAI,YAAY,WAAW,IAAI,UAAU,OAAO,IAAI;GAIzE,GAAI,OAAO,IAAI,SAAS,YAAY,IAAI,KAAK,SAAS,IAAI,EAAE,MAAM,IAAI,MAAM,GAAG,EAAE;GAClF;;AAEH,QAAO;EAAE,MAAM;EAAW,SAAS,OAAO,IAAI;EAAE"}
@@ -1,6 +1,6 @@
1
1
  import { ServerConfigSpec } from "../config.js";
2
- import { SecretValue } from "@graphorin/security";
3
2
  import { GraphorinSqliteStore } from "@graphorin/store-sqlite";
3
+ import { SecretValue } from "@graphorin/security";
4
4
 
5
5
  //#region src/lifecycle/pre-bind.d.ts
6
6
 
@@ -1 +1 @@
1
- {"version":3,"file":"catalog.d.ts","names":[],"sources":["../../src/metrics/catalog.ts"],"sourcesContent":[],"mappings":";;;;;;;cA0Ba,qBAAmB;;;;;;;;;;;;;;;;;;;;;;;iBAwBhB,0BAAA,CAAA,GAA8B"}
1
+ {"version":3,"file":"catalog.d.ts","names":[],"sources":["../../src/metrics/catalog.ts"],"sourcesContent":[],"mappings":";;;;;;;cA+Ba,qBAAmB;;;;;;;;;;;;;;;;;;;;;;;iBAwBhB,0BAAA,CAAA,GAA8B"}
@@ -1 +1 @@
1
- {"version":3,"file":"catalog.js","names":[],"sources":["../../src/metrics/catalog.ts"],"sourcesContent":["/**\n * Canonical metric inventory for the standalone server. Every metric\n * the framework emits is registered here in one place so the\n * exposition output is deterministic across builds.\n *\n * Metric naming follows the documented `graphorin_*` prefix\n * discipline; label cardinality is bounded by construction (no PII\n * labels - see DEC-141 cross-cut).\n *\n * @packageDocumentation\n */\n\nimport { MetricRegistry } from './registry.js';\n\n/**\n * @stable\n */\n// IP-15: the catalog lists only metrics the server actually moves. Five\n// previously-registered series - `graphorin_tool_calls_total`,\n// `graphorin_provider_tokens_total`, `graphorin_provider_cost_usd_total`,\n// `graphorin_redaction_drops_total` and `graphorin_oauth_tokens_freshness_seconds`\n// - had no producer anywhere in the monorepo (per-tool and provider usage live\n// in the agent runtime, not the server; redaction drops in the observability\n// layer; OAuth freshness needs an MCP token store the server does not own). A\n// permanently-empty series is worse than an absent one for dashboards, so they\n// are dropped until a real producer exists rather than advertised inert.\nexport const SERVER_METRIC_NAMES = Object.freeze({\n agentRunsTotal: 'graphorin_agent_runs_total',\n agentRunDuration: 'graphorin_agent_run_duration_seconds',\n storageWalSize: 'graphorin_storage_wal_size_bytes',\n idempotencyCacheHitRatio: 'graphorin_idempotency_cache_hit_ratio',\n triggersFiresTotal: 'graphorin_triggers_fires_total',\n consolidatorQueueDepth: 'graphorin_consolidator_queue_depth',\n consolidatorDlqSize: 'graphorin_consolidator_dlq_size',\n consolidatorBudgetRemainingUsd: 'graphorin_consolidator_budget_remaining_usd',\n consolidatorBudgetRemainingTokens: 'graphorin_consolidator_budget_remaining_tokens',\n replayBufferEvents: 'graphorin_replay_buffer_events',\n inflightRuns: 'graphorin_inflight_runs',\n serverUptime: 'graphorin_server_uptime_seconds',\n buildInfo: 'graphorin_build_info',\n} as const);\n\n/**\n * Build a fully-registered {@link MetricRegistry} ready for the\n * `/v1/metrics` exposition. The returned registry has every metric\n * declared but no samples; the server runtime updates samples\n * incrementally.\n *\n * @stable\n */\nexport function createServerMetricRegistry(): MetricRegistry {\n const registry = new MetricRegistry();\n\n registry.registerCounter(\n SERVER_METRIC_NAMES.agentRunsTotal,\n 'Total agent runs by terminal status.',\n ['status'],\n );\n registry.registerSummary(\n SERVER_METRIC_NAMES.agentRunDuration,\n 'Agent run duration in seconds.',\n [],\n );\n registry.registerGauge(SERVER_METRIC_NAMES.storageWalSize, 'Current SQLite WAL size in bytes.');\n registry.registerGauge(\n SERVER_METRIC_NAMES.idempotencyCacheHitRatio,\n 'Idempotency LRU cache hit ratio in [0, 1].',\n );\n registry.registerCounter(\n SERVER_METRIC_NAMES.triggersFiresTotal,\n 'Total trigger fires by trigger id and outcome.',\n ['trigger_id', 'status'],\n );\n registry.registerGauge(\n SERVER_METRIC_NAMES.consolidatorQueueDepth,\n 'Pending consolidator items by phase.',\n ['phase'],\n );\n registry.registerGauge(\n SERVER_METRIC_NAMES.consolidatorDlqSize,\n 'Number of consolidator runs sitting in the dead-letter queue.',\n );\n registry.registerGauge(\n SERVER_METRIC_NAMES.consolidatorBudgetRemainingUsd,\n 'Consolidator USD budget remaining for the current period.',\n );\n registry.registerGauge(\n SERVER_METRIC_NAMES.consolidatorBudgetRemainingTokens,\n 'Consolidator token budget remaining for the current period.',\n );\n registry.registerGauge(\n SERVER_METRIC_NAMES.replayBufferEvents,\n 'Number of events currently buffered for WebSocket replay.',\n );\n registry.registerGauge(\n SERVER_METRIC_NAMES.inflightRuns,\n 'Number of in-flight agent / workflow runs.',\n );\n registry.registerGauge(SERVER_METRIC_NAMES.serverUptime, 'Server process uptime in seconds.');\n registry.registerGauge(\n SERVER_METRIC_NAMES.buildInfo,\n 'Static `1` gauge carrying graphorin build labels.',\n ['version'],\n );\n\n return registry;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AA0BA,MAAa,sBAAsB,OAAO,OAAO;CAC/C,gBAAgB;CAChB,kBAAkB;CAClB,gBAAgB;CAChB,0BAA0B;CAC1B,oBAAoB;CACpB,wBAAwB;CACxB,qBAAqB;CACrB,gCAAgC;CAChC,mCAAmC;CACnC,oBAAoB;CACpB,cAAc;CACd,cAAc;CACd,WAAW;CACZ,CAAU;;;;;;;;;AAUX,SAAgB,6BAA6C;CAC3D,MAAM,WAAW,IAAI,gBAAgB;AAErC,UAAS,gBACP,oBAAoB,gBACpB,wCACA,CAAC,SAAS,CACX;AACD,UAAS,gBACP,oBAAoB,kBACpB,kCACA,EAAE,CACH;AACD,UAAS,cAAc,oBAAoB,gBAAgB,oCAAoC;AAC/F,UAAS,cACP,oBAAoB,0BACpB,6CACD;AACD,UAAS,gBACP,oBAAoB,oBACpB,kDACA,CAAC,cAAc,SAAS,CACzB;AACD,UAAS,cACP,oBAAoB,wBACpB,wCACA,CAAC,QAAQ,CACV;AACD,UAAS,cACP,oBAAoB,qBACpB,gEACD;AACD,UAAS,cACP,oBAAoB,gCACpB,4DACD;AACD,UAAS,cACP,oBAAoB,mCACpB,8DACD;AACD,UAAS,cACP,oBAAoB,oBACpB,4DACD;AACD,UAAS,cACP,oBAAoB,cACpB,6CACD;AACD,UAAS,cAAc,oBAAoB,cAAc,oCAAoC;AAC7F,UAAS,cACP,oBAAoB,WACpB,qDACA,CAAC,UAAU,CACZ;AAED,QAAO"}
1
+ {"version":3,"file":"catalog.js","names":[],"sources":["../../src/metrics/catalog.ts"],"sourcesContent":["/**\n * Canonical metric inventory for the standalone server. Every metric\n * the framework emits is registered here in one place so the\n * exposition output is deterministic across builds.\n *\n * Metric naming follows the documented `graphorin_*` prefix\n * discipline; label cardinality is bounded by construction (no PII\n * labels - see DEC-141 cross-cut).\n *\n * @packageDocumentation\n */\n\nimport { MetricRegistry } from './registry.js';\n\n/**\n * @stable\n */\n// IP-15: the catalog lists only metrics the server actually moves. Five\n// previously-registered series - `graphorin_tool_calls_total`,\n// `graphorin_provider_tokens_total`, `graphorin_provider_cost_usd_total`,\n// `graphorin_redaction_drops_total` and `graphorin_oauth_tokens_freshness_seconds`\n// - had no producer anywhere in the monorepo (per-tool and provider usage live\n// in the agent runtime, not the server; redaction drops in the observability\n// layer; OAuth freshness needs an MCP token store the server does not own). A\n// permanently-empty series is worse than an absent one for dashboards, so they\n// are dropped until a real producer exists rather than advertised inert.\n// W-051 update: tool/MCP telemetry NOW has a producer - the scrape-time\n// `metrics/tools-bridge.ts` sync lazily registers\n// `graphorin_tool_*` / `graphorin_mcp_*` series from the tools package's\n// live counter snapshot, so only series that actually moved ever appear\n// (consistent with IP-15: nothing advertised inert).\nexport const SERVER_METRIC_NAMES = Object.freeze({\n agentRunsTotal: 'graphorin_agent_runs_total',\n agentRunDuration: 'graphorin_agent_run_duration_seconds',\n storageWalSize: 'graphorin_storage_wal_size_bytes',\n idempotencyCacheHitRatio: 'graphorin_idempotency_cache_hit_ratio',\n triggersFiresTotal: 'graphorin_triggers_fires_total',\n consolidatorQueueDepth: 'graphorin_consolidator_queue_depth',\n consolidatorDlqSize: 'graphorin_consolidator_dlq_size',\n consolidatorBudgetRemainingUsd: 'graphorin_consolidator_budget_remaining_usd',\n consolidatorBudgetRemainingTokens: 'graphorin_consolidator_budget_remaining_tokens',\n replayBufferEvents: 'graphorin_replay_buffer_events',\n inflightRuns: 'graphorin_inflight_runs',\n serverUptime: 'graphorin_server_uptime_seconds',\n buildInfo: 'graphorin_build_info',\n} as const);\n\n/**\n * Build a fully-registered {@link MetricRegistry} ready for the\n * `/v1/metrics` exposition. The returned registry has every metric\n * declared but no samples; the server runtime updates samples\n * incrementally.\n *\n * @stable\n */\nexport function createServerMetricRegistry(): MetricRegistry {\n const registry = new MetricRegistry();\n\n registry.registerCounter(\n SERVER_METRIC_NAMES.agentRunsTotal,\n 'Total agent runs by terminal status.',\n ['status'],\n );\n registry.registerSummary(\n SERVER_METRIC_NAMES.agentRunDuration,\n 'Agent run duration in seconds.',\n [],\n );\n registry.registerGauge(SERVER_METRIC_NAMES.storageWalSize, 'Current SQLite WAL size in bytes.');\n registry.registerGauge(\n SERVER_METRIC_NAMES.idempotencyCacheHitRatio,\n 'Idempotency LRU cache hit ratio in [0, 1].',\n );\n registry.registerCounter(\n SERVER_METRIC_NAMES.triggersFiresTotal,\n 'Total trigger fires by trigger id and outcome.',\n ['trigger_id', 'status'],\n );\n registry.registerGauge(\n SERVER_METRIC_NAMES.consolidatorQueueDepth,\n 'Pending consolidator items by phase.',\n ['phase'],\n );\n registry.registerGauge(\n SERVER_METRIC_NAMES.consolidatorDlqSize,\n 'Number of consolidator runs sitting in the dead-letter queue.',\n );\n registry.registerGauge(\n SERVER_METRIC_NAMES.consolidatorBudgetRemainingUsd,\n 'Consolidator USD budget remaining for the current period.',\n );\n registry.registerGauge(\n SERVER_METRIC_NAMES.consolidatorBudgetRemainingTokens,\n 'Consolidator token budget remaining for the current period.',\n );\n registry.registerGauge(\n SERVER_METRIC_NAMES.replayBufferEvents,\n 'Number of events currently buffered for WebSocket replay.',\n );\n registry.registerGauge(\n SERVER_METRIC_NAMES.inflightRuns,\n 'Number of in-flight agent / workflow runs.',\n );\n registry.registerGauge(SERVER_METRIC_NAMES.serverUptime, 'Server process uptime in seconds.');\n registry.registerGauge(\n SERVER_METRIC_NAMES.buildInfo,\n 'Static `1` gauge carrying graphorin build labels.',\n ['version'],\n );\n\n return registry;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AA+BA,MAAa,sBAAsB,OAAO,OAAO;CAC/C,gBAAgB;CAChB,kBAAkB;CAClB,gBAAgB;CAChB,0BAA0B;CAC1B,oBAAoB;CACpB,wBAAwB;CACxB,qBAAqB;CACrB,gCAAgC;CAChC,mCAAmC;CACnC,oBAAoB;CACpB,cAAc;CACd,cAAc;CACd,WAAW;CACZ,CAAU;;;;;;;;;AAUX,SAAgB,6BAA6C;CAC3D,MAAM,WAAW,IAAI,gBAAgB;AAErC,UAAS,gBACP,oBAAoB,gBACpB,wCACA,CAAC,SAAS,CACX;AACD,UAAS,gBACP,oBAAoB,kBACpB,kCACA,EAAE,CACH;AACD,UAAS,cAAc,oBAAoB,gBAAgB,oCAAoC;AAC/F,UAAS,cACP,oBAAoB,0BACpB,6CACD;AACD,UAAS,gBACP,oBAAoB,oBACpB,kDACA,CAAC,cAAc,SAAS,CACzB;AACD,UAAS,cACP,oBAAoB,wBACpB,wCACA,CAAC,QAAQ,CACV;AACD,UAAS,cACP,oBAAoB,qBACpB,gEACD;AACD,UAAS,cACP,oBAAoB,gCACpB,4DACD;AACD,UAAS,cACP,oBAAoB,mCACpB,8DACD;AACD,UAAS,cACP,oBAAoB,oBACpB,4DACD;AACD,UAAS,cACP,oBAAoB,cACpB,6CACD;AACD,UAAS,cAAc,oBAAoB,cAAc,oCAAoC;AAC7F,UAAS,cACP,oBAAoB,WACpB,qDACA,CAAC,UAAU,CACZ;AAED,QAAO"}
@@ -0,0 +1,15 @@
1
+ import { MetricRegistry } from "./registry.js";
2
+ import { CounterSnapshot } from "@graphorin/tools/audit";
3
+
4
+ //#region src/metrics/tools-bridge.d.ts
5
+
6
+ /**
7
+ * Sync the tools-package counter snapshot into `registry`. Idempotent
8
+ * per value: scraping twice without new increments changes nothing.
9
+ *
10
+ * @stable
11
+ */
12
+ declare function syncToolCounters(registry: MetricRegistry, snapshot?: CounterSnapshot): void;
13
+ //#endregion
14
+ export { syncToolCounters };
15
+ //# sourceMappingURL=tools-bridge.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tools-bridge.d.ts","names":[],"sources":["../../src/metrics/tools-bridge.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;iBAqCgB,gBAAA,WACJ,2BACA"}
@@ -0,0 +1,103 @@
1
+ import { snapshotCounters } from "@graphorin/tools/audit";
2
+
3
+ //#region src/metrics/tools-bridge.ts
4
+ /**
5
+ * W-051: bridge the `@graphorin/tools` module-level counter registry
6
+ * (which `@graphorin/mcp` also writes) into the server's
7
+ * {@link MetricRegistry}, so `tool.*` / `mcp.*` telemetry - including
8
+ * the shadow-mode `tool.dataflow.*` counters - shows up on
9
+ * `/v1/metrics` without hand-wiring.
10
+ *
11
+ * Called from `refreshLiveMetrics` on every scrape. Counters are
12
+ * delta-synced (the tools registry is cumulative per process; the
13
+ * Prometheus registry increments by the positive difference, so
14
+ * repeated scrapes never double-count); gauges are set absolutely -
15
+ * the `kinds` field on the snapshot (added for exactly this bridge)
16
+ * tells the two apart. Histograms are deliberately NOT bridged yet:
17
+ * summary bridging needs per-key consumed-observation offsets, and the
18
+ * raw observation lists stay available through `snapshotCounters()`
19
+ * for library users (documented in the observability guide).
20
+ *
21
+ * Naming: `tool.executor.retry.total{toolName=x}` becomes
22
+ * `graphorin_tool_executor_retry_total{toolName="x"}` - `[.-]` map to
23
+ * `_` (the Prometheus name grammar forbids dots), label values pass
24
+ * through the same sanitizer as trigger ids.
25
+ *
26
+ * @packageDocumentation
27
+ */
28
+ const BRIDGED_PREFIXES = ["tool.", "mcp."];
29
+ const PROM_LABEL_NAME_RE = /^[a-zA-Z_][a-zA-Z0-9_]*$/;
30
+ /**
31
+ * Sync the tools-package counter snapshot into `registry`. Idempotent
32
+ * per value: scraping twice without new increments changes nothing.
33
+ *
34
+ * @stable
35
+ */
36
+ function syncToolCounters(registry, snapshot = snapshotCounters()) {
37
+ for (const [key, value] of Object.entries(snapshot.counters)) {
38
+ const parsed = parseCounterKey(key);
39
+ if (parsed === void 0) continue;
40
+ if (!BRIDGED_PREFIXES.some((prefix) => parsed.name.startsWith(prefix))) continue;
41
+ const kind = snapshot.kinds[key] ?? "counter";
42
+ const metricName = toPrometheusName(parsed.name);
43
+ try {
44
+ if (kind === "gauge") {
45
+ registry.registerGauge(metricName, `Bridged from tools counter '${parsed.name}'.`);
46
+ registry.set(metricName, value, parsed.labels);
47
+ } else {
48
+ registry.registerCounter(metricName, `Bridged from tools counter '${parsed.name}'.`);
49
+ const delta = value - readBridgedValue(registry, metricName, parsed.labels);
50
+ if (delta > 0) registry.inc(metricName, parsed.labels, delta);
51
+ }
52
+ } catch {}
53
+ }
54
+ }
55
+ function parseCounterKey(key) {
56
+ const brace = key.indexOf("{");
57
+ if (brace === -1) return {
58
+ name: key,
59
+ labels: {}
60
+ };
61
+ if (!key.endsWith("}")) return void 0;
62
+ const name = key.slice(0, brace);
63
+ const body = key.slice(brace + 1, -1);
64
+ const labels = {};
65
+ for (const pair of body.split(",")) {
66
+ const eq = pair.indexOf("=");
67
+ if (eq <= 0) return void 0;
68
+ const labelName = pair.slice(0, eq);
69
+ if (!PROM_LABEL_NAME_RE.test(labelName)) return void 0;
70
+ labels[labelName] = sanitizeLabelValue(pair.slice(eq + 1));
71
+ }
72
+ return {
73
+ name,
74
+ labels
75
+ };
76
+ }
77
+ function toPrometheusName(name) {
78
+ return `graphorin_${name.replace(/[.-]/g, "_")}`;
79
+ }
80
+ /**
81
+ * Same policy as the trigger-id sanitizer in `app-metrics.ts`: bound
82
+ * the character set and the length so server identities / tool names
83
+ * cannot explode label cardinality with UTF-8 sequences.
84
+ */
85
+ function sanitizeLabelValue(value) {
86
+ return value.replace(/[^A-Za-z0-9_:.\-/]/g, "_").slice(0, 200);
87
+ }
88
+ function readBridgedValue(registry, name, labels) {
89
+ const entries = registry.snapshot().counters[name] ?? [];
90
+ for (const entry of entries) if (labelsEqual(entry.labels, labels)) return entry.value;
91
+ return 0;
92
+ }
93
+ function labelsEqual(a, b) {
94
+ const aKeys = Object.keys(a);
95
+ const bKeys = Object.keys(b);
96
+ if (aKeys.length !== bKeys.length) return false;
97
+ for (const k of bKeys) if (String(a[k]) !== b[k]) return false;
98
+ return true;
99
+ }
100
+
101
+ //#endregion
102
+ export { syncToolCounters };
103
+ //# sourceMappingURL=tools-bridge.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tools-bridge.js","names":["labels: Record<string, string>"],"sources":["../../src/metrics/tools-bridge.ts"],"sourcesContent":["/**\n * W-051: bridge the `@graphorin/tools` module-level counter registry\n * (which `@graphorin/mcp` also writes) into the server's\n * {@link MetricRegistry}, so `tool.*` / `mcp.*` telemetry - including\n * the shadow-mode `tool.dataflow.*` counters - shows up on\n * `/v1/metrics` without hand-wiring.\n *\n * Called from `refreshLiveMetrics` on every scrape. Counters are\n * delta-synced (the tools registry is cumulative per process; the\n * Prometheus registry increments by the positive difference, so\n * repeated scrapes never double-count); gauges are set absolutely -\n * the `kinds` field on the snapshot (added for exactly this bridge)\n * tells the two apart. Histograms are deliberately NOT bridged yet:\n * summary bridging needs per-key consumed-observation offsets, and the\n * raw observation lists stay available through `snapshotCounters()`\n * for library users (documented in the observability guide).\n *\n * Naming: `tool.executor.retry.total{toolName=x}` becomes\n * `graphorin_tool_executor_retry_total{toolName=\"x\"}` - `[.-]` map to\n * `_` (the Prometheus name grammar forbids dots), label values pass\n * through the same sanitizer as trigger ids.\n *\n * @packageDocumentation\n */\n\nimport { type CounterSnapshot, snapshotCounters } from '@graphorin/tools/audit';\nimport type { MetricRegistry } from './registry.js';\n\nconst BRIDGED_PREFIXES = ['tool.', 'mcp.'] as const;\nconst PROM_LABEL_NAME_RE = /^[a-zA-Z_][a-zA-Z0-9_]*$/;\n\n/**\n * Sync the tools-package counter snapshot into `registry`. Idempotent\n * per value: scraping twice without new increments changes nothing.\n *\n * @stable\n */\nexport function syncToolCounters(\n registry: MetricRegistry,\n snapshot: CounterSnapshot = snapshotCounters(),\n): void {\n for (const [key, value] of Object.entries(snapshot.counters)) {\n const parsed = parseCounterKey(key);\n if (parsed === undefined) continue;\n if (!BRIDGED_PREFIXES.some((prefix) => parsed.name.startsWith(prefix))) continue;\n const kind = snapshot.kinds[key] ?? 'counter';\n const metricName = toPrometheusName(parsed.name);\n try {\n if (kind === 'gauge') {\n registry.registerGauge(metricName, `Bridged from tools counter '${parsed.name}'.`);\n registry.set(metricName, value, parsed.labels);\n } else {\n registry.registerCounter(metricName, `Bridged from tools counter '${parsed.name}'.`);\n const current = readBridgedValue(registry, metricName, parsed.labels);\n const delta = value - current;\n if (delta > 0) registry.inc(metricName, parsed.labels, delta);\n }\n } catch {\n // Best-effort: one malformed key (or a name registered by other\n // code with a conflicting kind) must never fail the scrape.\n }\n }\n}\n\n/** Parsed `name{k=v,...}` key in the tools `buildKey` format. */\ninterface ParsedCounterKey {\n readonly name: string;\n readonly labels: Record<string, string>;\n}\n\nfunction parseCounterKey(key: string): ParsedCounterKey | undefined {\n const brace = key.indexOf('{');\n if (brace === -1) return { name: key, labels: {} };\n if (!key.endsWith('}')) return undefined;\n const name = key.slice(0, brace);\n const body = key.slice(brace + 1, -1);\n const labels: Record<string, string> = {};\n for (const pair of body.split(',')) {\n const eq = pair.indexOf('=');\n if (eq <= 0) return undefined;\n const labelName = pair.slice(0, eq);\n if (!PROM_LABEL_NAME_RE.test(labelName)) return undefined;\n labels[labelName] = sanitizeLabelValue(pair.slice(eq + 1));\n }\n return { name, labels };\n}\n\nfunction toPrometheusName(name: string): string {\n return `graphorin_${name.replace(/[.-]/g, '_')}`;\n}\n\n/**\n * Same policy as the trigger-id sanitizer in `app-metrics.ts`: bound\n * the character set and the length so server identities / tool names\n * cannot explode label cardinality with UTF-8 sequences.\n */\nfunction sanitizeLabelValue(value: string): string {\n return value.replace(/[^A-Za-z0-9_:.\\-/]/g, '_').slice(0, 200);\n}\n\nfunction readBridgedValue(\n registry: MetricRegistry,\n name: string,\n labels: Record<string, string>,\n): number {\n const entries = registry.snapshot().counters[name] ?? [];\n for (const entry of entries) {\n if (labelsEqual(entry.labels, labels)) return entry.value;\n }\n return 0;\n}\n\nfunction labelsEqual(\n a: Record<string, string | number | boolean>,\n b: Record<string, string>,\n): boolean {\n const aKeys = Object.keys(a);\n const bKeys = Object.keys(b);\n if (aKeys.length !== bKeys.length) return false;\n for (const k of bKeys) {\n if (String(a[k]) !== b[k]) return false;\n }\n return true;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AA4BA,MAAM,mBAAmB,CAAC,SAAS,OAAO;AAC1C,MAAM,qBAAqB;;;;;;;AAQ3B,SAAgB,iBACd,UACA,WAA4B,kBAAkB,EACxC;AACN,MAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,SAAS,SAAS,EAAE;EAC5D,MAAM,SAAS,gBAAgB,IAAI;AACnC,MAAI,WAAW,OAAW;AAC1B,MAAI,CAAC,iBAAiB,MAAM,WAAW,OAAO,KAAK,WAAW,OAAO,CAAC,CAAE;EACxE,MAAM,OAAO,SAAS,MAAM,QAAQ;EACpC,MAAM,aAAa,iBAAiB,OAAO,KAAK;AAChD,MAAI;AACF,OAAI,SAAS,SAAS;AACpB,aAAS,cAAc,YAAY,+BAA+B,OAAO,KAAK,IAAI;AAClF,aAAS,IAAI,YAAY,OAAO,OAAO,OAAO;UACzC;AACL,aAAS,gBAAgB,YAAY,+BAA+B,OAAO,KAAK,IAAI;IAEpF,MAAM,QAAQ,QADE,iBAAiB,UAAU,YAAY,OAAO,OAAO;AAErE,QAAI,QAAQ,EAAG,UAAS,IAAI,YAAY,OAAO,QAAQ,MAAM;;UAEzD;;;AAaZ,SAAS,gBAAgB,KAA2C;CAClE,MAAM,QAAQ,IAAI,QAAQ,IAAI;AAC9B,KAAI,UAAU,GAAI,QAAO;EAAE,MAAM;EAAK,QAAQ,EAAE;EAAE;AAClD,KAAI,CAAC,IAAI,SAAS,IAAI,CAAE,QAAO;CAC/B,MAAM,OAAO,IAAI,MAAM,GAAG,MAAM;CAChC,MAAM,OAAO,IAAI,MAAM,QAAQ,GAAG,GAAG;CACrC,MAAMA,SAAiC,EAAE;AACzC,MAAK,MAAM,QAAQ,KAAK,MAAM,IAAI,EAAE;EAClC,MAAM,KAAK,KAAK,QAAQ,IAAI;AAC5B,MAAI,MAAM,EAAG,QAAO;EACpB,MAAM,YAAY,KAAK,MAAM,GAAG,GAAG;AACnC,MAAI,CAAC,mBAAmB,KAAK,UAAU,CAAE,QAAO;AAChD,SAAO,aAAa,mBAAmB,KAAK,MAAM,KAAK,EAAE,CAAC;;AAE5D,QAAO;EAAE;EAAM;EAAQ;;AAGzB,SAAS,iBAAiB,MAAsB;AAC9C,QAAO,aAAa,KAAK,QAAQ,SAAS,IAAI;;;;;;;AAQhD,SAAS,mBAAmB,OAAuB;AACjD,QAAO,MAAM,QAAQ,uBAAuB,IAAI,CAAC,MAAM,GAAG,IAAI;;AAGhE,SAAS,iBACP,UACA,MACA,QACQ;CACR,MAAM,UAAU,SAAS,UAAU,CAAC,SAAS,SAAS,EAAE;AACxD,MAAK,MAAM,SAAS,QAClB,KAAI,YAAY,MAAM,QAAQ,OAAO,CAAE,QAAO,MAAM;AAEtD,QAAO;;AAGT,SAAS,YACP,GACA,GACS;CACT,MAAM,QAAQ,OAAO,KAAK,EAAE;CAC5B,MAAM,QAAQ,OAAO,KAAK,EAAE;AAC5B,KAAI,MAAM,WAAW,MAAM,OAAQ,QAAO;AAC1C,MAAK,MAAM,KAAK,MACd,KAAI,OAAO,EAAE,GAAG,KAAK,EAAE,GAAI,QAAO;AAEpC,QAAO"}
@@ -1,6 +1,6 @@
1
1
  import { ServerVariables } from "../internal/context.js";
2
- import { AuditDb, AuditEntryInput } from "@graphorin/security/audit";
3
2
  import { MiddlewareHandler } from "hono";
3
+ import { AuditDb, AuditEntryInput } from "@graphorin/security/audit";
4
4
 
5
5
  //#region src/middleware/audit.d.ts
6
6
 
@@ -1,4 +1,4 @@
1
- import { parseScope } from "@graphorin/security/auth";
1
+ import { parseScope, tryParseScope } from "@graphorin/security/auth";
2
2
 
3
3
  //#region src/middleware/auth.ts
4
4
  /**
@@ -1,5 +1,5 @@
1
- import { randomBytes, timingSafeEqual } from "node:crypto";
2
1
  import { Buffer } from "node:buffer";
2
+ import { randomBytes, timingSafeEqual } from "node:crypto";
3
3
 
4
4
  //#region src/middleware/csrf.ts
5
5
  /**