@warlock.js/devtools 5.56.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.
Files changed (34) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/cjs/{boot-BQi0Etor.cjs → boot-Dy5OqgTM.cjs} +4 -4
  3. package/cjs/{boot-BQi0Etor.cjs.map → boot-Dy5OqgTM.cjs.map} +1 -1
  4. package/cjs/{http-CabcUwBx.cjs → http-DCfXQvw-.cjs} +3 -3
  5. package/cjs/{http-CabcUwBx.cjs.map → http-DCfXQvw-.cjs.map} +1 -1
  6. package/cjs/index.cjs +2 -1
  7. package/cjs/{panels-B0dAfGbJ.cjs → panels-Rcmeitu3.cjs} +26 -6
  8. package/cjs/panels-Rcmeitu3.cjs.map +1 -0
  9. package/cjs/{server-B6xdeKS8.cjs → server-ykxsOwob.cjs} +3 -3
  10. package/cjs/{server-B6xdeKS8.cjs.map → server-ykxsOwob.cjs.map} +1 -1
  11. package/cjs/{src-Ce-3Lniv.cjs → src-UPtTCI2j.cjs} +53 -4
  12. package/cjs/src-UPtTCI2j.cjs.map +1 -0
  13. package/cjs/{stream-route-BGJa-zQu.cjs → stream-route-CJTABkUy.cjs} +2 -2
  14. package/cjs/{stream-route-BGJa-zQu.cjs.map → stream-route-CJTABkUy.cjs.map} +1 -1
  15. package/esm/index.d.mts +3 -2
  16. package/esm/index.mjs +2 -1
  17. package/esm/panel-tokens.d.mts +13 -0
  18. package/esm/panel-tokens.d.mts.map +1 -0
  19. package/esm/panel-tokens.mjs +45 -0
  20. package/esm/panel-tokens.mjs.map +1 -0
  21. package/esm/panels.mjs +25 -5
  22. package/esm/panels.mjs.map +1 -1
  23. package/esm/types.d.mts +6 -2
  24. package/esm/types.d.mts.map +1 -1
  25. package/llms-full.txt +7 -0
  26. package/package.json +8 -8
  27. package/skills/SKILL.md +7 -0
  28. package/ui/dashboard/assets/app.css +1 -1
  29. package/ui/dashboard/assets/app.js +4 -4
  30. package/ui/dashboard/build-info.json +10 -10
  31. package/ui/dashboard/index.html +1 -0
  32. package/ui/panels/processes.js +12 -3
  33. package/cjs/panels-B0dAfGbJ.cjs.map +0 -1
  34. package/cjs/src-Ce-3Lniv.cjs.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"stream-route-BGJa-zQu.cjs","names":["AGENT_TRACE_INSTALL_GUIDANCE","DevtoolsApiError","createErrorRef","DevtoolsApiError","path","resolveUiRoot","readFileSync","existsSync","path","resolveUiRoot","panelContentType","DevtoolsApiError"],"sources":["../../../../../../../packages/devtools/src/server/ai-routes.ts","../../../../../../../packages/devtools/src/server/explain-route.ts","../../../../../../../packages/devtools/src/server/insights-routes.ts","../../../../../../../packages/devtools/src/server/log-routes.ts","../../../../../../../packages/devtools/src/server/mail-routes.ts","../../../../../../../packages/devtools/src/server/ui-assets.ts","../../../../../../../packages/devtools/src/server/openapi-routes.ts","../../../../../../../packages/devtools/src/server/panel-routes.ts","../../../../../../../packages/devtools/src/request-history.ts","../../../../../../../packages/devtools/src/server/requests-routes.ts","../../../../../../../packages/devtools/src/server/route-routes.ts","../../../../../../../packages/devtools/src/server/stream-route.ts"],"sourcesContent":["import type { FastifyInstance } from \"fastify\";\nimport { AGENT_TRACE_INSTALL_GUIDANCE } from \"../sources/agent-trace-source\";\nimport { AI_INSTALL_GUIDANCE } from \"../sources/ai-source\";\nimport type { MountDevtoolsRoutesDeps } from \"./types\";\n\n/** Read-only AI metadata, inside the same development/loopback guard as every panel. */\nexport function registerAiRoutes(server: FastifyInstance, deps: MountDevtoolsRoutesDeps): void {\n server.get<{ Querystring: { requestId?: string } }>(\"/api/ai\", async (request, reply) => {\n reply.header(\"Cache-Control\", \"no-store\");\n const source = deps.ai;\n if (!source?.available) {\n return { available: false, message: source?.message ?? AI_INSTALL_GUIDANCE, runs: [] };\n }\n const filter =\n request.query.requestId === undefined ? undefined : { requestId: request.query.requestId };\n return {\n available: true,\n runs: source.store.query(filter).map(source.summarize),\n aggregate: source.store.aggregate(filter),\n };\n });\n\n // Per-turn agent traces recorded by `@warlock.js/ai` itself (system prompt,\n // tools offered, tool calls, refusals, retries, usage and cost). Unlike the\n // Panoptic feed above, these carry prompt and tool content: they exist for\n // debugging in development and sit behind the same guard.\n server.get<{ Querystring: { requestId?: string } }>(\n \"/api/ai/agent-runs\",\n async (request, reply) => {\n reply.header(\"Cache-Control\", \"no-store\");\n const source = deps.agentTraces;\n\n if (!source?.available()) {\n return { available: false, message: AGENT_TRACE_INSTALL_GUIDANCE, runs: [] };\n }\n\n return {\n available: true,\n runs: source.list(\n request.query.requestId === undefined\n ? undefined\n : { requestId: request.query.requestId },\n ),\n };\n },\n );\n\n server.get<{ Params: { id: string } }>(\"/api/ai/agent-runs/:id\", async (request, reply) => {\n reply.header(\"Cache-Control\", \"no-store\");\n const trace = deps.agentTraces?.get(request.params.id);\n\n if (!trace) return reply.code(404).send();\n\n return trace;\n });\n\n server.get<{ Params: { id: string } }>(\"/api/ai/runs/:id\", async (request, reply) => {\n reply.header(\"Cache-Control\", \"no-store\");\n const source = deps.ai;\n const trace = source?.available ? source.store.get(request.params.id) : undefined;\n if (!trace) return reply.code(404).send();\n return trace;\n });\n}\n","import { log } from \"@warlock.js/logger\";\nimport type { FastifyInstance } from \"fastify\";\nimport { createErrorRef, DevtoolsApiError } from \"../production/errors\";\nimport type { MountDevtoolsRoutesDeps } from \"./types\";\n\n/**\n * The value the logger's redaction substitutes for a censored leaf\n * (`logger/src/redact/redact.ts`, `DEFAULT_CENSOR`). Not exported from\n * `@warlock.js/logger`, so matched by literal here.\n */\nconst REDACTED_PLACEHOLDER = \"[REDACTED]\";\n\nfunction isExplainableSql(sql: string | undefined): boolean {\n return /^\\s*(select|with)\\b/i.test(sql ?? \"\");\n}\n\n/** Registers the EXPLAIN route: Postgres `SELECT`/`WITH` queries only. */\nexport function registerExplainRoute(server: FastifyInstance, deps: MountDevtoolsRoutesDeps): void {\n server.post<{ Params: { requestId: string; queryId: string } }>(\n \"/api/requests/:requestId/queries/:queryId/explain\",\n async (request, reply) => {\n const found = deps.collector.getRequest(request.params.requestId);\n const query = found?.queries.find((item) => item.id === request.params.queryId);\n\n if (!query) {\n reply.code(404).send();\n return;\n }\n\n if (query.driver !== \"postgres\" || !isExplainableSql(query.sql) || !deps.explain) {\n reply.code(400).send({ error: \"Only Postgres SELECT or WITH queries can be explained\" });\n return;\n }\n\n if (query.bindings?.some((binding) => binding === REDACTED_PLACEHOLDER)) {\n reply.code(400).send({ error: \"bindings redacted\" });\n return;\n }\n\n try {\n const plan = await deps.explain(query);\n return { plan };\n } catch (error) {\n reply.code(500).send({ error: error instanceof Error ? error.message : String(error) });\n }\n },\n );\n}\n\n/**\n * Registers `POST /api/queries/:shapeId/explain`: EXPLAIN for a query shape,\n * run by the process that kept an example of it (development and production).\n * A failure answers `{ error, code, ref?, instance? }` with the code's status.\n */\nexport function registerShapeExplainRoute(\n server: FastifyInstance,\n deps: MountDevtoolsRoutesDeps,\n): void {\n const explainShape = deps.explainShape;\n\n if (!explainShape) return;\n\n server.post<{ Params: { shapeId: string } }>(\n \"/api/queries/:shapeId/explain\",\n async (request, reply) => {\n try {\n return await explainShape(request.params.shapeId);\n } catch (error) {\n if (error instanceof DevtoolsApiError) {\n reply.code(error.statusCode).send(error.toBody());\n return;\n }\n\n const failure = new DevtoolsApiError(\"server.error\", { ref: createErrorRef() });\n\n log.error(\n \"devtools\",\n \"explain\",\n `EXPLAIN route failed (ref ${failure.ref}): ${error instanceof Error ? error.message : String(error)}`,\n );\n reply.code(failure.statusCode).send(failure.toBody());\n }\n },\n );\n}\n","import type { FastifyInstance } from \"fastify\";\nimport { DevtoolsApiError } from \"../production/errors\";\nimport type { DevtoolsInsightQuery, DevtoolsInsights } from \"../production/insights/types\";\nimport type { MountDevtoolsRoutesDeps } from \"./types\";\n\ntype InsightsQuerystring = { instance?: string; sort?: string; limit?: string };\n\nconst QUERY_SORTS = [\"total\", \"p95\", \"count\", \"n+1\"] as const;\nconst ROUTE_SORTS = [\"total\", \"p95\", \"count\", \"errors\"] as const;\n\n/**\n * Reads `?instance=&sort=&limit=`. A sort outside `sorts` or a limit that is\n * not a whole number from 1 to 500 answers `input.invalid`.\n */\nexport function parseInsightQuery(\n query: InsightsQuerystring,\n sorts?: readonly string[],\n): DevtoolsInsightQuery {\n const result: DevtoolsInsightQuery = { instance: query.instance || \"all\" };\n\n if (sorts && query.sort !== undefined && query.sort !== \"\") {\n if (!sorts.includes(query.sort)) throw new DevtoolsApiError(\"input.invalid\");\n\n result.sort = query.sort;\n }\n\n if (query.limit !== undefined && query.limit !== \"\") {\n const limit = Number(query.limit);\n\n if (!Number.isInteger(limit) || limit < 1 || limit > 500) {\n throw new DevtoolsApiError(\"input.invalid\");\n }\n\n result.limit = limit;\n }\n\n return result;\n}\n\n/**\n * The read-only routes of the Resources, Queries (statistics), Routes\n * (statistics), Health, Errors, Logs (production) and Jobs tabs, over\n * `deps.insights`: `GET /api/instances`, `/api/resources`,\n * `/api/queries/stats`, `/api/routes/stats`, `/api/health`, `/api/errors`,\n * `/api/jobs`. Each takes `?instance=<id|all>` (default `all`). Without\n * `deps.insights` nothing is registered.\n */\nexport function registerInsightsRoutes(\n server: FastifyInstance,\n deps: MountDevtoolsRoutesDeps,\n): void {\n const insights: DevtoolsInsights | undefined = deps.insights;\n\n if (!insights) return;\n\n const route = (\n path: string,\n sorts: readonly string[] | undefined,\n read: (query: DevtoolsInsightQuery) => Promise<unknown>,\n ): void => {\n server.get<{ Querystring: InsightsQuerystring }>(path, async (request, reply) => {\n const query = parseInsightQuery(request.query, sorts);\n\n reply.header(\"Cache-Control\", \"no-store\");\n\n return read(query);\n });\n };\n\n route(\"/api/instances\", undefined, () => insights.instances());\n route(\"/api/resources\", undefined, (query) => insights.resources(query));\n route(\"/api/queries/stats\", QUERY_SORTS, (query) => insights.queryStats(query));\n route(\"/api/routes/stats\", ROUTE_SORTS, (query) => insights.routeStats(query));\n route(\"/api/health\", undefined, (query) => insights.health(query));\n route(\"/api/errors\", undefined, (query) => insights.errors(query));\n route(\"/api/jobs\", undefined, (query) => insights.jobs(query));\n}\n","import type { FastifyInstance } from \"fastify\";\nimport type { DevtoolsLogRow } from \"../production/contracts\";\nimport type { DevtoolsLogEntry } from \"../types\";\nimport { parseInsightQuery } from \"./insights-routes\";\nimport type { MountDevtoolsRoutesDeps } from \"./types\";\n\ntype LogsQuery = {\n level?: DevtoolsLogEntry[\"level\"];\n module?: string;\n instance?: string;\n limit?: string;\n};\n\n/**\n * Registers the log listing route, filterable by `level` and `module`. In\n * production it answers from the insights (every instance, no `context`);\n * in development it answers from the collector's logs, which keep `context`.\n */\nexport function registerLogRoutes(server: FastifyInstance, deps: MountDevtoolsRoutesDeps): void {\n server.get<{ Querystring: LogsQuery }>(\"/api/logs\", async (request, reply) => {\n const { level, module } = request.query;\n\n if (deps.mode === \"production\" && deps.insights) {\n const query = parseInsightQuery(request.query);\n\n reply.header(\"Cache-Control\", \"no-store\");\n\n return deps.insights.logs({\n ...query,\n ...(level ? { level } : {}),\n ...(module ? { module } : {}),\n });\n }\n\n const rows: DevtoolsLogRow[] = deps.collector.listLogs({ level, module }).map((entry) => ({\n level: entry.level,\n module: entry.module,\n action: entry.action,\n message: entry.message,\n at: entry.at,\n requestId: null,\n instance: null,\n context: entry.context,\n }));\n\n return rows;\n });\n}\n","import type { FastifyInstance } from \"fastify\";\nimport type { MountDevtoolsRoutesDeps } from \"./types\";\n\nconst MAIL_HTML_CSP =\n \"sandbox; default-src 'none'; img-src data: https: http:; style-src 'unsafe-inline'\";\n\n/** Registers the mailbox list, single-mail detail, and mail HTML routes. */\nexport function registerMailRoutes(server: FastifyInstance, deps: MountDevtoolsRoutesDeps): void {\n server.get(\"/api/mails\", async () => deps.collector.listMails());\n\n server.get<{ Params: { id: string } }>(\"/api/mails/:id\", async (request, reply) => {\n const mail = deps.collector.getMail(request.params.id);\n\n if (!mail) {\n reply.code(404).send();\n return;\n }\n\n const { html, ...rest } = mail;\n return rest;\n });\n\n server.get<{ Params: { id: string } }>(\"/api/mails/:id/html\", async (request, reply) => {\n const mail = deps.collector.getMail(request.params.id);\n\n if (!mail || !mail.html) {\n reply.code(404).send();\n return;\n }\n\n reply\n .header(\"Content-Security-Policy\", MAIL_HTML_CSP)\n .header(\"X-Content-Type-Options\", \"nosniff\")\n .header(\"Content-Type\", \"text/html; charset=utf-8\")\n .send(mail.html);\n });\n}\n","import { existsSync, readFileSync } from \"node:fs\";\nimport path from \"node:path\";\nimport type { FastifyInstance, FastifyReply, FastifyRequest } from \"fastify\";\nimport { resolveUiRoot } from \"../ui-root\";\n\n/**\n * Where an asset's bytes come from: a file in this package's `ui/` folder.\n */\ntype UiAsset = {\n contentType: string;\n file: () => string;\n};\n\nconst uiFile = (name: string) => () => path.join(resolveUiRoot(), name);\n\n/**\n * The only assets that can be requested. The request's asset name is looked\n * up here and never joined into a filesystem path.\n */\nconst UI_ASSETS: Record<string, UiAsset> = {\n \"app.js\": {\n contentType: \"text/javascript; charset=utf-8\",\n file: uiFile(\"dashboard/assets/app.js\"),\n },\n \"app.css\": { contentType: \"text/css; charset=utf-8\", file: uiFile(\"dashboard/assets/app.css\") },\n \"scalar.js\": {\n contentType: \"text/javascript; charset=utf-8\",\n file: uiFile(\"vendor/scalar/standalone.js\"),\n },\n \"swagger-ui-bundle.js\": {\n contentType: \"text/javascript; charset=utf-8\",\n file: uiFile(\"vendor/swagger-ui/swagger-ui-bundle.js\"),\n },\n \"swagger-ui.css\": {\n contentType: \"text/css; charset=utf-8\",\n file: uiFile(\"vendor/swagger-ui/swagger-ui.css\"),\n },\n \"docs-swagger.js\": {\n contentType: \"text/javascript; charset=utf-8\",\n file: uiFile(\"docs-swagger.js\"),\n },\n};\n\n/** Sends `file` with `contentType` and no caching. */\nexport function sendFile(reply: FastifyReply, file: string, contentType: string): void {\n reply\n .header(\"Cache-Control\", \"no-store\")\n .header(\"Content-Type\", contentType)\n .send(readFileSync(file));\n}\n\nconst NOT_BUILT_HTML =\n \"<!doctype html><title>Warlock Devtools</title><p>The devtools dashboard has not been built. Run <code>pnpm --filter @warlock.js/devtools build:ui</code>.</p>\";\n\n/**\n * Serves the static dashboard: the built `ui/dashboard/index.html` at the\n * dashboard root and the whitelisted assets (`app.js`, `app.css`, the\n * vendored Scalar bundle as `scalar.js`, and the vendored Swagger UI files\n * plus their init script). The asset name is matched against a fixed\n * whitelist — never joined into a filesystem path — so no request can\n * traverse outside it. Before the first `build:ui` the root answers 503 with\n * a note that says how to build. `notFound` answers an unknown asset (the\n * production gate passes its uniform 404, so the public asset route answers\n * like any unknown URL of the app); without it the answer is a bare 404.\n */\nexport function registerUiAssets(\n server: FastifyInstance,\n options: { notFound?: (request: FastifyRequest, reply: FastifyReply) => FastifyReply } = {},\n): void {\n const serveIndex = (request: FastifyRequest, reply: FastifyReply): void => {\n // The address as sent: core's server drops a trailing slash before routing.\n const [pathname = \"\", search] = (request.originalUrl ?? request.url).split(\"?\");\n\n // The page loads its assets by relative URL, so it must be served from `<path>/`. The target is built from\n // the route, never from the request, so it always stays on the dashboard path.\n if (!pathname.endsWith(\"/\")) {\n const base = (request.routeOptions.url ?? pathname).replace(/\\/+$/, \"\");\n\n reply\n .code(308)\n .header(\"Cache-Control\", \"no-store\")\n .redirect(`${base}/${search === undefined ? \"\" : `?${search}`}`, 308);\n return;\n }\n\n const index = path.join(resolveUiRoot(), \"dashboard\", \"index.html\");\n\n if (!existsSync(index)) {\n reply\n .code(503)\n .header(\"Cache-Control\", \"no-store\")\n .header(\"Content-Type\", \"text/html; charset=utf-8\")\n .send(NOT_BUILT_HTML);\n return;\n }\n\n reply\n .header(\"Cache-Control\", \"no-store\")\n .header(\"Content-Type\", \"text/html; charset=utf-8\")\n .send(readFileSync(index));\n };\n\n server.get(\"/\", serveIndex);\n\n server.get<{ Params: { name: string } }>(\"/assets/:name\", (request, reply) => {\n const asset = Object.hasOwn(UI_ASSETS, request.params.name)\n ? UI_ASSETS[request.params.name]\n : undefined;\n const file = asset?.file();\n\n if (!asset || !file || !existsSync(file)) {\n if (options.notFound) {\n options.notFound(request, reply);\n return;\n }\n\n reply.code(404).header(\"Cache-Control\", \"no-store\").send();\n return;\n }\n\n sendFile(reply, file, asset.contentType);\n });\n}\n","import path from \"node:path\";\nimport type { FastifyInstance, FastifyReply } from \"fastify\";\nimport { resolveUiRoot } from \"../ui-root\";\nimport type { MountDevtoolsRoutesDeps } from \"./types\";\nimport { sendFile } from \"./ui-assets\";\n\n/**\n * Registers the API docs: `GET /api/openapi.json` returns the document core\n * builds from the registered routes (`deps.getOpenApiDocument`), and\n * `GET /docs` serves the page that renders it with Scalar and\n * `GET /docs/swagger` the same document in Swagger UI;\n * `GET /api/postman.json` returns the Postman collection core builds\n * (`deps.getPostmanCollection`). The pages use relative URLs, so it works under whatever base path the dashboard is\n * mounted on.\n */\nexport function registerOpenApiRoutes(\n server: FastifyInstance,\n deps: MountDevtoolsRoutesDeps,\n): void {\n server.get(\"/api/openapi.json\", async (_request, reply) => {\n if (!deps.getOpenApiDocument) {\n return reply.code(503).header(\"Cache-Control\", \"no-store\").send({\n error: \"The OpenAPI document is not available: the host did not provide a generator.\",\n });\n }\n\n reply.header(\"Cache-Control\", \"no-store\");\n\n return deps.getOpenApiDocument();\n });\n\n server.get(\"/api/postman.json\", async (_request, reply) => {\n if (!deps.getPostmanCollection) {\n return reply.code(503).header(\"Cache-Control\", \"no-store\").send({\n error: \"The Postman collection is not available: the host did not provide a generator.\",\n });\n }\n\n reply.header(\"Cache-Control\", \"no-store\");\n\n return deps.getPostmanCollection();\n });\n\n // The API tab shows these pages in a frame. The app's own headers (core's security headers forbid framing) are\n // replaced on the reply; production sets its full docs policy on top.\n const frameable = (reply: FastifyReply): FastifyReply =>\n reply\n .header(\"X-Frame-Options\", \"SAMEORIGIN\")\n .header(\"Content-Security-Policy\", \"frame-ancestors 'self'\");\n\n server.get(\"/docs\", (_request, reply) => {\n sendFile(frameable(reply), path.join(resolveUiRoot(), \"docs.html\"), \"text/html; charset=utf-8\");\n });\n\n server.get(\"/docs/swagger\", (_request, reply) => {\n sendFile(\n frameable(reply),\n path.join(resolveUiRoot(), \"docs-swagger.html\"),\n \"text/html; charset=utf-8\",\n );\n });\n}\n","import type { FastifyInstance } from \"fastify\";\nimport { type MountedDevtoolsPanel, panelContentType } from \"../panels\";\nimport type { DevtoolsPanelRequest } from \"../types\";\nimport { sendFile } from \"./ui-assets\";\n\n/**\n * Mounts each panel's data routes at `/api/<id><route path>` and its view\n * module and assets at `/panels/<id>/<name>`. Callers register this inside\n * the devtools scope, so the guard covers every one of them. A file is\n * served only when its name is listed by the panel; the request never\n * becomes a filesystem path.\n */\nexport function registerPanelRoutes(\n server: FastifyInstance,\n panels: readonly MountedDevtoolsPanel[],\n): void {\n const byId = new Map(panels.map((panel) => [panel.id, panel]));\n\n for (const panel of panels) {\n for (const route of panel.routes) {\n server.route({\n method: route.method,\n url: `/api/${panel.id}${route.path}`,\n handler: async (request, reply) => {\n const input: DevtoolsPanelRequest = {\n params: (request.params ?? {}) as Record<string, string>,\n query: (request.query ?? {}) as Record<string, string | string[]>,\n body: request.body,\n };\n const result = await route.handler(input);\n\n reply.header(\"cache-control\", \"no-store\");\n\n if (result === undefined) return reply.code(204).send();\n\n return result;\n },\n });\n }\n }\n\n server.get<{ Params: { id: string; name: string } }>(\"/panels/:id/:name\", (request, reply) => {\n const panel = byId.get(request.params.id);\n const name = request.params.name;\n const file =\n panel === undefined\n ? undefined\n : name === \"view.js\"\n ? panel.view\n : Object.hasOwn(panel.assets, name)\n ? panel.assets[name]\n : undefined;\n\n if (file === undefined) {\n reply.code(404).header(\"Cache-Control\", \"no-store\").send();\n return;\n }\n\n reply.header(\"X-Content-Type-Options\", \"nosniff\");\n sendFile(reply, file, panelContentType(name));\n });\n}\n","import type { RequestLogFilter, RequestLogRecord, RequestLogSummary } from \"@warlock.js/core\";\nimport type {\n DevtoolsLogEntry,\n DevtoolsRequestDetail,\n DevtoolsRequestSummary,\n DevtoolsWarning,\n} from \"./types\";\n\n/** The list row filters run over, from an in-memory summary. */\nexport function summaryToRow(summary: DevtoolsRequestSummary): RequestLogSummary {\n return {\n id: summary.id,\n time: new Date(summary.startedAt).toISOString(),\n method: summary.method,\n url: summary.path,\n ...(summary.route ? { route: summary.route } : {}),\n status: summary.status ?? 0,\n durationMs: summary.durationMs ?? 0,\n };\n}\n\n/** An in-memory-shaped list row from a persisted one. */\nexport function rowToSummary(row: RequestLogSummary): DevtoolsRequestSummary {\n return {\n id: row.id,\n method: row.method,\n path: row.url,\n route: row.route,\n status: row.status,\n startedAt: Date.parse(row.time),\n durationMs: row.durationMs,\n queryCount: row.queryCount ?? 0,\n warningCount: row.nPlusOneCount ?? 0,\n persisted: true,\n };\n}\n\n/**\n * Merge the live ring buffer with the persisted log, newest first, without\n * duplicates: a request in both is shown from memory (it has the full\n * timeline). Persisted rows fill in what a restart or the ring buffer's size\n * evicted.\n */\nexport function mergeRequestHistory(\n live: readonly DevtoolsRequestSummary[],\n persisted: readonly RequestLogSummary[],\n limit: number,\n): DevtoolsRequestSummary[] {\n const seen = new Set(live.map((summary) => summary.id));\n const merged = [...live];\n\n for (const row of persisted) {\n if (seen.has(row.id)) continue;\n\n seen.add(row.id);\n merged.push(rowToSummary(row));\n }\n\n return merged.sort((first, second) => second.startedAt - first.startedAt).slice(0, limit);\n}\n\nconst FILTER_KEYS = [\"status\", \"route\", \"method\", \"since\", \"until\", \"q\"] as const;\n\n/** The request log filter in a `GET /api/requests` query string. */\nexport function filterFromQuery(query: Record<string, unknown>): RequestLogFilter {\n const filter: RequestLogFilter = {};\n\n for (const key of FILTER_KEYS) {\n const value = query[key];\n\n if (typeof value === \"string\" && value.trim() !== \"\") filter[key] = value.trim();\n }\n\n const limit = Number(query.limit);\n\n if (Number.isInteger(limit) && limit > 0) filter.limit = limit;\n\n return filter;\n}\n\n/** Whether a filter narrows anything. */\nexport function hasFilter(filter: RequestLogFilter): boolean {\n return FILTER_KEYS.some((key) => filter[key] !== undefined);\n}\n\nfunction toLogLevel(level: string): DevtoolsLogEntry[\"level\"] {\n return level === \"debug\" || level === \"info\" || level === \"warn\" || level === \"success\"\n ? level\n : \"error\";\n}\n\n/**\n * A request detail rebuilt from a persisted record, in the shape of an\n * in-memory one: phases, logs and N+1 warnings carry over; query-by-query\n * and cache detail live only in memory, so those lists are empty. `record`\n * has everything the log kept.\n */\nexport function recordToDetail(record: RequestLogRecord): DevtoolsRequestDetail {\n const startedAt = Date.parse(record.time);\n const warnings: DevtoolsWarning[] = (record.queries?.nPlusOne ?? []).map((finding) => ({\n type: \"n+1\",\n message: `${finding.query} ran ${finding.count} times`,\n shape: finding.query,\n count: finding.count,\n }));\n\n return {\n id: record.id,\n method: record.method,\n path: record.url,\n route: record.route.pattern,\n status: record.status,\n startedAt,\n durationMs: record.durationMs,\n error: record.error?.message,\n phases: (record.phases ?? []).map((phase) => ({\n name: phase.name,\n startedAt,\n durationMs: phase.durationMs,\n })),\n queries: [],\n cache: [],\n logs: (record.logs ?? []).map((entry) => ({\n level: toLogLevel(entry.level),\n module: entry.module,\n action: entry.action,\n message: entry.message,\n at: entry.at,\n ...(entry.context ? { context: entry.context } : {}),\n })),\n mails: [],\n warnings,\n persisted: true,\n record,\n };\n}\n","import type { RequestLogFilter } from \"@warlock.js/core\";\nimport type { FastifyInstance, FastifyReply } from \"fastify\";\nimport { DevtoolsApiError } from \"../production/errors\";\nimport type { DevtoolsSampleFilter } from \"../production/store/types\";\nimport {\n filterFromQuery,\n hasFilter,\n mergeRequestHistory,\n recordToDetail,\n summaryToRow,\n} from \"../request-history\";\nimport type { DevtoolsRequestDetail } from \"../types\";\nimport type { MountDevtoolsRoutesDeps } from \"./types\";\n\nconst STATUS_FILTER = /^(?:[1-5]\\d\\d|[1-5]xx)$/i;\nconst METHOD_FILTER = /^[A-Za-z]{1,16}$/;\nconst RELATIVE_SINCE = /^(\\d+)(s|m|h|d)$/;\nconst UNIT_MS = { s: 1000, m: 60_000, h: 3_600_000, d: 86_400_000 } as const;\nconst DEFAULT_SAMPLE_LIMIT = 200;\nconst MAX_SAMPLE_LIMIT = 1000;\n\n/** A time bound as epoch ms: a number, an ISO date, or (for `since`) a duration back such as `15m`. */\nfunction parseTimeBound(value: string, allowRelative: boolean): number {\n if (/^\\d+$/.test(value)) return Number(value);\n\n const relative = allowRelative ? RELATIVE_SINCE.exec(value) : null;\n\n if (relative) {\n return Date.now() - Number(relative[1]) * UNIT_MS[relative[2] as keyof typeof UNIT_MS];\n }\n\n const parsed = Date.parse(value);\n\n if (Number.isNaN(parsed)) throw new DevtoolsApiError(\"request.invalid-filter\");\n\n return parsed;\n}\n\n/** The stored-sample filter in a `GET /api/requests` query string; throws `request.invalid-filter`. */\nfunction sampleFilterFromQuery(\n query: Record<string, unknown>,\n filter: RequestLogFilter,\n fallbackLimit: number,\n): DevtoolsSampleFilter {\n const result: DevtoolsSampleFilter = {\n limit: Math.min(MAX_SAMPLE_LIMIT, filter.limit ?? fallbackLimit),\n };\n\n if (filter.status !== undefined) {\n const status = String(filter.status);\n\n if (!STATUS_FILTER.test(status)) throw new DevtoolsApiError(\"request.invalid-filter\");\n\n result.status = status.toLowerCase();\n }\n\n if (filter.method !== undefined) {\n if (!METHOD_FILTER.test(String(filter.method))) {\n throw new DevtoolsApiError(\"request.invalid-filter\");\n }\n\n result.method = String(filter.method);\n }\n\n if (filter.route !== undefined) result.route = String(filter.route);\n if (filter.q !== undefined) result.q = String(filter.q);\n if (filter.since !== undefined) result.since = parseTimeBound(String(filter.since), true);\n if (filter.until !== undefined) result.until = parseTimeBound(String(filter.until), false);\n\n const instance = query.instance;\n\n if (typeof instance === \"string\" && instance.trim() !== \"\" && instance !== \"all\") {\n result.instance = instance.trim();\n }\n\n return result;\n}\n\nfunction sendApiError(reply: FastifyReply, error: DevtoolsApiError): void {\n reply.code(error.statusCode).send(error.toBody());\n}\n\n/**\n * Production: the same four routes over the request source (stored samples\n * and this process's memory), merged with the persisted request log the way\n * development merges it with the ring buffer.\n */\nfunction registerProductionRequestsRoutes(\n server: FastifyInstance,\n deps: MountDevtoolsRoutesDeps,\n): void {\n const source = deps.requests;\n\n if (!source) return;\n\n server.get<{ Querystring: Record<string, unknown> }>(\"/api/requests\", async (request, reply) => {\n const { requestLog, options } = deps;\n\n try {\n const filter = filterFromQuery(request.query);\n const sampleFilter = sampleFilterFromQuery(request.query, filter, DEFAULT_SAMPLE_LIMIT);\n const limit = Math.min(MAX_SAMPLE_LIMIT, filter.limit ?? options.maxRequests);\n let persisted: Awaited<ReturnType<NonNullable<typeof requestLog>[\"list\"]>> = [];\n\n if (requestLog) {\n try {\n requestLog.compile(filter);\n persisted = await requestLog.list({ ...filter, limit });\n } catch (error) {\n // A bad filter value is the caller's mistake; a read failure leaves the samples.\n if (error instanceof Error && /^Invalid /.test(error.message)) {\n throw new DevtoolsApiError(\"request.invalid-filter\");\n }\n }\n }\n\n const samples = await source.list({ ...sampleFilter, limit });\n\n return mergeRequestHistory(samples, persisted, limit);\n } catch (error) {\n if (error instanceof DevtoolsApiError) {\n sendApiError(reply, error);\n return;\n }\n\n throw error;\n }\n });\n\n server.get<{ Params: { id: string } }>(\"/api/requests/:id\", async (request, reply) => {\n const { id } = request.params;\n const persisted = await deps.requestLog?.get(id).catch(() => undefined);\n const found = await source.get(id);\n\n if (found) {\n const hasTimeline = \"phases\" in found;\n\n if (hasTimeline) return persisted ? { ...found, record: persisted } : found;\n\n // A slow or failed request that was not sampled: the summary, plus what the log kept.\n if (persisted) {\n return {\n ...recordToDetail(persisted),\n ...(found.instance === undefined ? {} : { instance: found.instance }),\n partial: true,\n };\n }\n\n return found;\n }\n\n if (!persisted) {\n sendApiError(reply, new DevtoolsApiError(\"request.not-found\"));\n return;\n }\n\n return recordToDetail(persisted);\n });\n\n server.get<{ Params: { id: string } }>(\"/api/requests/:id/curl\", async (request, reply) => {\n const { id } = request.params;\n const baseUrl = `${request.protocol}://${request.headers.host ?? \"localhost\"}`;\n const persisted = await deps.requestLog?.get(id).catch(() => undefined);\n\n if (persisted && deps.requestLog) return { curl: deps.requestLog.curl(persisted, baseUrl) };\n\n const found = await source.get(id);\n\n if (!found) {\n sendApiError(reply, new DevtoolsApiError(\"request.not-found\"));\n return;\n }\n\n return { curl: `curl -X ${found.method} '${baseUrl}${found.path.replace(/'/g, `'\\\\''`)}'` };\n });\n\n server.delete(\"/api/requests\", async (_request, reply) => {\n await source.clear();\n deps.collector.clear();\n reply.code(204).send();\n });\n}\n\n/**\n * Registers the request list, single-request detail, \"copy as curl\", and\n * clear routes.\n *\n * With core's persistent request log available, the list and the detail also\n * read the JSON-lines history, so requests survive a restart. The list\n * accepts `status` (404 or 5xx), `route`, `method`, `since`, `until`, `q`\n * and `limit` query parameters.\n */\nexport function registerRequestsRoutes(\n server: FastifyInstance,\n deps: MountDevtoolsRoutesDeps,\n): void {\n if (deps.requests) {\n registerProductionRequestsRoutes(server, deps);\n return;\n }\n\n server.get<{ Querystring: Record<string, unknown> }>(\"/api/requests\", async (request, reply) => {\n const { requestLog, collector, options } = deps;\n\n if (!requestLog) return collector.listRequests();\n\n try {\n const filter = filterFromQuery(request.query);\n const matches = requestLog.compile(filter);\n const live = hasFilter(filter)\n ? collector.listRequests().filter((summary) => matches(summaryToRow(summary)))\n : collector.listRequests();\n const limit = filter.limit ?? options.maxRequests;\n const persisted = await requestLog.list({ ...filter, limit });\n\n return mergeRequestHistory(live, persisted, limit);\n } catch (error) {\n // A bad filter value is the caller's mistake; a read failure leaves the live list.\n if (error instanceof Error && /^Invalid /.test(error.message)) {\n reply.code(400).send({ error: error.message });\n return;\n }\n\n return collector.listRequests();\n }\n });\n\n server.get<{ Params: { id: string } }>(\"/api/requests/:id\", async (request, reply) => {\n const { id } = request.params;\n const persisted = await deps.requestLog?.get(id).catch(() => undefined);\n const found = deps.collector.getRequest(id);\n\n if (found) {\n const detail: DevtoolsRequestDetail = persisted ? { ...found, record: persisted } : found;\n\n return detail;\n }\n\n if (!persisted) {\n reply.code(404).send();\n return;\n }\n\n return recordToDetail(persisted);\n });\n\n server.get<{ Params: { id: string } }>(\"/api/requests/:id/curl\", async (request, reply) => {\n const { id } = request.params;\n const baseUrl = `${request.protocol}://${request.headers.host ?? \"localhost\"}`;\n const persisted = await deps.requestLog?.get(id).catch(() => undefined);\n\n if (persisted && deps.requestLog) return { curl: deps.requestLog.curl(persisted, baseUrl) };\n\n // Without a persisted record only the method and path are known.\n const live = deps.collector.getRequest(id);\n\n if (!live) {\n reply.code(404).send();\n return;\n }\n\n return { curl: `curl -X ${live.method} '${baseUrl}${live.path.replace(/'/g, `'\\\\''`)}'` };\n });\n\n server.delete(\"/api/requests\", async (_request, reply) => {\n deps.collector.clear();\n if (deps.ai?.available) deps.ai.store.clear();\n reply.code(204).send();\n });\n}\n","import type { FastifyInstance } from \"fastify\";\nimport type { MountDevtoolsRoutesDeps } from \"./types\";\n\n/** Registers the route map, sourced from core's router via `deps.listRoutes`. */\nexport function registerRouteRoutes(server: FastifyInstance, deps: MountDevtoolsRoutesDeps): void {\n server.get(\"/api/routes\", async () => (deps.listRoutes ? deps.listRoutes() : []));\n}\n","import type { FastifyInstance } from \"fastify\";\nimport type { DevtoolsStreamSession, MountDevtoolsRoutesDeps } from \"./types\";\nimport type { DevtoolsLogEntry, DevtoolsStreamEvent } from \"../types\";\n\nconst PING_INTERVAL_MS = 15_000;\n\n/** How long a browser waits before it reconnects a dropped stream. */\nconst RETRY_MS = 5000;\n\n/** The log entry as the production stream sends it: no context (it may hold values). */\nfunction withoutContext(entry: DevtoolsLogEntry): DevtoolsLogEntry {\n return {\n level: entry.level,\n module: entry.module,\n action: entry.action,\n message: entry.message,\n at: entry.at,\n };\n}\n\n/**\n * Registers the SSE stream: one `event: <type>\\ndata: <json>\\n\\n` frame per\n * collector event, plus a `: ping` comment every 15s to keep intermediaries\n * from closing an idle connection. The reply is hijacked so Fastify never\n * tries to serialize or close the response itself.\n *\n * The first frames are `retry: 5000` and an `event: hello` with the mode,\n * instance and role. In production (`deps.streamSession` set) the session and\n * the open state are checked again at every ping and the stream ends when\n * either fails; log entries carry no context; mail, AI and agent events flow\n * only when those tabs are enabled.\n */\nexport function registerStreamRoute(server: FastifyInstance, deps: MountDevtoolsRoutesDeps): void {\n server.get(\"/api/stream\", async (request, reply) => {\n // Opening first, so a refused stream (`stream.too-many`) is a normal JSON error.\n const session: DevtoolsStreamSession | null = deps.streamSession\n ? await deps.streamSession(request)\n : null;\n const enabled = new Set(deps.builtInPanels ?? []);\n const instanceId = deps.instance?.id;\n const mode = deps.mode ?? \"development\";\n\n reply.hijack();\n const res = reply.raw;\n\n res.writeHead(200, {\n ...session?.headers,\n \"Content-Type\": \"text/event-stream\",\n \"Cache-Control\": \"no-store\",\n Connection: \"keep-alive\",\n \"X-Accel-Buffering\": \"no\",\n });\n\n const write = (frame: string): void => {\n if (!res.writableEnded && !res.destroyed) res.write(frame);\n };\n\n write(`retry: ${RETRY_MS}\\n\\n`);\n\n const hello: Extract<DevtoolsStreamEvent, { type: \"hello\" }>[\"data\"] = {\n mode,\n instance: instanceId ?? null,\n role: session?.role ?? (mode === \"development\" ? \"admin\" : null),\n };\n\n write(`event: hello\\ndata: ${JSON.stringify(hello)}\\n\\n`);\n\n const dispose = deps.collector.subscribe((event) => {\n if (event.type === \"hello\") return;\n\n if (session !== null) {\n if (event.type === \"mail\" && !enabled.has(\"mail\")) return;\n\n if (event.type === \"log\") {\n if (!session.logLevels.includes(event.data.level)) return;\n\n const row = withoutContext(event.data);\n\n write(\n `event: log\\ndata: ${JSON.stringify(instanceId !== undefined ? { ...row, instance: instanceId } : row)}\\n\\n`,\n );\n return;\n }\n }\n\n const data =\n event.type === \"request\" && instanceId !== undefined\n ? { ...event.data, instance: instanceId }\n : event.data;\n\n write(`event: ${event.type}\\ndata: ${JSON.stringify(data)}\\n\\n`);\n });\n\n const aiAllowed = session === null || enabled.has(\"ai\");\n const agentsAllowed = session === null || enabled.has(\"agents\");\n\n const disposeAi =\n aiAllowed && deps.ai?.available\n ? deps.ai.subscribe((event) => {\n write(`event: ai\\ndata: ${JSON.stringify(event)}\\n\\n`);\n })\n : undefined;\n\n const disposeAgentTraces = agentsAllowed\n ? deps.agentTraces?.subscribe((event) => {\n write(`event: agent-trace\\ndata: ${JSON.stringify(event)}\\n\\n`);\n })\n : undefined;\n\n let closed = false;\n\n const close = (): void => {\n if (closed) return;\n\n closed = true;\n clearInterval(pingTimer);\n dispose();\n disposeAi?.();\n disposeAgentTraces?.();\n session?.release();\n\n if (!res.writableEnded && !res.destroyed) res.end();\n };\n\n const pingTimer = setInterval(() => {\n if (session === null) {\n write(\": ping\\n\\n\");\n return;\n }\n\n session.revalidate().then(\n (stillValid) => {\n if (closed) return;\n\n if (stillValid) write(\": ping\\n\\n\");\n else close();\n },\n () => close(),\n );\n }, PING_INTERVAL_MS);\n pingTimer.unref();\n\n request.raw.on(\"close\", close);\n res.on(\"error\", close);\n });\n}\n"],"mappings":";;;;;;;;;;;AAMA,SAAgB,iBAAiB,QAAyB,MAAqC;CAC7F,OAAO,IAA6C,WAAW,OAAO,SAAS,UAAU;EACvF,MAAM,OAAO,iBAAiB,UAAU;EACxC,MAAM,SAAS,KAAK;EACpB,IAAI,CAAC,QAAQ,WACX,OAAO;GAAE,WAAW;GAAO,SAAS,QAAQ;GAAgC,MAAM,CAAC;EAAE;EAEvF,MAAM,SACJ,QAAQ,MAAM,cAAc,SAAY,SAAY,EAAE,WAAW,QAAQ,MAAM,UAAU;EAC3F,OAAO;GACL,WAAW;GACX,MAAM,OAAO,MAAM,MAAM,MAAM,CAAC,CAAC,IAAI,OAAO,SAAS;GACrD,WAAW,OAAO,MAAM,UAAU,MAAM;EAC1C;CACF,CAAC;CAMD,OAAO,IACL,sBACA,OAAO,SAAS,UAAU;EACxB,MAAM,OAAO,iBAAiB,UAAU;EACxC,MAAM,SAAS,KAAK;EAEpB,IAAI,CAAC,QAAQ,UAAU,GACrB,OAAO;GAAE,WAAW;GAAO,SAASA;GAA8B,MAAM,CAAC;EAAE;EAG7E,OAAO;GACL,WAAW;GACX,MAAM,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AS,KAAK;EAC7B,IAAI,GAAG,SAAS,KAAK;CACvB,CAAC;AACH"}
1
+ {"version":3,"file":"stream-route-CJTABkUy.cjs","names":["AGENT_TRACE_INSTALL_GUIDANCE","DevtoolsApiError","createErrorRef","DevtoolsApiError","path","resolveUiRoot","readFileSync","existsSync","path","resolveUiRoot","panelContentType","DevtoolsApiError"],"sources":["../../../../../../../packages/devtools/src/server/ai-routes.ts","../../../../../../../packages/devtools/src/server/explain-route.ts","../../../../../../../packages/devtools/src/server/insights-routes.ts","../../../../../../../packages/devtools/src/server/log-routes.ts","../../../../../../../packages/devtools/src/server/mail-routes.ts","../../../../../../../packages/devtools/src/server/ui-assets.ts","../../../../../../../packages/devtools/src/server/openapi-routes.ts","../../../../../../../packages/devtools/src/server/panel-routes.ts","../../../../../../../packages/devtools/src/request-history.ts","../../../../../../../packages/devtools/src/server/requests-routes.ts","../../../../../../../packages/devtools/src/server/route-routes.ts","../../../../../../../packages/devtools/src/server/stream-route.ts"],"sourcesContent":["import type { FastifyInstance } from \"fastify\";\nimport { AGENT_TRACE_INSTALL_GUIDANCE } from \"../sources/agent-trace-source\";\nimport { AI_INSTALL_GUIDANCE } from \"../sources/ai-source\";\nimport type { MountDevtoolsRoutesDeps } from \"./types\";\n\n/** Read-only AI metadata, inside the same development/loopback guard as every panel. */\nexport function registerAiRoutes(server: FastifyInstance, deps: MountDevtoolsRoutesDeps): void {\n server.get<{ Querystring: { requestId?: string } }>(\"/api/ai\", async (request, reply) => {\n reply.header(\"Cache-Control\", \"no-store\");\n const source = deps.ai;\n if (!source?.available) {\n return { available: false, message: source?.message ?? AI_INSTALL_GUIDANCE, runs: [] };\n }\n const filter =\n request.query.requestId === undefined ? undefined : { requestId: request.query.requestId };\n return {\n available: true,\n runs: source.store.query(filter).map(source.summarize),\n aggregate: source.store.aggregate(filter),\n };\n });\n\n // Per-turn agent traces recorded by `@warlock.js/ai` itself (system prompt,\n // tools offered, tool calls, refusals, retries, usage and cost). Unlike the\n // Panoptic feed above, these carry prompt and tool content: they exist for\n // debugging in development and sit behind the same guard.\n server.get<{ Querystring: { requestId?: string } }>(\n \"/api/ai/agent-runs\",\n async (request, reply) => {\n reply.header(\"Cache-Control\", \"no-store\");\n const source = deps.agentTraces;\n\n if (!source?.available()) {\n return { available: false, message: AGENT_TRACE_INSTALL_GUIDANCE, runs: [] };\n }\n\n return {\n available: true,\n runs: source.list(\n request.query.requestId === undefined\n ? undefined\n : { requestId: request.query.requestId },\n ),\n };\n },\n );\n\n server.get<{ Params: { id: string } }>(\"/api/ai/agent-runs/:id\", async (request, reply) => {\n reply.header(\"Cache-Control\", \"no-store\");\n const trace = deps.agentTraces?.get(request.params.id);\n\n if (!trace) return reply.code(404).send();\n\n return trace;\n });\n\n server.get<{ Params: { id: string } }>(\"/api/ai/runs/:id\", async (request, reply) => {\n reply.header(\"Cache-Control\", \"no-store\");\n const source = deps.ai;\n const trace = source?.available ? source.store.get(request.params.id) : undefined;\n if (!trace) return reply.code(404).send();\n return trace;\n });\n}\n","import { log } from \"@warlock.js/logger\";\nimport type { FastifyInstance } from \"fastify\";\nimport { createErrorRef, DevtoolsApiError } from \"../production/errors\";\nimport type { MountDevtoolsRoutesDeps } from \"./types\";\n\n/**\n * The value the logger's redaction substitutes for a censored leaf\n * (`logger/src/redact/redact.ts`, `DEFAULT_CENSOR`). Not exported from\n * `@warlock.js/logger`, so matched by literal here.\n */\nconst REDACTED_PLACEHOLDER = \"[REDACTED]\";\n\nfunction isExplainableSql(sql: string | undefined): boolean {\n return /^\\s*(select|with)\\b/i.test(sql ?? \"\");\n}\n\n/** Registers the EXPLAIN route: Postgres `SELECT`/`WITH` queries only. */\nexport function registerExplainRoute(server: FastifyInstance, deps: MountDevtoolsRoutesDeps): void {\n server.post<{ Params: { requestId: string; queryId: string } }>(\n \"/api/requests/:requestId/queries/:queryId/explain\",\n async (request, reply) => {\n const found = deps.collector.getRequest(request.params.requestId);\n const query = found?.queries.find((item) => item.id === request.params.queryId);\n\n if (!query) {\n reply.code(404).send();\n return;\n }\n\n if (query.driver !== \"postgres\" || !isExplainableSql(query.sql) || !deps.explain) {\n reply.code(400).send({ error: \"Only Postgres SELECT or WITH queries can be explained\" });\n return;\n }\n\n if (query.bindings?.some((binding) => binding === REDACTED_PLACEHOLDER)) {\n reply.code(400).send({ error: \"bindings redacted\" });\n return;\n }\n\n try {\n const plan = await deps.explain(query);\n return { plan };\n } catch (error) {\n reply.code(500).send({ error: error instanceof Error ? error.message : String(error) });\n }\n },\n );\n}\n\n/**\n * Registers `POST /api/queries/:shapeId/explain`: EXPLAIN for a query shape,\n * run by the process that kept an example of it (development and production).\n * A failure answers `{ error, code, ref?, instance? }` with the code's status.\n */\nexport function registerShapeExplainRoute(\n server: FastifyInstance,\n deps: MountDevtoolsRoutesDeps,\n): void {\n const explainShape = deps.explainShape;\n\n if (!explainShape) return;\n\n server.post<{ Params: { shapeId: string } }>(\n \"/api/queries/:shapeId/explain\",\n async (request, reply) => {\n try {\n return await explainShape(request.params.shapeId);\n } catch (error) {\n if (error instanceof DevtoolsApiError) {\n reply.code(error.statusCode).send(error.toBody());\n return;\n }\n\n const failure = new DevtoolsApiError(\"server.error\", { ref: createErrorRef() });\n\n log.error(\n \"devtools\",\n \"explain\",\n `EXPLAIN route failed (ref ${failure.ref}): ${error instanceof Error ? error.message : String(error)}`,\n );\n reply.code(failure.statusCode).send(failure.toBody());\n }\n },\n );\n}\n","import type { FastifyInstance } from \"fastify\";\nimport { DevtoolsApiError } from \"../production/errors\";\nimport type { DevtoolsInsightQuery, DevtoolsInsights } from \"../production/insights/types\";\nimport type { MountDevtoolsRoutesDeps } from \"./types\";\n\ntype InsightsQuerystring = { instance?: string; sort?: string; limit?: string };\n\nconst QUERY_SORTS = [\"total\", \"p95\", \"count\", \"n+1\"] as const;\nconst ROUTE_SORTS = [\"total\", \"p95\", \"count\", \"errors\"] as const;\n\n/**\n * Reads `?instance=&sort=&limit=`. A sort outside `sorts` or a limit that is\n * not a whole number from 1 to 500 answers `input.invalid`.\n */\nexport function parseInsightQuery(\n query: InsightsQuerystring,\n sorts?: readonly string[],\n): DevtoolsInsightQuery {\n const result: DevtoolsInsightQuery = { instance: query.instance || \"all\" };\n\n if (sorts && query.sort !== undefined && query.sort !== \"\") {\n if (!sorts.includes(query.sort)) throw new DevtoolsApiError(\"input.invalid\");\n\n result.sort = query.sort;\n }\n\n if (query.limit !== undefined && query.limit !== \"\") {\n const limit = Number(query.limit);\n\n if (!Number.isInteger(limit) || limit < 1 || limit > 500) {\n throw new DevtoolsApiError(\"input.invalid\");\n }\n\n result.limit = limit;\n }\n\n return result;\n}\n\n/**\n * The read-only routes of the Resources, Queries (statistics), Routes\n * (statistics), Health, Errors, Logs (production) and Jobs tabs, over\n * `deps.insights`: `GET /api/instances`, `/api/resources`,\n * `/api/queries/stats`, `/api/routes/stats`, `/api/health`, `/api/errors`,\n * `/api/jobs`. Each takes `?instance=<id|all>` (default `all`). Without\n * `deps.insights` nothing is registered.\n */\nexport function registerInsightsRoutes(\n server: FastifyInstance,\n deps: MountDevtoolsRoutesDeps,\n): void {\n const insights: DevtoolsInsights | undefined = deps.insights;\n\n if (!insights) return;\n\n const route = (\n path: string,\n sorts: readonly string[] | undefined,\n read: (query: DevtoolsInsightQuery) => Promise<unknown>,\n ): void => {\n server.get<{ Querystring: InsightsQuerystring }>(path, async (request, reply) => {\n const query = parseInsightQuery(request.query, sorts);\n\n reply.header(\"Cache-Control\", \"no-store\");\n\n return read(query);\n });\n };\n\n route(\"/api/instances\", undefined, () => insights.instances());\n route(\"/api/resources\", undefined, (query) => insights.resources(query));\n route(\"/api/queries/stats\", QUERY_SORTS, (query) => insights.queryStats(query));\n route(\"/api/routes/stats\", ROUTE_SORTS, (query) => insights.routeStats(query));\n route(\"/api/health\", undefined, (query) => insights.health(query));\n route(\"/api/errors\", undefined, (query) => insights.errors(query));\n route(\"/api/jobs\", undefined, (query) => insights.jobs(query));\n}\n","import type { FastifyInstance } from \"fastify\";\nimport type { DevtoolsLogRow } from \"../production/contracts\";\nimport type { DevtoolsLogEntry } from \"../types\";\nimport { parseInsightQuery } from \"./insights-routes\";\nimport type { MountDevtoolsRoutesDeps } from \"./types\";\n\ntype LogsQuery = {\n level?: DevtoolsLogEntry[\"level\"];\n module?: string;\n instance?: string;\n limit?: string;\n};\n\n/**\n * Registers the log listing route, filterable by `level` and `module`. In\n * production it answers from the insights (every instance, no `context`);\n * in development it answers from the collector's logs, which keep `context`.\n */\nexport function registerLogRoutes(server: FastifyInstance, deps: MountDevtoolsRoutesDeps): void {\n server.get<{ Querystring: LogsQuery }>(\"/api/logs\", async (request, reply) => {\n const { level, module } = request.query;\n\n if (deps.mode === \"production\" && deps.insights) {\n const query = parseInsightQuery(request.query);\n\n reply.header(\"Cache-Control\", \"no-store\");\n\n return deps.insights.logs({\n ...query,\n ...(level ? { level } : {}),\n ...(module ? { module } : {}),\n });\n }\n\n const rows: DevtoolsLogRow[] = deps.collector.listLogs({ level, module }).map((entry) => ({\n level: entry.level,\n module: entry.module,\n action: entry.action,\n message: entry.message,\n at: entry.at,\n requestId: null,\n instance: null,\n context: entry.context,\n }));\n\n return rows;\n });\n}\n","import type { FastifyInstance } from \"fastify\";\nimport type { MountDevtoolsRoutesDeps } from \"./types\";\n\nconst MAIL_HTML_CSP =\n \"sandbox; default-src 'none'; img-src data: https: http:; style-src 'unsafe-inline'\";\n\n/** Registers the mailbox list, single-mail detail, and mail HTML routes. */\nexport function registerMailRoutes(server: FastifyInstance, deps: MountDevtoolsRoutesDeps): void {\n server.get(\"/api/mails\", async () => deps.collector.listMails());\n\n server.get<{ Params: { id: string } }>(\"/api/mails/:id\", async (request, reply) => {\n const mail = deps.collector.getMail(request.params.id);\n\n if (!mail) {\n reply.code(404).send();\n return;\n }\n\n const { html, ...rest } = mail;\n return rest;\n });\n\n server.get<{ Params: { id: string } }>(\"/api/mails/:id/html\", async (request, reply) => {\n const mail = deps.collector.getMail(request.params.id);\n\n if (!mail || !mail.html) {\n reply.code(404).send();\n return;\n }\n\n reply\n .header(\"Content-Security-Policy\", MAIL_HTML_CSP)\n .header(\"X-Content-Type-Options\", \"nosniff\")\n .header(\"Content-Type\", \"text/html; charset=utf-8\")\n .send(mail.html);\n });\n}\n","import { existsSync, readFileSync } from \"node:fs\";\nimport path from \"node:path\";\nimport type { FastifyInstance, FastifyReply, FastifyRequest } from \"fastify\";\nimport { resolveUiRoot } from \"../ui-root\";\n\n/**\n * Where an asset's bytes come from: a file in this package's `ui/` folder.\n */\ntype UiAsset = {\n contentType: string;\n file: () => string;\n};\n\nconst uiFile = (name: string) => () => path.join(resolveUiRoot(), name);\n\n/**\n * The only assets that can be requested. The request's asset name is looked\n * up here and never joined into a filesystem path.\n */\nconst UI_ASSETS: Record<string, UiAsset> = {\n \"app.js\": {\n contentType: \"text/javascript; charset=utf-8\",\n file: uiFile(\"dashboard/assets/app.js\"),\n },\n \"app.css\": { contentType: \"text/css; charset=utf-8\", file: uiFile(\"dashboard/assets/app.css\") },\n \"scalar.js\": {\n contentType: \"text/javascript; charset=utf-8\",\n file: uiFile(\"vendor/scalar/standalone.js\"),\n },\n \"swagger-ui-bundle.js\": {\n contentType: \"text/javascript; charset=utf-8\",\n file: uiFile(\"vendor/swagger-ui/swagger-ui-bundle.js\"),\n },\n \"swagger-ui.css\": {\n contentType: \"text/css; charset=utf-8\",\n file: uiFile(\"vendor/swagger-ui/swagger-ui.css\"),\n },\n \"docs-swagger.js\": {\n contentType: \"text/javascript; charset=utf-8\",\n file: uiFile(\"docs-swagger.js\"),\n },\n};\n\n/** Sends `file` with `contentType` and no caching. */\nexport function sendFile(reply: FastifyReply, file: string, contentType: string): void {\n reply\n .header(\"Cache-Control\", \"no-store\")\n .header(\"Content-Type\", contentType)\n .send(readFileSync(file));\n}\n\nconst NOT_BUILT_HTML =\n \"<!doctype html><title>Warlock Devtools</title><p>The devtools dashboard has not been built. Run <code>pnpm --filter @warlock.js/devtools build:ui</code>.</p>\";\n\n/**\n * Serves the static dashboard: the built `ui/dashboard/index.html` at the\n * dashboard root and the whitelisted assets (`app.js`, `app.css`, the\n * vendored Scalar bundle as `scalar.js`, and the vendored Swagger UI files\n * plus their init script). The asset name is matched against a fixed\n * whitelist — never joined into a filesystem path — so no request can\n * traverse outside it. Before the first `build:ui` the root answers 503 with\n * a note that says how to build. `notFound` answers an unknown asset (the\n * production gate passes its uniform 404, so the public asset route answers\n * like any unknown URL of the app); without it the answer is a bare 404.\n */\nexport function registerUiAssets(\n server: FastifyInstance,\n options: { notFound?: (request: FastifyRequest, reply: FastifyReply) => FastifyReply } = {},\n): void {\n const serveIndex = (request: FastifyRequest, reply: FastifyReply): void => {\n // The address as sent: core's server drops a trailing slash before routing.\n const [pathname = \"\", search] = (request.originalUrl ?? request.url).split(\"?\");\n\n // The page loads its assets by relative URL, so it must be served from `<path>/`. The target is built from\n // the route, never from the request, so it always stays on the dashboard path.\n if (!pathname.endsWith(\"/\")) {\n const base = (request.routeOptions.url ?? pathname).replace(/\\/+$/, \"\");\n\n reply\n .code(308)\n .header(\"Cache-Control\", \"no-store\")\n .redirect(`${base}/${search === undefined ? \"\" : `?${search}`}`, 308);\n return;\n }\n\n const index = path.join(resolveUiRoot(), \"dashboard\", \"index.html\");\n\n if (!existsSync(index)) {\n reply\n .code(503)\n .header(\"Cache-Control\", \"no-store\")\n .header(\"Content-Type\", \"text/html; charset=utf-8\")\n .send(NOT_BUILT_HTML);\n return;\n }\n\n reply\n .header(\"Cache-Control\", \"no-store\")\n .header(\"Content-Type\", \"text/html; charset=utf-8\")\n .send(readFileSync(index));\n };\n\n server.get(\"/\", serveIndex);\n\n server.get<{ Params: { name: string } }>(\"/assets/:name\", (request, reply) => {\n const asset = Object.hasOwn(UI_ASSETS, request.params.name)\n ? UI_ASSETS[request.params.name]\n : undefined;\n const file = asset?.file();\n\n if (!asset || !file || !existsSync(file)) {\n if (options.notFound) {\n options.notFound(request, reply);\n return;\n }\n\n reply.code(404).header(\"Cache-Control\", \"no-store\").send();\n return;\n }\n\n sendFile(reply, file, asset.contentType);\n });\n}\n","import path from \"node:path\";\nimport type { FastifyInstance, FastifyReply } from \"fastify\";\nimport { resolveUiRoot } from \"../ui-root\";\nimport type { MountDevtoolsRoutesDeps } from \"./types\";\nimport { sendFile } from \"./ui-assets\";\n\n/**\n * Registers the API docs: `GET /api/openapi.json` returns the document core\n * builds from the registered routes (`deps.getOpenApiDocument`), and\n * `GET /docs` serves the page that renders it with Scalar and\n * `GET /docs/swagger` the same document in Swagger UI;\n * `GET /api/postman.json` returns the Postman collection core builds\n * (`deps.getPostmanCollection`). The pages use relative URLs, so it works under whatever base path the dashboard is\n * mounted on.\n */\nexport function registerOpenApiRoutes(\n server: FastifyInstance,\n deps: MountDevtoolsRoutesDeps,\n): void {\n server.get(\"/api/openapi.json\", async (_request, reply) => {\n if (!deps.getOpenApiDocument) {\n return reply.code(503).header(\"Cache-Control\", \"no-store\").send({\n error: \"The OpenAPI document is not available: the host did not provide a generator.\",\n });\n }\n\n reply.header(\"Cache-Control\", \"no-store\");\n\n return deps.getOpenApiDocument();\n });\n\n server.get(\"/api/postman.json\", async (_request, reply) => {\n if (!deps.getPostmanCollection) {\n return reply.code(503).header(\"Cache-Control\", \"no-store\").send({\n error: \"The Postman collection is not available: the host did not provide a generator.\",\n });\n }\n\n reply.header(\"Cache-Control\", \"no-store\");\n\n return deps.getPostmanCollection();\n });\n\n // The API tab shows these pages in a frame. The app's own headers (core's security headers forbid framing) are\n // replaced on the reply; production sets its full docs policy on top.\n const frameable = (reply: FastifyReply): FastifyReply =>\n reply\n .header(\"X-Frame-Options\", \"SAMEORIGIN\")\n .header(\"Content-Security-Policy\", \"frame-ancestors 'self'\");\n\n server.get(\"/docs\", (_request, reply) => {\n sendFile(frameable(reply), path.join(resolveUiRoot(), \"docs.html\"), \"text/html; charset=utf-8\");\n });\n\n server.get(\"/docs/swagger\", (_request, reply) => {\n sendFile(\n frameable(reply),\n path.join(resolveUiRoot(), \"docs-swagger.html\"),\n \"text/html; charset=utf-8\",\n );\n });\n}\n","import type { FastifyInstance } from \"fastify\";\nimport { type MountedDevtoolsPanel, panelContentType } from \"../panels\";\nimport type { DevtoolsPanelRequest } from \"../types\";\nimport { sendFile } from \"./ui-assets\";\n\n/**\n * Mounts each panel's data routes at `/api/<id><route path>` and its view\n * module and assets at `/panels/<id>/<name>`. Callers register this inside\n * the devtools scope, so the guard covers every one of them. A file is\n * served only when its name is listed by the panel; the request never\n * becomes a filesystem path.\n */\nexport function registerPanelRoutes(\n server: FastifyInstance,\n panels: readonly MountedDevtoolsPanel[],\n): void {\n const byId = new Map(panels.map((panel) => [panel.id, panel]));\n\n for (const panel of panels) {\n for (const route of panel.routes) {\n server.route({\n method: route.method,\n url: `/api/${panel.id}${route.path}`,\n handler: async (request, reply) => {\n const input: DevtoolsPanelRequest = {\n params: (request.params ?? {}) as Record<string, string>,\n query: (request.query ?? {}) as Record<string, string | string[]>,\n body: request.body,\n };\n const result = await route.handler(input);\n\n reply.header(\"cache-control\", \"no-store\");\n\n if (result === undefined) return reply.code(204).send();\n\n return result;\n },\n });\n }\n }\n\n server.get<{ Params: { id: string; name: string } }>(\"/panels/:id/:name\", (request, reply) => {\n const panel = byId.get(request.params.id);\n const name = request.params.name;\n const file =\n panel === undefined\n ? undefined\n : name === \"view.js\"\n ? panel.view\n : Object.hasOwn(panel.assets, name)\n ? panel.assets[name]\n : undefined;\n\n if (file === undefined) {\n reply.code(404).header(\"Cache-Control\", \"no-store\").send();\n return;\n }\n\n reply.header(\"X-Content-Type-Options\", \"nosniff\");\n sendFile(reply, file, panelContentType(name));\n });\n}\n","import type { RequestLogFilter, RequestLogRecord, RequestLogSummary } from \"@warlock.js/core\";\nimport type {\n DevtoolsLogEntry,\n DevtoolsRequestDetail,\n DevtoolsRequestSummary,\n DevtoolsWarning,\n} from \"./types\";\n\n/** The list row filters run over, from an in-memory summary. */\nexport function summaryToRow(summary: DevtoolsRequestSummary): RequestLogSummary {\n return {\n id: summary.id,\n time: new Date(summary.startedAt).toISOString(),\n method: summary.method,\n url: summary.path,\n ...(summary.route ? { route: summary.route } : {}),\n status: summary.status ?? 0,\n durationMs: summary.durationMs ?? 0,\n };\n}\n\n/** An in-memory-shaped list row from a persisted one. */\nexport function rowToSummary(row: RequestLogSummary): DevtoolsRequestSummary {\n return {\n id: row.id,\n method: row.method,\n path: row.url,\n route: row.route,\n status: row.status,\n startedAt: Date.parse(row.time),\n durationMs: row.durationMs,\n queryCount: row.queryCount ?? 0,\n warningCount: row.nPlusOneCount ?? 0,\n persisted: true,\n };\n}\n\n/**\n * Merge the live ring buffer with the persisted log, newest first, without\n * duplicates: a request in both is shown from memory (it has the full\n * timeline). Persisted rows fill in what a restart or the ring buffer's size\n * evicted.\n */\nexport function mergeRequestHistory(\n live: readonly DevtoolsRequestSummary[],\n persisted: readonly RequestLogSummary[],\n limit: number,\n): DevtoolsRequestSummary[] {\n const seen = new Set(live.map((summary) => summary.id));\n const merged = [...live];\n\n for (const row of persisted) {\n if (seen.has(row.id)) continue;\n\n seen.add(row.id);\n merged.push(rowToSummary(row));\n }\n\n return merged.sort((first, second) => second.startedAt - first.startedAt).slice(0, limit);\n}\n\nconst FILTER_KEYS = [\"status\", \"route\", \"method\", \"since\", \"until\", \"q\"] as const;\n\n/** The request log filter in a `GET /api/requests` query string. */\nexport function filterFromQuery(query: Record<string, unknown>): RequestLogFilter {\n const filter: RequestLogFilter = {};\n\n for (const key of FILTER_KEYS) {\n const value = query[key];\n\n if (typeof value === \"string\" && value.trim() !== \"\") filter[key] = value.trim();\n }\n\n const limit = Number(query.limit);\n\n if (Number.isInteger(limit) && limit > 0) filter.limit = limit;\n\n return filter;\n}\n\n/** Whether a filter narrows anything. */\nexport function hasFilter(filter: RequestLogFilter): boolean {\n return FILTER_KEYS.some((key) => filter[key] !== undefined);\n}\n\nfunction toLogLevel(level: string): DevtoolsLogEntry[\"level\"] {\n return level === \"debug\" || level === \"info\" || level === \"warn\" || level === \"success\"\n ? level\n : \"error\";\n}\n\n/**\n * A request detail rebuilt from a persisted record, in the shape of an\n * in-memory one: phases, logs and N+1 warnings carry over; query-by-query\n * and cache detail live only in memory, so those lists are empty. `record`\n * has everything the log kept.\n */\nexport function recordToDetail(record: RequestLogRecord): DevtoolsRequestDetail {\n const startedAt = Date.parse(record.time);\n const warnings: DevtoolsWarning[] = (record.queries?.nPlusOne ?? []).map((finding) => ({\n type: \"n+1\",\n message: `${finding.query} ran ${finding.count} times`,\n shape: finding.query,\n count: finding.count,\n }));\n\n return {\n id: record.id,\n method: record.method,\n path: record.url,\n route: record.route.pattern,\n status: record.status,\n startedAt,\n durationMs: record.durationMs,\n error: record.error?.message,\n phases: (record.phases ?? []).map((phase) => ({\n name: phase.name,\n startedAt,\n durationMs: phase.durationMs,\n })),\n queries: [],\n cache: [],\n logs: (record.logs ?? []).map((entry) => ({\n level: toLogLevel(entry.level),\n module: entry.module,\n action: entry.action,\n message: entry.message,\n at: entry.at,\n ...(entry.context ? { context: entry.context } : {}),\n })),\n mails: [],\n warnings,\n persisted: true,\n record,\n };\n}\n","import type { RequestLogFilter } from \"@warlock.js/core\";\nimport type { FastifyInstance, FastifyReply } from \"fastify\";\nimport { DevtoolsApiError } from \"../production/errors\";\nimport type { DevtoolsSampleFilter } from \"../production/store/types\";\nimport {\n filterFromQuery,\n hasFilter,\n mergeRequestHistory,\n recordToDetail,\n summaryToRow,\n} from \"../request-history\";\nimport type { DevtoolsRequestDetail } from \"../types\";\nimport type { MountDevtoolsRoutesDeps } from \"./types\";\n\nconst STATUS_FILTER = /^(?:[1-5]\\d\\d|[1-5]xx)$/i;\nconst METHOD_FILTER = /^[A-Za-z]{1,16}$/;\nconst RELATIVE_SINCE = /^(\\d+)(s|m|h|d)$/;\nconst UNIT_MS = { s: 1000, m: 60_000, h: 3_600_000, d: 86_400_000 } as const;\nconst DEFAULT_SAMPLE_LIMIT = 200;\nconst MAX_SAMPLE_LIMIT = 1000;\n\n/** A time bound as epoch ms: a number, an ISO date, or (for `since`) a duration back such as `15m`. */\nfunction parseTimeBound(value: string, allowRelative: boolean): number {\n if (/^\\d+$/.test(value)) return Number(value);\n\n const relative = allowRelative ? RELATIVE_SINCE.exec(value) : null;\n\n if (relative) {\n return Date.now() - Number(relative[1]) * UNIT_MS[relative[2] as keyof typeof UNIT_MS];\n }\n\n const parsed = Date.parse(value);\n\n if (Number.isNaN(parsed)) throw new DevtoolsApiError(\"request.invalid-filter\");\n\n return parsed;\n}\n\n/** The stored-sample filter in a `GET /api/requests` query string; throws `request.invalid-filter`. */\nfunction sampleFilterFromQuery(\n query: Record<string, unknown>,\n filter: RequestLogFilter,\n fallbackLimit: number,\n): DevtoolsSampleFilter {\n const result: DevtoolsSampleFilter = {\n limit: Math.min(MAX_SAMPLE_LIMIT, filter.limit ?? fallbackLimit),\n };\n\n if (filter.status !== undefined) {\n const status = String(filter.status);\n\n if (!STATUS_FILTER.test(status)) throw new DevtoolsApiError(\"request.invalid-filter\");\n\n result.status = status.toLowerCase();\n }\n\n if (filter.method !== undefined) {\n if (!METHOD_FILTER.test(String(filter.method))) {\n throw new DevtoolsApiError(\"request.invalid-filter\");\n }\n\n result.method = String(filter.method);\n }\n\n if (filter.route !== undefined) result.route = String(filter.route);\n if (filter.q !== undefined) result.q = String(filter.q);\n if (filter.since !== undefined) result.since = parseTimeBound(String(filter.since), true);\n if (filter.until !== undefined) result.until = parseTimeBound(String(filter.until), false);\n\n const instance = query.instance;\n\n if (typeof instance === \"string\" && instance.trim() !== \"\" && instance !== \"all\") {\n result.instance = instance.trim();\n }\n\n return result;\n}\n\nfunction sendApiError(reply: FastifyReply, error: DevtoolsApiError): void {\n reply.code(error.statusCode).send(error.toBody());\n}\n\n/**\n * Production: the same four routes over the request source (stored samples\n * and this process's memory), merged with the persisted request log the way\n * development merges it with the ring buffer.\n */\nfunction registerProductionRequestsRoutes(\n server: FastifyInstance,\n deps: MountDevtoolsRoutesDeps,\n): void {\n const source = deps.requests;\n\n if (!source) return;\n\n server.get<{ Querystring: Record<string, unknown> }>(\"/api/requests\", async (request, reply) => {\n const { requestLog, options } = deps;\n\n try {\n const filter = filterFromQuery(request.query);\n const sampleFilter = sampleFilterFromQuery(request.query, filter, DEFAULT_SAMPLE_LIMIT);\n const limit = Math.min(MAX_SAMPLE_LIMIT, filter.limit ?? options.maxRequests);\n let persisted: Awaited<ReturnType<NonNullable<typeof requestLog>[\"list\"]>> = [];\n\n if (requestLog) {\n try {\n requestLog.compile(filter);\n persisted = await requestLog.list({ ...filter, limit });\n } catch (error) {\n // A bad filter value is the caller's mistake; a read failure leaves the samples.\n if (error instanceof Error && /^Invalid /.test(error.message)) {\n throw new DevtoolsApiError(\"request.invalid-filter\");\n }\n }\n }\n\n const samples = await source.list({ ...sampleFilter, limit });\n\n return mergeRequestHistory(samples, persisted, limit);\n } catch (error) {\n if (error instanceof DevtoolsApiError) {\n sendApiError(reply, error);\n return;\n }\n\n throw error;\n }\n });\n\n server.get<{ Params: { id: string } }>(\"/api/requests/:id\", async (request, reply) => {\n const { id } = request.params;\n const persisted = await deps.requestLog?.get(id).catch(() => undefined);\n const found = await source.get(id);\n\n if (found) {\n const hasTimeline = \"phases\" in found;\n\n if (hasTimeline) return persisted ? { ...found, record: persisted } : found;\n\n // A slow or failed request that was not sampled: the summary, plus what the log kept.\n if (persisted) {\n return {\n ...recordToDetail(persisted),\n ...(found.instance === undefined ? {} : { instance: found.instance }),\n partial: true,\n };\n }\n\n return found;\n }\n\n if (!persisted) {\n sendApiError(reply, new DevtoolsApiError(\"request.not-found\"));\n return;\n }\n\n return recordToDetail(persisted);\n });\n\n server.get<{ Params: { id: string } }>(\"/api/requests/:id/curl\", async (request, reply) => {\n const { id } = request.params;\n const baseUrl = `${request.protocol}://${request.headers.host ?? \"localhost\"}`;\n const persisted = await deps.requestLog?.get(id).catch(() => undefined);\n\n if (persisted && deps.requestLog) return { curl: deps.requestLog.curl(persisted, baseUrl) };\n\n const found = await source.get(id);\n\n if (!found) {\n sendApiError(reply, new DevtoolsApiError(\"request.not-found\"));\n return;\n }\n\n return { curl: `curl -X ${found.method} '${baseUrl}${found.path.replace(/'/g, `'\\\\''`)}'` };\n });\n\n server.delete(\"/api/requests\", async (_request, reply) => {\n await source.clear();\n deps.collector.clear();\n reply.code(204).send();\n });\n}\n\n/**\n * Registers the request list, single-request detail, \"copy as curl\", and\n * clear routes.\n *\n * With core's persistent request log available, the list and the detail also\n * read the JSON-lines history, so requests survive a restart. The list\n * accepts `status` (404 or 5xx), `route`, `method`, `since`, `until`, `q`\n * and `limit` query parameters.\n */\nexport function registerRequestsRoutes(\n server: FastifyInstance,\n deps: MountDevtoolsRoutesDeps,\n): void {\n if (deps.requests) {\n registerProductionRequestsRoutes(server, deps);\n return;\n }\n\n server.get<{ Querystring: Record<string, unknown> }>(\"/api/requests\", async (request, reply) => {\n const { requestLog, collector, options } = deps;\n\n if (!requestLog) return collector.listRequests();\n\n try {\n const filter = filterFromQuery(request.query);\n const matches = requestLog.compile(filter);\n const live = hasFilter(filter)\n ? collector.listRequests().filter((summary) => matches(summaryToRow(summary)))\n : collector.listRequests();\n const limit = filter.limit ?? options.maxRequests;\n const persisted = await requestLog.list({ ...filter, limit });\n\n return mergeRequestHistory(live, persisted, limit);\n } catch (error) {\n // A bad filter value is the caller's mistake; a read failure leaves the live list.\n if (error instanceof Error && /^Invalid /.test(error.message)) {\n reply.code(400).send({ error: error.message });\n return;\n }\n\n return collector.listRequests();\n }\n });\n\n server.get<{ Params: { id: string } }>(\"/api/requests/:id\", async (request, reply) => {\n const { id } = request.params;\n const persisted = await deps.requestLog?.get(id).catch(() => undefined);\n const found = deps.collector.getRequest(id);\n\n if (found) {\n const detail: DevtoolsRequestDetail = persisted ? { ...found, record: persisted } : found;\n\n return detail;\n }\n\n if (!persisted) {\n reply.code(404).send();\n return;\n }\n\n return recordToDetail(persisted);\n });\n\n server.get<{ Params: { id: string } }>(\"/api/requests/:id/curl\", async (request, reply) => {\n const { id } = request.params;\n const baseUrl = `${request.protocol}://${request.headers.host ?? \"localhost\"}`;\n const persisted = await deps.requestLog?.get(id).catch(() => undefined);\n\n if (persisted && deps.requestLog) return { curl: deps.requestLog.curl(persisted, baseUrl) };\n\n // Without a persisted record only the method and path are known.\n const live = deps.collector.getRequest(id);\n\n if (!live) {\n reply.code(404).send();\n return;\n }\n\n return { curl: `curl -X ${live.method} '${baseUrl}${live.path.replace(/'/g, `'\\\\''`)}'` };\n });\n\n server.delete(\"/api/requests\", async (_request, reply) => {\n deps.collector.clear();\n if (deps.ai?.available) deps.ai.store.clear();\n reply.code(204).send();\n });\n}\n","import type { FastifyInstance } from \"fastify\";\nimport type { MountDevtoolsRoutesDeps } from \"./types\";\n\n/** Registers the route map, sourced from core's router via `deps.listRoutes`. */\nexport function registerRouteRoutes(server: FastifyInstance, deps: MountDevtoolsRoutesDeps): void {\n server.get(\"/api/routes\", async () => (deps.listRoutes ? deps.listRoutes() : []));\n}\n","import type { FastifyInstance } from \"fastify\";\nimport type { DevtoolsStreamSession, MountDevtoolsRoutesDeps } from \"./types\";\nimport type { DevtoolsLogEntry, DevtoolsStreamEvent } from \"../types\";\n\nconst PING_INTERVAL_MS = 15_000;\n\n/** How long a browser waits before it reconnects a dropped stream. */\nconst RETRY_MS = 5000;\n\n/** The log entry as the production stream sends it: no context (it may hold values). */\nfunction withoutContext(entry: DevtoolsLogEntry): DevtoolsLogEntry {\n return {\n level: entry.level,\n module: entry.module,\n action: entry.action,\n message: entry.message,\n at: entry.at,\n };\n}\n\n/**\n * Registers the SSE stream: one `event: <type>\\ndata: <json>\\n\\n` frame per\n * collector event, plus a `: ping` comment every 15s to keep intermediaries\n * from closing an idle connection. The reply is hijacked so Fastify never\n * tries to serialize or close the response itself.\n *\n * The first frames are `retry: 5000` and an `event: hello` with the mode,\n * instance and role. In production (`deps.streamSession` set) the session and\n * the open state are checked again at every ping and the stream ends when\n * either fails; log entries carry no context; mail, AI and agent events flow\n * only when those tabs are enabled.\n */\nexport function registerStreamRoute(server: FastifyInstance, deps: MountDevtoolsRoutesDeps): void {\n server.get(\"/api/stream\", async (request, reply) => {\n // Opening first, so a refused stream (`stream.too-many`) is a normal JSON error.\n const session: DevtoolsStreamSession | null = deps.streamSession\n ? await deps.streamSession(request)\n : null;\n const enabled = new Set(deps.builtInPanels ?? []);\n const instanceId = deps.instance?.id;\n const mode = deps.mode ?? \"development\";\n\n reply.hijack();\n const res = reply.raw;\n\n res.writeHead(200, {\n ...session?.headers,\n \"Content-Type\": \"text/event-stream\",\n \"Cache-Control\": \"no-store\",\n Connection: \"keep-alive\",\n \"X-Accel-Buffering\": \"no\",\n });\n\n const write = (frame: string): void => {\n if (!res.writableEnded && !res.destroyed) res.write(frame);\n };\n\n write(`retry: ${RETRY_MS}\\n\\n`);\n\n const hello: Extract<DevtoolsStreamEvent, { type: \"hello\" }>[\"data\"] = {\n mode,\n instance: instanceId ?? null,\n role: session?.role ?? (mode === \"development\" ? \"admin\" : null),\n };\n\n write(`event: hello\\ndata: ${JSON.stringify(hello)}\\n\\n`);\n\n const dispose = deps.collector.subscribe((event) => {\n if (event.type === \"hello\") return;\n\n if (session !== null) {\n if (event.type === \"mail\" && !enabled.has(\"mail\")) return;\n\n if (event.type === \"log\") {\n if (!session.logLevels.includes(event.data.level)) return;\n\n const row = withoutContext(event.data);\n\n write(\n `event: log\\ndata: ${JSON.stringify(instanceId !== undefined ? { ...row, instance: instanceId } : row)}\\n\\n`,\n );\n return;\n }\n }\n\n const data =\n event.type === \"request\" && instanceId !== undefined\n ? { ...event.data, instance: instanceId }\n : event.data;\n\n write(`event: ${event.type}\\ndata: ${JSON.stringify(data)}\\n\\n`);\n });\n\n const aiAllowed = session === null || enabled.has(\"ai\");\n const agentsAllowed = session === null || enabled.has(\"agents\");\n\n const disposeAi =\n aiAllowed && deps.ai?.available\n ? deps.ai.subscribe((event) => {\n write(`event: ai\\ndata: ${JSON.stringify(event)}\\n\\n`);\n })\n : undefined;\n\n const disposeAgentTraces = agentsAllowed\n ? deps.agentTraces?.subscribe((event) => {\n write(`event: agent-trace\\ndata: ${JSON.stringify(event)}\\n\\n`);\n })\n : undefined;\n\n let closed = false;\n\n const close = (): void => {\n if (closed) return;\n\n closed = true;\n clearInterval(pingTimer);\n dispose();\n disposeAi?.();\n disposeAgentTraces?.();\n session?.release();\n\n if (!res.writableEnded && !res.destroyed) res.end();\n };\n\n const pingTimer = setInterval(() => {\n if (session === null) {\n write(\": ping\\n\\n\");\n return;\n }\n\n session.revalidate().then(\n (stillValid) => {\n if (closed) return;\n\n if (stillValid) write(\": ping\\n\\n\");\n else close();\n },\n () => close(),\n );\n }, PING_INTERVAL_MS);\n pingTimer.unref();\n\n request.raw.on(\"close\", close);\n res.on(\"error\", close);\n });\n}\n"],"mappings":";;;;;;;;;;;AAMA,SAAgB,iBAAiB,QAAyB,MAAqC;CAC7F,OAAO,IAA6C,WAAW,OAAO,SAAS,UAAU;EACvF,MAAM,OAAO,iBAAiB,UAAU;EACxC,MAAM,SAAS,KAAK;EACpB,IAAI,CAAC,QAAQ,WACX,OAAO;GAAE,WAAW;GAAO,SAAS,QAAQ;GAAgC,MAAM,CAAC;EAAE;EAEvF,MAAM,SACJ,QAAQ,MAAM,cAAc,SAAY,SAAY,EAAE,WAAW,QAAQ,MAAM,UAAU;EAC3F,OAAO;GACL,WAAW;GACX,MAAM,OAAO,MAAM,MAAM,MAAM,CAAC,CAAC,IAAI,OAAO,SAAS;GACrD,WAAW,OAAO,MAAM,UAAU,MAAM;EAC1C;CACF,CAAC;CAMD,OAAO,IACL,sBACA,OAAO,SAAS,UAAU;EACxB,MAAM,OAAO,iBAAiB,UAAU;EACxC,MAAM,SAAS,KAAK;EAEpB,IAAI,CAAC,QAAQ,UAAU,GACrB,OAAO;GAAE,WAAW;GAAO,SAASA;GAA8B,MAAM,CAAC;EAAE;EAG7E,OAAO;GACL,WAAW;GACX,MAAM,OAAO,KACX,QAAQ,MAAM,cAAc,SACxB,SACA,EAAE,WAAW,QAAQ,MAAM,UAAU,CAC3C;EACF;CACF,CACF;CAEA,OAAO,IAAgC,0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sAgentRun, DevtoolsAgentTraceEvent } from "./sources/agent-trace-source.mjs";
2
2
  import { DevtoolsAiEvent, DevtoolsAiRun } from "./sources/ai-source.mjs";
3
3
  import { DEVTOOLS_BUILT_IN_PANELS, DEVTOOLS_FAILURE_AUDIT_TYPES, DEVTOOLS_LATENCY_BUCKETS_MS, DevtoolsAccountView, DevtoolsApiErrorBody, DevtoolsAuditEntry, DevtoolsAuditType, DevtoolsAuthStepResult, DevtoolsBuiltInPanelId, DevtoolsCaptureCounters, DevtoolsCreatedInvite, DevtoolsErrorCode, DevtoolsErrorGroup, DevtoolsErrorsView, DevtoolsExplainResult, DevtoolsHealthReport, DevtoolsHealthView, DevtoolsHistogram, DevtoolsInstanceInfo, DevtoolsInstanceReport, DevtoolsInstancesView, DevtoolsInviteView, DevtoolsJobsReport, DevtoolsJobsView, DevtoolsLogRow, DevtoolsLoginInput, DevtoolsLogsView, DevtoolsMode, DevtoolsPanelInfo, DevtoolsPasswordSource, DevtoolsQueryShapeRow, DevtoolsQueryShapeStats, DevtoolsQueryStatsView, DevtoolsRecoveryCodes, DevtoolsReportLogEntry, DevtoolsResourcePoint, DevtoolsResourceSnapshot, DevtoolsResourcesView, DevtoolsRole, DevtoolsRoutePhaseStats, DevtoolsRouteStats, DevtoolsRouteStatsRow, DevtoolsRouteStatsView, DevtoolsSampleDetail, DevtoolsSampleQuery, DevtoolsSampleSummary, DevtoolsScheduleInfo, DevtoolsSessionInfo, DevtoolsSessionStage, DevtoolsSessionView, DevtoolsTotpEnrolment, DevtoolsUserListView } from "./production/contracts.mjs";
4
- import { DevtoolsBackground, DevtoolsCacheOperation, DevtoolsCallerLocation, DevtoolsCollector, DevtoolsDisposer, DevtoolsLogEntry, DevtoolsMail, DevtoolsMailAttachment, DevtoolsMailSummary, DevtoolsOptions, DevtoolsPanel, DevtoolsPanelExport, DevtoolsPanelFactoryContext, DevtoolsPanelMethod, DevtoolsPanelRequest, DevtoolsPanelRoute, DevtoolsPanels, DevtoolsPhase, DevtoolsProductionOptions, DevtoolsQuery, DevtoolsRequest, DevtoolsRequestDetail, DevtoolsRequestSummary, DevtoolsStreamEvent, DevtoolsWarning, ResolvedDevtoolsOptions } from "./types.mjs";
4
+ import { DevtoolsBackground, DevtoolsCacheOperation, DevtoolsCallerLocation, DevtoolsCollector, DevtoolsDisposer, DevtoolsLogEntry, DevtoolsMail, DevtoolsMailAttachment, DevtoolsMailSummary, DevtoolsOptions, DevtoolsPanel, DevtoolsPanelEntry, DevtoolsPanelExport, DevtoolsPanelFactoryContext, DevtoolsPanelMethod, DevtoolsPanelRequest, DevtoolsPanelRoute, DevtoolsPanels, DevtoolsPhase, DevtoolsProductionOptions, DevtoolsQuery, DevtoolsRequest, DevtoolsRequestDetail, DevtoolsRequestSummary, DevtoolsStreamEvent, DevtoolsWarning, ResolvedDevtoolsOptions } from "./types.mjs";
5
5
  import { devtoolsConnector } from "./devtools-connector.mjs";
6
- export { type DEVTOOLS_BUILT_IN_PANELS, type DEVTOOLS_FAILURE_AUDIT_TYPES, type DEVTOOLS_LATENCY_BUCKETS_MS, type DevtoolsAccountView, type DevtoolsAgentRun, type DevtoolsAgentTraceEvent, type DevtoolsAiEvent, type DevtoolsAiRun, type DevtoolsApiErrorBody, type DevtoolsAuditEntry, type DevtoolsAuditType, type DevtoolsAuthStepResult, type DevtoolsBackground, type DevtoolsBuiltInPanelId, type DevtoolsCacheOperation, type DevtoolsCallerLocation, type DevtoolsCaptureCounters, type DevtoolsCollector, type DevtoolsCreatedInvite, type DevtoolsDisposer, type DevtoolsErrorCode, type DevtoolsErrorGroup, type DevtoolsErrorsView, type DevtoolsExplainResult, type DevtoolsHealthReport, type DevtoolsHealthView, type DevtoolsHistogram, type DevtoolsInstanceInfo, type DevtoolsInstanceReport, type DevtoolsInstancesView, type DevtoolsInviteView, type DevtoolsJobsReport, type DevtoolsJobsView, type DevtoolsLogEntry, type DevtoolsLogRow, type DevtoolsLoginInput, type DevtoolsLogsView, type DevtoolsMail, type DevtoolsMailAttachment, type DevtoolsMailSummary, type DevtoolsMode, type DevtoolsOptions, type DevtoolsPanel, type DevtoolsPanelExport, type DevtoolsPanelFactoryContext, type DevtoolsPanelInfo, type DevtoolsPanelMethod, type DevtoolsPanelRequest, type DevtoolsPanelRoute, type DevtoolsPanels, type DevtoolsPasswordSource, type DevtoolsPhase, type DevtoolsProductionOptions, type DevtoolsQuery, type DevtoolsQueryShapeRow, type DevtoolsQueryShapeStats, type DevtoolsQueryStatsView, type DevtoolsRecoveryCodes, type DevtoolsReportLogEntry, type DevtoolsRequest, type DevtoolsRequestDetail, type DevtoolsRequestSummary, type DevtoolsResourcePoint, type DevtoolsResourceSnapshot, type DevtoolsResourcesView, type DevtoolsRole, type DevtoolsRoutePhaseStats, type DevtoolsRouteStats, type DevtoolsRouteStatsRow, type DevtoolsRouteStatsView, type DevtoolsSampleDetail, type DevtoolsSampleQuery, type DevtoolsSampleSummary, type DevtoolsScheduleInfo, type DevtoolsSessionInfo, type DevtoolsSessionStage, type DevtoolsSessionView, type DevtoolsStreamEvent, type DevtoolsTotpEnrolment, type DevtoolsUserListView, type DevtoolsWarning, type ResolvedDevtoolsOptions, devtoolsConnector };
6
+ import { DEVTOOLS_PANEL_TOKENS } from "./panel-tokens.mjs";
7
+ export { type DEVTOOLS_BUILT_IN_PANELS, type DEVTOOLS_FAILURE_AUDIT_TYPES, type DEVTOOLS_LATENCY_BUCKETS_MS, DEVTOOLS_PANEL_TOKENS, type DevtoolsAccountView, type DevtoolsAgentRun, type DevtoolsAgentTraceEvent, type DevtoolsAiEvent, type DevtoolsAiRun, type DevtoolsApiErrorBody, type DevtoolsAuditEntry, type DevtoolsAuditType, type DevtoolsAuthStepResult, type DevtoolsBackground, type DevtoolsBuiltInPanelId, type DevtoolsCacheOperation, type DevtoolsCallerLocation, type DevtoolsCaptureCounters, type DevtoolsCollector, type DevtoolsCreatedInvite, type DevtoolsDisposer, type DevtoolsErrorCode, type DevtoolsErrorGroup, type DevtoolsErrorsView, type DevtoolsExplainResult, type DevtoolsHealthReport, type DevtoolsHealthView, type DevtoolsHistogram, type DevtoolsInstanceInfo, type DevtoolsInstanceReport, type DevtoolsInstancesView, type DevtoolsInviteView, type DevtoolsJobsReport, type DevtoolsJobsView, type DevtoolsLogEntry, type DevtoolsLogRow, type DevtoolsLoginInput, type DevtoolsLogsView, type DevtoolsMail, type DevtoolsMailAttachment, type DevtoolsMailSummary, type DevtoolsMode, type DevtoolsOptions, type DevtoolsPanel, type DevtoolsPanelEntry, type DevtoolsPanelExport, type DevtoolsPanelFactoryContext, type DevtoolsPanelInfo, type DevtoolsPanelMethod, type DevtoolsPanelRequest, type DevtoolsPanelRoute, type DevtoolsPanels, type DevtoolsPasswordSource, type DevtoolsPhase, type DevtoolsProductionOptions, type DevtoolsQuery, type DevtoolsQueryShapeRow, type DevtoolsQueryShapeStats, type DevtoolsQueryStatsView, type DevtoolsRecoveryCodes, type DevtoolsReportLogEntry, type DevtoolsRequest, type DevtoolsRequestDetail, type DevtoolsRequestSummary, type DevtoolsResourcePoint, type DevtoolsResourceSnapshot, type DevtoolsResourcesView, type DevtoolsRole, type DevtoolsRoutePhaseStats, type DevtoolsRouteStats, type DevtoolsRouteStatsRow, type DevtoolsRouteStatsView, type DevtoolsSampleDetail, type DevtoolsSampleQuery, type DevtoolsSampleSummary, type DevtoolsScheduleInfo, type DevtoolsSessionInfo, type DevtoolsSessionStage, type DevtoolsSessionView, type DevtoolsStreamEvent, type DevtoolsTotpEnrolment, type DevtoolsUserListView, type DevtoolsWarning, type ResolvedDevtoolsOptions, devtoolsConnector };
package/esm/index.mjs CHANGED
@@ -1,3 +1,4 @@
1
1
  import { devtoolsConnector } from "./devtools-connector.mjs";
2
+ import { DEVTOOLS_PANEL_TOKENS } from "./panel-tokens.mjs";
2
3
 
3
- export { devtoolsConnector };
4
+ export { DEVTOOLS_PANEL_TOKENS, devtoolsConnector };
@@ -0,0 +1,13 @@
1
+ //#region ../../packages/devtools/src/panel-tokens.d.ts
2
+ /**
3
+ * The CSS variables the dashboard defines for package panels, in both themes.
4
+ *
5
+ * A package panel's stylesheet may use only these variables, plus variables it
6
+ * defines itself (in the same file). Anything else is undefined in the
7
+ * dashboard and renders as the browser default, which is how a panel ends up
8
+ * with unreadable text. The dashboard's own colours are checked for contrast
9
+ * (4.5:1 for the text tokens on `--background` and `--card`) in both themes.
10
+ */
11
+ export declare const DEVTOOLS_PANEL_TOKENS: readonly string[];
12
+ //#endregion
13
+ //# sourceMappingURL=panel-tokens.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"panel-tokens.d.mts","names":[],"sources":["../../../../../../../packages/devtools/src/panel-tokens.ts"],"mappings":";;;;;;;;;;qBASa"}
@@ -0,0 +1,45 @@
1
+ //#region ../../packages/devtools/src/panel-tokens.ts
2
+ /**
3
+ * The CSS variables the dashboard defines for package panels, in both themes.
4
+ *
5
+ * A package panel's stylesheet may use only these variables, plus variables it
6
+ * defines itself (in the same file). Anything else is undefined in the
7
+ * dashboard and renders as the browser default, which is how a panel ends up
8
+ * with unreadable text. The dashboard's own colours are checked for contrast
9
+ * (4.5:1 for the text tokens on `--background` and `--card`) in both themes.
10
+ */
11
+ const DEVTOOLS_PANEL_TOKENS = [
12
+ "--background",
13
+ "--foreground",
14
+ "--card",
15
+ "--card-foreground",
16
+ "--popover",
17
+ "--popover-foreground",
18
+ "--primary",
19
+ "--primary-foreground",
20
+ "--secondary",
21
+ "--secondary-foreground",
22
+ "--muted",
23
+ "--muted-foreground",
24
+ "--accent",
25
+ "--accent-foreground",
26
+ "--destructive",
27
+ "--border",
28
+ "--input",
29
+ "--ring",
30
+ "--radius",
31
+ "--brand",
32
+ "--brand-foreground",
33
+ "--success",
34
+ "--warning",
35
+ "--info",
36
+ "--chart-1",
37
+ "--chart-2",
38
+ "--chart-3",
39
+ "--chart-4",
40
+ "--chart-5"
41
+ ];
42
+
43
+ //#endregion
44
+ export { DEVTOOLS_PANEL_TOKENS };
45
+ //# sourceMappingURL=panel-tokens.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"panel-tokens.mjs","names":[],"sources":["../../../../../../../packages/devtools/src/panel-tokens.ts"],"sourcesContent":["/**\n * The CSS variables the dashboard defines for package panels, in both themes.\n *\n * A package panel's stylesheet may use only these variables, plus variables it\n * defines itself (in the same file). Anything else is undefined in the\n * dashboard and renders as the browser default, which is how a panel ends up\n * with unreadable text. The dashboard's own colours are checked for contrast\n * (4.5:1 for the text tokens on `--background` and `--card`) in both themes.\n */\nexport const DEVTOOLS_PANEL_TOKENS: readonly string[] = [\n \"--background\",\n \"--foreground\",\n \"--card\",\n \"--card-foreground\",\n \"--popover\",\n \"--popover-foreground\",\n \"--primary\",\n \"--primary-foreground\",\n \"--secondary\",\n \"--secondary-foreground\",\n \"--muted\",\n \"--muted-foreground\",\n \"--accent\",\n \"--accent-foreground\",\n \"--destructive\",\n \"--border\",\n \"--input\",\n \"--ring\",\n \"--radius\",\n \"--brand\",\n \"--brand-foreground\",\n \"--success\",\n \"--warning\",\n \"--info\",\n \"--chart-1\",\n \"--chart-2\",\n \"--chart-3\",\n \"--chart-4\",\n \"--chart-5\",\n];\n"],"mappings":";;;;;;;;;;AASA,MAAa,wBAA2C;CACtD;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF"}
package/esm/panels.mjs CHANGED
@@ -117,6 +117,17 @@ function checkDevtoolsPanels(panels) {
117
117
  const taken = /* @__PURE__ */ new Map();
118
118
  return panels.map((panel) => checkDevtoolsPanel(panel, taken));
119
119
  }
120
+ function isPlainObject(value) {
121
+ if (value === null || typeof value !== "object" || Array.isArray(value)) return false;
122
+ const prototype = Object.getPrototypeOf(value);
123
+ return prototype === Object.prototype || prototype === null;
124
+ }
125
+ /** What is wrong with a `[specifier, options]` entry, or `undefined` when it is valid. */
126
+ function tupleProblem(entry) {
127
+ if (entry.length !== 2) return `it has ${entry.length} item(s); use exactly [specifier, options]`;
128
+ if (typeof entry[0] !== "string" || entry[0] === "") return `its first item is ${JSON.stringify(entry[0])}; use the module specifier as a string`;
129
+ if (!isPlainObject(entry[1])) return `its second item is not a plain object; pass the options as { name: value }`;
130
+ }
120
131
  /** The URL or specifier to import for a `panels` entry. */
121
132
  function resolvePanelSpecifier(entry, root) {
122
133
  if (entry.startsWith("./") || entry.startsWith("../") || path.isAbsolute(entry)) return pathToFileURL(path.resolve(root, entry)).href;
@@ -185,8 +196,9 @@ function resolveWithRequire(entry, root) {
185
196
  }
186
197
  }
187
198
  /** The panels a module's default export describes. */
188
- async function panelsOf(exported, root, mode) {
199
+ async function panelsOf(exported, root, mode, panelOptions = {}) {
189
200
  const value = typeof exported === "function" ? await exported({
201
+ ...panelOptions,
190
202
  root,
191
203
  mode
192
204
  }) : exported;
@@ -210,13 +222,21 @@ async function loadDevtoolsPanels(entries, options) {
210
222
  for (const entry of entries) {
211
223
  let candidates;
212
224
  try {
213
- if (typeof entry === "string") {
214
- const module = await importModule(resolvePanelSpecifier(entry, options.root));
225
+ if (Array.isArray(entry)) {
226
+ const problem = tupleProblem(entry);
227
+ if (problem !== void 0) {
228
+ options.warn(`Devtools panels entry ${JSON.stringify(entry)} is invalid: ${problem}. Example: ["@warlock.js/grimoire/devtools", { ttlMs: 60000 }]. The entry was not added.`);
229
+ continue;
230
+ }
231
+ }
232
+ if (typeof entry === "string" || Array.isArray(entry)) {
233
+ const [specifier, panelOptions] = typeof entry === "string" ? [entry, void 0] : entry;
234
+ const module = await importModule(resolvePanelSpecifier(specifier, options.root));
215
235
  if (module.default === void 0) throw new Error("the module has no default export");
216
- candidates = await panelsOf(module.default, options.root, mode);
236
+ candidates = await panelsOf(module.default, options.root, mode, panelOptions);
217
237
  } else candidates = [entry];
218
238
  } catch (error) {
219
- options.warn(`Devtools panel module "${String(entry)}" could not be loaded: ${describe(error)}. Check that it is installed and listed correctly in the devtools "panels" option.`);
239
+ options.warn(`Devtools panel module "${String(Array.isArray(entry) ? entry[0] : entry)}" could not be loaded: ${describe(error)}. Check that it is installed and listed correctly in the devtools "panels" option.`);
220
240
  continue;
221
241
  }
222
242
  for (const candidate of candidates) try {
@@ -1 +1 @@
1
- {"version":3,"file":"panels.mjs","names":[],"sources":["../../../../../../../packages/devtools/src/panels.ts"],"sourcesContent":["import { existsSync, readFileSync, statSync } from \"node:fs\";\nimport { createRequire } from \"node:module\";\nimport path from \"node:path\";\nimport { fileURLToPath, pathToFileURL } from \"node:url\";\nimport { DEVTOOLS_BUILT_IN_PANELS } from \"./production/contracts\";\nimport type { DevtoolsMode, DevtoolsPanelInfo } from \"./production/contracts\";\nimport type {\n DevtoolsPanel,\n DevtoolsPanelExport,\n DevtoolsPanelMethod,\n DevtoolsPanelRoute,\n} from \"./types\";\n\n/**\n * A validated panel: file paths are absolute strings and every list is\n * present, so the server never re-checks them per request.\n */\nexport type MountedDevtoolsPanel = {\n id: string;\n title: string;\n view: string;\n routes: readonly (DevtoolsPanelRoute & { method: DevtoolsPanelMethod })[];\n assets: Readonly<Record<string, string>>;\n /** Whether the panel declared itself safe for the production monitor. */\n production: boolean;\n};\n\n/**\n * Ids the dashboard already uses for its own tabs, API segments and URLs. A\n * panel's routes live under `<path>/api/<id>`, so these would collide.\n */\nconst RESERVED_PANEL_IDS = new Set([\n \"account\",\n \"admin\",\n \"agents\",\n \"ai\",\n \"api\",\n \"assets\",\n \"auth\",\n \"background\",\n \"docs\",\n \"errors\",\n \"health\",\n \"instances\",\n \"jobs\",\n \"logs\",\n \"mail\",\n \"mails\",\n \"panels\",\n \"queries\",\n \"requests\",\n \"resources\",\n \"routes\",\n \"stream\",\n]);\n\nconst PANEL_ID = /^[a-z][a-z0-9-]*$/;\nconst ASSET_NAME = /^[A-Za-z0-9_][A-Za-z0-9._-]*$/;\nconst METHODS = new Set<DevtoolsPanelMethod>([\"GET\", \"POST\", \"PUT\", \"PATCH\", \"DELETE\"]);\n\n/** Content types for the files a panel may serve; anything else is sent as bytes. */\nconst CONTENT_TYPES: Record<string, string> = {\n \".js\": \"text/javascript; charset=utf-8\",\n \".mjs\": \"text/javascript; charset=utf-8\",\n \".css\": \"text/css; charset=utf-8\",\n \".json\": \"application/json; charset=utf-8\",\n \".svg\": \"image/svg+xml\",\n \".png\": \"image/png\",\n \".woff2\": \"font/woff2\",\n};\n\n/** The content type a panel file is served with, from its served name. */\nexport function panelContentType(name: string): string {\n return CONTENT_TYPES[path.extname(name).toLowerCase()] ?? \"application/octet-stream\";\n}\n\n/** An absolute file path from a path or `file:` URL, or `undefined` for anything else. */\nfunction toFilePath(value: unknown): string | undefined {\n if (value instanceof URL) return value.protocol === \"file:\" ? fileURLToPath(value) : undefined;\n if (typeof value !== \"string\" || value === \"\") return undefined;\n if (value.startsWith(\"file:\")) return fileURLToPath(value);\n\n return path.isAbsolute(value) ? value : undefined;\n}\n\nfunction isFile(file: string): boolean {\n return existsSync(file) && statSync(file).isFile();\n}\n\n/**\n * Validates `value` as a panel and returns it ready to mount. Throws an\n * error that names the panel and what to change; `taken` maps the ids\n * already registered to their titles and receives this panel's id.\n */\nexport function checkDevtoolsPanel(\n value: unknown,\n taken: Map<string, string>,\n): MountedDevtoolsPanel {\n const panel = (value ?? {}) as Partial<DevtoolsPanel>;\n const id = panel.id;\n\n if (typeof id !== \"string\" || !PANEL_ID.test(id)) {\n throw new Error(\n `A devtools panel needs an \"id\" of lower-case letters, digits and dashes that starts with a letter; got ${JSON.stringify(id)}.`,\n );\n }\n\n if (RESERVED_PANEL_IDS.has(id)) {\n throw new Error(\n `Devtools panel id \"${id}\" is used by the dashboard itself; give the panel another id.`,\n );\n }\n\n const existing = taken.get(id);\n\n if (existing !== undefined) {\n throw new Error(\n `Devtools panel id \"${id}\" is already registered by the \"${existing}\" panel; each panel needs its own id.`,\n );\n }\n\n if (typeof panel.title !== \"string\" || panel.title.trim() === \"\") {\n throw new Error(`Devtools panel \"${id}\" needs a \"title\" for its tab.`);\n }\n\n const view = toFilePath(panel.view);\n\n if (view === undefined) {\n throw new Error(\n `Devtools panel \"${id}\" needs a \"view\": an absolute path or file: URL of its browser module.`,\n );\n }\n\n if (!isFile(view)) {\n throw new Error(`The view module of devtools panel \"${id}\" was not found at ${view}.`);\n }\n\n // Two routes on one method and path would make the server refuse to start.\n const seen = new Set<string>();\n const routes = (panel.routes ?? []).map((route) => {\n const method = route.method ?? \"GET\";\n\n if (!METHODS.has(method)) {\n throw new Error(\n `Devtools panel \"${id}\" has a route with method \"${String(method)}\"; use GET, POST, PUT, PATCH or DELETE.`,\n );\n }\n\n if (typeof route.path !== \"string\" || (route.path !== \"\" && !route.path.startsWith(\"/\"))) {\n throw new Error(\n `Devtools panel \"${id}\" has a route path ${JSON.stringify(route.path)}; use \"\" or a path starting with \"/\".`,\n );\n }\n\n if (typeof route.handler !== \"function\") {\n throw new Error(`Devtools panel \"${id}\" route ${method} \"${route.path}\" has no handler.`);\n }\n\n if (seen.has(`${method} ${route.path}`)) {\n throw new Error(\n `Devtools panel \"${id}\" lists route ${method} \"${route.path}\" twice; keep one.`,\n );\n }\n\n seen.add(`${method} ${route.path}`);\n\n return { ...route, method };\n });\n\n const assets: Record<string, string> = {};\n\n for (const [name, source] of Object.entries(panel.assets ?? {})) {\n if (!ASSET_NAME.test(name) || name === \"view.js\") {\n throw new Error(\n `Devtools panel \"${id}\" has an asset named ${JSON.stringify(name)}; use a plain file name other than \"view.js\".`,\n );\n }\n\n const file = toFilePath(source);\n\n if (file === undefined || !isFile(file)) {\n throw new Error(\n `The asset \"${name}\" of devtools panel \"${id}\" was not found at ${String(source)}; give an absolute path or file: URL.`,\n );\n }\n\n assets[name] = file;\n }\n\n taken.set(id, panel.title);\n\n return { id, title: panel.title, view, routes, assets, production: panel.production === true };\n}\n\n/** Validates a list of panels; the first invalid or duplicate one throws. */\nexport function checkDevtoolsPanels(panels: readonly unknown[]): MountedDevtoolsPanel[] {\n const taken = new Map<string, string>();\n\n return panels.map((panel) => checkDevtoolsPanel(panel, taken));\n}\n\n/** Hooks `loadDevtoolsPanels` uses; replaced in specs. */\nexport type LoadDevtoolsPanelsOptions = {\n /** The app's root directory: bare specifiers resolve from here, `./` paths are relative to it. */\n root: string;\n /** Receives one line per entry that could not be loaded or was rejected. */\n warn: (message: string) => void;\n /** Ids already taken (the built-in panels), mapped to their titles. */\n taken?: ReadonlyMap<string, string>;\n /** Imports a module URL or specifier; defaults to a dynamic `import()`. */\n importModule?: (specifier: string) => Promise<unknown>;\n /** Where the dashboard runs; panel factories receive it as `context.mode`. @default \"development\" */\n mode?: DevtoolsMode;\n};\n\n/** The URL or specifier to import for a `panels` entry. */\nfunction resolvePanelSpecifier(entry: string, root: string): string {\n if (entry.startsWith(\"./\") || entry.startsWith(\"../\") || path.isAbsolute(entry)) {\n return pathToFileURL(path.resolve(root, entry)).href;\n }\n\n return resolveFromNodeModules(entry, root) ?? resolveWithRequire(entry, root) ?? entry;\n}\n\n/** Picks the file an `exports` target names: `import`, then `default`, then `node`. */\nfunction exportTarget(target: unknown): string | undefined {\n if (typeof target === \"string\") return target;\n\n if (Array.isArray(target)) {\n for (const item of target) {\n const found = exportTarget(item);\n\n if (found !== undefined) return found;\n }\n\n return undefined;\n }\n\n if (target !== null && typeof target === \"object\") {\n const conditions = target as Record<string, unknown>;\n\n for (const condition of [\"import\", \"node\", \"default\"]) {\n const found = exportTarget(conditions[condition]);\n\n if (found !== undefined) return found;\n }\n }\n\n return undefined;\n}\n\n/**\n * Resolves a package specifier by looking it up in the `node_modules` folders\n * above the app root and reading its `exports` map. `createRequire().resolve`\n * cannot do this for a package that only has an `import` condition.\n */\nfunction resolveFromNodeModules(entry: string, root: string): string | undefined {\n const parts = entry.split(\"/\");\n const nameLength = entry.startsWith(\"@\") ? 2 : 1;\n const name = parts.slice(0, nameLength).join(\"/\");\n const subpath = parts.length > nameLength ? `./${parts.slice(nameLength).join(\"/\")}` : \".\";\n\n if (!name) return undefined;\n\n let directory = path.resolve(root);\n\n for (;;) {\n const packageDirectory = path.join(directory, \"node_modules\", name);\n const manifestFile = path.join(packageDirectory, \"package.json\");\n\n if (existsSync(manifestFile)) {\n try {\n const manifest = JSON.parse(readFileSync(manifestFile, \"utf8\")) as {\n exports?: unknown;\n main?: string;\n };\n const exported = manifest.exports;\n const map =\n exported !== null && typeof exported === \"object\" && !Array.isArray(exported)\n ? (exported as Record<string, unknown>)\n : undefined;\n const hasSubpaths =\n map !== undefined && Object.keys(map).some((key) => key.startsWith(\".\"));\n const target =\n exported === undefined\n ? subpath === \".\"\n ? (manifest.main ?? \"index.js\")\n : subpath\n : hasSubpaths\n ? exportTarget(map?.[subpath])\n : subpath === \".\"\n ? exportTarget(exported)\n : undefined;\n\n if (target === undefined) return undefined;\n\n const file = path.resolve(packageDirectory, target);\n\n return isFile(file) ? pathToFileURL(file).href : undefined;\n } catch {\n return undefined;\n }\n }\n\n const parent = path.dirname(directory);\n\n if (parent === directory) return undefined;\n\n directory = parent;\n }\n}\n\n/** The `require` resolution, for packages the `node_modules` lookup does not understand. */\nfunction resolveWithRequire(entry: string, root: string): string | undefined {\n try {\n return pathToFileURL(createRequire(path.join(root, \"package.json\")).resolve(entry)).href;\n } catch {\n return undefined;\n }\n}\n\n/** The panels a module's default export describes. */\nasync function panelsOf(\n exported: DevtoolsPanelExport,\n root: string,\n mode: DevtoolsMode,\n): Promise<readonly unknown[]> {\n const value = typeof exported === \"function\" ? await exported({ root, mode }) : exported;\n\n return Array.isArray(value) ? value : [value];\n}\n\n/**\n * Loads the devtools `panels` option: imports each module entry, reads its\n * default export, and validates every panel. An entry that fails to load and\n * a panel that is invalid or reuses an id are reported through `warn` and\n * skipped, so one broken panel never stops the dashboard.\n */\nexport async function loadDevtoolsPanels(\n entries: readonly (string | DevtoolsPanel)[],\n options: LoadDevtoolsPanelsOptions,\n): Promise<MountedDevtoolsPanel[]> {\n // `src/config/devtools.ts` is a plain object with no types: a single string would be read letter by letter.\n if (!Array.isArray(entries as unknown)) {\n options.warn(\n `The devtools \"panels\" option must be a list, such as panels: [\"@warlock.js/grimoire/devtools\"]; got ${JSON.stringify(entries)}. No panel was added.`,\n );\n\n return [];\n }\n\n const importModule = options.importModule ?? ((specifier: string) => import(specifier));\n const mode = options.mode ?? \"development\";\n const taken = new Map<string, string>(options.taken ?? []);\n const panels: MountedDevtoolsPanel[] = [];\n\n for (const entry of entries) {\n let candidates: readonly unknown[];\n\n try {\n if (typeof entry === \"string\") {\n const module = (await importModule(resolvePanelSpecifier(entry, options.root))) as {\n default?: DevtoolsPanelExport;\n };\n\n if (module.default === undefined) {\n throw new Error(\"the module has no default export\");\n }\n\n candidates = await panelsOf(module.default, options.root, mode);\n } else {\n candidates = [entry];\n }\n } catch (error) {\n options.warn(\n `Devtools panel module \"${String(entry)}\" could not be loaded: ${describe(error)}. Check that it is installed and listed correctly in the devtools \"panels\" option.`,\n );\n continue;\n }\n\n for (const candidate of candidates) {\n try {\n panels.push(checkDevtoolsPanel(candidate, taken));\n } catch (error) {\n options.warn(`${describe(error)} The panel was not added.`);\n }\n }\n }\n\n return panels;\n}\n\nfunction describe(error: unknown): string {\n return error instanceof Error ? error.message : String(error);\n}\n\n/** What `productionPanels` decides. */\nexport type DevtoolsProductionPanels = {\n /** Built-in tab ids shown, in display order. */\n builtIn: string[];\n /** Package panels shown. */\n panels: MountedDevtoolsPanel[];\n};\n\n/**\n * Which tabs the production monitor shows. A built-in tab follows\n * `DEVTOOLS_BUILT_IN_PANELS` unless `overrides[id]` says otherwise. A package\n * panel (the Processes panel included) shows when it declares\n * `production: true` or `overrides[id]` is `true`; `overrides[id]: false` turns\n * any tab off.\n */\nexport function productionPanels(\n packagePanels: readonly MountedDevtoolsPanel[],\n overrides: Readonly<Record<string, boolean>> = {},\n): DevtoolsProductionPanels {\n const builtIn = DEVTOOLS_BUILT_IN_PANELS.filter((tab) => overrides[tab.id] ?? tab.production).map(\n (tab) => tab.id,\n );\n const panels = packagePanels.filter((panel) => overrides[panel.id] ?? panel.production);\n\n return { builtIn, panels };\n}\n\n/**\n * The tab list `GET api/panels` answers with: the built-in tabs in\n * `builtIn` (default: every one), in display order, then the package panels\n * in registration order.\n */\nexport function listPanelInfos(\n panels: readonly Pick<MountedDevtoolsPanel, \"id\" | \"title\">[],\n builtIn?: readonly string[],\n): DevtoolsPanelInfo[] {\n const tabs: DevtoolsPanelInfo[] = DEVTOOLS_BUILT_IN_PANELS.filter(\n (tab) => builtIn === undefined || builtIn.includes(tab.id),\n ).map((tab) => ({ id: tab.id, title: tab.title, type: \"built-in\" as const }));\n\n for (const panel of panels)\n tabs.push({ id: panel.id, title: panel.title, type: \"package\" as const });\n\n return tabs;\n}\n"],"mappings":";;;;;;;;;;;AA+BA,MAAM,qCAAqB,IAAI,IAAI;CACjC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;AAED,MAAM,WAAW;AACjB,MAAM,aAAa;AACnB,MAAM,0BAAU,IAAI,IAAyB;CAAC;CAAO;CAAQ;CAAO;CAAS;AAAQ,CAAC;;AAGtF,MAAM,gBAAwC;CAC5C,OAAO;CACP,QAAQ;CACR,QAAQ;CACR,SAAS;CACT,QAAQ;CACR,QAAQ;CACR,UAAU;AACZ;;AAGA,SAAgB,iBAAiB,MAAsB;CACrD,OAAO,cAAc,KAAK,QAAQ,IAAI,CAAC,CAAC,YAAY,MAAM;AAC5D;;AAGA,SAAS,WAAW,OAAoC;CACtD,IAAI,iBAAiB,KAAK,OAAO,MAAM,aAAa,UAAU,cAAc,KAAK,IAAI;CACrF,IAAI,OAAO,UAAU,YAAY,UAAU,IAAI,OAAO;CACtD,IAAI,MAAM,WAAW,OAAO,GAAG,OAAO,cAAc,KAAK;CAEzD,OAAO,KAAK,WAAW,KAAK,IAAI,QAAQ;AAC1C;AAEA,SAAS,OAAO,MAAuB;CACrC,OAAO,WAAW,IAAI,KAAK,SAAS,IAAI,CAAC,CAAC,OAAO;AAC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0BAA0B,OAAO,KAAK,EAAE,yBAAyB,SAAS,KAAK,EAAE,mFACnF;GACA;EACF;EAEA,KAAK,MAAM,aAAa,YACtB,IAAI;GACF,OAAO,KAAK,mBAAmB,WAAW,KAAK,CAAC;EAClD,SAAS,OAAO;GACd,QAAQ,KAAK,GAAG,SAAS,KAAK,EAAE,0BAA0B;EAC5D;CAEJ;CAEA,OAAO;AACT;AAEA,SAAS,SAAS,OAAwB;CACxC,OAAO,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;AAC9D;;;;;;;;AAiBA,SAAgB,iBACd,eACA,YAA+C,CAAC,GACtB;CAM1B,OAAO;EAAE,SALO,yBAAyB,QAAQ,QAAQ,UAAU,IAAI,OAAO,IAAI,UAAU,CAAC,CAAC,KAC3F,QAAQ,IAAI,EAIA;EAAG,QAFH,cAAc,QAAQ,UAAU,UAAU,MAAM,OAAO,MAAM,UAErD;CAAE;AAC3B;;;;;;AAOA,SAAgB,eACd,QACA,SACqB;CACrB,MAAM,OAA4B,yBAAyB,QACxD,QAAQ,YAAY,UAAa,QAAQ,SAAS,IAAI,EAAE,CAC3D,CAAC,CAAC,KAAK,SAAS;EAAE,IAAI,IAAI;EAAI,OAAO,IAAI;EAAO,MAAM;CAAoB,EAAE;CAE5E,KAAK,MAAM,SAAS,QAClB,KAAK,KAAK;EAAE,IAAI,MAAM;EAAI,OAAO,MAAM;EAAO,MAAM;CAAmB,CAAC;CAE1E,OAAO;AACT"}
1
+ {"version":3,"file":"panels.mjs","names":[],"sources":["../../../../../../../packages/devtools/src/panels.ts"],"sourcesContent":["import { existsSync, readFileSync, statSync } from \"node:fs\";\nimport { createRequire } from \"node:module\";\nimport path from \"node:path\";\nimport { fileURLToPath, pathToFileURL } from \"node:url\";\nimport { DEVTOOLS_BUILT_IN_PANELS } from \"./production/contracts\";\nimport type { DevtoolsMode, DevtoolsPanelInfo } from \"./production/contracts\";\nimport type {\n DevtoolsPanel,\n DevtoolsPanelEntry,\n DevtoolsPanelExport,\n DevtoolsPanelMethod,\n DevtoolsPanelRoute,\n} from \"./types\";\n\n/**\n * A validated panel: file paths are absolute strings and every list is\n * present, so the server never re-checks them per request.\n */\nexport type MountedDevtoolsPanel = {\n id: string;\n title: string;\n view: string;\n routes: readonly (DevtoolsPanelRoute & { method: DevtoolsPanelMethod })[];\n assets: Readonly<Record<string, string>>;\n /** Whether the panel declared itself safe for the production monitor. */\n production: boolean;\n};\n\n/**\n * Ids the dashboard already uses for its own tabs, API segments and URLs. A\n * panel's routes live under `<path>/api/<id>`, so these would collide.\n */\nconst RESERVED_PANEL_IDS = new Set([\n \"account\",\n \"admin\",\n \"agents\",\n \"ai\",\n \"api\",\n \"assets\",\n \"auth\",\n \"background\",\n \"docs\",\n \"errors\",\n \"health\",\n \"instances\",\n \"jobs\",\n \"logs\",\n \"mail\",\n \"mails\",\n \"panels\",\n \"queries\",\n \"requests\",\n \"resources\",\n \"routes\",\n \"stream\",\n]);\n\nconst PANEL_ID = /^[a-z][a-z0-9-]*$/;\nconst ASSET_NAME = /^[A-Za-z0-9_][A-Za-z0-9._-]*$/;\nconst METHODS = new Set<DevtoolsPanelMethod>([\"GET\", \"POST\", \"PUT\", \"PATCH\", \"DELETE\"]);\n\n/** Content types for the files a panel may serve; anything else is sent as bytes. */\nconst CONTENT_TYPES: Record<string, string> = {\n \".js\": \"text/javascript; charset=utf-8\",\n \".mjs\": \"text/javascript; charset=utf-8\",\n \".css\": \"text/css; charset=utf-8\",\n \".json\": \"application/json; charset=utf-8\",\n \".svg\": \"image/svg+xml\",\n \".png\": \"image/png\",\n \".woff2\": \"font/woff2\",\n};\n\n/** The content type a panel file is served with, from its served name. */\nexport function panelContentType(name: string): string {\n return CONTENT_TYPES[path.extname(name).toLowerCase()] ?? \"application/octet-stream\";\n}\n\n/** An absolute file path from a path or `file:` URL, or `undefined` for anything else. */\nfunction toFilePath(value: unknown): string | undefined {\n if (value instanceof URL) return value.protocol === \"file:\" ? fileURLToPath(value) : undefined;\n if (typeof value !== \"string\" || value === \"\") return undefined;\n if (value.startsWith(\"file:\")) return fileURLToPath(value);\n\n return path.isAbsolute(value) ? value : undefined;\n}\n\nfunction isFile(file: string): boolean {\n return existsSync(file) && statSync(file).isFile();\n}\n\n/**\n * Validates `value` as a panel and returns it ready to mount. Throws an\n * error that names the panel and what to change; `taken` maps the ids\n * already registered to their titles and receives this panel's id.\n */\nexport function checkDevtoolsPanel(\n value: unknown,\n taken: Map<string, string>,\n): MountedDevtoolsPanel {\n const panel = (value ?? {}) as Partial<DevtoolsPanel>;\n const id = panel.id;\n\n if (typeof id !== \"string\" || !PANEL_ID.test(id)) {\n throw new Error(\n `A devtools panel needs an \"id\" of lower-case letters, digits and dashes that starts with a letter; got ${JSON.stringify(id)}.`,\n );\n }\n\n if (RESERVED_PANEL_IDS.has(id)) {\n throw new Error(\n `Devtools panel id \"${id}\" is used by the dashboard itself; give the panel another id.`,\n );\n }\n\n const existing = taken.get(id);\n\n if (existing !== undefined) {\n throw new Error(\n `Devtools panel id \"${id}\" is already registered by the \"${existing}\" panel; each panel needs its own id.`,\n );\n }\n\n if (typeof panel.title !== \"string\" || panel.title.trim() === \"\") {\n throw new Error(`Devtools panel \"${id}\" needs a \"title\" for its tab.`);\n }\n\n const view = toFilePath(panel.view);\n\n if (view === undefined) {\n throw new Error(\n `Devtools panel \"${id}\" needs a \"view\": an absolute path or file: URL of its browser module.`,\n );\n }\n\n if (!isFile(view)) {\n throw new Error(`The view module of devtools panel \"${id}\" was not found at ${view}.`);\n }\n\n // Two routes on one method and path would make the server refuse to start.\n const seen = new Set<string>();\n const routes = (panel.routes ?? []).map((route) => {\n const method = route.method ?? \"GET\";\n\n if (!METHODS.has(method)) {\n throw new Error(\n `Devtools panel \"${id}\" has a route with method \"${String(method)}\"; use GET, POST, PUT, PATCH or DELETE.`,\n );\n }\n\n if (typeof route.path !== \"string\" || (route.path !== \"\" && !route.path.startsWith(\"/\"))) {\n throw new Error(\n `Devtools panel \"${id}\" has a route path ${JSON.stringify(route.path)}; use \"\" or a path starting with \"/\".`,\n );\n }\n\n if (typeof route.handler !== \"function\") {\n throw new Error(`Devtools panel \"${id}\" route ${method} \"${route.path}\" has no handler.`);\n }\n\n if (seen.has(`${method} ${route.path}`)) {\n throw new Error(\n `Devtools panel \"${id}\" lists route ${method} \"${route.path}\" twice; keep one.`,\n );\n }\n\n seen.add(`${method} ${route.path}`);\n\n return { ...route, method };\n });\n\n const assets: Record<string, string> = {};\n\n for (const [name, source] of Object.entries(panel.assets ?? {})) {\n if (!ASSET_NAME.test(name) || name === \"view.js\") {\n throw new Error(\n `Devtools panel \"${id}\" has an asset named ${JSON.stringify(name)}; use a plain file name other than \"view.js\".`,\n );\n }\n\n const file = toFilePath(source);\n\n if (file === undefined || !isFile(file)) {\n throw new Error(\n `The asset \"${name}\" of devtools panel \"${id}\" was not found at ${String(source)}; give an absolute path or file: URL.`,\n );\n }\n\n assets[name] = file;\n }\n\n taken.set(id, panel.title);\n\n return { id, title: panel.title, view, routes, assets, production: panel.production === true };\n}\n\n/** Validates a list of panels; the first invalid or duplicate one throws. */\nexport function checkDevtoolsPanels(panels: readonly unknown[]): MountedDevtoolsPanel[] {\n const taken = new Map<string, string>();\n\n return panels.map((panel) => checkDevtoolsPanel(panel, taken));\n}\n\n/** Hooks `loadDevtoolsPanels` uses; replaced in specs. */\nexport type LoadDevtoolsPanelsOptions = {\n /** The app's root directory: bare specifiers resolve from here, `./` paths are relative to it. */\n root: string;\n /** Receives one line per entry that could not be loaded or was rejected. */\n warn: (message: string) => void;\n /** Ids already taken (the built-in panels), mapped to their titles. */\n taken?: ReadonlyMap<string, string>;\n /** Imports a module URL or specifier; defaults to a dynamic `import()`. */\n importModule?: (specifier: string) => Promise<unknown>;\n /** Where the dashboard runs; panel factories receive it as `context.mode`. @default \"development\" */\n mode?: DevtoolsMode;\n};\n\nfunction isPlainObject(value: unknown): value is Record<string, unknown> {\n if (value === null || typeof value !== \"object\" || Array.isArray(value)) return false;\n\n const prototype = Object.getPrototypeOf(value);\n\n return prototype === Object.prototype || prototype === null;\n}\n\n/** What is wrong with a `[specifier, options]` entry, or `undefined` when it is valid. */\nfunction tupleProblem(entry: readonly unknown[]): string | undefined {\n if (entry.length !== 2) {\n return `it has ${entry.length} item(s); use exactly [specifier, options]`;\n }\n\n if (typeof entry[0] !== \"string\" || entry[0] === \"\") {\n return `its first item is ${JSON.stringify(entry[0])}; use the module specifier as a string`;\n }\n\n if (!isPlainObject(entry[1])) {\n return `its second item is not a plain object; pass the options as { name: value }`;\n }\n\n return undefined;\n}\n\n/** The URL or specifier to import for a `panels` entry. */\nfunction resolvePanelSpecifier(entry: string, root: string): string {\n if (entry.startsWith(\"./\") || entry.startsWith(\"../\") || path.isAbsolute(entry)) {\n return pathToFileURL(path.resolve(root, entry)).href;\n }\n\n return resolveFromNodeModules(entry, root) ?? resolveWithRequire(entry, root) ?? entry;\n}\n\n/** Picks the file an `exports` target names: `import`, then `default`, then `node`. */\nfunction exportTarget(target: unknown): string | undefined {\n if (typeof target === \"string\") return target;\n\n if (Array.isArray(target)) {\n for (const item of target) {\n const found = exportTarget(item);\n\n if (found !== undefined) return found;\n }\n\n return undefined;\n }\n\n if (target !== null && typeof target === \"object\") {\n const conditions = target as Record<string, unknown>;\n\n for (const condition of [\"import\", \"node\", \"default\"]) {\n const found = exportTarget(conditions[condition]);\n\n if (found !== undefined) return found;\n }\n }\n\n return undefined;\n}\n\n/**\n * Resolves a package specifier by looking it up in the `node_modules` folders\n * above the app root and reading its `exports` map. `createRequire().resolve`\n * cannot do this for a package that only has an `import` condition.\n */\nfunction resolveFromNodeModules(entry: string, root: string): string | undefined {\n const parts = entry.split(\"/\");\n const nameLength = entry.startsWith(\"@\") ? 2 : 1;\n const name = parts.slice(0, nameLength).join(\"/\");\n const subpath = parts.length > nameLength ? `./${parts.slice(nameLength).join(\"/\")}` : \".\";\n\n if (!name) return undefined;\n\n let directory = path.resolve(root);\n\n for (;;) {\n const packageDirectory = path.join(directory, \"node_modules\", name);\n const manifestFile = path.join(packageDirectory, \"package.json\");\n\n if (existsSync(manifestFile)) {\n try {\n const manifest = JSON.parse(readFileSync(manifestFile, \"utf8\")) as {\n exports?: unknown;\n main?: string;\n };\n const exported = manifest.exports;\n const map =\n exported !== null && typeof exported === \"object\" && !Array.isArray(exported)\n ? (exported as Record<string, unknown>)\n : undefined;\n const hasSubpaths =\n map !== undefined && Object.keys(map).some((key) => key.startsWith(\".\"));\n const target =\n exported === undefined\n ? subpath === \".\"\n ? (manifest.main ?? \"index.js\")\n : subpath\n : hasSubpaths\n ? exportTarget(map?.[subpath])\n : subpath === \".\"\n ? exportTarget(exported)\n : undefined;\n\n if (target === undefined) return undefined;\n\n const file = path.resolve(packageDirectory, target);\n\n return isFile(file) ? pathToFileURL(file).href : undefined;\n } catch {\n return undefined;\n }\n }\n\n const parent = path.dirname(directory);\n\n if (parent === directory) return undefined;\n\n directory = parent;\n }\n}\n\n/** The `require` resolution, for packages the `node_modules` lookup does not understand. */\nfunction resolveWithRequire(entry: string, root: string): string | undefined {\n try {\n return pathToFileURL(createRequire(path.join(root, \"package.json\")).resolve(entry)).href;\n } catch {\n return undefined;\n }\n}\n\n/** The panels a module's default export describes. */\nasync function panelsOf(\n exported: DevtoolsPanelExport,\n root: string,\n mode: DevtoolsMode,\n panelOptions: Readonly<Record<string, unknown>> = {},\n): Promise<readonly unknown[]> {\n const value =\n typeof exported === \"function\" ? await exported({ ...panelOptions, root, mode }) : exported;\n\n return Array.isArray(value) ? value : [value];\n}\n\n/**\n * Loads the devtools `panels` option: imports each module entry, reads its\n * default export, and validates every panel. An entry that fails to load and\n * a panel that is invalid or reuses an id are reported through `warn` and\n * skipped, so one broken panel never stops the dashboard.\n */\nexport async function loadDevtoolsPanels(\n entries: readonly DevtoolsPanelEntry[],\n options: LoadDevtoolsPanelsOptions,\n): Promise<MountedDevtoolsPanel[]> {\n // `src/config/devtools.ts` is a plain object with no types: a single string would be read letter by letter.\n if (!Array.isArray(entries as unknown)) {\n options.warn(\n `The devtools \"panels\" option must be a list, such as panels: [\"@warlock.js/grimoire/devtools\"]; got ${JSON.stringify(entries)}. No panel was added.`,\n );\n\n return [];\n }\n\n const importModule = options.importModule ?? ((specifier: string) => import(specifier));\n const mode = options.mode ?? \"development\";\n const taken = new Map<string, string>(options.taken ?? []);\n const panels: MountedDevtoolsPanel[] = [];\n\n for (const entry of entries) {\n let candidates: readonly unknown[];\n\n try {\n if (Array.isArray(entry as unknown)) {\n const problem = tupleProblem(entry as readonly unknown[]);\n\n if (problem !== undefined) {\n options.warn(\n `Devtools panels entry ${JSON.stringify(entry)} is invalid: ${problem}. Example: [\"@warlock.js/grimoire/devtools\", { ttlMs: 60000 }]. The entry was not added.`,\n );\n continue;\n }\n }\n\n if (typeof entry === \"string\" || Array.isArray(entry as unknown)) {\n const [specifier, panelOptions] =\n typeof entry === \"string\"\n ? [entry, undefined]\n : (entry as readonly [string, Record<string, unknown>]);\n const module = (await importModule(resolvePanelSpecifier(specifier, options.root))) as {\n default?: DevtoolsPanelExport;\n };\n\n if (module.default === undefined) {\n throw new Error(\"the module has no default export\");\n }\n\n candidates = await panelsOf(module.default, options.root, mode, panelOptions);\n } else {\n candidates = [entry];\n }\n } catch (error) {\n options.warn(\n `Devtools panel module \"${String(Array.isArray(entry as unknown) ? (entry as readonly unknown[])[0] : entry)}\" could not be loaded: ${describe(error)}. Check that it is installed and listed correctly in the devtools \"panels\" option.`,\n );\n continue;\n }\n\n for (const candidate of candidates) {\n try {\n panels.push(checkDevtoolsPanel(candidate, taken));\n } catch (error) {\n options.warn(`${describe(error)} The panel was not added.`);\n }\n }\n }\n\n return panels;\n}\n\nfunction describe(error: unknown): string {\n return error instanceof Error ? error.message : String(error);\n}\n\n/** What `productionPanels` decides. */\nexport type DevtoolsProductionPanels = {\n /** Built-in tab ids shown, in display order. */\n builtIn: string[];\n /** Package panels shown. */\n panels: MountedDevtoolsPanel[];\n};\n\n/**\n * Which tabs the production monitor shows. A built-in tab follows\n * `DEVTOOLS_BUILT_IN_PANELS` unless `overrides[id]` says otherwise. A package\n * panel (the Processes panel included) shows when it declares\n * `production: true` or `overrides[id]` is `true`; `overrides[id]: false` turns\n * any tab off.\n */\nexport function productionPanels(\n packagePanels: readonly MountedDevtoolsPanel[],\n overrides: Readonly<Record<string, boolean>> = {},\n): DevtoolsProductionPanels {\n const builtIn = DEVTOOLS_BUILT_IN_PANELS.filter((tab) => overrides[tab.id] ?? tab.production).map(\n (tab) => tab.id,\n );\n const panels = packagePanels.filter((panel) => overrides[panel.id] ?? panel.production);\n\n return { builtIn, panels };\n}\n\n/**\n * The tab list `GET api/panels` answers with: the built-in tabs in\n * `builtIn` (default: every one), in display order, then the package panels\n * in registration order.\n */\nexport function listPanelInfos(\n panels: readonly Pick<MountedDevtoolsPanel, \"id\" | \"title\">[],\n builtIn?: readonly string[],\n): DevtoolsPanelInfo[] {\n const tabs: DevtoolsPanelInfo[] = DEVTOOLS_BUILT_IN_PANELS.filter(\n (tab) => builtIn === undefined || builtIn.includes(tab.id),\n ).map((tab) => ({ id: tab.id, title: tab.title, type: \"built-in\" as const }));\n\n for (const panel of panels)\n tabs.push({ id: panel.id, title: panel.title, type: \"package\" as const });\n\n return tabs;\n}\n"],"mappings":";;;;;;;;;;;AAgCA,MAAM,qCAAqB,IAAI,IAAI;CACjC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;AAED,MAAM,WAAW;AACjB,MAAM,aAAa;AACnB,MAAM,0BAAU,IAAI,IAAyB;CAAC;CAAO;CAAQ;CAAO;CAAS;AAAQ,CAAC;;AAGtF,MAAM,gBAAwC;CAC5C,OAAO;CACP,QAAQ;CACR,QAAQ;CACR,SAAS;CACT,QAAQ;CACR,QAAQ;CACR,UAAU;AACZ;;AAGA,SAAgB,iBAAiB,MAAsB;CACrD,OAAO,cAAc,KAAK,QAAQ,IAAI,CAAC,CAAC,Y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,OAAO,KAAK,mBAAmB,WAAW,KAAK,CAAC;EAClD,SAAS,OAAO;GACd,QAAQ,KAAK,GAAG,SAAS,KAAK,EAAE,0BAA0B;EAC5D;CAEJ;CAEA,OAAO;AACT;AAEA,SAAS,SAAS,OAAwB;CACxC,OAAO,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;AAC9D;;;;;;;;AAiBA,SAAgB,iBACd,eACA,YAA+C,CAAC,GACtB;CAM1B,OAAO;EAAE,SALO,yBAAyB,QAAQ,QAAQ,UAAU,IAAI,OAAO,IAAI,UAAU,CAAC,CAAC,KAC3F,QAAQ,IAAI,EAIA;EAAG,QAFH,cAAc,QAAQ,UAAU,UAAU,MAAM,OAAO,MAAM,UAErD;CAAE;AAC3B;;;;;;AAOA,SAAgB,eACd,QACA,SACqB;CACrB,MAAM,OAA4B,yBAAyB,QACxD,QAAQ,YAAY,UAAa,QAAQ,SAAS,IAAI,EAAE,CAC3D,CAAC,CAAC,KAAK,SAAS;EAAE,IAAI,IAAI;EAAI,OAAO,IAAI;EAAO,MAAM;CAAoB,EAAE;CAE5E,KAAK,MAAM,SAAS,QAClB,KAAK,KAAK;EAAE,IAAI,MAAM;EAAI,OAAO,MAAM;EAAO,MAAM;CAAmB,CAAC;CAE1E,OAAO;AACT"}
package/esm/types.d.mts CHANGED
@@ -56,11 +56,13 @@ export type DevtoolsOptions = {
56
56
  * development, whose default export is a `DevtoolsPanelExport`: a package
57
57
  * export such as `"@warlock.js/grimoire/devtools"` (resolved from the app
58
58
  * root) or a path starting with `./` (relative to the app root). An entry
59
- * may also be a `DevtoolsPanel` object.
59
+ * may also be a `DevtoolsPanel` object, or a `[specifier, options]` pair
60
+ * whose options object is passed to the panel factory next to `root` and
61
+ * `mode` (`["@warlock.js/grimoire/devtools", { ttlMs: 60_000 }]`).
60
62
  *
61
63
  * @default []
62
64
  */
63
- panels?: readonly (string | DevtoolsPanel)[];
65
+ panels?: readonly DevtoolsPanelEntry[];
64
66
  /**
65
67
  * The production monitor: a signed-in dashboard at a secret path. Off
66
68
  * unless `enabled` is `true`; read only when the app runs in production
@@ -294,6 +296,8 @@ export type DevtoolsPanel = {
294
296
  */
295
297
  assets?: Readonly<Record<string, string | URL>>;
296
298
  };
299
+ /** One `panels` entry: a module specifier, a ready panel, or `[specifier, options]` to pass options to the module's factory. */
300
+ export type DevtoolsPanelEntry = string | DevtoolsPanel | readonly [specifier: string, options: Readonly<Record<string, unknown>>];
297
301
  /** What a panel factory receives. */
298
302
  export type DevtoolsPanelFactoryContext = {
299
303
  /** The app's root directory. */
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.mts","names":[],"sources":["../../../../../../../packages/devtools/src/types.ts"],"mappings":";;;;;;;;;;;;;;YAiBY;;;;;;EAMV;;;;;;EAMA;;;;;;;EAOA;;;;;;;;;;EAUA;;;;;;;;;EASA;;;;;;;;;;EAUA,4BAA4B;;;;;;;;;;;EAW5B,aAAa;;;;;;;YAQH;;;;;;;EAOV;;;;;;;EAOA;;;;;;;EAOA;;;;;;EAMA;;;;;;;EAOA;;;;;;EAMA;;;;;;EAMA;;;;;;;EAOA;;;;;;;EAOA;;;;;;;;;EASA;;;;;;;EAOA;;;;;;;EAOA;;;;;;;;EAQA;;EAEA;;IAEE;;IAEA;;;;;;;EAOF;;EAEA;;IAEE;;IAEA;;IAEA;;IAEA;;IAEA;;;EAGF;;;;;;;IAOE;;;;;;;;;;EAUF,SAAS,SAAS;;;;;;EAMlB,qBAAqB;;;;;;EAMrB;;EAEA;;IAEE;;IAEA;;;;YAKQ,0BAA0B,SACpC,KAAK,kEAEL,KAAK;;YAGK;;YAGA;;EAEV,QAAQ,SAAS;;EAEjB,OAAO,SAAS;;EAEhB;;;;;;;;YASU;;EAEV,SAAS;;EAET;EACA,UAAU,SAAS;;;;;;;;;YAUT;;EAEV;;EAEA;;EAEA,eAAe;;EAEf,kBAAkB;;;;;;;;;;EAUlB;;;;;;EAMA,SAAS,SAAS,wBAAwB;;;YAIhC;;EAEV;;;;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