@warlock.js/devtools 5.57.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 (135) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/README.md +3 -0
  3. package/cjs/{ai-source-DTpxumMA.cjs → ai-source-BdvMfyKw.cjs} +84 -17
  4. package/cjs/ai-source-BdvMfyKw.cjs.map +1 -0
  5. package/cjs/app-versions-DfpPZOI2.cjs +253 -0
  6. package/cjs/app-versions-DfpPZOI2.cjs.map +1 -0
  7. package/cjs/{auth-DzU0gHDG.cjs → auth-B3wyjJnQ.cjs} +43 -406
  8. package/cjs/auth-B3wyjJnQ.cjs.map +1 -0
  9. package/cjs/{boot-Dy5OqgTM.cjs → boot-nczSvJ_F.cjs} +15 -12
  10. package/cjs/boot-nczSvJ_F.cjs.map +1 -0
  11. package/cjs/{capture-CqIiaznN.cjs → capture-CuyT8Vab.cjs} +4 -4
  12. package/cjs/{capture-CqIiaznN.cjs.map → capture-CuyT8Vab.cjs.map} +1 -1
  13. package/cjs/{cascade-store-pHjKeSFm.cjs → cascade-store-CuRRYzt_.cjs} +141 -4
  14. package/cjs/cascade-store-CuRRYzt_.cjs.map +1 -0
  15. package/cjs/{current-request-id-BoJJb3y7.cjs → current-request-id-CeQhRz9Q.cjs} +3 -3
  16. package/cjs/{current-request-id-BoJJb3y7.cjs.map → current-request-id-CeQhRz9Q.cjs.map} +1 -1
  17. package/cjs/{errors-CyZp5yS-.cjs → errors-BadbSDX8.cjs} +6 -4
  18. package/cjs/errors-BadbSDX8.cjs.map +1 -0
  19. package/cjs/helpers-BcMBFy9v.cjs +439 -0
  20. package/cjs/helpers-BcMBFy9v.cjs.map +1 -0
  21. package/cjs/{histogram-BaI-PnCv.cjs → histogram-DTOGnNBW.cjs} +6 -6
  22. package/cjs/{histogram-BaI-PnCv.cjs.map → histogram-DTOGnNBW.cjs.map} +1 -1
  23. package/cjs/{http-DCfXQvw-.cjs → http-Biauhqi0.cjs} +517 -28
  24. package/cjs/http-Biauhqi0.cjs.map +1 -0
  25. package/cjs/index.cjs +1 -1
  26. package/cjs/{insights-BKtqxdnP.cjs → insights-BjJA6Ret.cjs} +8 -7
  27. package/cjs/{insights-BKtqxdnP.cjs.map → insights-BjJA6Ret.cjs.map} +1 -1
  28. package/cjs/{migrations-w7GMsrQw.cjs → migrations-BP4cYTGo.cjs} +40 -5
  29. package/cjs/migrations-BP4cYTGo.cjs.map +1 -0
  30. package/cjs/{options-CWqFC5__.cjs → options-B9FHbRAJ.cjs} +29 -5
  31. package/cjs/options-B9FHbRAJ.cjs.map +1 -0
  32. package/cjs/{panels-Rcmeitu3.cjs → panels-D1ITm-jc.cjs} +77 -11
  33. package/cjs/panels-D1ITm-jc.cjs.map +1 -0
  34. package/cjs/{process-panel-DEOnLxoT.cjs → process-panel-DskSA7Cm.cjs} +4 -4
  35. package/cjs/{process-panel-DEOnLxoT.cjs.map → process-panel-DskSA7Cm.cjs.map} +1 -1
  36. package/cjs/production/index.cjs +4 -4
  37. package/cjs/{server-ykxsOwob.cjs → server-D3XRbSSb.cjs} +8 -5
  38. package/cjs/server-D3XRbSSb.cjs.map +1 -0
  39. package/cjs/{src-UPtTCI2j.cjs → src-QcNghoYN.cjs} +52 -15
  40. package/cjs/src-QcNghoYN.cjs.map +1 -0
  41. package/cjs/{store-aq207T8v.cjs → store-CNFv3wVp.cjs} +2 -2
  42. package/cjs/{stream-route-CJTABkUy.cjs → stream-route-BqyAlfxQ.cjs} +92 -17
  43. package/cjs/stream-route-BqyAlfxQ.cjs.map +1 -0
  44. package/esm/app-versions.mjs +74 -0
  45. package/esm/app-versions.mjs.map +1 -0
  46. package/esm/devtools-connector.d.mts.map +1 -1
  47. package/esm/devtools-connector.mjs +10 -3
  48. package/esm/devtools-connector.mjs.map +1 -1
  49. package/esm/index.d.mts +3 -3
  50. package/esm/panel-errors.mjs +33 -0
  51. package/esm/panel-errors.mjs.map +1 -0
  52. package/esm/panels.mjs +73 -6
  53. package/esm/panels.mjs.map +1 -1
  54. package/esm/production/auth/helpers.mjs +8 -5
  55. package/esm/production/auth/helpers.mjs.map +1 -1
  56. package/esm/production/auth/service.mjs +15 -5
  57. package/esm/production/auth/service.mjs.map +1 -1
  58. package/esm/production/boot.mjs +5 -2
  59. package/esm/production/boot.mjs.map +1 -1
  60. package/esm/production/contracts.d.mts +75 -2
  61. package/esm/production/contracts.d.mts.map +1 -1
  62. package/esm/production/contracts.mjs +5 -1
  63. package/esm/production/contracts.mjs.map +1 -1
  64. package/esm/production/errors.d.mts +1 -1
  65. package/esm/production/errors.mjs +5 -3
  66. package/esm/production/errors.mjs.map +1 -1
  67. package/esm/production/http/access.mjs +6 -2
  68. package/esm/production/http/access.mjs.map +1 -1
  69. package/esm/production/http/constants.mjs +7 -1
  70. package/esm/production/http/constants.mjs.map +1 -1
  71. package/esm/production/http/context.mjs.map +1 -1
  72. package/esm/production/http/cookie.mjs +23 -2
  73. package/esm/production/http/cookie.mjs.map +1 -1
  74. package/esm/production/http/mount.mjs +25 -3
  75. package/esm/production/http/mount.mjs.map +1 -1
  76. package/esm/production/http/share-session.mjs +114 -0
  77. package/esm/production/http/share-session.mjs.map +1 -0
  78. package/esm/production/http/share.mjs +339 -0
  79. package/esm/production/http/share.mjs.map +1 -0
  80. package/esm/production/index.d.mts +2 -2
  81. package/esm/production/insights/writer.mjs +2 -1
  82. package/esm/production/insights/writer.mjs.map +1 -1
  83. package/esm/production/options.d.mts +10 -1
  84. package/esm/production/options.d.mts.map +1 -1
  85. package/esm/production/options.mjs +27 -3
  86. package/esm/production/options.mjs.map +1 -1
  87. package/esm/production/store/cascade-store.mjs +49 -2
  88. package/esm/production/store/cascade-store.mjs.map +1 -1
  89. package/esm/production/store/mapping.mjs +29 -1
  90. package/esm/production/store/mapping.mjs.map +1 -1
  91. package/esm/production/store/memory-store.mjs +62 -0
  92. package/esm/production/store/memory-store.mjs.map +1 -1
  93. package/esm/production/store/migrations.d.mts +2 -1
  94. package/esm/production/store/migrations.d.mts.map +1 -1
  95. package/esm/production/store/migrations.mjs +5 -2
  96. package/esm/production/store/migrations.mjs.map +1 -1
  97. package/esm/production/store/models/index.mjs +3 -1
  98. package/esm/production/store/models/share.migration.mjs +27 -0
  99. package/esm/production/store/models/share.migration.mjs.map +1 -0
  100. package/esm/production/store/models/share.model.mjs +13 -0
  101. package/esm/production/store/models/share.model.mjs.map +1 -0
  102. package/esm/server/ai-routes.mjs +20 -6
  103. package/esm/server/ai-routes.mjs.map +1 -1
  104. package/esm/server/panel-files.mjs +35 -0
  105. package/esm/server/panel-files.mjs.map +1 -0
  106. package/esm/server/panel-routes.mjs +27 -7
  107. package/esm/server/panel-routes.mjs.map +1 -1
  108. package/esm/server/session-routes.mjs +4 -1
  109. package/esm/server/session-routes.mjs.map +1 -1
  110. package/esm/sources/ai-source.d.mts.map +1 -1
  111. package/esm/sources/ai-source.mjs +75 -7
  112. package/esm/sources/ai-source.mjs.map +1 -1
  113. package/esm/types.d.mts +91 -3
  114. package/esm/types.d.mts.map +1 -1
  115. package/llms-full.txt +57 -19
  116. package/package.json +8 -8
  117. package/skills/SKILL.md +57 -19
  118. package/ui/dashboard/assets/app.css +1 -1
  119. package/ui/dashboard/assets/app.js +16 -16
  120. package/ui/dashboard/build-info.json +7 -7
  121. package/cjs/ai-source-DTpxumMA.cjs.map +0 -1
  122. package/cjs/auth-DzU0gHDG.cjs.map +0 -1
  123. package/cjs/boot-Dy5OqgTM.cjs.map +0 -1
  124. package/cjs/cascade-store-pHjKeSFm.cjs.map +0 -1
  125. package/cjs/contracts-CVmplkNb.cjs +0 -112
  126. package/cjs/contracts-CVmplkNb.cjs.map +0 -1
  127. package/cjs/errors-CyZp5yS-.cjs.map +0 -1
  128. package/cjs/http-DCfXQvw-.cjs.map +0 -1
  129. package/cjs/migrations-w7GMsrQw.cjs.map +0 -1
  130. package/cjs/options-CWqFC5__.cjs.map +0 -1
  131. package/cjs/panels-Rcmeitu3.cjs.map +0 -1
  132. package/cjs/rolldown-runtime-Zuuoy_Rh.cjs +0 -52
  133. package/cjs/server-ykxsOwob.cjs.map +0 -1
  134. package/cjs/src-UPtTCI2j.cjs.map +0 -1
  135. package/cjs/stream-route-CJTABkUy.cjs.map +0 -1
@@ -4,6 +4,7 @@ import { DevtoolsInvitesMigration } from "./models/invite.migration.mjs";
4
4
  import { DevtoolsReportsMigration } from "./models/report.migration.mjs";
5
5
  import { DevtoolsSamplesMigration } from "./models/sample.migration.mjs";
6
6
  import { DevtoolsSessionsMigration } from "./models/session.migration.mjs";
7
+ import { DevtoolsSharesMigration } from "./models/share.migration.mjs";
7
8
  import { DevtoolsStateMigration } from "./models/state.migration.mjs";
8
9
  import "./models/index.mjs";
9
10
 
@@ -11,7 +12,8 @@ import "./models/index.mjs";
11
12
  /**
12
13
  * The migrations of the production monitor's tables/collections:
13
14
  * `devtools_accounts`, `devtools_sessions`, `devtools_invites`,
14
- * `devtools_audit`, `devtools_state`, `devtools_samples`, `devtools_reports`.
15
+ * `devtools_audit`, `devtools_state`, `devtools_samples`, `devtools_reports`,
16
+ * `devtools_shares`.
15
17
  * An app lists them in `warlock.config.ts > database.migrations`.
16
18
  */
17
19
  const devtoolsMigrations = [
@@ -21,7 +23,8 @@ const devtoolsMigrations = [
21
23
  DevtoolsAuditMigration,
22
24
  DevtoolsStateMigration,
23
25
  DevtoolsSamplesMigration,
24
- DevtoolsReportsMigration
26
+ DevtoolsReportsMigration,
27
+ DevtoolsSharesMigration
25
28
  ];
26
29
 
27
30
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"migrations.mjs","names":[],"sources":["../../../../../../../../../packages/devtools/src/production/store/migrations.ts"],"sourcesContent":["import type { MigrationConstructor } from \"@warlock.js/cascade\";\nimport {\n DevtoolsAccountsMigration,\n DevtoolsAuditMigration,\n DevtoolsInvitesMigration,\n DevtoolsReportsMigration,\n DevtoolsSamplesMigration,\n DevtoolsSessionsMigration,\n DevtoolsStateMigration,\n} from \"./models\";\n\n/**\n * The migrations of the production monitor's tables/collections:\n * `devtools_accounts`, `devtools_sessions`, `devtools_invites`,\n * `devtools_audit`, `devtools_state`, `devtools_samples`, `devtools_reports`.\n * An app lists them in `warlock.config.ts > database.migrations`.\n */\nexport const devtoolsMigrations: readonly MigrationConstructor[] = [\n DevtoolsAccountsMigration,\n DevtoolsSessionsMigration,\n DevtoolsInvitesMigration,\n DevtoolsAuditMigration,\n DevtoolsStateMigration,\n DevtoolsSamplesMigration,\n DevtoolsReportsMigration,\n];\n"],"mappings":";;;;;;;;;;;;;;;;AAiBA,MAAa,qBAAsD;CACjE;CACA;CACA;CACA;CACA;CACA;CACA;AACF"}
1
+ {"version":3,"file":"migrations.mjs","names":[],"sources":["../../../../../../../../../packages/devtools/src/production/store/migrations.ts"],"sourcesContent":["import type { MigrationConstructor } from \"@warlock.js/cascade\";\nimport {\n DevtoolsAccountsMigration,\n DevtoolsAuditMigration,\n DevtoolsInvitesMigration,\n DevtoolsReportsMigration,\n DevtoolsSamplesMigration,\n DevtoolsSessionsMigration,\n DevtoolsSharesMigration,\n DevtoolsStateMigration,\n} from \"./models\";\n\n/**\n * The migrations of the production monitor's tables/collections:\n * `devtools_accounts`, `devtools_sessions`, `devtools_invites`,\n * `devtools_audit`, `devtools_state`, `devtools_samples`, `devtools_reports`,\n * `devtools_shares`.\n * An app lists them in `warlock.config.ts > database.migrations`.\n */\nexport const devtoolsMigrations: readonly MigrationConstructor[] = [\n DevtoolsAccountsMigration,\n DevtoolsSessionsMigration,\n DevtoolsInvitesMigration,\n DevtoolsAuditMigration,\n DevtoolsStateMigration,\n DevtoolsSamplesMigration,\n DevtoolsReportsMigration,\n DevtoolsSharesMigration,\n];\n"],"mappings":";;;;;;;;;;;;;;;;;;AAmBA,MAAa,qBAAsD;CACjE;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF"}
@@ -11,7 +11,9 @@ import { DevtoolsSampleRow } from "./sample.model.mjs";
11
11
  import { DevtoolsSamplesMigration } from "./sample.migration.mjs";
12
12
  import { DevtoolsSessionRow } from "./session.model.mjs";
13
13
  import { DevtoolsSessionsMigration } from "./session.migration.mjs";
14
+ import { DevtoolsShareRow } from "./share.model.mjs";
15
+ import { DevtoolsSharesMigration } from "./share.migration.mjs";
14
16
  import { DevtoolsStateRow } from "./state.model.mjs";
15
17
  import { DevtoolsStateMigration } from "./state.migration.mjs";
16
18
 
17
- export { DevtoolsAccountRow, DevtoolsAccountsMigration, DevtoolsAuditMigration, DevtoolsAuditRow, DevtoolsInviteRow, DevtoolsInvitesMigration, DevtoolsReportRow, DevtoolsReportsMigration, DevtoolsRowModel, DevtoolsSampleRow, DevtoolsSamplesMigration, DevtoolsSessionRow, DevtoolsSessionsMigration, DevtoolsStateMigration, DevtoolsStateRow };
19
+ export { DevtoolsAccountRow, DevtoolsAccountsMigration, DevtoolsAuditMigration, DevtoolsAuditRow, DevtoolsInviteRow, DevtoolsInvitesMigration, DevtoolsReportRow, DevtoolsReportsMigration, DevtoolsRowModel, DevtoolsSampleRow, DevtoolsSamplesMigration, DevtoolsSessionRow, DevtoolsSessionsMigration, DevtoolsShareRow, DevtoolsSharesMigration, DevtoolsStateMigration, DevtoolsStateRow };
@@ -0,0 +1,27 @@
1
+ import { DevtoolsShareRow } from "./share.model.mjs";
2
+ import { migrate } from "@warlock.js/cascade";
3
+
4
+ //#region ../../packages/devtools/src/production/store/models/share.migration.ts
5
+ const DevtoolsSharesMigration = migrate(DevtoolsShareRow, {
6
+ name: "devtoolsShares",
7
+ up() {
8
+ this.createTableIfNotExists();
9
+ this.string("id", 64).primary().unique();
10
+ this.string("token_hash", 64).unique();
11
+ this.string("panel", 64);
12
+ this.string("label", 80);
13
+ this.string("created_by", 64).nullable();
14
+ this.bigInteger("created_at");
15
+ this.bigInteger("expires_at").index();
16
+ this.bigInteger("revoked_at").nullable();
17
+ this.bigInteger("last_used_at").nullable();
18
+ this.integer("uses").default(0);
19
+ },
20
+ down() {
21
+ this.dropTableIfExists();
22
+ }
23
+ });
24
+
25
+ //#endregion
26
+ export { DevtoolsSharesMigration };
27
+ //# sourceMappingURL=share.migration.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"share.migration.mjs","names":[],"sources":["../../../../../../../../../../packages/devtools/src/production/store/models/share.migration.ts"],"sourcesContent":["import { migrate } from \"@warlock.js/cascade\";\nimport { DevtoolsShareRow } from \"./share.model\";\n\nexport const DevtoolsSharesMigration = migrate(DevtoolsShareRow, {\n name: \"devtoolsShares\",\n up() {\n this.createTableIfNotExists();\n\n // The id is a string the store supplies; `unique` also covers MongoDB,\n // which ignores primary keys.\n this.string(\"id\", 64).primary().unique();\n\n this.string(\"token_hash\", 64).unique();\n this.string(\"panel\", 64);\n this.string(\"label\", 80);\n this.string(\"created_by\", 64).nullable();\n this.bigInteger(\"created_at\");\n this.bigInteger(\"expires_at\").index();\n this.bigInteger(\"revoked_at\").nullable();\n this.bigInteger(\"last_used_at\").nullable();\n this.integer(\"uses\").default(0);\n },\n down() {\n this.dropTableIfExists();\n },\n});\n"],"mappings":";;;;AAGA,MAAa,0BAA0B,QAAQ,kBAAkB;CAC/D,MAAM;CACN,KAAK;EACH,KAAK,uBAAuB;EAI5B,KAAK,OAAO,MAAM,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,OAAO;EAEvC,KAAK,OAAO,cAAc,EAAE,CAAC,CAAC,OAAO;EACrC,KAAK,OAAO,SAAS,EAAE;EACvB,KAAK,OAAO,SAAS,EAAE;EACvB,KAAK,OAAO,cAAc,EAAE,CAAC,CAAC,SAAS;EACvC,KAAK,WAAW,YAAY;EAC5B,KAAK,WAAW,YAAY,CAAC,CAAC,MAAM;EACpC,KAAK,WAAW,YAAY,CAAC,CAAC,SAAS;EACvC,KAAK,WAAW,cAAc,CAAC,CAAC,SAAS;EACzC,KAAK,QAAQ,MAAM,CAAC,CAAC,QAAQ,CAAC;CAChC;CACA,OAAO;EACL,KAAK,kBAAkB;CACzB;AACF,CAAC"}
@@ -0,0 +1,13 @@
1
+ import { DevtoolsRowModel } from "./base.mjs";
2
+
3
+ //#region ../../packages/devtools/src/production/store/models/share.model.ts
4
+ /** A row of `devtools_shares`. */
5
+ var DevtoolsShareRow = class extends DevtoolsRowModel {
6
+ static {
7
+ this.table = "devtools_shares";
8
+ }
9
+ };
10
+
11
+ //#endregion
12
+ export { DevtoolsShareRow };
13
+ //# sourceMappingURL=share.model.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"share.model.mjs","names":[],"sources":["../../../../../../../../../../packages/devtools/src/production/store/models/share.model.ts"],"sourcesContent":["import { DevtoolsRowModel } from \"./base\";\n\n/** A row of `devtools_shares`. */\nexport class DevtoolsShareRow extends DevtoolsRowModel {\n public static table = \"devtools_shares\";\n}\n"],"mappings":";;;;AAGA,IAAa,mBAAb,cAAsC,iBAAiB;;eAC/B;;AACxB"}
@@ -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,CA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realpath, stat } from "node:fs/promises";
3
+
4
+ //#region ../../packages/devtools/src/server/panel-files.ts
5
+ /** The longest request path a panel's file route looks at. */
6
+ const MAX_PATH_LENGTH = 512;
7
+ /**
8
+ * Resolves a request path inside a panel's folder of images, or `null` when
9
+ * it must answer 404. The path is the one URL decoding left (decoded once);
10
+ * it is refused when it is empty, absolute, has an empty, `.` or `..`
11
+ * segment, a backslash, a colon or a NUL byte, or an extension the panel did
12
+ * not list. The resolved file must be a regular file whose real path (links
13
+ * followed) stays inside the real path of the folder.
14
+ */
15
+ async function resolvePanelFile(files, requested) {
16
+ if (typeof requested !== "string" || requested === "" || requested.length > MAX_PATH_LENGTH) return null;
17
+ if (/[\0\\:]/.test(requested) || requested.startsWith("/")) return null;
18
+ const segments = requested.split("/");
19
+ if (segments.some((segment) => segment === "" || segment === "." || segment === "..")) return null;
20
+ const extension = path.extname(segments[segments.length - 1] ?? "").toLowerCase();
21
+ if (!files.extensions.includes(extension)) return null;
22
+ try {
23
+ const root = await realpath(files.dir);
24
+ const real = await realpath(path.join(root, ...segments));
25
+ if (!real.startsWith(root.endsWith(path.sep) ? root : root + path.sep)) return null;
26
+ if (!files.extensions.includes(path.extname(real).toLowerCase())) return null;
27
+ return (await stat(real)).isFile() ? real : null;
28
+ } catch {
29
+ return null;
30
+ }
31
+ }
32
+
33
+ //#endregion
34
+ export { resolvePanelFile };
35
+ //# sourceMappingURL=panel-files.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"panel-files.mjs","names":[],"sources":["../../../../../../../../packages/devtools/src/server/panel-files.ts"],"sourcesContent":["import { realpath, stat } from \"node:fs/promises\";\nimport path from \"node:path\";\nimport type { MountedPanelFiles } from \"../panels\";\n\n/** The longest request path a panel's file route looks at. */\nconst MAX_PATH_LENGTH = 512;\n\n/**\n * Resolves a request path inside a panel's folder of images, or `null` when\n * it must answer 404. The path is the one URL decoding left (decoded once);\n * it is refused when it is empty, absolute, has an empty, `.` or `..`\n * segment, a backslash, a colon or a NUL byte, or an extension the panel did\n * not list. The resolved file must be a regular file whose real path (links\n * followed) stays inside the real path of the folder.\n */\nexport async function resolvePanelFile(\n files: MountedPanelFiles,\n requested: unknown,\n): Promise<string | null> {\n if (typeof requested !== \"string\" || requested === \"\" || requested.length > MAX_PATH_LENGTH) {\n return null;\n }\n\n if (/[\\0\\\\:]/.test(requested) || requested.startsWith(\"/\")) return null;\n\n const segments = requested.split(\"/\");\n\n if (segments.some((segment) => segment === \"\" || segment === \".\" || segment === \"..\")) {\n return null;\n }\n\n const extension = path.extname(segments[segments.length - 1] ?? \"\").toLowerCase();\n\n if (!files.extensions.includes(extension)) return null;\n\n try {\n const root = await realpath(files.dir);\n const real = await realpath(path.join(root, ...segments));\n\n if (!real.startsWith(root.endsWith(path.sep) ? root : root + path.sep)) return null;\n\n // A link inside the folder must not turn an image name into another kind of file.\n if (!files.extensions.includes(path.extname(real).toLowerCase())) return null;\n\n return (await stat(real)).isFile() ? real : null;\n } catch {\n return null;\n }\n}\n"],"mappings":";;;;;AAKA,MAAM,kBAAkB;;;;;;;;;AAUxB,eAAsB,iBACpB,OACA,WACwB;CACxB,IAAI,OAAO,cAAc,YAAY,cAAc,MAAM,UAAU,SAAS,iBAC1E,OAAO;CAGT,IAAI,UAAU,KAAK,SAAS,KAAK,UAAU,WAAW,GAAG,GAAG,OAAO;CAEnE,MAAM,WAAW,UAAU,MAAM,GAAG;CAEpC,IAAI,SAAS,MAAM,YAAY,YAAY,MAAM,YAAY,OAAO,YAAY,IAAI,GAClF,OAAO;CAGT,MAAM,YAAY,KAAK,QAAQ,SAAS,SAAS,SAAS,MAAM,EAAE,CAAC,CAAC,YAAY;CAEhF,IAAI,CAAC,MAAM,WAAW,SAAS,SAAS,GAAG,OAAO;CAElD,IAAI;EACF,MAAM,OAAO,MAAM,SAAS,MAAM,GAAG;EACrC,MAAM,OAAO,MAAM,SAAS,KAAK,KAAK,MAAM,GAAG,QAAQ,CAAC;EAExD,IAAI,CAAC,KAAK,WAAW,KAAK,SAAS,KAAK,GAAG,IAAI,OAAO,OAAO,KAAK,GAAG,GAAG,OAAO;EAG/E,IAAI,CAAC,MAAM,WAAW,SAAS,KAAK,QAAQ,IAAI,CAAC,CAAC,YAAY,CAAC,GAAG,OAAO;EAEzE,QAAQ,MAAM,KAAK,IAAI,EAAC,CAAE,OAAO,IAAI,OAAO;CAC9C,QAAQ;EACN,OAAO;CACT;AACF"}
@@ -1,16 +1,31 @@
1
1
  import { panelContentType } from "../panels.mjs";
2
2
  import { sendFile } from "./ui-assets.mjs";
3
+ import { resolvePanelFile } from "./panel-files.mjs";
4
+ import { createReadStream } from "node:fs";
3
5
 
4
6
  //#region ../../packages/devtools/src/server/panel-routes.ts
7
+ /** Sends one image of a panel's folder with its content type, or answers 404. */
8
+ async function sendPanelFile(panel, requested, request, reply, notFound) {
9
+ const file = panel.files === null ? null : await resolvePanelFile(panel.files, requested);
10
+ if (file === null) return notFound(request, reply);
11
+ reply.header("X-Content-Type-Options", "nosniff").header("Cache-Control", "no-store").header("Content-Type", panelContentType(file));
12
+ return reply.send(createReadStream(file));
13
+ }
5
14
  /**
6
- * Mounts each panel's data routes at `/api/<id><route path>` and its view
7
- * module and assets at `/panels/<id>/<name>`. Callers register this inside
8
- * the devtools scope, so the guard covers every one of them. A file is
9
- * served only when its name is listed by the panel; the request never
10
- * becomes a filesystem path.
15
+ * Mounts each panel's data routes at `/api/<id><route path>`, its view
16
+ * module and assets at `/panels/<id>/<name>`, and its folder of images at
17
+ * `/panels/<id>/files/<path>`. Callers register this inside the devtools
18
+ * scope, so the guard covers every one of them. A file is served only when
19
+ * its name is listed by the panel (or, for `files`, resolves inside the
20
+ * panel's folder with a listed extension); the request never becomes a
21
+ * filesystem path on its own.
11
22
  */
12
- function registerPanelRoutes(server, panels) {
23
+ function registerPanelRoutes(server, panels, options = {}) {
13
24
  const byId = new Map(panels.map((panel) => [panel.id, panel]));
25
+ const notFound = options.notFound ?? ((_request, reply) => {
26
+ reply.code(404).header("Cache-Control", "no-store").send();
27
+ return reply;
28
+ });
14
29
  for (const panel of panels) for (const route of panel.routes) server.route({
15
30
  method: route.method,
16
31
  url: `/api/${panel.id}${route.path}`,
@@ -26,6 +41,11 @@ function registerPanelRoutes(server, panels) {
26
41
  return result;
27
42
  }
28
43
  });
44
+ server.get("/panels/:id/files/*", async (request, reply) => {
45
+ const panel = byId.get(request.params.id);
46
+ if (panel === void 0) return notFound(request, reply);
47
+ return sendPanelFile(panel, request.params["*"], request, reply, notFound);
48
+ });
29
49
  server.get("/panels/:id/:name", (request, reply) => {
30
50
  const panel = byId.get(request.params.id);
31
51
  const name = request.params.name;
@@ -40,5 +60,5 @@ function registerPanelRoutes(server, panels) {
40
60
  }
41
61
 
42
62
  //#endregion
43
- export { registerPanelRoutes };
63
+ export { registerPanelRoutes, sendPanelFile };
44
64
  //# sourceMappingURL=panel-routes.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"panel-routes.mjs","names":[],"sources":["../../../../../../../../packages/devtools/src/server/panel-routes.ts"],"sourcesContent":["import type { FastifyInstance } from \"fastify\";\nimport { type MountedDevtoolsPanel, panelContentType } from \"../panels\";\nimport type { DevtoolsPanelRequest } from \"../types\";\nimport { sendFile } from \"./ui-assets\";\n\n/**\n * Mounts each panel's data routes at `/api/<id><route path>` and its view\n * module and assets at `/panels/<id>/<name>`. Callers register this inside\n * the devtools scope, so the guard covers every one of them. A file is\n * served only when its name is listed by the panel; the request never\n * becomes a filesystem path.\n */\nexport function registerPanelRoutes(\n server: FastifyInstance,\n panels: readonly MountedDevtoolsPanel[],\n): void {\n const byId = new Map(panels.map((panel) => [panel.id, panel]));\n\n for (const panel of panels) {\n for (const route of panel.routes) {\n server.route({\n method: route.method,\n url: `/api/${panel.id}${route.path}`,\n handler: async (request, reply) => {\n const input: DevtoolsPanelRequest = {\n params: (request.params ?? {}) as Record<string, string>,\n query: (request.query ?? {}) as Record<string, string | string[]>,\n body: request.body,\n };\n const result = await route.handler(input);\n\n reply.header(\"cache-control\", \"no-store\");\n\n if (result === undefined) return reply.code(204).send();\n\n return result;\n },\n });\n }\n }\n\n server.get<{ Params: { id: string; name: string } }>(\"/panels/:id/:name\", (request, reply) => {\n const panel = byId.get(request.params.id);\n const name = request.params.name;\n const file =\n panel === undefined\n ? undefined\n : name === \"view.js\"\n ? panel.view\n : Object.hasOwn(panel.assets, name)\n ? panel.assets[name]\n : undefined;\n\n if (file === undefined) {\n reply.code(404).header(\"Cache-Control\", \"no-store\").send();\n return;\n }\n\n reply.header(\"X-Content-Type-Options\", \"nosniff\");\n sendFile(reply, file, panelContentType(name));\n });\n}\n"],"mappings":";;;;;;;;;;;AAYA,SAAgB,oBACd,QACA,QACM;CACN,MAAM,OAAO,IAAI,IAAI,OAAO,KAAK,UAAU,CAAC,MAAM,IAAI,KAAK,CAAC,CAAC;CAE7D,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,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 = (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,CAA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AAM,OAAO,0BAA0B,SAAS;EAChD,SAAS,OAAO,MAAM,iBAAiB,IAAI,CAAC;CAC9C,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
  /**
@@ -14,7 +15,9 @@ function developmentSessionView(deps) {
14
15
  csrf: null,
15
16
  expiresAt: null,
16
17
  instance: deps.instance ?? null,
17
- methods: null
18
+ methods: null,
19
+ share: null,
20
+ ...readVersions()
18
21
  };
19
22
  }
20
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 };\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): 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;CACX;AACF;;AAGA,SAAgB,WACd,MACA,QACqB;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,OAAc,MAA8B;CAC3E,MAAM,yBAAS,IAAI,IAAY;CAC/B,IAAI,YAAY;CAChB,IAAI,UAAU;CACd,IAAI;CACJ,IAAI,aAAa;CACjB,IAAI,iBAAiB;CACrB,IAAI,cAAc;CAClB,IAAI,qBAAqB;CACzB,IAAI,sBAAsB;CAC1B,MAAM,SAAS,SAA0B;EACvC,MAAM,aAAa,KAAK,cAAc,CAAC;EACvC,MAAM,QAAQ,WAAW;EACzB,MAAM,WAAW,WAAW;EAC5B,IAAI,OAAO,UAAU,UACnB,OAAO,IAAI,OAAO,aAAa,WAAW,GAAG,SAAS,GAAG,UAAU,KAAK;EAC1E,IAAI,KAAK,SAAS,QAAQ,aAAa;EACvC,IAAI,OAAO,WAAW,YAAY,UAAU,WAAW,WAAW;EAClE,IAAI,OAAO,WAAW,uBAAuB,UAC3C,aAAa,aAAa,KAAK,WAAW;EAC5C,IAAI,OAAO,WAAW,4BAA4B,UAChD,kBAAkB,WAAW;EAC/B,IAAI,OAAO,WAAW,iCAAiC,UACrD,uBAAuB,WAAW;EACpC,IAAI,MAAM,QAAQ,WAAW,oBAAoB,GAAG;GAClD,MAAM,UAAqB,WAAW;GACtC,KAAK,MAAM,UAAU,SAAS;IAC5B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AAQ,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,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 { 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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