@warlock.js/devtools 5.58.0 → 5.59.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 (90) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/cjs/{ai-source-DTpxumMA.cjs → ai-source-BdvMfyKw.cjs} +84 -17
  3. package/cjs/ai-source-BdvMfyKw.cjs.map +1 -0
  4. package/cjs/app-versions-DfpPZOI2.cjs +253 -0
  5. package/cjs/app-versions-DfpPZOI2.cjs.map +1 -0
  6. package/cjs/{auth-DV2GA1A9.cjs → auth-B3wyjJnQ.cjs} +20 -13
  7. package/cjs/auth-B3wyjJnQ.cjs.map +1 -0
  8. package/cjs/{boot-CyeHPFtk.cjs → boot-nczSvJ_F.cjs} +11 -10
  9. package/cjs/boot-nczSvJ_F.cjs.map +1 -0
  10. package/cjs/{capture-DcyBhdqw.cjs → capture-CuyT8Vab.cjs} +4 -4
  11. package/cjs/{capture-DcyBhdqw.cjs.map → capture-CuyT8Vab.cjs.map} +1 -1
  12. package/cjs/{cascade-store-DEGxAFDI.cjs → cascade-store-CuRRYzt_.cjs} +3 -3
  13. package/cjs/cascade-store-CuRRYzt_.cjs.map +1 -0
  14. package/cjs/{current-request-id-BoJJb3y7.cjs → current-request-id-CeQhRz9Q.cjs} +3 -3
  15. package/cjs/{current-request-id-BoJJb3y7.cjs.map → current-request-id-CeQhRz9Q.cjs.map} +1 -1
  16. package/cjs/{errors-DEqdWaqm.cjs → errors-BadbSDX8.cjs} +4 -4
  17. package/cjs/errors-BadbSDX8.cjs.map +1 -0
  18. package/cjs/{helpers-7k_Q-abk.cjs → helpers-BcMBFy9v.cjs} +9 -6
  19. package/cjs/{helpers-7k_Q-abk.cjs.map → helpers-BcMBFy9v.cjs.map} +1 -1
  20. package/cjs/{histogram-BRV5eHcp.cjs → histogram-DTOGnNBW.cjs} +6 -6
  21. package/cjs/{histogram-BRV5eHcp.cjs.map → histogram-DTOGnNBW.cjs.map} +1 -1
  22. package/cjs/{http-XNLYU2vS.cjs → http-Biauhqi0.cjs} +7 -7
  23. package/cjs/http-Biauhqi0.cjs.map +1 -0
  24. package/cjs/index.cjs +1 -1
  25. package/cjs/{insights-BBZnUpWO.cjs → insights-BjJA6Ret.cjs} +6 -6
  26. package/cjs/{insights-BBZnUpWO.cjs.map → insights-BjJA6Ret.cjs.map} +1 -1
  27. package/cjs/{migrations-DTTzCNpR.cjs → migrations-BP4cYTGo.cjs} +3 -3
  28. package/cjs/{migrations-DTTzCNpR.cjs.map → migrations-BP4cYTGo.cjs.map} +1 -1
  29. package/cjs/{options-CHhmQJic.cjs → options-B9FHbRAJ.cjs} +15 -3
  30. package/cjs/options-B9FHbRAJ.cjs.map +1 -0
  31. package/cjs/{panels-CHd20RK5.cjs → panels-D1ITm-jc.cjs} +5 -6
  32. package/cjs/{panels-CHd20RK5.cjs.map → panels-D1ITm-jc.cjs.map} +1 -1
  33. package/cjs/{process-panel-DEOnLxoT.cjs → process-panel-DskSA7Cm.cjs} +4 -4
  34. package/cjs/{process-panel-DEOnLxoT.cjs.map → process-panel-DskSA7Cm.cjs.map} +1 -1
  35. package/cjs/production/index.cjs +4 -4
  36. package/cjs/{server-C8JfggQU.cjs → server-D3XRbSSb.cjs} +7 -5
  37. package/cjs/server-D3XRbSSb.cjs.map +1 -0
  38. package/cjs/{src-DjOUdhKc.cjs → src-QcNghoYN.cjs} +12 -12
  39. package/cjs/{src-DjOUdhKc.cjs.map → src-QcNghoYN.cjs.map} +1 -1
  40. package/cjs/{store-C06KO_A1.cjs → store-CNFv3wVp.cjs} +2 -2
  41. package/cjs/{stream-route-D4k-sJvW.cjs → stream-route-BqyAlfxQ.cjs} +25 -11
  42. package/cjs/stream-route-BqyAlfxQ.cjs.map +1 -0
  43. package/esm/app-versions.mjs +74 -0
  44. package/esm/app-versions.mjs.map +1 -0
  45. package/esm/production/auth/helpers.mjs +8 -5
  46. package/esm/production/auth/helpers.mjs.map +1 -1
  47. package/esm/production/auth/service.mjs +14 -6
  48. package/esm/production/auth/service.mjs.map +1 -1
  49. package/esm/production/boot.mjs +1 -0
  50. package/esm/production/boot.mjs.map +1 -1
  51. package/esm/production/contracts.d.mts +7 -0
  52. package/esm/production/contracts.d.mts.map +1 -1
  53. package/esm/production/contracts.mjs.map +1 -1
  54. package/esm/production/errors.d.mts +1 -1
  55. package/esm/production/errors.mjs +3 -3
  56. package/esm/production/errors.mjs.map +1 -1
  57. package/esm/production/http/share-session.mjs.map +1 -1
  58. package/esm/production/insights/writer.mjs.map +1 -1
  59. package/esm/production/options.d.mts +5 -1
  60. package/esm/production/options.d.mts.map +1 -1
  61. package/esm/production/options.mjs +13 -1
  62. package/esm/production/options.mjs.map +1 -1
  63. package/esm/production/store/memory-store.mjs.map +1 -1
  64. package/esm/server/ai-routes.mjs +20 -6
  65. package/esm/server/ai-routes.mjs.map +1 -1
  66. package/esm/server/session-routes.mjs +3 -1
  67. package/esm/server/session-routes.mjs.map +1 -1
  68. package/esm/sources/ai-source.d.mts.map +1 -1
  69. package/esm/sources/ai-source.mjs +75 -7
  70. package/esm/sources/ai-source.mjs.map +1 -1
  71. package/esm/types.d.mts +10 -1
  72. package/esm/types.d.mts.map +1 -1
  73. package/llms-full.txt +25 -17
  74. package/package.json +8 -8
  75. package/skills/SKILL.md +25 -17
  76. package/ui/dashboard/assets/app.css +1 -1
  77. package/ui/dashboard/assets/app.js +16 -16
  78. package/ui/dashboard/build-info.json +7 -7
  79. package/cjs/ai-source-DTpxumMA.cjs.map +0 -1
  80. package/cjs/auth-DV2GA1A9.cjs.map +0 -1
  81. package/cjs/boot-CyeHPFtk.cjs.map +0 -1
  82. package/cjs/cascade-store-DEGxAFDI.cjs.map +0 -1
  83. package/cjs/contracts-CDuY-ahl.cjs +0 -116
  84. package/cjs/contracts-CDuY-ahl.cjs.map +0 -1
  85. package/cjs/errors-DEqdWaqm.cjs.map +0 -1
  86. package/cjs/http-XNLYU2vS.cjs.map +0 -1
  87. package/cjs/options-CHhmQJic.cjs.map +0 -1
  88. package/cjs/rolldown-runtime-Zuuoy_Rh.cjs +0 -52
  89. package/cjs/server-C8JfggQU.cjs.map +0 -1
  90. package/cjs/stream-route-D4k-sJvW.cjs.map +0 -1
@@ -1,5 +1,5 @@
1
1
  import { AGENT_TRACE_INSTALL_GUIDANCE } from "../sources/agent-trace-source.mjs";
2
- import { AI_INSTALL_GUIDANCE } from "../sources/ai-source.mjs";
2
+ import { describeAiUnavailable } from "../sources/ai-source.mjs";
3
3
 
4
4
  //#region ../../packages/devtools/src/server/ai-routes.ts
5
5
  /** Read-only AI metadata, inside the same development/loopback guard as every panel. */
@@ -7,15 +7,29 @@ function registerAiRoutes(server, deps) {
7
7
  server.get("/api/ai", async (request, reply) => {
8
8
  reply.header("Cache-Control", "no-store");
9
9
  const source = deps.ai;
10
- if (!source?.available) return {
11
- available: false,
12
- message: source?.message ?? "Install @warlock.js/ai and @warlock.js/ai-panoptic, then restart warlock dev. Import @warlock.js/ai-panoptic and enable ai.config({ panoptic: { observeAll: true } }). If already installed, check that both packages are compatible and can be loaded.",
10
+ if (!source?.available) {
11
+ if (!source) {
12
+ const reason = deps.mode === "production" ? "not-collected" : "ai-missing";
13
+ return {
14
+ ...describeAiUnavailable(reason),
15
+ runs: []
16
+ };
17
+ }
18
+ const { dispose: _dispose, ...unavailable } = source;
19
+ return {
20
+ ...unavailable,
21
+ runs: []
22
+ };
23
+ }
24
+ const filter = request.query.requestId === void 0 ? void 0 : { requestId: request.query.requestId };
25
+ const runs = source.store.query(filter).map(source.summarize);
26
+ if (!runs.length && filter === void 0 && source.observationOff?.()) return {
27
+ ...describeAiUnavailable("observation-off"),
13
28
  runs: []
14
29
  };
15
- const filter = request.query.requestId === void 0 ? void 0 : { requestId: request.query.requestId };
16
30
  return {
17
31
  available: true,
18
- runs: source.store.query(filter).map(source.summarize),
32
+ runs,
19
33
  aggregate: source.store.aggregate(filter)
20
34
  };
21
35
  });
@@ -1 +1 @@
1
- {"version":3,"file":"ai-routes.mjs","names":[],"sources":["../../../../../../../../packages/devtools/src/server/ai-routes.ts"],"sourcesContent":["import type { FastifyInstance } from \"fastify\";\nimport { AGENT_TRACE_INSTALL_GUIDANCE } from \"../sources/agent-trace-source\";\nimport { AI_INSTALL_GUIDANCE } from \"../sources/ai-source\";\nimport type { MountDevtoolsRoutesDeps } from \"./types\";\n\n/** Read-only AI metadata, inside the same development/loopback guard as every panel. */\nexport function registerAiRoutes(server: FastifyInstance, deps: MountDevtoolsRoutesDeps): void {\n server.get<{ Querystring: { requestId?: string } }>(\"/api/ai\", async (request, reply) => {\n reply.header(\"Cache-Control\", \"no-store\");\n const source = deps.ai;\n if (!source?.available) {\n return { available: false, message: source?.message ?? AI_INSTALL_GUIDANCE, runs: [] };\n }\n const filter =\n request.query.requestId === undefined ? undefined : { requestId: request.query.requestId };\n return {\n available: true,\n runs: source.store.query(filter).map(source.summarize),\n aggregate: source.store.aggregate(filter),\n };\n });\n\n // Per-turn agent traces recorded by `@warlock.js/ai` itself (system prompt,\n // tools offered, tool calls, refusals, retries, usage and cost). Unlike the\n // Panoptic feed above, these carry prompt and tool content: they exist for\n // debugging in development and sit behind the same guard.\n server.get<{ Querystring: { requestId?: string } }>(\n \"/api/ai/agent-runs\",\n async (request, reply) => {\n reply.header(\"Cache-Control\", \"no-store\");\n const source = deps.agentTraces;\n\n if (!source?.available()) {\n return { available: false, message: AGENT_TRACE_INSTALL_GUIDANCE, runs: [] };\n }\n\n return {\n available: true,\n runs: source.list(\n request.query.requestId === undefined\n ? undefined\n : { requestId: request.query.requestId },\n ),\n };\n },\n );\n\n server.get<{ Params: { id: string } }>(\"/api/ai/agent-runs/:id\", async (request, reply) => {\n reply.header(\"Cache-Control\", \"no-store\");\n const trace = deps.agentTraces?.get(request.params.id);\n\n if (!trace) return reply.code(404).send();\n\n return trace;\n });\n\n server.get<{ Params: { id: string } }>(\"/api/ai/runs/:id\", async (request, reply) => {\n reply.header(\"Cache-Control\", \"no-store\");\n const source = deps.ai;\n const trace = source?.available ? source.store.get(request.params.id) : undefined;\n if (!trace) return reply.code(404).send();\n return trace;\n });\n}\n"],"mappings":";;;;;AAMA,SAAgB,iBAAiB,QAAyB,MAAqC;CAC7F,OAAO,IAA6C,WAAW,OAAO,SAAS,UAAU;EACvF,MAAM,OAAO,iBAAiB,UAAU;EACxC,MAAM,SAAS,KAAK;EACpB,IAAI,CAAC,QAAQ,WACX,OAAO;GAAE,WAAW;GAAO,SAAS,QAAQ;GAAgC,MAAM,CAAC;EAAE;EAEvF,MAAM,SACJ,QAAQ,MAAM,cAAc,SAAY,SAAY,EAAE,WAAW,QAAQ,MAAM,UAAU;EAC3F,OAAO;GACL,WAAW;GACX,MAAM,OAAO,MAAM,MAAM,MAAM,CAAC,CAAC,IAAI,OAAO,SAAS;GACrD,WAAW,OAAO,MAAM,UAAU,MAAM;EAC1C;CACF,CAAC;CAMD,OAAO,IACL,sBACA,OAAO,SAAS,UAAU;EACxB,MAAM,OAAO,iBAAiB,UAAU;EACxC,MAAM,SAAS,KAAK;EAEpB,IAAI,CAAC,QAAQ,UAAU,GACrB,OAAO;GAAE,WAAW;GAAO,SAAS;GAA8B,MAAM,CAAC;EAAE;EAG7E,OAAO;GACL,WAAW;GACX,MAAM,OAAO,KACX,QAAQ,MAAM,cAAc,SACxB,SACA,EAAE,WAAW,QAAQ,MAAM,UAAU,CAC3C;EACF;CACF,CACF;CAEA,OAAO,IAAgC,0BAA0B,OAAO,SAAS,UAAU;EACzF,MAAM,OAAO,iBAAiB,UAAU;EACxC,MAAM,QAAQ,KAAK,aAAa,IAAI,QAAQ,OAAO,EAAE;EAErD,IAAI,CAAC,OAAO,OAAO,MAAM,KAAK,GAAG,CAAC,CAAC,KAAK;EAExC,OAAO;CACT,CAAC;CAED,OAAO,IAAgC,oBAAoB,OAAO,SAAS,UAAU;EACnF,MAAM,OAAO,iBAAiB,UAAU;EACxC,MAAM,SAAS,KAAK;EACpB,MAAM,QAAQ,QAAQ,YAAY,OAAO,MAAM,IAAI,QAAQ,OAAO,EAAE,IAAI;EACxE,IAAI,CAAC,OAAO,OAAO,MAAM,KAAK,GAAG,CAAC,CAAC,KAAK;EACxC,OAAO;CACT,CAAC;AACH"}
1
+ {"version":3,"file":"ai-routes.mjs","names":[],"sources":["../../../../../../../../packages/devtools/src/server/ai-routes.ts"],"sourcesContent":["import type { FastifyInstance } from \"fastify\";\nimport { AGENT_TRACE_INSTALL_GUIDANCE } from \"../sources/agent-trace-source\";\nimport { describeAiUnavailable } from \"../sources/ai-source\";\nimport type { MountDevtoolsRoutesDeps } from \"./types\";\n\n/** Read-only AI metadata, inside the same development/loopback guard as every panel. */\nexport function registerAiRoutes(server: FastifyInstance, deps: MountDevtoolsRoutesDeps): void {\n server.get<{ Querystring: { requestId?: string } }>(\"/api/ai\", async (request, reply) => {\n reply.header(\"Cache-Control\", \"no-store\");\n const source = deps.ai;\n if (!source?.available) {\n if (!source) {\n // Production never attaches the feed: say so instead of claiming AI is missing.\n const reason = deps.mode === \"production\" ? \"not-collected\" : \"ai-missing\";\n return { ...describeAiUnavailable(reason), runs: [] };\n }\n const { dispose: _dispose, ...unavailable } = source;\n return { ...unavailable, runs: [] };\n }\n const filter =\n request.query.requestId === undefined ? undefined : { requestId: request.query.requestId };\n const runs = source.store.query(filter).map(source.summarize);\n // Nothing collected and nothing that would collect: say how to turn it on.\n if (!runs.length && filter === undefined && source.observationOff?.()) {\n return { ...describeAiUnavailable(\"observation-off\"), runs: [] };\n }\n return {\n available: true,\n runs,\n aggregate: source.store.aggregate(filter),\n };\n });\n\n // Per-turn agent traces recorded by `@warlock.js/ai` itself (system prompt,\n // tools offered, tool calls, refusals, retries, usage and cost). Unlike the\n // Panoptic feed above, these carry prompt and tool content: they exist for\n // debugging in development and sit behind the same guard.\n server.get<{ Querystring: { requestId?: string } }>(\n \"/api/ai/agent-runs\",\n async (request, reply) => {\n reply.header(\"Cache-Control\", \"no-store\");\n const source = deps.agentTraces;\n\n if (!source?.available()) {\n return { available: false, message: AGENT_TRACE_INSTALL_GUIDANCE, runs: [] };\n }\n\n return {\n available: true,\n runs: source.list(\n request.query.requestId === undefined\n ? undefined\n : { requestId: request.query.requestId },\n ),\n };\n },\n );\n\n server.get<{ Params: { id: string } }>(\"/api/ai/agent-runs/:id\", async (request, reply) => {\n reply.header(\"Cache-Control\", \"no-store\");\n const trace = deps.agentTraces?.get(request.params.id);\n\n if (!trace) return reply.code(404).send();\n\n return trace;\n });\n\n server.get<{ Params: { id: string } }>(\"/api/ai/runs/:id\", async (request, reply) => {\n reply.header(\"Cache-Control\", \"no-store\");\n const source = deps.ai;\n const trace = source?.available ? source.store.get(request.params.id) : undefined;\n if (!trace) return reply.code(404).send();\n return trace;\n });\n}\n"],"mappings":";;;;;AAMA,SAAgB,iBAAiB,QAAyB,MAAqC;CAC7F,OAAO,IAA6C,WAAW,OAAO,SAAS,UAAU;EACvF,MAAM,OAAO,iBAAiB,UAAU;EACxC,MAAM,SAAS,KAAK;EACpB,IAAI,CAAC,QAAQ,WAAW;GACtB,IAAI,CAAC,QAAQ;IAEX,MAAM,SAAS,KAAK,SAAS,eAAe,kBAAkB;IAC9D,OAAO;KAAE,GAAG,sBAAsB,MAAM;KAAG,MAAM,CAAC;IAAE;GACtD;GACA,MAAM,EAAE,SAAS,UAAU,GAAG,gBAAgB;GAC9C,OAAO;IAAE,GAAG;IAAa,MAAM,CAAC;GAAE;EACpC;EACA,MAAM,SACJ,QAAQ,MAAM,cAAc,SAAY,SAAY,EAAE,WAAW,QAAQ,MAAM,UAAU;EAC3F,MAAM,OAAO,OAAO,MAAM,MAAM,MAAM,CAAC,CAAC,IAAI,OAAO,SAAS;EAE5D,IAAI,CAAC,KAAK,UAAU,WAAW,UAAa,OAAO,iBAAiB,GAClE,OAAO;GAAE,GAAG,sBAAsB,iBAAiB;GAAG,MAAM,CAAC;EAAE;EAEjE,OAAO;GACL,WAAW;GACX;GACA,WAAW,OAAO,MAAM,UAAU,MAAM;EAC1C;CACF,CAAC;CAMD,OAAO,IACL,sBACA,OAAO,SAAS,UAAU;EACxB,MAAM,OAAO,iBAAiB,UAAU;EACxC,MAAM,SAAS,KAAK;EAEpB,IAAI,CAAC,QAAQ,UAAU,GACrB,OAAO;GAAE,WAAW;GAAO,SAAS;GAA8B,MAAM,CAAC;EAAE;EAG7E,OAAO;GACL,WAAW;GACX,MAAM,OAAO,KACX,QAAQ,MAAM,cAAc,SACxB,SACA,EAAE,WAAW,QAAQ,MAAM,UAAU,CAC3C;EACF;CACF,CACF;CAEA,OAAO,IAAgC,0BAA0B,OAAO,SAAS,UAAU;EACzF,MAAM,OAAO,iBAAiB,UAAU;EACxC,MAAM,QAAQ,KAAK,aAAa,IAAI,QAAQ,OAAO,EAAE;EAErD,IAAI,CAAC,OAAO,OAAO,MAAM,KAAK,GAAG,CAAC,CAAC,KAAK;EAExC,OAAO;CACT,CAAC;CAED,OAAO,IAAgC,oBAAoB,OAAO,SAAS,UAAU;EACnF,MAAM,OAAO,iBAAiB,UAAU;EACxC,MAAM,SAAS,KAAK;EACpB,MAAM,QAAQ,QAAQ,YAAY,OAAO,MAAM,IAAI,QAAQ,OAAO,EAAE,IAAI;EACxE,IAAI,CAAC,OAAO,OAAO,MAAM,KAAK,GAAG,CAAC,CAAC,KAAK;EACxC,OAAO;CACT,CAAC;AACH"}
@@ -1,4 +1,5 @@
1
1
  import { listPanelInfos } from "../panels.mjs";
2
+ import { readVersions } from "../app-versions.mjs";
2
3
 
3
4
  //#region ../../packages/devtools/src/server/session-routes.ts
4
5
  /**
@@ -15,7 +16,8 @@ function developmentSessionView(deps) {
15
16
  expiresAt: null,
16
17
  instance: deps.instance ?? null,
17
18
  methods: null,
18
- share: null
19
+ share: null,
20
+ ...readVersions()
19
21
  };
20
22
  }
21
23
  /** The tabs `GET api/panels` lists: the built-in tabs in `deps.builtInPanels` (default all), then the package panels. */
@@ -1 +1 @@
1
- {"version":3,"file":"session-routes.mjs","names":[],"sources":["../../../../../../../../packages/devtools/src/server/session-routes.ts"],"sourcesContent":["import type { FastifyInstance } from \"fastify\";\nimport { listPanelInfos, type MountedDevtoolsPanel } from \"../panels\";\nimport type { DevtoolsPanelInfo, DevtoolsSessionView } from \"../production/contracts\";\nimport type { MountDevtoolsRoutesDeps } from \"./types\";\n\n/**\n * The session view of the development dashboard: there are no accounts, the\n * loopback guard is the access control, and the visitor is an admin.\n */\nexport function developmentSessionView(deps: MountDevtoolsRoutesDeps): DevtoolsSessionView {\n return {\n mode: \"development\",\n stage: \"active\",\n account: null,\n role: \"admin\",\n csrf: null,\n expiresAt: null,\n instance: deps.instance ?? null,\n methods: null,\n share: null,\n };\n}\n\n/** The tabs `GET api/panels` lists: the built-in tabs in `deps.builtInPanels` (default all), then the package panels. */\nexport function panelInfos(\n deps: MountDevtoolsRoutesDeps,\n panels: readonly (Pick<MountedDevtoolsPanel, \"id\" | \"title\"> &\n Partial<Pick<MountedDevtoolsPanel, \"share\">>)[],\n): DevtoolsPanelInfo[] {\n return listPanelInfos(panels, deps.builtInPanels);\n}\n\n/**\n * Registers `GET /api/auth/session` (the development view: signed in as an\n * admin, no accounts) and `GET /api/panels`, so the same dashboard shell\n * works in both modes. Production answers these from its own mount.\n */\nexport function registerSessionRoutes(\n server: FastifyInstance,\n deps: MountDevtoolsRoutesDeps,\n panels: readonly MountedDevtoolsPanel[],\n): void {\n server.get(\"/api/auth/session\", async (_request, reply) => {\n reply.header(\"Cache-Control\", \"no-store\");\n\n return developmentSessionView(deps);\n });\n\n server.get(\"/api/panels\", async (_request, reply) => {\n reply.header(\"Cache-Control\", \"no-store\");\n\n return panelInfos(deps, panels);\n });\n}\n"],"mappings":";;;;;;;AASA,SAAgB,uBAAuB,MAAoD;CACzF,OAAO;EACL,MAAM;EACN,OAAO;EACP,SAAS;EACT,MAAM;EACN,MAAM;EACN,WAAW;EACX,UAAU,KAAK,YAAY;EAC3B,SAAS;EACT,OAAO;CACT;AACF;;AAGA,SAAgB,WACd,MACA,QAEqB;CACrB,OAAO,eAAe,QAAQ,KAAK,aAAa;AAClD;;;;;;AAOA,SAAgB,sBACd,QACA,MACA,QACM;CACN,OAAO,IAAI,qBAAqB,OAAO,UAAU,UAAU;EACzD,MAAM,OAAO,iBAAiB,UAAU;EAExC,OAAO,uBAAuB,IAAI;CACpC,CAAC;CAED,OAAO,IAAI,eAAe,OAAO,UAAU,UAAU;EACnD,MAAM,OAAO,iBAAiB,UAAU;EAExC,OAAO,WAAW,MAAM,MAAM;CAChC,CAAC;AACH"}
1
+ {"version":3,"file":"session-routes.mjs","names":[],"sources":["../../../../../../../../packages/devtools/src/server/session-routes.ts"],"sourcesContent":["import type { FastifyInstance } from \"fastify\";\nimport { readVersions } from \"../app-versions\";\nimport { listPanelInfos, type MountedDevtoolsPanel } from \"../panels\";\nimport type { DevtoolsPanelInfo, DevtoolsSessionView } from \"../production/contracts\";\nimport type { MountDevtoolsRoutesDeps } from \"./types\";\n\n/**\n * The session view of the development dashboard: there are no accounts, the\n * loopback guard is the access control, and the visitor is an admin.\n */\nexport function developmentSessionView(deps: MountDevtoolsRoutesDeps): DevtoolsSessionView {\n return {\n mode: \"development\",\n stage: \"active\",\n account: null,\n role: \"admin\",\n csrf: null,\n expiresAt: null,\n instance: deps.instance ?? null,\n methods: null,\n share: null,\n ...readVersions(),\n };\n}\n\n/** The tabs `GET api/panels` lists: the built-in tabs in `deps.builtInPanels` (default all), then the package panels. */\nexport function panelInfos(\n deps: MountDevtoolsRoutesDeps,\n panels: readonly (Pick<MountedDevtoolsPanel, \"id\" | \"title\"> &\n Partial<Pick<MountedDevtoolsPanel, \"share\">>)[],\n): DevtoolsPanelInfo[] {\n return listPanelInfos(panels, deps.builtInPanels);\n}\n\n/**\n * Registers `GET /api/auth/session` (the development view: signed in as an\n * admin, no accounts) and `GET /api/panels`, so the same dashboard shell\n * works in both modes. Production answers these from its own mount.\n */\nexport function registerSessionRoutes(\n server: FastifyInstance,\n deps: MountDevtoolsRoutesDeps,\n panels: readonly MountedDevtoolsPanel[],\n): void {\n server.get(\"/api/auth/session\", async (_request, reply) => {\n reply.header(\"Cache-Control\", \"no-store\");\n\n return developmentSessionView(deps);\n });\n\n server.get(\"/api/panels\", async (_request, reply) => {\n reply.header(\"Cache-Control\", \"no-store\");\n\n return panelInfos(deps, panels);\n });\n}\n"],"mappings":";;;;;;;;AAUA,SAAgB,uBAAuB,MAAoD;CACzF,OAAO;EACL,MAAM;EACN,OAAO;EACP,SAAS;EACT,MAAM;EACN,MAAM;EACN,WAAW;EACX,UAAU,KAAK,YAAY;EAC3B,SAAS;EACT,OAAO;EACP,GAAG,aAAa;CAClB;AACF;;AAGA,SAAgB,WACd,MACA,QAEqB;CACrB,OAAO,eAAe,QAAQ,KAAK,aAAa;AAClD;;;;;;AAOA,SAAgB,sBACd,QACA,MACA,QACM;CACN,OAAO,IAAI,qBAAqB,OAAO,UAAU,UAAU;EACzD,MAAM,OAAO,iBAAiB,UAAU;EAExC,OAAO,uBAAuB,IAAI;CACpC,CAAC;CAED,OAAO,IAAI,eAAe,OAAO,UAAU,UAAU;EACnD,MAAM,OAAO,iBAAiB,UAAU;EAExC,OAAO,WAAW,MAAM,MAAM;CAChC,CAAC;AACH"}
@@ -1 +1 @@
1
- {"version":3,"file":"ai-source.d.mts","names":[],"sources":["../../../../../../../../packages/devtools/src/sources/ai-source.ts"],"mappings":";;;YAOY;EAAoB;EAAiB;;YAarC;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":";;;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,7 +1,55 @@
1
+ import { installedVersion } from "../app-versions.mjs";
1
2
  import { toSafeValue } from "../safe-value.mjs";
2
3
 
3
4
  //#region ../../packages/devtools/src/sources/ai-source.ts
4
- const AI_INSTALL_GUIDANCE = "Install @warlock.js/ai and @warlock.js/ai-panoptic, then restart warlock dev. Import @warlock.js/ai-panoptic and enable ai.config({ panoptic: { observeAll: true } }). If already installed, check that both packages are compatible and can be loaded.";
5
+ /** Replaces absolute file paths in an error line with their package-relative part, or `<path>`. */
6
+ function redactPaths(text) {
7
+ return text.replace(/(?:file:\/\/)?(?:[A-Za-z]:)?[\\/][^\s'"`()]*/g, (match) => {
8
+ const normalized = match.replace(/^file:\/\//, "").replaceAll("\\", "/");
9
+ const index = normalized.lastIndexOf("node_modules/");
10
+ return index === -1 ? "<path>" : normalized.slice(index + 13);
11
+ });
12
+ }
13
+ const OBSERVATION_COMMAND = "ai.config({ panoptic: { observeAll: true } })";
14
+ /** The answer for each reason; `detail` carries the load error and versions for `panoptic-failed`. */
15
+ function describeAiUnavailable(reason, detail) {
16
+ switch (reason) {
17
+ case "ai-missing": return {
18
+ available: false,
19
+ reason,
20
+ title: "AI isn't installed",
21
+ message: "Add @warlock.js/ai to see AI runs here.",
22
+ command: "warlock add ai"
23
+ };
24
+ case "panoptic-missing": return {
25
+ available: false,
26
+ reason,
27
+ title: "Panoptic isn't installed",
28
+ message: "Your app uses @warlock.js/ai. Add Panoptic to see its runs.",
29
+ command: "warlock add ai-panoptic"
30
+ };
31
+ case "panoptic-failed": return {
32
+ available: false,
33
+ reason,
34
+ title: "Panoptic could not be loaded",
35
+ message: "Panoptic is installed but failed to load. Check that both packages share a version.",
36
+ detail
37
+ };
38
+ case "not-collected": return {
39
+ available: false,
40
+ reason,
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."
43
+ };
44
+ case "observation-off": return {
45
+ available: false,
46
+ reason,
47
+ title: "AI observation is off",
48
+ message: "Turn it on in src/config/ai.ts, then restart warlock dev.",
49
+ command: OBSERVATION_COMMAND
50
+ };
51
+ }
52
+ }
5
53
  /** Summaries use root usage once: nested spans already roll up into it. */
6
54
  function summarizeAiTrace(trace, cost) {
7
55
  const models = /* @__PURE__ */ new Set();
@@ -83,18 +131,37 @@ function snapshotSpan(span) {
83
131
  * Optional, lazy integration. Retains only traces collected after devtools boots,
84
132
  * using Panoptic's bounded query store; existing exporter/cache stores stay independent.
85
133
  */
86
- async function attachAiSource(capacity) {
134
+ async function attachAiSource(capacity, deps = {}) {
135
+ const aiPackage = "@warlock.js/ai";
136
+ const load = deps.load ?? ((name) => name === "@warlock.js/ai-panoptic" ? import("@warlock.js/ai-panoptic") : import(aiPackage));
137
+ const version = deps.version ?? ((name) => installedVersion(name, process.cwd(), import.meta.resolve));
87
138
  let panoptic;
88
139
  try {
89
- panoptic = await import("@warlock.js/ai-panoptic");
140
+ panoptic = await load("@warlock.js/ai-panoptic");
90
141
  if (typeof panoptic.subscribeTraces !== "function") throw new Error("Trace subscription unavailable");
91
- } catch {
142
+ } catch (error) {
143
+ const aiVersion = version("@warlock.js/ai");
144
+ 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
+ };
92
153
  return {
93
- available: false,
94
- message: AI_INSTALL_GUIDANCE,
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})`),
95
155
  dispose() {}
96
156
  };
97
157
  }
158
+ let core;
159
+ try {
160
+ core = await load("@warlock.js/ai");
161
+ } catch {
162
+ core = void 0;
163
+ }
164
+ const observationOff = () => typeof core?.isObserveAll === "function" && typeof core.getObservers === "function" && !core.isObserveAll() && core.getObservers().length === 0;
98
165
  const { currentRequestId } = await import("../current-request-id.mjs");
99
166
  const store = panoptic.createInMemoryTraceStore({ capacity });
100
167
  const listeners = /* @__PURE__ */ new Set();
@@ -115,6 +182,7 @@ async function attachAiSource(capacity) {
115
182
  });
116
183
  return {
117
184
  available: true,
185
+ observationOff,
118
186
  store,
119
187
  summarize: (trace) => summarizeAiTrace(trace, panoptic.totalCostUsd(trace.usage)),
120
188
  subscribe(listener) {
@@ -132,5 +200,5 @@ async function attachAiSource(capacity) {
132
200
  }
133
201
 
134
202
  //#endregion
135
- export { AI_INSTALL_GUIDANCE, attachAiSource, summarizeAiTrace };
203
+ export { attachAiSource, describeAiUnavailable, redactPaths, summarizeAiTrace };
136
204
  //# 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 { toSafeValue } from \"../safe-value\";\nimport type { DevtoolsDisposer } from \"../types\";\n\nexport const AI_INSTALL_GUIDANCE =\n \"Install @warlock.js/ai and @warlock.js/ai-panoptic, then restart warlock dev. Import @warlock.js/ai-panoptic and enable ai.config({ panoptic: { observeAll: true } }). If already installed, check that both packages are compatible and can be loaded.\";\n\nexport type DevtoolsAiEvent = { traceId: string; requestId?: string };\n\n/** Only the connector's development branch constructs this source. */\nexport type DevtoolsAiSource =\n | { available: false; message: string; dispose: DevtoolsDisposer }\n | {\n available: true;\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(capacity: number): Promise<DevtoolsAiSource> {\n let panoptic: typeof import(\"@warlock.js/ai-panoptic\");\n try {\n panoptic = await import(\"@warlock.js/ai-panoptic\");\n if (typeof panoptic.subscribeTraces !== \"function\")\n throw new Error(\"Trace subscription unavailable\");\n } catch {\n return { available: false, message: AI_INSTALL_GUIDANCE, dispose() {} };\n }\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 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":";;;AAIA,MAAa,sBACX;;AAqCF,SAAgB,iBAAiB,O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,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 { 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":";;;;;AAuBA,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,OAAO;GACL,WAAW;GACX;GACA,OAAO;GACP,SAAS;GACT,SAAS;EACX;EACF,KAAK,oBACH,OAAO;GACL,WAAW;GACX;GACA,OAAO;GACP,SAAS;GACT,SAAS;EACX;EACF,KAAK,mBACH,OAAO;GACL,WAAW;GACX;GACA,OAAO;GACP,SACE;GACF;EACF;EACF,KAAK,iBACH,OAAO;GACL,WAAW;GACX;GACA,OAAO;GACP,SACE;EACJ;EACF,KAAK,mBACH,OAAO;GACL,WAAW;GACX;GACA,OAAO;GACP,SAAS;GACT,SAAS;E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,CAAC,MAAM,EAC7E,CAAC,CAAC,MAAM,GAAG,GAID,EAAE,mBAAmB,UAAU,4BAA4B,gBAAgB,EACnF;GACA,UAAU,CAAC;EACb;CACF;CAEA,IAAI;CACJ,IAAI;EACF,OAAQ,MAAM,KAAK,gBAAgB;CACrC,QAAQ;EACN,OAAO;CACT;CACA,MAAM,uBACJ,OAAO,MAAM,iBAAiB,cAC9B,OAAO,KAAK,iBAAiB,cAC7B,CAAC,KAAK,aAAa,KACnB,KAAK,aAAa,CAAC,CAAC,WAAW;CAEjC,MAAM,EAAE,qBAAqB,MAAM,OAAO;CAC1C,MAAM,QAAQ,SAAS,yBAAyB,EAAE,SAAS,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;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
@@ -181,10 +181,19 @@ export type DevtoolsProductionOptions = {
181
181
  };
182
182
  /**
183
183
  * Who must use a second factor (an authenticator app or a passkey).
184
+ * `"off"` requires nobody: users may still add a factor, and an account
185
+ * that has one is always asked for it. Boot logs a warning when it is off.
184
186
  *
185
187
  * @default "admins"
186
188
  */
187
- twoFactor?: "admins" | "everyone";
189
+ twoFactor?: "off" | "admins" | "everyone";
190
+ /** Password rules for accounts, invites and the first admin. */
191
+ passwords?: {
192
+ /** Shortest password, in characters; 8 or more. @default 8 */
193
+ minLength?: number;
194
+ /** Refuse passwords from the built-in common list. @default true */
195
+ rejectCommon?: boolean;
196
+ };
188
197
  /** Failed sign-in limits, counted over the audit log in a sliding window. */
189
198
  rateLimits?: {
190
199
  /** @default 15 */
@@ -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;;;;;;EAMA;;;;;;;EAOA;;;;;;;EAOA;;;;;;;;;EASA;;;;;;;EAOA;;;;;;;EAOA;;;;;;;;EAQA;;EAEA;;IAEE;;IAEA;;;;;;;EAOF;;EAEA;;IAEE;;IAEA;;IAEA;;IAEA;;IAEA;;;EAGF;;;;;;;IAOE;;;;;;;;;;EAUF,SAAS,SAAS;;;;;;EAMlB,qBAAqB;;;;;;EAMrB;;EAEA;;IAEE;;IAEA;;;;;;;;EAQF;;IAEE;;IAEA;;;;YAKQ,0BAA0B,SACpC,KAAK,kEAEL,KAAK;;YAGK;;YAGA;;EAEV,QAAQ,SAAS;;EAEjB,OAAO,SAAS;;EAEhB;;;;;;;EAOA;;;;;;;;YASU;;EAEV,SAAS;;EAET;EACA,UAAU,SAAS;;;;;;;;;YAUT;;EAEV;;EAEA;;EAEA,eAAe;;EAEf,kBAAkB;;;;;;;;;;EAUlB;;;;;;EAMA,SAAS,SAAS,wBAAwB;;;;;;EAM1C,QAAQ;;;;;EAKR,QAAQ;;;YAIE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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
@@ -105,8 +105,11 @@ An older core without the request log leaves the panel in-memory only.
105
105
  ## AI runs alongside HTTP requests
106
106
 
107
107
  The **AI** tab and each request's **AI runs** section display completed traces
108
- from optional `@warlock.js/ai-panoptic`. If it cannot be imported, the tab shows
109
- install/restart guidance and the other panels keep working.
108
+ from optional `@warlock.js/ai-panoptic`. If the tab is empty it says why
109
+ (`/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
112
+ other panels keep working.
110
113
 
111
114
  ```bash
112
115
  warlock add devtools
@@ -282,7 +285,7 @@ Environment variables:
282
285
 
283
286
  The accounts live in the app's database through Cascade. Roles are `viewer`
284
287
  and `admin`. Admins invite users with a 24-hour single-use link. Two-factor is
285
- required for admins by default (`twoFactor: "admins"`; or `"everyone"`): an
288
+ 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
286
289
  authenticator app, or passkeys when `@simplewebauthn/server` is installed, plus
287
290
  10 recovery codes. Every closed case answers the app's own 404.
288
291
 
@@ -292,7 +295,7 @@ Options under `production` (all optional, defaults in brackets):
292
295
  `requestRetentionHours` [24], `maxStoredSamplesPerMinute` [120],
293
296
  `reportIntervalMs` [10000], `trustedProxies` [[]], `requireHttps` [true],
294
297
  `allowedIps` [[]], `origin`, `session.idleMinutes` [30], `session.maxHours` [8],
295
- `twoFactor` ["admins"], `rateLimits.windowMinutes` [15], `rateLimits.account`
298
+ `twoFactor` ["admins"], `passwords.minLength` [8, from 8 to 72], `passwords.rejectCommon` [true], `rateLimits.windowMinutes` [15], `rateLimits.account`
296
299
  [5], `rateLimits.ip` [20], `rateLimits.global` [100], `rateLimits.lockMinutes`
297
300
  [15], `explain.executing` [false], `panels` [{}], `logLevels` [warn, error],
298
301
  `auditRetentionDays` [90], `passkeys.rpName`, `passkeys.rpId`.
@@ -355,18 +358,18 @@ Options under `production` (all optional, defaults in brackets):
355
358
  The app refuses to boot with a `DevtoolsProductionConfigError`
356
359
  (`DEVTOOLS_CONFIG_CODES` holds the messages):
357
360
 
358
- | Code | Fix |
359
- | ------- | --------------------------------------------------------------------------------------------------------------------------- |
360
- | `DT001` | Set `DEVTOOLS_PATH` or `production.path`. |
361
- | `DT002` | Use a path of 8+ characters starting with `/`, with letters, digits and `- _ . ~ /` only; not `/__warlock`. |
362
- | `DT003` | No admin: set `DEVTOOLS_ADMIN_EMAIL` plus a password or setup token, or run `warlock devtools:reset-admin --email <email>`. |
363
- | `DT004` | The env password breaks the rules (8+ characters, at most 72 bytes, not common, not the email). |
364
- | `DT005` | Install `@warlock.js/cascade` and configure a database. |
365
- | `DT006` | Set `encryption.key` (64 hex characters). |
366
- | `DT007` | An option is invalid (`share.maxDays` must be 1 to 365); the message names it. |
367
- | `DT008` | Add `devtoolsMigrations` to `database.migrations` and run `warlock migrate` (`devtools_shares` when sharing is on). |
368
- | `DT009` | Set the password or the setup token, not both. |
369
- | `DT010` | The setup token needs 32+ characters (`openssl rand -base64 32`). |
361
+ | Code | Fix |
362
+ | ------- | -------------------------------------------------------------------------------------------------------------------------------------------------- |
363
+ | `DT001` | Set `DEVTOOLS_PATH` or `production.path`. |
364
+ | `DT002` | Use a path of 8+ characters starting with `/`, with letters, digits and `- _ . ~ /` only; not `/__warlock`. |
365
+ | `DT003` | No admin: set `DEVTOOLS_ADMIN_EMAIL` plus a password or setup token, or run `warlock devtools:reset-admin --email <email>`. |
366
+ | `DT004` | The env password breaks the rules (`passwords.minLength`+ characters, at most 72 bytes, not common unless `rejectCommon` is false, not the email). |
367
+ | `DT005` | Install `@warlock.js/cascade` and configure a database. |
368
+ | `DT006` | Set `encryption.key` (64 hex characters). |
369
+ | `DT007` | An option is invalid (`share.maxDays` must be 1 to 365); the message names it. |
370
+ | `DT008` | Add `devtoolsMigrations` to `database.migrations` and run `warlock migrate` (`devtools_shares` when sharing is on). |
371
+ | `DT009` | Set the password or the setup token, not both. |
372
+ | `DT010` | The setup token needs 32+ characters (`openssl rand -base64 32`). |
370
373
 
371
374
  Every dashboard URL gives a 404: check that `production.enabled` is true, the
372
375
  dashboard is not disabled or locked (`warlock devtools:enable`), the request is
@@ -457,6 +460,11 @@ Panel styling: a package panel's CSS may use only the dashboard's variables (`DE
457
460
  `@warlock.js/devtools`: `--background --foreground --card --muted --muted-foreground --accent --border --brand
458
461
  --success --warning --info --destructive --chart-1..5` and the other shadcn names) plus variables it defines itself.
459
462
  Never use another name (such as `--text` or `--surface`): the dashboard does not define it, and text can become
460
- unreadable. The text tokens meet 4.5:1 contrast on `--background` and `--card` in both themes.
463
+ unreadable. The text tokens meet 4.5:1 contrast on `--background` and `--card` in both themes. In the light theme `--primary` is the
464
+ gold fill (dark `--primary-foreground` on it) and `--brand` is the deep amber for text; in the dark theme both are gold.
465
+
466
+ The dashboard shows the Warlock logo and installed core version at the top of the sidebar and the app's own
467
+ `package.json` name and version at the bottom. They come from `GET api/auth/session` (`warlockVersion`, `app`), read once
468
+ on the server, signed-in only, `null` when unknown.
461
469
 
462
470
 
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.58.0",
10
- "@warlock.js/cache": "5.58.0",
11
- "@warlock.js/cascade": "5.58.0",
12
- "@warlock.js/core": "5.58.0",
13
- "@warlock.js/logger": "5.58.0",
14
- "@warlock.js/queue": "5.58.0",
15
- "@warlock.js/scheduler": "5.58.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"
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.58.0",
55
+ "version": "5.59.0",
56
56
  "main": "./cjs/index.cjs",
57
57
  "module": "./esm/index.mjs",
58
58
  "types": "./esm/index.d.mts",
package/skills/SKILL.md CHANGED
@@ -97,8 +97,11 @@ An older core without the request log leaves the panel in-memory only.
97
97
  ## AI runs alongside HTTP requests
98
98
 
99
99
  The **AI** tab and each request's **AI runs** section display completed traces
100
- from optional `@warlock.js/ai-panoptic`. If it cannot be imported, the tab shows
101
- install/restart guidance and the other panels keep working.
100
+ from optional `@warlock.js/ai-panoptic`. If the tab is empty it says why
101
+ (`/api/ai` answers `reason`: `ai-missing`, `panoptic-missing`, `panoptic-failed` with the load
102
+ error (absolute paths replaced) and versions, `observation-off`, or `not-collected` in the
103
+ production dashboard, which never collects AI runs) with a title, one line and a copyable command; the
104
+ other panels keep working.
102
105
 
103
106
  ```bash
104
107
  warlock add devtools
@@ -274,7 +277,7 @@ Environment variables:
274
277
 
275
278
  The accounts live in the app's database through Cascade. Roles are `viewer`
276
279
  and `admin`. Admins invite users with a 24-hour single-use link. Two-factor is
277
- required for admins by default (`twoFactor: "admins"`; or `"everyone"`): an
280
+ 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
278
281
  authenticator app, or passkeys when `@simplewebauthn/server` is installed, plus
279
282
  10 recovery codes. Every closed case answers the app's own 404.
280
283
 
@@ -284,7 +287,7 @@ Options under `production` (all optional, defaults in brackets):
284
287
  `requestRetentionHours` [24], `maxStoredSamplesPerMinute` [120],
285
288
  `reportIntervalMs` [10000], `trustedProxies` [[]], `requireHttps` [true],
286
289
  `allowedIps` [[]], `origin`, `session.idleMinutes` [30], `session.maxHours` [8],
287
- `twoFactor` ["admins"], `rateLimits.windowMinutes` [15], `rateLimits.account`
290
+ `twoFactor` ["admins"], `passwords.minLength` [8, from 8 to 72], `passwords.rejectCommon` [true], `rateLimits.windowMinutes` [15], `rateLimits.account`
288
291
  [5], `rateLimits.ip` [20], `rateLimits.global` [100], `rateLimits.lockMinutes`
289
292
  [15], `explain.executing` [false], `panels` [{}], `logLevels` [warn, error],
290
293
  `auditRetentionDays` [90], `passkeys.rpName`, `passkeys.rpId`.
@@ -347,18 +350,18 @@ Options under `production` (all optional, defaults in brackets):
347
350
  The app refuses to boot with a `DevtoolsProductionConfigError`
348
351
  (`DEVTOOLS_CONFIG_CODES` holds the messages):
349
352
 
350
- | Code | Fix |
351
- | ------- | --------------------------------------------------------------------------------------------------------------------------- |
352
- | `DT001` | Set `DEVTOOLS_PATH` or `production.path`. |
353
- | `DT002` | Use a path of 8+ characters starting with `/`, with letters, digits and `- _ . ~ /` only; not `/__warlock`. |
354
- | `DT003` | No admin: set `DEVTOOLS_ADMIN_EMAIL` plus a password or setup token, or run `warlock devtools:reset-admin --email <email>`. |
355
- | `DT004` | The env password breaks the rules (8+ characters, at most 72 bytes, not common, not the email). |
356
- | `DT005` | Install `@warlock.js/cascade` and configure a database. |
357
- | `DT006` | Set `encryption.key` (64 hex characters). |
358
- | `DT007` | An option is invalid (`share.maxDays` must be 1 to 365); the message names it. |
359
- | `DT008` | Add `devtoolsMigrations` to `database.migrations` and run `warlock migrate` (`devtools_shares` when sharing is on). |
360
- | `DT009` | Set the password or the setup token, not both. |
361
- | `DT010` | The setup token needs 32+ characters (`openssl rand -base64 32`). |
353
+ | Code | Fix |
354
+ | ------- | -------------------------------------------------------------------------------------------------------------------------------------------------- |
355
+ | `DT001` | Set `DEVTOOLS_PATH` or `production.path`. |
356
+ | `DT002` | Use a path of 8+ characters starting with `/`, with letters, digits and `- _ . ~ /` only; not `/__warlock`. |
357
+ | `DT003` | No admin: set `DEVTOOLS_ADMIN_EMAIL` plus a password or setup token, or run `warlock devtools:reset-admin --email <email>`. |
358
+ | `DT004` | The env password breaks the rules (`passwords.minLength`+ characters, at most 72 bytes, not common unless `rejectCommon` is false, not the email). |
359
+ | `DT005` | Install `@warlock.js/cascade` and configure a database. |
360
+ | `DT006` | Set `encryption.key` (64 hex characters). |
361
+ | `DT007` | An option is invalid (`share.maxDays` must be 1 to 365); the message names it. |
362
+ | `DT008` | Add `devtoolsMigrations` to `database.migrations` and run `warlock migrate` (`devtools_shares` when sharing is on). |
363
+ | `DT009` | Set the password or the setup token, not both. |
364
+ | `DT010` | The setup token needs 32+ characters (`openssl rand -base64 32`). |
362
365
 
363
366
  Every dashboard URL gives a 404: check that `production.enabled` is true, the
364
367
  dashboard is not disabled or locked (`warlock devtools:enable`), the request is
@@ -449,4 +452,9 @@ Panel styling: a package panel's CSS may use only the dashboard's variables (`DE
449
452
  `@warlock.js/devtools`: `--background --foreground --card --muted --muted-foreground --accent --border --brand
450
453
  --success --warning --info --destructive --chart-1..5` and the other shadcn names) plus variables it defines itself.
451
454
  Never use another name (such as `--text` or `--surface`): the dashboard does not define it, and text can become
452
- unreadable. The text tokens meet 4.5:1 contrast on `--background` and `--card` in both themes.
455
+ unreadable. The text tokens meet 4.5:1 contrast on `--background` and `--card` in both themes. In the light theme `--primary` is the
456
+ gold fill (dark `--primary-foreground` on it) and `--brand` is the deep amber for text; in the dark theme both are gold.
457
+
458
+ The dashboard shows the Warlock logo and installed core version at the top of the sidebar and the app's own
459
+ `package.json` name and version at the bottom. They come from `GET api/auth/session` (`warlockVersion`, `app`), read once
460
+ on the server, signed-in only, `null` when unknown.