@warlock.js/devtools 5.58.0 → 5.60.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 (162) hide show
  1. package/CHANGELOG.md +32 -0
  2. package/cjs/app-versions-C_ZyzuvD.cjs +138 -0
  3. package/cjs/app-versions-C_ZyzuvD.cjs.map +1 -0
  4. package/cjs/attach-D5aMqUnA.cjs +1342 -0
  5. package/cjs/attach-D5aMqUnA.cjs.map +1 -0
  6. package/cjs/{auth-DV2GA1A9.cjs → auth-ChHh5E7j.cjs} +20 -13
  7. package/cjs/auth-ChHh5E7j.cjs.map +1 -0
  8. package/cjs/{boot-CyeHPFtk.cjs → boot-Dg5YZGGR.cjs} +78 -14
  9. package/cjs/boot-Dg5YZGGR.cjs.map +1 -0
  10. package/cjs/{capture-DcyBhdqw.cjs → capture-CBgONYhk.cjs} +4 -4
  11. package/cjs/{capture-DcyBhdqw.cjs.map → capture-CBgONYhk.cjs.map} +1 -1
  12. package/cjs/{cascade-store-DEGxAFDI.cjs → cascade-store-DUT2Laha.cjs} +3 -3
  13. package/cjs/cascade-store-DUT2Laha.cjs.map +1 -0
  14. package/cjs/{current-request-id-BoJJb3y7.cjs → current-request-id-Badec-TH.cjs} +3 -3
  15. package/cjs/{current-request-id-BoJJb3y7.cjs.map → current-request-id-Badec-TH.cjs.map} +1 -1
  16. package/cjs/{errors-DEqdWaqm.cjs → errors-DNQ-g49I.cjs} +201 -4
  17. package/cjs/errors-DNQ-g49I.cjs.map +1 -0
  18. package/cjs/extract-8kaX_cUV.cjs +1103 -0
  19. package/cjs/extract-8kaX_cUV.cjs.map +1 -0
  20. package/cjs/{helpers-7k_Q-abk.cjs → helpers-BcMBFy9v.cjs} +9 -6
  21. package/cjs/{helpers-7k_Q-abk.cjs.map → helpers-BcMBFy9v.cjs.map} +1 -1
  22. package/cjs/{histogram-BRV5eHcp.cjs → histogram-CkoVizdf.cjs} +6 -6
  23. package/cjs/{histogram-BRV5eHcp.cjs.map → histogram-CkoVizdf.cjs.map} +1 -1
  24. package/cjs/{http-XNLYU2vS.cjs → http-DCVCf44M.cjs} +26 -9
  25. package/cjs/http-DCVCf44M.cjs.map +1 -0
  26. package/cjs/index.cjs +1 -1
  27. package/cjs/{insights-BBZnUpWO.cjs → insights-CFof59kF.cjs} +6 -6
  28. package/cjs/{insights-BBZnUpWO.cjs.map → insights-CFof59kF.cjs.map} +1 -1
  29. package/cjs/migrations-BQdNOL5_.cjs +30 -0
  30. package/cjs/migrations-BQdNOL5_.cjs.map +1 -0
  31. package/cjs/{migrations-DTTzCNpR.cjs → models-DF1agAm4.cjs} +107 -25
  32. package/cjs/models-DF1agAm4.cjs.map +1 -0
  33. package/cjs/{process-panel-DEOnLxoT.cjs → process-panel-D3D9Y_dc.cjs} +5 -5
  34. package/cjs/{process-panel-DEOnLxoT.cjs.map → process-panel-D3D9Y_dc.cjs.map} +1 -1
  35. package/cjs/production/index.cjs +4 -4
  36. package/cjs/runs-DECWPGnq.cjs +390 -0
  37. package/cjs/runs-DECWPGnq.cjs.map +1 -0
  38. package/cjs/{server-C8JfggQU.cjs → server-CC5DpObz.cjs} +10 -7
  39. package/cjs/server-CC5DpObz.cjs.map +1 -0
  40. package/cjs/{src-DjOUdhKc.cjs → src-VyOjEEAo.cjs} +179 -24
  41. package/cjs/src-VyOjEEAo.cjs.map +1 -0
  42. package/cjs/{store-C06KO_A1.cjs → store-EFn4wp0T.cjs} +2 -2
  43. package/cjs/{stream-route-D4k-sJvW.cjs → stream-route-DFHuIWgg.cjs} +125 -19
  44. package/cjs/stream-route-DFHuIWgg.cjs.map +1 -0
  45. package/esm/ai/attach.mjs +92 -0
  46. package/esm/ai/attach.mjs.map +1 -0
  47. package/esm/ai/options.mjs +31 -0
  48. package/esm/ai/options.mjs.map +1 -0
  49. package/esm/ai/reports/aggregate.mjs +330 -0
  50. package/esm/ai/reports/aggregate.mjs.map +1 -0
  51. package/esm/ai/reports/evaluate.mjs +108 -0
  52. package/esm/ai/reports/evaluate.mjs.map +1 -0
  53. package/esm/ai/reports/range.mjs +121 -0
  54. package/esm/ai/reports/range.mjs.map +1 -0
  55. package/esm/ai/reports/runs.d.mts +2 -0
  56. package/esm/ai/reports/runs.mjs +212 -0
  57. package/esm/ai/reports/runs.mjs.map +1 -0
  58. package/esm/ai/reports/service.mjs +132 -0
  59. package/esm/ai/reports/service.mjs.map +1 -0
  60. package/esm/ai/rollup/cascade-store.mjs +84 -0
  61. package/esm/ai/rollup/cascade-store.mjs.map +1 -0
  62. package/esm/ai/rollup/categories.mjs +67 -0
  63. package/esm/ai/rollup/categories.mjs.map +1 -0
  64. package/esm/ai/rollup/extract.mjs +225 -0
  65. package/esm/ai/rollup/extract.mjs.map +1 -0
  66. package/esm/ai/rollup/file-store.mjs +147 -0
  67. package/esm/ai/rollup/file-store.mjs.map +1 -0
  68. package/esm/ai/rollup/histogram.mjs +42 -0
  69. package/esm/ai/rollup/histogram.mjs.map +1 -0
  70. package/esm/ai/rollup/increment-error.mjs +19 -0
  71. package/esm/ai/rollup/increment-error.mjs.map +1 -0
  72. package/esm/ai/rollup/index.mjs +9 -0
  73. package/esm/ai/rollup/mapping.mjs +69 -0
  74. package/esm/ai/rollup/mapping.mjs.map +1 -0
  75. package/esm/ai/rollup/memory-store.mjs +26 -0
  76. package/esm/ai/rollup/memory-store.mjs.map +1 -0
  77. package/esm/ai/rollup/writer.mjs +113 -0
  78. package/esm/ai/rollup/writer.mjs.map +1 -0
  79. package/esm/ai/types.d.mts +29 -0
  80. package/esm/ai/types.d.mts.map +1 -0
  81. package/esm/app-versions.mjs +74 -0
  82. package/esm/app-versions.mjs.map +1 -0
  83. package/esm/devtools-connector.d.mts.map +1 -1
  84. package/esm/devtools-connector.mjs +54 -2
  85. package/esm/devtools-connector.mjs.map +1 -1
  86. package/esm/index.d.mts +3 -2
  87. package/esm/options.mjs +4 -0
  88. package/esm/options.mjs.map +1 -1
  89. package/esm/production/auth/helpers.mjs +8 -5
  90. package/esm/production/auth/helpers.mjs.map +1 -1
  91. package/esm/production/auth/service.mjs +14 -6
  92. package/esm/production/auth/service.mjs.map +1 -1
  93. package/esm/production/boot.mjs +70 -3
  94. package/esm/production/boot.mjs.map +1 -1
  95. package/esm/production/contracts.d.mts +378 -2
  96. package/esm/production/contracts.d.mts.map +1 -1
  97. package/esm/production/contracts.mjs +64 -2
  98. package/esm/production/contracts.mjs.map +1 -1
  99. package/esm/production/errors.d.mts +1 -1
  100. package/esm/production/errors.mjs +11 -3
  101. package/esm/production/errors.mjs.map +1 -1
  102. package/esm/production/http/access.mjs +6 -0
  103. package/esm/production/http/access.mjs.map +1 -1
  104. package/esm/production/http/mount.mjs +13 -0
  105. package/esm/production/http/mount.mjs.map +1 -1
  106. package/esm/production/http/share-session.mjs.map +1 -1
  107. package/esm/production/index.d.mts +2 -2
  108. package/esm/production/insights/writer.mjs.map +1 -1
  109. package/esm/production/options.d.mts +5 -1
  110. package/esm/production/options.d.mts.map +1 -1
  111. package/esm/production/options.mjs +13 -1
  112. package/esm/production/options.mjs.map +1 -1
  113. package/esm/production/store/memory-store.mjs.map +1 -1
  114. package/esm/production/store/migrations.d.mts +1 -1
  115. package/esm/production/store/migrations.d.mts.map +1 -1
  116. package/esm/production/store/migrations.mjs +4 -2
  117. package/esm/production/store/migrations.mjs.map +1 -1
  118. package/esm/production/store/models/ai-rollup.migration.mjs +48 -0
  119. package/esm/production/store/models/ai-rollup.migration.mjs.map +1 -0
  120. package/esm/production/store/models/ai-rollup.model.mjs +13 -0
  121. package/esm/production/store/models/ai-rollup.model.mjs.map +1 -0
  122. package/esm/production/store/models/index.mjs +3 -1
  123. package/esm/server/ai-report-routes.mjs +72 -0
  124. package/esm/server/ai-report-routes.mjs.map +1 -0
  125. package/esm/server/ai-routes.mjs +41 -6
  126. package/esm/server/ai-routes.mjs.map +1 -1
  127. package/esm/server/index.mjs +2 -0
  128. package/esm/server/index.mjs.map +1 -1
  129. package/esm/server/session-routes.mjs +3 -1
  130. package/esm/server/session-routes.mjs.map +1 -1
  131. package/esm/sources/agent-trace-source.d.mts.map +1 -1
  132. package/esm/sources/agent-trace-source.mjs.map +1 -1
  133. package/esm/sources/ai-source.d.mts +2 -0
  134. package/esm/sources/ai-source.d.mts.map +1 -1
  135. package/esm/sources/ai-source.mjs +120 -11
  136. package/esm/sources/ai-source.mjs.map +1 -1
  137. package/esm/types.d.mts +23 -4
  138. package/esm/types.d.mts.map +1 -1
  139. package/llms-full.txt +79 -32
  140. package/package.json +8 -8
  141. package/skills/SKILL.md +79 -32
  142. package/ui/dashboard/assets/app.css +1 -1
  143. package/ui/dashboard/assets/app.js +23 -16
  144. package/ui/dashboard/build-info.json +7 -7
  145. package/cjs/ai-source-DTpxumMA.cjs +0 -381
  146. package/cjs/ai-source-DTpxumMA.cjs.map +0 -1
  147. package/cjs/auth-DV2GA1A9.cjs.map +0 -1
  148. package/cjs/boot-CyeHPFtk.cjs.map +0 -1
  149. package/cjs/cascade-store-DEGxAFDI.cjs.map +0 -1
  150. package/cjs/contracts-CDuY-ahl.cjs +0 -116
  151. package/cjs/contracts-CDuY-ahl.cjs.map +0 -1
  152. package/cjs/errors-DEqdWaqm.cjs.map +0 -1
  153. package/cjs/http-XNLYU2vS.cjs.map +0 -1
  154. package/cjs/migrations-DTTzCNpR.cjs.map +0 -1
  155. package/cjs/options-CHhmQJic.cjs +0 -193
  156. package/cjs/options-CHhmQJic.cjs.map +0 -1
  157. package/cjs/panels-CHd20RK5.cjs +0 -385
  158. package/cjs/panels-CHd20RK5.cjs.map +0 -1
  159. package/cjs/rolldown-runtime-Zuuoy_Rh.cjs +0 -52
  160. package/cjs/server-C8JfggQU.cjs.map +0 -1
  161. package/cjs/src-DjOUdhKc.cjs.map +0 -1
  162. package/cjs/stream-route-D4k-sJvW.cjs.map +0 -1
package/llms-full.txt CHANGED
@@ -63,21 +63,23 @@ export default {
63
63
 
64
64
  ## What each panel shows
65
65
 
66
- | Panel | What you see | Where it comes from |
67
- | ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------- |
68
- | **Requests** | Each request with its status, duration and query count. Click one for a waterfall: router middleware, `page.middleware`, loaders, `page.cache` hit/miss, `render.shell`, `defer.settle`, with queries and cache ops placed on the same time axis. | core `registerTracingHooks()` |
69
- | **Queries** | SQL + bindings or the Mongo command, duration, rows, and an **Explain** button (Postgres `SELECT` only; runs `EXPLAIN (FORMAT JSON)`, never `ANALYZE`) | cascade `dataSourceRegistry.on("query")` |
70
- | **N+1** | `⚠ N+1: 12× "select … where post_id = $1" — src/app/posts/services/list-posts.service.ts:18`, shown on the request and printed in the terminal | same query shape ≥ 5 times in one request |
71
- | **Mail** | Every mail sent in development: headers, HTML (sandboxed) and text, attachment names | core `mailEvents.onCaptured()` |
72
- | **Logs** | Log entries per request, filterable by level and module | a logger channel |
73
- | **Cache** | hit / miss / set / removed / `invalidated` (tags, keys removed) | cache `cache.on(...)` |
74
- | **Resources** | Memory, CPU, event-loop delay and garbage collection, with a 10-minute history | the process |
75
- | **Health** | Readiness checks over time | core `health.readiness()` |
76
- | **Errors** | Failed requests grouped by cause with counts | tracing and logger |
77
- | **Jobs** | Registered scheduled jobs with schedule, last and next run (no run history, duration or error yet); queue counts only when the queue driver reports them (not available today) | `@warlock.js/scheduler`, `@warlock.js/queue` |
78
- | **Agents** | Per-turn traces of `@warlock.js/ai` agents: system prompt, tools offered with schema hashes, tool calls, results and refusals, retries, usage and cost, plus a comparison with the previous run of the agent | `@warlock.js/ai` `agentTraces` store |
79
- | **Routes** | Every HTTP route with its method, path, name and middleware | core router |
80
- | **API** | The app's API reference: every route with its parameters, request body, responses and auth | core `getDevelopmentOpenApiDocument()` |
66
+ | Panel | What you see | Where it comes from |
67
+ | ------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------- |
68
+ | **Requests** | Each request with its status, duration and query count. Click one for a waterfall: router middleware, `page.middleware`, loaders, `page.cache` hit/miss, `render.shell`, `defer.settle`, with queries and cache ops placed on the same time axis. | core `registerTracingHooks()` |
69
+ | **Queries** | SQL + bindings or the Mongo command, duration, rows, and an **Explain** button (Postgres `SELECT` only; runs `EXPLAIN (FORMAT JSON)`, never `ANALYZE`) | cascade `dataSourceRegistry.on("query")` |
70
+ | **N+1** | `⚠ N+1: 12× "select … where post_id = $1" — src/app/posts/services/list-posts.service.ts:18`, shown on the request and printed in the terminal | same query shape ≥ 5 times in one request |
71
+ | **Mail** | Every mail sent in development: headers, HTML (sandboxed) and text, attachment names | core `mailEvents.onCaptured()` |
72
+ | **Logs** | Log entries per request, filterable by level and module | a logger channel |
73
+ | **Cache** | hit / miss / set / removed / `invalidated` (tags, keys removed) | cache `cache.on(...)` |
74
+ | **Resources** | Memory, CPU, event-loop delay and garbage collection, with a 10-minute history | the process |
75
+ | **Health** | Readiness checks over time | core `health.readiness()` |
76
+ | **Errors** | Failed requests grouped by cause with counts | tracing and logger |
77
+ | **Jobs** | Registered scheduled jobs with schedule, last and next run (no run history, duration or error yet); queue counts only when the queue driver reports them (not available today) | `@warlock.js/scheduler`, `@warlock.js/queue` |
78
+ | **AI Reports, Models, Errors** | Hourly totals of agent runs, tokens, estimated cost (from model pricing; unpriced models flagged), errors by category, latency, fallbacks and refusals, with 24h / 7d / 30d / custom ranges and Agent, Model, Provider filters. Production too | `@warlock.js/ai-panoptic` trace feed, saved as hourly rollups |
79
+ | **AI Runs, Evaluate** | Single runs with filters, grouping and a cost tint; grade a system prompt with a judge model. Development only | Panoptic traces in memory; `panoptic.evaluate` |
80
+ | **Agents** | Per-turn traces of `@warlock.js/ai` agents: system prompt, tools offered with schema hashes, tool calls, results and refusals, retries, usage and cost, plus a comparison with the previous run of the agent | `@warlock.js/ai` `agentTraces` store |
81
+ | **Routes** | Every HTTP route with its method, path, name and middleware | core router |
82
+ | **API** | The app's API reference: every route with its parameters, request body, responses and auth | core `getDevelopmentOpenApiDocument()` |
81
83
 
82
84
  Work outside a request (boot, scheduler ticks, queue jobs) goes to a separate
83
85
  background list, so it never clutters a request's timeline.
@@ -102,11 +104,51 @@ without duplicates by id (saved-only rows are marked **saved**).
102
104
 
103
105
  An older core without the request log leaves the panel in-memory only.
104
106
 
107
+ ## AI section: Reports, Runs, Agents, Models, Errors, Evaluate
108
+
109
+ The **AI** sidebar group has six pages. Reports (`ai-reports`), Models (`ai-models`) and Errors (`ai-errors`) read
110
+ **hourly rollups** (names and numbers only: agent, model, provider, runs, tokens, estimated cost, errors by category,
111
+ latency histogram, fallback and refusal counts). Runs (`ai`, id unchanged), Agents (`agents`) and Evaluate
112
+ (`ai-evaluate`) read in-memory data and exist in development only. Cost is always "Estimated from model pricing"; runs of
113
+ models without pricing are counted as unpriced and shown next to every cost (a model priced at 0 counts as priced).
114
+ Runs filters by text, status, type and exact HTTP request id (`GET api/ai/runs?requestId=`). A comparison whose
115
+ previous period is older than the kept history reads "No earlier data". Custom ranges longer than 8 days use daily
116
+ columns from local midnight to midnight.
117
+
118
+ Options in `src/config/devtools.ts`:
119
+
120
+ ```ts
121
+ export default {
122
+ ai: {
123
+ reports: true, // keep hourly totals; false turns the writer off (pages say so)
124
+ retentionDays: 30, // 1 to 400; default 30 in development, 90 in production
125
+ flushIntervalMs: 60_000, // at least 5000
126
+ },
127
+ };
128
+ ```
129
+
130
+ - Storage: development files under `storage/devtools/ai-rollups`; production table `devtools_ai_rollups`, part of
131
+ `devtoolsMigrations`. After upgrading run `warlock migrate`; without it one warning is logged and the pages answer
132
+ `table-missing` ("AI reports need their table", command `warlock migrate`).
133
+ - Production tabs: Reports, Models and Errors are on by default when Panoptic is installed and loads; Runs, Agents and
134
+ Evaluate stay off. `production.panels` overrides by id (`{ "ai-reports": false }`). Every process that boots the
135
+ connector writes to the same table, so totals add up all instances and workers.
136
+ - Needs Panoptic and observation (`ai.config({ panoptic: { observeAll: true } })`). Evaluate also needs
137
+ `ai.config({ panoptic: { evaluate: { model, instructions? } } })`; without it the page shows the setup.
138
+ - Routes: `GET /api/ai/reports`, `/api/ai/models`, `/api/ai/errors` (query `range=24h|7d|30d|custom`, `from`, `to`, `tz`,
139
+ `agent`, `model`, `provider`), `GET /api/ai/runs` (`q`, `status`, `type`, `session`, `prompt`, `groupBy`, `limit`),
140
+ `GET` and `POST /api/ai/evaluate`; `GET /api/ai`, `/api/ai/runs/:id` and `/api/ai/agent-runs*` keep their shapes. Error
141
+ codes: `ai.range-invalid`, `ai.evaluate-unavailable`, `ai.prompt-not-found`, `ai.evaluate-failed`.
142
+ - Inside a Warlock app Panoptic's standalone dashboard does not start (one notice points here); the AI section replaces it.
143
+
105
144
  ## AI runs alongside HTTP requests
106
145
 
107
146
  The **AI** tab and each request's **AI runs** section display completed traces
108
- from optional `@warlock.js/ai-panoptic`. If it cannot be imported, the tab shows
109
- install/restart guidance and the other panels keep working.
147
+ from optional `@warlock.js/ai-panoptic`. If the tab is empty it says why
148
+ (`/api/ai` answers `reason`: `ai-missing`, `panoptic-missing`, `panoptic-failed` with the load
149
+ error (absolute paths replaced) and versions, `observation-off`, or `table-missing`, `reports-off`, or `not-collected` in the
150
+ production dashboard, which keeps hourly totals but not single runs) with a title, one line and a copyable command; the
151
+ other panels keep working.
110
152
 
111
153
  ```bash
112
154
  warlock add devtools
@@ -282,7 +324,7 @@ Environment variables:
282
324
 
283
325
  The accounts live in the app's database through Cascade. Roles are `viewer`
284
326
  and `admin`. Admins invite users with a 24-hour single-use link. Two-factor is
285
- required for admins by default (`twoFactor: "admins"`; or `"everyone"`): an
327
+ required for admins by default (`twoFactor: "admins"`; or `"everyone"`, or `"off"` for nobody, which logs a boot warning; an account that has a factor is always asked for it): an
286
328
  authenticator app, or passkeys when `@simplewebauthn/server` is installed, plus
287
329
  10 recovery codes. Every closed case answers the app's own 404.
288
330
 
@@ -292,7 +334,7 @@ Options under `production` (all optional, defaults in brackets):
292
334
  `requestRetentionHours` [24], `maxStoredSamplesPerMinute` [120],
293
335
  `reportIntervalMs` [10000], `trustedProxies` [[]], `requireHttps` [true],
294
336
  `allowedIps` [[]], `origin`, `session.idleMinutes` [30], `session.maxHours` [8],
295
- `twoFactor` ["admins"], `rateLimits.windowMinutes` [15], `rateLimits.account`
337
+ `twoFactor` ["admins"], `passwords.minLength` [8, from 8 to 72], `passwords.rejectCommon` [true], `rateLimits.windowMinutes` [15], `rateLimits.account`
296
338
  [5], `rateLimits.ip` [20], `rateLimits.global` [100], `rateLimits.lockMinutes`
297
339
  [15], `explain.executing` [false], `panels` [{}], `logLevels` [warn, error],
298
340
  `auditRetentionDays` [90], `passkeys.rpName`, `passkeys.rpId`.
@@ -355,18 +397,18 @@ Options under `production` (all optional, defaults in brackets):
355
397
  The app refuses to boot with a `DevtoolsProductionConfigError`
356
398
  (`DEVTOOLS_CONFIG_CODES` holds the messages):
357
399
 
358
- | Code | Fix |
359
- | ------- | --------------------------------------------------------------------------------------------------------------------------- |
360
- | `DT001` | Set `DEVTOOLS_PATH` or `production.path`. |
361
- | `DT002` | Use a path of 8+ characters starting with `/`, with letters, digits and `- _ . ~ /` only; not `/__warlock`. |
362
- | `DT003` | No admin: set `DEVTOOLS_ADMIN_EMAIL` plus a password or setup token, or run `warlock devtools:reset-admin --email <email>`. |
363
- | `DT004` | The env password breaks the rules (8+ characters, at most 72 bytes, not common, not the email). |
364
- | `DT005` | Install `@warlock.js/cascade` and configure a database. |
365
- | `DT006` | Set `encryption.key` (64 hex characters). |
366
- | `DT007` | An option is invalid (`share.maxDays` must be 1 to 365); the message names it. |
367
- | `DT008` | Add `devtoolsMigrations` to `database.migrations` and run `warlock migrate` (`devtools_shares` when sharing is on). |
368
- | `DT009` | Set the password or the setup token, not both. |
369
- | `DT010` | The setup token needs 32+ characters (`openssl rand -base64 32`). |
400
+ | Code | Fix |
401
+ | ------- | -------------------------------------------------------------------------------------------------------------------------------------------------- |
402
+ | `DT001` | Set `DEVTOOLS_PATH` or `production.path`. |
403
+ | `DT002` | Use a path of 8+ characters starting with `/`, with letters, digits and `- _ . ~ /` only; not `/__warlock`. |
404
+ | `DT003` | No admin: set `DEVTOOLS_ADMIN_EMAIL` plus a password or setup token, or run `warlock devtools:reset-admin --email <email>`. |
405
+ | `DT004` | The env password breaks the rules (`passwords.minLength`+ characters, at most 72 bytes, not common unless `rejectCommon` is false, not the email). |
406
+ | `DT005` | Install `@warlock.js/cascade` and configure a database. |
407
+ | `DT006` | Set `encryption.key` (64 hex characters). |
408
+ | `DT007` | An option is invalid (`share.maxDays` must be 1 to 365); the message names it. |
409
+ | `DT008` | Add `devtoolsMigrations` to `database.migrations` and run `warlock migrate` (`devtools_shares` when sharing is on). |
410
+ | `DT009` | Set the password or the setup token, not both. |
411
+ | `DT010` | The setup token needs 32+ characters (`openssl rand -base64 32`). |
370
412
 
371
413
  Every dashboard URL gives a 404: check that `production.enabled` is true, the
372
414
  dashboard is not disabled or locked (`warlock devtools:enable`), the request is
@@ -457,6 +499,11 @@ Panel styling: a package panel's CSS may use only the dashboard's variables (`DE
457
499
  `@warlock.js/devtools`: `--background --foreground --card --muted --muted-foreground --accent --border --brand
458
500
  --success --warning --info --destructive --chart-1..5` and the other shadcn names) plus variables it defines itself.
459
501
  Never use another name (such as `--text` or `--surface`): the dashboard does not define it, and text can become
460
- unreadable. The text tokens meet 4.5:1 contrast on `--background` and `--card` in both themes.
502
+ unreadable. The text tokens meet 4.5:1 contrast on `--background` and `--card` in both themes. In the light theme `--primary` is the
503
+ gold fill (dark `--primary-foreground` on it) and `--brand` is the deep amber for text; in the dark theme both are gold.
504
+
505
+ The dashboard shows the Warlock logo and installed core version at the top of the sidebar and the app's own
506
+ `package.json` name and version at the bottom. They come from `GET api/auth/session` (`warlockVersion`, `app`), read once
507
+ on the server, signed-in only, `null` when unknown.
461
508
 
462
509
 
package/package.json CHANGED
@@ -6,13 +6,13 @@
6
6
  },
7
7
  "peerDependencies": {
8
8
  "@simplewebauthn/server": "^13.1.0",
9
- "@warlock.js/ai-panoptic": "5.58.0",
10
- "@warlock.js/cache": "5.58.0",
11
- "@warlock.js/cascade": "5.58.0",
12
- "@warlock.js/core": "5.58.0",
13
- "@warlock.js/logger": "5.58.0",
14
- "@warlock.js/queue": "5.58.0",
15
- "@warlock.js/scheduler": "5.58.0"
9
+ "@warlock.js/ai-panoptic": "5.60.0",
10
+ "@warlock.js/cache": "5.60.0",
11
+ "@warlock.js/cascade": "5.60.0",
12
+ "@warlock.js/core": "5.60.0",
13
+ "@warlock.js/logger": "5.60.0",
14
+ "@warlock.js/queue": "5.60.0",
15
+ "@warlock.js/scheduler": "5.60.0"
16
16
  },
17
17
  "peerDependenciesMeta": {
18
18
  "@simplewebauthn/server": {
@@ -52,7 +52,7 @@
52
52
  ],
53
53
  "author": "hassanzohdy",
54
54
  "license": "MIT",
55
- "version": "5.58.0",
55
+ "version": "5.60.0",
56
56
  "main": "./cjs/index.cjs",
57
57
  "module": "./esm/index.mjs",
58
58
  "types": "./esm/index.d.mts",
package/skills/SKILL.md CHANGED
@@ -55,21 +55,23 @@ export default {
55
55
 
56
56
  ## What each panel shows
57
57
 
58
- | Panel | What you see | Where it comes from |
59
- | ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------- |
60
- | **Requests** | Each request with its status, duration and query count. Click one for a waterfall: router middleware, `page.middleware`, loaders, `page.cache` hit/miss, `render.shell`, `defer.settle`, with queries and cache ops placed on the same time axis. | core `registerTracingHooks()` |
61
- | **Queries** | SQL + bindings or the Mongo command, duration, rows, and an **Explain** button (Postgres `SELECT` only; runs `EXPLAIN (FORMAT JSON)`, never `ANALYZE`) | cascade `dataSourceRegistry.on("query")` |
62
- | **N+1** | `⚠ N+1: 12× "select … where post_id = $1" — src/app/posts/services/list-posts.service.ts:18`, shown on the request and printed in the terminal | same query shape ≥ 5 times in one request |
63
- | **Mail** | Every mail sent in development: headers, HTML (sandboxed) and text, attachment names | core `mailEvents.onCaptured()` |
64
- | **Logs** | Log entries per request, filterable by level and module | a logger channel |
65
- | **Cache** | hit / miss / set / removed / `invalidated` (tags, keys removed) | cache `cache.on(...)` |
66
- | **Resources** | Memory, CPU, event-loop delay and garbage collection, with a 10-minute history | the process |
67
- | **Health** | Readiness checks over time | core `health.readiness()` |
68
- | **Errors** | Failed requests grouped by cause with counts | tracing and logger |
69
- | **Jobs** | Registered scheduled jobs with schedule, last and next run (no run history, duration or error yet); queue counts only when the queue driver reports them (not available today) | `@warlock.js/scheduler`, `@warlock.js/queue` |
70
- | **Agents** | Per-turn traces of `@warlock.js/ai` agents: system prompt, tools offered with schema hashes, tool calls, results and refusals, retries, usage and cost, plus a comparison with the previous run of the agent | `@warlock.js/ai` `agentTraces` store |
71
- | **Routes** | Every HTTP route with its method, path, name and middleware | core router |
72
- | **API** | The app's API reference: every route with its parameters, request body, responses and auth | core `getDevelopmentOpenApiDocument()` |
58
+ | Panel | What you see | Where it comes from |
59
+ | ------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------- |
60
+ | **Requests** | Each request with its status, duration and query count. Click one for a waterfall: router middleware, `page.middleware`, loaders, `page.cache` hit/miss, `render.shell`, `defer.settle`, with queries and cache ops placed on the same time axis. | core `registerTracingHooks()` |
61
+ | **Queries** | SQL + bindings or the Mongo command, duration, rows, and an **Explain** button (Postgres `SELECT` only; runs `EXPLAIN (FORMAT JSON)`, never `ANALYZE`) | cascade `dataSourceRegistry.on("query")` |
62
+ | **N+1** | `⚠ N+1: 12× "select … where post_id = $1" — src/app/posts/services/list-posts.service.ts:18`, shown on the request and printed in the terminal | same query shape ≥ 5 times in one request |
63
+ | **Mail** | Every mail sent in development: headers, HTML (sandboxed) and text, attachment names | core `mailEvents.onCaptured()` |
64
+ | **Logs** | Log entries per request, filterable by level and module | a logger channel |
65
+ | **Cache** | hit / miss / set / removed / `invalidated` (tags, keys removed) | cache `cache.on(...)` |
66
+ | **Resources** | Memory, CPU, event-loop delay and garbage collection, with a 10-minute history | the process |
67
+ | **Health** | Readiness checks over time | core `health.readiness()` |
68
+ | **Errors** | Failed requests grouped by cause with counts | tracing and logger |
69
+ | **Jobs** | Registered scheduled jobs with schedule, last and next run (no run history, duration or error yet); queue counts only when the queue driver reports them (not available today) | `@warlock.js/scheduler`, `@warlock.js/queue` |
70
+ | **AI Reports, Models, Errors** | Hourly totals of agent runs, tokens, estimated cost (from model pricing; unpriced models flagged), errors by category, latency, fallbacks and refusals, with 24h / 7d / 30d / custom ranges and Agent, Model, Provider filters. Production too | `@warlock.js/ai-panoptic` trace feed, saved as hourly rollups |
71
+ | **AI Runs, Evaluate** | Single runs with filters, grouping and a cost tint; grade a system prompt with a judge model. Development only | Panoptic traces in memory; `panoptic.evaluate` |
72
+ | **Agents** | Per-turn traces of `@warlock.js/ai` agents: system prompt, tools offered with schema hashes, tool calls, results and refusals, retries, usage and cost, plus a comparison with the previous run of the agent | `@warlock.js/ai` `agentTraces` store |
73
+ | **Routes** | Every HTTP route with its method, path, name and middleware | core router |
74
+ | **API** | The app's API reference: every route with its parameters, request body, responses and auth | core `getDevelopmentOpenApiDocument()` |
73
75
 
74
76
  Work outside a request (boot, scheduler ticks, queue jobs) goes to a separate
75
77
  background list, so it never clutters a request's timeline.
@@ -94,11 +96,51 @@ without duplicates by id (saved-only rows are marked **saved**).
94
96
 
95
97
  An older core without the request log leaves the panel in-memory only.
96
98
 
99
+ ## AI section: Reports, Runs, Agents, Models, Errors, Evaluate
100
+
101
+ The **AI** sidebar group has six pages. Reports (`ai-reports`), Models (`ai-models`) and Errors (`ai-errors`) read
102
+ **hourly rollups** (names and numbers only: agent, model, provider, runs, tokens, estimated cost, errors by category,
103
+ latency histogram, fallback and refusal counts). Runs (`ai`, id unchanged), Agents (`agents`) and Evaluate
104
+ (`ai-evaluate`) read in-memory data and exist in development only. Cost is always "Estimated from model pricing"; runs of
105
+ models without pricing are counted as unpriced and shown next to every cost (a model priced at 0 counts as priced).
106
+ Runs filters by text, status, type and exact HTTP request id (`GET api/ai/runs?requestId=`). A comparison whose
107
+ previous period is older than the kept history reads "No earlier data". Custom ranges longer than 8 days use daily
108
+ columns from local midnight to midnight.
109
+
110
+ Options in `src/config/devtools.ts`:
111
+
112
+ ```ts
113
+ export default {
114
+ ai: {
115
+ reports: true, // keep hourly totals; false turns the writer off (pages say so)
116
+ retentionDays: 30, // 1 to 400; default 30 in development, 90 in production
117
+ flushIntervalMs: 60_000, // at least 5000
118
+ },
119
+ };
120
+ ```
121
+
122
+ - Storage: development files under `storage/devtools/ai-rollups`; production table `devtools_ai_rollups`, part of
123
+ `devtoolsMigrations`. After upgrading run `warlock migrate`; without it one warning is logged and the pages answer
124
+ `table-missing` ("AI reports need their table", command `warlock migrate`).
125
+ - Production tabs: Reports, Models and Errors are on by default when Panoptic is installed and loads; Runs, Agents and
126
+ Evaluate stay off. `production.panels` overrides by id (`{ "ai-reports": false }`). Every process that boots the
127
+ connector writes to the same table, so totals add up all instances and workers.
128
+ - Needs Panoptic and observation (`ai.config({ panoptic: { observeAll: true } })`). Evaluate also needs
129
+ `ai.config({ panoptic: { evaluate: { model, instructions? } } })`; without it the page shows the setup.
130
+ - Routes: `GET /api/ai/reports`, `/api/ai/models`, `/api/ai/errors` (query `range=24h|7d|30d|custom`, `from`, `to`, `tz`,
131
+ `agent`, `model`, `provider`), `GET /api/ai/runs` (`q`, `status`, `type`, `session`, `prompt`, `groupBy`, `limit`),
132
+ `GET` and `POST /api/ai/evaluate`; `GET /api/ai`, `/api/ai/runs/:id` and `/api/ai/agent-runs*` keep their shapes. Error
133
+ codes: `ai.range-invalid`, `ai.evaluate-unavailable`, `ai.prompt-not-found`, `ai.evaluate-failed`.
134
+ - Inside a Warlock app Panoptic's standalone dashboard does not start (one notice points here); the AI section replaces it.
135
+
97
136
  ## AI runs alongside HTTP requests
98
137
 
99
138
  The **AI** tab and each request's **AI runs** section display completed traces
100
- from optional `@warlock.js/ai-panoptic`. If it cannot be imported, the tab shows
101
- install/restart guidance and the other panels keep working.
139
+ from optional `@warlock.js/ai-panoptic`. If the tab is empty it says why
140
+ (`/api/ai` answers `reason`: `ai-missing`, `panoptic-missing`, `panoptic-failed` with the load
141
+ error (absolute paths replaced) and versions, `observation-off`, or `table-missing`, `reports-off`, or `not-collected` in the
142
+ production dashboard, which keeps hourly totals but not single runs) with a title, one line and a copyable command; the
143
+ other panels keep working.
102
144
 
103
145
  ```bash
104
146
  warlock add devtools
@@ -274,7 +316,7 @@ Environment variables:
274
316
 
275
317
  The accounts live in the app's database through Cascade. Roles are `viewer`
276
318
  and `admin`. Admins invite users with a 24-hour single-use link. Two-factor is
277
- required for admins by default (`twoFactor: "admins"`; or `"everyone"`): an
319
+ required for admins by default (`twoFactor: "admins"`; or `"everyone"`, or `"off"` for nobody, which logs a boot warning; an account that has a factor is always asked for it): an
278
320
  authenticator app, or passkeys when `@simplewebauthn/server` is installed, plus
279
321
  10 recovery codes. Every closed case answers the app's own 404.
280
322
 
@@ -284,7 +326,7 @@ Options under `production` (all optional, defaults in brackets):
284
326
  `requestRetentionHours` [24], `maxStoredSamplesPerMinute` [120],
285
327
  `reportIntervalMs` [10000], `trustedProxies` [[]], `requireHttps` [true],
286
328
  `allowedIps` [[]], `origin`, `session.idleMinutes` [30], `session.maxHours` [8],
287
- `twoFactor` ["admins"], `rateLimits.windowMinutes` [15], `rateLimits.account`
329
+ `twoFactor` ["admins"], `passwords.minLength` [8, from 8 to 72], `passwords.rejectCommon` [true], `rateLimits.windowMinutes` [15], `rateLimits.account`
288
330
  [5], `rateLimits.ip` [20], `rateLimits.global` [100], `rateLimits.lockMinutes`
289
331
  [15], `explain.executing` [false], `panels` [{}], `logLevels` [warn, error],
290
332
  `auditRetentionDays` [90], `passkeys.rpName`, `passkeys.rpId`.
@@ -347,18 +389,18 @@ Options under `production` (all optional, defaults in brackets):
347
389
  The app refuses to boot with a `DevtoolsProductionConfigError`
348
390
  (`DEVTOOLS_CONFIG_CODES` holds the messages):
349
391
 
350
- | Code | Fix |
351
- | ------- | --------------------------------------------------------------------------------------------------------------------------- |
352
- | `DT001` | Set `DEVTOOLS_PATH` or `production.path`. |
353
- | `DT002` | Use a path of 8+ characters starting with `/`, with letters, digits and `- _ . ~ /` only; not `/__warlock`. |
354
- | `DT003` | No admin: set `DEVTOOLS_ADMIN_EMAIL` plus a password or setup token, or run `warlock devtools:reset-admin --email <email>`. |
355
- | `DT004` | The env password breaks the rules (8+ characters, at most 72 bytes, not common, not the email). |
356
- | `DT005` | Install `@warlock.js/cascade` and configure a database. |
357
- | `DT006` | Set `encryption.key` (64 hex characters). |
358
- | `DT007` | An option is invalid (`share.maxDays` must be 1 to 365); the message names it. |
359
- | `DT008` | Add `devtoolsMigrations` to `database.migrations` and run `warlock migrate` (`devtools_shares` when sharing is on). |
360
- | `DT009` | Set the password or the setup token, not both. |
361
- | `DT010` | The setup token needs 32+ characters (`openssl rand -base64 32`). |
392
+ | Code | Fix |
393
+ | ------- | -------------------------------------------------------------------------------------------------------------------------------------------------- |
394
+ | `DT001` | Set `DEVTOOLS_PATH` or `production.path`. |
395
+ | `DT002` | Use a path of 8+ characters starting with `/`, with letters, digits and `- _ . ~ /` only; not `/__warlock`. |
396
+ | `DT003` | No admin: set `DEVTOOLS_ADMIN_EMAIL` plus a password or setup token, or run `warlock devtools:reset-admin --email <email>`. |
397
+ | `DT004` | The env password breaks the rules (`passwords.minLength`+ characters, at most 72 bytes, not common unless `rejectCommon` is false, not the email). |
398
+ | `DT005` | Install `@warlock.js/cascade` and configure a database. |
399
+ | `DT006` | Set `encryption.key` (64 hex characters). |
400
+ | `DT007` | An option is invalid (`share.maxDays` must be 1 to 365); the message names it. |
401
+ | `DT008` | Add `devtoolsMigrations` to `database.migrations` and run `warlock migrate` (`devtools_shares` when sharing is on). |
402
+ | `DT009` | Set the password or the setup token, not both. |
403
+ | `DT010` | The setup token needs 32+ characters (`openssl rand -base64 32`). |
362
404
 
363
405
  Every dashboard URL gives a 404: check that `production.enabled` is true, the
364
406
  dashboard is not disabled or locked (`warlock devtools:enable`), the request is
@@ -449,4 +491,9 @@ Panel styling: a package panel's CSS may use only the dashboard's variables (`DE
449
491
  `@warlock.js/devtools`: `--background --foreground --card --muted --muted-foreground --accent --border --brand
450
492
  --success --warning --info --destructive --chart-1..5` and the other shadcn names) plus variables it defines itself.
451
493
  Never use another name (such as `--text` or `--surface`): the dashboard does not define it, and text can become
452
- unreadable. The text tokens meet 4.5:1 contrast on `--background` and `--card` in both themes.
494
+ unreadable. The text tokens meet 4.5:1 contrast on `--background` and `--card` in both themes. In the light theme `--primary` is the
495
+ gold fill (dark `--primary-foreground` on it) and `--brand` is the deep amber for text; in the dark theme both are gold.
496
+
497
+ The dashboard shows the Warlock logo and installed core version at the top of the sidebar and the app's own
498
+ `package.json` name and version at the bottom. They come from `GET api/auth/session` (`warlockVersion`, `app`), read once
499
+ on the server, signed-in only, `null` when unknown.