@warlock.js/devtools 5.59.0 → 5.61.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 (154) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/cjs/{app-versions-DfpPZOI2.cjs → app-versions-C_ZyzuvD.cjs} +1 -116
  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-B3wyjJnQ.cjs → auth-ChHh5E7j.cjs} +6 -6
  7. package/cjs/{auth-B3wyjJnQ.cjs.map → auth-ChHh5E7j.cjs.map} +1 -1
  8. package/cjs/{boot-nczSvJ_F.cjs → boot-D0nF-7w3.cjs} +78 -14
  9. package/cjs/boot-D0nF-7w3.cjs.map +1 -0
  10. package/cjs/{capture-CuyT8Vab.cjs → capture-D2k0GnBN.cjs} +23 -422
  11. package/cjs/capture-D2k0GnBN.cjs.map +1 -0
  12. package/cjs/{cascade-store-CuRRYzt_.cjs → cascade-store-DUT2Laha.cjs} +3 -3
  13. package/cjs/{cascade-store-CuRRYzt_.cjs.map → cascade-store-DUT2Laha.cjs.map} +1 -1
  14. package/cjs/{collector-CJbQbzzK.cjs → collector-BfC4v87v.cjs} +4 -46
  15. package/cjs/collector-BfC4v87v.cjs.map +1 -0
  16. package/cjs/{current-request-id-CeQhRz9Q.cjs → current-request-id-Badec-TH.cjs} +2 -2
  17. package/cjs/{current-request-id-CeQhRz9Q.cjs.map → current-request-id-Badec-TH.cjs.map} +1 -1
  18. package/cjs/{errors-BadbSDX8.cjs → errors-DNQ-g49I.cjs} +198 -1
  19. package/cjs/errors-DNQ-g49I.cjs.map +1 -0
  20. package/cjs/extract-8kaX_cUV.cjs +1103 -0
  21. package/cjs/extract-8kaX_cUV.cjs.map +1 -0
  22. package/cjs/{http-Biauhqi0.cjs → http-1nnpAoI7.cjs} +33 -10
  23. package/cjs/http-1nnpAoI7.cjs.map +1 -0
  24. package/cjs/index.cjs +1 -1
  25. package/cjs/{insights-BjJA6Ret.cjs → insights-COA3u37q.cjs} +54 -22
  26. package/cjs/insights-COA3u37q.cjs.map +1 -0
  27. package/cjs/migrations-BQdNOL5_.cjs +30 -0
  28. package/cjs/migrations-BQdNOL5_.cjs.map +1 -0
  29. package/cjs/{migrations-BP4cYTGo.cjs → models-DF1agAm4.cjs} +106 -24
  30. package/cjs/models-DF1agAm4.cjs.map +1 -0
  31. package/cjs/{process-panel-DskSA7Cm.cjs → process-panel-D3D9Y_dc.cjs} +4 -4
  32. package/cjs/{process-panel-DskSA7Cm.cjs.map → process-panel-D3D9Y_dc.cjs.map} +1 -1
  33. package/cjs/production/index.cjs +4 -4
  34. package/cjs/query-shape-DShKQa0x.cjs +45 -0
  35. package/cjs/query-shape-DShKQa0x.cjs.map +1 -0
  36. package/cjs/redact-DQ28mDzr.cjs +533 -0
  37. package/cjs/redact-DQ28mDzr.cjs.map +1 -0
  38. package/cjs/runs-DECWPGnq.cjs +390 -0
  39. package/cjs/runs-DECWPGnq.cjs.map +1 -0
  40. package/cjs/{server-D3XRbSSb.cjs → server-DLT3uPef.cjs} +8 -7
  41. package/cjs/{server-D3XRbSSb.cjs.map → server-DLT3uPef.cjs.map} +1 -1
  42. package/cjs/{src-QcNghoYN.cjs → src-BZiSv8A1.cjs} +182 -24
  43. package/cjs/src-BZiSv8A1.cjs.map +1 -0
  44. package/cjs/{store-CNFv3wVp.cjs → store-EFn4wp0T.cjs} +2 -2
  45. package/cjs/{stream-route-BqyAlfxQ.cjs → stream-route-B6WAjbPG.cjs} +111 -22
  46. package/cjs/stream-route-B6WAjbPG.cjs.map +1 -0
  47. package/esm/ai/attach.mjs +92 -0
  48. package/esm/ai/attach.mjs.map +1 -0
  49. package/esm/ai/options.mjs +31 -0
  50. package/esm/ai/options.mjs.map +1 -0
  51. package/esm/ai/reports/aggregate.mjs +330 -0
  52. package/esm/ai/reports/aggregate.mjs.map +1 -0
  53. package/esm/ai/reports/evaluate.mjs +108 -0
  54. package/esm/ai/reports/evaluate.mjs.map +1 -0
  55. package/esm/ai/reports/range.mjs +121 -0
  56. package/esm/ai/reports/range.mjs.map +1 -0
  57. package/esm/ai/reports/runs.d.mts +2 -0
  58. package/esm/ai/reports/runs.mjs +212 -0
  59. package/esm/ai/reports/runs.mjs.map +1 -0
  60. package/esm/ai/reports/service.mjs +132 -0
  61. package/esm/ai/reports/service.mjs.map +1 -0
  62. package/esm/ai/rollup/cascade-store.mjs +84 -0
  63. package/esm/ai/rollup/cascade-store.mjs.map +1 -0
  64. package/esm/ai/rollup/categories.mjs +67 -0
  65. package/esm/ai/rollup/categories.mjs.map +1 -0
  66. package/esm/ai/rollup/extract.mjs +225 -0
  67. package/esm/ai/rollup/extract.mjs.map +1 -0
  68. package/esm/ai/rollup/file-store.mjs +147 -0
  69. package/esm/ai/rollup/file-store.mjs.map +1 -0
  70. package/esm/ai/rollup/histogram.mjs +42 -0
  71. package/esm/ai/rollup/histogram.mjs.map +1 -0
  72. package/esm/ai/rollup/increment-error.mjs +19 -0
  73. package/esm/ai/rollup/increment-error.mjs.map +1 -0
  74. package/esm/ai/rollup/index.mjs +9 -0
  75. package/esm/ai/rollup/mapping.mjs +69 -0
  76. package/esm/ai/rollup/mapping.mjs.map +1 -0
  77. package/esm/ai/rollup/memory-store.mjs +26 -0
  78. package/esm/ai/rollup/memory-store.mjs.map +1 -0
  79. package/esm/ai/rollup/writer.mjs +113 -0
  80. package/esm/ai/rollup/writer.mjs.map +1 -0
  81. package/esm/ai/types.d.mts +29 -0
  82. package/esm/ai/types.d.mts.map +1 -0
  83. package/esm/devtools-connector.d.mts.map +1 -1
  84. package/esm/devtools-connector.mjs +58 -3
  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/boot.mjs +70 -3
  90. package/esm/production/boot.mjs.map +1 -1
  91. package/esm/production/contracts.d.mts +388 -6
  92. package/esm/production/contracts.d.mts.map +1 -1
  93. package/esm/production/contracts.mjs +64 -2
  94. package/esm/production/contracts.mjs.map +1 -1
  95. package/esm/production/errors.mjs +8 -0
  96. package/esm/production/errors.mjs.map +1 -1
  97. package/esm/production/http/access.mjs +6 -0
  98. package/esm/production/http/access.mjs.map +1 -1
  99. package/esm/production/http/mount.mjs +21 -2
  100. package/esm/production/http/mount.mjs.map +1 -1
  101. package/esm/production/http/share.mjs.map +1 -1
  102. package/esm/production/index.d.mts +2 -2
  103. package/esm/production/insights/jobs.mjs +45 -11
  104. package/esm/production/insights/jobs.mjs.map +1 -1
  105. package/esm/production/store/migrations.d.mts +1 -1
  106. package/esm/production/store/migrations.d.mts.map +1 -1
  107. package/esm/production/store/migrations.mjs +4 -2
  108. package/esm/production/store/migrations.mjs.map +1 -1
  109. package/esm/production/store/models/ai-rollup.migration.mjs +48 -0
  110. package/esm/production/store/models/ai-rollup.migration.mjs.map +1 -0
  111. package/esm/production/store/models/ai-rollup.model.mjs +13 -0
  112. package/esm/production/store/models/ai-rollup.model.mjs.map +1 -0
  113. package/esm/production/store/models/index.mjs +3 -1
  114. package/esm/server/ai-report-routes.mjs +72 -0
  115. package/esm/server/ai-report-routes.mjs.map +1 -0
  116. package/esm/server/ai-routes.mjs +22 -1
  117. package/esm/server/ai-routes.mjs.map +1 -1
  118. package/esm/server/index.mjs +2 -0
  119. package/esm/server/index.mjs.map +1 -1
  120. package/esm/server/panel-routes.mjs.map +1 -1
  121. package/esm/server/ui-assets.mjs +4 -7
  122. package/esm/server/ui-assets.mjs.map +1 -1
  123. package/esm/sources/agent-trace-source.d.mts.map +1 -1
  124. package/esm/sources/agent-trace-source.mjs.map +1 -1
  125. package/esm/sources/ai-source.d.mts +2 -0
  126. package/esm/sources/ai-source.d.mts.map +1 -1
  127. package/esm/sources/ai-source.mjs +58 -17
  128. package/esm/sources/ai-source.mjs.map +1 -1
  129. package/esm/types.d.mts +13 -3
  130. package/esm/types.d.mts.map +1 -1
  131. package/llms-full.txt +61 -22
  132. package/package.json +8 -8
  133. package/skills/SKILL.md +61 -22
  134. package/ui/dashboard/assets/app.css +1 -1
  135. package/ui/dashboard/assets/app.js +12 -5
  136. package/ui/dashboard/build-info.json +7 -7
  137. package/cjs/ai-source-BdvMfyKw.cjs +0 -448
  138. package/cjs/ai-source-BdvMfyKw.cjs.map +0 -1
  139. package/cjs/app-versions-DfpPZOI2.cjs.map +0 -1
  140. package/cjs/boot-nczSvJ_F.cjs.map +0 -1
  141. package/cjs/capture-CuyT8Vab.cjs.map +0 -1
  142. package/cjs/collector-CJbQbzzK.cjs.map +0 -1
  143. package/cjs/errors-BadbSDX8.cjs.map +0 -1
  144. package/cjs/histogram-DTOGnNBW.cjs +0 -102
  145. package/cjs/histogram-DTOGnNBW.cjs.map +0 -1
  146. package/cjs/http-Biauhqi0.cjs.map +0 -1
  147. package/cjs/insights-BjJA6Ret.cjs.map +0 -1
  148. package/cjs/migrations-BP4cYTGo.cjs.map +0 -1
  149. package/cjs/options-B9FHbRAJ.cjs +0 -205
  150. package/cjs/options-B9FHbRAJ.cjs.map +0 -1
  151. package/cjs/panels-D1ITm-jc.cjs +0 -384
  152. package/cjs/panels-D1ITm-jc.cjs.map +0 -1
  153. package/cjs/src-QcNghoYN.cjs.map +0 -1
  154. package/cjs/stream-route-BqyAlfxQ.cjs.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"panel-routes.mjs","names":[],"sources":["../../../../../../../../packages/devtools/src/server/panel-routes.ts"],"sourcesContent":["import { createReadStream } from \"node:fs\";\nimport type { FastifyInstance, FastifyReply, FastifyRequest } from \"fastify\";\nimport { type MountedDevtoolsPanel, panelContentType } from \"../panels\";\nimport type { DevtoolsPanelRequest } from \"../types\";\nimport { resolvePanelFile } from \"./panel-files\";\nimport { sendFile } from \"./ui-assets\";\n\n/** Answers 404; the production mount passes its uniform not-found answer. */\nexport type PanelNotFound = (request: FastifyRequest, reply: FastifyReply) => FastifyReply;\n\n/** Sends one image of a panel's folder with its content type, or answers 404. */\nexport async function sendPanelFile(\n panel: Pick<MountedDevtoolsPanel, \"files\">,\n requested: unknown,\n request: FastifyRequest,\n reply: FastifyReply,\n notFound: PanelNotFound,\n): Promise<FastifyReply | void> {\n const file = panel.files === null ? null : await resolvePanelFile(panel.files, requested);\n\n if (file === null) return notFound(request, reply);\n\n reply\n .header(\"X-Content-Type-Options\", \"nosniff\")\n .header(\"Cache-Control\", \"no-store\")\n .header(\"Content-Type\", panelContentType(file));\n\n return reply.send(createReadStream(file));\n}\n\n/**\n * Mounts each panel's data routes at `/api/<id><route path>`, its view\n * module and assets at `/panels/<id>/<name>`, and its folder of images at\n * `/panels/<id>/files/<path>`. Callers register this inside the devtools\n * scope, so the guard covers every one of them. A file is served only when\n * its name is listed by the panel (or, for `files`, resolves inside the\n * panel's folder with a listed extension); the request never becomes a\n * filesystem path on its own.\n */\nexport function registerPanelRoutes(\n server: FastifyInstance,\n panels: readonly MountedDevtoolsPanel[],\n options: { notFound?: PanelNotFound } = {},\n): void {\n const byId = new Map(panels.map((panel) => [panel.id, panel]));\n const notFound: PanelNotFound =\n options.notFound ??\n ((_request, reply) => {\n reply.code(404).header(\"Cache-Control\", \"no-store\").send();\n\n return reply;\n });\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; \"*\": string } }>(\n \"/panels/:id/files/*\",\n async (request, reply) => {\n const panel = byId.get(request.params.id);\n\n if (panel === undefined) return notFound(request, reply);\n\n return sendPanelFile(panel, request.params[\"*\"], request, reply, notFound);\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"],"mappings":";;;;;;;AAWA,eAAsB,cACpB,OACA,WACA,SACA,OACA,UAC8B;CAC9B,MAAM,OAAO,MAAM,UAAU,OAAO,OAAO,MAAM,iBAAiB,MAAM,OAAO,SAAS;CAExF,IAAI,SAAS,MAAM,OAAO,SAAS,SAAS,KAAK;CAEjD,MACG,OAAO,0BAA0B,SAAS,CAAC,CAC3C,OAAO,iBAAiB,UAAU,CAAC,CACnC,OAAO,gBAAgB,iBAAiB,IAAI,CAAC;CAEhD,OAAO,MAAM,KAAK,iBAAiB,IAAI,CAAC;AAC1C;;;;;;;;;;AAWA,SAAgB,oBACd,QACA,QACA,UAAwC,CAAC,GACnC;CACN,MAAM,OAAO,IAAI,IAAI,OAAO,KAAK,UAAU,CAAC,MAAM,IAAI,KAAK,CAAC,CAAC;CAC7D,MAAM,WACJ,QAAQ,cACN,UAAU,UAAU;EACpB,MAAM,KAAK,GAAG,CAAC,CAAC,OAAO,iBAAiB,UAAU,CAAC,CAAC,KAAK;EAEzD,OAAO;CACT;CAEF,KAAK,MAAM,SAAS,QAClB,KAAK,MAAM,SAAS,MAAM,QACxB,OAAO,MAAM;EACX,QAAQ,MAAM;EACd,KAAK,QAAQ,MAAM,KAAK,MAAM;EAC9B,SAAS,OAAO,SAAS,UAAU;GACjC,MAAM,QAA8B;IAClC,QAAS,QAAQ,UAAU,CAAC;IAC5B,OAAQ,QAAQ,SAAS,CAAC;IAC1B,MAAM,QAAQ;GAChB;GACA,MAAM,SAAS,MAAM,MAAM,QAAQ,KAAK;GAExC,MAAM,OAAO,iBAAiB,UAAU;GAExC,IAAI,WAAW,QAAW,OAAO,MAAM,KAAK,GAAG,CAAC,CAAC,KAAK;GAEtD,OAAO;EACT;CACF,CAAC;CAIL,OAAO,IACL,uBACA,OAAO,SAAS,UAAU;EACxB,MAAM,QAAQ,KAAK,IAAI,QAAQ,OAAO,EAAE;EAExC,IAAI,UAAU,QAAW,OAAO,SAAS,SAAS,KAAK;EAEvD,OAAO,cAAc,OAAO,QAAQ,OAAO,MAAM,SAAS,OAAO,QAAQ;CAC3E,CACF;CAEA,OAAO,IAA8C,sBAAsB,SAAS,UAAU;EAC5F,MAAM,QAAQ,KAAK,IAAI,QAAQ,OAAO,EAAE;EACxC,MAAM,OAAO,QAAQ,OAAO;EAC5B,MAAM,OACJ,UAAU,SACN,SACA,SAAS,YACP,MAAM,OACN,OAAO,OAAO,MAAM,QAAQ,IAAI,IAC9B,MAAM,OAAO,QACb;EAEV,IAAI,SAAS,QAAW;GACtB,MAAM,KAAK,GAAG,CAAC,CAAC,OAAO,iBAAiB,UAAU,CAAC,CAAC,KAAK;GACzD;EACF;EAEA,MAAM,OAAO,0BAA0B,SAAS;EAChD,SAAS,OAAO,MAAM,iBAAiB,IAAI,CAAC;CAC9C,CAAC;AACH"}
1
+ {"version":3,"file":"panel-routes.mjs","names":[],"sources":["../../../../../../../../packages/devtools/src/server/panel-routes.ts"],"sourcesContent":["import { createReadStream } from \"node:fs\";\nimport type { FastifyInstance, FastifyReply, FastifyRequest } from \"fastify\";\nimport { type MountedDevtoolsPanel, panelContentType } from \"../panels\";\nimport type { DevtoolsPanelRequest } from \"../types\";\nimport { resolvePanelFile } from \"./panel-files\";\nimport { sendFile } from \"./ui-assets\";\n\n/** Answers 404; the production mount passes its uniform not-found answer. */\nexport type PanelNotFound = (\n request: FastifyRequest,\n reply: FastifyReply,\n) => FastifyReply | Promise<FastifyReply>;\n\n/** Sends one image of a panel's folder with its content type, or answers 404. */\nexport async function sendPanelFile(\n panel: Pick<MountedDevtoolsPanel, \"files\">,\n requested: unknown,\n request: FastifyRequest,\n reply: FastifyReply,\n notFound: PanelNotFound,\n): Promise<FastifyReply | void> {\n const file = panel.files === null ? null : await resolvePanelFile(panel.files, requested);\n\n if (file === null) return notFound(request, reply);\n\n reply\n .header(\"X-Content-Type-Options\", \"nosniff\")\n .header(\"Cache-Control\", \"no-store\")\n .header(\"Content-Type\", panelContentType(file));\n\n return reply.send(createReadStream(file));\n}\n\n/**\n * Mounts each panel's data routes at `/api/<id><route path>`, its view\n * module and assets at `/panels/<id>/<name>`, and its folder of images at\n * `/panels/<id>/files/<path>`. Callers register this inside the devtools\n * scope, so the guard covers every one of them. A file is served only when\n * its name is listed by the panel (or, for `files`, resolves inside the\n * panel's folder with a listed extension); the request never becomes a\n * filesystem path on its own.\n */\nexport function registerPanelRoutes(\n server: FastifyInstance,\n panels: readonly MountedDevtoolsPanel[],\n options: { notFound?: PanelNotFound } = {},\n): void {\n const byId = new Map(panels.map((panel) => [panel.id, panel]));\n const notFound: PanelNotFound =\n options.notFound ??\n ((_request, reply) => {\n reply.code(404).header(\"Cache-Control\", \"no-store\").send();\n\n return reply;\n });\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; \"*\": string } }>(\n \"/panels/:id/files/*\",\n async (request, reply) => {\n const panel = byId.get(request.params.id);\n\n if (panel === undefined) return notFound(request, reply);\n\n return sendPanelFile(panel, request.params[\"*\"], request, reply, notFound);\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"],"mappings":";;;;;;;AAcA,eAAsB,cACpB,OACA,WACA,SACA,OACA,UAC8B;CAC9B,MAAM,OAAO,MAAM,UAAU,OAAO,OAAO,MAAM,iBAAiB,MAAM,OAAO,SAAS;CAExF,IAAI,SAAS,MAAM,OAAO,SAAS,SAAS,KAAK;CAEjD,MACG,OAAO,0BAA0B,SAAS,CAAC,CAC3C,OAAO,iBAAiB,UAAU,CAAC,CACnC,OAAO,gBAAgB,iBAAiB,IAAI,CAAC;CAEhD,OAAO,MAAM,KAAK,iBAAiB,IAAI,CAAC;AAC1C;;;;;;;;;;AAWA,SAAgB,oBACd,QACA,QACA,UAAwC,CAAC,GACnC;CACN,MAAM,OAAO,IAAI,IAAI,OAAO,KAAK,UAAU,CAAC,MAAM,IAAI,KAAK,CAAC,CAAC;CAC7D,MAAM,WACJ,QAAQ,cACN,UAAU,UAAU;EACpB,MAAM,KAAK,GAAG,CAAC,CAAC,OAAO,iBAAiB,UAAU,CAAC,CAAC,KAAK;EAEzD,OAAO;CACT;CAEF,KAAK,MAAM,SAAS,QAClB,KAAK,MAAM,SAAS,MAAM,QACxB,OAAO,MAAM;EACX,QAAQ,MAAM;EACd,KAAK,QAAQ,MAAM,KAAK,MAAM;EAC9B,SAAS,OAAO,SAAS,UAAU;GACjC,MAAM,QAA8B;IAClC,QAAS,QAAQ,UAAU,CAAC;IAC5B,OAAQ,QAAQ,SAAS,CAAC;IAC1B,MAAM,QAAQ;GAChB;GACA,MAAM,SAAS,MAAM,MAAM,QAAQ,KAAK;GAExC,MAAM,OAAO,iBAAiB,UAAU;GAExC,IAAI,WAAW,QAAW,OAAO,MAAM,KAAK,GAAG,CAAC,CAAC,KAAK;GAEtD,OAAO;EACT;CACF,CAAC;CAIL,OAAO,IACL,uBACA,OAAO,SAAS,UAAU;EACxB,MAAM,QAAQ,KAAK,IAAI,QAAQ,OAAO,EAAE;EAExC,IAAI,UAAU,QAAW,OAAO,SAAS,SAAS,KAAK;EAEvD,OAAO,cAAc,OAAO,QAAQ,OAAO,MAAM,SAAS,OAAO,QAAQ;CAC3E,CACF;CAEA,OAAO,IAA8C,sBAAsB,SAAS,UAAU;EAC5F,MAAM,QAAQ,KAAK,IAAI,QAAQ,OAAO,EAAE;EACxC,MAAM,OAAO,QAAQ,OAAO;EAC5B,MAAM,OACJ,UAAU,SACN,SACA,SAAS,YACP,MAAM,OACN,OAAO,OAAO,MAAM,QAAQ,IAAI,IAC9B,MAAM,OAAO,QACb;EAEV,IAAI,SAAS,QAAW;GACtB,MAAM,KAAK,GAAG,CAAC,CAAC,OAAO,iBAAiB,UAAU,CAAC,CAAC,KAAK;GACzD;EACF;EAEA,MAAM,OAAO,0BAA0B,SAAS;EAChD,SAAS,OAAO,MAAM,iBAAiB,IAAI,CAAC;CAC9C,CAAC;AACH"}
@@ -66,18 +66,15 @@ function registerUiAssets(server, options = {}) {
66
66
  reply.header("Cache-Control", "no-store").header("Content-Type", "text/html; charset=utf-8").send(readFileSync(index));
67
67
  };
68
68
  server.get("/", serveIndex);
69
- server.get("/assets/:name", (request, reply) => {
69
+ server.get("/assets/:name", async (request, reply) => {
70
70
  const asset = Object.hasOwn(UI_ASSETS, request.params.name) ? UI_ASSETS[request.params.name] : void 0;
71
71
  const file = asset?.file();
72
72
  if (!asset || !file || !existsSync(file)) {
73
- if (options.notFound) {
74
- options.notFound(request, reply);
75
- return;
76
- }
77
- reply.code(404).header("Cache-Control", "no-store").send();
78
- return;
73
+ if (options.notFound) return options.notFound(request, reply);
74
+ return reply.code(404).header("Cache-Control", "no-store").send();
79
75
  }
80
76
  sendFile(reply, file, asset.contentType);
77
+ return reply;
81
78
  });
82
79
  }
83
80
 
@@ -1 +1 @@
1
- {"version":3,"file":"ui-assets.mjs","names":[],"sources":["../../../../../../../../packages/devtools/src/server/ui-assets.ts"],"sourcesContent":["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"],"mappings":";;;;;AAaA,MAAM,UAAU,eAAuB,KAAK,KAAK,cAAc,GAAG,IAAI;;;;;AAMtE,MAAM,YAAqC;CACzC,UAAU;EACR,aAAa;EACb,MAAM,OAAO,yBAAyB;CACxC;CACA,WAAW;EAAE,aAAa;EAA2B,MAAM,OAAO,0BAA0B;CAAE;CAC9F,aAAa;EACX,aAAa;EACb,MAAM,OAAO,6BAA6B;CAC5C;CACA,wBAAwB;EACtB,aAAa;EACb,MAAM,OAAO,wCAAwC;CACvD;CACA,kBAAkB;EAChB,aAAa;EACb,MAAM,OAAO,kCAAkC;CACjD;CACA,mBAAmB;EACjB,aAAa;EACb,MAAM,OAAO,iBAAiB;CAChC;AACF;;AAGA,SAAgB,SAAS,OAAqB,MAAc,aAA2B;CACrF,MACG,OAAO,iBAAiB,UAAU,CAAC,CACnC,OAAO,gBAAgB,WAAW,CAAC,CACnC,KAAK,aAAa,IAAI,CAAC;AAC5B;AAEA,MAAM,iBACJ;;;;;;;;;;;;AAaF,SAAgB,iBACd,QACA,UAAyF,CAAC,GACpF;CACN,MAAM,cAAc,SAAyB,UAA8B;EAEzE,MAAM,CAAC,WAAW,IAAI,WAAW,QAAQ,eAAe,QAAQ,IAAG,CAAE,MAAM,GAAG;EAI9E,IAAI,CAAC,SAAS,SAAS,GAAG,GAAG;GAC3B,MAAM,QAAQ,QAAQ,aAAa,OAAO,SAAQ,CAAE,QAAQ,QAAQ,EAAE;GAEtE,MACG,KAAK,GAAG,CAAC,CACT,OAAO,iBAAiB,UAAU,CAAC,CACnC,SAAS,GAAG,KAAK,GAAG,WAAW,SAAY,KAAK,IAAI,YAAY,GAAG;GACtE;EACF;EAEA,MAAM,QAAQ,KAAK,KAAK,cAAc,GAAG,aAAa,YAAY;EAElE,IAAI,CAAC,WAAW,KAAK,GAAG;GACtB,MACG,KAAK,GAAG,CAAC,CACT,OAAO,iBAAiB,UAAU,CAAC,CACnC,OAAO,gBAAgB,0BAA0B,CAAC,CAClD,KAAK,cAAc;GACtB;EACF;EAEA,MACG,OAAO,iBAAiB,UAAU,CAAC,CACnC,OAAO,gBAAgB,0BAA0B,CAAC,CAClD,KAAK,aAAa,KAAK,CAAC;CAC7B;CAEA,OAAO,IAAI,KAAK,UAAU;CAE1B,OAAO,IAAkC,kBAAkB,SAAS,UAAU;EAC5E,MAAM,QAAQ,OAAO,OAAO,WAAW,QAAQ,OAAO,IAAI,IACtD,UAAU,QAAQ,OAAO,QACzB;EACJ,MAAM,OAAO,OAAO,KAAK;EAEzB,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,WAAW,IAAI,GAAG;GACxC,IAAI,QAAQ,UAAU;IACpB,QAAQ,SAAS,SAAS,KAAK;IAC/B;GACF;GAEA,MAAM,KAAK,GAAG,CAAC,CAAC,OAAO,iBAAiB,UAAU,CAAC,CAAC,KAAK;GACzD;EACF;EAEA,SAAS,OAAO,MAAM,MAAM,WAAW;CACzC,CAAC;AACH"}
1
+ {"version":3,"file":"ui-assets.mjs","names":[],"sources":["../../../../../../../../packages/devtools/src/server/ui-assets.ts"],"sourcesContent":["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: {\n notFound?: (\n request: FastifyRequest,\n reply: FastifyReply,\n ) => FastifyReply | Promise<FastifyReply>;\n } = {},\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\", async (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 return options.notFound(request, reply);\n }\n\n return reply.code(404).header(\"Cache-Control\", \"no-store\").send();\n }\n\n sendFile(reply, file, asset.contentType);\n\n return reply;\n });\n}\n"],"mappings":";;;;;AAaA,MAAM,UAAU,eAAuB,KAAK,KAAK,cAAc,GAAG,IAAI;;;;;AAMtE,MAAM,YAAqC;CACzC,UAAU;EACR,aAAa;EACb,MAAM,OAAO,yBAAyB;CACxC;CACA,WAAW;EAAE,aAAa;EAA2B,MAAM,OAAO,0BAA0B;CAAE;CAC9F,aAAa;EACX,aAAa;EACb,MAAM,OAAO,6BAA6B;CAC5C;CACA,wBAAwB;EACtB,aAAa;EACb,MAAM,OAAO,wCAAwC;CACvD;CACA,kBAAkB;EAChB,aAAa;EACb,MAAM,OAAO,kCAAkC;CACjD;CACA,mBAAmB;EACjB,aAAa;EACb,MAAM,OAAO,iBAAiB;CAChC;AACF;;AAGA,SAAgB,SAAS,OAAqB,MAAc,aAA2B;CACrF,MACG,OAAO,iBAAiB,UAAU,CAAC,CACnC,OAAO,gBAAgB,WAAW,CAAC,CACnC,KAAK,aAAa,IAA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CACT,CAAC;AACH"}
@@ -1 +1 @@
1
- {"version":3,"file":"agent-trace-source.d.mts","names":[],"sources":["../../../../../../../../packages/devtools/src/sources/agent-trace-source.ts"],"mappings":";;YAiCY;EAA4B;EAAe;EAAgB;;;YAG3D;EACV;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;IAAS;IAAe;;EACxB;EACA"}
1
+ {"version":3,"file":"agent-trace-source.d.mts","names":[],"sources":["../../../../../../../../packages/devtools/src/sources/agent-trace-source.ts"],"mappings":";;YAmCY;EAA4B;EAAe;EAAgB;;;YAG3D;EACV;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;IAAS;IAAe;;EACxB;EACA"}
@@ -1 +1 @@
1
- {"version":3,"file":"agent-trace-source.mjs","names":[],"sources":["../../../../../../../../packages/devtools/src/sources/agent-trace-source.ts"],"sourcesContent":["import type { DevtoolsDisposer } from \"../types\";\n\n/**\n * Key `@warlock.js/ai` publishes its agent trace store under on\n * `globalThis`. Reading the store from the registry, not by importing the\n * package, keeps devtools free of an AI dependency and shares one store\n * even when two copies of the package are installed.\n */\nexport const AGENT_TRACES_KEY = Symbol.for(\"@warlock.js/ai.agentTraces\");\n\nexport const AGENT_TRACE_INSTALL_GUIDANCE =\n \"No agent traces yet. Install @warlock.js/ai 5.38 or newer and run an agent in development (agents record traces by default there; `trace: true` turns it on elsewhere), then reload.\";\n\n/** The part of `@warlock.js/ai`'s `AgentTrace` this panel reads; the rest passes through untouched. */\nexport type DevtoolsAgentTrace = {\n runId: string;\n agent: string;\n status: string;\n startedAt: string;\n durationMs?: number;\n model: { name: string; provider: string };\n usage: { input: number; output: number; total: number };\n cost?: number;\n turns: Array<{ toolCalls: Array<{ refusal?: string }> }>;\n};\n\n/** The part of `@warlock.js/ai`'s `AgentTraceStore` devtools uses. */\nexport type DevtoolsAgentTraceStore = {\n get(runId: string): DevtoolsAgentTrace | undefined;\n list(filter?: { limit?: number }): DevtoolsAgentTrace[];\n subscribe(listener: (event: { runId: string; status: string }) => void): () => void;\n};\n\nexport type DevtoolsAgentTraceEvent = { runId: string; status: string; requestId?: string };\n\n/** One row of the run list. */\nexport type DevtoolsAgentRun = {\n runId: string;\n agent: string;\n status: string;\n startedAt: string;\n durationMs?: number;\n model: string;\n turns: number;\n toolCalls: number;\n refusals: number;\n usage: { input: number; output: number };\n cost?: number;\n requestId?: string;\n};\n\n/** Reads agent traces from the shared store; the connector builds one in development only. */\nexport type DevtoolsAgentTraceSource = {\n /** `false` until `@warlock.js/ai` has created its store in this process. */\n available(): boolean;\n list(filter?: { requestId?: string }): DevtoolsAgentRun[];\n get(runId: string): DevtoolsAgentTrace | undefined;\n subscribe(listener: (event: DevtoolsAgentTraceEvent) => void): DevtoolsDisposer;\n dispose: DevtoolsDisposer;\n};\n\n/** One list row for a trace. */\nexport function summarizeAgentTrace(\n trace: DevtoolsAgentTrace,\n requestId?: string,\n): DevtoolsAgentRun {\n let toolCalls = 0;\n let refusals = 0;\n\n for (const turn of trace.turns) {\n toolCalls += turn.toolCalls.length;\n refusals += turn.toolCalls.filter((call) => call.refusal !== undefined).length;\n }\n\n return {\n runId: trace.runId,\n agent: trace.agent,\n status: trace.status,\n startedAt: trace.startedAt,\n durationMs: trace.durationMs,\n model: `${trace.model.provider}/${trace.model.name}`,\n turns: trace.turns.length,\n toolCalls,\n refusals,\n usage: { input: trace.usage.input, output: trace.usage.output },\n cost: trace.cost,\n ...(requestId ? { requestId } : {}),\n };\n}\n\nconst MAX_REQUEST_LINKS = 500;\n\n/**\n * Attach to the shared agent trace store. The store is looked up lazily on\n * every call, so it works whichever of devtools and `@warlock.js/ai` loads\n * first. Runs are linked to the HTTP request that was active when the\n * store first reported them.\n */\nexport async function attachAgentTraceSource(): Promise<DevtoolsAgentTraceSource> {\n const { currentRequestId } = await import(\"../current-request-id\");\n const listeners = new Set<(event: DevtoolsAgentTraceEvent) => void>();\n const requestIds = new Map<string, string>();\n let attachedStore: DevtoolsAgentTraceStore | undefined;\n let detach: (() => void) | undefined;\n\n const findStore = (): DevtoolsAgentTraceStore | undefined => {\n const store = (globalThis as { [AGENT_TRACES_KEY]?: DevtoolsAgentTraceStore })[\n AGENT_TRACES_KEY\n ];\n\n return store && typeof store.list === \"function\" ? store : undefined;\n };\n\n const ensureAttached = (): DevtoolsAgentTraceStore | undefined => {\n const store = findStore();\n\n if (store && store !== attachedStore) {\n detach?.();\n attachedStore = store;\n detach = store.subscribe((event) => {\n // Read the request id before anything asynchronous: the store\n // publishes synchronously from inside the agent run.\n let requestId = requestIds.get(event.runId);\n\n if (!requestId) {\n requestId = currentRequestId();\n\n if (requestId) {\n requestIds.set(event.runId, requestId);\n\n if (requestIds.size > MAX_REQUEST_LINKS) {\n const oldest = requestIds.keys().next();\n\n if (!oldest.done) requestIds.delete(oldest.value);\n }\n }\n }\n\n for (const listener of listeners) {\n try {\n listener({ ...event, ...(requestId ? { requestId } : {}) });\n } catch {\n /* isolate clients */\n }\n }\n });\n }\n\n return store;\n };\n\n ensureAttached();\n\n return {\n available: () => ensureAttached() !== undefined,\n\n list(filter) {\n const store = ensureAttached();\n\n if (!store) return [];\n\n return store\n .list()\n .map((trace) => summarizeAgentTrace(trace, requestIds.get(trace.runId)))\n .filter((run) => filter?.requestId === undefined || run.requestId === filter.requestId);\n },\n\n get: (runId) => ensureAttached()?.get(runId),\n\n subscribe(listener) {\n ensureAttached();\n listeners.add(listener);\n\n return () => {\n listeners.delete(listener);\n };\n },\n\n dispose() {\n detach?.();\n detach = undefined;\n attachedStore = undefined;\n listeners.clear();\n requestIds.clear();\n },\n };\n}\n"],"mappings":";;;;;;;AAQA,MAAa,mBAAmB,OAAO,IAAI,4BAA4B;AAEvE,MAAa,+BACX;;AAmDF,SAAgB,oBACd,OACA,WACkB;CAClB,IAAI,YAAY;CAChB,IAAI,WAAW;CAEf,KAAK,MAAM,QAAQ,MAAM,OAAO;EAC9B,aAAa,KAAK,UAAU;EAC5B,YAAY,KAAK,UAAU,QAAQ,SAAS,KAAK,YAA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AEA,eAAe;CAEf,OAAO;EACL,iBAAiB,eAAe,MAAM;EAEtC,KAAK,QAAQ;GACX,MAAM,QAAQ,eAAe;GAE7B,IAAI,CAAC,OAAO,OAAO,CAAC;GAEpB,OAAO,MACJ,KAAK,CAAC,CACN,KAAK,UAAU,oBAAoB,OAAO,WAAW,IAAI,MAAM,KAAK,CAAC,CAAC,CAAC,CACvE,QAAQ,QAAQ,QAAQ,cAAc,UAAa,IAAI,cAAc,OAAO,SAAS;EAC1F;EAEA,MAAM,UAAU,eAAe,CAAC,EAAE,IAAI,KAAK;EAE3C,UAAU,UAAU;GAClB,eAAe;GACf,UAAU,IAAI,QAAQ;GAEtB,aAAa;IACX,UAAU,OAAO,QAAQ;GAC3B;EACF;EAEA,UAAU;GACR,SAAS;GACT,SAAS;GACT,gBAAgB;GAChB,UAAU,MAAM;GAChB,WAAW,MAAM;EACnB;CACF;AACF"}
1
+ {"version":3,"file":"agent-trace-source.mjs","names":[],"sources":["../../../../../../../../packages/devtools/src/sources/agent-trace-source.ts"],"sourcesContent":["import type { DevtoolsDisposer } from \"../types\";\n\n/**\n * Key `@warlock.js/ai` publishes its agent trace store under on\n * `globalThis`. Reading the store from the registry, not by importing the\n * package, keeps devtools free of an AI dependency and shares one store\n * even when two copies of the package are installed.\n */\nexport const AGENT_TRACES_KEY = Symbol.for(\"@warlock.js/ai.agentTraces\");\n\nexport const AGENT_TRACE_INSTALL_GUIDANCE =\n \"No agent traces yet. Install @warlock.js/ai 5.38 or newer and run an agent in development (agents record traces by default there; `trace: true` turns it on elsewhere), then reload.\";\n\n/** The part of `@warlock.js/ai`'s `AgentTrace` this panel reads; the rest passes through untouched. */\nexport type DevtoolsAgentTrace = {\n runId: string;\n agent: string;\n status: string;\n startedAt: string;\n durationMs?: number;\n model: { name: string; provider: string };\n usage: { input: number; output: number; total: number };\n cost?: number;\n /** The system prompt's hash; `text` is kept only when the agent records prompt text (development). */\n systemPrompt?: { hash: string; text?: string };\n turns: Array<{ toolCalls: Array<{ refusal?: string }> }>;\n};\n\n/** The part of `@warlock.js/ai`'s `AgentTraceStore` devtools uses. */\nexport type DevtoolsAgentTraceStore = {\n get(runId: string): DevtoolsAgentTrace | undefined;\n list(filter?: { limit?: number }): DevtoolsAgentTrace[];\n subscribe(listener: (event: { runId: string; status: string }) => void): () => void;\n};\n\nexport type DevtoolsAgentTraceEvent = { runId: string; status: string; requestId?: string };\n\n/** One row of the run list. */\nexport type DevtoolsAgentRun = {\n runId: string;\n agent: string;\n status: string;\n startedAt: string;\n durationMs?: number;\n model: string;\n turns: number;\n toolCalls: number;\n refusals: number;\n usage: { input: number; output: number };\n cost?: number;\n requestId?: string;\n};\n\n/** Reads agent traces from the shared store; the connector builds one in development only. */\nexport type DevtoolsAgentTraceSource = {\n /** `false` until `@warlock.js/ai` has created its store in this process. */\n available(): boolean;\n list(filter?: { requestId?: string }): DevtoolsAgentRun[];\n get(runId: string): DevtoolsAgentTrace | undefined;\n subscribe(listener: (event: DevtoolsAgentTraceEvent) => void): DevtoolsDisposer;\n dispose: DevtoolsDisposer;\n};\n\n/** One list row for a trace. */\nexport function summarizeAgentTrace(\n trace: DevtoolsAgentTrace,\n requestId?: string,\n): DevtoolsAgentRun {\n let toolCalls = 0;\n let refusals = 0;\n\n for (const turn of trace.turns) {\n toolCalls += turn.toolCalls.length;\n refusals += turn.toolCalls.filter((call) => call.refusal !== undefined).length;\n }\n\n return {\n runId: trace.runId,\n agent: trace.agent,\n status: trace.status,\n startedAt: trace.startedAt,\n durationMs: trace.durationMs,\n model: `${trace.model.provider}/${trace.model.name}`,\n turns: trace.turns.length,\n toolCalls,\n refusals,\n usage: { input: trace.usage.input, output: trace.usage.output },\n cost: trace.cost,\n ...(requestId ? { requestId } : {}),\n };\n}\n\nconst MAX_REQUEST_LINKS = 500;\n\n/**\n * Attach to the shared agent trace store. The store is looked up lazily on\n * every call, so it works whichever of devtools and `@warlock.js/ai` loads\n * first. Runs are linked to the HTTP request that was active when the\n * store first reported them.\n */\nexport async function attachAgentTraceSource(): Promise<DevtoolsAgentTraceSource> {\n const { currentRequestId } = await import(\"../current-request-id\");\n const listeners = new Set<(event: DevtoolsAgentTraceEvent) => void>();\n const requestIds = new Map<string, string>();\n let attachedStore: DevtoolsAgentTraceStore | undefined;\n let detach: (() => void) | undefined;\n\n const findStore = (): DevtoolsAgentTraceStore | undefined => {\n const store = (globalThis as { [AGENT_TRACES_KEY]?: DevtoolsAgentTraceStore })[\n AGENT_TRACES_KEY\n ];\n\n return store && typeof store.list === \"function\" ? store : undefined;\n };\n\n const ensureAttached = (): DevtoolsAgentTraceStore | undefined => {\n const store = findStore();\n\n if (store && store !== attachedStore) {\n detach?.();\n attachedStore = store;\n detach = store.subscribe((event) => {\n // Read the request id before anything asynchronous: the store\n // publishes synchronously from inside the agent run.\n let requestId = requestIds.get(event.runId);\n\n if (!requestId) {\n requestId = currentRequestId();\n\n if (requestId) {\n requestIds.set(event.runId, requestId);\n\n if (requestIds.size > MAX_REQUEST_LINKS) {\n const oldest = requestIds.keys().next();\n\n if (!oldest.done) requestIds.delete(oldest.value);\n }\n }\n }\n\n for (const listener of listeners) {\n try {\n listener({ ...event, ...(requestId ? { requestId } : {}) });\n } catch {\n /* isolate clients */\n }\n }\n });\n }\n\n return store;\n };\n\n ensureAttached();\n\n return {\n available: () => ensureAttached() !== undefined,\n\n list(filter) {\n const store = ensureAttached();\n\n if (!store) return [];\n\n return store\n .list()\n .map((trace) => summarizeAgentTrace(trace, requestIds.get(trace.runId)))\n .filter((run) => filter?.requestId === undefined || run.requestId === filter.requestId);\n },\n\n get: (runId) => ensureAttached()?.get(runId),\n\n subscribe(listener) {\n ensureAttached();\n listeners.add(listener);\n\n return () => {\n listeners.delete(listener);\n };\n },\n\n dispose() {\n detach?.();\n detach = undefined;\n attachedStore = undefined;\n listeners.clear();\n requestIds.clear();\n },\n };\n}\n"],"mappings":";;;;;;;AAQA,MAAa,mBAAmB,OAAO,IAAI,4BAA4B;AAEvE,MAAa,+BACX;;AA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F;IACF;IAEA,KAAK,MAAM,YAAY,WACrB,IAAI;KACF,SAAS;MAAE,GAAG;MAAO,GAAI,YAAY,EAAE,UAAU,IAAI,CAAC;KAAG,CAAC;IAC5D,QAAQ,CAER;GAEJ,CAAC;EACH;EAEA,OAAO;CACT;CAEA,eAAe;CAEf,OAAO;EACL,iBAAiB,eAAe,MAAM;EAEtC,KAAK,QAAQ;GACX,MAAM,QAAQ,eAAe;GAE7B,IAAI,CAAC,OAAO,OAAO,CAAC;GAEpB,OAAO,MACJ,KAAK,CAAC,CACN,KAAK,UAAU,oBAAoB,OAAO,WAAW,IAAI,MAAM,KAAK,CAAC,CAAC,CAAC,CACvE,QAAQ,QAAQ,QAAQ,cAAc,UAAa,IAAI,cAAc,OAAO,SAAS;EAC1F;EAEA,MAAM,UAAU,eAAe,CAAC,EAAE,IAAI,KAAK;EAE3C,UAAU,UAAU;GAClB,eAAe;GACf,UAAU,IAAI,QAAQ;GAEtB,aAAa;IACX,UAAU,OAAO,QAAQ;GAC3B;EACF;EAEA,UAAU;GACR,SAAS;GACT,SAAS;GACT,gBAAgB;GAChB,UAAU,MAAM;GAChB,WAAW,MAAM;EACnB;CACF;AACF"}
@@ -1,3 +1,5 @@
1
+ import "../ai/types.mjs";
2
+ import "../ai/reports/runs.mjs";
1
3
  import "../types.mjs";
2
4
  import { Trace, TraceSpan } from "@warlock.js/ai-panoptic";
3
5
  //#region ../../packages/devtools/src/sources/ai-source.d.ts
@@ -1 +1 @@
1
- {"version":3,"file":"ai-source.d.mts","names":[],"sources":["../../../../../../../../packages/devtools/src/sources/ai-source.ts"],"mappings":";;;YA0FY;EAAoB;EAAiB;;YAerC;EACV;EACA;EACA;EACA;EACA,QAAQ;EACR;EACA;EACA,OAAO;EACP;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA"}
1
+ {"version":3,"file":"ai-source.d.mts","names":[],"sources":["../../../../../../../../packages/devtools/src/sources/ai-source.ts"],"mappings":";;;;;YA2HY;EAAoB;EAAiB;;YAmBrC;EACV;EACA;EACA;EACA;EACA,QAAQ;EACR;EACA;EACA,OAAO;EACP;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA"}
@@ -39,7 +39,20 @@ function describeAiUnavailable(reason, detail) {
39
39
  available: false,
40
40
  reason,
41
41
  title: "AI runs are not collected here",
42
- message: "The production dashboard does not collect AI runs. Open the AI tab in development (warlock dev) to see them."
42
+ message: "Production keeps hourly AI totals, not run details. Open Reports, Models or Errors here, or the Runs tab in development (warlock dev)."
43
+ };
44
+ case "table-missing": return {
45
+ available: false,
46
+ reason,
47
+ title: "AI reports need their table",
48
+ message: "Run the devtools migrations to create devtools_ai_rollups, then restart the app.",
49
+ command: "warlock migrate"
50
+ };
51
+ case "reports-off": return {
52
+ available: false,
53
+ reason,
54
+ title: "AI reports are off",
55
+ message: "Set devtools.ai.reports to true in src/config/devtools.ts to keep hourly AI totals."
43
56
  };
44
57
  case "observation-off": return {
45
58
  available: false,
@@ -50,6 +63,17 @@ function describeAiUnavailable(reason, detail) {
50
63
  };
51
64
  }
52
65
  }
66
+ /** The unavailable answer as the AI routes send it: `command` and `detail` are `null` when absent. */
67
+ function toAiUnavailableView(unavailable) {
68
+ return {
69
+ available: false,
70
+ reason: unavailable.reason,
71
+ title: unavailable.title,
72
+ message: unavailable.message,
73
+ command: unavailable.command ?? null,
74
+ detail: unavailable.detail ?? null
75
+ };
76
+ }
53
77
  /** Summaries use root usage once: nested spans already roll up into it. */
54
78
  function summarizeAiTrace(trace, cost) {
55
79
  const models = /* @__PURE__ */ new Set();
@@ -128,10 +152,11 @@ function snapshotSpan(span) {
128
152
  };
129
153
  }
130
154
  /**
131
- * Optional, lazy integration. Retains only traces collected after devtools boots,
132
- * using Panoptic's bounded query store; existing exporter/cache stores stay independent.
155
+ * Loads Panoptic (required) and `@warlock.js/ai` (for the observation check)
156
+ * lazily, or says why not. Shared by the development source and the AI
157
+ * reports wiring, so both answer the same unavailable reasons.
133
158
  */
134
- async function attachAiSource(capacity, deps = {}) {
159
+ async function loadAiPackages(deps = {}) {
135
160
  const aiPackage = "@warlock.js/ai";
136
161
  const load = deps.load ?? ((name) => name === "@warlock.js/ai-panoptic" ? import("@warlock.js/ai-panoptic") : import(aiPackage));
137
162
  const version = deps.version ?? ((name) => installedVersion(name, process.cwd(), import.meta.resolve));
@@ -142,18 +167,9 @@ async function attachAiSource(capacity, deps = {}) {
142
167
  } catch (error) {
143
168
  const aiVersion = version("@warlock.js/ai");
144
169
  const panopticVersion = version("@warlock.js/ai-panoptic");
145
- if (aiVersion === null) return {
146
- ...describeAiUnavailable("ai-missing"),
147
- dispose() {}
148
- };
149
- if (panopticVersion === null) return {
150
- ...describeAiUnavailable("panoptic-missing"),
151
- dispose() {}
152
- };
153
- return {
154
- ...describeAiUnavailable("panoptic-failed", `${redactPaths((error instanceof Error ? error.message : String(error)).split("\n")[0] ?? "").slice(0, 300)} (@warlock.js/ai ${aiVersion}, @warlock.js/ai-panoptic ${panopticVersion})`),
155
- dispose() {}
156
- };
170
+ if (aiVersion === null) return { unavailable: describeAiUnavailable("ai-missing") };
171
+ if (panopticVersion === null) return { unavailable: describeAiUnavailable("panoptic-missing") };
172
+ return { unavailable: describeAiUnavailable("panoptic-failed", `${redactPaths((error instanceof Error ? error.message : String(error)).split("\n")[0] ?? "").slice(0, 300)} (@warlock.js/ai ${aiVersion}, @warlock.js/ai-panoptic ${panopticVersion})`) };
157
173
  }
158
174
  let core;
159
175
  try {
@@ -162,6 +178,22 @@ async function attachAiSource(capacity, deps = {}) {
162
178
  core = void 0;
163
179
  }
164
180
  const observationOff = () => typeof core?.isObserveAll === "function" && typeof core.getObservers === "function" && !core.isObserveAll() && core.getObservers().length === 0;
181
+ return {
182
+ panoptic,
183
+ observationOff
184
+ };
185
+ }
186
+ /**
187
+ * Optional, lazy integration. Retains only traces collected after devtools boots,
188
+ * using Panoptic's bounded query store; existing exporter/cache stores stay independent.
189
+ */
190
+ async function attachAiSource(capacity, deps = {}) {
191
+ const loaded = await loadAiPackages(deps);
192
+ if ("unavailable" in loaded) return {
193
+ ...loaded.unavailable,
194
+ dispose() {}
195
+ };
196
+ const { panoptic, observationOff } = loaded;
165
197
  const { currentRequestId } = await import("../current-request-id.mjs");
166
198
  const store = panoptic.createInMemoryTraceStore({ capacity });
167
199
  const listeners = /* @__PURE__ */ new Set();
@@ -183,6 +215,15 @@ async function attachAiSource(capacity, deps = {}) {
183
215
  return {
184
216
  available: true,
185
217
  observationOff,
218
+ totalCost: (usage) => panoptic.totalCostUsd(usage),
219
+ helpers: {
220
+ filterTraces: panoptic.filterTraces,
221
+ groupBySession: panoptic.groupBySession,
222
+ groupByPrompt: panoptic.groupByPrompt,
223
+ groupByType: panoptic.groupByType,
224
+ percentile: panoptic.percentile,
225
+ tracePromptKey: panoptic.tracePromptKey
226
+ },
186
227
  store,
187
228
  summarize: (trace) => summarizeAiTrace(trace, panoptic.totalCostUsd(trace.usage)),
188
229
  subscribe(listener) {
@@ -200,5 +241,5 @@ async function attachAiSource(capacity, deps = {}) {
200
241
  }
201
242
 
202
243
  //#endregion
203
- export { attachAiSource, describeAiUnavailable, redactPaths, summarizeAiTrace };
244
+ export { attachAiSource, describeAiUnavailable, loadAiPackages, redactPaths, summarizeAiTrace, toAiUnavailableView };
204
245
  //# sourceMappingURL=ai-source.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"ai-source.mjs","names":[],"sources":["../../../../../../../../packages/devtools/src/sources/ai-source.ts"],"sourcesContent":["import type { Trace, TraceSpan, TraceStoreContract } from \"@warlock.js/ai-panoptic\";\nimport { installedVersion } from \"../app-versions\";\nimport { toSafeValue } from \"../safe-value\";\nimport type { DevtoolsDisposer } from \"../types\";\n\nexport type DevtoolsAiUnavailableReason =\n | \"ai-missing\"\n | \"panoptic-missing\"\n | \"panoptic-failed\"\n | \"observation-off\"\n | \"not-collected\";\n\n/** Why the AI tab is empty, as sent to the dashboard: a title, one line and an optional command. */\nexport type DevtoolsAiUnavailable = {\n available: false;\n reason: DevtoolsAiUnavailableReason;\n title: string;\n message: string;\n command?: string;\n detail?: string;\n};\n\n/** Replaces absolute file paths in an error line with their package-relative part, or `<path>`. */\nexport function redactPaths(text: string): string {\n return text.replace(/(?:file:\\/\\/)?(?:[A-Za-z]:)?[\\\\/][^\\s'\"`()]*/g, (match) => {\n const normalized = match.replace(/^file:\\/\\//, \"\").replaceAll(\"\\\\\", \"/\");\n const index = normalized.lastIndexOf(\"node_modules/\");\n\n return index === -1 ? \"<path>\" : normalized.slice(index + \"node_modules/\".length);\n });\n}\n\nconst OBSERVATION_COMMAND = \"ai.config({ panoptic: { observeAll: true } })\";\n\n/** The answer for each reason; `detail` carries the load error and versions for `panoptic-failed`. */\nexport function describeAiUnavailable(\n reason: DevtoolsAiUnavailableReason,\n detail?: string,\n): DevtoolsAiUnavailable {\n switch (reason) {\n case \"ai-missing\":\n return {\n available: false,\n reason,\n title: \"AI isn't installed\",\n message: \"Add @warlock.js/ai to see AI runs here.\",\n command: \"warlock add ai\",\n };\n case \"panoptic-missing\":\n return {\n available: false,\n reason,\n title: \"Panoptic isn't installed\",\n message: \"Your app uses @warlock.js/ai. Add Panoptic to see its runs.\",\n command: \"warlock add ai-panoptic\",\n };\n case \"panoptic-failed\":\n return {\n available: false,\n reason,\n title: \"Panoptic could not be loaded\",\n message:\n \"Panoptic is installed but failed to load. Check that both packages share a version.\",\n detail,\n };\n case \"not-collected\":\n return {\n available: false,\n reason,\n title: \"AI runs are not collected here\",\n message:\n \"The production dashboard does not collect AI runs. Open the AI tab in development (warlock dev) to see them.\",\n };\n case \"observation-off\":\n return {\n available: false,\n reason,\n title: \"AI observation is off\",\n message: \"Turn it on in src/config/ai.ts, then restart warlock dev.\",\n command: OBSERVATION_COMMAND,\n };\n }\n}\n\n/** Test seam: how packages are loaded and their versions read. */\nexport type AiSourceDeps = {\n load?: (name: string) => Promise<unknown>;\n version?: (name: string) => string | null;\n};\n\nexport type DevtoolsAiEvent = { traceId: string; requestId?: string };\n\n/** Only the connector's development branch constructs this source. */\nexport type DevtoolsAiSource =\n | (DevtoolsAiUnavailable & { dispose: DevtoolsDisposer })\n | {\n available: true;\n /** True when `@warlock.js/ai` has no `observeAll` and no registered observer (read per request). */\n observationOff?: () => boolean;\n store: TraceStoreContract;\n summarize: (trace: Trace) => DevtoolsAiRun;\n subscribe: (listener: (event: DevtoolsAiEvent) => void) => DevtoolsDisposer;\n dispose: DevtoolsDisposer;\n };\n\nexport type DevtoolsAiRun = {\n traceId: string;\n requestId?: string;\n sessionId?: string;\n name: string;\n status: TraceSpan[\"status\"];\n startedAt: string;\n duration: number;\n usage: Trace[\"usage\"];\n cost?: number;\n models: string[];\n toolCalls: number;\n retries: number;\n cacheHits?: number;\n incomplete: boolean;\n truncatedTrips: number;\n compactions: number;\n skippedCompactions: number;\n providerCompactions: number;\n};\n\n/** Summaries use root usage once: nested spans already roll up into it. */\nexport function summarizeAiTrace(trace: Trace, cost?: number): DevtoolsAiRun {\n const models = new Set<string>();\n let toolCalls = 0;\n let retries = 0;\n let cacheHits: number | undefined;\n let incomplete = false;\n let truncatedTrips = 0;\n let compactions = 0;\n let skippedCompactions = 0;\n let providerCompactions = 0;\n const visit = (span: TraceSpan): void => {\n const attributes = span.attributes ?? {};\n const model = attributes[\"agent.model.name\"];\n const provider = attributes[\"agent.model.provider\"];\n if (typeof model === \"string\")\n models.add(typeof provider === \"string\" ? `${provider}/${model}` : model);\n if (span.type === \"tool\") toolCalls += 1;\n if (typeof attributes.retries === \"number\") retries += attributes.retries;\n if (typeof attributes[\"agent.cacheHits\"] === \"number\")\n cacheHits = (cacheHits ?? 0) + attributes[\"agent.cacheHits\"];\n if (typeof attributes[\"agent.truncatedTrips\"] === \"number\")\n truncatedTrips += attributes[\"agent.truncatedTrips\"];\n if (typeof attributes[\"agent.providerCompactions\"] === \"number\")\n providerCompactions += attributes[\"agent.providerCompactions\"];\n if (Array.isArray(attributes[\"agent.compactions\"])) {\n const records: unknown[] = attributes[\"agent.compactions\"];\n for (const record of records) {\n if (typeof record !== \"object\" || record === null || !(\"type\" in record)) continue;\n if (record.type === \"applied\") compactions += 1;\n if (record.type === \"skipped\") skippedCompactions += 1;\n }\n }\n incomplete ||=\n span.status === \"incomplete\" ||\n span.error?.type === \"AgentIncompleteError\" ||\n span.error?.type === \"AGENT_INCOMPLETE\";\n span.children.forEach(visit);\n };\n visit(trace.root);\n return {\n traceId: trace.traceId,\n requestId: trace.requestId,\n sessionId: trace.sessionId,\n name: trace.root.name,\n status: trace.root.status,\n startedAt: trace.startedAt,\n duration: trace.duration,\n usage: trace.usage,\n cost,\n models: [...models],\n toolCalls,\n retries,\n cacheHits,\n incomplete,\n truncatedTrips,\n compactions,\n skippedCompactions,\n providerCompactions,\n };\n}\n\n/** Content-free snapshot; never retain prompts, completions or tool arguments/results. */\nfunction snapshotSpan(span: TraceSpan): TraceSpan {\n return {\n spanId: span.spanId,\n parentSpanId: span.parentSpanId,\n traceId: span.traceId,\n sessionId: span.sessionId,\n name: span.name,\n version: span.version,\n type: span.type,\n status: span.status,\n startedAt: span.startedAt,\n endedAt: span.endedAt,\n duration: span.duration,\n usage: structuredClone(span.usage),\n error: span.error ? { type: span.error.type, message: span.error.message } : undefined,\n attributes: toSafeValue(span.attributes) as Record<string, unknown> | undefined,\n children: span.children.map(snapshotSpan),\n };\n}\n\n/**\n * Optional, lazy integration. Retains only traces collected after devtools boots,\n * using Panoptic's bounded query store; existing exporter/cache stores stay independent.\n */\nexport async function attachAiSource(\n capacity: number,\n deps: AiSourceDeps = {},\n): Promise<DevtoolsAiSource> {\n const aiPackage: string = \"@warlock.js/ai\"; // not a dependency of devtools: never resolved at build time\n const load =\n deps.load ??\n ((name: string) =>\n name === \"@warlock.js/ai-panoptic\" ? import(\"@warlock.js/ai-panoptic\") : import(aiPackage));\n const version =\n deps.version ?? ((name: string) => installedVersion(name, process.cwd(), import.meta.resolve));\n let panoptic: typeof import(\"@warlock.js/ai-panoptic\");\n try {\n panoptic = (await load(\"@warlock.js/ai-panoptic\")) as typeof panoptic;\n if (typeof panoptic.subscribeTraces !== \"function\")\n throw new Error(\"Trace subscription unavailable\");\n } catch (error) {\n const aiVersion = version(\"@warlock.js/ai\");\n const panopticVersion = version(\"@warlock.js/ai-panoptic\");\n if (aiVersion === null) return { ...describeAiUnavailable(\"ai-missing\"), dispose() {} };\n if (panopticVersion === null)\n return { ...describeAiUnavailable(\"panoptic-missing\"), dispose() {} };\n const text = redactPaths(\n (error instanceof Error ? error.message : String(error)).split(\"\\n\")[0] ?? \"\",\n ).slice(0, 300);\n return {\n ...describeAiUnavailable(\n \"panoptic-failed\",\n `${text} (@warlock.js/ai ${aiVersion}, @warlock.js/ai-panoptic ${panopticVersion})`,\n ),\n dispose() {},\n };\n }\n\n let core: { isObserveAll?: () => boolean; getObservers?: () => readonly unknown[] } | undefined;\n try {\n core = (await load(\"@warlock.js/ai\")) as typeof core;\n } catch {\n core = undefined;\n }\n const observationOff = (): boolean =>\n typeof core?.isObserveAll === \"function\" &&\n typeof core.getObservers === \"function\" &&\n !core.isObserveAll() &&\n core.getObservers().length === 0;\n\n const { currentRequestId } = await import(\"../current-request-id\");\n const store = panoptic.createInMemoryTraceStore({ capacity });\n const listeners = new Set<(event: DevtoolsAiEvent) => void>();\n const detach = panoptic.subscribeTraces((trace) => {\n // Read ALS before any asynchronous exporter work, including for runs that\n // finish after the HTTP response. Never use sessionId as a request id.\n const requestId = currentRequestId() ?? trace.requestId;\n store.add({\n ...trace,\n requestId,\n usage: structuredClone(trace.usage),\n root: snapshotSpan(trace.root),\n });\n for (const listener of listeners) {\n try {\n listener({ traceId: trace.traceId, requestId });\n } catch {\n /* isolate clients */\n }\n }\n });\n\n return {\n available: true,\n observationOff,\n store,\n summarize: (trace) => summarizeAiTrace(trace, panoptic.totalCostUsd(trace.usage)),\n subscribe(listener) {\n listeners.add(listener);\n return () => {\n listeners.delete(listener);\n };\n },\n dispose() {\n detach();\n listeners.clear();\n store.clear();\n },\n };\n}\n"],"mappings":";;;;;AA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AAI;GACR,GAAG;GACH;GACA,OAAO,gBAAgB,MAAM,KAAK;GAClC,MAAM,aAAa,MAAM,IAAI;EAC/B,CAAC;EACD,KAAK,MAAM,YAAY,WACrB,IAAI;GACF,SAAS;IAAE,SAAS,MAAM;IAAS;GAAU,CAAC;EAChD,QAAQ,CAER;CAEJ,CAAC;CAED,OAAO;EACL,WAAW;EACX;EACA;EACA,YAAY,UAAU,iBAAiB,OAAO,SAAS,aAAa,MAAM,KAAK,CAAC;EAChF,UAAU,UAAU;GAClB,UAAU,IAAI,QAAQ;GACtB,aAAa;IACX,UAAU,OAAO,QAAQ;GAC3B;EACF;EACA,UAAU;GACR,OAAO;GACP,UAAU,MAAM;GAChB,MAAM,MAAM;EACd;CACF;AACF"}
1
+ {"version":3,"file":"ai-source.mjs","names":[],"sources":["../../../../../../../../packages/devtools/src/sources/ai-source.ts"],"sourcesContent":["import type { Trace, TraceSpan, TraceStoreContract } from \"@warlock.js/ai-panoptic\";\nimport { installedVersion } from \"../app-versions\";\nimport type { DevtoolsAiRunHelpers } from \"../ai/reports/runs\";\nimport type { DevtoolsAiTotalCost } from \"../ai/types\";\nimport type { DevtoolsAiUnavailableView } from \"../production/contracts\";\nimport { toSafeValue } from \"../safe-value\";\nimport type { DevtoolsDisposer } from \"../types\";\n\nexport type DevtoolsAiUnavailableReason =\n | \"ai-missing\"\n | \"panoptic-missing\"\n | \"panoptic-failed\"\n | \"observation-off\"\n | \"not-collected\"\n | \"table-missing\"\n | \"reports-off\";\n\n/** Why the AI tab is empty, as sent to the dashboard: a title, one line and an optional command. */\nexport type DevtoolsAiUnavailable = {\n available: false;\n reason: DevtoolsAiUnavailableReason;\n title: string;\n message: string;\n command?: string;\n detail?: string;\n};\n\n/** Replaces absolute file paths in an error line with their package-relative part, or `<path>`. */\nexport function redactPaths(text: string): string {\n return text.replace(/(?:file:\\/\\/)?(?:[A-Za-z]:)?[\\\\/][^\\s'\"`()]*/g, (match) => {\n const normalized = match.replace(/^file:\\/\\//, \"\").replaceAll(\"\\\\\", \"/\");\n const index = normalized.lastIndexOf(\"node_modules/\");\n\n return index === -1 ? \"<path>\" : normalized.slice(index + \"node_modules/\".length);\n });\n}\n\nconst OBSERVATION_COMMAND = \"ai.config({ panoptic: { observeAll: true } })\";\n\n/** The answer for each reason; `detail` carries the load error and versions for `panoptic-failed`. */\nexport function describeAiUnavailable(\n reason: DevtoolsAiUnavailableReason,\n detail?: string,\n): DevtoolsAiUnavailable {\n switch (reason) {\n case \"ai-missing\":\n return {\n available: false,\n reason,\n title: \"AI isn't installed\",\n message: \"Add @warlock.js/ai to see AI runs here.\",\n command: \"warlock add ai\",\n };\n case \"panoptic-missing\":\n return {\n available: false,\n reason,\n title: \"Panoptic isn't installed\",\n message: \"Your app uses @warlock.js/ai. Add Panoptic to see its runs.\",\n command: \"warlock add ai-panoptic\",\n };\n case \"panoptic-failed\":\n return {\n available: false,\n reason,\n title: \"Panoptic could not be loaded\",\n message:\n \"Panoptic is installed but failed to load. Check that both packages share a version.\",\n detail,\n };\n case \"not-collected\":\n return {\n available: false,\n reason,\n title: \"AI runs are not collected here\",\n message:\n \"Production keeps hourly AI totals, not run details. Open Reports, Models or Errors here, or the Runs tab in development (warlock dev).\",\n };\n case \"table-missing\":\n return {\n available: false,\n reason,\n title: \"AI reports need their table\",\n message: \"Run the devtools migrations to create devtools_ai_rollups, then restart the app.\",\n command: \"warlock migrate\",\n };\n case \"reports-off\":\n return {\n available: false,\n reason,\n title: \"AI reports are off\",\n message:\n \"Set devtools.ai.reports to true in src/config/devtools.ts to keep hourly AI totals.\",\n };\n case \"observation-off\":\n return {\n available: false,\n reason,\n title: \"AI observation is off\",\n message: \"Turn it on in src/config/ai.ts, then restart warlock dev.\",\n command: OBSERVATION_COMMAND,\n };\n }\n}\n\n/** The unavailable answer as the AI routes send it: `command` and `detail` are `null` when absent. */\nexport function toAiUnavailableView(unavailable: DevtoolsAiUnavailable): DevtoolsAiUnavailableView {\n return {\n available: false,\n reason: unavailable.reason,\n title: unavailable.title,\n message: unavailable.message,\n command: unavailable.command ?? null,\n detail: unavailable.detail ?? null,\n };\n}\n\n/** Test seam: how packages are loaded and their versions read. */\nexport type AiSourceDeps = {\n load?: (name: string) => Promise<unknown>;\n version?: (name: string) => string | null;\n};\n\nexport type DevtoolsAiEvent = { traceId: string; requestId?: string };\n\n/** Only the connector's development branch constructs this source. */\nexport type DevtoolsAiSource =\n | (DevtoolsAiUnavailable & { dispose: DevtoolsDisposer })\n | {\n available: true;\n /** True when `@warlock.js/ai` has no `observeAll` and no registered observer (read per request). */\n observationOff?: () => boolean;\n /** Totals a trace's priced usage (Panoptic's `totalCostUsd`). */\n totalCost: DevtoolsAiTotalCost;\n /** Panoptic's trace filter, grouping and percentile helpers for the Runs list. */\n helpers: DevtoolsAiRunHelpers;\n store: TraceStoreContract;\n summarize: (trace: Trace) => DevtoolsAiRun;\n subscribe: (listener: (event: DevtoolsAiEvent) => void) => DevtoolsDisposer;\n dispose: DevtoolsDisposer;\n };\n\nexport type DevtoolsAiRun = {\n traceId: string;\n requestId?: string;\n sessionId?: string;\n name: string;\n status: TraceSpan[\"status\"];\n startedAt: string;\n duration: number;\n usage: Trace[\"usage\"];\n cost?: number;\n models: string[];\n toolCalls: number;\n retries: number;\n cacheHits?: number;\n incomplete: boolean;\n truncatedTrips: number;\n compactions: number;\n skippedCompactions: number;\n providerCompactions: number;\n};\n\n/** Summaries use root usage once: nested spans already roll up into it. */\nexport function summarizeAiTrace(trace: Trace, cost?: number): DevtoolsAiRun {\n const models = new Set<string>();\n let toolCalls = 0;\n let retries = 0;\n let cacheHits: number | undefined;\n let incomplete = false;\n let truncatedTrips = 0;\n let compactions = 0;\n let skippedCompactions = 0;\n let providerCompactions = 0;\n const visit = (span: TraceSpan): void => {\n const attributes = span.attributes ?? {};\n const model = attributes[\"agent.model.name\"];\n const provider = attributes[\"agent.model.provider\"];\n if (typeof model === \"string\")\n models.add(typeof provider === \"string\" ? `${provider}/${model}` : model);\n if (span.type === \"tool\") toolCalls += 1;\n if (typeof attributes.retries === \"number\") retries += attributes.retries;\n if (typeof attributes[\"agent.cacheHits\"] === \"number\")\n cacheHits = (cacheHits ?? 0) + attributes[\"agent.cacheHits\"];\n if (typeof attributes[\"agent.truncatedTrips\"] === \"number\")\n truncatedTrips += attributes[\"agent.truncatedTrips\"];\n if (typeof attributes[\"agent.providerCompactions\"] === \"number\")\n providerCompactions += attributes[\"agent.providerCompactions\"];\n if (Array.isArray(attributes[\"agent.compactions\"])) {\n const records: unknown[] = attributes[\"agent.compactions\"];\n for (const record of records) {\n if (typeof record !== \"object\" || record === null || !(\"type\" in record)) continue;\n if (record.type === \"applied\") compactions += 1;\n if (record.type === \"skipped\") skippedCompactions += 1;\n }\n }\n incomplete ||=\n span.status === \"incomplete\" ||\n span.error?.type === \"AgentIncompleteError\" ||\n span.error?.type === \"AGENT_INCOMPLETE\";\n span.children.forEach(visit);\n };\n visit(trace.root);\n return {\n traceId: trace.traceId,\n requestId: trace.requestId,\n sessionId: trace.sessionId,\n name: trace.root.name,\n status: trace.root.status,\n startedAt: trace.startedAt,\n duration: trace.duration,\n usage: trace.usage,\n cost,\n models: [...models],\n toolCalls,\n retries,\n cacheHits,\n incomplete,\n truncatedTrips,\n compactions,\n skippedCompactions,\n providerCompactions,\n };\n}\n\n/** Content-free snapshot; never retain prompts, completions or tool arguments/results. */\nfunction snapshotSpan(span: TraceSpan): TraceSpan {\n return {\n spanId: span.spanId,\n parentSpanId: span.parentSpanId,\n traceId: span.traceId,\n sessionId: span.sessionId,\n name: span.name,\n version: span.version,\n type: span.type,\n status: span.status,\n startedAt: span.startedAt,\n endedAt: span.endedAt,\n duration: span.duration,\n usage: structuredClone(span.usage),\n error: span.error ? { type: span.error.type, message: span.error.message } : undefined,\n attributes: toSafeValue(span.attributes) as Record<string, unknown> | undefined,\n children: span.children.map(snapshotSpan),\n };\n}\n\ntype PanopticModule = typeof import(\"@warlock.js/ai-panoptic\");\ntype AiCoreModule = { isObserveAll?: () => boolean; getObservers?: () => readonly unknown[] };\n\n/**\n * Loads Panoptic (required) and `@warlock.js/ai` (for the observation check)\n * lazily, or says why not. Shared by the development source and the AI\n * reports wiring, so both answer the same unavailable reasons.\n */\nexport async function loadAiPackages(\n deps: AiSourceDeps = {},\n): Promise<\n | { panoptic: PanopticModule; observationOff: () => boolean }\n | { unavailable: DevtoolsAiUnavailable }\n> {\n const aiPackage: string = \"@warlock.js/ai\"; // not a dependency of devtools: never resolved at build time\n const load =\n deps.load ??\n ((name: string) =>\n name === \"@warlock.js/ai-panoptic\" ? import(\"@warlock.js/ai-panoptic\") : import(aiPackage));\n const version =\n deps.version ?? ((name: string) => installedVersion(name, process.cwd(), import.meta.resolve));\n let panoptic: PanopticModule;\n try {\n panoptic = (await load(\"@warlock.js/ai-panoptic\")) as PanopticModule;\n if (typeof panoptic.subscribeTraces !== \"function\")\n throw new Error(\"Trace subscription unavailable\");\n } catch (error) {\n const aiVersion = version(\"@warlock.js/ai\");\n const panopticVersion = version(\"@warlock.js/ai-panoptic\");\n if (aiVersion === null) return { unavailable: describeAiUnavailable(\"ai-missing\") };\n if (panopticVersion === null) return { unavailable: describeAiUnavailable(\"panoptic-missing\") };\n const text = redactPaths(\n (error instanceof Error ? error.message : String(error)).split(\"\\n\")[0] ?? \"\",\n ).slice(0, 300);\n return {\n unavailable: describeAiUnavailable(\n \"panoptic-failed\",\n `${text} (@warlock.js/ai ${aiVersion}, @warlock.js/ai-panoptic ${panopticVersion})`,\n ),\n };\n }\n\n let core: AiCoreModule | undefined;\n try {\n core = (await load(\"@warlock.js/ai\")) as AiCoreModule;\n } catch {\n core = undefined;\n }\n const observationOff = (): boolean =>\n typeof core?.isObserveAll === \"function\" &&\n typeof core.getObservers === \"function\" &&\n !core.isObserveAll() &&\n core.getObservers().length === 0;\n\n return { panoptic, observationOff };\n}\n\n/**\n * Optional, lazy integration. Retains only traces collected after devtools boots,\n * using Panoptic's bounded query store; existing exporter/cache stores stay independent.\n */\nexport async function attachAiSource(\n capacity: number,\n deps: AiSourceDeps = {},\n): Promise<DevtoolsAiSource> {\n const loaded = await loadAiPackages(deps);\n if (\"unavailable\" in loaded) return { ...loaded.unavailable, dispose() {} };\n const { panoptic, observationOff } = loaded;\n\n const { currentRequestId } = await import(\"../current-request-id\");\n const store = panoptic.createInMemoryTraceStore({ capacity });\n const listeners = new Set<(event: DevtoolsAiEvent) => void>();\n const detach = panoptic.subscribeTraces((trace) => {\n // Read ALS before any asynchronous exporter work, including for runs that\n // finish after the HTTP response. Never use sessionId as a request id.\n const requestId = currentRequestId() ?? trace.requestId;\n store.add({\n ...trace,\n requestId,\n usage: structuredClone(trace.usage),\n root: snapshotSpan(trace.root),\n });\n for (const listener of listeners) {\n try {\n listener({ traceId: trace.traceId, requestId });\n } catch {\n /* isolate clients */\n }\n }\n });\n\n return {\n available: true,\n observationOff,\n totalCost: (usage) => panoptic.totalCostUsd(usage),\n helpers: {\n filterTraces: panoptic.filterTraces,\n groupBySession: panoptic.groupBySession,\n groupByPrompt: panoptic.groupByPrompt,\n groupByType: panoptic.groupByType,\n percentile: panoptic.percentile,\n tracePromptKey: panoptic.tracePromptKey,\n },\n store,\n summarize: (trace) => summarizeAiTrace(trace, panoptic.totalCostUsd(trace.usage)),\n subscribe(listener) {\n listeners.add(listener);\n return () => {\n listeners.delete(listener);\n };\n },\n dispose() {\n detach();\n listeners.clear();\n store.clear();\n },\n };\n}\n"],"mappings":";;;;;AA4BA,SAAgB,YAAY,MAAsB;CAChD,OAAO,KAAK,QAAQ,kDAAkD,UAAU;EAC9E,MAAM,aAAa,MAAM,QAAQ,cAAc,EAAE,CAAC,CAAC,WAAW,MAAM,GAAG;EACvE,MAAM,QAAQ,WAAW,YAAY,eAAe;EAEpD,OAAO,UAAU,KAAK,WAAW,WAAW,MAAM,QAAQ,EAAsB;CAClF,CAAC;AACH;AAEA,MAAM,sBAAsB;;AAG5B,SAAgB,sBACd,QACA,QACuB;CACvB,QAAQ,QAAR;EACE,KAAK,cACH,OAA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AS,CAAC;CAC5D,MAAM,4BAAY,IAAI,IAAsC;CAC5D,MAAM,SAAS,SAAS,iBAAiB,UAAU;EAGjD,MAAM,YAAY,iBAAiB,KAAK,MAAM;EAC9C,MAAM,IAAI;GACR,GAAG;GACH;GACA,OAAO,gBAAgB,MAAM,KAAK;GAClC,MAAM,aAAa,MAAM,IAAI;EAC/B,CAAC;EACD,KAAK,MAAM,YAAY,WACrB,IAAI;GACF,SAAS;IAAE,SAAS,MAAM;IAAS;GAAU,CAAC;EAChD,QAAQ,CAER;CAEJ,CAAC;CAED,OAAO;EACL,WAAW;EACX;EACA,YAAY,UAAU,SAAS,aAAa,KAAK;EACjD,SAAS;GACP,cAAc,SAAS;GACvB,gBAAgB,SAAS;GACzB,eAAe,SAAS;GACxB,aAAa,SAAS;GACtB,YAAY,SAAS;GACrB,gBAAgB,SAAS;EAC3B;EACA;EACA,YAAY,UAAU,iBAAiB,OAAO,SAAS,aAAa,MAAM,KAAK,CAAC;EAChF,UAAU,UAAU;GAClB,UAAU,IAAI,QAAQ;GACtB,aAAa;IACX,UAAU,OAAO,QAAQ;GAC3B;EACF;EACA,UAAU;GACR,OAAO;GACP,UAAU,MAAM;GAChB,MAAM,MAAM;EACd;CACF;AACF"}
package/esm/types.d.mts CHANGED
@@ -1,6 +1,7 @@
1
1
  import { DevtoolsAgentTraceEvent } from "./sources/agent-trace-source.mjs";
2
+ import { DEVTOOLS_AI_ERROR_CATEGORIES, DEVTOOLS_AI_LATENCY_BUCKETS_MS, DEVTOOLS_BUILT_IN_PANELS, DEVTOOLS_FAILURE_AUDIT_TYPES, DEVTOOLS_LATENCY_BUCKETS_MS, DEVTOOLS_SHARE_LABEL_MAX, DevtoolsAccountView, DevtoolsAiBreakdownRow, DevtoolsAiCostTotals, DevtoolsAiErrorCategory, DevtoolsAiErrorGroup, DevtoolsAiErrorsView, DevtoolsAiEvaluatePrompt, DevtoolsAiEvaluateRequest, DevtoolsAiEvaluateResult, DevtoolsAiEvaluateView, DevtoolsAiFailedRun, DevtoolsAiFilterOptions, DevtoolsAiLatencyTotals, DevtoolsAiModelRow, DevtoolsAiModelsView, DevtoolsAiPricingState, DevtoolsAiRangePreset, DevtoolsAiRatePoint, DevtoolsAiReportView, DevtoolsAiResolvedRange, DevtoolsAiRunGroup, DevtoolsAiRunRow, DevtoolsAiRunsView, DevtoolsAiSeriesSet, DevtoolsAiTokenTotals, DevtoolsAiTotals, DevtoolsAiUnavailableReasonView, DevtoolsAiUnavailableView, DevtoolsAiUsageView, DevtoolsApiErrorBody, DevtoolsAuditEntry, DevtoolsAuditType, DevtoolsAuthStepResult, DevtoolsBuiltInPanelId, DevtoolsCaptureCounters, DevtoolsCreatedInvite, DevtoolsCreatedShare, DevtoolsErrorCode, DevtoolsErrorGroup, DevtoolsErrorsView, DevtoolsExplainResult, DevtoolsHealthReport, DevtoolsHealthView, DevtoolsHistogram, DevtoolsInstanceInfo, DevtoolsInstanceReport, DevtoolsInstancesView, DevtoolsInviteView, DevtoolsJobsReport, DevtoolsJobsView, DevtoolsLogRow, DevtoolsLoginInput, DevtoolsLogsView, DevtoolsMode, DevtoolsPanelInfo, DevtoolsPasswordSource, DevtoolsQueryShapeRow, DevtoolsQueryShapeStats, DevtoolsQueryStatsView, DevtoolsQueueInfo, DevtoolsRecoveryCodes, DevtoolsReportLogEntry, DevtoolsResourcePoint, DevtoolsResourceSnapshot, DevtoolsResourcesView, DevtoolsRole, DevtoolsRoutePhaseStats, DevtoolsRouteStats, DevtoolsRouteStatsRow, DevtoolsRouteStatsView, DevtoolsSampleDetail, DevtoolsSampleQuery, DevtoolsSampleSummary, DevtoolsScheduleInfo, DevtoolsScheduleRun, DevtoolsSessionInfo, DevtoolsSessionStage, DevtoolsSessionView, DevtoolsShareCreateInput, DevtoolsShareList, DevtoolsShareOpenAnswer, DevtoolsShareStatus, DevtoolsShareView, DevtoolsTotpEnrolment, DevtoolsUserListView } from "./production/contracts.mjs";
3
+ import { DevtoolsAiOptions } from "./ai/types.mjs";
2
4
  import { DevtoolsAiEvent } from "./sources/ai-source.mjs";
3
- import { DEVTOOLS_BUILT_IN_PANELS, DEVTOOLS_FAILURE_AUDIT_TYPES, DEVTOOLS_LATENCY_BUCKETS_MS, DEVTOOLS_SHARE_LABEL_MAX, DevtoolsAccountView, DevtoolsApiErrorBody, DevtoolsAuditEntry, DevtoolsAuditType, DevtoolsAuthStepResult, DevtoolsBuiltInPanelId, DevtoolsCaptureCounters, DevtoolsCreatedInvite, DevtoolsCreatedShare, 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, DevtoolsShareCreateInput, DevtoolsShareList, DevtoolsShareOpenAnswer, DevtoolsShareStatus, DevtoolsShareView, DevtoolsTotpEnrolment, DevtoolsUserListView } from "./production/contracts.mjs";
4
5
  import { RequestLogRecord } from "@warlock.js/core";
5
6
  //#region ../../packages/devtools/src/types.d.ts
6
7
  /**
@@ -63,6 +64,15 @@ export type DevtoolsOptions = {
63
64
  * @default []
64
65
  */
65
66
  panels?: readonly DevtoolsPanelEntry[];
67
+ /**
68
+ * The AI section (Reports, Models and Errors pages): hourly totals of runs,
69
+ * tokens, estimated cost, errors and latency, kept in the app database in
70
+ * production (table `devtools_ai_rollups`, in `devtoolsMigrations`) and in
71
+ * JSON files under the storage folder in development.
72
+ *
73
+ * @default { reports: true, retentionDays: 30 (development) or 90 (production), flushIntervalMs: 60000 }
74
+ */
75
+ ai?: DevtoolsAiOptions;
66
76
  /**
67
77
  * The production monitor: a signed-in dashboard at a secret path. Off
68
78
  * unless `enabled` is `true`; read only when the app runs in production
@@ -259,7 +269,7 @@ export type DevtoolsProductionOptions = {
259
269
  };
260
270
  };
261
271
  /** `DevtoolsOptions` with every default applied. */
262
- export type ResolvedDevtoolsOptions = Required<Pick<DevtoolsOptions, "path" | "maxRequests" | "nPlusOneThreshold">> & Pick<DevtoolsOptions, "allowedHosts" | "allowProxied" | "panels" | "production">;
272
+ export type ResolvedDevtoolsOptions = Required<Pick<DevtoolsOptions, "path" | "maxRequests" | "nPlusOneThreshold">> & Pick<DevtoolsOptions, "allowedHosts" | "allowProxied" | "panels" | "production" | "ai">;
263
273
  /** HTTP methods a panel data route may answer. */
264
274
  export type DevtoolsPanelMethod = "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
265
275
  /** What a panel data route handler receives. */
@@ -622,5 +632,5 @@ export type DevtoolsCollector = {
622
632
  clear(): void;
623
633
  };
624
634
  //#endregion
625
- export type { DEVTOOLS_BUILT_IN_PANELS, DEVTOOLS_FAILURE_AUDIT_TYPES, DEVTOOLS_LATENCY_BUCKETS_MS, DEVTOOLS_SHARE_LABEL_MAX, DevtoolsAccountView, DevtoolsApiErrorBody, DevtoolsAuditEntry, DevtoolsAuditType, DevtoolsAuthStepResult, DevtoolsBuiltInPanelId, DevtoolsCaptureCounters, DevtoolsCreatedInvite, DevtoolsCreatedShare, 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, DevtoolsShareCreateInput, DevtoolsShareList, DevtoolsShareOpenAnswer, DevtoolsShareStatus, DevtoolsShareView, DevtoolsTotpEnrolment, DevtoolsUserListView };
635
+ export type { DEVTOOLS_AI_ERROR_CATEGORIES, DEVTOOLS_AI_LATENCY_BUCKETS_MS, DEVTOOLS_BUILT_IN_PANELS, DEVTOOLS_FAILURE_AUDIT_TYPES, DEVTOOLS_LATENCY_BUCKETS_MS, DEVTOOLS_SHARE_LABEL_MAX, DevtoolsAccountView, DevtoolsAiBreakdownRow, DevtoolsAiCostTotals, DevtoolsAiErrorCategory, DevtoolsAiErrorGroup, DevtoolsAiErrorsView, DevtoolsAiEvaluatePrompt, DevtoolsAiEvaluateRequest, DevtoolsAiEvaluateResult, DevtoolsAiEvaluateView, DevtoolsAiFailedRun, DevtoolsAiFilterOptions, DevtoolsAiLatencyTotals, DevtoolsAiModelRow, DevtoolsAiModelsView, DevtoolsAiOptions, DevtoolsAiPricingState, DevtoolsAiRangePreset, DevtoolsAiRatePoint, DevtoolsAiReportView, DevtoolsAiResolvedRange, DevtoolsAiRunGroup, DevtoolsAiRunRow, DevtoolsAiRunsView, DevtoolsAiSeriesSet, DevtoolsAiTokenTotals, DevtoolsAiTotals, DevtoolsAiUnavailableReasonView, DevtoolsAiUnavailableView, DevtoolsAiUsageView, DevtoolsApiErrorBody, DevtoolsAuditEntry, DevtoolsAuditType, DevtoolsAuthStepResult, DevtoolsBuiltInPanelId, DevtoolsCaptureCounters, DevtoolsCreatedInvite, DevtoolsCreatedShare, DevtoolsErrorCode, DevtoolsErrorGroup, DevtoolsErrorsView, DevtoolsExplainResult, DevtoolsHealthReport, DevtoolsHealthView, DevtoolsHistogram, DevtoolsInstanceInfo, DevtoolsInstanceReport, DevtoolsInstancesView, DevtoolsInviteView, DevtoolsJobsReport, DevtoolsJobsView, DevtoolsLogRow, DevtoolsLoginInput, DevtoolsLogsView, DevtoolsMode, DevtoolsPanelInfo, DevtoolsPasswordSource, DevtoolsQueryShapeRow, DevtoolsQueryShapeStats, DevtoolsQueryStatsView, DevtoolsQueueInfo, DevtoolsRecoveryCodes, DevtoolsReportLogEntry, DevtoolsResourcePoint, DevtoolsResourceSnapshot, DevtoolsResourcesView, DevtoolsRole, DevtoolsRoutePhaseStats, DevtoolsRouteStats, DevtoolsRouteStatsRow, DevtoolsRouteStatsView, DevtoolsSampleDetail, DevtoolsSampleQuery, DevtoolsSampleSummary, DevtoolsScheduleInfo, DevtoolsScheduleRun, DevtoolsSessionInfo, DevtoolsSessionStage, DevtoolsSessionView, DevtoolsShareCreateInput, DevtoolsShareList, DevtoolsShareOpenAnswer, DevtoolsShareStatus, DevtoolsShareView, DevtoolsTotpEnrolment, DevtoolsUserListView };
626
636
  //# sourceMappingURL=types.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.mts","names":[],"sources":["../../../../../../../packages/devtools/src/types.ts"],"mappings":";;;;;;;;;;;;;;YAiBY;;;;;;EAMV;;;;;;EAMA;;;;;;;EAOA;;;;;;;;;;EAUA;;;;;;;;;EASA;;;;;;;;;;;;EAYA,kBAAkB;;;;;;;;;;;EAWlB,aAAa;;;;;;;YAQH;;;;;;;EAOV;;;;;;;EAOA;;;;;;;EAOA;;;;;;EAMA;;;;;;;EAOA;;;;;;EAMA;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;EACA;EACA;EACA;EACA;EACA;EACA;EACA,SAAS;EACT,aAAa;;;YAIH;EACV;EACA;EACA;;;YAIU;EACV;EACA;EACA;EACA;EACA,SAAS;;;YAIC;;EAEV;EACA;EACA;;EAEA;EACA;EACA;;EAEA;EACA;EACA,QAAQ;EACR,SAAS;EACT,OAAO;EACP,MAAM;;EAEN;EACA,UAAU;;;YAIA;EACV;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;EAEA;;EAEA;;EAEA;;;;;;;YAQU,wBAAwB;EAClC;EACA,SAAS;;;YAIC;EACV;EACA;EACA;EACA;EACA;;;;;;YAOU;EACV,SAAS;EACT,OAAO;EACP,MAAM;;;YAII;EAEN;EACA;IAAQ,MAAM;IAAc;IAAyB,MAAM;;;EAE3D;EAAiB,MAAM;;EACvB;EAAc,MAAM;;EACpB;EAAa,MAAM;;EACnB;EAAY,MAAM;;EAClB;EAAqB,MAAM;;;YAGrB;;;;;;YAOA;EACV,aAAa;IACX;IACA;IACA;IACA;IACA;;;EAGF,WACE,YACA;IAAU;IAAiB;IAAoB;IAAgB;;EAEjE,SAAS,mBAAmB,OAAO;;EAEnC,SACE,+BACA,OAAO,KAAK,iCACX;EACH,kBAAkB,+BAA+B,WAAW;EAC5D,OAAO,+BAA+B,OAAO;EAC7C,QAAQ,MAAM;EACd,gBAAgB;EAChB,WAAW,aAAa;EACxB,aAAa;EACb,QAAQ,aAAa;EACrB,SAAS;IAAW,QAAQ;IAA2B;MAAoB;EAC3E,iBAAiB;EACjB,UAAU,WAAW,OAAO,+BAA+B;EAC3D"}
1
+ {"version":3,"file":"types.d.mts","names":[],"sources":["../../../../../../../packages/devtools/src/types.ts"],"mappings":";;;;;;;;;;;;;;;YAmBY;;;;;;EAMV;;;;;;EAMA;;;;;;;EAOA;;;;;;;;;;EAUA;;;;;;;;;EASA;;;;;;;;;;;;EAYA,kBAAkB;;;;;;;;;EASlB,KAAK;;;;;;;;;;;EAWL,aAAa;;;;;;;YAQH;;;;;;;EA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;;;YAIU;EACV;EACA;EACA;EACA;EACA;;EAEA;;;YAIU;EACV;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,SAAS;EACT,aAAa;;;YAIH;EACV;EACA;EACA;;;YAIU;EACV;EACA;EACA;EACA;EACA,SAAS;;;YAIC;;EAEV;EACA;EACA;;EAEA;EACA;EACA;;EAEA;EACA;EACA,QAAQ;EACR,SAAS;EACT,OAAO;EACP,MAAM;;EAEN;EACA,UAAU;;;YAIA;EACV;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;EAEA;;EAEA;;EAEA;;;;;;;YAQU,wBAAwB;EAClC;EACA,SAAS;;;YAIC;EACV;EACA;EACA;EACA;EACA;;;;;;YAOU;EACV,SAAS;EACT,OAAO;EACP,MAAM;;;YAII;EAEN;EACA;IAAQ,MAAM;IAAc;IAAyB,MAAM;;;EAE3D;EAAiB,MAAM;;EACvB;EAAc,MAAM;;EACpB;EAAa,MAAM;;EACnB;EAAY,MAAM;;EAClB;EAAqB,MAAM;;;YAGrB;;;;;;YAOA;EACV,aAAa;IACX;IACA;IACA;IACA;IACA;;;EAGF,WACE,YACA;IAAU;IAAiB;IAAoB;IAAgB;;EAEjE,SAAS,mBAAmB,OAAO;;EAEnC,SACE,+BACA,OAAO,KAAK,iCACX;EACH,kBAAkB,+BAA+B,WAAW;EAC5D,OAAO,+BAA+B,OAAO;EAC7C,QAAQ,MAAM;EACd,gBAAgB;EAChB,WAAW,aAAa;EACxB,aAAa;EACb,QAAQ,aAAa;EACrB,SAAS;IAAW,QAAQ;IAA2B;MAAoB;EAC3E,iBAAiB;EACjB,UAAU,WAAW,OAAO,+BAA+B;EAC3D"}
package/llms-full.txt CHANGED
@@ -63,21 +63,23 @@ export default {
63
63
 
64
64
  ## What each panel shows
65
65
 
66
- | Panel | What you see | Where it comes from |
67
- | ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------- |
68
- | **Requests** | Each request with its status, duration and query count. Click one for a waterfall: router middleware, `page.middleware`, loaders, `page.cache` hit/miss, `render.shell`, `defer.settle`, with queries and cache ops placed on the same time axis. | core `registerTracingHooks()` |
69
- | **Queries** | SQL + bindings or the Mongo command, duration, rows, and an **Explain** button (Postgres `SELECT` only; runs `EXPLAIN (FORMAT JSON)`, never `ANALYZE`) | cascade `dataSourceRegistry.on("query")` |
70
- | **N+1** | `⚠ N+1: 12× "select … where post_id = $1" — src/app/posts/services/list-posts.service.ts:18`, shown on the request and printed in the terminal | same query shape ≥ 5 times in one request |
71
- | **Mail** | Every mail sent in development: headers, HTML (sandboxed) and text, attachment names | core `mailEvents.onCaptured()` |
72
- | **Logs** | Log entries per request, filterable by level and module | a logger channel |
73
- | **Cache** | hit / miss / set / removed / `invalidated` (tags, keys removed) | cache `cache.on(...)` |
74
- | **Resources** | Memory, CPU, event-loop delay and garbage collection, with a 10-minute history | the process |
75
- | **Health** | Readiness checks over time | core `health.readiness()` |
76
- | **Errors** | Failed requests grouped by cause with counts | tracing and logger |
77
- | **Jobs** | Registered scheduled jobs with schedule, last and next run (no run history, duration or error yet); queue counts only when the queue driver reports them (not available today) | `@warlock.js/scheduler`, `@warlock.js/queue` |
78
- | **Agents** | Per-turn traces of `@warlock.js/ai` agents: system prompt, tools offered with schema hashes, tool calls, results and refusals, retries, usage and cost, plus a comparison with the previous run of the agent | `@warlock.js/ai` `agentTraces` store |
79
- | **Routes** | Every HTTP route with its method, path, name and middleware | core router |
80
- | **API** | The app's API reference: every route with its parameters, request body, responses and auth | core `getDevelopmentOpenApiDocument()` |
66
+ | Panel | What you see | Where it comes from |
67
+ | ------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------- |
68
+ | **Requests** | Each request with its status, duration and query count. Click one for a waterfall: router middleware, `page.middleware`, loaders, `page.cache` hit/miss, `render.shell`, `defer.settle`, with queries and cache ops placed on the same time axis. | core `registerTracingHooks()` |
69
+ | **Queries** | SQL + bindings or the Mongo command, duration, rows, and an **Explain** button (Postgres `SELECT` only; runs `EXPLAIN (FORMAT JSON)`, never `ANALYZE`) | cascade `dataSourceRegistry.on("query")` |
70
+ | **N+1** | `⚠ N+1: 12× "select … where post_id = $1" — src/app/posts/services/list-posts.service.ts:18`, shown on the request and printed in the terminal | same query shape ≥ 5 times in one request |
71
+ | **Mail** | Every mail sent in development: headers, HTML (sandboxed) and text, attachment names | core `mailEvents.onCaptured()` |
72
+ | **Logs** | Log entries per request, filterable by level and module | a logger channel |
73
+ | **Cache** | hit / miss / set / removed / `invalidated` (tags, keys removed) | cache `cache.on(...)` |
74
+ | **Resources** | Memory, CPU, event-loop delay and garbage collection, with a 10-minute history | the process |
75
+ | **Health** | Readiness checks over time | core `health.readiness()` |
76
+ | **Errors** | Failed requests grouped by cause with counts | tracing and logger |
77
+ | **Jobs** | Registered scheduled jobs with schedule, last and next run, last duration, last error, runs, failures and recent runs (from the scheduler run history; error messages scrubbed like request errors); queue counts per queue when the driver implements `counts()` (the built-in BullMQ, local and memory drivers do), "not available" otherwise | `@warlock.js/scheduler`, `@warlock.js/queue` |
78
+ | **AI Reports, Models, Errors** | Hourly totals of agent runs, tokens, estimated cost (from model pricing; unpriced models flagged), errors by category, latency, fallbacks and refusals, with 24h / 7d / 30d / custom ranges and Agent, Model, Provider filters. Production too | `@warlock.js/ai-panoptic` trace feed, saved as hourly rollups |
79
+ | **AI Runs, Evaluate** | Single runs with filters, grouping and a cost tint; grade a system prompt with a judge model. Development only | Panoptic traces in memory; `panoptic.evaluate` |
80
+ | **Agents** | Per-turn traces of `@warlock.js/ai` agents: system prompt, tools offered with schema hashes, tool calls, results and refusals, retries, usage and cost, plus a comparison with the previous run of the agent | `@warlock.js/ai` `agentTraces` store |
81
+ | **Routes** | Every HTTP route with its method, path, name and middleware | core router |
82
+ | **API** | The app's API reference: every route with its parameters, request body, responses and auth | core `getDevelopmentOpenApiDocument()` |
81
83
 
82
84
  Work outside a request (boot, scheduler ticks, queue jobs) goes to a separate
83
85
  background list, so it never clutters a request's timeline.
@@ -102,13 +104,50 @@ without duplicates by id (saved-only rows are marked **saved**).
102
104
 
103
105
  An older core without the request log leaves the panel in-memory only.
104
106
 
107
+ ## AI section: Reports, Runs, Agents, Models, Errors, Evaluate
108
+
109
+ The **AI** sidebar group has six pages. Reports (`ai-reports`), Models (`ai-models`) and Errors (`ai-errors`) read
110
+ **hourly rollups** (names and numbers only: agent, model, provider, runs, tokens, estimated cost, errors by category,
111
+ latency histogram, fallback and refusal counts). Runs (`ai`, id unchanged), Agents (`agents`) and Evaluate
112
+ (`ai-evaluate`) read in-memory data and exist in development only. Cost is always "Estimated from model pricing"; runs of
113
+ models without pricing are counted as unpriced and shown next to every cost (a model priced at 0 counts as priced).
114
+ Runs filters by text, status, type and exact HTTP request id (`GET api/ai/runs?requestId=`). A comparison whose
115
+ previous period is older than the kept history reads "No earlier data". Custom ranges longer than 8 days use daily
116
+ columns from local midnight to midnight.
117
+
118
+ Options in `src/config/devtools.ts`:
119
+
120
+ ```ts
121
+ export default {
122
+ ai: {
123
+ reports: true, // keep hourly totals; false turns the writer off (pages say so)
124
+ retentionDays: 30, // 1 to 400; default 30 in development, 90 in production
125
+ flushIntervalMs: 60_000, // at least 5000
126
+ },
127
+ };
128
+ ```
129
+
130
+ - Storage: development files under `storage/devtools/ai-rollups`; production table `devtools_ai_rollups`, part of
131
+ `devtoolsMigrations`. After upgrading run `warlock migrate`; without it one warning is logged and the pages answer
132
+ `table-missing` ("AI reports need their table", command `warlock migrate`).
133
+ - Production tabs: Reports, Models and Errors are on by default when Panoptic is installed and loads; Runs, Agents and
134
+ Evaluate stay off. `production.panels` overrides by id (`{ "ai-reports": false }`). Every process that boots the
135
+ connector writes to the same table, so totals add up all instances and workers.
136
+ - Needs Panoptic and observation (`ai.config({ panoptic: { observeAll: true } })`). Evaluate also needs
137
+ `ai.config({ panoptic: { evaluate: { model, instructions? } } })`; without it the page shows the setup.
138
+ - Routes: `GET /api/ai/reports`, `/api/ai/models`, `/api/ai/errors` (query `range=24h|7d|30d|custom`, `from`, `to`, `tz`,
139
+ `agent`, `model`, `provider`), `GET /api/ai/runs` (`q`, `status`, `type`, `session`, `prompt`, `groupBy`, `limit`),
140
+ `GET` and `POST /api/ai/evaluate`; `GET /api/ai`, `/api/ai/runs/:id` and `/api/ai/agent-runs*` keep their shapes. Error
141
+ codes: `ai.range-invalid`, `ai.evaluate-unavailable`, `ai.prompt-not-found`, `ai.evaluate-failed`.
142
+ - Inside a Warlock app Panoptic's standalone dashboard does not start (one notice points here); the AI section replaces it.
143
+
105
144
  ## AI runs alongside HTTP requests
106
145
 
107
146
  The **AI** tab and each request's **AI runs** section display completed traces
108
147
  from optional `@warlock.js/ai-panoptic`. If the tab is empty it says why
109
148
  (`/api/ai` answers `reason`: `ai-missing`, `panoptic-missing`, `panoptic-failed` with the load
110
- error (absolute paths replaced) and versions, `observation-off`, or `not-collected` in the
111
- production dashboard, which never collects AI runs) with a title, one line and a copyable command; the
149
+ error (absolute paths replaced) and versions, `observation-off`, or `table-missing`, `reports-off`, or `not-collected` in the
150
+ production dashboard, which keeps hourly totals but not single runs) with a title, one line and a copyable command; the
112
151
  other panels keep working.
113
152
 
114
153
  ```bash
@@ -287,7 +326,7 @@ The accounts live in the app's database through Cascade. Roles are `viewer`
287
326
  and `admin`. Admins invite users with a 24-hour single-use link. Two-factor is
288
327
  required for admins by default (`twoFactor: "admins"`; or `"everyone"`, or `"off"` for nobody, which logs a boot warning; an account that has a factor is always asked for it): an
289
328
  authenticator app, or passkeys when `@simplewebauthn/server` is installed, plus
290
- 10 recovery codes. Every closed case answers the app's own 404.
329
+ 10 recovery codes. Every closed case answers like any unknown URL of the app: through its catch-all route (a web site's `route_not_found` answer, JSON or document) or its not-found handler.
291
330
 
292
331
  Options under `production` (all optional, defaults in brackets):
293
332
  `enabled` [false], `path` [`DEVTOOLS_PATH`], `sampleRate` [0.1],
@@ -311,10 +350,10 @@ Options under `production` (all optional, defaults in brackets):
311
350
  rolled back. `explain.executing: true` allows `EXPLAIN ANALYZE` and
312
351
  `executionStats`; they run the query, so leave it off unless accepted.
313
352
  Production plans show `?` in place of the query's values.
314
- - MongoDB: with `devtools.production.enabled` in `src/config/devtools.ts`, core
315
- turns `queryEvents` on in processes that serve HTTP (command monitoring is off
316
- in production by default); an explicit `queryEvents: false` wins. With the
317
- option passed only to `devtoolsConnector()`, set `queryEvents: true` yourself.
353
+ - MongoDB: with `devtools.production.enabled` in `src/config/devtools.ts` or
354
+ `production: { enabled: true }` passed to `devtoolsConnector()`, core turns
355
+ `queryEvents` on in processes that serve HTTP (command monitoring is off in
356
+ production by default); an explicit `queryEvents: false` wins.
318
357
  - A correct password does not reset an account's failed-try count; only a
319
358
  completed sign-in (second factor included) does. A caller over the IP limit
320
359
  costs no password check, and refused tries are audited at most once a minute
package/package.json CHANGED
@@ -6,13 +6,13 @@
6
6
  },
7
7
  "peerDependencies": {
8
8
  "@simplewebauthn/server": "^13.1.0",
9
- "@warlock.js/ai-panoptic": "5.59.0",
10
- "@warlock.js/cache": "5.59.0",
11
- "@warlock.js/cascade": "5.59.0",
12
- "@warlock.js/core": "5.59.0",
13
- "@warlock.js/logger": "5.59.0",
14
- "@warlock.js/queue": "5.59.0",
15
- "@warlock.js/scheduler": "5.59.0"
9
+ "@warlock.js/ai-panoptic": "5.61.0",
10
+ "@warlock.js/cache": "5.61.0",
11
+ "@warlock.js/cascade": "5.61.0",
12
+ "@warlock.js/core": "5.61.0",
13
+ "@warlock.js/logger": "5.61.0",
14
+ "@warlock.js/queue": "5.61.0",
15
+ "@warlock.js/scheduler": "5.61.0"
16
16
  },
17
17
  "peerDependenciesMeta": {
18
18
  "@simplewebauthn/server": {
@@ -52,7 +52,7 @@
52
52
  ],
53
53
  "author": "hassanzohdy",
54
54
  "license": "MIT",
55
- "version": "5.59.0",
55
+ "version": "5.61.0",
56
56
  "main": "./cjs/index.cjs",
57
57
  "module": "./esm/index.mjs",
58
58
  "types": "./esm/index.d.mts",