@warlock.js/devtools 5.63.1 → 5.64.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -0
- package/cjs/{boot-Guumt-du.cjs → boot-Cy3jyixg.cjs} +3 -3
- package/cjs/{boot-Guumt-du.cjs.map → boot-Cy3jyixg.cjs.map} +1 -1
- package/cjs/{http-CPbhLN61.cjs → http-BnKzYWOT.cjs} +33 -11
- package/cjs/{http-CPbhLN61.cjs.map → http-BnKzYWOT.cjs.map} +1 -1
- package/cjs/index.cjs +1 -1
- package/cjs/{server-Dc0YdP6Y.cjs → server-BhiUHfRi.cjs} +15 -3
- package/cjs/server-BhiUHfRi.cjs.map +1 -0
- package/cjs/{src-Ca1gNdZj.cjs → src-ChI4g-4B.cjs} +3 -3
- package/cjs/{src-Ca1gNdZj.cjs.map → src-ChI4g-4B.cjs.map} +1 -1
- package/esm/production/http/mount.mjs +32 -10
- package/esm/production/http/mount.mjs.map +1 -1
- package/esm/server/index.mjs +14 -2
- package/esm/server/index.mjs.map +1 -1
- package/llms-full.txt +1 -1
- package/package.json +8 -8
- package/skills/SKILL.md +1 -1
- package/ui/dashboard/assets/app.js +1 -1
- package/ui/dashboard/build-info.json +4 -4
- package/cjs/server-Dc0YdP6Y.cjs.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,13 @@ All notable changes to `@warlock.js/devtools` are documented in this file.
|
|
|
4
4
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/). `@warlock.js/*` packages are released in lockstep — every package shares the same version number, so a version below may list only the changes that affected this package.
|
|
6
6
|
|
|
7
|
+
## 5.64.0 - 2026-11-23
|
|
8
|
+
|
|
9
|
+
### Fixed
|
|
10
|
+
|
|
11
|
+
- In development, a dashboard or panel route that fails on the server answers its message with a short `ref`, written to the log with the failure, and a package panel's `ctx.api` rejects with `status` and `ref` (the server's reference, else the `x-request-id` header) so the panel can show the reference to quote.
|
|
12
|
+
- A closed production monitor URL hit with a request body (`POST`, `PUT`, `PATCH`, `DELETE`) is answered after the body is read, like an unknown URL: a malformed or oversized body gets the app's own `400` or `413`, not a `404` that only a dashboard path gave.
|
|
13
|
+
|
|
7
14
|
## 5.62.0 - 2026-11-20
|
|
8
15
|
|
|
9
16
|
### Fixed
|
|
@@ -83,7 +83,7 @@ async function bootProductionDevtools(input) {
|
|
|
83
83
|
Promise.resolve().then(() => require("./auth-ChHh5E7j.cjs")),
|
|
84
84
|
Promise.resolve().then(() => require("./capture-D2k0GnBN.cjs")),
|
|
85
85
|
Promise.resolve().then(() => require("./insights-COA3u37q.cjs")),
|
|
86
|
-
Promise.resolve().then(() => require("./http-
|
|
86
|
+
Promise.resolve().then(() => require("./http-BnKzYWOT.cjs"))
|
|
87
87
|
]);
|
|
88
88
|
const store = await createCascadeStore({ shares: production.share.enabled });
|
|
89
89
|
await store.verify();
|
|
@@ -158,7 +158,7 @@ async function bootProductionDevtools(input) {
|
|
|
158
158
|
stops.push(() => aiWiring.reports.dispose());
|
|
159
159
|
if (typeof core.excludeFromRequestLog === "function") stops.push(core.excludeFromRequestLog(production.path));
|
|
160
160
|
if (builtIn.includes("mail")) {
|
|
161
|
-
const { attachMailSource } = await Promise.resolve().then(() => require("./src-
|
|
161
|
+
const { attachMailSource } = await Promise.resolve().then(() => require("./src-ChI4g-4B.cjs")).then((n) => n.mail_source_exports);
|
|
162
162
|
stops.push(await attachMailSource(capture.collector));
|
|
163
163
|
}
|
|
164
164
|
httpModule.mountProductionDevtools(server, {
|
|
@@ -204,4 +204,4 @@ async function bootProductionDevtools(input) {
|
|
|
204
204
|
|
|
205
205
|
//#endregion
|
|
206
206
|
exports.bootProductionDevtools = bootProductionDevtools;
|
|
207
|
-
//# sourceMappingURL=boot-
|
|
207
|
+
//# sourceMappingURL=boot-Cy3jyixg.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"boot-Guumt-du.cjs","names":["DEVTOOLS_MOUNTED_KEY","loadAiFeed","attachAiReports","resolveDevtoolsAiOptions","toAiUnavailableView","describeAiUnavailable","resolveProductionOptions","DevtoolsProductionConfigError","productionPanels","withoutDevelopmentAiTabs"],"sources":["../../../../../../../packages/devtools/src/production/boot.ts"],"sourcesContent":["import type { FastifyInstance } from \"fastify\";\nimport {\n attachAiReports,\n DEVTOOLS_MOUNTED_KEY,\n type DevtoolsAiReports,\n loadAiFeed,\n} from \"../ai/attach\";\nimport { resolveDevtoolsAiOptions } from \"../ai/options\";\nimport { type MountedDevtoolsPanel, productionPanels, withoutDevelopmentAiTabs } from \"../panels\";\nimport type { MountDevtoolsRoutesDeps } from \"../server/types\";\nimport type { ResolvedDevtoolsOptions } from \"../types\";\nimport { DevtoolsProductionConfigError } from \"./errors\";\nimport type { DevtoolsInsights } from \"./insights/types\";\nimport { resolveProductionOptions } from \"./options\";\nimport { describeAiUnavailable, toAiUnavailableView } from \"../sources/ai-source\";\n\n/** What the connector hands production boot. */\nexport type BootProductionDevtoolsInput = {\n options: ResolvedDevtoolsOptions;\n env: Readonly<Record<string, string | undefined>>;\n server: FastifyInstance;\n /** Package panels loaded with `mode: \"production\"` (not yet filtered). */\n panels: readonly MountedDevtoolsPanel[];\n /** The route deps the connector builds for development, reused (requestLog, listRoutes, ai, …). */\n routes: Omit<MountDevtoolsRoutesDeps, \"collector\" | \"options\" | \"isDevelopment\">;\n /** Reads one config value (`encryption.key`); defaults to core's `config.get`. */\n readConfig?: (key: string) => unknown;\n /** Called once the shared insights exist (panels read captured error counts through them). */\n onInsights?: (insights: DevtoolsInsights) => void;\n log: {\n info(module: string, action: string, message: string): unknown;\n warn(module: string, action: string, message: string): unknown;\n error(module: string, action: string, message: string): unknown;\n };\n};\n\nconst AI_REPORT_TABS: readonly string[] = [\"ai-reports\", \"ai-models\", \"ai-errors\"];\n\n/** Tells other packages (Panoptic) that devtools is mounted here and where. */\nfunction publishMounted(path: string): void {\n (globalThis as Record<symbol, unknown>)[DEVTOOLS_MOUNTED_KEY] = { path, mode: \"production\" };\n}\n\nfunction clearMounted(): void {\n delete (globalThis as Record<symbol, unknown>)[DEVTOOLS_MOUNTED_KEY];\n}\n\n/**\n * Loads the AI feed and starts this process's rollup writer (every process of\n * a deployment adds into the same table). Never throws: a failure leaves the\n * AI report tabs answering their unavailable view.\n */\nasync function attachProductionAi(\n options: ResolvedDevtoolsOptions,\n warn: (message: string) => void,\n): Promise<{ feedAvailable: boolean; reports: DevtoolsAiReports }> {\n const loaded = await loadAiFeed();\n\n if (\"unavailable\" in loaded) {\n return { feedAvailable: false, reports: { ...loaded.unavailable, async dispose() {} } };\n }\n\n try {\n return {\n feedAvailable: true,\n reports: await attachAiReports({\n feed: loaded.feed,\n options: resolveDevtoolsAiOptions(options.ai, \"production\"),\n warn,\n }),\n };\n } catch (error) {\n warn(`AI reports could not start: ${error instanceof Error ? error.message : String(error)}`);\n\n return {\n feedAvailable: true,\n reports: { ...toAiUnavailableView(describeAiUnavailable(\"reports-off\")), async dispose() {} },\n };\n }\n}\n\n/** `/ops-…`: the first part of the path, enough to recognise it and not enough to use it. */\nexport function maskDashboardPath(path: string): string {\n const match = /^\\/[A-Za-z]{1,8}-/.exec(path);\n\n return `${match ? match[0] : \"/\"}…`;\n}\n\n/** The key core encrypts with: 64 hex characters. */\nfunction hasEncryptionKey(value: unknown): boolean {\n return typeof value === \"string\" && /^[0-9a-fA-F]{64}$/.test(value);\n}\n\n/**\n * Starts the production monitor, in this order: resolve options (env) →\n * check `encryption.key` (DT006) → cascade store (DT005) → `store.verify()`\n * (DT008) → `ensureFirstAdmin()` (DT003/DT004) → instance info → capture\n * (attach hooks) → resource monitor, health history, jobs reader → local\n * reporter → report writer → shared insights → `excludeFromRequestLog(path)`\n * → mount. Logs one line with the path masked (`/ops-…`), never the full path.\n * Any `DevtoolsProductionConfigError` propagates: the app does not boot.\n *\n * Returns the disposer the connector calls at shutdown (flush samples, stop\n * timers, detach hooks).\n */\nexport async function bootProductionDevtools(\n input: BootProductionDevtoolsInput,\n): Promise<() => Promise<void>> {\n const { options, env, server, log } = input;\n const production = resolveProductionOptions(options.production, env);\n const core = await import(\"@warlock.js/core\");\n const readConfig = input.readConfig ?? ((key: string) => core.config.get(key));\n\n if (!hasEncryptionKey(readConfig(\"encryption.key\"))) {\n throw new DevtoolsProductionConfigError(\"DT006\");\n }\n\n const [{ createCascadeStore }, authModule, captureModule, insightsModule, httpModule] =\n await Promise.all([\n import(\"./store\"),\n import(\"./auth\"),\n import(\"./capture\"),\n import(\"./insights\"),\n import(\"./http\"),\n ]);\n\n const store = await createCascadeStore({ shares: production.share.enabled });\n\n await store.verify();\n\n const warn = (message: string): void => {\n log.warn(\"devtools\", \"production\", message);\n };\n if (production.twoFactor === \"off\") {\n warn(\n 'Two-factor sign-in is off for the dashboard (production.twoFactor is \"off\"): anyone with a password can sign in. Set it to \"admins\" or \"everyone\" to require an authenticator app or passkey.',\n );\n }\n\n const instance = insightsModule.createInstanceInfo();\n const [crypto, passkeys] = await Promise.all([\n authModule.defaultDevtoolsCrypto(),\n authModule.loadDevtoolsPasskeys(),\n ]);\n const auth = authModule.createDevtoolsAuth({\n store,\n options: production,\n instance,\n crypto,\n passkeys,\n warn,\n });\n\n await auth.ensureFirstAdmin();\n\n const isDashboardPath = (path: string): boolean =>\n path === production.path || path.startsWith(`${production.path}/`);\n const capture = captureModule.createProductionCapture({\n options,\n production,\n instance,\n store,\n isDashboardPath,\n warn,\n });\n const stops: (() => unknown)[] = [];\n\n try {\n stops.push(await capture.attach());\n\n const resources = insightsModule.createResourceMonitor();\n const health = insightsModule.createHealthHistory();\n\n resources.start();\n health.start();\n stops.push(\n () => resources.stop(),\n () => health.stop(),\n );\n\n const reporter = insightsModule.createLocalReporter({\n instance,\n resources,\n health,\n jobs: insightsModule.createJobsReader(),\n queries: capture.queries,\n routes: capture.routes,\n errors: capture.errors,\n logs: capture.logs,\n counters: () => capture.counters(),\n });\n const writer = insightsModule.startReportWriter({ reporter, store, production, warn });\n\n stops.push(() => writer.stop());\n\n const insights = insightsModule.createSharedInsights({\n store,\n reporter,\n sampleRate: production.sampleRate,\n });\n input.onInsights?.(insights);\n\n const state = httpModule.createDashboardState(store, production.path);\n const { builtIn: requestedTabs, panels } = productionPanels(input.panels, production.panels);\n\n // Runs and Agents read per-process run details, which production does not keep (it keeps hourly totals).\n const { builtIn: shownTabs, ignored: ignoredAiTabs } = withoutDevelopmentAiTabs(\n requestedTabs,\n production.panels,\n );\n\n if (ignoredAiTabs.length > 0) {\n warn(\n \"The Runs and Agents tabs are development tabs, so production.panels.ai and production.panels.agents are ignored. Production shows AI totals in Reports, Models and Errors.\",\n );\n }\n\n // The AI report tabs are listed only when the app has the AI feed (Panoptic), unless the project turned one on.\n // With every report tab turned off, no totals are written (and no missing-table warning is logged).\n const aiWiring = shownTabs.some((tab) => AI_REPORT_TABS.includes(tab))\n ? await attachProductionAi(options, warn)\n : {\n feedAvailable: false,\n reports: {\n ...toAiUnavailableView(describeAiUnavailable(\"reports-off\")),\n async dispose() {},\n },\n };\n const builtIn = aiWiring.feedAvailable\n ? shownTabs\n : shownTabs.filter((tab) => !AI_REPORT_TABS.includes(tab) || production.panels[tab] === true);\n\n stops.push(() => aiWiring.reports.dispose());\n\n // The dashboard's own requests are not worth a line in the request log, and its sign-in bodies must not reach it.\n if (typeof core.excludeFromRequestLog === \"function\") {\n stops.push(core.excludeFromRequestLog(production.path));\n }\n\n // Mail previews exist only when the project turned that tab on.\n if (builtIn.includes(\"mail\")) {\n const { attachMailSource } = await import(\"../sources/mail-source\");\n\n stops.push(await attachMailSource(capture.collector));\n }\n\n httpModule.mountProductionDevtools(server, {\n routes: {\n ...input.routes,\n aiReports: aiWiring.reports,\n collector: capture.collector,\n options,\n isDevelopment: () => false,\n },\n production,\n store,\n auth,\n capture,\n insights,\n instance,\n panels,\n builtInPanels: builtIn,\n state,\n warn,\n ...(typeof core.answerUnknownUrl === \"function\"\n ? { answerUnknownUrl: core.answerUnknownUrl }\n : {}),\n hmac: (value) => crypto.hmac(value),\n });\n\n publishMounted(production.path);\n stops.push(clearMounted);\n\n log.info(\n \"devtools\",\n \"ready\",\n `devtools production monitor mounted at ${maskDashboardPath(production.path)} (DEVTOOLS_PATH)`,\n );\n } catch (error) {\n for (const stop of stops.splice(0).reverse()) {\n try {\n void Promise.resolve(stop()).catch(() => undefined);\n } catch {\n // Cleanup after a failed boot must not hide the real error.\n }\n }\n\n void capture.dispose().catch(() => undefined);\n\n throw error;\n }\n\n // Returns the promise of the stops so the connector can wait for the final AI totals flush.\n return () => {\n const finished: Promise<unknown>[] = [];\n\n for (const stop of stops.splice(0).reverse()) {\n try {\n finished.push(Promise.resolve(stop()).catch(() => undefined));\n } catch {\n // Shutdown continues past a failing step.\n }\n }\n\n finished.push(capture.dispose().catch(() => undefined));\n\n return Promise.all(finished).then(() => undefined);\n };\n}\n"],"mappings":";;;;;AAoCA,MAAM,iBAAoC;CAAC;CAAc;CAAa;AAAW;;AAGjF,SAAS,eAAe,MAAoB;CAC1C,AAAC,WAAuCA,uCAAwB;EAAE;EAAM,MAAM;CAAa;AAC7F;AAEA,SAAS,eAAqB;CAC5B,OAAQ,WAAuCA;AACjD;;;;;;AAOA,eAAe,mBACb,SACA,MACiE;CACjE,MAAM,SAAS,MAAMC,0BAAW;CAEhC,IAAI,iBAAiB,QACnB,OAAO;EAAE,eAAe;EAAO,SAAS;GAAE,GAAG,OAAO;GAAa,MAAM,UAAU,CAAC;EAAE;CAAE;CAGxF,IAAI;EACF,OAAO;GACL,eAAe;GACf,SAAS,MAAMC,+BAAgB;IAC7B,MAAM,OAAO;IACb,SAASC,wCAAyB,QAAQ,IAAI,YAAY;IAC1D;GACF,CAAC;EACH;CACF,SAAS,OAAO;EACd,KAAK,+BAA+B,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,GAAG;EAE5F,OAAO;GACL,eAAe;GACf,SAAS;IAAE,GAAGC,sCAAoBC,wCAAsB,aAAa,CAAC;IAAG,MAAM,U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1
|
+
{"version":3,"file":"boot-Cy3jyixg.cjs","names":["DEVTOOLS_MOUNTED_KEY","loadAiFeed","attachAiReports","resolveDevtoolsAiOptions","toAiUnavailableView","describeAiUnavailable","resolveProductionOptions","DevtoolsProductionConfigError","productionPanels","withoutDevelopmentAiTabs"],"sources":["../../../../../../../packages/devtools/src/production/boot.ts"],"sourcesContent":["import type { FastifyInstance } from \"fastify\";\nimport {\n attachAiReports,\n DEVTOOLS_MOUNTED_KEY,\n type DevtoolsAiReports,\n loadAiFeed,\n} from \"../ai/attach\";\nimport { resolveDevtoolsAiOptions } from \"../ai/options\";\nimport { type MountedDevtoolsPanel, productionPanels, withoutDevelopmentAiTabs } from \"../panels\";\nimport type { MountDevtoolsRoutesDeps } from \"../server/types\";\nimport type { ResolvedDevtoolsOptions } from \"../types\";\nimport { DevtoolsProductionConfigError } from \"./errors\";\nimport type { DevtoolsInsights } from \"./insights/types\";\nimport { resolveProductionOptions } from \"./options\";\nimport { describeAiUnavailable, toAiUnavailableView } from \"../sources/ai-source\";\n\n/** What the connector hands production boot. */\nexport type BootProductionDevtoolsInput = {\n options: ResolvedDevtoolsOptions;\n env: Readonly<Record<string, string | undefined>>;\n server: FastifyInstance;\n /** Package panels loaded with `mode: \"production\"` (not yet filtered). */\n panels: readonly MountedDevtoolsPanel[];\n /** The route deps the connector builds for development, reused (requestLog, listRoutes, ai, …). */\n routes: Omit<MountDevtoolsRoutesDeps, \"collector\" | \"options\" | \"isDevelopment\">;\n /** Reads one config value (`encryption.key`); defaults to core's `config.get`. */\n readConfig?: (key: string) => unknown;\n /** Called once the shared insights exist (panels read captured error counts through them). */\n onInsights?: (insights: DevtoolsInsights) => void;\n log: {\n info(module: string, action: string, message: string): unknown;\n warn(module: string, action: string, message: string): unknown;\n error(module: string, action: string, message: string): unknown;\n };\n};\n\nconst AI_REPORT_TABS: readonly string[] = [\"ai-reports\", \"ai-models\", \"ai-errors\"];\n\n/** Tells other packages (Panoptic) that devtools is mounted here and where. */\nfunction publishMounted(path: string): void {\n (globalThis as Record<symbol, unknown>)[DEVTOOLS_MOUNTED_KEY] = { path, mode: \"production\" };\n}\n\nfunction clearMounted(): void {\n delete (globalThis as Record<symbol, unknown>)[DEVTOOLS_MOUNTED_KEY];\n}\n\n/**\n * Loads the AI feed and starts this process's rollup writer (every process of\n * a deployment adds into the same table). Never throws: a failure leaves the\n * AI report tabs answering their unavailable view.\n */\nasync function attachProductionAi(\n options: ResolvedDevtoolsOptions,\n warn: (message: string) => void,\n): Promise<{ feedAvailable: boolean; reports: DevtoolsAiReports }> {\n const loaded = await loadAiFeed();\n\n if (\"unavailable\" in loaded) {\n return { feedAvailable: false, reports: { ...loaded.unavailable, async dispose() {} } };\n }\n\n try {\n return {\n feedAvailable: true,\n reports: await attachAiReports({\n feed: loaded.feed,\n options: resolveDevtoolsAiOptions(options.ai, \"production\"),\n warn,\n }),\n };\n } catch (error) {\n warn(`AI reports could not start: ${error instanceof Error ? error.message : String(error)}`);\n\n return {\n feedAvailable: true,\n reports: { ...toAiUnavailableView(describeAiUnavailable(\"reports-off\")), async dispose() {} },\n };\n }\n}\n\n/** `/ops-…`: the first part of the path, enough to recognise it and not enough to use it. */\nexport function maskDashboardPath(path: string): string {\n const match = /^\\/[A-Za-z]{1,8}-/.exec(path);\n\n return `${match ? match[0] : \"/\"}…`;\n}\n\n/** The key core encrypts with: 64 hex characters. */\nfunction hasEncryptionKey(value: unknown): boolean {\n return typeof value === \"string\" && /^[0-9a-fA-F]{64}$/.test(value);\n}\n\n/**\n * Starts the production monitor, in this order: resolve options (env) →\n * check `encryption.key` (DT006) → cascade store (DT005) → `store.verify()`\n * (DT008) → `ensureFirstAdmin()` (DT003/DT004) → instance info → capture\n * (attach hooks) → resource monitor, health history, jobs reader → local\n * reporter → report writer → shared insights → `excludeFromRequestLog(path)`\n * → mount. Logs one line with the path masked (`/ops-…`), never the full path.\n * Any `DevtoolsProductionConfigError` propagates: the app does not boot.\n *\n * Returns the disposer the connector calls at shutdown (flush samples, stop\n * timers, detach hooks).\n */\nexport async function bootProductionDevtools(\n input: BootProductionDevtoolsInput,\n): Promise<() => Promise<void>> {\n const { options, env, server, log } = input;\n const production = resolveProductionOptions(options.production, env);\n const core = await import(\"@warlock.js/core\");\n const readConfig = input.readConfig ?? ((key: string) => core.config.get(key));\n\n if (!hasEncryptionKey(readConfig(\"encryption.key\"))) {\n throw new DevtoolsProductionConfigError(\"DT006\");\n }\n\n const [{ createCascadeStore }, authModule, captureModule, insightsModule, httpModule] =\n await Promise.all([\n import(\"./store\"),\n import(\"./auth\"),\n import(\"./capture\"),\n import(\"./insights\"),\n import(\"./http\"),\n ]);\n\n const store = await createCascadeStore({ shares: production.share.enabled });\n\n await store.verify();\n\n const warn = (message: string): void => {\n log.warn(\"devtools\", \"production\", message);\n };\n if (production.twoFactor === \"off\") {\n warn(\n 'Two-factor sign-in is off for the dashboard (production.twoFactor is \"off\"): anyone with a password can sign in. Set it to \"admins\" or \"everyone\" to require an authenticator app or passkey.',\n );\n }\n\n const instance = insightsModule.createInstanceInfo();\n const [crypto, passkeys] = await Promise.all([\n authModule.defaultDevtoolsCrypto(),\n authModule.loadDevtoolsPasskeys(),\n ]);\n const auth = authModule.createDevtoolsAuth({\n store,\n options: production,\n instance,\n crypto,\n passkeys,\n warn,\n });\n\n await auth.ensureFirstAdmin();\n\n const isDashboardPath = (path: string): boolean =>\n path === production.path || path.startsWith(`${production.path}/`);\n const capture = captureModule.createProductionCapture({\n options,\n production,\n instance,\n store,\n isDashboardPath,\n warn,\n });\n const stops: (() => unknown)[] = [];\n\n try {\n stops.push(await capture.attach());\n\n const resources = insightsModule.createResourceMonitor();\n const health = insightsModule.createHealthHistory();\n\n resources.start();\n health.start();\n stops.push(\n () => resources.stop(),\n () => health.stop(),\n );\n\n const reporter = insightsModule.createLocalReporter({\n instance,\n resources,\n health,\n jobs: insightsModule.createJobsReader(),\n queries: capture.queries,\n routes: capture.routes,\n errors: capture.errors,\n logs: capture.logs,\n counters: () => capture.counters(),\n });\n const writer = insightsModule.startReportWriter({ reporter, store, production, warn });\n\n stops.push(() => writer.stop());\n\n const insights = insightsModule.createSharedInsights({\n store,\n reporter,\n sampleRate: production.sampleRate,\n });\n input.onInsights?.(insights);\n\n const state = httpModule.createDashboardState(store, production.path);\n const { builtIn: requestedTabs, panels } = productionPanels(input.panels, production.panels);\n\n // Runs and Agents read per-process run details, which production does not keep (it keeps hourly totals).\n const { builtIn: shownTabs, ignored: ignoredAiTabs } = withoutDevelopmentAiTabs(\n requestedTabs,\n production.panels,\n );\n\n if (ignoredAiTabs.length > 0) {\n warn(\n \"The Runs and Agents tabs are development tabs, so production.panels.ai and production.panels.agents are ignored. Production shows AI totals in Reports, Models and Errors.\",\n );\n }\n\n // The AI report tabs are listed only when the app has the AI feed (Panoptic), unless the project turned one on.\n // With every report tab turned off, no totals are written (and no missing-table warning is logged).\n const aiWiring = shownTabs.some((tab) => AI_REPORT_TABS.includes(tab))\n ? await attachProductionAi(options, warn)\n : {\n feedAvailable: false,\n reports: {\n ...toAiUnavailableView(describeAiUnavailable(\"reports-off\")),\n async dispose() {},\n },\n };\n const builtIn = aiWiring.feedAvailable\n ? shownTabs\n : shownTabs.filter((tab) => !AI_REPORT_TABS.includes(tab) || production.panels[tab] === true);\n\n stops.push(() => aiWiring.reports.dispose());\n\n // The dashboard's own requests are not worth a line in the request log, and its sign-in bodies must not reach it.\n if (typeof core.excludeFromRequestLog === \"function\") {\n stops.push(core.excludeFromRequestLog(production.path));\n }\n\n // Mail previews exist only when the project turned that tab on.\n if (builtIn.includes(\"mail\")) {\n const { attachMailSource } = await import(\"../sources/mail-source\");\n\n stops.push(await attachMailSource(capture.collector));\n }\n\n httpModule.mountProductionDevtools(server, {\n routes: {\n ...input.routes,\n aiReports: aiWiring.reports,\n collector: capture.collector,\n options,\n isDevelopment: () => false,\n },\n production,\n store,\n auth,\n capture,\n insights,\n instance,\n panels,\n builtInPanels: builtIn,\n state,\n warn,\n ...(typeof core.answerUnknownUrl === \"function\"\n ? { answerUnknownUrl: core.answerUnknownUrl }\n : {}),\n hmac: (value) => crypto.hmac(value),\n });\n\n publishMounted(production.path);\n stops.push(clearMounted);\n\n log.info(\n \"devtools\",\n \"ready\",\n `devtools production monitor mounted at ${maskDashboardPath(production.path)} (DEVTOOLS_PATH)`,\n );\n } catch (error) {\n for (const stop of stops.splice(0).reverse()) {\n try {\n void Promise.resolve(stop()).catch(() => undefined);\n } catch {\n // Cleanup after a failed boot must not hide the real error.\n }\n }\n\n void capture.dispose().catch(() => undefined);\n\n throw error;\n }\n\n // Returns the promise of the stops so the connector can wait for the final AI totals flush.\n return () => {\n const finished: Promise<unknown>[] = [];\n\n for (const stop of stops.splice(0).reverse()) {\n try {\n finished.push(Promise.resolve(stop()).catch(() => undefined));\n } catch {\n // Shutdown continues past a failing step.\n }\n }\n\n finished.push(capture.dispose().catch(() => undefined));\n\n return Promise.all(finished).then(() => undefined);\n };\n}\n"],"mappings":";;;;;AAoCA,MAAM,iBAAoC;CAAC;CAAc;CAAa;AAAW;;AAGjF,SAAS,eAAe,MAAoB;CAC1C,AAAC,WAAuCA,uCAAwB;EAAE;EAAM,MAAM;CAAa;AAC7F;AAEA,SAAS,eAAqB;CAC5B,OAAQ,WAAuCA;AACjD;;;;;;AAOA,eAAe,mBACb,SACA,MACiE;CACjE,MAAM,SAAS,MAAMC,0BAAW;CAEhC,IAAI,iBAAiB,QACnB,OAAO;EAAE,eAAe;EAAO,SAAS;GAAE,GAAG,OAAO;GAAa,MAAM,UAAU,CAAC;EAAE;CAAE;CAGxF,IAAI;EACF,OAAO;GACL,eAAe;GACf,SAAS,MAAMC,+BAAgB;IAC7B,MAAM,OAAO;IACb,SAASC,wCAAyB,QAAQ,IAAI,YAAY;IAC1D;GACF,CAAC;EACH;CACF,SAAS,OAAO;EACd,KAAK,+BAA+B,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,GAAG;EAE5F,OAAO;GACL,eAAe;GACf,SAAS;IAAE,GAAGC,sCA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AC,CAAC,WAAW,MAAS;CACnD;AACF"}
|
|
@@ -1060,6 +1060,14 @@ function tokenHash(token) {
|
|
|
1060
1060
|
/** Requests that were answered with the uniform 404: they get none of the dashboard's headers. */
|
|
1061
1061
|
const uniformNotFound = /* @__PURE__ */ new WeakSet();
|
|
1062
1062
|
/**
|
|
1063
|
+
* Requests refused before their body was read. Fastify reads the body of such a
|
|
1064
|
+
* request next, as it does for an unknown URL, and `preValidation` then answers
|
|
1065
|
+
* the refusal: a malformed, oversized or unsupported body gets the app's own
|
|
1066
|
+
* 400, 413 or 415 (the plugin's error handler hands those on), never a 404 that
|
|
1067
|
+
* only a dashboard path would give.
|
|
1068
|
+
*/
|
|
1069
|
+
const refusedBeforeBody = /* @__PURE__ */ new WeakSet();
|
|
1070
|
+
/**
|
|
1063
1071
|
* The origin the browser must send for an unsafe request: `production.origin`,
|
|
1064
1072
|
* else the scheme and host the request was addressed to.
|
|
1065
1073
|
*/
|
|
@@ -1114,6 +1122,16 @@ function mountProductionDevtools(server, deps) {
|
|
|
1114
1122
|
}
|
|
1115
1123
|
return reply;
|
|
1116
1124
|
};
|
|
1125
|
+
/**
|
|
1126
|
+
* Refuses a request in the gate with the uniform answer. A request that may
|
|
1127
|
+
* carry a body is answered after Fastify has read it, so it gets the same
|
|
1128
|
+
* parsing errors, in the same order and at the same cost, as an unknown URL.
|
|
1129
|
+
*/
|
|
1130
|
+
const refuse = async (request, reply) => {
|
|
1131
|
+
if (request.method === "GET" || request.method === "HEAD") return notFound(request, reply);
|
|
1132
|
+
uniformNotFound.add(request);
|
|
1133
|
+
refusedBeforeBody.add(request);
|
|
1134
|
+
};
|
|
1117
1135
|
const streamSession = async (request) => {
|
|
1118
1136
|
const authenticated = devtoolsRequestContext(request)?.authenticated;
|
|
1119
1137
|
if (!authenticated) throw new Error("A dashboard stream was opened without a session.");
|
|
@@ -1166,10 +1184,10 @@ function mountProductionDevtools(server, deps) {
|
|
|
1166
1184
|
warn(`The devtools dashboard state could not be read and the dashboard is closed: ${error instanceof Error ? error.message : String(error)}`);
|
|
1167
1185
|
open = false;
|
|
1168
1186
|
}
|
|
1169
|
-
if (!open) return
|
|
1187
|
+
if (!open) return refuse(request, reply);
|
|
1170
1188
|
const client = resolveClient(request, production.trustedProxies);
|
|
1171
|
-
if (production.requireHttps && client.proto !== "https") return
|
|
1172
|
-
if (production.allowedIps.length > 0 && !require_ip.ipMatches(client.ip, production.allowedIps)) return
|
|
1189
|
+
if (production.requireHttps && client.proto !== "https") return refuse(request, reply);
|
|
1190
|
+
if (production.allowedIps.length > 0 && !require_ip.ipMatches(client.ip, production.allowedIps)) return refuse(request, reply);
|
|
1173
1191
|
const userAgent = request.headers["user-agent"];
|
|
1174
1192
|
const expectedOrigin = production.origin ?? `${client.proto}://${client.host}`;
|
|
1175
1193
|
const meta = {
|
|
@@ -1191,18 +1209,18 @@ function mountProductionDevtools(server, deps) {
|
|
|
1191
1209
|
pattern,
|
|
1192
1210
|
authenticated: null
|
|
1193
1211
|
});
|
|
1194
|
-
if (method !== "GET" && method !== "HEAD") return
|
|
1212
|
+
if (method !== "GET" && method !== "HEAD") return refuse(request, reply);
|
|
1195
1213
|
const search = sent.includes("?") ? `?${sent.split("?").slice(1).join("?")}` : "";
|
|
1196
1214
|
return reply.redirect(`${prefix}/${search}`, 308);
|
|
1197
1215
|
}
|
|
1198
1216
|
const tab = tabOf(pattern);
|
|
1199
|
-
if (tab !== void 0 && !enabledTabs.has(tab)) return
|
|
1217
|
+
if (tab !== void 0 && !enabledTabs.has(tab)) return refuse(request, reply);
|
|
1200
1218
|
const rule = lookup(method, pattern);
|
|
1201
1219
|
const access = rule?.access ?? { type: "admin" };
|
|
1202
1220
|
let authenticated = null;
|
|
1203
1221
|
if (access.type === "share") {
|
|
1204
1222
|
const grant = share ? await share.authorize(request, meta) : null;
|
|
1205
|
-
if (grant === null) return
|
|
1223
|
+
if (grant === null) return refuse(request, reply);
|
|
1206
1224
|
setDevtoolsRequestContext(request, {
|
|
1207
1225
|
client,
|
|
1208
1226
|
meta,
|
|
@@ -1218,9 +1236,9 @@ function mountProductionDevtools(server, deps) {
|
|
|
1218
1236
|
authenticated = await auth.authenticate(readCookie(request.headers.cookie, cookieName));
|
|
1219
1237
|
} catch (error) {
|
|
1220
1238
|
warn(`The devtools session could not be checked and the request was refused: ${error instanceof Error ? error.message : String(error)}`);
|
|
1221
|
-
return
|
|
1239
|
+
return refuse(request, reply);
|
|
1222
1240
|
}
|
|
1223
|
-
if (authenticated === null || !sessionAccessOk(access, authenticated.stage)) return
|
|
1241
|
+
if (authenticated === null || !sessionAccessOk(access, authenticated.stage)) return refuse(request, reply);
|
|
1224
1242
|
if (access.type === "admin" && authenticated.account.role !== "admin") {
|
|
1225
1243
|
setDevtoolsRequestContext(request, {
|
|
1226
1244
|
client,
|
|
@@ -1241,11 +1259,11 @@ function mountProductionDevtools(server, deps) {
|
|
|
1241
1259
|
});
|
|
1242
1260
|
if (SAFE_METHODS.has(method)) return;
|
|
1243
1261
|
if (!originAllowed(request, expectedOrigin)) {
|
|
1244
|
-
if (authenticated === null) return
|
|
1262
|
+
if (authenticated === null) return refuse(request, reply);
|
|
1245
1263
|
throw new require_errors.DevtoolsApiError("csrf.invalid");
|
|
1246
1264
|
}
|
|
1247
1265
|
if (hasBody(request) && !isJson(request)) {
|
|
1248
|
-
if (pattern === SHARE_OPEN_PATTERN) return
|
|
1266
|
+
if (pattern === SHARE_OPEN_PATTERN) return refuse(request, reply);
|
|
1249
1267
|
throw new require_errors.DevtoolsApiError("input.invalid");
|
|
1250
1268
|
}
|
|
1251
1269
|
if (authenticated !== null) {
|
|
@@ -1253,6 +1271,10 @@ function mountProductionDevtools(server, deps) {
|
|
|
1253
1271
|
if (!auth.verifyCsrf(authenticated, Array.isArray(header) ? header[0] : header)) throw new require_errors.DevtoolsApiError("csrf.invalid");
|
|
1254
1272
|
}
|
|
1255
1273
|
});
|
|
1274
|
+
instance.addHook("preValidation", async (request, reply) => {
|
|
1275
|
+
if (!refusedBeforeBody.has(request)) return;
|
|
1276
|
+
return notFound(request, reply);
|
|
1277
|
+
});
|
|
1256
1278
|
instance.addHook("onSend", async (request, reply, payload) => {
|
|
1257
1279
|
if (uniformNotFound.has(request)) return payload;
|
|
1258
1280
|
for (const name of Object.keys(reply.getHeaders())) if (name.startsWith("access-control-")) reply.removeHeader(name);
|
|
@@ -1379,4 +1401,4 @@ exports.mountProductionDevtools = mountProductionDevtools;
|
|
|
1379
1401
|
exports.productionRouteAccess = productionRouteAccess;
|
|
1380
1402
|
exports.resolveClient = resolveClient;
|
|
1381
1403
|
exports.sessionCookie = sessionCookie;
|
|
1382
|
-
//# sourceMappingURL=http-
|
|
1404
|
+
//# sourceMappingURL=http-BnKzYWOT.cjs.map
|