@warlock.js/devtools 5.55.0 → 5.57.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.
- package/CHANGELOG.md +52 -0
- package/README.md +26 -13
- package/cjs/ai-source-DTpxumMA.cjs +381 -0
- package/cjs/ai-source-DTpxumMA.cjs.map +1 -0
- package/cjs/auth-DzU0gHDG.cjs +1655 -0
- package/cjs/auth-DzU0gHDG.cjs.map +1 -0
- package/cjs/boot-Dy5OqgTM.cjs +138 -0
- package/cjs/boot-Dy5OqgTM.cjs.map +1 -0
- package/cjs/capture-CqIiaznN.cjs +1342 -0
- package/cjs/capture-CqIiaznN.cjs.map +1 -0
- package/cjs/cascade-store-pHjKeSFm.cjs +863 -0
- package/cjs/cascade-store-pHjKeSFm.cjs.map +1 -0
- package/cjs/collector-CJbQbzzK.cjs +271 -0
- package/cjs/collector-CJbQbzzK.cjs.map +1 -0
- package/cjs/contracts-CVmplkNb.cjs +112 -0
- package/cjs/contracts-CVmplkNb.cjs.map +1 -0
- package/cjs/current-request-id-BoJJb3y7.cjs +37 -0
- package/cjs/current-request-id-BoJJb3y7.cjs.map +1 -0
- package/cjs/errors-CyZp5yS-.cjs +177 -0
- package/cjs/errors-CyZp5yS-.cjs.map +1 -0
- package/cjs/histogram-BaI-PnCv.cjs +102 -0
- package/cjs/histogram-BaI-PnCv.cjs.map +1 -0
- package/cjs/http-DCfXQvw-.cjs +870 -0
- package/cjs/http-DCfXQvw-.cjs.map +1 -0
- package/cjs/index.cjs +2 -1
- package/cjs/insights-BKtqxdnP.cjs +811 -0
- package/cjs/insights-BKtqxdnP.cjs.map +1 -0
- package/cjs/ip-DbNhPOzi.cjs +153 -0
- package/cjs/ip-DbNhPOzi.cjs.map +1 -0
- package/cjs/migrations-w7GMsrQw.cjs +297 -0
- package/cjs/migrations-w7GMsrQw.cjs.map +1 -0
- package/cjs/openapi-CC7OAUc6.cjs +52 -0
- package/cjs/openapi-CC7OAUc6.cjs.map +1 -0
- package/cjs/options-CWqFC5__.cjs +181 -0
- package/cjs/options-CWqFC5__.cjs.map +1 -0
- package/cjs/panels-Rcmeitu3.cjs +318 -0
- package/cjs/panels-Rcmeitu3.cjs.map +1 -0
- package/cjs/process-panel-DEOnLxoT.cjs +48 -0
- package/cjs/process-panel-DEOnLxoT.cjs.map +1 -0
- package/cjs/production/index.cjs +238 -0
- package/cjs/production/index.cjs.map +1 -0
- package/cjs/rolldown-runtime-Zuuoy_Rh.cjs +52 -0
- package/cjs/server-ykxsOwob.cjs +184 -0
- package/cjs/server-ykxsOwob.cjs.map +1 -0
- package/cjs/{src-Xwm3Eel9.cjs → src-UPtTCI2j.cjs} +210 -293
- package/cjs/src-UPtTCI2j.cjs.map +1 -0
- package/cjs/store-aq207T8v.cjs +9 -0
- package/cjs/stream-route-CJTABkUy.cjs +875 -0
- package/cjs/stream-route-CJTABkUy.cjs.map +1 -0
- package/esm/devtools-connector.d.mts +16 -13
- package/esm/devtools-connector.d.mts.map +1 -1
- package/esm/devtools-connector.mjs +127 -18
- package/esm/devtools-connector.mjs.map +1 -1
- package/esm/index.d.mts +4 -2
- package/esm/index.mjs +2 -1
- package/esm/options.mjs +2 -1
- package/esm/options.mjs.map +1 -1
- package/esm/panel-tokens.d.mts +13 -0
- package/esm/panel-tokens.d.mts.map +1 -0
- package/esm/panel-tokens.mjs +45 -0
- package/esm/panel-tokens.mjs.map +1 -0
- package/esm/panels.mjs +73 -8
- package/esm/panels.mjs.map +1 -1
- package/esm/production/auth/common-passwords.mjs +303 -0
- package/esm/production/auth/common-passwords.mjs.map +1 -0
- package/esm/production/auth/default-crypto.mjs +19 -0
- package/esm/production/auth/default-crypto.mjs.map +1 -0
- package/esm/production/auth/helpers.mjs +77 -0
- package/esm/production/auth/helpers.mjs.map +1 -0
- package/esm/production/auth/index.mjs +6 -0
- package/esm/production/auth/passkeys.mjs +96 -0
- package/esm/production/auth/passkeys.mjs.map +1 -0
- package/esm/production/auth/service.mjs +1166 -0
- package/esm/production/auth/service.mjs.map +1 -0
- package/esm/production/boot.mjs +138 -0
- package/esm/production/boot.mjs.map +1 -0
- package/esm/production/capture/dev-stats.mjs +83 -0
- package/esm/production/capture/dev-stats.mjs.map +1 -0
- package/esm/production/capture/engine.mjs +442 -0
- package/esm/production/capture/engine.mjs.map +1 -0
- package/esm/production/capture/explain.mjs +271 -0
- package/esm/production/capture/explain.mjs.map +1 -0
- package/esm/production/capture/filter.mjs +24 -0
- package/esm/production/capture/filter.mjs.map +1 -0
- package/esm/production/capture/index.mjs +7 -0
- package/esm/production/capture/production-capture.mjs +134 -0
- package/esm/production/capture/production-capture.mjs.map +1 -0
- package/esm/production/capture/redact.mjs +109 -0
- package/esm/production/capture/redact.mjs.map +1 -0
- package/esm/production/capture/stats-stores.mjs +300 -0
- package/esm/production/capture/stats-stores.mjs.map +1 -0
- package/esm/production/cli/actions.mjs +151 -0
- package/esm/production/cli/actions.mjs.map +1 -0
- package/esm/production/cli/index.d.mts +17 -0
- package/esm/production/cli/index.d.mts.map +1 -0
- package/esm/production/cli/index.mjs +86 -0
- package/esm/production/cli/index.mjs.map +1 -0
- package/esm/production/contracts.d.mts +592 -0
- package/esm/production/contracts.d.mts.map +1 -0
- package/esm/production/contracts.mjs +95 -0
- package/esm/production/contracts.mjs.map +1 -0
- package/esm/production/errors.d.mts +31 -0
- package/esm/production/errors.d.mts.map +1 -0
- package/esm/production/errors.mjs +142 -0
- package/esm/production/errors.mjs.map +1 -0
- package/esm/production/http/access.mjs +124 -0
- package/esm/production/http/access.mjs.map +1 -0
- package/esm/production/http/auth-routes.mjs +280 -0
- package/esm/production/http/auth-routes.mjs.map +1 -0
- package/esm/production/http/client.mjs +57 -0
- package/esm/production/http/client.mjs.map +1 -0
- package/esm/production/http/constants.mjs +11 -0
- package/esm/production/http/constants.mjs.map +1 -0
- package/esm/production/http/context.mjs +14 -0
- package/esm/production/http/context.mjs.map +1 -0
- package/esm/production/http/cookie.mjs +39 -0
- package/esm/production/http/cookie.mjs.map +1 -0
- package/esm/production/http/headers.mjs +25 -0
- package/esm/production/http/headers.mjs.map +1 -0
- package/esm/production/http/index.mjs +10 -0
- package/esm/production/http/ip.mjs +130 -0
- package/esm/production/http/ip.mjs.map +1 -0
- package/esm/production/http/mount.mjs +300 -0
- package/esm/production/http/mount.mjs.map +1 -0
- package/esm/production/http/state.mjs +54 -0
- package/esm/production/http/state.mjs.map +1 -0
- package/esm/production/index.d.mts +6 -0
- package/esm/production/index.mjs +5 -0
- package/esm/production/insights/cap-report.mjs +67 -0
- package/esm/production/insights/cap-report.mjs.map +1 -0
- package/esm/production/insights/health.mjs +88 -0
- package/esm/production/insights/health.mjs.map +1 -0
- package/esm/production/insights/index.mjs +10 -0
- package/esm/production/insights/insights.mjs +167 -0
- package/esm/production/insights/insights.mjs.map +1 -0
- package/esm/production/insights/instance.mjs +24 -0
- package/esm/production/insights/instance.mjs.map +1 -0
- package/esm/production/insights/jobs.mjs +100 -0
- package/esm/production/insights/jobs.mjs.map +1 -0
- package/esm/production/insights/reporter.mjs +59 -0
- package/esm/production/insights/reporter.mjs.map +1 -0
- package/esm/production/insights/resources.mjs +139 -0
- package/esm/production/insights/resources.mjs.map +1 -0
- package/esm/production/insights/writer.mjs +72 -0
- package/esm/production/insights/writer.mjs.map +1 -0
- package/esm/production/openapi.mjs +52 -0
- package/esm/production/openapi.mjs.map +1 -0
- package/esm/production/options.d.mts +60 -0
- package/esm/production/options.d.mts.map +1 -0
- package/esm/production/options.mjs +170 -0
- package/esm/production/options.mjs.map +1 -0
- package/esm/production/stats/histogram.mjs +67 -0
- package/esm/production/stats/histogram.mjs.map +1 -0
- package/esm/production/stats/merge.mjs +106 -0
- package/esm/production/stats/merge.mjs.map +1 -0
- package/esm/production/store/cascade-store.mjs +322 -0
- package/esm/production/store/cascade-store.mjs.map +1 -0
- package/esm/production/store/index.mjs +5 -0
- package/esm/production/store/mapping.mjs +258 -0
- package/esm/production/store/mapping.mjs.map +1 -0
- package/esm/production/store/memory-store.mjs +291 -0
- package/esm/production/store/memory-store.mjs.map +1 -0
- package/esm/production/store/migrations.d.mts +11 -0
- package/esm/production/store/migrations.d.mts.map +1 -0
- package/esm/production/store/migrations.mjs +29 -0
- package/esm/production/store/migrations.mjs.map +1 -0
- package/esm/production/store/models/account.migration.mjs +34 -0
- package/esm/production/store/models/account.migration.mjs.map +1 -0
- package/esm/production/store/models/account.model.mjs +13 -0
- package/esm/production/store/models/account.model.mjs.map +1 -0
- package/esm/production/store/models/audit.migration.mjs +30 -0
- package/esm/production/store/models/audit.migration.mjs.map +1 -0
- package/esm/production/store/models/audit.model.mjs +13 -0
- package/esm/production/store/models/audit.model.mjs.map +1 -0
- package/esm/production/store/models/base.mjs +27 -0
- package/esm/production/store/models/base.mjs.map +1 -0
- package/esm/production/store/models/index.mjs +17 -0
- package/esm/production/store/models/invite.migration.mjs +26 -0
- package/esm/production/store/models/invite.migration.mjs.map +1 -0
- package/esm/production/store/models/invite.model.mjs +13 -0
- package/esm/production/store/models/invite.model.mjs.map +1 -0
- package/esm/production/store/models/report.migration.mjs +20 -0
- package/esm/production/store/models/report.migration.mjs.map +1 -0
- package/esm/production/store/models/report.model.mjs +13 -0
- package/esm/production/store/models/report.model.mjs.map +1 -0
- package/esm/production/store/models/sample.migration.mjs +25 -0
- package/esm/production/store/models/sample.migration.mjs.map +1 -0
- package/esm/production/store/models/sample.model.mjs +13 -0
- package/esm/production/store/models/sample.model.mjs.map +1 -0
- package/esm/production/store/models/session.migration.mjs +31 -0
- package/esm/production/store/models/session.migration.mjs.map +1 -0
- package/esm/production/store/models/session.model.mjs +13 -0
- package/esm/production/store/models/session.model.mjs.map +1 -0
- package/esm/production/store/models/state.migration.mjs +26 -0
- package/esm/production/store/models/state.migration.mjs.map +1 -0
- package/esm/production/store/models/state.model.mjs +13 -0
- package/esm/production/store/models/state.model.mjs.map +1 -0
- package/esm/query-shape.mjs +14 -1
- package/esm/query-shape.mjs.map +1 -1
- package/esm/server/explain-route.mjs +26 -1
- package/esm/server/explain-route.mjs.map +1 -1
- package/esm/server/index.mjs +9 -4
- package/esm/server/index.mjs.map +1 -1
- package/esm/server/insights-routes.mjs +62 -0
- package/esm/server/insights-routes.mjs.map +1 -0
- package/esm/server/log-routes.mjs +32 -5
- package/esm/server/log-routes.mjs.map +1 -1
- package/esm/server/openapi-routes.mjs +3 -2
- package/esm/server/openapi-routes.mjs.map +1 -1
- package/esm/server/requests-routes.mjs +125 -0
- package/esm/server/requests-routes.mjs.map +1 -1
- package/esm/server/session-routes.mjs +42 -0
- package/esm/server/session-routes.mjs.map +1 -0
- package/esm/server/stream-route.mjs +81 -11
- package/esm/server/stream-route.mjs.map +1 -1
- package/esm/server/ui-assets.mjs +34 -25
- package/esm/server/ui-assets.mjs.map +1 -1
- package/esm/sources/log-source.mjs +14 -1
- package/esm/sources/log-source.mjs.map +1 -1
- package/esm/types.d.mts +208 -3
- package/esm/types.d.mts.map +1 -1
- package/esm/ui-root.mjs +9 -4
- package/esm/ui-root.mjs.map +1 -1
- package/llms-full.txt +166 -21
- package/llms.txt +2 -2
- package/package.json +32 -8
- package/skills/SKILL.md +166 -21
- package/ui/dashboard/assets/app.css +3 -0
- package/ui/dashboard/assets/app.js +50 -0
- package/ui/dashboard/build-info.json +21 -0
- package/ui/dashboard/index.html +16 -0
- package/ui/panels/processes.js +12 -3
- package/cjs/ai-source-Dz_3tlZ5.cjs +0 -703
- package/cjs/ai-source-Dz_3tlZ5.cjs.map +0 -1
- package/cjs/server-B11ShQYE.cjs +0 -628
- package/cjs/server-B11ShQYE.cjs.map +0 -1
- package/cjs/src-Xwm3Eel9.cjs.map +0 -1
- package/ui/app.css +0 -376
- package/ui/app.js +0 -1158
- package/ui/index.html +0 -28
package/llms-full.txt
CHANGED
|
@@ -8,14 +8,17 @@
|
|
|
8
8
|
|
|
9
9
|
---
|
|
10
10
|
name: warlock-js-devtools
|
|
11
|
-
description: '
|
|
11
|
+
description: 'Dev dashboard and opt-in production monitor for Warlock apps via `devtoolsConnector`: request timelines, queries, N+1, errors, resources, health, jobs, mail, routes. Use for "debug a slow endpoint", "monitor production", "devtools DT00x error", "reset devtools admin" or "add a devtools panel". Not this package → @warlock.js/core for `warlock trace` and OpenAPI; @warlock.js/ai-panoptic for AI tracing.'
|
|
12
12
|
---
|
|
13
13
|
|
|
14
14
|
# `@warlock.js/devtools` — overview
|
|
15
15
|
|
|
16
|
-
A dashboard
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
A dashboard served by your own app. In **development** it lives at `/__warlock`
|
|
17
|
+
and answers loopback clients only. In **production** it is an opt-in monitor at
|
|
18
|
+
a secret path (see "Production monitor" below). It shows what each request did:
|
|
19
|
+
its timing waterfall, the queries it ran, the cache operations, the logs, and
|
|
20
|
+
any mail it sent, plus query and route statistics, errors, resources, health
|
|
21
|
+
and jobs. The dashboard is a React app; panel view modules work as before.
|
|
19
22
|
|
|
20
23
|
## Install: one command, no config
|
|
21
24
|
|
|
@@ -27,9 +30,9 @@ warlock dev # open http://localhost:<port>/__warlock
|
|
|
27
30
|
There's nothing to register. `warlock dev` loads devtools automatically when
|
|
28
31
|
the package is installed.
|
|
29
32
|
|
|
30
|
-
|
|
31
|
-
dev dependency, so a production install doesn't have it
|
|
32
|
-
|
|
33
|
+
For development only, do not add `devtoolsConnector()` to `warlock.config.ts`:
|
|
34
|
+
it is a dev dependency, so a production install doesn't have it. For the
|
|
35
|
+
production monitor you do add it, as a regular dependency (next sections).
|
|
33
36
|
|
|
34
37
|
## Why it can't leak into production
|
|
35
38
|
|
|
@@ -60,17 +63,21 @@ export default {
|
|
|
60
63
|
|
|
61
64
|
## What each panel shows
|
|
62
65
|
|
|
63
|
-
| Panel
|
|
64
|
-
|
|
|
65
|
-
| **Requests**
|
|
66
|
-
| **Queries**
|
|
67
|
-
| **N+1**
|
|
68
|
-
| **Mail**
|
|
69
|
-
| **Logs**
|
|
70
|
-
| **Cache**
|
|
71
|
-
| **
|
|
72
|
-
| **
|
|
73
|
-
| **
|
|
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()` |
|
|
74
81
|
|
|
75
82
|
Work outside a request (boot, scheduler ticks, queue jobs) goes to a separate
|
|
76
83
|
background list, so it never clutters a request's timeline.
|
|
@@ -213,7 +220,8 @@ phases, queries flagged `nPlusOne`, warnings, logs and timings. See the
|
|
|
213
220
|
|
|
214
221
|
Query bindings and log context go through the logger's redaction rules
|
|
215
222
|
before they're stored. The data is still real request data, which is exactly
|
|
216
|
-
why the dashboard is
|
|
223
|
+
why the development dashboard is loopback-only. The production monitor removes
|
|
224
|
+
values before storing anything (see "Production monitor").
|
|
217
225
|
|
|
218
226
|
## Related
|
|
219
227
|
|
|
@@ -233,6 +241,130 @@ endpoint retains development/loopback guards and provides no stop action.
|
|
|
233
241
|
Use the `warlock-js-process` skill for launch,
|
|
234
242
|
recovery and stop APIs; configure one owner/registry per application instance.
|
|
235
243
|
|
|
244
|
+
## Production monitor
|
|
245
|
+
|
|
246
|
+
Opt in: nothing is mounted or captured in production unless
|
|
247
|
+
`production.enabled` is `true`. Install the package as a regular dependency,
|
|
248
|
+
then register it in `warlock.config.ts`. `@warlock.js/devtools/production`
|
|
249
|
+
exports `devtoolsMigrations` and `registerDevtoolsCommands`, which adds the
|
|
250
|
+
`devtools:enable` and `devtools:reset-admin` commands.
|
|
251
|
+
|
|
252
|
+
```ts
|
|
253
|
+
import { defineConfig } from "@warlock.js/core";
|
|
254
|
+
import { devtoolsConnector } from "@warlock.js/devtools";
|
|
255
|
+
import { devtoolsMigrations, registerDevtoolsCommands } from "@warlock.js/devtools/production";
|
|
256
|
+
|
|
257
|
+
export default defineConfig({
|
|
258
|
+
connectors: [devtoolsConnector()],
|
|
259
|
+
cli: { commands: [registerDevtoolsCommands()] },
|
|
260
|
+
database: { migrations: [...devtoolsMigrations] },
|
|
261
|
+
});
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
Then run `warlock migrate`, and enable it in `src/config/devtools.ts`:
|
|
265
|
+
|
|
266
|
+
```ts
|
|
267
|
+
export default {
|
|
268
|
+
panels: ["@warlock.js/grimoire/devtools"],
|
|
269
|
+
production: {
|
|
270
|
+
enabled: true,
|
|
271
|
+
trustedProxies: ["loopback"],
|
|
272
|
+
sampleRate: 0.1,
|
|
273
|
+
},
|
|
274
|
+
};
|
|
275
|
+
```
|
|
276
|
+
|
|
277
|
+
Environment variables:
|
|
278
|
+
|
|
279
|
+
- `DEVTOOLS_PATH`: the secret dashboard path (`/ops-7f3k2q9x`; at least 8 characters, never `/__warlock`).
|
|
280
|
+
- `DEVTOOLS_ADMIN_EMAIL` with `DEVTOOLS_ADMIN_PASSWORD` (changed at first sign-in) or `DEVTOOLS_SETUP_TOKEN` (32+ characters; the admin opens `<origin><path>/#/setup/<token>`). Not both.
|
|
281
|
+
- `encryption.key` (64 hex characters) must be set in `src/config/encryption.ts`.
|
|
282
|
+
|
|
283
|
+
The accounts live in the app's database through Cascade. Roles are `viewer`
|
|
284
|
+
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
|
|
286
|
+
authenticator app, or passkeys when `@simplewebauthn/server` is installed, plus
|
|
287
|
+
10 recovery codes. Every closed case answers the app's own 404.
|
|
288
|
+
|
|
289
|
+
Options under `production` (all optional, defaults in brackets):
|
|
290
|
+
`enabled` [false], `path` [`DEVTOOLS_PATH`], `sampleRate` [0.1],
|
|
291
|
+
`slowRequestMs` [1000], `slowQueryMs` [200], `maxRequests` [200],
|
|
292
|
+
`requestRetentionHours` [24], `maxStoredSamplesPerMinute` [120],
|
|
293
|
+
`reportIntervalMs` [10000], `trustedProxies` [[]], `requireHttps` [true],
|
|
294
|
+
`allowedIps` [[]], `origin`, `session.idleMinutes` [30], `session.maxHours` [8],
|
|
295
|
+
`twoFactor` ["admins"], `rateLimits.windowMinutes` [15], `rateLimits.account`
|
|
296
|
+
[5], `rateLimits.ip` [20], `rateLimits.global` [100], `rateLimits.lockMinutes`
|
|
297
|
+
[15], `explain.executing` [false], `panels` [{}], `logLevels` [warn, error],
|
|
298
|
+
`auditRetentionDays` [90], `passkeys.rpName`, `passkeys.rpId`.
|
|
299
|
+
|
|
300
|
+
- Redaction: queries are stored as their shape (no literals or bindings), logs
|
|
301
|
+
lose `context`, phases lose `attrs`, cache keys become counts, request error
|
|
302
|
+
messages and stacks, and error-level log lines, lose quoted values, emails and `{ … }` documents, headers
|
|
303
|
+
and bodies come only from core's request log. Paths are kept (no query
|
|
304
|
+
string): keep secrets out of URL paths.
|
|
305
|
+
- EXPLAIN is admin-only and plain (`EXPLAIN (FORMAT JSON)`, MongoDB
|
|
306
|
+
`queryPlanner`), for one read statement only (a MongoDB aggregate with `$out`
|
|
307
|
+
or `$merge` never). PostgreSQL plans run in a read-only transaction that is
|
|
308
|
+
rolled back. `explain.executing: true` allows `EXPLAIN ANALYZE` and
|
|
309
|
+
`executionStats`; they run the query, so leave it off unless accepted.
|
|
310
|
+
Production plans show `?` in place of the query's values.
|
|
311
|
+
- MongoDB: with `devtools.production.enabled` in `src/config/devtools.ts`, core
|
|
312
|
+
turns `queryEvents` on in processes that serve HTTP (command monitoring is off
|
|
313
|
+
in production by default); an explicit `queryEvents: false` wins. With the
|
|
314
|
+
option passed only to `devtoolsConnector()`, set `queryEvents: true` yourself.
|
|
315
|
+
- A correct password does not reset an account's failed-try count; only a
|
|
316
|
+
completed sign-in (second factor included) does. A caller over the IP limit
|
|
317
|
+
costs no password check, and refused tries are audited at most once a minute
|
|
318
|
+
per address and account. The per-IP limit counts an IPv6 client by its /64
|
|
319
|
+
(an IPv4-mapped address as its IPv4 address).
|
|
320
|
+
- From the account page, adding or removing a second factor needs the current
|
|
321
|
+
password (`current` in the JSON body, also on `DELETE api/account/totp` and
|
|
322
|
+
`DELETE api/account/passkeys/:id`); removing also accepts a passkey check
|
|
323
|
+
from the last five minutes. New recovery codes need a TOTP code or that
|
|
324
|
+
passkey check, which is single use.
|
|
325
|
+
- Several instances share the database: each writes a report every 10 s, the
|
|
326
|
+
instance picker filters, the live stream is per instance.
|
|
327
|
+
- Disable from the dashboard (admin); re-enable with `warlock devtools:enable`
|
|
328
|
+
or a new `DEVTOOLS_PATH`. Lost admin: `warlock devtools:reset-admin --email <email>`.
|
|
329
|
+
- Behind a proxy set `trustedProxies`, set `origin`, and have the proxy set
|
|
330
|
+
(not pass through) `X-Forwarded-For`, `X-Forwarded-Proto` and
|
|
331
|
+
`X-Forwarded-Host`; turn off proxy buffering (or rely on
|
|
332
|
+
`X-Accel-Buffering: no`) for the live view.
|
|
333
|
+
- Tabs on in production: requests, queries, routes, resources, health, errors,
|
|
334
|
+
logs, jobs. `mail`, `ai`, `agents`, `api`, `processes` need
|
|
335
|
+
`panels: { id: true }`. A package panel needs `production: true` or the same.
|
|
336
|
+
- Panel writes in production need an admin and the `X-Devtools-Csrf` header
|
|
337
|
+
(`api()` adds it); they are audited.
|
|
338
|
+
|
|
339
|
+
### When something fails
|
|
340
|
+
|
|
341
|
+
The app refuses to boot with a `DevtoolsProductionConfigError`
|
|
342
|
+
(`DEVTOOLS_CONFIG_CODES` holds the messages):
|
|
343
|
+
|
|
344
|
+
| Code | Fix |
|
|
345
|
+
| ------- | --------------------------------------------------------------------------------------------------------------------------- |
|
|
346
|
+
| `DT001` | Set `DEVTOOLS_PATH` or `production.path`. |
|
|
347
|
+
| `DT002` | Use a path of 8+ characters starting with `/`, with letters, digits and `- _ . ~ /` only; not `/__warlock`. |
|
|
348
|
+
| `DT003` | No admin: set `DEVTOOLS_ADMIN_EMAIL` plus a password or setup token, or run `warlock devtools:reset-admin --email <email>`. |
|
|
349
|
+
| `DT004` | The env password breaks the rules (8+ characters, at most 72 bytes, not common, not the email). |
|
|
350
|
+
| `DT005` | Install `@warlock.js/cascade` and configure a database. |
|
|
351
|
+
| `DT006` | Set `encryption.key` (64 hex characters). |
|
|
352
|
+
| `DT007` | An option is invalid; the message names it. |
|
|
353
|
+
| `DT008` | Add `devtoolsMigrations` to `database.migrations` and run `warlock migrate`. |
|
|
354
|
+
| `DT009` | Set the password or the setup token, not both. |
|
|
355
|
+
| `DT010` | The setup token needs 32+ characters (`openssl rand -base64 32`). |
|
|
356
|
+
|
|
357
|
+
Every dashboard URL gives a 404: check that `production.enabled` is true, the
|
|
358
|
+
dashboard is not disabled or locked (`warlock devtools:enable`), the request is
|
|
359
|
+
HTTPS (`trustedProxies`), the IP is in `allowedIps`, the tab is not turned off,
|
|
360
|
+
and you opened the exact `DEVTOOLS_PATH`. Most closed cases log nothing on
|
|
361
|
+
purpose. The boot line `devtools production monitor mounted at /ops-… (DEVTOOLS_PATH)`
|
|
362
|
+
shows the monitor started; the audit log has `dashboard.disabled`,
|
|
363
|
+
`dashboard.locked` and `login.blocked`; only an unreadable state or session
|
|
364
|
+
store logs a warning (`devtools`, at most once a minute).
|
|
365
|
+
|
|
366
|
+
Full pages: "Devtools in production" and "Devtools security" in the docs.
|
|
367
|
+
|
|
236
368
|
## Registering a panel
|
|
237
369
|
|
|
238
370
|
A package or the app adds a tab with one line in `src/config/devtools.ts`:
|
|
@@ -240,6 +372,7 @@ A package or the app adds a tab with one line in `src/config/devtools.ts`:
|
|
|
240
372
|
```ts
|
|
241
373
|
export default {
|
|
242
374
|
panels: ["@acme/queue/devtools"], // or "./src/devtools/queue-panel.ts"
|
|
375
|
+
// pass options to a panel factory (root and mode always win): [["@acme/queue/devtools", { pageSize: 50 }]]
|
|
243
376
|
};
|
|
244
377
|
```
|
|
245
378
|
|
|
@@ -278,10 +411,22 @@ export default queuePanel;
|
|
|
278
411
|
that opens that view (`route` is then `"jobs/7"`); `svg()` builds SVG
|
|
279
412
|
elements for small graphs. Build text with `text`, never `innerHTML`.
|
|
280
413
|
- Every panel route, view and asset sits behind the devtools guard
|
|
281
|
-
(development
|
|
282
|
-
headers). A reused id (the built-in `processes` included) or a dashboard id
|
|
414
|
+
(in development: loopback socket and host, no foreign `Origin`, no proxy
|
|
415
|
+
headers; in production: sign-in). A reused id (the built-in `processes` included) or a dashboard id
|
|
283
416
|
such as `mail` is refused; devtools logs why and leaves the panel out.
|
|
284
417
|
|
|
418
|
+
A panel can set `production: true` when it is safe in the production monitor
|
|
419
|
+
(otherwise it needs `production.panels[id]: true`). The factory receives
|
|
420
|
+
`{ root, mode }`; `mode` is `"development"` or `"production"`, and a panel must
|
|
421
|
+
not write files in production. The ids `resources`, `health`, `errors`, `jobs`,
|
|
422
|
+
`instances`, `auth`, `account` and `admin` are reserved.
|
|
423
|
+
|
|
285
424
|
Full reference: the "Registering a panel" page of the devtools docs.
|
|
286
425
|
|
|
426
|
+
Panel styling: a package panel's CSS may use only the dashboard's variables (`DEVTOOLS_PANEL_TOKENS`, exported by
|
|
427
|
+
`@warlock.js/devtools`: `--background --foreground --card --muted --muted-foreground --accent --border --brand
|
|
428
|
+
--success --warning --info --destructive --chart-1..5` and the other shadcn names) plus variables it defines itself.
|
|
429
|
+
Never use another name (such as `--text` or `--surface`): the dashboard does not define it, and text can become
|
|
430
|
+
unreadable. The text tokens meet 4.5:1 contrast on `--background` and `--card` in both themes.
|
|
431
|
+
|
|
287
432
|
|
package/llms.txt
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
> Package: `@warlock.js/devtools`
|
|
4
4
|
|
|
5
|
-
>
|
|
5
|
+
> Dashboard for Warlock.js apps: request timeline, queries with EXPLAIN, N+1 detection, resources, health, errors, logs and jobs. Loopback-only at /__warlock in development; an opt-in, signed-in monitor at a secret path in production.
|
|
6
6
|
|
|
7
7
|
## Skills
|
|
8
8
|
|
|
9
|
-
- [devtools](@warlock.js/devtools/skills/SKILL.md):
|
|
9
|
+
- [devtools](@warlock.js/devtools/skills/SKILL.md): Dev dashboard and opt-in production monitor for Warlock apps via `devtoolsConnector`: request timelines, queries, N+1, errors, resources, health, jobs, mail, routes. Use for "debug a slow endpoint", "monitor production", "devtools DT00x error", "reset devtools admin" or "add a devtools panel". Not this package → @warlock.js/core for `warlock trace` and OpenAPI; @warlock.js/ai-panoptic for AI tracing.
|
package/package.json
CHANGED
|
@@ -1,17 +1,23 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@warlock.js/devtools",
|
|
3
|
-
"description": "
|
|
3
|
+
"description": "Dashboard for Warlock.js apps: request timeline, queries with EXPLAIN, N+1 detection, resources, health, errors, logs and jobs. Loopback-only at /__warlock in development; an opt-in, signed-in monitor at a secret path in production.",
|
|
4
4
|
"warlock": {
|
|
5
5
|
"environment": "server"
|
|
6
6
|
},
|
|
7
7
|
"peerDependencies": {
|
|
8
|
-
"@
|
|
9
|
-
"@warlock.js/
|
|
10
|
-
"@warlock.js/
|
|
11
|
-
"@warlock.js/
|
|
12
|
-
"@warlock.js/
|
|
8
|
+
"@simplewebauthn/server": "^13.1.0",
|
|
9
|
+
"@warlock.js/ai-panoptic": "5.57.0",
|
|
10
|
+
"@warlock.js/cache": "5.57.0",
|
|
11
|
+
"@warlock.js/cascade": "5.57.0",
|
|
12
|
+
"@warlock.js/core": "5.57.0",
|
|
13
|
+
"@warlock.js/logger": "5.57.0",
|
|
14
|
+
"@warlock.js/queue": "5.57.0",
|
|
15
|
+
"@warlock.js/scheduler": "5.57.0"
|
|
13
16
|
},
|
|
14
17
|
"peerDependenciesMeta": {
|
|
18
|
+
"@simplewebauthn/server": {
|
|
19
|
+
"optional": true
|
|
20
|
+
},
|
|
15
21
|
"@warlock.js/ai-panoptic": {
|
|
16
22
|
"optional": true
|
|
17
23
|
},
|
|
@@ -20,6 +26,12 @@
|
|
|
20
26
|
},
|
|
21
27
|
"@warlock.js/cascade": {
|
|
22
28
|
"optional": true
|
|
29
|
+
},
|
|
30
|
+
"@warlock.js/queue": {
|
|
31
|
+
"optional": true
|
|
32
|
+
},
|
|
33
|
+
"@warlock.js/scheduler": {
|
|
34
|
+
"optional": true
|
|
23
35
|
}
|
|
24
36
|
},
|
|
25
37
|
"repository": {
|
|
@@ -34,11 +46,13 @@
|
|
|
34
46
|
"profiler",
|
|
35
47
|
"n+1",
|
|
36
48
|
"timeline",
|
|
37
|
-
"mailbox"
|
|
49
|
+
"mailbox",
|
|
50
|
+
"monitoring",
|
|
51
|
+
"production"
|
|
38
52
|
],
|
|
39
53
|
"author": "hassanzohdy",
|
|
40
54
|
"license": "MIT",
|
|
41
|
-
"version": "5.
|
|
55
|
+
"version": "5.57.0",
|
|
42
56
|
"main": "./cjs/index.cjs",
|
|
43
57
|
"module": "./esm/index.mjs",
|
|
44
58
|
"types": "./esm/index.d.mts",
|
|
@@ -52,6 +66,16 @@
|
|
|
52
66
|
"types": "./esm/index.d.mts",
|
|
53
67
|
"default": "./cjs/index.cjs"
|
|
54
68
|
}
|
|
69
|
+
},
|
|
70
|
+
"./production": {
|
|
71
|
+
"import": {
|
|
72
|
+
"types": "./esm/production/index.d.mts",
|
|
73
|
+
"default": "./esm/production/index.mjs"
|
|
74
|
+
},
|
|
75
|
+
"require": {
|
|
76
|
+
"types": "./esm/production/index.d.mts",
|
|
77
|
+
"default": "./cjs/production/index.cjs"
|
|
78
|
+
}
|
|
55
79
|
}
|
|
56
80
|
}
|
|
57
81
|
}
|
package/skills/SKILL.md
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: warlock-js-devtools
|
|
3
|
-
description: '
|
|
3
|
+
description: 'Dev dashboard and opt-in production monitor for Warlock apps via `devtoolsConnector`: request timelines, queries, N+1, errors, resources, health, jobs, mail, routes. Use for "debug a slow endpoint", "monitor production", "devtools DT00x error", "reset devtools admin" or "add a devtools panel". Not this package → @warlock.js/core for `warlock trace` and OpenAPI; @warlock.js/ai-panoptic for AI tracing.'
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# `@warlock.js/devtools` — overview
|
|
7
7
|
|
|
8
|
-
A dashboard
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
A dashboard served by your own app. In **development** it lives at `/__warlock`
|
|
9
|
+
and answers loopback clients only. In **production** it is an opt-in monitor at
|
|
10
|
+
a secret path (see "Production monitor" below). It shows what each request did:
|
|
11
|
+
its timing waterfall, the queries it ran, the cache operations, the logs, and
|
|
12
|
+
any mail it sent, plus query and route statistics, errors, resources, health
|
|
13
|
+
and jobs. The dashboard is a React app; panel view modules work as before.
|
|
11
14
|
|
|
12
15
|
## Install: one command, no config
|
|
13
16
|
|
|
@@ -19,9 +22,9 @@ warlock dev # open http://localhost:<port>/__warlock
|
|
|
19
22
|
There's nothing to register. `warlock dev` loads devtools automatically when
|
|
20
23
|
the package is installed.
|
|
21
24
|
|
|
22
|
-
|
|
23
|
-
dev dependency, so a production install doesn't have it
|
|
24
|
-
|
|
25
|
+
For development only, do not add `devtoolsConnector()` to `warlock.config.ts`:
|
|
26
|
+
it is a dev dependency, so a production install doesn't have it. For the
|
|
27
|
+
production monitor you do add it, as a regular dependency (next sections).
|
|
25
28
|
|
|
26
29
|
## Why it can't leak into production
|
|
27
30
|
|
|
@@ -52,17 +55,21 @@ export default {
|
|
|
52
55
|
|
|
53
56
|
## What each panel shows
|
|
54
57
|
|
|
55
|
-
| Panel
|
|
56
|
-
|
|
|
57
|
-
| **Requests**
|
|
58
|
-
| **Queries**
|
|
59
|
-
| **N+1**
|
|
60
|
-
| **Mail**
|
|
61
|
-
| **Logs**
|
|
62
|
-
| **Cache**
|
|
63
|
-
| **
|
|
64
|
-
| **
|
|
65
|
-
| **
|
|
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()` |
|
|
66
73
|
|
|
67
74
|
Work outside a request (boot, scheduler ticks, queue jobs) goes to a separate
|
|
68
75
|
background list, so it never clutters a request's timeline.
|
|
@@ -205,7 +212,8 @@ phases, queries flagged `nPlusOne`, warnings, logs and timings. See the
|
|
|
205
212
|
|
|
206
213
|
Query bindings and log context go through the logger's redaction rules
|
|
207
214
|
before they're stored. The data is still real request data, which is exactly
|
|
208
|
-
why the dashboard is
|
|
215
|
+
why the development dashboard is loopback-only. The production monitor removes
|
|
216
|
+
values before storing anything (see "Production monitor").
|
|
209
217
|
|
|
210
218
|
## Related
|
|
211
219
|
|
|
@@ -225,6 +233,130 @@ endpoint retains development/loopback guards and provides no stop action.
|
|
|
225
233
|
Use the `warlock-js-process` skill for launch,
|
|
226
234
|
recovery and stop APIs; configure one owner/registry per application instance.
|
|
227
235
|
|
|
236
|
+
## Production monitor
|
|
237
|
+
|
|
238
|
+
Opt in: nothing is mounted or captured in production unless
|
|
239
|
+
`production.enabled` is `true`. Install the package as a regular dependency,
|
|
240
|
+
then register it in `warlock.config.ts`. `@warlock.js/devtools/production`
|
|
241
|
+
exports `devtoolsMigrations` and `registerDevtoolsCommands`, which adds the
|
|
242
|
+
`devtools:enable` and `devtools:reset-admin` commands.
|
|
243
|
+
|
|
244
|
+
```ts
|
|
245
|
+
import { defineConfig } from "@warlock.js/core";
|
|
246
|
+
import { devtoolsConnector } from "@warlock.js/devtools";
|
|
247
|
+
import { devtoolsMigrations, registerDevtoolsCommands } from "@warlock.js/devtools/production";
|
|
248
|
+
|
|
249
|
+
export default defineConfig({
|
|
250
|
+
connectors: [devtoolsConnector()],
|
|
251
|
+
cli: { commands: [registerDevtoolsCommands()] },
|
|
252
|
+
database: { migrations: [...devtoolsMigrations] },
|
|
253
|
+
});
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
Then run `warlock migrate`, and enable it in `src/config/devtools.ts`:
|
|
257
|
+
|
|
258
|
+
```ts
|
|
259
|
+
export default {
|
|
260
|
+
panels: ["@warlock.js/grimoire/devtools"],
|
|
261
|
+
production: {
|
|
262
|
+
enabled: true,
|
|
263
|
+
trustedProxies: ["loopback"],
|
|
264
|
+
sampleRate: 0.1,
|
|
265
|
+
},
|
|
266
|
+
};
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
Environment variables:
|
|
270
|
+
|
|
271
|
+
- `DEVTOOLS_PATH`: the secret dashboard path (`/ops-7f3k2q9x`; at least 8 characters, never `/__warlock`).
|
|
272
|
+
- `DEVTOOLS_ADMIN_EMAIL` with `DEVTOOLS_ADMIN_PASSWORD` (changed at first sign-in) or `DEVTOOLS_SETUP_TOKEN` (32+ characters; the admin opens `<origin><path>/#/setup/<token>`). Not both.
|
|
273
|
+
- `encryption.key` (64 hex characters) must be set in `src/config/encryption.ts`.
|
|
274
|
+
|
|
275
|
+
The accounts live in the app's database through Cascade. Roles are `viewer`
|
|
276
|
+
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
|
|
278
|
+
authenticator app, or passkeys when `@simplewebauthn/server` is installed, plus
|
|
279
|
+
10 recovery codes. Every closed case answers the app's own 404.
|
|
280
|
+
|
|
281
|
+
Options under `production` (all optional, defaults in brackets):
|
|
282
|
+
`enabled` [false], `path` [`DEVTOOLS_PATH`], `sampleRate` [0.1],
|
|
283
|
+
`slowRequestMs` [1000], `slowQueryMs` [200], `maxRequests` [200],
|
|
284
|
+
`requestRetentionHours` [24], `maxStoredSamplesPerMinute` [120],
|
|
285
|
+
`reportIntervalMs` [10000], `trustedProxies` [[]], `requireHttps` [true],
|
|
286
|
+
`allowedIps` [[]], `origin`, `session.idleMinutes` [30], `session.maxHours` [8],
|
|
287
|
+
`twoFactor` ["admins"], `rateLimits.windowMinutes` [15], `rateLimits.account`
|
|
288
|
+
[5], `rateLimits.ip` [20], `rateLimits.global` [100], `rateLimits.lockMinutes`
|
|
289
|
+
[15], `explain.executing` [false], `panels` [{}], `logLevels` [warn, error],
|
|
290
|
+
`auditRetentionDays` [90], `passkeys.rpName`, `passkeys.rpId`.
|
|
291
|
+
|
|
292
|
+
- Redaction: queries are stored as their shape (no literals or bindings), logs
|
|
293
|
+
lose `context`, phases lose `attrs`, cache keys become counts, request error
|
|
294
|
+
messages and stacks, and error-level log lines, lose quoted values, emails and `{ … }` documents, headers
|
|
295
|
+
and bodies come only from core's request log. Paths are kept (no query
|
|
296
|
+
string): keep secrets out of URL paths.
|
|
297
|
+
- EXPLAIN is admin-only and plain (`EXPLAIN (FORMAT JSON)`, MongoDB
|
|
298
|
+
`queryPlanner`), for one read statement only (a MongoDB aggregate with `$out`
|
|
299
|
+
or `$merge` never). PostgreSQL plans run in a read-only transaction that is
|
|
300
|
+
rolled back. `explain.executing: true` allows `EXPLAIN ANALYZE` and
|
|
301
|
+
`executionStats`; they run the query, so leave it off unless accepted.
|
|
302
|
+
Production plans show `?` in place of the query's values.
|
|
303
|
+
- MongoDB: with `devtools.production.enabled` in `src/config/devtools.ts`, core
|
|
304
|
+
turns `queryEvents` on in processes that serve HTTP (command monitoring is off
|
|
305
|
+
in production by default); an explicit `queryEvents: false` wins. With the
|
|
306
|
+
option passed only to `devtoolsConnector()`, set `queryEvents: true` yourself.
|
|
307
|
+
- A correct password does not reset an account's failed-try count; only a
|
|
308
|
+
completed sign-in (second factor included) does. A caller over the IP limit
|
|
309
|
+
costs no password check, and refused tries are audited at most once a minute
|
|
310
|
+
per address and account. The per-IP limit counts an IPv6 client by its /64
|
|
311
|
+
(an IPv4-mapped address as its IPv4 address).
|
|
312
|
+
- From the account page, adding or removing a second factor needs the current
|
|
313
|
+
password (`current` in the JSON body, also on `DELETE api/account/totp` and
|
|
314
|
+
`DELETE api/account/passkeys/:id`); removing also accepts a passkey check
|
|
315
|
+
from the last five minutes. New recovery codes need a TOTP code or that
|
|
316
|
+
passkey check, which is single use.
|
|
317
|
+
- Several instances share the database: each writes a report every 10 s, the
|
|
318
|
+
instance picker filters, the live stream is per instance.
|
|
319
|
+
- Disable from the dashboard (admin); re-enable with `warlock devtools:enable`
|
|
320
|
+
or a new `DEVTOOLS_PATH`. Lost admin: `warlock devtools:reset-admin --email <email>`.
|
|
321
|
+
- Behind a proxy set `trustedProxies`, set `origin`, and have the proxy set
|
|
322
|
+
(not pass through) `X-Forwarded-For`, `X-Forwarded-Proto` and
|
|
323
|
+
`X-Forwarded-Host`; turn off proxy buffering (or rely on
|
|
324
|
+
`X-Accel-Buffering: no`) for the live view.
|
|
325
|
+
- Tabs on in production: requests, queries, routes, resources, health, errors,
|
|
326
|
+
logs, jobs. `mail`, `ai`, `agents`, `api`, `processes` need
|
|
327
|
+
`panels: { id: true }`. A package panel needs `production: true` or the same.
|
|
328
|
+
- Panel writes in production need an admin and the `X-Devtools-Csrf` header
|
|
329
|
+
(`api()` adds it); they are audited.
|
|
330
|
+
|
|
331
|
+
### When something fails
|
|
332
|
+
|
|
333
|
+
The app refuses to boot with a `DevtoolsProductionConfigError`
|
|
334
|
+
(`DEVTOOLS_CONFIG_CODES` holds the messages):
|
|
335
|
+
|
|
336
|
+
| Code | Fix |
|
|
337
|
+
| ------- | --------------------------------------------------------------------------------------------------------------------------- |
|
|
338
|
+
| `DT001` | Set `DEVTOOLS_PATH` or `production.path`. |
|
|
339
|
+
| `DT002` | Use a path of 8+ characters starting with `/`, with letters, digits and `- _ . ~ /` only; not `/__warlock`. |
|
|
340
|
+
| `DT003` | No admin: set `DEVTOOLS_ADMIN_EMAIL` plus a password or setup token, or run `warlock devtools:reset-admin --email <email>`. |
|
|
341
|
+
| `DT004` | The env password breaks the rules (8+ characters, at most 72 bytes, not common, not the email). |
|
|
342
|
+
| `DT005` | Install `@warlock.js/cascade` and configure a database. |
|
|
343
|
+
| `DT006` | Set `encryption.key` (64 hex characters). |
|
|
344
|
+
| `DT007` | An option is invalid; the message names it. |
|
|
345
|
+
| `DT008` | Add `devtoolsMigrations` to `database.migrations` and run `warlock migrate`. |
|
|
346
|
+
| `DT009` | Set the password or the setup token, not both. |
|
|
347
|
+
| `DT010` | The setup token needs 32+ characters (`openssl rand -base64 32`). |
|
|
348
|
+
|
|
349
|
+
Every dashboard URL gives a 404: check that `production.enabled` is true, the
|
|
350
|
+
dashboard is not disabled or locked (`warlock devtools:enable`), the request is
|
|
351
|
+
HTTPS (`trustedProxies`), the IP is in `allowedIps`, the tab is not turned off,
|
|
352
|
+
and you opened the exact `DEVTOOLS_PATH`. Most closed cases log nothing on
|
|
353
|
+
purpose. The boot line `devtools production monitor mounted at /ops-… (DEVTOOLS_PATH)`
|
|
354
|
+
shows the monitor started; the audit log has `dashboard.disabled`,
|
|
355
|
+
`dashboard.locked` and `login.blocked`; only an unreadable state or session
|
|
356
|
+
store logs a warning (`devtools`, at most once a minute).
|
|
357
|
+
|
|
358
|
+
Full pages: "Devtools in production" and "Devtools security" in the docs.
|
|
359
|
+
|
|
228
360
|
## Registering a panel
|
|
229
361
|
|
|
230
362
|
A package or the app adds a tab with one line in `src/config/devtools.ts`:
|
|
@@ -232,6 +364,7 @@ A package or the app adds a tab with one line in `src/config/devtools.ts`:
|
|
|
232
364
|
```ts
|
|
233
365
|
export default {
|
|
234
366
|
panels: ["@acme/queue/devtools"], // or "./src/devtools/queue-panel.ts"
|
|
367
|
+
// pass options to a panel factory (root and mode always win): [["@acme/queue/devtools", { pageSize: 50 }]]
|
|
235
368
|
};
|
|
236
369
|
```
|
|
237
370
|
|
|
@@ -270,8 +403,20 @@ export default queuePanel;
|
|
|
270
403
|
that opens that view (`route` is then `"jobs/7"`); `svg()` builds SVG
|
|
271
404
|
elements for small graphs. Build text with `text`, never `innerHTML`.
|
|
272
405
|
- Every panel route, view and asset sits behind the devtools guard
|
|
273
|
-
(development
|
|
274
|
-
headers). A reused id (the built-in `processes` included) or a dashboard id
|
|
406
|
+
(in development: loopback socket and host, no foreign `Origin`, no proxy
|
|
407
|
+
headers; in production: sign-in). A reused id (the built-in `processes` included) or a dashboard id
|
|
275
408
|
such as `mail` is refused; devtools logs why and leaves the panel out.
|
|
276
409
|
|
|
410
|
+
A panel can set `production: true` when it is safe in the production monitor
|
|
411
|
+
(otherwise it needs `production.panels[id]: true`). The factory receives
|
|
412
|
+
`{ root, mode }`; `mode` is `"development"` or `"production"`, and a panel must
|
|
413
|
+
not write files in production. The ids `resources`, `health`, `errors`, `jobs`,
|
|
414
|
+
`instances`, `auth`, `account` and `admin` are reserved.
|
|
415
|
+
|
|
277
416
|
Full reference: the "Registering a panel" page of the devtools docs.
|
|
417
|
+
|
|
418
|
+
Panel styling: a package panel's CSS may use only the dashboard's variables (`DEVTOOLS_PANEL_TOKENS`, exported by
|
|
419
|
+
`@warlock.js/devtools`: `--background --foreground --card --muted --muted-foreground --accent --border --brand
|
|
420
|
+
--success --warning --info --destructive --chart-1..5` and the other shadcn names) plus variables it defines itself.
|
|
421
|
+
Never use another name (such as `--text` or `--surface`): the dashboard does not define it, and text can become
|
|
422
|
+
unreadable. The text tokens meet 4.5:1 contrast on `--background` and `--card` in both themes.
|