@warlock.js/devtools 5.55.0 → 5.56.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 (234) hide show
  1. package/CHANGELOG.md +29 -0
  2. package/README.md +26 -13
  3. package/cjs/ai-source-DTpxumMA.cjs +381 -0
  4. package/cjs/ai-source-DTpxumMA.cjs.map +1 -0
  5. package/cjs/auth-DzU0gHDG.cjs +1655 -0
  6. package/cjs/auth-DzU0gHDG.cjs.map +1 -0
  7. package/cjs/boot-BQi0Etor.cjs +138 -0
  8. package/cjs/boot-BQi0Etor.cjs.map +1 -0
  9. package/cjs/capture-CqIiaznN.cjs +1342 -0
  10. package/cjs/capture-CqIiaznN.cjs.map +1 -0
  11. package/cjs/cascade-store-pHjKeSFm.cjs +863 -0
  12. package/cjs/cascade-store-pHjKeSFm.cjs.map +1 -0
  13. package/cjs/collector-CJbQbzzK.cjs +271 -0
  14. package/cjs/collector-CJbQbzzK.cjs.map +1 -0
  15. package/cjs/contracts-CVmplkNb.cjs +112 -0
  16. package/cjs/contracts-CVmplkNb.cjs.map +1 -0
  17. package/cjs/current-request-id-BoJJb3y7.cjs +37 -0
  18. package/cjs/current-request-id-BoJJb3y7.cjs.map +1 -0
  19. package/cjs/errors-CyZp5yS-.cjs +177 -0
  20. package/cjs/errors-CyZp5yS-.cjs.map +1 -0
  21. package/cjs/histogram-BaI-PnCv.cjs +102 -0
  22. package/cjs/histogram-BaI-PnCv.cjs.map +1 -0
  23. package/cjs/http-CabcUwBx.cjs +870 -0
  24. package/cjs/http-CabcUwBx.cjs.map +1 -0
  25. package/cjs/index.cjs +1 -1
  26. package/cjs/insights-BKtqxdnP.cjs +811 -0
  27. package/cjs/insights-BKtqxdnP.cjs.map +1 -0
  28. package/cjs/ip-DbNhPOzi.cjs +153 -0
  29. package/cjs/ip-DbNhPOzi.cjs.map +1 -0
  30. package/cjs/migrations-w7GMsrQw.cjs +297 -0
  31. package/cjs/migrations-w7GMsrQw.cjs.map +1 -0
  32. package/cjs/openapi-CC7OAUc6.cjs +52 -0
  33. package/cjs/openapi-CC7OAUc6.cjs.map +1 -0
  34. package/cjs/options-CWqFC5__.cjs +181 -0
  35. package/cjs/options-CWqFC5__.cjs.map +1 -0
  36. package/cjs/panels-B0dAfGbJ.cjs +298 -0
  37. package/cjs/panels-B0dAfGbJ.cjs.map +1 -0
  38. package/cjs/process-panel-DEOnLxoT.cjs +48 -0
  39. package/cjs/process-panel-DEOnLxoT.cjs.map +1 -0
  40. package/cjs/production/index.cjs +238 -0
  41. package/cjs/production/index.cjs.map +1 -0
  42. package/cjs/rolldown-runtime-Zuuoy_Rh.cjs +52 -0
  43. package/cjs/server-B6xdeKS8.cjs +184 -0
  44. package/cjs/server-B6xdeKS8.cjs.map +1 -0
  45. package/cjs/{src-Xwm3Eel9.cjs → src-Ce-3Lniv.cjs} +163 -295
  46. package/cjs/src-Ce-3Lniv.cjs.map +1 -0
  47. package/cjs/store-aq207T8v.cjs +9 -0
  48. package/cjs/stream-route-BGJa-zQu.cjs +875 -0
  49. package/cjs/stream-route-BGJa-zQu.cjs.map +1 -0
  50. package/esm/devtools-connector.d.mts +16 -13
  51. package/esm/devtools-connector.d.mts.map +1 -1
  52. package/esm/devtools-connector.mjs +127 -18
  53. package/esm/devtools-connector.mjs.map +1 -1
  54. package/esm/index.d.mts +3 -2
  55. package/esm/options.mjs +2 -1
  56. package/esm/options.mjs.map +1 -1
  57. package/esm/panels.mjs +50 -5
  58. package/esm/panels.mjs.map +1 -1
  59. package/esm/production/auth/common-passwords.mjs +303 -0
  60. package/esm/production/auth/common-passwords.mjs.map +1 -0
  61. package/esm/production/auth/default-crypto.mjs +19 -0
  62. package/esm/production/auth/default-crypto.mjs.map +1 -0
  63. package/esm/production/auth/helpers.mjs +77 -0
  64. package/esm/production/auth/helpers.mjs.map +1 -0
  65. package/esm/production/auth/index.mjs +6 -0
  66. package/esm/production/auth/passkeys.mjs +96 -0
  67. package/esm/production/auth/passkeys.mjs.map +1 -0
  68. package/esm/production/auth/service.mjs +1166 -0
  69. package/esm/production/auth/service.mjs.map +1 -0
  70. package/esm/production/boot.mjs +138 -0
  71. package/esm/production/boot.mjs.map +1 -0
  72. package/esm/production/capture/dev-stats.mjs +83 -0
  73. package/esm/production/capture/dev-stats.mjs.map +1 -0
  74. package/esm/production/capture/engine.mjs +442 -0
  75. package/esm/production/capture/engine.mjs.map +1 -0
  76. package/esm/production/capture/explain.mjs +271 -0
  77. package/esm/production/capture/explain.mjs.map +1 -0
  78. package/esm/production/capture/filter.mjs +24 -0
  79. package/esm/production/capture/filter.mjs.map +1 -0
  80. package/esm/production/capture/index.mjs +7 -0
  81. package/esm/production/capture/production-capture.mjs +134 -0
  82. package/esm/production/capture/production-capture.mjs.map +1 -0
  83. package/esm/production/capture/redact.mjs +109 -0
  84. package/esm/production/capture/redact.mjs.map +1 -0
  85. package/esm/production/capture/stats-stores.mjs +300 -0
  86. package/esm/production/capture/stats-stores.mjs.map +1 -0
  87. package/esm/production/cli/actions.mjs +151 -0
  88. package/esm/production/cli/actions.mjs.map +1 -0
  89. package/esm/production/cli/index.d.mts +17 -0
  90. package/esm/production/cli/index.d.mts.map +1 -0
  91. package/esm/production/cli/index.mjs +86 -0
  92. package/esm/production/cli/index.mjs.map +1 -0
  93. package/esm/production/contracts.d.mts +592 -0
  94. package/esm/production/contracts.d.mts.map +1 -0
  95. package/esm/production/contracts.mjs +95 -0
  96. package/esm/production/contracts.mjs.map +1 -0
  97. package/esm/production/errors.d.mts +31 -0
  98. package/esm/production/errors.d.mts.map +1 -0
  99. package/esm/production/errors.mjs +142 -0
  100. package/esm/production/errors.mjs.map +1 -0
  101. package/esm/production/http/access.mjs +124 -0
  102. package/esm/production/http/access.mjs.map +1 -0
  103. package/esm/production/http/auth-routes.mjs +280 -0
  104. package/esm/production/http/auth-routes.mjs.map +1 -0
  105. package/esm/production/http/client.mjs +57 -0
  106. package/esm/production/http/client.mjs.map +1 -0
  107. package/esm/production/http/constants.mjs +11 -0
  108. package/esm/production/http/constants.mjs.map +1 -0
  109. package/esm/production/http/context.mjs +14 -0
  110. package/esm/production/http/context.mjs.map +1 -0
  111. package/esm/production/http/cookie.mjs +39 -0
  112. package/esm/production/http/cookie.mjs.map +1 -0
  113. package/esm/production/http/headers.mjs +25 -0
  114. package/esm/production/http/headers.mjs.map +1 -0
  115. package/esm/production/http/index.mjs +10 -0
  116. package/esm/production/http/ip.mjs +130 -0
  117. package/esm/production/http/ip.mjs.map +1 -0
  118. package/esm/production/http/mount.mjs +300 -0
  119. package/esm/production/http/mount.mjs.map +1 -0
  120. package/esm/production/http/state.mjs +54 -0
  121. package/esm/production/http/state.mjs.map +1 -0
  122. package/esm/production/index.d.mts +6 -0
  123. package/esm/production/index.mjs +5 -0
  124. package/esm/production/insights/cap-report.mjs +67 -0
  125. package/esm/production/insights/cap-report.mjs.map +1 -0
  126. package/esm/production/insights/health.mjs +88 -0
  127. package/esm/production/insights/health.mjs.map +1 -0
  128. package/esm/production/insights/index.mjs +10 -0
  129. package/esm/production/insights/insights.mjs +167 -0
  130. package/esm/production/insights/insights.mjs.map +1 -0
  131. package/esm/production/insights/instance.mjs +24 -0
  132. package/esm/production/insights/instance.mjs.map +1 -0
  133. package/esm/production/insights/jobs.mjs +100 -0
  134. package/esm/production/insights/jobs.mjs.map +1 -0
  135. package/esm/production/insights/reporter.mjs +59 -0
  136. package/esm/production/insights/reporter.mjs.map +1 -0
  137. package/esm/production/insights/resources.mjs +139 -0
  138. package/esm/production/insights/resources.mjs.map +1 -0
  139. package/esm/production/insights/writer.mjs +72 -0
  140. package/esm/production/insights/writer.mjs.map +1 -0
  141. package/esm/production/openapi.mjs +52 -0
  142. package/esm/production/openapi.mjs.map +1 -0
  143. package/esm/production/options.d.mts +60 -0
  144. package/esm/production/options.d.mts.map +1 -0
  145. package/esm/production/options.mjs +170 -0
  146. package/esm/production/options.mjs.map +1 -0
  147. package/esm/production/stats/histogram.mjs +67 -0
  148. package/esm/production/stats/histogram.mjs.map +1 -0
  149. package/esm/production/stats/merge.mjs +106 -0
  150. package/esm/production/stats/merge.mjs.map +1 -0
  151. package/esm/production/store/cascade-store.mjs +322 -0
  152. package/esm/production/store/cascade-store.mjs.map +1 -0
  153. package/esm/production/store/index.mjs +5 -0
  154. package/esm/production/store/mapping.mjs +258 -0
  155. package/esm/production/store/mapping.mjs.map +1 -0
  156. package/esm/production/store/memory-store.mjs +291 -0
  157. package/esm/production/store/memory-store.mjs.map +1 -0
  158. package/esm/production/store/migrations.d.mts +11 -0
  159. package/esm/production/store/migrations.d.mts.map +1 -0
  160. package/esm/production/store/migrations.mjs +29 -0
  161. package/esm/production/store/migrations.mjs.map +1 -0
  162. package/esm/production/store/models/account.migration.mjs +34 -0
  163. package/esm/production/store/models/account.migration.mjs.map +1 -0
  164. package/esm/production/store/models/account.model.mjs +13 -0
  165. package/esm/production/store/models/account.model.mjs.map +1 -0
  166. package/esm/production/store/models/audit.migration.mjs +30 -0
  167. package/esm/production/store/models/audit.migration.mjs.map +1 -0
  168. package/esm/production/store/models/audit.model.mjs +13 -0
  169. package/esm/production/store/models/audit.model.mjs.map +1 -0
  170. package/esm/production/store/models/base.mjs +27 -0
  171. package/esm/production/store/models/base.mjs.map +1 -0
  172. package/esm/production/store/models/index.mjs +17 -0
  173. package/esm/production/store/models/invite.migration.mjs +26 -0
  174. package/esm/production/store/models/invite.migration.mjs.map +1 -0
  175. package/esm/production/store/models/invite.model.mjs +13 -0
  176. package/esm/production/store/models/invite.model.mjs.map +1 -0
  177. package/esm/production/store/models/report.migration.mjs +20 -0
  178. package/esm/production/store/models/report.migration.mjs.map +1 -0
  179. package/esm/production/store/models/report.model.mjs +13 -0
  180. package/esm/production/store/models/report.model.mjs.map +1 -0
  181. package/esm/production/store/models/sample.migration.mjs +25 -0
  182. package/esm/production/store/models/sample.migration.mjs.map +1 -0
  183. package/esm/production/store/models/sample.model.mjs +13 -0
  184. package/esm/production/store/models/sample.model.mjs.map +1 -0
  185. package/esm/production/store/models/session.migration.mjs +31 -0
  186. package/esm/production/store/models/session.migration.mjs.map +1 -0
  187. package/esm/production/store/models/session.model.mjs +13 -0
  188. package/esm/production/store/models/session.model.mjs.map +1 -0
  189. package/esm/production/store/models/state.migration.mjs +26 -0
  190. package/esm/production/store/models/state.migration.mjs.map +1 -0
  191. package/esm/production/store/models/state.model.mjs +13 -0
  192. package/esm/production/store/models/state.model.mjs.map +1 -0
  193. package/esm/query-shape.mjs +14 -1
  194. package/esm/query-shape.mjs.map +1 -1
  195. package/esm/server/explain-route.mjs +26 -1
  196. package/esm/server/explain-route.mjs.map +1 -1
  197. package/esm/server/index.mjs +9 -4
  198. package/esm/server/index.mjs.map +1 -1
  199. package/esm/server/insights-routes.mjs +62 -0
  200. package/esm/server/insights-routes.mjs.map +1 -0
  201. package/esm/server/log-routes.mjs +32 -5
  202. package/esm/server/log-routes.mjs.map +1 -1
  203. package/esm/server/openapi-routes.mjs +3 -2
  204. package/esm/server/openapi-routes.mjs.map +1 -1
  205. package/esm/server/requests-routes.mjs +125 -0
  206. package/esm/server/requests-routes.mjs.map +1 -1
  207. package/esm/server/session-routes.mjs +42 -0
  208. package/esm/server/session-routes.mjs.map +1 -0
  209. package/esm/server/stream-route.mjs +81 -11
  210. package/esm/server/stream-route.mjs.map +1 -1
  211. package/esm/server/ui-assets.mjs +34 -25
  212. package/esm/server/ui-assets.mjs.map +1 -1
  213. package/esm/sources/log-source.mjs +14 -1
  214. package/esm/sources/log-source.mjs.map +1 -1
  215. package/esm/types.d.mts +202 -1
  216. package/esm/types.d.mts.map +1 -1
  217. package/esm/ui-root.mjs +9 -4
  218. package/esm/ui-root.mjs.map +1 -1
  219. package/llms-full.txt +159 -21
  220. package/llms.txt +2 -2
  221. package/package.json +32 -8
  222. package/skills/SKILL.md +159 -21
  223. package/ui/dashboard/assets/app.css +3 -0
  224. package/ui/dashboard/assets/app.js +50 -0
  225. package/ui/dashboard/build-info.json +21 -0
  226. package/ui/dashboard/index.html +15 -0
  227. package/cjs/ai-source-Dz_3tlZ5.cjs +0 -703
  228. package/cjs/ai-source-Dz_3tlZ5.cjs.map +0 -1
  229. package/cjs/server-B11ShQYE.cjs +0 -628
  230. package/cjs/server-B11ShQYE.cjs.map +0 -1
  231. package/cjs/src-Xwm3Eel9.cjs.map +0 -1
  232. package/ui/app.css +0 -376
  233. package/ui/app.js +0 -1158
  234. package/ui/index.html +0 -28
@@ -0,0 +1,592 @@
1
+ //#region ../../packages/devtools/src/production/contracts.d.ts
2
+ /**
3
+ * The contracts of the devtools production monitor: the shapes the server
4
+ * stores, the JSON its API returns, and the few constants both sides share.
5
+ *
6
+ * This file has NO imports, so the dashboard (`ui-src/`) can import its types
7
+ * too. Every timestamp is epoch milliseconds, every duration milliseconds,
8
+ * every size bytes. Absent values are `null`, never missing.
9
+ */
10
+ /** Where the dashboard runs: the loopback development dashboard or the signed-in production monitor. */
11
+ export type DevtoolsMode = "development" | "production";
12
+ /** What an account may do: `admin` manages users and the dashboard, `viewer` reads. */
13
+ export type DevtoolsRole = "admin" | "viewer";
14
+ /**
15
+ * Where a browser session stands. Only `active` reaches the data routes;
16
+ * every other stage reaches only the sign-in steps it needs next.
17
+ */
18
+ export type DevtoolsSessionStage = "signed-out" | "password-change" | "mfa-enrol" | "mfa-verify" | "active";
19
+ /** How an account's current password was set. `env` and `reset` passwords must be changed at the next sign-in. */
20
+ export type DevtoolsPasswordSource = "env" | "setup" | "invite" | "user" | "reset";
21
+ /** One process that runs the monitor (a pm2 or cluster worker, a container). */
22
+ export type DevtoolsInstanceInfo = {
23
+ /** Stable for the life of the process: `<host>:<pid>:<start time base36>`. */
24
+ id: string;
25
+ /** What the dashboard shows: `<host> #<worker>` or `<host> pid <pid>`. */
26
+ label: string;
27
+ host: string;
28
+ pid: number;
29
+ /** pm2's `NODE_APP_INSTANCE` / `pm_id`, or the cluster worker id; `null` when neither is set. */
30
+ worker: string | null;
31
+ startedAt: number;
32
+ /** When the instance last wrote its report (the current time for the instance answering). */
33
+ seenAt: number;
34
+ nodeVersion: string;
35
+ };
36
+ /**
37
+ * Upper bounds (inclusive, ms) of the latency buckets every histogram uses.
38
+ * A histogram's `counts` has one more entry than this list: the last entry
39
+ * counts everything above the highest bound. Fixed bounds make histograms
40
+ * from several instances merge exactly.
41
+ */
42
+ export declare const DEVTOOLS_LATENCY_BUCKETS_MS: readonly [1, 2, 5, 10, 25, 50, 100, 250, 500, 1000, 2500, 5000, 10000, 30000];
43
+ /** A latency histogram over `DEVTOOLS_LATENCY_BUCKETS_MS`. */
44
+ export type DevtoolsHistogram = {
45
+ /** `DEVTOOLS_LATENCY_BUCKETS_MS.length + 1` entries. */
46
+ counts: number[];
47
+ count: number;
48
+ sumMs: number;
49
+ maxMs: number;
50
+ };
51
+ /** Statistics for one normalized query shape (literals and bindings replaced by `?`). */
52
+ export type DevtoolsQueryShapeStats = {
53
+ /** First 16 hex characters of the SHA-256 of `shape`; the id the API and EXPLAIN use. */
54
+ id: string;
55
+ /** The normalized query, at most 2000 characters. Never holds a value. */
56
+ shape: string;
57
+ driver: "postgres" | "mongodb";
58
+ connection: string;
59
+ count: number;
60
+ errors: number;
61
+ histogram: DevtoolsHistogram;
62
+ /** Sampled requests in which this shape reached the N+1 threshold, and the highest count in one request. */
63
+ nPlusOne: {
64
+ requests: number;
65
+ maxPerRequest: number;
66
+ };
67
+ /** The slowest run seen; its values stay in the process that ran it (see EXPLAIN). */
68
+ slowest: {
69
+ durationMs: number;
70
+ at: number;
71
+ route: string | null;
72
+ requestId: string | null;
73
+ instance: string;
74
+ } | null;
75
+ firstSeen: number;
76
+ lastSeen: number;
77
+ /** Whether EXPLAIN can run for this shape (a Postgres `SELECT`/`WITH`, or a MongoDB `find`/`aggregate`/`count`). */
78
+ explainable: boolean;
79
+ };
80
+ /** Time spent in one named request phase (middleware, validation, handler, …) on one route. */
81
+ export type DevtoolsRoutePhaseStats = {
82
+ name: string;
83
+ count: number;
84
+ sumMs: number;
85
+ maxMs: number;
86
+ };
87
+ /** Statistics for one route pattern and method. */
88
+ export type DevtoolsRouteStats = {
89
+ /** `"<METHOD> <route pattern>"`, e.g. `"GET /posts/:slug"`. */
90
+ key: string;
91
+ method: string;
92
+ route: string;
93
+ count: number;
94
+ /** Responses with a 5xx status or a thrown error. */
95
+ errors: number;
96
+ histogram: DevtoolsHistogram;
97
+ /** At most 30 phases, slowest total first. */
98
+ phases: DevtoolsRoutePhaseStats[];
99
+ slowest: {
100
+ durationMs: number;
101
+ at: number;
102
+ requestId: string | null;
103
+ instance: string;
104
+ } | null;
105
+ };
106
+ /** Errors grouped by fingerprint (normalized message + route + source). */
107
+ export type DevtoolsErrorGroup = {
108
+ /** First 16 hex characters of the SHA-256 of the fingerprint. */
109
+ id: string;
110
+ /** The latest message as raised, at most 500 characters. */
111
+ message: string;
112
+ /** The error class name when known (`TypeError`). */
113
+ name: string | null;
114
+ source: "request" | "log";
115
+ route: string | null;
116
+ status: number | null;
117
+ count: number;
118
+ firstSeen: number;
119
+ lastSeen: number;
120
+ lastRequestId: string | null;
121
+ /** The latest stack, at most 4000 characters; `null` when none was available. */
122
+ stack: string | null;
123
+ };
124
+ /** A warn/error log entry kept for the Logs panel in production (no context: it may hold values). */
125
+ export type DevtoolsReportLogEntry = {
126
+ level: "debug" | "info" | "warn" | "error" | "success";
127
+ module: string;
128
+ action: string;
129
+ /** At most 1000 characters. */
130
+ message: string;
131
+ at: number;
132
+ requestId: string | null;
133
+ };
134
+ /** One resource reading of a process. */
135
+ export type DevtoolsResourcePoint = {
136
+ at: number;
137
+ rssBytes: number;
138
+ heapUsedBytes: number;
139
+ heapTotalBytes: number;
140
+ externalBytes: number;
141
+ /** Process CPU time over wall time since the previous point, 0–100 per core (can exceed 100). */
142
+ cpuPercent: number;
143
+ eventLoopDelayP50Ms: number;
144
+ eventLoopDelayP99Ms: number;
145
+ eventLoopDelayMaxMs: number;
146
+ /** `performance.eventLoopUtilization()` since the previous point, 0–1. */
147
+ eventLoopUtilization: number;
148
+ /** Garbage collections since the previous point. */
149
+ gcCount: number;
150
+ /** Total GC pause since the previous point. */
151
+ gcPauseMs: number;
152
+ };
153
+ /** The latest resource reading plus values that change rarely. */
154
+ export type DevtoolsResourceSnapshot = DevtoolsResourcePoint & {
155
+ heapLimitBytes: number;
156
+ uptimeSeconds: number;
157
+ /** Totals since the monitor started, by GC kind. */
158
+ gcByKind: Record<"minor" | "major" | "incremental" | "weakcb", {
159
+ count: number;
160
+ pauseMs: number;
161
+ }>;
162
+ };
163
+ /** Readiness checks (core's `health` registry) of one process, with a short history. */
164
+ export type DevtoolsHealthReport = {
165
+ status: "ok" | "error" | "unknown";
166
+ checkedAt: number | null;
167
+ checks: Record<string, boolean>;
168
+ /** Newest last, at most 60 entries. */
169
+ history: {
170
+ at: number;
171
+ status: "ok" | "error";
172
+ failed: string[];
173
+ }[];
174
+ };
175
+ /** One scheduled job (`@warlock.js/scheduler`). */
176
+ export type DevtoolsScheduleInfo = {
177
+ name: string;
178
+ /** The cron expression, or `null` for an interval schedule. */
179
+ cron: string | null;
180
+ /** A readable interval such as `"every 5 minutes"`, or `null`. */
181
+ interval: string | null;
182
+ isRunning: boolean;
183
+ lastRunAt: number | null;
184
+ nextRunAt: number | null;
185
+ lastDurationMs: number | null;
186
+ lastError: string | null;
187
+ runs: number;
188
+ failures: number;
189
+ };
190
+ /** Background work of one process: schedules and queue counts, each `available: false` when its package is not installed. */
191
+ export type DevtoolsJobsReport = {
192
+ available: {
193
+ scheduler: boolean;
194
+ queue: boolean;
195
+ };
196
+ schedules: DevtoolsScheduleInfo[];
197
+ /** Job counts per queue and state (`waiting`, `active`, `delayed`, `failed`, `completed`). */
198
+ queues: {
199
+ name: string;
200
+ counts: Record<string, number>;
201
+ }[];
202
+ };
203
+ /** What the capture did since the process started. */
204
+ export type DevtoolsCaptureCounters = {
205
+ sampleRate: number;
206
+ requests: number;
207
+ sampled: number;
208
+ /** Unsampled requests kept as a summary because they were slow or failed. */
209
+ keptUnsampled: number;
210
+ /** Samples written to the database. */
211
+ stored: number;
212
+ /** Samples not written because the per-minute budget was spent. */
213
+ droppedStored: number;
214
+ /** Query shapes, routes and error groups evicted to keep memory bounded. */
215
+ evictedShapes: number;
216
+ evictedRoutes: number;
217
+ evictedErrors: number;
218
+ /** Queries not kept inside a sampled request because it reached its per-request limit. */
219
+ droppedQueries: number;
220
+ };
221
+ /**
222
+ * Everything one process reports, written to the database every
223
+ * `reportIntervalMs` (one row per instance) and merged by the dashboard.
224
+ * Serialized it stays under 256 KB: lists are trimmed from the end.
225
+ */
226
+ export type DevtoolsInstanceReport = {
227
+ instance: DevtoolsInstanceInfo;
228
+ at: number;
229
+ resources: {
230
+ snapshot: DevtoolsResourceSnapshot;
231
+ history: DevtoolsResourcePoint[];
232
+ };
233
+ /** At most 200, highest total time first. */
234
+ queries: DevtoolsQueryShapeStats[];
235
+ /** At most 200, highest total time first. */
236
+ routes: DevtoolsRouteStats[];
237
+ /** At most 50, newest first. */
238
+ errors: DevtoolsErrorGroup[];
239
+ /** At most 50, newest first. */
240
+ logs: DevtoolsReportLogEntry[];
241
+ health: DevtoolsHealthReport;
242
+ jobs: DevtoolsJobsReport;
243
+ capture: DevtoolsCaptureCounters;
244
+ };
245
+ /**
246
+ * A request row. Matches the development `DevtoolsRequestSummary` field for
247
+ * field, plus where it was captured.
248
+ */
249
+ export type DevtoolsSampleSummary = {
250
+ id: string;
251
+ method: string;
252
+ path: string;
253
+ route?: string;
254
+ status?: number;
255
+ startedAt: number;
256
+ durationMs?: number;
257
+ queryCount: number;
258
+ warningCount: number;
259
+ /** Read from the persisted request log only. */
260
+ persisted?: true;
261
+ /** The instance that served the request. */
262
+ instance?: string;
263
+ /** Kept because it was slow or failed, without a timeline (the request was not sampled). */
264
+ partial?: true;
265
+ };
266
+ /** A query inside a stored sample: the shape only, never the SQL text with values or the bindings. */
267
+ export type DevtoolsSampleQuery = {
268
+ id: string;
269
+ connection: string;
270
+ driver: "postgres" | "mongodb";
271
+ /** Same as `shape`: kept under this name so the request view renders it like a development query. */
272
+ sql?: string;
273
+ collection?: string;
274
+ command?: string;
275
+ shape: string;
276
+ shapeId: string;
277
+ startedAt: number;
278
+ durationMs: number;
279
+ rowCount?: number;
280
+ error?: string;
281
+ };
282
+ /** The timeline of a sampled request, with every value removed (see the redaction rules). */
283
+ export type DevtoolsSampleDetail = DevtoolsSampleSummary & {
284
+ error?: string;
285
+ phases: {
286
+ name: string;
287
+ startedAt: number;
288
+ durationMs: number;
289
+ }[];
290
+ queries: DevtoolsSampleQuery[];
291
+ /** Cache operation counts only; keys are not kept. */
292
+ cache: {
293
+ hits: number;
294
+ misses: number;
295
+ writes: number;
296
+ };
297
+ /** Log entries without context. */
298
+ logs: {
299
+ level: string;
300
+ module: string;
301
+ action: string;
302
+ message: string;
303
+ at: number;
304
+ }[];
305
+ warnings: {
306
+ type: "n+1";
307
+ message: string;
308
+ shape: string;
309
+ count: number;
310
+ }[];
311
+ /** Queries left out because the request reached `maxQueriesPerRequest`. */
312
+ droppedQueries: number;
313
+ };
314
+ /** `GET api/instances`. */
315
+ export type DevtoolsInstancesView = {
316
+ /** The instance that answered this request. */
317
+ current: string;
318
+ /** Instances seen in the last 5 minutes (the answering one included), newest first. */
319
+ instances: DevtoolsInstanceInfo[];
320
+ };
321
+ /** `GET api/resources?instance=<id|all>`. */
322
+ export type DevtoolsResourcesView = {
323
+ instances: {
324
+ instance: DevtoolsInstanceInfo;
325
+ snapshot: DevtoolsResourceSnapshot;
326
+ history: DevtoolsResourcePoint[];
327
+ }[];
328
+ };
329
+ /** A shape row with figures computed from its histogram. */
330
+ export type DevtoolsQueryShapeRow = DevtoolsQueryShapeStats & {
331
+ p50Ms: number;
332
+ p95Ms: number;
333
+ meanMs: number;
334
+ /** Ids of the instances that reported this shape. */
335
+ instances: string[];
336
+ };
337
+ /** `GET api/queries/stats?instance=&sort=total|p95|count|n+1&limit=`. */
338
+ export type DevtoolsQueryStatsView = {
339
+ shapes: DevtoolsQueryShapeRow[];
340
+ /** The sample rate the counts come from; counts are of sampled requests only. */
341
+ sampleRate: number;
342
+ instanceCount: number;
343
+ evicted: number;
344
+ };
345
+ /** A route row with figures computed from its histogram. */
346
+ export type DevtoolsRouteStatsRow = DevtoolsRouteStats & {
347
+ p50Ms: number;
348
+ p95Ms: number;
349
+ meanMs: number;
350
+ instances: string[];
351
+ };
352
+ /** `GET api/routes/stats?instance=&sort=total|p95|count|errors&limit=`. */
353
+ export type DevtoolsRouteStatsView = {
354
+ routes: DevtoolsRouteStatsRow[];
355
+ sampleRate: number;
356
+ instanceCount: number;
357
+ };
358
+ /** `GET api/health?instance=`. */
359
+ export type DevtoolsHealthView = {
360
+ instances: {
361
+ instance: DevtoolsInstanceInfo;
362
+ report: DevtoolsHealthReport;
363
+ }[];
364
+ };
365
+ /** `GET api/errors?instance=&limit=`. */
366
+ export type DevtoolsErrorsView = {
367
+ groups: (DevtoolsErrorGroup & {
368
+ instances: string[];
369
+ })[];
370
+ };
371
+ /**
372
+ * One row of `GET api/logs?level=&module=&instance=` (newest first), in both
373
+ * modes. Development rows carry `context` and no `instance`; production rows
374
+ * carry `instance` and never `context`.
375
+ */
376
+ export type DevtoolsLogRow = DevtoolsReportLogEntry & {
377
+ instance: string | null;
378
+ context?: unknown;
379
+ };
380
+ /** `GET api/logs`: the rows, newest first (a plain array, as in 5.55). */
381
+ export type DevtoolsLogsView = DevtoolsLogRow[];
382
+ /** `GET api/jobs?instance=`. */
383
+ export type DevtoolsJobsView = {
384
+ instances: {
385
+ instance: DevtoolsInstanceInfo;
386
+ report: DevtoolsJobsReport;
387
+ }[];
388
+ };
389
+ /** `POST api/queries/:shapeId/explain`. */
390
+ export type DevtoolsExplainResult = {
391
+ shapeId: string;
392
+ driver: "postgres" | "mongodb";
393
+ /** `true` only when the project allows executing plans (`explain.executing`). */
394
+ executing: boolean;
395
+ plan: unknown;
396
+ /** The instance whose example ran the EXPLAIN. */
397
+ instance: string;
398
+ };
399
+ /** One dashboard tab, as `GET api/panels` lists it (enabled tabs only, in display order). */
400
+ export type DevtoolsPanelInfo = {
401
+ id: string;
402
+ title: string;
403
+ /** `built-in` tabs are React views in the bundle; `package` tabs load `panels/<id>/view.js`. */
404
+ type: "built-in" | "package";
405
+ };
406
+ /**
407
+ * The built-in tabs, in display order, with whether production shows them
408
+ * when the project says nothing (`production.panels` overrides per id).
409
+ */
410
+ export declare const DEVTOOLS_BUILT_IN_PANELS: readonly [{
411
+ readonly id: "requests";
412
+ readonly title: "Requests";
413
+ readonly production: true;
414
+ }, {
415
+ readonly id: "queries";
416
+ readonly title: "Queries";
417
+ readonly production: true;
418
+ }, {
419
+ readonly id: "routes";
420
+ readonly title: "Routes";
421
+ readonly production: true;
422
+ }, {
423
+ readonly id: "resources";
424
+ readonly title: "Resources";
425
+ readonly production: true;
426
+ }, {
427
+ readonly id: "health";
428
+ readonly title: "Health";
429
+ readonly production: true;
430
+ }, {
431
+ readonly id: "errors";
432
+ readonly title: "Errors";
433
+ readonly production: true;
434
+ }, {
435
+ readonly id: "logs";
436
+ readonly title: "Logs";
437
+ readonly production: true;
438
+ }, {
439
+ readonly id: "jobs";
440
+ readonly title: "Jobs";
441
+ readonly production: true;
442
+ }, {
443
+ readonly id: "mail";
444
+ readonly title: "Mail";
445
+ readonly production: false;
446
+ }, {
447
+ readonly id: "ai";
448
+ readonly title: "AI";
449
+ readonly production: false;
450
+ }, {
451
+ readonly id: "agents";
452
+ readonly title: "Agents";
453
+ readonly production: false;
454
+ }, {
455
+ readonly id: "api";
456
+ readonly title: "API";
457
+ readonly production: false;
458
+ }];
459
+ /** The id of a built-in tab. */
460
+ export type DevtoolsBuiltInPanelId = (typeof DEVTOOLS_BUILT_IN_PANELS)[number]["id"];
461
+ /** An account as the API shows it (never a hash or a secret). */
462
+ export type DevtoolsAccountView = {
463
+ id: string;
464
+ email: string;
465
+ role: DevtoolsRole;
466
+ twoFactor: {
467
+ totp: boolean;
468
+ passkeys: {
469
+ id: string;
470
+ name: string;
471
+ createdAt: number;
472
+ lastUsedAt: number | null;
473
+ }[];
474
+ recoveryCodesLeft: number;
475
+ };
476
+ mustChangePassword: boolean;
477
+ createdAt: number;
478
+ lastLoginAt: number | null;
479
+ };
480
+ /** `GET api/auth/session`: who is signed in and what comes next. */
481
+ export type DevtoolsSessionView = {
482
+ mode: DevtoolsMode;
483
+ stage: DevtoolsSessionStage;
484
+ /** `null` when signed out, and in development (no accounts there). */
485
+ account: DevtoolsAccountView | null;
486
+ /** `admin` in development; `null` when signed out. */
487
+ role: DevtoolsRole | null;
488
+ /** The token to send as `X-Devtools-Csrf` on every POST/PUT/PATCH/DELETE; `null` when signed out and in development. */
489
+ csrf: string | null;
490
+ /** When the session ends at the latest; `null` when signed out and in development. */
491
+ expiresAt: number | null;
492
+ /** The instance that answered; `null` when signed out. */
493
+ instance: DevtoolsInstanceInfo | null;
494
+ /** Sign-in methods the server offers; `null` when signed out. */
495
+ methods: {
496
+ totp: true;
497
+ passkeys: boolean;
498
+ } | null;
499
+ };
500
+ /** `POST api/auth/login` body. */
501
+ export type DevtoolsLoginInput = {
502
+ email: string;
503
+ password: string;
504
+ };
505
+ /** Answer of every sign-in step: the next stage, and the new CSRF token when the session changed. */
506
+ export type DevtoolsAuthStepResult = {
507
+ stage: DevtoolsSessionStage;
508
+ csrf: string | null;
509
+ };
510
+ /** `POST api/auth/totp/start` (and `api/account/totp/start`). */
511
+ export type DevtoolsTotpEnrolment = {
512
+ /** Base32, for manual entry. */
513
+ secret: string;
514
+ /** `otpauth://totp/...`, rendered as a QR code by the dashboard. */
515
+ uri: string;
516
+ issuer: string;
517
+ account: string;
518
+ };
519
+ /** Recovery codes, shown once. */
520
+ export type DevtoolsRecoveryCodes = {
521
+ codes: string[];
522
+ };
523
+ /** A pending or used invite. */
524
+ export type DevtoolsInviteView = {
525
+ id: string;
526
+ email: string;
527
+ role: DevtoolsRole;
528
+ createdAt: number;
529
+ expiresAt: number;
530
+ createdBy: string | null;
531
+ usedAt: number | null;
532
+ };
533
+ /** `POST api/admin/invites`: the token appears only in this answer. */
534
+ export type DevtoolsCreatedInvite = {
535
+ invite: DevtoolsInviteView;
536
+ token: string;
537
+ };
538
+ /** `GET api/admin/users`. */
539
+ export type DevtoolsUserListView = {
540
+ accounts: DevtoolsAccountView[];
541
+ invites: DevtoolsInviteView[];
542
+ };
543
+ /** A session as its owner sees it (`GET api/account/sessions`). */
544
+ export type DevtoolsSessionInfo = {
545
+ id: string;
546
+ current: boolean;
547
+ createdAt: number;
548
+ lastSeenAt: number;
549
+ expiresAt: number;
550
+ ip: string | null;
551
+ userAgent: string | null;
552
+ };
553
+ /** Every audited event. `login.failed` and `mfa.failed` are the ones rate limits count. */
554
+ export type DevtoolsAuditType = "admin.seeded" | "admin.reset" | "setup.completed" | "login.succeeded" | "login.failed" | "login.blocked" | "mfa.succeeded" | "mfa.failed" | "mfa.enrolled" | "mfa.removed" | "recovery-code.used" | "recovery-codes.regenerated" | "passkey.added" | "passkey.removed" | "password.changed" | "logout" | "session.revoked" | "invite.created" | "invite.revoked" | "invite.accepted" | "account.role-changed" | "account.removed" | "account.mfa-reset" | "account.signed-out" | "dashboard.disabled" | "dashboard.enabled" | "dashboard.locked" | "explain.run" | "requests.cleared" | "panel.action";
555
+ /** The audit types that count toward the account, IP and global failure limits. */
556
+ export declare const DEVTOOLS_FAILURE_AUDIT_TYPES: readonly DevtoolsAuditType[];
557
+ /** One audit log entry. */
558
+ export type DevtoolsAuditEntry = {
559
+ id: string;
560
+ at: number;
561
+ type: DevtoolsAuditType;
562
+ /** The account acting or targeted; `null` for an unknown email or the CLI. */
563
+ accountId: string | null;
564
+ /** The email as typed or as stored, lower-cased; `null` when there was none. */
565
+ email: string | null;
566
+ /** `"cli"` for a command, else the client IP after trusted-proxy resolution. */
567
+ ip: string | null;
568
+ /** At most 200 characters. */
569
+ userAgent: string | null;
570
+ /** Small flat facts: target account, role, shape id, panel route. Never a secret. */
571
+ detail: Record<string, string | number | boolean | null>;
572
+ /** Short reference shown to users in error messages (8 characters). */
573
+ ref: string;
574
+ };
575
+ /**
576
+ * Error codes in API answers. Each has a fixed message (see
577
+ * `DEVTOOLS_ERROR_MESSAGES` in `errors.ts`) that says what failed and what to
578
+ * do next.
579
+ */
580
+ export type DevtoolsErrorCode = "auth.invalid-credentials" | "auth.invalid-code" | "auth.invalid-setup-token" | "auth.password-too-short" | "auth.password-too-long" | "auth.password-common" | "auth.password-same-as-email" | "auth.password-unchanged" | "auth.wrong-current-password" | "auth.busy" | "invite.invalid" | "invite.email-taken" | "account.not-found" | "account.last-admin" | "account.self" | "account.last-factor" | "role.forbidden" | "csrf.invalid" | "passkey.unavailable" | "passkey.failed" | "explain.not-allowed" | "explain.unsupported" | "explain.elsewhere" | "explain.failed" | "request.not-found" | "request.invalid-filter" | "stream.too-many" | "input.invalid" | "server.error";
581
+ /** The JSON body of every failed API call. */
582
+ export type DevtoolsApiErrorBody = {
583
+ /** What failed and what to do next. */
584
+ error: string;
585
+ code: DevtoolsErrorCode;
586
+ /** Short reference to quote to an admin; also written to the audit log or server log. */
587
+ ref?: string;
588
+ /** The instance that answered, when it matters (`explain.elsewhere`). */
589
+ instance?: string;
590
+ };
591
+ //#endregion
592
+ //# sourceMappingURL=contracts.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contracts.d.mts","names":[],"sources":["../../../../../../../../packages/devtools/src/production/contracts.ts"],"mappings":"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"}
@@ -0,0 +1,95 @@
1
+ //#region ../../packages/devtools/src/production/contracts.ts
2
+ /**
3
+ * Upper bounds (inclusive, ms) of the latency buckets every histogram uses.
4
+ * A histogram's `counts` has one more entry than this list: the last entry
5
+ * counts everything above the highest bound. Fixed bounds make histograms
6
+ * from several instances merge exactly.
7
+ */
8
+ const DEVTOOLS_LATENCY_BUCKETS_MS = [
9
+ 1,
10
+ 2,
11
+ 5,
12
+ 10,
13
+ 25,
14
+ 50,
15
+ 100,
16
+ 250,
17
+ 500,
18
+ 1e3,
19
+ 2500,
20
+ 5e3,
21
+ 1e4,
22
+ 3e4
23
+ ];
24
+ /**
25
+ * The built-in tabs, in display order, with whether production shows them
26
+ * when the project says nothing (`production.panels` overrides per id).
27
+ */
28
+ const DEVTOOLS_BUILT_IN_PANELS = [
29
+ {
30
+ id: "requests",
31
+ title: "Requests",
32
+ production: true
33
+ },
34
+ {
35
+ id: "queries",
36
+ title: "Queries",
37
+ production: true
38
+ },
39
+ {
40
+ id: "routes",
41
+ title: "Routes",
42
+ production: true
43
+ },
44
+ {
45
+ id: "resources",
46
+ title: "Resources",
47
+ production: true
48
+ },
49
+ {
50
+ id: "health",
51
+ title: "Health",
52
+ production: true
53
+ },
54
+ {
55
+ id: "errors",
56
+ title: "Errors",
57
+ production: true
58
+ },
59
+ {
60
+ id: "logs",
61
+ title: "Logs",
62
+ production: true
63
+ },
64
+ {
65
+ id: "jobs",
66
+ title: "Jobs",
67
+ production: true
68
+ },
69
+ {
70
+ id: "mail",
71
+ title: "Mail",
72
+ production: false
73
+ },
74
+ {
75
+ id: "ai",
76
+ title: "AI",
77
+ production: false
78
+ },
79
+ {
80
+ id: "agents",
81
+ title: "Agents",
82
+ production: false
83
+ },
84
+ {
85
+ id: "api",
86
+ title: "API",
87
+ production: false
88
+ }
89
+ ];
90
+ /** The audit types that count toward the account, IP and global failure limits. */
91
+ const DEVTOOLS_FAILURE_AUDIT_TYPES = ["login.failed", "mfa.failed"];
92
+
93
+ //#endregion
94
+ export { DEVTOOLS_BUILT_IN_PANELS, DEVTOOLS_FAILURE_AUDIT_TYPES, DEVTOOLS_LATENCY_BUCKETS_MS };
95
+ //# sourceMappingURL=contracts.mjs.map