@warlock.js/devtools 5.58.0 → 5.60.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (162) hide show
  1. package/CHANGELOG.md +32 -0
  2. package/cjs/app-versions-C_ZyzuvD.cjs +138 -0
  3. package/cjs/app-versions-C_ZyzuvD.cjs.map +1 -0
  4. package/cjs/attach-D5aMqUnA.cjs +1342 -0
  5. package/cjs/attach-D5aMqUnA.cjs.map +1 -0
  6. package/cjs/{auth-DV2GA1A9.cjs → auth-ChHh5E7j.cjs} +20 -13
  7. package/cjs/auth-ChHh5E7j.cjs.map +1 -0
  8. package/cjs/{boot-CyeHPFtk.cjs → boot-Dg5YZGGR.cjs} +78 -14
  9. package/cjs/boot-Dg5YZGGR.cjs.map +1 -0
  10. package/cjs/{capture-DcyBhdqw.cjs → capture-CBgONYhk.cjs} +4 -4
  11. package/cjs/{capture-DcyBhdqw.cjs.map → capture-CBgONYhk.cjs.map} +1 -1
  12. package/cjs/{cascade-store-DEGxAFDI.cjs → cascade-store-DUT2Laha.cjs} +3 -3
  13. package/cjs/cascade-store-DUT2Laha.cjs.map +1 -0
  14. package/cjs/{current-request-id-BoJJb3y7.cjs → current-request-id-Badec-TH.cjs} +3 -3
  15. package/cjs/{current-request-id-BoJJb3y7.cjs.map → current-request-id-Badec-TH.cjs.map} +1 -1
  16. package/cjs/{errors-DEqdWaqm.cjs → errors-DNQ-g49I.cjs} +201 -4
  17. package/cjs/errors-DNQ-g49I.cjs.map +1 -0
  18. package/cjs/extract-8kaX_cUV.cjs +1103 -0
  19. package/cjs/extract-8kaX_cUV.cjs.map +1 -0
  20. package/cjs/{helpers-7k_Q-abk.cjs → helpers-BcMBFy9v.cjs} +9 -6
  21. package/cjs/{helpers-7k_Q-abk.cjs.map → helpers-BcMBFy9v.cjs.map} +1 -1
  22. package/cjs/{histogram-BRV5eHcp.cjs → histogram-CkoVizdf.cjs} +6 -6
  23. package/cjs/{histogram-BRV5eHcp.cjs.map → histogram-CkoVizdf.cjs.map} +1 -1
  24. package/cjs/{http-XNLYU2vS.cjs → http-DCVCf44M.cjs} +26 -9
  25. package/cjs/http-DCVCf44M.cjs.map +1 -0
  26. package/cjs/index.cjs +1 -1
  27. package/cjs/{insights-BBZnUpWO.cjs → insights-CFof59kF.cjs} +6 -6
  28. package/cjs/{insights-BBZnUpWO.cjs.map → insights-CFof59kF.cjs.map} +1 -1
  29. package/cjs/migrations-BQdNOL5_.cjs +30 -0
  30. package/cjs/migrations-BQdNOL5_.cjs.map +1 -0
  31. package/cjs/{migrations-DTTzCNpR.cjs → models-DF1agAm4.cjs} +107 -25
  32. package/cjs/models-DF1agAm4.cjs.map +1 -0
  33. package/cjs/{process-panel-DEOnLxoT.cjs → process-panel-D3D9Y_dc.cjs} +5 -5
  34. package/cjs/{process-panel-DEOnLxoT.cjs.map → process-panel-D3D9Y_dc.cjs.map} +1 -1
  35. package/cjs/production/index.cjs +4 -4
  36. package/cjs/runs-DECWPGnq.cjs +390 -0
  37. package/cjs/runs-DECWPGnq.cjs.map +1 -0
  38. package/cjs/{server-C8JfggQU.cjs → server-CC5DpObz.cjs} +10 -7
  39. package/cjs/server-CC5DpObz.cjs.map +1 -0
  40. package/cjs/{src-DjOUdhKc.cjs → src-VyOjEEAo.cjs} +179 -24
  41. package/cjs/src-VyOjEEAo.cjs.map +1 -0
  42. package/cjs/{store-C06KO_A1.cjs → store-EFn4wp0T.cjs} +2 -2
  43. package/cjs/{stream-route-D4k-sJvW.cjs → stream-route-DFHuIWgg.cjs} +125 -19
  44. package/cjs/stream-route-DFHuIWgg.cjs.map +1 -0
  45. package/esm/ai/attach.mjs +92 -0
  46. package/esm/ai/attach.mjs.map +1 -0
  47. package/esm/ai/options.mjs +31 -0
  48. package/esm/ai/options.mjs.map +1 -0
  49. package/esm/ai/reports/aggregate.mjs +330 -0
  50. package/esm/ai/reports/aggregate.mjs.map +1 -0
  51. package/esm/ai/reports/evaluate.mjs +108 -0
  52. package/esm/ai/reports/evaluate.mjs.map +1 -0
  53. package/esm/ai/reports/range.mjs +121 -0
  54. package/esm/ai/reports/range.mjs.map +1 -0
  55. package/esm/ai/reports/runs.d.mts +2 -0
  56. package/esm/ai/reports/runs.mjs +212 -0
  57. package/esm/ai/reports/runs.mjs.map +1 -0
  58. package/esm/ai/reports/service.mjs +132 -0
  59. package/esm/ai/reports/service.mjs.map +1 -0
  60. package/esm/ai/rollup/cascade-store.mjs +84 -0
  61. package/esm/ai/rollup/cascade-store.mjs.map +1 -0
  62. package/esm/ai/rollup/categories.mjs +67 -0
  63. package/esm/ai/rollup/categories.mjs.map +1 -0
  64. package/esm/ai/rollup/extract.mjs +225 -0
  65. package/esm/ai/rollup/extract.mjs.map +1 -0
  66. package/esm/ai/rollup/file-store.mjs +147 -0
  67. package/esm/ai/rollup/file-store.mjs.map +1 -0
  68. package/esm/ai/rollup/histogram.mjs +42 -0
  69. package/esm/ai/rollup/histogram.mjs.map +1 -0
  70. package/esm/ai/rollup/increment-error.mjs +19 -0
  71. package/esm/ai/rollup/increment-error.mjs.map +1 -0
  72. package/esm/ai/rollup/index.mjs +9 -0
  73. package/esm/ai/rollup/mapping.mjs +69 -0
  74. package/esm/ai/rollup/mapping.mjs.map +1 -0
  75. package/esm/ai/rollup/memory-store.mjs +26 -0
  76. package/esm/ai/rollup/memory-store.mjs.map +1 -0
  77. package/esm/ai/rollup/writer.mjs +113 -0
  78. package/esm/ai/rollup/writer.mjs.map +1 -0
  79. package/esm/ai/types.d.mts +29 -0
  80. package/esm/ai/types.d.mts.map +1 -0
  81. package/esm/app-versions.mjs +74 -0
  82. package/esm/app-versions.mjs.map +1 -0
  83. package/esm/devtools-connector.d.mts.map +1 -1
  84. package/esm/devtools-connector.mjs +54 -2
  85. package/esm/devtools-connector.mjs.map +1 -1
  86. package/esm/index.d.mts +3 -2
  87. package/esm/options.mjs +4 -0
  88. package/esm/options.mjs.map +1 -1
  89. package/esm/production/auth/helpers.mjs +8 -5
  90. package/esm/production/auth/helpers.mjs.map +1 -1
  91. package/esm/production/auth/service.mjs +14 -6
  92. package/esm/production/auth/service.mjs.map +1 -1
  93. package/esm/production/boot.mjs +70 -3
  94. package/esm/production/boot.mjs.map +1 -1
  95. package/esm/production/contracts.d.mts +378 -2
  96. package/esm/production/contracts.d.mts.map +1 -1
  97. package/esm/production/contracts.mjs +64 -2
  98. package/esm/production/contracts.mjs.map +1 -1
  99. package/esm/production/errors.d.mts +1 -1
  100. package/esm/production/errors.mjs +11 -3
  101. package/esm/production/errors.mjs.map +1 -1
  102. package/esm/production/http/access.mjs +6 -0
  103. package/esm/production/http/access.mjs.map +1 -1
  104. package/esm/production/http/mount.mjs +13 -0
  105. package/esm/production/http/mount.mjs.map +1 -1
  106. package/esm/production/http/share-session.mjs.map +1 -1
  107. package/esm/production/index.d.mts +2 -2
  108. package/esm/production/insights/writer.mjs.map +1 -1
  109. package/esm/production/options.d.mts +5 -1
  110. package/esm/production/options.d.mts.map +1 -1
  111. package/esm/production/options.mjs +13 -1
  112. package/esm/production/options.mjs.map +1 -1
  113. package/esm/production/store/memory-store.mjs.map +1 -1
  114. package/esm/production/store/migrations.d.mts +1 -1
  115. package/esm/production/store/migrations.d.mts.map +1 -1
  116. package/esm/production/store/migrations.mjs +4 -2
  117. package/esm/production/store/migrations.mjs.map +1 -1
  118. package/esm/production/store/models/ai-rollup.migration.mjs +48 -0
  119. package/esm/production/store/models/ai-rollup.migration.mjs.map +1 -0
  120. package/esm/production/store/models/ai-rollup.model.mjs +13 -0
  121. package/esm/production/store/models/ai-rollup.model.mjs.map +1 -0
  122. package/esm/production/store/models/index.mjs +3 -1
  123. package/esm/server/ai-report-routes.mjs +72 -0
  124. package/esm/server/ai-report-routes.mjs.map +1 -0
  125. package/esm/server/ai-routes.mjs +41 -6
  126. package/esm/server/ai-routes.mjs.map +1 -1
  127. package/esm/server/index.mjs +2 -0
  128. package/esm/server/index.mjs.map +1 -1
  129. package/esm/server/session-routes.mjs +3 -1
  130. package/esm/server/session-routes.mjs.map +1 -1
  131. package/esm/sources/agent-trace-source.d.mts.map +1 -1
  132. package/esm/sources/agent-trace-source.mjs.map +1 -1
  133. package/esm/sources/ai-source.d.mts +2 -0
  134. package/esm/sources/ai-source.d.mts.map +1 -1
  135. package/esm/sources/ai-source.mjs +120 -11
  136. package/esm/sources/ai-source.mjs.map +1 -1
  137. package/esm/types.d.mts +23 -4
  138. package/esm/types.d.mts.map +1 -1
  139. package/llms-full.txt +79 -32
  140. package/package.json +8 -8
  141. package/skills/SKILL.md +79 -32
  142. package/ui/dashboard/assets/app.css +1 -1
  143. package/ui/dashboard/assets/app.js +23 -16
  144. package/ui/dashboard/build-info.json +7 -7
  145. package/cjs/ai-source-DTpxumMA.cjs +0 -381
  146. package/cjs/ai-source-DTpxumMA.cjs.map +0 -1
  147. package/cjs/auth-DV2GA1A9.cjs.map +0 -1
  148. package/cjs/boot-CyeHPFtk.cjs.map +0 -1
  149. package/cjs/cascade-store-DEGxAFDI.cjs.map +0 -1
  150. package/cjs/contracts-CDuY-ahl.cjs +0 -116
  151. package/cjs/contracts-CDuY-ahl.cjs.map +0 -1
  152. package/cjs/errors-DEqdWaqm.cjs.map +0 -1
  153. package/cjs/http-XNLYU2vS.cjs.map +0 -1
  154. package/cjs/migrations-DTTzCNpR.cjs.map +0 -1
  155. package/cjs/options-CHhmQJic.cjs +0 -193
  156. package/cjs/options-CHhmQJic.cjs.map +0 -1
  157. package/cjs/panels-CHd20RK5.cjs +0 -385
  158. package/cjs/panels-CHd20RK5.cjs.map +0 -1
  159. package/cjs/rolldown-runtime-Zuuoy_Rh.cjs +0 -52
  160. package/cjs/server-C8JfggQU.cjs.map +0 -1
  161. package/cjs/src-DjOUdhKc.cjs.map +0 -1
  162. package/cjs/stream-route-D4k-sJvW.cjs.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"boot.mjs","names":[],"sources":["../../../../../../../../packages/devtools/src/production/boot.ts"],"sourcesContent":["import type { FastifyInstance } from \"fastify\";\nimport { type MountedDevtoolsPanel, productionPanels } from \"../panels\";\nimport type { MountDevtoolsRoutesDeps } from \"../server/types\";\nimport type { DevtoolsDisposer, ResolvedDevtoolsOptions } from \"../types\";\nimport { DevtoolsProductionConfigError } from \"./errors\";\nimport type { DevtoolsInsights } from \"./insights/types\";\nimport { resolveProductionOptions } from \"./options\";\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\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<DevtoolsDisposer> {\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 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, panels } = productionPanels(input.panels, production.panels);\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 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 hmac: (value) => crypto.hmac(value),\n });\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 return () => {\n for (const stop of stops.splice(0).reverse()) {\n try {\n void Promise.resolve(stop()).catch(() => undefined);\n } catch {\n // Shutdown continues past a failing step.\n }\n }\n\n void capture.dispose().catch(() => undefined);\n };\n}\n"],"mappings":";;;;;;AA6BA,SAAgB,kBAAkB,MAAsB;CACtD,MAAM,QAAQ,oBAAoB,KAAK,IAAI;CAE3C,OAAO,GAAG,QAAQ,MAAM,KAAK,IAAI;AACnC;;AAGA,SAAS,iBAAiB,OAAyB;CACjD,OAAO,OAAO,UAAU,YAAY,oBAAoB,KAAK,KAAK;AACpE;;;;;;;;;;;;;AAcA,eAAsB,uBACpB,OAC2B;CAC3B,MAAM,EAAE,SAAS,KAAK,QAAQ,QAAQ;CACtC,MAAM,aAAa,yBAAyB,QAAQ,YAAY,GAAG;CACnE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C,CAAC,YAAY,MAAS;EACpD,QAAQ,CAER;EAGF,AAAK,QAAQ,QAAQ,CAAC,CAAC,YAAY,MAAS;CAC9C;AACF"}
1
+ {"version":3,"file":"boot.mjs","names":[],"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 } 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: shownTabs, panels } = productionPanels(input.panels, production.panels);\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 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,WAAuC,wBAAwB;EAAE;EAAM,MAAM;CAAa;AAC7F;AAEA,SAAS,eAAqB;CAC5B,OAAQ,WAAuC;AACjD;;;;;;AAOA,eAAe,mBACb,SACA,MACiE;CACjE,MAAM,SAAS,MAAM,WAAW;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,MAAM,gBAAgB;IAC7B,MAAM,OAAO;IACb,SAAS,yBAAyB,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,GAAG,oBAAoB,sBAAsB,aAAa,CAAC;IAAG,MAAM,UAAU,CAAC;GAAE;EAC9F;CACF;AACF;;AAGA,SAAgB,kBAAkB,MAAsB;CACtD,MAAM,QAAQ,oBAAoB,KAAK,IAAI;CAE3C,OAAO,GAAG,QAAQ,MAAM,KAAK,IAAI;AACnC;;AAGA,SAAS,iBAAiB,OAAyB;CACjD,OAAO,OAAO,UAAU,YAAY,oBAAoB,KAAK,KAAK;AACpE;;;;;;;;;;;;;AAcA,eAAsB,uBACpB,OAC8B;CAC9B,MAAM,EAAE,SAAS,KAAK,QAAQ,QAAQ;CACtC,MAAM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AO,KAAK,KAAK;EACpC,CAAC;EAED,eAAe,WAAW,IAAI;EAC9B,MAAM,KAAK,YAAY;EAEvB,IAAI,KACF,YACA,SACA,0CAA0C,kBAAkB,WAAW,IAAI,EAAE,iBAC/E;CACF,SAAS,OAAO;EACd,KAAK,MAAM,QAAQ,MAAM,OAAO,CAAC,CAAC,CAAC,QAAQ,GACzC,IAAI;GACF,AAAK,QAAQ,QAAQ,KAAK,CAAC,CAAC,CAAC,YAAY,MAAS;EACpD,QAAQ,CAER;EAGF,AAAK,QAAQ,QAAQ,CAAC,CAAC,YAAY,MAAS;EAE5C,MAAM;CACR;CAGA,aAAa;EACX,MAAM,WAA+B,CAAC;EAEtC,KAAK,MAAM,QAAQ,MAAM,OAAO,CAAC,CAAC,CAAC,QAAQ,GACzC,IAAI;GACF,SAAS,KAAK,QAAQ,QAAQ,KAAK,CAAC,CAAC,CAAC,YAAY,MAAS,CAAC;EAC9D,QAAQ,CAER;EAGF,SAAS,KAAK,QAAQ,QAAQ,CAAC,CAAC,YAAY,MAAS,CAAC;EAEtD,OAAO,QAAQ,IAAI,QAAQ,CAAC,CAAC,WAAW,MAAS;CACnD;AACF"}
@@ -408,6 +408,12 @@ export type DevtoolsPanelInfo = {
408
408
  /**
409
409
  * The built-in tabs, in display order, with whether production shows them
410
410
  * when the project says nothing (`production.panels` overrides per id).
411
+ *
412
+ * The AI section (`ai-reports`, `ai`, `agents`, `ai-models`, `ai-errors`,
413
+ * `ai-evaluate`) sits under "AI" in the sidebar. `ai` keeps its id (it is the
414
+ * Runs page) so existing links and `production.panels.ai` keep working. In
415
+ * production the three report tabs show only when the AI feed is available
416
+ * (Panoptic loads), unless `production.panels` turns one on explicitly.
411
417
  */
412
418
  export declare const DEVTOOLS_BUILT_IN_PANELS: readonly [{
413
419
  readonly id: "requests";
@@ -445,14 +451,30 @@ export declare const DEVTOOLS_BUILT_IN_PANELS: readonly [{
445
451
  readonly id: "mail";
446
452
  readonly title: "Mail";
447
453
  readonly production: false;
454
+ }, {
455
+ readonly id: "ai-reports";
456
+ readonly title: "Reports";
457
+ readonly production: true;
448
458
  }, {
449
459
  readonly id: "ai";
450
- readonly title: "AI";
460
+ readonly title: "Runs";
451
461
  readonly production: false;
452
462
  }, {
453
463
  readonly id: "agents";
454
464
  readonly title: "Agents";
455
465
  readonly production: false;
466
+ }, {
467
+ readonly id: "ai-models";
468
+ readonly title: "Models";
469
+ readonly production: true;
470
+ }, {
471
+ readonly id: "ai-errors";
472
+ readonly title: "Errors";
473
+ readonly production: true;
474
+ }, {
475
+ readonly id: "ai-evaluate";
476
+ readonly title: "Evaluate";
477
+ readonly production: false;
456
478
  }, {
457
479
  readonly id: "api";
458
480
  readonly title: "API";
@@ -502,6 +524,13 @@ export type DevtoolsSessionView = {
502
524
  share: {
503
525
  enabled: boolean;
504
526
  } | null;
527
+ /** The installed `@warlock.js/core` version; `null` when signed out or not found. */
528
+ warlockVersion: string | null;
529
+ /** The app's own `package.json` name and version (nothing else is read); `null` when signed out or not found. */
530
+ app: {
531
+ name: string;
532
+ version: string;
533
+ } | null;
505
534
  };
506
535
  /** `POST api/auth/login` body. */
507
536
  export type DevtoolsLoginInput = {
@@ -643,7 +672,7 @@ export type DevtoolsAuditEntry = {
643
672
  * `DEVTOOLS_ERROR_MESSAGES` in `errors.ts`) that says what failed and what to
644
673
  * do next.
645
674
  */
646
- export type DevtoolsErrorCode = "auth.invalid-credentials" | "auth.invalid-code" | "auth.invalid-setup-token" | "auth.password-too-short" | "auth.password-too-long" | "auth.password-common" | "auth.password-same-as-email" | "auth.password-unchanged" | "auth.wrong-current-password" | "auth.busy" | "invite.invalid" | "invite.email-taken" | "account.not-found" | "account.last-admin" | "account.self" | "account.last-factor" | "role.forbidden" | "csrf.invalid" | "passkey.unavailable" | "passkey.failed" | "explain.not-allowed" | "explain.unsupported" | "explain.elsewhere" | "explain.failed" | "request.not-found" | "request.invalid-filter" | "share.not-found" | "stream.too-many" | "input.invalid" | "server.error";
675
+ export type DevtoolsErrorCode = "auth.invalid-credentials" | "auth.invalid-code" | "auth.invalid-setup-token" | "auth.password-too-short" | "auth.password-too-long" | "auth.password-common" | "auth.password-same-as-email" | "auth.password-unchanged" | "auth.wrong-current-password" | "auth.busy" | "invite.invalid" | "invite.email-taken" | "account.not-found" | "account.last-admin" | "account.self" | "account.last-factor" | "role.forbidden" | "csrf.invalid" | "passkey.unavailable" | "passkey.failed" | "explain.not-allowed" | "explain.unsupported" | "explain.elsewhere" | "explain.failed" | "request.not-found" | "request.invalid-filter" | "share.not-found" | "stream.too-many" | "ai.range-invalid" | "ai.evaluate-unavailable" | "ai.prompt-not-found" | "ai.evaluate-failed" | "input.invalid" | "server.error";
647
676
  /** The JSON body of every failed API call. */
648
677
  export type DevtoolsApiErrorBody = {
649
678
  /** What failed and what to do next. */
@@ -654,5 +683,352 @@ export type DevtoolsApiErrorBody = {
654
683
  /** The instance that answered, when it matters (`explain.elsewhere`). */
655
684
  instance?: string;
656
685
  };
686
+ /**
687
+ * Upper bounds (inclusive, ms) of the latency buckets of the AI rollups.
688
+ * Model calls take seconds, so these differ from `DEVTOOLS_LATENCY_BUCKETS_MS`.
689
+ * A histogram has one more count than this list: the last counts everything
690
+ * above five minutes. Fixed bounds make rollups from several processes add up
691
+ * exactly. Changing them is a breaking change of the stored rollups.
692
+ */
693
+ export declare const DEVTOOLS_AI_LATENCY_BUCKETS_MS: readonly [250, 500, 1000, 2000, 3000, 5000, 7500, 10000, 15000, 20000, 30000, 45000, 60000, 120000, 300000];
694
+ /** The date-range presets of the Reports, Models and Errors pages. */
695
+ export type DevtoolsAiRangePreset = "24h" | "7d" | "30d";
696
+ /** The range a report covers, after the server aligned it to its buckets. */
697
+ export type DevtoolsAiResolvedRange = {
698
+ preset: DevtoolsAiRangePreset | "custom";
699
+ /** Inclusive start, on an hour boundary. */
700
+ from: number;
701
+ /** Exclusive end, on an hour boundary. */
702
+ to: number;
703
+ /** Bucket width of the charts: 1 hour, 6 hours or 1 day. */
704
+ stepMs: number;
705
+ /** The browser's offset from UTC (minutes east), used to align day buckets. */
706
+ utcOffsetMinutes: number;
707
+ };
708
+ /** Why an AI page has nothing to show; `title`, `message` and `command` are written for the page. */
709
+ export type DevtoolsAiUnavailableReasonView = "ai-missing" | "panoptic-missing" | "panoptic-failed" | "observation-off" | "not-collected" | "table-missing" | "reports-off";
710
+ /** The answer of any AI route that cannot serve its data. */
711
+ export type DevtoolsAiUnavailableView = {
712
+ available: false;
713
+ reason: DevtoolsAiUnavailableReasonView;
714
+ title: string;
715
+ message: string;
716
+ /** A command or config line to copy; `null` when there is none. */
717
+ command: string | null;
718
+ /** The load error and versions for `panoptic-failed`; otherwise `null`. */
719
+ detail: string | null;
720
+ };
721
+ /** Token counts. `input` is the whole prompt (cache reads and writes included) on every provider. */
722
+ export type DevtoolsAiTokenTotals = {
723
+ input: number;
724
+ output: number;
725
+ /** Prompt tokens read from the provider's cache (part of `input`). */
726
+ cached: number;
727
+ /** Prompt tokens written to the provider's cache (part of `input`). */
728
+ cacheWrite: number;
729
+ /** Reasoning tokens (part of `output`). */
730
+ reasoning: number;
731
+ };
732
+ /**
733
+ * Estimated cost. `estimatedUsd` sums only runs whose model has pricing; runs
734
+ * that used tokens on a model without pricing are counted in `unpricedRuns`
735
+ * and `unpricedTokens`, never as zero cost.
736
+ */
737
+ export type DevtoolsAiCostTotals = {
738
+ estimatedUsd: number;
739
+ pricedRuns: number;
740
+ unpricedRuns: number;
741
+ unpricedTokens: number;
742
+ };
743
+ /** Latency from the bucketed histogram: each figure is a bucket's upper bound (`null` with no runs). */
744
+ export type DevtoolsAiLatencyTotals = {
745
+ p50Ms: number | null;
746
+ p95Ms: number | null;
747
+ meanMs: number | null;
748
+ };
749
+ /** Totals over a range (or one row of a breakdown). */
750
+ export type DevtoolsAiTotals = {
751
+ runs: number;
752
+ completed: number;
753
+ failed: number;
754
+ /** Runs that stopped early: `incomplete` and `max-iterations`. */
755
+ incomplete: number;
756
+ cancelled: number;
757
+ /** `(failed + incomplete) / runs`, from 0 to 1; 0 with no runs. Cancelled runs are not errors. */
758
+ errorRate: number;
759
+ tokens: DevtoolsAiTokenTotals;
760
+ cost: DevtoolsAiCostTotals;
761
+ latency: DevtoolsAiLatencyTotals;
762
+ /** Runs where a `fallbackModel()` chain answered from a later model at least once. */
763
+ fallbackRuns: number;
764
+ /** Runs where the provider refused at least once (finish reason `refusal` or a content filter). */
765
+ refusals: number;
766
+ };
767
+ /**
768
+ * Time series for a stacked chart: `values[i]` belongs to `buckets[i]`. At
769
+ * most five named series; the rest are summed into one `other` series.
770
+ */
771
+ export type DevtoolsAiSeriesSet = {
772
+ /** Bucket starts, oldest first. */
773
+ buckets: number[];
774
+ series: {
775
+ /** Stable identity (`provider/model`, an agent name, a category); the UI keys colours on it. */
776
+ key: string;
777
+ label: string;
778
+ values: number[];
779
+ /** `true` for the summed "Other" series. */
780
+ other: boolean;
781
+ }[];
782
+ };
783
+ /** One bucket of the error-rate line. */
784
+ export type DevtoolsAiRatePoint = {
785
+ at: number;
786
+ runs: number;
787
+ /** Failed plus incomplete runs. */
788
+ errors: number;
789
+ /** `errors / runs`; `null` for a bucket without runs (the line has a gap there). */
790
+ rate: number | null;
791
+ };
792
+ /** A row of the top agents or top models table. */
793
+ export type DevtoolsAiBreakdownRow = {
794
+ /** The agent name, or `provider/model`. */
795
+ key: string;
796
+ label: string;
797
+ /** The provider for a model row; `null` for an agent row. */
798
+ provider: string | null;
799
+ totals: DevtoolsAiTotals;
800
+ /** Share of the range's estimated cost, 0 to 1 (share of runs when nothing was priced). */
801
+ share: number;
802
+ };
803
+ /** The filter values present in a range, for the filter row. */
804
+ export type DevtoolsAiFilterOptions = {
805
+ agents: string[];
806
+ /** `provider/model` keys. */
807
+ models: string[];
808
+ providers: string[];
809
+ };
810
+ /** `GET api/ai/reports`. */
811
+ export type DevtoolsAiReportView = DevtoolsAiUnavailableView | {
812
+ available: true;
813
+ range: DevtoolsAiResolvedRange;
814
+ /** The period of the same length just before `range`. */
815
+ previousRange: {
816
+ from: number;
817
+ to: number;
818
+ };
819
+ /** `false` when part of the previous period is older than the kept history: its totals are partial. */
820
+ previousComplete: boolean;
821
+ totals: DevtoolsAiTotals;
822
+ previous: DevtoolsAiTotals;
823
+ /** Estimated USD per bucket, by model (top five plus Other). */
824
+ costByModel: DevtoolsAiSeriesSet;
825
+ /** Tokens per bucket: series `uncached`, `cached`, `output`. */
826
+ tokens: DevtoolsAiSeriesSet;
827
+ errorRate: DevtoolsAiRatePoint[];
828
+ /** Up to 10 rows, highest estimated cost first (most runs when nothing was priced). */
829
+ topAgents: DevtoolsAiBreakdownRow[];
830
+ topModels: DevtoolsAiBreakdownRow[];
831
+ /** `provider/model` keys that used tokens without pricing in the range. */
832
+ unpricedModels: string[];
833
+ filters: DevtoolsAiFilterOptions;
834
+ /** `true` when `@warlock.js/ai` observes nothing, so new runs are not counted. */
835
+ observationOff: boolean;
836
+ generatedAt: number;
837
+ };
838
+ /** Whether a model's runs carried pricing in the range; `no-tokens` when no run used tokens. */
839
+ export type DevtoolsAiPricingState = "set" | "missing" | "partial" | "no-tokens";
840
+ /** One row of the Models page. */
841
+ export type DevtoolsAiModelRow = {
842
+ /** `provider/model`. */
843
+ key: string;
844
+ model: string;
845
+ provider: string;
846
+ totals: DevtoolsAiTotals;
847
+ pricing: DevtoolsAiPricingState;
848
+ /** Estimated USD per priced run; `null` when no run was priced. */
849
+ costPerRunUsd: number | null;
850
+ /** `fallbackRuns / runs`, 0 to 1. */
851
+ fallbackRate: number;
852
+ /** Agents that used the model, most runs first (at most 5). */
853
+ agents: string[];
854
+ /** Start of the last hour with a run. */
855
+ lastSeenAt: number;
856
+ };
857
+ /** `GET api/ai/models`. */
858
+ export type DevtoolsAiModelsView = DevtoolsAiUnavailableView | {
859
+ available: true;
860
+ range: DevtoolsAiResolvedRange;
861
+ totals: DevtoolsAiTotals;
862
+ /** Most runs first. */
863
+ models: DevtoolsAiModelRow[];
864
+ /** Runs per bucket by model (top five plus Other). */
865
+ runsByModel: DevtoolsAiSeriesSet;
866
+ filters: DevtoolsAiFilterOptions;
867
+ observationOff: boolean;
868
+ generatedAt: number;
869
+ };
870
+ /** How failed runs are grouped on the Errors page. */
871
+ export type DevtoolsAiErrorCategory = "rate-limit" | "timeout" | "refusal" | "provider" | "budget" | "tool" | "schema" | "incomplete" | "other";
872
+ /** Every category, in the order the Errors page lists them. */
873
+ export declare const DEVTOOLS_AI_ERROR_CATEGORIES: readonly ["rate-limit", "timeout", "refusal", "provider", "budget", "tool", "schema", "incomplete", "other"];
874
+ /** One category of failed runs. */
875
+ export type DevtoolsAiErrorGroup = {
876
+ category: DevtoolsAiErrorCategory;
877
+ /** "Rate limit", "Timeout", "Refusal", "Provider error", "Budget", "Tool failed", "Invalid output", "Incomplete", "Other". */
878
+ label: string;
879
+ count: number;
880
+ /** Share of all failed runs in the range, 0 to 1. */
881
+ share: number;
882
+ previousCount: number;
883
+ /** At most 5 each, most first. */
884
+ byModel: {
885
+ key: string;
886
+ count: number;
887
+ }[];
888
+ byAgent: {
889
+ key: string;
890
+ count: number;
891
+ }[];
892
+ };
893
+ /** A recent failed run (development only: production keeps no run details). */
894
+ export type DevtoolsAiFailedRun = {
895
+ traceId: string;
896
+ /** The agent span that failed. */
897
+ agent: string;
898
+ /** `provider/model`, or `null` when unreported. */
899
+ model: string | null;
900
+ status: string;
901
+ category: DevtoolsAiErrorCategory;
902
+ /** The error code (`PROVIDER_RATE_LIMIT`) or error name. */
903
+ code: string | null;
904
+ /** The error message, secrets scrubbed, at most 300 characters. */
905
+ message: string | null;
906
+ endedAt: number;
907
+ requestId: string | null;
908
+ };
909
+ /** `GET api/ai/errors`. */
910
+ export type DevtoolsAiErrorsView = DevtoolsAiUnavailableView | {
911
+ available: true;
912
+ range: DevtoolsAiResolvedRange;
913
+ totals: DevtoolsAiTotals;
914
+ previous: DevtoolsAiTotals;
915
+ /** `false` when part of the previous period is older than the kept history: its totals are partial. */
916
+ previousComplete: boolean;
917
+ /** Categories with at least one failed run, most first. */
918
+ groups: DevtoolsAiErrorGroup[];
919
+ /** Failed runs per bucket by category (top five plus Other). */
920
+ overTime: DevtoolsAiSeriesSet;
921
+ /** Newest first, at most 50; `null` in production. */
922
+ recent: DevtoolsAiFailedRun[] | null;
923
+ filters: DevtoolsAiFilterOptions;
924
+ observationOff: boolean;
925
+ generatedAt: number;
926
+ };
927
+ /** Usage of one run as the Runs page shows it. */
928
+ export type DevtoolsAiUsageView = {
929
+ input: number;
930
+ output: number;
931
+ total: number;
932
+ cachedTokens: number | null;
933
+ cacheWriteTokens: number | null;
934
+ /** `false` when `input` excludes cache tokens (the provider reports them on top). */
935
+ inputIncludesCache: boolean | null;
936
+ };
937
+ /** One row of the Runs page (a Panoptic trace, content-free). */
938
+ export type DevtoolsAiRunRow = {
939
+ traceId: string;
940
+ requestId: string | null;
941
+ sessionId: string | null;
942
+ name: string;
943
+ /** The root span type: `agent`, `workflow`, `supervisor`, … */
944
+ type: string;
945
+ status: string;
946
+ startedAt: string;
947
+ duration: number;
948
+ usage: DevtoolsAiUsageView;
949
+ /** Estimated USD; `null` when the run carried no pricing. */
950
+ cost: number | null;
951
+ models: string[];
952
+ /** `promptName@promptVersion` of the root agent, or `null`. */
953
+ promptKey: string | null;
954
+ toolCalls: number;
955
+ retries: number;
956
+ incomplete: boolean;
957
+ };
958
+ /** A group of the Runs page (`groupBy=session|prompt|type`). */
959
+ export type DevtoolsAiRunGroup = {
960
+ key: string;
961
+ label: string;
962
+ runs: number;
963
+ failed: number;
964
+ estimatedCostUsd: number;
965
+ p95Ms: number | null;
966
+ /** Trace ids of the group, newest first (at most 50). */
967
+ traceIds: string[];
968
+ };
969
+ /** `GET api/ai/runs`. */
970
+ export type DevtoolsAiRunsView = DevtoolsAiUnavailableView | {
971
+ available: true;
972
+ /** Newest first, at most `limit` (default 200). */
973
+ runs: DevtoolsAiRunRow[];
974
+ /** `null` unless `groupBy` was given. */
975
+ groups: DevtoolsAiRunGroup[] | null;
976
+ stats: {
977
+ /** Runs matching the filter (before `limit`). */
978
+ count: number;
979
+ failed: number;
980
+ /** Priced runs only. */
981
+ estimatedCostUsd: number;
982
+ /** Runs that used tokens on a model without pricing (not in `estimatedCostUsd`). */
983
+ unpricedRuns: number;
984
+ p50Ms: number | null;
985
+ p95Ms: number | null;
986
+ };
987
+ /** How many traces the dashboard keeps (`maxRequests`). */
988
+ capacity: number;
989
+ };
990
+ /** A distinct system prompt seen in recent agent runs (the Evaluate picker). */
991
+ export type DevtoolsAiEvaluatePrompt = {
992
+ /** The prompt's hash from the agent trace. */
993
+ hash: string;
994
+ /** Agents that used it, most recent first. */
995
+ agents: string[];
996
+ /** The newest run that carried its text. */
997
+ runId: string;
998
+ lastSeenAt: string;
999
+ /** The first 200 characters. */
1000
+ preview: string;
1001
+ length: number;
1002
+ };
1003
+ /** `GET api/ai/evaluate`. */
1004
+ export type DevtoolsAiEvaluateView = DevtoolsAiUnavailableView | {
1005
+ available: true;
1006
+ /** Whether `panoptic.evaluate` (or `panoptic.dashboard.evaluate`) has a judge model. */
1007
+ configured: boolean;
1008
+ /** The judge model as `provider/name`; `null` when not configured. */
1009
+ judge: string | null;
1010
+ /** The configured default grading instructions; `""` when none. */
1011
+ instructions: string;
1012
+ /** Newest first, at most 50. */
1013
+ prompts: DevtoolsAiEvaluatePrompt[];
1014
+ };
1015
+ /** `POST api/ai/evaluate` body: exactly one of `runId` and `systemPrompt`. */
1016
+ export type DevtoolsAiEvaluateRequest = {
1017
+ /** An agent run whose system prompt text is kept. */
1018
+ runId?: string;
1019
+ /** A pasted prompt, 1 to 100,000 characters. */
1020
+ systemPrompt?: string;
1021
+ /** Overrides the configured instructions for this run; at most 4,000 characters. */
1022
+ instructions?: string;
1023
+ };
1024
+ /** `POST api/ai/evaluate` answer. */
1025
+ export type DevtoolsAiEvaluateResult = {
1026
+ /** 0 to 1; `null` when the judge returned no score. */
1027
+ score: number | null;
1028
+ issues: string[];
1029
+ /** The judge model as `provider/name`. */
1030
+ judge: string;
1031
+ durationMs: number;
1032
+ };
657
1033
  //#endregion
658
1034
  //# sourceMappingURL=contracts.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"contracts.d.mts","names":[],"sources":["../../../../../../../../packages/devtools/src/production/contracts.ts"],"mappings":";;;;;;;;;;YAcY;;YAGA;;;;;YAMA;;YAQA;;YAOA;;EAEV;;EAEA;EACA;EACA;;EAEA;EACA;;EAEA;EACA;;;;;;;;qBAaW;;YAKD;;EAEV;EACA;EACA;EACA;;;YAQU;;EAEV;;EAEA;EACA;EACA;EACA;EACA;EACA,WAAW;;EAEX;IAAY;IAAkB;;;EAE9B;IACE;IACA;IACA;IACA;IACA;;EAEF;EACA;;EAEA;;;YAIU;EACV;EACA;EACA;EACA;;;YAIU;;EAEV;EACA;EACA;EACA;;EAEA;EACA,WAAW;;EAEX,QAAQ;EACR;IAAW;IAAoB;IAAY;IAA0B;;;;YAI3D;;EAEV;;EAEA;;EAEA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;EAEA;;;YAIU;EACV;EACA;EACA;;EAEA;EACA;EACA;;;YAQU;EACV;EACA;EACA;EACA;EACA;;EAEA;EACA;EACA;EACA;;EAEA;;EAEA;;EAEA;;;YAIU,2BAA2B;EACrC;EACA;;EAEA,UAAU;IAEN;IAAe;;;;YAKT;EACV;EACA;EACA,QAAQ;;EAER;IAAW;IAAY;IAAwB;;;;YAIrC;EACV;;EAEA;;EAEA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;;YAIU;EACV;IAAa;IAAoB;;EACjC,WAAW;;EAEX;IAAU;IAAc,QAAQ;;;;YAItB;EACV;EACA;EACA;;EAEA;;EAEA;;EAEA;;EAEA;EACA;EACA;;EAEA;;;;;;;YAQU;EACV,UAAU;EACV;EACA;IAAa,UAAU;IAA0B,SAAS;;;EAE1D,SAAS;;EAET,QAAQ;;EAER,QAAQ;;EAER,MAAM;EACN,QAAQ;EACR,MAAM;EACN,SAAS;;;;;;YAWC;EACV;EACA;EACA;EACA;EACA;EACA;EACA;E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Ae;;;YAGtC;EAA2B,OAAO;EAAsB;;;YAGxD;;EAEV;;EAEA;EACA;EACA;;;YAIU;EAA0B;;;YAG1B;EACV;EACA;EACA,MAAM;EACN;EACA;EACA;EACA;;;YAIU;EAA0B,QAAQ;EAAoB;;;YAGtD;EACV,UAAU;EACV,SAAS;;;YAIC;EACV;EACA;EACA;EACA;EACA;EACA;EACA;;;YAQU;;YAGA;EACV;;EAEA;;EAEA;;EAEA;EACA;EACA;EACA;EACA;;EAEA;EACA,QAAQ;;;YAIE;EACV;;EAEA;;EAEA;IAAU;IAAY;;;EAEtB,QAAQ;;;YAIE;EAA6B;EAAe;EAAe;;;YAG3D;EAAyB,OAAO;EAAmB;;;;;;YAMnD;EACV;;EAEA;EACA;EACA;;EAEA;;EAEA;;;qBAIW;;YAOD;;qBAoCC,uCAAuC;;YAOxC;EACV;EACA;EACA,MAAM;;EAEN;;EAEA;;EAEA;;EAEA;;EAEA,QAAQ;;EAER;;;;;;;YAYU;;YAiCA;;EAEV;EACA,MAAM;;EAEN;;EAEA"}
1
+ {"version":3,"file":"contracts.d.mts","names":[],"sources":["../../../../../../../../packages/devtools/src/production/contracts.ts"],"mappings":";;;;;;;;;;YAcY;;YAGA;;;;;YAMA;;YAQA;;YAOA;;EAEV;;EAEA;EACA;EACA;;EAEA;EACA;;EAEA;EACA;;;;;;;;qBAaW;;YAKD;;EAEV;EACA;EACA;EACA;;;YAQU;;EAEV;;EAEA;EACA;EACA;EACA;EACA;EACA,WAAW;;EAEX;IAAY;IAAkB;;;EAE9B;IACE;IACA;IACA;IACA;IACA;;EAEF;EACA;;EAEA;;;YAIU;EACV;EACA;EACA;EACA;;;YAIU;;EAEV;EACA;EACA;EACA;;EAEA;EACA,WAAW;;EAEX,QAAQ;EACR;IAAW;IAAoB;IAAY;IAA0B;;;;YAI3D;;EAEV;;EAEA;;EAEA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;EAEA;;;YAIU;EACV;EACA;EACA;;EAEA;EACA;EACA;;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EACA;EACA;EACA;;EAEA;;;YAIU;EACV;EACA;EACA;EACA;;EAEA;EACA;EACA;EACA;EACA,OAAO;;EAEP;EACA;;EAEA;EACA;EACA;EACA;;;YAIU;EACV;EACA;EACA;EACA;EACA;EACA;;EAEA;;;YAIU,qBACR;EAEE;;EAEA,MAAM;;EAEN,QAAQ;EACR;;IAEE;IACA;;IAEA;;IAEA;IACA;IACA;;;EAGF;;;YAIM;;EAEV;;EAEA;;EAEA;EACA;;EAEA;EACA;;;YAIU,yBACR;EAEE;;EAEA;;EAEA;;EAEA;;EAEA,SAAS;;;YAIH;;EAEV;;EAEA;;EAEA;;;YAIU;;EAEV;EACA;;EAEA;EACA"}
@@ -24,6 +24,12 @@ const DEVTOOLS_LATENCY_BUCKETS_MS = [
24
24
  /**
25
25
  * The built-in tabs, in display order, with whether production shows them
26
26
  * when the project says nothing (`production.panels` overrides per id).
27
+ *
28
+ * The AI section (`ai-reports`, `ai`, `agents`, `ai-models`, `ai-errors`,
29
+ * `ai-evaluate`) sits under "AI" in the sidebar. `ai` keeps its id (it is the
30
+ * Runs page) so existing links and `production.panels.ai` keep working. In
31
+ * production the three report tabs show only when the AI feed is available
32
+ * (Panoptic loads), unless `production.panels` turns one on explicitly.
27
33
  */
28
34
  const DEVTOOLS_BUILT_IN_PANELS = [
29
35
  {
@@ -71,9 +77,14 @@ const DEVTOOLS_BUILT_IN_PANELS = [
71
77
  title: "Mail",
72
78
  production: false
73
79
  },
80
+ {
81
+ id: "ai-reports",
82
+ title: "Reports",
83
+ production: true
84
+ },
74
85
  {
75
86
  id: "ai",
76
- title: "AI",
87
+ title: "Runs",
77
88
  production: false
78
89
  },
79
90
  {
@@ -81,6 +92,21 @@ const DEVTOOLS_BUILT_IN_PANELS = [
81
92
  title: "Agents",
82
93
  production: false
83
94
  },
95
+ {
96
+ id: "ai-models",
97
+ title: "Models",
98
+ production: true
99
+ },
100
+ {
101
+ id: "ai-errors",
102
+ title: "Errors",
103
+ production: true
104
+ },
105
+ {
106
+ id: "ai-evaluate",
107
+ title: "Evaluate",
108
+ production: false
109
+ },
84
110
  {
85
111
  id: "api",
86
112
  title: "API",
@@ -93,7 +119,43 @@ const DEVTOOLS_FAILURE_AUDIT_TYPES = [
93
119
  "mfa.failed",
94
120
  "share.failed"
95
121
  ];
122
+ /**
123
+ * Upper bounds (inclusive, ms) of the latency buckets of the AI rollups.
124
+ * Model calls take seconds, so these differ from `DEVTOOLS_LATENCY_BUCKETS_MS`.
125
+ * A histogram has one more count than this list: the last counts everything
126
+ * above five minutes. Fixed bounds make rollups from several processes add up
127
+ * exactly. Changing them is a breaking change of the stored rollups.
128
+ */
129
+ const DEVTOOLS_AI_LATENCY_BUCKETS_MS = [
130
+ 250,
131
+ 500,
132
+ 1e3,
133
+ 2e3,
134
+ 3e3,
135
+ 5e3,
136
+ 7500,
137
+ 1e4,
138
+ 15e3,
139
+ 2e4,
140
+ 3e4,
141
+ 45e3,
142
+ 6e4,
143
+ 12e4,
144
+ 3e5
145
+ ];
146
+ /** Every category, in the order the Errors page lists them. */
147
+ const DEVTOOLS_AI_ERROR_CATEGORIES = [
148
+ "rate-limit",
149
+ "timeout",
150
+ "refusal",
151
+ "provider",
152
+ "budget",
153
+ "tool",
154
+ "schema",
155
+ "incomplete",
156
+ "other"
157
+ ];
96
158
 
97
159
  //#endregion
98
- export { DEVTOOLS_BUILT_IN_PANELS, DEVTOOLS_FAILURE_AUDIT_TYPES, DEVTOOLS_LATENCY_BUCKETS_MS };
160
+ export { DEVTOOLS_AI_ERROR_CATEGORIES, DEVTOOLS_AI_LATENCY_BUCKETS_MS, DEVTOOLS_BUILT_IN_PANELS, DEVTOOLS_FAILURE_AUDIT_TYPES, DEVTOOLS_LATENCY_BUCKETS_MS };
99
161
  //# sourceMappingURL=contracts.mjs.map