@warlock.js/devtools 5.56.0 → 5.58.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 (121) hide show
  1. package/CHANGELOG.md +31 -0
  2. package/README.md +3 -0
  3. package/cjs/{auth-DzU0gHDG.cjs → auth-DV2GA1A9.cjs} +33 -403
  4. package/cjs/auth-DV2GA1A9.cjs.map +1 -0
  5. package/cjs/{boot-BQi0Etor.cjs → boot-CyeHPFtk.cjs} +14 -12
  6. package/cjs/boot-CyeHPFtk.cjs.map +1 -0
  7. package/cjs/{capture-CqIiaznN.cjs → capture-DcyBhdqw.cjs} +3 -3
  8. package/cjs/{capture-CqIiaznN.cjs.map → capture-DcyBhdqw.cjs.map} +1 -1
  9. package/cjs/{cascade-store-pHjKeSFm.cjs → cascade-store-DEGxAFDI.cjs} +141 -4
  10. package/cjs/cascade-store-DEGxAFDI.cjs.map +1 -0
  11. package/cjs/{contracts-CVmplkNb.cjs → contracts-CDuY-ahl.cjs} +6 -2
  12. package/cjs/{contracts-CVmplkNb.cjs.map → contracts-CDuY-ahl.cjs.map} +1 -1
  13. package/cjs/{errors-CyZp5yS-.cjs → errors-DEqdWaqm.cjs} +3 -1
  14. package/cjs/{errors-CyZp5yS-.cjs.map → errors-DEqdWaqm.cjs.map} +1 -1
  15. package/cjs/helpers-7k_Q-abk.cjs +436 -0
  16. package/cjs/helpers-7k_Q-abk.cjs.map +1 -0
  17. package/cjs/{histogram-BaI-PnCv.cjs → histogram-BRV5eHcp.cjs} +2 -2
  18. package/cjs/{histogram-BaI-PnCv.cjs.map → histogram-BRV5eHcp.cjs.map} +1 -1
  19. package/cjs/{http-CabcUwBx.cjs → http-XNLYU2vS.cjs} +517 -28
  20. package/cjs/http-XNLYU2vS.cjs.map +1 -0
  21. package/cjs/index.cjs +2 -1
  22. package/cjs/{insights-BKtqxdnP.cjs → insights-BBZnUpWO.cjs} +4 -3
  23. package/cjs/{insights-BKtqxdnP.cjs.map → insights-BBZnUpWO.cjs.map} +1 -1
  24. package/cjs/{migrations-w7GMsrQw.cjs → migrations-DTTzCNpR.cjs} +38 -3
  25. package/cjs/migrations-DTTzCNpR.cjs.map +1 -0
  26. package/cjs/{options-CWqFC5__.cjs → options-CHhmQJic.cjs} +16 -4
  27. package/cjs/options-CHhmQJic.cjs.map +1 -0
  28. package/cjs/{panels-B0dAfGbJ.cjs → panels-CHd20RK5.cjs} +97 -10
  29. package/cjs/panels-CHd20RK5.cjs.map +1 -0
  30. package/cjs/production/index.cjs +4 -4
  31. package/cjs/{server-B6xdeKS8.cjs → server-C8JfggQU.cjs} +5 -4
  32. package/cjs/server-C8JfggQU.cjs.map +1 -0
  33. package/cjs/{src-Ce-3Lniv.cjs → src-DjOUdhKc.cjs} +96 -10
  34. package/cjs/src-DjOUdhKc.cjs.map +1 -0
  35. package/cjs/{store-aq207T8v.cjs → store-C06KO_A1.cjs} +2 -2
  36. package/cjs/{stream-route-BGJa-zQu.cjs → stream-route-D4k-sJvW.cjs} +70 -9
  37. package/cjs/stream-route-D4k-sJvW.cjs.map +1 -0
  38. package/esm/devtools-connector.d.mts.map +1 -1
  39. package/esm/devtools-connector.mjs +10 -3
  40. package/esm/devtools-connector.mjs.map +1 -1
  41. package/esm/index.d.mts +4 -3
  42. package/esm/index.mjs +2 -1
  43. package/esm/panel-errors.mjs +33 -0
  44. package/esm/panel-errors.mjs.map +1 -0
  45. package/esm/panel-tokens.d.mts +13 -0
  46. package/esm/panel-tokens.d.mts.map +1 -0
  47. package/esm/panel-tokens.mjs +45 -0
  48. package/esm/panel-tokens.mjs.map +1 -0
  49. package/esm/panels.mjs +96 -9
  50. package/esm/panels.mjs.map +1 -1
  51. package/esm/production/auth/service.mjs +4 -2
  52. package/esm/production/auth/service.mjs.map +1 -1
  53. package/esm/production/boot.mjs +4 -2
  54. package/esm/production/boot.mjs.map +1 -1
  55. package/esm/production/contracts.d.mts +68 -2
  56. package/esm/production/contracts.d.mts.map +1 -1
  57. package/esm/production/contracts.mjs +5 -1
  58. package/esm/production/contracts.mjs.map +1 -1
  59. package/esm/production/errors.mjs +2 -0
  60. package/esm/production/errors.mjs.map +1 -1
  61. package/esm/production/http/access.mjs +6 -2
  62. package/esm/production/http/access.mjs.map +1 -1
  63. package/esm/production/http/constants.mjs +7 -1
  64. package/esm/production/http/constants.mjs.map +1 -1
  65. package/esm/production/http/context.mjs.map +1 -1
  66. package/esm/production/http/cookie.mjs +23 -2
  67. package/esm/production/http/cookie.mjs.map +1 -1
  68. package/esm/production/http/mount.mjs +25 -3
  69. package/esm/production/http/mount.mjs.map +1 -1
  70. package/esm/production/http/share-session.mjs +114 -0
  71. package/esm/production/http/share-session.mjs.map +1 -0
  72. package/esm/production/http/share.mjs +339 -0
  73. package/esm/production/http/share.mjs.map +1 -0
  74. package/esm/production/index.d.mts +2 -2
  75. package/esm/production/insights/writer.mjs +2 -1
  76. package/esm/production/insights/writer.mjs.map +1 -1
  77. package/esm/production/options.d.mts +5 -0
  78. package/esm/production/options.d.mts.map +1 -1
  79. package/esm/production/options.mjs +14 -2
  80. package/esm/production/options.mjs.map +1 -1
  81. package/esm/production/store/cascade-store.mjs +49 -2
  82. package/esm/production/store/cascade-store.mjs.map +1 -1
  83. package/esm/production/store/mapping.mjs +29 -1
  84. package/esm/production/store/mapping.mjs.map +1 -1
  85. package/esm/production/store/memory-store.mjs +62 -0
  86. package/esm/production/store/memory-store.mjs.map +1 -1
  87. package/esm/production/store/migrations.d.mts +2 -1
  88. package/esm/production/store/migrations.d.mts.map +1 -1
  89. package/esm/production/store/migrations.mjs +5 -2
  90. package/esm/production/store/migrations.mjs.map +1 -1
  91. package/esm/production/store/models/index.mjs +3 -1
  92. package/esm/production/store/models/share.migration.mjs +27 -0
  93. package/esm/production/store/models/share.migration.mjs.map +1 -0
  94. package/esm/production/store/models/share.model.mjs +13 -0
  95. package/esm/production/store/models/share.model.mjs.map +1 -0
  96. package/esm/server/panel-files.mjs +35 -0
  97. package/esm/server/panel-files.mjs.map +1 -0
  98. package/esm/server/panel-routes.mjs +27 -7
  99. package/esm/server/panel-routes.mjs.map +1 -1
  100. package/esm/server/session-routes.mjs +2 -1
  101. package/esm/server/session-routes.mjs.map +1 -1
  102. package/esm/types.d.mts +87 -4
  103. package/esm/types.d.mts.map +1 -1
  104. package/llms-full.txt +41 -4
  105. package/package.json +8 -8
  106. package/skills/SKILL.md +41 -4
  107. package/ui/dashboard/assets/app.css +1 -1
  108. package/ui/dashboard/assets/app.js +16 -16
  109. package/ui/dashboard/build-info.json +10 -10
  110. package/ui/dashboard/index.html +1 -0
  111. package/ui/panels/processes.js +12 -3
  112. package/cjs/auth-DzU0gHDG.cjs.map +0 -1
  113. package/cjs/boot-BQi0Etor.cjs.map +0 -1
  114. package/cjs/cascade-store-pHjKeSFm.cjs.map +0 -1
  115. package/cjs/http-CabcUwBx.cjs.map +0 -1
  116. package/cjs/migrations-w7GMsrQw.cjs.map +0 -1
  117. package/cjs/options-CWqFC5__.cjs.map +0 -1
  118. package/cjs/panels-B0dAfGbJ.cjs.map +0 -1
  119. package/cjs/server-B6xdeKS8.cjs.map +0 -1
  120. package/cjs/src-Ce-3Lniv.cjs.map +0 -1
  121. package/cjs/stream-route-BGJa-zQu.cjs.map +0 -1
@@ -213,6 +213,37 @@ const DevtoolsSessionsMigration = (0, _warlock_js_cascade.migrate)(DevtoolsSessi
213
213
  }
214
214
  });
215
215
 
216
+ //#endregion
217
+ //#region ../../packages/devtools/src/production/store/models/share.model.ts
218
+ /** A row of `devtools_shares`. */
219
+ var DevtoolsShareRow = class extends DevtoolsRowModel {
220
+ static {
221
+ this.table = "devtools_shares";
222
+ }
223
+ };
224
+
225
+ //#endregion
226
+ //#region ../../packages/devtools/src/production/store/models/share.migration.ts
227
+ const DevtoolsSharesMigration = (0, _warlock_js_cascade.migrate)(DevtoolsShareRow, {
228
+ name: "devtoolsShares",
229
+ up() {
230
+ this.createTableIfNotExists();
231
+ this.string("id", 64).primary().unique();
232
+ this.string("token_hash", 64).unique();
233
+ this.string("panel", 64);
234
+ this.string("label", 80);
235
+ this.string("created_by", 64).nullable();
236
+ this.bigInteger("created_at");
237
+ this.bigInteger("expires_at").index();
238
+ this.bigInteger("revoked_at").nullable();
239
+ this.bigInteger("last_used_at").nullable();
240
+ this.integer("uses").default(0);
241
+ },
242
+ down() {
243
+ this.dropTableIfExists();
244
+ }
245
+ });
246
+
216
247
  //#endregion
217
248
  //#region ../../packages/devtools/src/production/store/models/state.model.ts
218
249
  /** A row of `devtools_state`. */
@@ -259,6 +290,8 @@ var models_exports = /* @__PURE__ */ require_rolldown_runtime.__exportAll({
259
290
  DevtoolsSamplesMigration: () => DevtoolsSamplesMigration,
260
291
  DevtoolsSessionRow: () => DevtoolsSessionRow,
261
292
  DevtoolsSessionsMigration: () => DevtoolsSessionsMigration,
293
+ DevtoolsShareRow: () => DevtoolsShareRow,
294
+ DevtoolsSharesMigration: () => DevtoolsSharesMigration,
262
295
  DevtoolsStateMigration: () => DevtoolsStateMigration,
263
296
  DevtoolsStateRow: () => DevtoolsStateRow
264
297
  });
@@ -268,7 +301,8 @@ var models_exports = /* @__PURE__ */ require_rolldown_runtime.__exportAll({
268
301
  /**
269
302
  * The migrations of the production monitor's tables/collections:
270
303
  * `devtools_accounts`, `devtools_sessions`, `devtools_invites`,
271
- * `devtools_audit`, `devtools_state`, `devtools_samples`, `devtools_reports`.
304
+ * `devtools_audit`, `devtools_state`, `devtools_samples`, `devtools_reports`,
305
+ * `devtools_shares`.
272
306
  * An app lists them in `warlock.config.ts > database.migrations`.
273
307
  */
274
308
  const devtoolsMigrations = [
@@ -278,7 +312,8 @@ const devtoolsMigrations = [
278
312
  DevtoolsAuditMigration,
279
313
  DevtoolsStateMigration,
280
314
  DevtoolsSamplesMigration,
281
- DevtoolsReportsMigration
315
+ DevtoolsReportsMigration,
316
+ DevtoolsSharesMigration
282
317
  ];
283
318
 
284
319
  //#endregion
@@ -294,4 +329,4 @@ Object.defineProperty(exports, "models_exports", {
294
329
  return models_exports;
295
330
  }
296
331
  });
297
- //# sourceMappingURL=migrations-w7GMsrQw.cjs.map
332
+ //# sourceMappingURL=migrations-DTTzCNpR.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"migrations-DTTzCNpR.cjs","names":["Model","migrate","migrate","migrate","migrate","migrate","migrate","migrate","migrate"],"sources":["../../../../../../../packages/devtools/src/production/store/models/base.ts","../../../../../../../packages/devtools/src/production/store/models/account.model.ts","../../../../../../../packages/devtools/src/production/store/models/account.migration.ts","../../../../../../../packages/devtools/src/production/store/models/audit.model.ts","../../../../../../../packages/devtools/src/production/store/models/audit.migration.ts","../../../../../../../packages/devtools/src/production/store/models/invite.model.ts","../../../../../../../packages/devtools/src/production/store/models/invite.migration.ts","../../../../../../../packages/devtools/src/production/store/models/report.model.ts","../../../../../../../packages/devtools/src/production/store/models/report.migration.ts","../../../../../../../packages/devtools/src/production/store/models/sample.model.ts","../../../../../../../packages/devtools/src/production/store/models/sample.migration.ts","../../../../../../../packages/devtools/src/production/store/models/session.model.ts","../../../../../../../packages/devtools/src/production/store/models/session.migration.ts","../../../../../../../packages/devtools/src/production/store/models/share.model.ts","../../../../../../../packages/devtools/src/production/store/models/share.migration.ts","../../../../../../../packages/devtools/src/production/store/models/state.model.ts","../../../../../../../packages/devtools/src/production/store/models/state.migration.ts","../../../../../../../packages/devtools/src/production/store/models/index.ts","../../../../../../../packages/devtools/src/production/store/migrations.ts"],"sourcesContent":["import { Model } from \"@warlock.js/cascade\";\n\n/**\n * Settings shared by the monitor's tables. Ids are supplied by the store\n * (random uuids, or `\"state\"`), times are plain epoch-millisecond columns the\n * store writes itself, and a removal is always permanent: sessions, invites\n * and samples must not be copied into a trash table.\n */\nexport abstract class DevtoolsRowModel extends Model {\n public static autoGenerateId = false;\n\n public static createdAtColumn = false as const;\n\n public static updatedAtColumn = false as const;\n\n public static deleteStrategy = \"permanent\" as const;\n}\n","import { DevtoolsRowModel } from \"./base\";\n\n/** A row of `devtools_accounts`. */\nexport class DevtoolsAccountRow extends DevtoolsRowModel {\n public static table = \"devtools_accounts\";\n}\n","import { migrate } from \"@warlock.js/cascade\";\nimport { DevtoolsAccountRow } from \"./account.model\";\n\nexport const DevtoolsAccountsMigration = migrate(DevtoolsAccountRow, {\n name: \"devtoolsAccounts\",\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(\"email\", 320).unique();\n this.string(\"role\", 16);\n this.text(\"password_hash\");\n this.string(\"password_source\", 32);\n this.boolean(\"must_change_password\").default(false);\n this.text(\"totp_secret\").nullable();\n this.bigInteger(\"totp_enabled_at\").nullable();\n this.bigInteger(\"totp_last_step\").nullable();\n this.json(\"recovery_codes\");\n this.json(\"passkeys\");\n this.bigInteger(\"failures_reset_at\").nullable();\n this.bigInteger(\"created_at\");\n this.bigInteger(\"updated_at\");\n this.bigInteger(\"last_login_at\").nullable();\n this.string(\"created_by\", 64).nullable();\n this.integer(\"version\").default(1);\n },\n down() {\n this.dropTableIfExists();\n },\n});\n","import { DevtoolsRowModel } from \"./base\";\n\n/** A row of `devtools_audit`. */\nexport class DevtoolsAuditRow extends DevtoolsRowModel {\n public static table = \"devtools_audit\";\n}\n","import { migrate } from \"@warlock.js/cascade\";\nimport { DevtoolsAuditRow } from \"./audit.model\";\n\nexport const DevtoolsAuditMigration = migrate(DevtoolsAuditRow, {\n name: \"devtoolsAudit\",\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(\"type\", 64);\n this.bigInteger(\"occurred_at\").index();\n this.string(\"account_id\", 64).nullable();\n this.string(\"email\", 320).nullable();\n this.string(\"ip\", 64).nullable();\n // The per-IP sign-in limit counts by this: the address, or its /64 for IPv6.\n this.string(\"ip_bucket\", 64).nullable();\n this.string(\"user_agent\", 255).nullable();\n this.json(\"detail\");\n this.string(\"ref\", 16);\n\n this.index([\"type\", \"occurred_at\"]);\n this.index([\"ip_bucket\", \"occurred_at\"]);\n this.index([\"account_id\", \"occurred_at\"]);\n },\n down() {\n this.dropTableIfExists();\n },\n});\n","import { DevtoolsRowModel } from \"./base\";\n\n/** A row of `devtools_invites`. */\nexport class DevtoolsInviteRow extends DevtoolsRowModel {\n public static table = \"devtools_invites\";\n}\n","import { migrate } from \"@warlock.js/cascade\";\nimport { DevtoolsInviteRow } from \"./invite.model\";\n\nexport const DevtoolsInvitesMigration = migrate(DevtoolsInviteRow, {\n name: \"devtoolsInvites\",\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(\"email\", 320);\n this.string(\"role\", 16);\n this.string(\"created_by\", 64).nullable();\n this.bigInteger(\"created_at\");\n this.bigInteger(\"expires_at\").index();\n this.bigInteger(\"used_at\").nullable();\n this.string(\"account_id\", 64).nullable();\n },\n down() {\n this.dropTableIfExists();\n },\n});\n","import { DevtoolsRowModel } from \"./base\";\n\n/** A row of `devtools_reports`. */\nexport class DevtoolsReportRow extends DevtoolsRowModel {\n public static table = \"devtools_reports\";\n}\n","import { migrate } from \"@warlock.js/cascade\";\nimport { DevtoolsReportRow } from \"./report.model\";\n\nexport const DevtoolsReportsMigration = migrate(DevtoolsReportRow, {\n name: \"devtoolsReports\",\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.bigInteger(\"seen_at\").index();\n // JSON text, up to 256 KB.\n this.longText(\"data\");\n },\n down() {\n this.dropTableIfExists();\n },\n});\n","import { DevtoolsRowModel } from \"./base\";\n\n/** A row of `devtools_samples`. */\nexport class DevtoolsSampleRow extends DevtoolsRowModel {\n public static table = \"devtools_samples\";\n}\n","import { migrate } from \"@warlock.js/cascade\";\nimport { DevtoolsSampleRow } from \"./sample.model\";\n\nexport const DevtoolsSamplesMigration = migrate(DevtoolsSampleRow, {\n name: \"devtoolsSamples\",\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(\"instance\", 128).index();\n this.bigInteger(\"started_at\").index();\n this.integer(\"status\").nullable().index();\n this.string(\"method\", 16);\n this.text(\"path\");\n this.json(\"summary\");\n // JSON text: request data may hold keys MongoDB cannot store as field names.\n this.longText(\"detail\").nullable();\n },\n down() {\n this.dropTableIfExists();\n },\n});\n","import { DevtoolsRowModel } from \"./base\";\n\n/** A row of `devtools_sessions`. */\nexport class DevtoolsSessionRow extends DevtoolsRowModel {\n public static table = \"devtools_sessions\";\n}\n","import { migrate } from \"@warlock.js/cascade\";\nimport { DevtoolsSessionRow } from \"./session.model\";\n\nexport const DevtoolsSessionsMigration = migrate(DevtoolsSessionRow, {\n name: \"devtoolsSessions\",\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(\"account_id\", 64).index();\n this.string(\"stage\", 32);\n this.string(\"csrf_secret\", 128);\n this.bigInteger(\"created_at\");\n this.bigInteger(\"last_seen_at\");\n this.bigInteger(\"expires_at\").index();\n this.string(\"ip\", 64).nullable();\n this.string(\"user_agent\", 255).nullable();\n this.text(\"pending_totp_secret\").nullable();\n this.text(\"challenge\").nullable();\n this.bigInteger(\"challenge_expires_at\").nullable();\n this.integer(\"version\").default(1);\n },\n down() {\n this.dropTableIfExists();\n },\n});\n","import { DevtoolsRowModel } from \"./base\";\n\n/** A row of `devtools_shares`. */\nexport class DevtoolsShareRow extends DevtoolsRowModel {\n public static table = \"devtools_shares\";\n}\n","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","import { DevtoolsRowModel } from \"./base\";\n\n/** A row of `devtools_state`. */\nexport class DevtoolsStateRow extends DevtoolsRowModel {\n public static table = \"devtools_state\";\n}\n","import { migrate } from \"@warlock.js/cascade\";\nimport { DevtoolsStateRow } from \"./state.model\";\n\nexport const DevtoolsStateMigration = migrate(DevtoolsStateRow, {\n name: \"devtoolsState\",\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.boolean(\"disabled\").default(false);\n this.string(\"disabled_path_hash\", 64).nullable();\n this.bigInteger(\"disabled_at\").nullable();\n this.string(\"disabled_by\", 64).nullable();\n this.bigInteger(\"locked_until\").nullable();\n this.bigInteger(\"failures_reset_at\").nullable();\n this.bigInteger(\"updated_at\");\n this.integer(\"version\").default(0);\n },\n down() {\n this.dropTableIfExists();\n },\n});\n","export { DevtoolsRowModel } from \"./base\";\nexport { DevtoolsAccountsMigration } from \"./account.migration\";\nexport { DevtoolsAccountRow } from \"./account.model\";\nexport { DevtoolsAuditMigration } from \"./audit.migration\";\nexport { DevtoolsAuditRow } from \"./audit.model\";\nexport { DevtoolsInvitesMigration } from \"./invite.migration\";\nexport { DevtoolsInviteRow } from \"./invite.model\";\nexport { DevtoolsReportsMigration } from \"./report.migration\";\nexport { DevtoolsReportRow } from \"./report.model\";\nexport { DevtoolsSamplesMigration } from \"./sample.migration\";\nexport { DevtoolsSampleRow } from \"./sample.model\";\nexport { DevtoolsSessionsMigration } from \"./session.migration\";\nexport { DevtoolsSessionRow } from \"./session.model\";\nexport { DevtoolsSharesMigration } from \"./share.migration\";\nexport { DevtoolsShareRow } from \"./share.model\";\nexport { DevtoolsStateMigration } from \"./state.migration\";\nexport { DevtoolsStateRow } from \"./state.model\";\n","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":";;;;;;;;;;AAQA,IAAsB,mBAAtB,cAA+CA,0BAAM;;wBACpB;;;yBAEC;;;yBAEA;;;wBAED;;AACjC;;;;;ACbA,IAAa,qBAAb,cAAwC,iBAAiB;;eACjC;;AACxB;;;;ACFA,MAAa,gCAA4BC,6BAAQ,oBAAoB;CACnE,MAAM;CACN,KAAK;EACH,KAAK,uBAAuB;EAI5B,KAAK,OAAO,MAAM,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,OAAO;EAEvC,KAAK,OAAO,SAAS,GAAG,CAAC,CAAC,OAAO;EACjC,KAAK,OAAO,QAAQ,EAAE;EACtB,KAAK,KAAK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+1,4 @@
1
- const require_errors = require("./errors-CyZp5yS-.cjs");
1
+ const require_errors = require("./errors-DEqdWaqm.cjs");
2
2
  const require_ip = require("./ip-DbNhPOzi.cjs");
3
3
 
4
4
  //#region ../../packages/devtools/src/production/options.ts
@@ -32,7 +32,11 @@ const DEVTOOLS_PRODUCTION_DEFAULTS = {
32
32
  explain: { executing: false },
33
33
  logLevels: ["warn", "error"],
34
34
  auditRetentionDays: 90,
35
- passkeys: { rpName: "Warlock monitor" }
35
+ passkeys: { rpName: "Warlock monitor" },
36
+ share: {
37
+ enabled: false,
38
+ maxDays: 30
39
+ }
36
40
  };
37
41
  /** The environment variables production mode reads. */
38
42
  const DEVTOOLS_ENV = {
@@ -83,7 +87,7 @@ function resolvePath(value) {
83
87
  * `env`, and validates everything.
84
88
  *
85
89
  * Throws `DevtoolsProductionConfigError`: DT001 (no path), DT002 (bad path),
86
- * DT007 (an option out of range: sampleRate outside 0–1, a non-positive
90
+ * DT007 (an option out of range: sampleRate outside 0–1, share.maxDays outside 1–365, a non-positive
87
91
  * limit, an unknown twoFactor value, a bad CIDR, an origin that is not
88
92
  * `https://host[:port]`), DT009 (both a password and a setup token), DT010
89
93
  * (setup token shorter than 32 characters). DT003/DT004 (admin) are checked
@@ -114,6 +118,10 @@ function resolveProductionOptions(options, env) {
114
118
  const rpId = given.passkeys?.rpId ?? null;
115
119
  if (typeof rpName !== "string" || rpName.trim() === "") invalid("passkeys.rpName", "use a non-empty name");
116
120
  if (rpId !== null && (typeof rpId !== "string" || rpId.trim() === "")) invalid("passkeys.rpId", "use a host name such as app.example.com");
121
+ const shareEnabled = given.share?.enabled ?? defaults.share.enabled;
122
+ const shareMaxDays = given.share?.maxDays ?? defaults.share.maxDays;
123
+ if (typeof shareEnabled !== "boolean") invalid("share.enabled", "use true or false");
124
+ if (!Number.isInteger(shareMaxDays) || shareMaxDays < 1 || shareMaxDays > 365) invalid("share.maxDays", "use a whole number of days from 1 to 365");
117
125
  const limits = given.rateLimits ?? {};
118
126
  const session = given.session ?? {};
119
127
  const resolved = {
@@ -158,6 +166,10 @@ function resolveProductionOptions(options, env) {
158
166
  passkeys: {
159
167
  rpName,
160
168
  rpId
169
+ },
170
+ share: {
171
+ enabled: shareEnabled,
172
+ maxDays: shareMaxDays
161
173
  }
162
174
  };
163
175
  if (resolved.admin.password !== null && resolved.admin.setupToken !== null) throw new require_errors.DevtoolsProductionConfigError("DT009");
@@ -178,4 +190,4 @@ Object.defineProperty(exports, "resolveProductionOptions", {
178
190
  return resolveProductionOptions;
179
191
  }
180
192
  });
181
- //# sourceMappingURL=options-CWqFC5__.cjs.map
193
+ //# sourceMappingURL=options-CHhmQJic.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"options-CHhmQJic.cjs","names":["DevtoolsProductionConfigError","isValidNetworkEntry"],"sources":["../../../../../../../packages/devtools/src/production/options.ts"],"sourcesContent":["import type { DevtoolsLogEntry, DevtoolsProductionOptions } from \"../types\";\nimport { DevtoolsProductionConfigError } from \"./errors\";\nimport { isValidNetworkEntry } from \"./http/ip\";\n\n/**\n * `DevtoolsProductionOptions` with every default applied and the environment\n * read. Built once at boot by `resolveProductionOptions`.\n */\nexport type ResolvedDevtoolsProductionOptions = {\n /** The dashboard path, without a trailing slash. */\n path: string;\n /** The first admin from the environment; every field `null` when unset. */\n admin: { email: string | null; password: string | null; setupToken: string | null };\n sampleRate: number;\n slowRequestMs: number;\n slowQueryMs: number;\n maxRequests: number;\n /** Queries kept per sampled request; the rest are counted in `droppedQueries`. */\n maxQueriesPerRequest: number;\n /** Query shapes kept in memory per process (least recently seen evicted). */\n maxShapes: number;\n /** Route keys kept in memory per process. */\n maxRoutes: number;\n /** Error groups kept in memory per process. */\n maxErrorGroups: number;\n requestRetentionHours: number;\n maxStoredSamplesPerMinute: number;\n reportIntervalMs: number;\n trustedProxies: readonly string[];\n requireHttps: boolean;\n allowedIps: readonly string[];\n origin: string | null;\n session: { idleMinutes: number; maxHours: number; pendingMinutes: number };\n twoFactor: \"admins\" | \"everyone\";\n rateLimits: {\n windowMinutes: number;\n account: number;\n ip: number;\n global: number;\n lockMinutes: number;\n };\n explain: { executing: boolean };\n panels: Readonly<Record<string, boolean>>;\n logLevels: readonly DevtoolsLogEntry[\"level\"][];\n auditRetentionDays: number;\n passkeys: { rpName: string; rpId: string | null };\n /** Read-only share links. */\n share: { enabled: boolean; maxDays: number };\n};\n\n/** The defaults `resolveProductionOptions` applies (environment values excluded). */\nexport const DEVTOOLS_PRODUCTION_DEFAULTS = {\n sampleRate: 0.1,\n slowRequestMs: 1000,\n slowQueryMs: 200,\n maxRequests: 200,\n maxQueriesPerRequest: 200,\n maxShapes: 500,\n maxRoutes: 300,\n maxErrorGroups: 100,\n requestRetentionHours: 24,\n maxStoredSamplesPerMinute: 120,\n reportIntervalMs: 10_000,\n requireHttps: true,\n session: { idleMinutes: 30, maxHours: 8, pendingMinutes: 10 },\n twoFactor: \"admins\",\n rateLimits: { windowMinutes: 15, account: 5, ip: 20, global: 100, lockMinutes: 15 },\n explain: { executing: false },\n logLevels: [\"warn\", \"error\"],\n auditRetentionDays: 90,\n passkeys: { rpName: \"Warlock monitor\" },\n share: { enabled: false, maxDays: 30 },\n} as const;\n\n/** The environment variables production mode reads. */\nexport const DEVTOOLS_ENV = {\n path: \"DEVTOOLS_PATH\",\n adminEmail: \"DEVTOOLS_ADMIN_EMAIL\",\n adminPassword: \"DEVTOOLS_ADMIN_PASSWORD\",\n setupToken: \"DEVTOOLS_SETUP_TOKEN\",\n} as const;\n\nconst LOG_LEVELS: readonly DevtoolsLogEntry[\"level\"][] = [\n \"debug\",\n \"info\",\n \"warn\",\n \"error\",\n \"success\",\n];\n\nconst PATH_CHARACTERS = /^[A-Za-z0-9._~/-]+$/;\nconst MIN_PATH_LENGTH = 8;\nconst MIN_SETUP_TOKEN_LENGTH = 32;\n\nfunction invalid(option: string, expected: string): never {\n throw new DevtoolsProductionConfigError(\n \"DT007\",\n `Option \"devtools.production.${option}\" is not valid: ${expected}.`,\n );\n}\n\nfunction present(value: string | undefined): string | null {\n return value === undefined || value === \"\" ? null : value;\n}\n\nfunction integerAtLeastOne(option: string, value: number | undefined, fallback: number): number {\n if (value === undefined) return fallback;\n\n if (!Number.isInteger(value) || value < 1) invalid(option, \"use a whole number of 1 or more\");\n\n return value;\n}\n\nfunction networkList(option: string, value: readonly string[] | undefined): readonly string[] {\n if (value === undefined) return [];\n\n if (!Array.isArray(value)) {\n invalid(option, 'use a list of IPs, CIDR ranges, \"loopback\" or \"private\"');\n }\n\n for (const entry of value as readonly unknown[]) {\n if (!isValidNetworkEntry(entry)) {\n invalid(option, `\"${String(entry)}\" is not an IP, a CIDR range, \"loopback\" or \"private\"`);\n }\n }\n\n return [...value];\n}\n\n/** The dashboard path without a trailing slash, or a DT001/DT002 error. */\nfunction resolvePath(value: string | undefined): string {\n const given = present(value);\n\n if (given === null) throw new DevtoolsProductionConfigError(\"DT001\");\n\n const path = given.replace(/\\/+$/, \"\");\n const segments = path.split(\"/\").slice(1);\n const lower = path.toLowerCase();\n\n if (\n !path.startsWith(\"/\") ||\n path.length < MIN_PATH_LENGTH ||\n !PATH_CHARACTERS.test(path) ||\n segments.some((segment) => segment === \"\" || segment === \".\" || segment === \"..\") ||\n lower === \"/__warlock\" ||\n lower.startsWith(\"/__warlock/\")\n ) {\n throw new DevtoolsProductionConfigError(\"DT002\");\n }\n\n return path;\n}\n\n/**\n * Applies the defaults to `options`, reads the path and first admin from\n * `env`, and validates everything.\n *\n * Throws `DevtoolsProductionConfigError`: DT001 (no path), DT002 (bad path),\n * DT007 (an option out of range: sampleRate outside 0–1, share.maxDays outside 1–365, a non-positive\n * limit, an unknown twoFactor value, a bad CIDR, an origin that is not\n * `https://host[:port]`), DT009 (both a password and a setup token), DT010\n * (setup token shorter than 32 characters). DT003/DT004 (admin) are checked\n * later by `ensureFirstAdmin`, which needs the database.\n */\nexport function resolveProductionOptions(\n options: DevtoolsProductionOptions | undefined,\n env: Readonly<Record<string, string | undefined>>,\n): ResolvedDevtoolsProductionOptions {\n const given = options ?? {};\n const defaults = DEVTOOLS_PRODUCTION_DEFAULTS;\n const path = resolvePath(given.path ?? env[DEVTOOLS_ENV.path]);\n\n const sampleRate = given.sampleRate ?? defaults.sampleRate;\n\n if (\n typeof sampleRate !== \"number\" ||\n !Number.isFinite(sampleRate) ||\n sampleRate < 0 ||\n sampleRate > 1\n ) {\n invalid(\"sampleRate\", \"use a number from 0 to 1\");\n }\n\n const requireHttps: boolean = given.requireHttps ?? defaults.requireHttps;\n\n if (typeof requireHttps !== \"boolean\") invalid(\"requireHttps\", \"use true or false\");\n\n const twoFactor = given.twoFactor ?? defaults.twoFactor;\n\n if (twoFactor !== \"admins\" && twoFactor !== \"everyone\") {\n invalid(\"twoFactor\", 'use \"admins\" or \"everyone\"');\n }\n\n const origin = given.origin ?? null;\n\n if (origin !== null) {\n const pattern = requireHttps ? /^https:\\/\\/[^/\\s]+$/ : /^https?:\\/\\/[^/\\s]+$/;\n\n if (typeof origin !== \"string\" || !pattern.test(origin)) {\n invalid(\n \"origin\",\n requireHttps\n ? \"use an origin such as https://app.example.com, without a path or a trailing slash\"\n : \"use an origin such as http://localhost:3000, without a path or a trailing slash\",\n );\n }\n }\n\n const panels: Readonly<Record<string, unknown>> = given.panels ?? {};\n\n if (panels === null || typeof panels !== \"object\" || Array.isArray(panels)) {\n invalid(\"panels\", \"use an object of tab ids and true or false\");\n }\n\n for (const [id, enabled] of Object.entries(panels)) {\n if (typeof enabled !== \"boolean\") invalid(`panels.${id}`, \"use true or false\");\n }\n\n const logLevels = given.logLevels ?? defaults.logLevels;\n\n if (!Array.isArray(logLevels) || logLevels.some((level) => !LOG_LEVELS.includes(level))) {\n invalid(\"logLevels\", `use a list of ${LOG_LEVELS.join(\", \")}`);\n }\n\n const executing: boolean = given.explain?.executing ?? defaults.explain.executing;\n\n if (typeof executing !== \"boolean\") invalid(\"explain.executing\", \"use true or false\");\n\n const rpName: string = given.passkeys?.rpName ?? defaults.passkeys.rpName;\n const rpId = given.passkeys?.rpId ?? null;\n\n if (typeof rpName !== \"string\" || rpName.trim() === \"\") {\n invalid(\"passkeys.rpName\", \"use a non-empty name\");\n }\n\n if (rpId !== null && (typeof rpId !== \"string\" || rpId.trim() === \"\")) {\n invalid(\"passkeys.rpId\", \"use a host name such as app.example.com\");\n }\n\n const shareEnabled: boolean = given.share?.enabled ?? defaults.share.enabled;\n const shareMaxDays: number = given.share?.maxDays ?? defaults.share.maxDays;\n\n if (typeof shareEnabled !== \"boolean\") invalid(\"share.enabled\", \"use true or false\");\n\n if (!Number.isInteger(shareMaxDays) || shareMaxDays < 1 || shareMaxDays > 365) {\n invalid(\"share.maxDays\", \"use a whole number of days from 1 to 365\");\n }\n\n const limits = given.rateLimits ?? {};\n const session = given.session ?? {};\n\n const resolved: ResolvedDevtoolsProductionOptions = {\n path,\n admin: {\n email: present(env[DEVTOOLS_ENV.adminEmail]),\n password: present(env[DEVTOOLS_ENV.adminPassword]),\n setupToken: present(env[DEVTOOLS_ENV.setupToken]),\n },\n sampleRate,\n slowRequestMs: integerAtLeastOne(\"slowRequestMs\", given.slowRequestMs, defaults.slowRequestMs),\n slowQueryMs: integerAtLeastOne(\"slowQueryMs\", given.slowQueryMs, defaults.slowQueryMs),\n maxRequests: integerAtLeastOne(\"maxRequests\", given.maxRequests, defaults.maxRequests),\n maxQueriesPerRequest: defaults.maxQueriesPerRequest,\n maxShapes: defaults.maxShapes,\n maxRoutes: defaults.maxRoutes,\n maxErrorGroups: defaults.maxErrorGroups,\n requestRetentionHours: integerAtLeastOne(\n \"requestRetentionHours\",\n given.requestRetentionHours,\n defaults.requestRetentionHours,\n ),\n maxStoredSamplesPerMinute: integerAtLeastOne(\n \"maxStoredSamplesPerMinute\",\n given.maxStoredSamplesPerMinute,\n defaults.maxStoredSamplesPerMinute,\n ),\n reportIntervalMs: integerAtLeastOne(\n \"reportIntervalMs\",\n given.reportIntervalMs,\n defaults.reportIntervalMs,\n ),\n trustedProxies: networkList(\"trustedProxies\", given.trustedProxies),\n requireHttps,\n allowedIps: networkList(\"allowedIps\", given.allowedIps),\n origin,\n session: {\n idleMinutes: integerAtLeastOne(\n \"session.idleMinutes\",\n session.idleMinutes,\n defaults.session.idleMinutes,\n ),\n maxHours: integerAtLeastOne(\"session.maxHours\", session.maxHours, defaults.session.maxHours),\n pendingMinutes: defaults.session.pendingMinutes,\n },\n twoFactor,\n rateLimits: {\n windowMinutes: integerAtLeastOne(\n \"rateLimits.windowMinutes\",\n limits.windowMinutes,\n defaults.rateLimits.windowMinutes,\n ),\n account: integerAtLeastOne(\"rateLimits.account\", limits.account, defaults.rateLimits.account),\n ip: integerAtLeastOne(\"rateLimits.ip\", limits.ip, defaults.rateLimits.ip),\n global: integerAtLeastOne(\"rateLimits.global\", limits.global, defaults.rateLimits.global),\n lockMinutes: integerAtLeastOne(\n \"rateLimits.lockMinutes\",\n limits.lockMinutes,\n defaults.rateLimits.lockMinutes,\n ),\n },\n explain: { executing },\n panels: { ...(panels as Readonly<Record<string, boolean>>) },\n logLevels: [...logLevels],\n auditRetentionDays: integerAtLeastOne(\n \"auditRetentionDays\",\n given.auditRetentionDays,\n defaults.auditRetentionDays,\n ),\n passkeys: { rpName, rpId },\n share: { enabled: shareEnabled, maxDays: shareMaxDays },\n };\n\n if (resolved.admin.password !== null && resolved.admin.setupToken !== null) {\n throw new DevtoolsProductionConfigError(\"DT009\");\n }\n\n if (\n resolved.admin.setupToken !== null &&\n resolved.admin.setupToken.length < MIN_SETUP_TOKEN_LENGTH\n ) {\n throw new DevtoolsProductionConfigError(\"DT010\");\n }\n\n return resolved;\n}\n"],"mappings":";;;;;AAmDA,MAAa,+BAA+B;CAC1C,YAAY;CACZ,eAAe;CACf,aAAa;CACb,aAAa;CACb,sBAAsB;CACtB,WAAW;CACX,WAAW;CACX,gBAAgB;CAChB,uBAAuB;CACvB,2BAA2B;CAC3B,kBAAkB;CAClB,cAAc;CACd,SAAS;EAAE,aAAa;EAAI,UAAU;EAAG,gBA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_contracts = require("./contracts-CVmplkNb.cjs");
2
+ const require_contracts = require("./contracts-CDuY-ahl.cjs");
3
3
  let node_fs = require("node:fs");
4
4
  let node_module = require("node:module");
5
5
  let node_path = require("node:path");
@@ -7,6 +7,22 @@ node_path = require_rolldown_runtime.__toESM(node_path, 1);
7
7
  let node_url = require("node:url");
8
8
 
9
9
  //#region ../../packages/devtools/src/panels.ts
10
+ /** The extensions a panel serves from `files` when it lists none. */
11
+ const DEFAULT_PANEL_FILE_EXTENSIONS = [
12
+ ".png",
13
+ ".jpg",
14
+ ".jpeg",
15
+ ".webp",
16
+ ".gif"
17
+ ];
18
+ /** Extensions a panel may never serve from `files`: a browser runs or renders them as a page. */
19
+ const BLOCKED_FILE_EXTENSIONS = /* @__PURE__ */ new Set([
20
+ ".svg",
21
+ ".html",
22
+ ".htm",
23
+ ".js",
24
+ ".mjs"
25
+ ]);
10
26
  /**
11
27
  * Ids the dashboard already uses for its own tabs, API segments and URLs. A
12
28
  * panel's routes live under `<path>/api/<id>`, so these would collide.
@@ -33,6 +49,7 @@ const RESERVED_PANEL_IDS = /* @__PURE__ */ new Set([
33
49
  "requests",
34
50
  "resources",
35
51
  "routes",
52
+ "share",
36
53
  "stream"
37
54
  ]);
38
55
  const PANEL_ID = /^[a-z][a-z0-9-]*$/;
@@ -52,6 +69,10 @@ const CONTENT_TYPES = {
52
69
  ".json": "application/json; charset=utf-8",
53
70
  ".svg": "image/svg+xml",
54
71
  ".png": "image/png",
72
+ ".jpg": "image/jpeg",
73
+ ".jpeg": "image/jpeg",
74
+ ".webp": "image/webp",
75
+ ".gif": "image/gif",
55
76
  ".woff2": "font/woff2"
56
77
  };
57
78
  /** The content type a panel file is served with, from its served name. */
@@ -104,6 +125,8 @@ function checkDevtoolsPanel(value, taken) {
104
125
  if (file === void 0 || !isFile(file)) throw new Error(`The asset "${name}" of devtools panel "${id}" was not found at ${String(source)}; give an absolute path or file: URL.`);
105
126
  assets[name] = file;
106
127
  }
128
+ const files = checkPanelFiles(id, panel.files);
129
+ const share = checkPanelShare(id, panel.share, routes, assets, files !== null);
107
130
  taken.set(id, panel.title);
108
131
  return {
109
132
  id,
@@ -111,14 +134,66 @@ function checkDevtoolsPanel(value, taken) {
111
134
  view,
112
135
  routes,
113
136
  assets,
137
+ files,
138
+ share,
114
139
  production: panel.production === true
115
140
  };
116
141
  }
142
+ const FILE_EXTENSION = /^\.[a-z0-9]{1,16}$/;
143
+ /** Validates `files`; `null` when the panel declares none. */
144
+ function checkPanelFiles(id, value) {
145
+ if (value === void 0 || value === null) return null;
146
+ if (typeof value !== "object") throw new Error(`Devtools panel "${id}" has files that is not an object; use { dir: "/absolute/folder" }.`);
147
+ const dir = toFilePath(value.dir);
148
+ if (dir === void 0) throw new Error(`Devtools panel "${id}" needs files.dir to be an absolute path or a file: URL; got ${String(value.dir)}.`);
149
+ const given = value.extensions;
150
+ if (given !== void 0 && (!Array.isArray(given) || given.length === 0)) throw new Error(`Devtools panel "${id}" has files.extensions that is not a list; use [".png", ".jpg"] or leave it out.`);
151
+ for (const extension of given ?? []) {
152
+ if (typeof extension !== "string" || !FILE_EXTENSION.test(extension)) throw new Error(`Devtools panel "${id}" has files.extensions entry ${JSON.stringify(extension)}; use lower-case extensions that start with a dot, such as ".png".`);
153
+ if (BLOCKED_FILE_EXTENSIONS.has(extension)) throw new Error(`Devtools panel "${id}" lists files.extensions entry "${extension}", which can run as a page or script in the browser; remove it (images such as .png, .jpg, .webp and .gif are fine).`);
154
+ }
155
+ return {
156
+ dir,
157
+ extensions: [...given ?? DEFAULT_PANEL_FILE_EXTENSIONS]
158
+ };
159
+ }
160
+ /** Validates `share` against the panel's own routes, assets and files. */
161
+ function checkPanelShare(id, value, routes, assets, hasFiles) {
162
+ if (value === void 0 || value === null) return null;
163
+ if (typeof value !== "object") throw new Error(`Devtools panel "${id}" has share that is not an object; use { view, routes }.`);
164
+ const view = toFilePath(value.view);
165
+ if (view === void 0) throw new Error(`Devtools panel "${id}" needs share.view: an absolute path or file: URL of the shared view module.`);
166
+ if (!isFile(view)) throw new Error(`The share.view module of devtools panel "${id}" was not found at ${view}.`);
167
+ if (!Array.isArray(value.routes)) throw new Error(`Devtools panel "${id}" needs share.routes: a list of the paths of its GET routes the shared page may call.`);
168
+ const getPaths = routes.filter((route) => route.method === "GET").map((route) => route.path);
169
+ for (const route of value.routes) if (typeof route !== "string" || !getPaths.includes(route)) throw new Error(`Devtools panel "${id}" lists share.routes entry ${JSON.stringify(route)}, which is not the path of one of its GET routes${getPaths.length > 0 ? `; use one of ${getPaths.map((path) => JSON.stringify(path)).join(", ")}` : " (the panel has no GET routes)"}.`);
170
+ for (const name of value.assets ?? []) if (typeof name !== "string" || !Object.hasOwn(assets, name)) throw new Error(`Devtools panel "${id}" lists share.assets entry ${JSON.stringify(name)}, which is not a name in its assets; use one of ${Object.keys(assets).join(", ") || "(the panel has no assets)"}.`);
171
+ const files = value.files === true;
172
+ if (value.files !== void 0 && typeof value.files !== "boolean") throw new Error(`Devtools panel "${id}" needs share.files to be true or false.`);
173
+ if (files && !hasFiles) throw new Error(`Devtools panel "${id}" sets share.files, but the panel has no files folder; add files: { dir } or remove share.files.`);
174
+ return {
175
+ view,
176
+ routes: [...value.routes],
177
+ assets: [...value.assets ?? []],
178
+ files
179
+ };
180
+ }
117
181
  /** Validates a list of panels; the first invalid or duplicate one throws. */
118
182
  function checkDevtoolsPanels(panels) {
119
183
  const taken = /* @__PURE__ */ new Map();
120
184
  return panels.map((panel) => checkDevtoolsPanel(panel, taken));
121
185
  }
186
+ function isPlainObject(value) {
187
+ if (value === null || typeof value !== "object" || Array.isArray(value)) return false;
188
+ const prototype = Object.getPrototypeOf(value);
189
+ return prototype === Object.prototype || prototype === null;
190
+ }
191
+ /** What is wrong with a `[specifier, options]` entry, or `undefined` when it is valid. */
192
+ function tupleProblem(entry) {
193
+ if (entry.length !== 2) return `it has ${entry.length} item(s); use exactly [specifier, options]`;
194
+ if (typeof entry[0] !== "string" || entry[0] === "") return `its first item is ${JSON.stringify(entry[0])}; use the module specifier as a string`;
195
+ if (!isPlainObject(entry[1])) return `its second item is not a plain object; pass the options as { name: value }`;
196
+ }
122
197
  /** The URL or specifier to import for a `panels` entry. */
123
198
  function resolvePanelSpecifier(entry, root) {
124
199
  if (entry.startsWith("./") || entry.startsWith("../") || node_path.default.isAbsolute(entry)) return (0, node_url.pathToFileURL)(node_path.default.resolve(root, entry)).href;
@@ -187,10 +262,12 @@ function resolveWithRequire(entry, root) {
187
262
  }
188
263
  }
189
264
  /** The panels a module's default export describes. */
190
- async function panelsOf(exported, root, mode) {
265
+ async function panelsOf(exported, root, mode, panelOptions = {}, errors) {
191
266
  const value = typeof exported === "function" ? await exported({
267
+ ...panelOptions,
192
268
  root,
193
- mode
269
+ mode,
270
+ ...errors ? { errors } : {}
194
271
  }) : exported;
195
272
  return Array.isArray(value) ? value : [value];
196
273
  }
@@ -212,13 +289,21 @@ async function loadDevtoolsPanels(entries, options) {
212
289
  for (const entry of entries) {
213
290
  let candidates;
214
291
  try {
215
- if (typeof entry === "string") {
216
- const module = await importModule(resolvePanelSpecifier(entry, options.root));
292
+ if (Array.isArray(entry)) {
293
+ const problem = tupleProblem(entry);
294
+ if (problem !== void 0) {
295
+ options.warn(`Devtools panels entry ${JSON.stringify(entry)} is invalid: ${problem}. Example: ["@warlock.js/grimoire/devtools", { ttlMs: 60000 }]. The entry was not added.`);
296
+ continue;
297
+ }
298
+ }
299
+ if (typeof entry === "string" || Array.isArray(entry)) {
300
+ const [specifier, panelOptions] = typeof entry === "string" ? [entry, void 0] : entry;
301
+ const module = await importModule(resolvePanelSpecifier(specifier, options.root));
217
302
  if (module.default === void 0) throw new Error("the module has no default export");
218
- candidates = await panelsOf(module.default, options.root, mode);
303
+ candidates = await panelsOf(module.default, options.root, mode, panelOptions, options.errors);
219
304
  } else candidates = [entry];
220
305
  } catch (error) {
221
- options.warn(`Devtools panel module "${String(entry)}" could not be loaded: ${describe(error)}. Check that it is installed and listed correctly in the devtools "panels" option.`);
306
+ options.warn(`Devtools panel module "${String(Array.isArray(entry) ? entry[0] : entry)}" could not be loaded: ${describe(error)}. Check that it is installed and listed correctly in the devtools "panels" option.`);
222
307
  continue;
223
308
  }
224
309
  for (const candidate of candidates) try {
@@ -254,12 +339,14 @@ function listPanelInfos(panels, builtIn) {
254
339
  const tabs = require_contracts.DEVTOOLS_BUILT_IN_PANELS.filter((tab) => builtIn === void 0 || builtIn.includes(tab.id)).map((tab) => ({
255
340
  id: tab.id,
256
341
  title: tab.title,
257
- type: "built-in"
342
+ type: "built-in",
343
+ shareable: false
258
344
  }));
259
345
  for (const panel of panels) tabs.push({
260
346
  id: panel.id,
261
347
  title: panel.title,
262
- type: "package"
348
+ type: "package",
349
+ shareable: panel.share !== void 0 && panel.share !== null
263
350
  });
264
351
  return tabs;
265
352
  }
@@ -295,4 +382,4 @@ Object.defineProperty(exports, "productionPanels", {
295
382
  return productionPanels;
296
383
  }
297
384
  });
298
- //# sourceMappingURL=panels-B0dAfGbJ.cjs.map
385
+ //# sourceMappingURL=panels-CHd20RK5.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"panels-CHd20RK5.cjs","names":["path","fileURLToPath","existsSync","statSync","pathToFileURL","readFileSync","createRequire","DEVTOOLS_BUILT_IN_PANELS"],"sources":["../../../../../../../packages/devtools/src/panels.ts"],"sourcesContent":["import { existsSync, readFileSync, statSync } from \"node:fs\";\nimport { createRequire } from \"node:module\";\nimport path from \"node:path\";\nimport { fileURLToPath, pathToFileURL } from \"node:url\";\nimport { DEVTOOLS_BUILT_IN_PANELS } from \"./production/contracts\";\nimport type { DevtoolsMode, DevtoolsPanelInfo } from \"./production/contracts\";\nimport type {\n DevtoolsPanel,\n DevtoolsPanelEntry,\n DevtoolsPanelErrorSummary,\n DevtoolsPanelExport,\n DevtoolsPanelMethod,\n DevtoolsPanelRoute,\n} from \"./types\";\n\n/**\n * A validated panel: file paths are absolute strings and every list is\n * present, so the server never re-checks them per request.\n */\nexport type MountedDevtoolsPanel = {\n id: string;\n title: string;\n view: string;\n routes: readonly (DevtoolsPanelRoute & { method: DevtoolsPanelMethod })[];\n assets: Readonly<Record<string, string>>;\n /** The folder of images the panel serves; `null` when it declared none. */\n files: MountedPanelFiles | null;\n /** What a read-only share link of the panel opens; `null` when the panel cannot be shared. */\n share: MountedPanelShare | null;\n /** Whether the panel declared itself safe for the production monitor. */\n production: boolean;\n};\n\n/** A panel's folder of images, validated: an absolute directory and lower-case extensions. */\nexport type MountedPanelFiles = {\n dir: string;\n extensions: readonly string[];\n};\n\n/** A panel's shared view, validated. */\nexport type MountedPanelShare = {\n /** Absolute path of the shared view module. */\n view: string;\n /** Paths of the GET routes the shared page may call. */\n routes: readonly string[];\n /** Served names from `assets` the shared page may load. */\n assets: readonly string[];\n /** Whether the shared page may load images from `files`. */\n files: boolean;\n};\n\n/** The extensions a panel serves from `files` when it lists none. */\nexport const DEFAULT_PANEL_FILE_EXTENSIONS: readonly string[] = [\n \".png\",\n \".jpg\",\n \".jpeg\",\n \".webp\",\n \".gif\",\n];\n\n/** Extensions a panel may never serve from `files`: a browser runs or renders them as a page. */\nconst BLOCKED_FILE_EXTENSIONS = new Set([\".svg\", \".html\", \".htm\", \".js\", \".mjs\"]);\n\n/**\n * Ids the dashboard already uses for its own tabs, API segments and URLs. A\n * panel's routes live under `<path>/api/<id>`, so these would collide.\n */\nconst RESERVED_PANEL_IDS = new Set([\n \"account\",\n \"admin\",\n \"agents\",\n \"ai\",\n \"api\",\n \"assets\",\n \"auth\",\n \"background\",\n \"docs\",\n \"errors\",\n \"health\",\n \"instances\",\n \"jobs\",\n \"logs\",\n \"mail\",\n \"mails\",\n \"panels\",\n \"queries\",\n \"requests\",\n \"resources\",\n \"routes\",\n \"share\",\n \"stream\",\n]);\n\nconst PANEL_ID = /^[a-z][a-z0-9-]*$/;\nconst ASSET_NAME = /^[A-Za-z0-9_][A-Za-z0-9._-]*$/;\nconst METHODS = new Set<DevtoolsPanelMethod>([\"GET\", \"POST\", \"PUT\", \"PATCH\", \"DELETE\"]);\n\n/** Content types for the files a panel may serve; anything else is sent as bytes. */\nconst CONTENT_TYPES: Record<string, string> = {\n \".js\": \"text/javascript; charset=utf-8\",\n \".mjs\": \"text/javascript; charset=utf-8\",\n \".css\": \"text/css; charset=utf-8\",\n \".json\": \"application/json; charset=utf-8\",\n \".svg\": \"image/svg+xml\",\n \".png\": \"image/png\",\n \".jpg\": \"image/jpeg\",\n \".jpeg\": \"image/jpeg\",\n \".webp\": \"image/webp\",\n \".gif\": \"image/gif\",\n \".woff2\": \"font/woff2\",\n};\n\n/** The content type a panel file is served with, from its served name. */\nexport function panelContentType(name: string): string {\n return CONTENT_TYPES[path.extname(name).toLowerCase()] ?? \"application/octet-stream\";\n}\n\n/** An absolute file path from a path or `file:` URL, or `undefined` for anything else. */\nfunction toFilePath(value: unknown): string | undefined {\n if (value instanceof URL) return value.protocol === \"file:\" ? fileURLToPath(value) : undefined;\n if (typeof value !== \"string\" || value === \"\") return undefined;\n if (value.startsWith(\"file:\")) return fileURLToPath(value);\n\n return path.isAbsolute(value) ? value : undefined;\n}\n\nfunction isFile(file: string): boolean {\n return existsSync(file) && statSync(file).isFile();\n}\n\n/**\n * Validates `value` as a panel and returns it ready to mount. Throws an\n * error that names the panel and what to change; `taken` maps the ids\n * already registered to their titles and receives this panel's id.\n */\nexport function checkDevtoolsPanel(\n value: unknown,\n taken: Map<string, string>,\n): MountedDevtoolsPanel {\n const panel = (value ?? {}) as Partial<DevtoolsPanel>;\n const id = panel.id;\n\n if (typeof id !== \"string\" || !PANEL_ID.test(id)) {\n throw new Error(\n `A devtools panel needs an \"id\" of lower-case letters, digits and dashes that starts with a letter; got ${JSON.stringify(id)}.`,\n );\n }\n\n if (RESERVED_PANEL_IDS.has(id)) {\n throw new Error(\n `Devtools panel id \"${id}\" is used by the dashboard itself; give the panel another id.`,\n );\n }\n\n const existing = taken.get(id);\n\n if (existing !== undefined) {\n throw new Error(\n `Devtools panel id \"${id}\" is already registered by the \"${existing}\" panel; each panel needs its own id.`,\n );\n }\n\n if (typeof panel.title !== \"string\" || panel.title.trim() === \"\") {\n throw new Error(`Devtools panel \"${id}\" needs a \"title\" for its tab.`);\n }\n\n const view = toFilePath(panel.view);\n\n if (view === undefined) {\n throw new Error(\n `Devtools panel \"${id}\" needs a \"view\": an absolute path or file: URL of its browser module.`,\n );\n }\n\n if (!isFile(view)) {\n throw new Error(`The view module of devtools panel \"${id}\" was not found at ${view}.`);\n }\n\n // Two routes on one method and path would make the server refuse to start.\n const seen = new Set<string>();\n const routes = (panel.routes ?? []).map((route) => {\n const method = route.method ?? \"GET\";\n\n if (!METHODS.has(method)) {\n throw new Error(\n `Devtools panel \"${id}\" has a route with method \"${String(method)}\"; use GET, POST, PUT, PATCH or DELETE.`,\n );\n }\n\n if (typeof route.path !== \"string\" || (route.path !== \"\" && !route.path.startsWith(\"/\"))) {\n throw new Error(\n `Devtools panel \"${id}\" has a route path ${JSON.stringify(route.path)}; use \"\" or a path starting with \"/\".`,\n );\n }\n\n if (typeof route.handler !== \"function\") {\n throw new Error(`Devtools panel \"${id}\" route ${method} \"${route.path}\" has no handler.`);\n }\n\n if (seen.has(`${method} ${route.path}`)) {\n throw new Error(\n `Devtools panel \"${id}\" lists route ${method} \"${route.path}\" twice; keep one.`,\n );\n }\n\n seen.add(`${method} ${route.path}`);\n\n return { ...route, method };\n });\n\n const assets: Record<string, string> = {};\n\n for (const [name, source] of Object.entries(panel.assets ?? {})) {\n if (!ASSET_NAME.test(name) || name === \"view.js\") {\n throw new Error(\n `Devtools panel \"${id}\" has an asset named ${JSON.stringify(name)}; use a plain file name other than \"view.js\".`,\n );\n }\n\n const file = toFilePath(source);\n\n if (file === undefined || !isFile(file)) {\n throw new Error(\n `The asset \"${name}\" of devtools panel \"${id}\" was not found at ${String(source)}; give an absolute path or file: URL.`,\n );\n }\n\n assets[name] = file;\n }\n\n const files = checkPanelFiles(id, panel.files);\n const share = checkPanelShare(id, panel.share, routes, assets, files !== null);\n\n taken.set(id, panel.title);\n\n return {\n id,\n title: panel.title,\n view,\n routes,\n assets,\n files,\n share,\n production: panel.production === true,\n };\n}\n\nconst FILE_EXTENSION = /^\\.[a-z0-9]{1,16}$/;\n\n/** Validates `files`; `null` when the panel declares none. */\nfunction checkPanelFiles(\n id: string,\n value: DevtoolsPanel[\"files\"] | null,\n): MountedPanelFiles | null {\n // A panel that was mounted before carries `null` for \"none\".\n if (value === undefined || value === null) return null;\n\n if (typeof value !== \"object\") {\n throw new Error(\n `Devtools panel \"${id}\" has files that is not an object; use { dir: \"/absolute/folder\" }.`,\n );\n }\n\n const dir = toFilePath(value.dir);\n\n if (dir === undefined) {\n throw new Error(\n `Devtools panel \"${id}\" needs files.dir to be an absolute path or a file: URL; got ${String(value.dir)}.`,\n );\n }\n\n const given = value.extensions;\n\n if (given !== undefined && (!Array.isArray(given) || given.length === 0)) {\n throw new Error(\n `Devtools panel \"${id}\" has files.extensions that is not a list; use [\".png\", \".jpg\"] or leave it out.`,\n );\n }\n\n for (const extension of given ?? []) {\n if (typeof extension !== \"string\" || !FILE_EXTENSION.test(extension)) {\n throw new Error(\n `Devtools panel \"${id}\" has files.extensions entry ${JSON.stringify(extension)}; use lower-case extensions that start with a dot, such as \".png\".`,\n );\n }\n\n if (BLOCKED_FILE_EXTENSIONS.has(extension)) {\n throw new Error(\n `Devtools panel \"${id}\" lists files.extensions entry \"${extension}\", which can run as a page or script in the browser; remove it (images such as .png, .jpg, .webp and .gif are fine).`,\n );\n }\n }\n\n return { dir, extensions: [...(given ?? DEFAULT_PANEL_FILE_EXTENSIONS)] };\n}\n\n/** Validates `share` against the panel's own routes, assets and files. */\nfunction checkPanelShare(\n id: string,\n value: DevtoolsPanel[\"share\"] | null,\n routes: readonly { method: DevtoolsPanelMethod; path: string }[],\n assets: Readonly<Record<string, string>>,\n hasFiles: boolean,\n): MountedPanelShare | null {\n // A panel that was mounted before carries `null` for \"none\".\n if (value === undefined || value === null) return null;\n\n if (typeof value !== \"object\") {\n throw new Error(\n `Devtools panel \"${id}\" has share that is not an object; use { view, routes }.`,\n );\n }\n\n const view = toFilePath(value.view);\n\n if (view === undefined) {\n throw new Error(\n `Devtools panel \"${id}\" needs share.view: an absolute path or file: URL of the shared view module.`,\n );\n }\n\n if (!isFile(view)) {\n throw new Error(`The share.view module of devtools panel \"${id}\" was not found at ${view}.`);\n }\n\n if (!Array.isArray(value.routes)) {\n throw new Error(\n `Devtools panel \"${id}\" needs share.routes: a list of the paths of its GET routes the shared page may call.`,\n );\n }\n\n const getPaths = routes.filter((route) => route.method === \"GET\").map((route) => route.path);\n\n for (const route of value.routes) {\n if (typeof route !== \"string\" || !getPaths.includes(route)) {\n throw new Error(\n `Devtools panel \"${id}\" lists share.routes entry ${JSON.stringify(route)}, which is not the path of one of its GET routes${getPaths.length > 0 ? `; use one of ${getPaths.map((path) => JSON.stringify(path)).join(\", \")}` : \" (the panel has no GET routes)\"}.`,\n );\n }\n }\n\n for (const name of value.assets ?? []) {\n if (typeof name !== \"string\" || !Object.hasOwn(assets, name)) {\n throw new Error(\n `Devtools panel \"${id}\" lists share.assets entry ${JSON.stringify(name)}, which is not a name in its assets; use one of ${Object.keys(assets).join(\", \") || \"(the panel has no assets)\"}.`,\n );\n }\n }\n\n const files = value.files === true;\n\n if (value.files !== undefined && typeof value.files !== \"boolean\") {\n throw new Error(`Devtools panel \"${id}\" needs share.files to be true or false.`);\n }\n\n if (files && !hasFiles) {\n throw new Error(\n `Devtools panel \"${id}\" sets share.files, but the panel has no files folder; add files: { dir } or remove share.files.`,\n );\n }\n\n return { view, routes: [...value.routes], assets: [...(value.assets ?? [])], files };\n}\n\n/** Validates a list of panels; the first invalid or duplicate one throws. */\nexport function checkDevtoolsPanels(panels: readonly unknown[]): MountedDevtoolsPanel[] {\n const taken = new Map<string, string>();\n\n return panels.map((panel) => checkDevtoolsPanel(panel, taken));\n}\n\n/** Hooks `loadDevtoolsPanels` uses; replaced in specs. */\nexport type LoadDevtoolsPanelsOptions = {\n /** The app's root directory: bare specifiers resolve from here, `./` paths are relative to it. */\n root: string;\n /** Receives one line per entry that could not be loaded or was rejected. */\n warn: (message: string) => void;\n /** Ids already taken (the built-in panels), mapped to their titles. */\n taken?: ReadonlyMap<string, string>;\n /** Imports a module URL or specifier; defaults to a dynamic `import()`. */\n importModule?: (specifier: string) => Promise<unknown>;\n /** Where the dashboard runs; panel factories receive it as `context.mode`. @default \"development\" */\n mode?: DevtoolsMode;\n /** The captured error groups of the last hour; panel factories receive it as `context.errors`. */\n errors?: () => Promise<readonly DevtoolsPanelErrorSummary[]>;\n};\n\nfunction isPlainObject(value: unknown): value is Record<string, unknown> {\n if (value === null || typeof value !== \"object\" || Array.isArray(value)) return false;\n\n const prototype = Object.getPrototypeOf(value);\n\n return prototype === Object.prototype || prototype === null;\n}\n\n/** What is wrong with a `[specifier, options]` entry, or `undefined` when it is valid. */\nfunction tupleProblem(entry: readonly unknown[]): string | undefined {\n if (entry.length !== 2) {\n return `it has ${entry.length} item(s); use exactly [specifier, options]`;\n }\n\n if (typeof entry[0] !== \"string\" || entry[0] === \"\") {\n return `its first item is ${JSON.stringify(entry[0])}; use the module specifier as a string`;\n }\n\n if (!isPlainObject(entry[1])) {\n return `its second item is not a plain object; pass the options as { name: value }`;\n }\n\n return undefined;\n}\n\n/** The URL or specifier to import for a `panels` entry. */\nfunction resolvePanelSpecifier(entry: string, root: string): string {\n if (entry.startsWith(\"./\") || entry.startsWith(\"../\") || path.isAbsolute(entry)) {\n return pathToFileURL(path.resolve(root, entry)).href;\n }\n\n return resolveFromNodeModules(entry, root) ?? resolveWithRequire(entry, root) ?? entry;\n}\n\n/** Picks the file an `exports` target names: `import`, then `default`, then `node`. */\nfunction exportTarget(target: unknown): string | undefined {\n if (typeof target === \"string\") return target;\n\n if (Array.isArray(target)) {\n for (const item of target) {\n const found = exportTarget(item);\n\n if (found !== undefined) return found;\n }\n\n return undefined;\n }\n\n if (target !== null && typeof target === \"object\") {\n const conditions = target as Record<string, unknown>;\n\n for (const condition of [\"import\", \"node\", \"default\"]) {\n const found = exportTarget(conditions[condition]);\n\n if (found !== undefined) return found;\n }\n }\n\n return undefined;\n}\n\n/**\n * Resolves a package specifier by looking it up in the `node_modules` folders\n * above the app root and reading its `exports` map. `createRequire().resolve`\n * cannot do this for a package that only has an `import` condition.\n */\nfunction resolveFromNodeModules(entry: string, root: string): string | undefined {\n const parts = entry.split(\"/\");\n const nameLength = entry.startsWith(\"@\") ? 2 : 1;\n const name = parts.slice(0, nameLength).join(\"/\");\n const subpath = parts.length > nameLength ? `./${parts.slice(nameLength).join(\"/\")}` : \".\";\n\n if (!name) return undefined;\n\n let directory = path.resolve(root);\n\n for (;;) {\n const packageDirectory = path.join(directory, \"node_modules\", name);\n const manifestFile = path.join(packageDirectory, \"package.json\");\n\n if (existsSync(manifestFile)) {\n try {\n const manifest = JSON.parse(readFileSync(manifestFile, \"utf8\")) as {\n exports?: unknown;\n main?: string;\n };\n const exported = manifest.exports;\n const map =\n exported !== null && typeof exported === \"object\" && !Array.isArray(exported)\n ? (exported as Record<string, unknown>)\n : undefined;\n const hasSubpaths =\n map !== undefined && Object.keys(map).some((key) => key.startsWith(\".\"));\n const target =\n exported === undefined\n ? subpath === \".\"\n ? (manifest.main ?? \"index.js\")\n : subpath\n : hasSubpaths\n ? exportTarget(map?.[subpath])\n : subpath === \".\"\n ? exportTarget(exported)\n : undefined;\n\n if (target === undefined) return undefined;\n\n const file = path.resolve(packageDirectory, target);\n\n return isFile(file) ? pathToFileURL(file).href : undefined;\n } catch {\n return undefined;\n }\n }\n\n const parent = path.dirname(directory);\n\n if (parent === directory) return undefined;\n\n directory = parent;\n }\n}\n\n/** The `require` resolution, for packages the `node_modules` lookup does not understand. */\nfunction resolveWithRequire(entry: string, root: string): string | undefined {\n try {\n return pathToFileURL(createRequire(path.join(root, \"package.json\")).resolve(entry)).href;\n } catch {\n return undefined;\n }\n}\n\n/** The panels a module's default export describes. */\nasync function panelsOf(\n exported: DevtoolsPanelExport,\n root: string,\n mode: DevtoolsMode,\n panelOptions: Readonly<Record<string, unknown>> = {},\n errors?: () => Promise<readonly DevtoolsPanelErrorSummary[]>,\n): Promise<readonly unknown[]> {\n const value =\n typeof exported === \"function\"\n ? await exported({ ...panelOptions, root, mode, ...(errors ? { errors } : {}) })\n : exported;\n\n return Array.isArray(value) ? value : [value];\n}\n\n/**\n * Loads the devtools `panels` option: imports each module entry, reads its\n * default export, and validates every panel. An entry that fails to load and\n * a panel that is invalid or reuses an id are reported through `warn` and\n * skipped, so one broken panel never stops the dashboard.\n */\nexport async function loadDevtoolsPanels(\n entries: readonly DevtoolsPanelEntry[],\n options: LoadDevtoolsPanelsOptions,\n): Promise<MountedDevtoolsPanel[]> {\n // `src/config/devtools.ts` is a plain object with no types: a single string would be read letter by letter.\n if (!Array.isArray(entries as unknown)) {\n options.warn(\n `The devtools \"panels\" option must be a list, such as panels: [\"@warlock.js/grimoire/devtools\"]; got ${JSON.stringify(entries)}. No panel was added.`,\n );\n\n return [];\n }\n\n const importModule = options.importModule ?? ((specifier: string) => import(specifier));\n const mode = options.mode ?? \"development\";\n const taken = new Map<string, string>(options.taken ?? []);\n const panels: MountedDevtoolsPanel[] = [];\n\n for (const entry of entries) {\n let candidates: readonly unknown[];\n\n try {\n if (Array.isArray(entry as unknown)) {\n const problem = tupleProblem(entry as readonly unknown[]);\n\n if (problem !== undefined) {\n options.warn(\n `Devtools panels entry ${JSON.stringify(entry)} is invalid: ${problem}. Example: [\"@warlock.js/grimoire/devtools\", { ttlMs: 60000 }]. The entry was not added.`,\n );\n continue;\n }\n }\n\n if (typeof entry === \"string\" || Array.isArray(entry as unknown)) {\n const [specifier, panelOptions] =\n typeof entry === \"string\"\n ? [entry, undefined]\n : (entry as readonly [string, Record<string, unknown>]);\n const module = (await importModule(resolvePanelSpecifier(specifier, options.root))) as {\n default?: DevtoolsPanelExport;\n };\n\n if (module.default === undefined) {\n throw new Error(\"the module has no default export\");\n }\n\n candidates = await panelsOf(\n module.default,\n options.root,\n mode,\n panelOptions,\n options.errors,\n );\n } else {\n candidates = [entry];\n }\n } catch (error) {\n options.warn(\n `Devtools panel module \"${String(Array.isArray(entry as unknown) ? (entry as readonly unknown[])[0] : entry)}\" could not be loaded: ${describe(error)}. Check that it is installed and listed correctly in the devtools \"panels\" option.`,\n );\n continue;\n }\n\n for (const candidate of candidates) {\n try {\n panels.push(checkDevtoolsPanel(candidate, taken));\n } catch (error) {\n options.warn(`${describe(error)} The panel was not added.`);\n }\n }\n }\n\n return panels;\n}\n\nfunction describe(error: unknown): string {\n return error instanceof Error ? error.message : String(error);\n}\n\n/** What `productionPanels` decides. */\nexport type DevtoolsProductionPanels = {\n /** Built-in tab ids shown, in display order. */\n builtIn: string[];\n /** Package panels shown. */\n panels: MountedDevtoolsPanel[];\n};\n\n/**\n * Which tabs the production monitor shows. A built-in tab follows\n * `DEVTOOLS_BUILT_IN_PANELS` unless `overrides[id]` says otherwise. A package\n * panel (the Processes panel included) shows when it declares\n * `production: true` or `overrides[id]` is `true`; `overrides[id]: false` turns\n * any tab off.\n */\nexport function productionPanels(\n packagePanels: readonly MountedDevtoolsPanel[],\n overrides: Readonly<Record<string, boolean>> = {},\n): DevtoolsProductionPanels {\n const builtIn = DEVTOOLS_BUILT_IN_PANELS.filter((tab) => overrides[tab.id] ?? tab.production).map(\n (tab) => tab.id,\n );\n const panels = packagePanels.filter((panel) => overrides[panel.id] ?? panel.production);\n\n return { builtIn, panels };\n}\n\n/**\n * The tab list `GET api/panels` answers with: the built-in tabs in\n * `builtIn` (default: every one), in display order, then the package panels\n * in registration order.\n */\nexport function listPanelInfos(\n panels: readonly (Pick<MountedDevtoolsPanel, \"id\" | \"title\"> &\n Partial<Pick<MountedDevtoolsPanel, \"share\">>)[],\n builtIn?: readonly string[],\n): DevtoolsPanelInfo[] {\n const tabs: DevtoolsPanelInfo[] = DEVTOOLS_BUILT_IN_PANELS.filter(\n (tab) => builtIn === undefined || builtIn.includes(tab.id),\n ).map((tab) => ({\n id: tab.id,\n title: tab.title,\n type: \"built-in\" as const,\n shareable: false,\n }));\n\n for (const panel of panels) {\n tabs.push({\n id: panel.id,\n title: panel.title,\n type: \"package\" as const,\n shareable: panel.share !== undefined && panel.share !== null,\n });\n }\n\n return tabs;\n}\n"],"mappings":";;;;;;;;;;AAoDA,MAAa,gCAAmD;CAC9D;CACA;CACA;CACA;CACA;AACF;;AAGA,MAAM,0CAA0B,IAAI,IAAI;CAAC;CAAQ;CAAS;CAAQ;CAAO;AAAM,CAAC;;;;;AAMhF,MAAM,qCAAqB,IAAI,IAAI;CACjC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;AAED,MAAM,WAAW;AACjB,MAAM,aAAa;AACnB,MAAM,0BAAU,IAAI,IAAyB;CAAC;CAAO;CAAQ;CAAO;CAAS;AAAQ,CAAC;;AAGtF,MAAM,gBAAwC;CAC5C,OAAO;CACP,QAAQ;CACR,QAAQ;CACR,SAAS;CACT,QAAQ;CACR,QAAQ;CACR,QAAQ;CACR,SAAS;CACT,SAAS;CACT,QAAQ;CACR,UAAU;AACZ;;AAGA,SAAgB,iBAAiB,MAAsB;CACrD,OAAO,cAAcA,kBAAK,QAAQ,IAAI,CAAC,CAAC,YAAY,MAAM;AAC5D;;AAGA,SAAS,WAAW,OAAoC;CACtD,IAAI,iBAAiB,KAAK,OAAO,MAAM,aAAa,cAAUC,wBAAc,KAAK,IAAI;CACrF,IAAI,OAAO,UAAU,YAAY,UAAU,IAAI,OAAO;CACtD,IAAI,MAAM,WAAW,OAAO,GAAG,WAAOA,wBAAc,KAAK;CAEzD,OAAOD,kBAAK,WAAW,KAAK,IAAI,QAAQ;AAC1C;AAEA,SAAS,OAAO,MAAuB;CACrC,WAAOE,oBAAW,IAAI,SAAKC,kBAAS,IAAI,CAAC,CAAC,OAAO;AACnD;;;;;;AAOA,SAAgB,mBACd,OACA,OAC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qB;CACrB,MAAM,OAA4BA,2CAAyB,QACxD,QAAQ,YAAY,UAAa,QAAQ,SAAS,IAAI,EAAE,CAC3D,CAAC,CAAC,KAAK,SAAS;EACd,IAAI,IAAI;EACR,OAAO,IAAI;EACX,MAAM;EACN,WAAW;CACb,EAAE;CAEF,KAAK,MAAM,SAAS,QAClB,KAAK,KAAK;EACR,IAAI,MAAM;EACV,OAAO,MAAM;EACb,MAAM;EACN,WAAW,MAAM,UAAU,UAAa,MAAM,UAAU;CAC1D,CAAC;CAGH,OAAO;AACT"}
@@ -1,6 +1,6 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_errors = require("../errors-CyZp5yS-.cjs");
3
- const require_migrations = require("../migrations-w7GMsrQw.cjs");
2
+ const require_errors = require("../errors-DEqdWaqm.cjs");
3
+ const require_migrations = require("../migrations-DTTzCNpR.cjs");
4
4
  let _warlock_js_core = require("@warlock.js/core");
5
5
 
6
6
  //#region ../../packages/devtools/src/production/cli/actions.ts
@@ -173,7 +173,7 @@ async function exitWith(code) {
173
173
  /** The store of the app's database, or the exit code of the error that stopped it. */
174
174
  async function openStore() {
175
175
  try {
176
- const { createCascadeStore } = await Promise.resolve().then(() => require("../cascade-store-pHjKeSFm.cjs"));
176
+ const { createCascadeStore } = await Promise.resolve().then(() => require("../cascade-store-DEGxAFDI.cjs"));
177
177
  return { store: await createCascadeStore() };
178
178
  } catch (error) {
179
179
  return { code: reportStoreError(io, error) };
@@ -213,7 +213,7 @@ function registerDevtoolsCommands() {
213
213
  const email = resolveAdminEmail(options.email, process.env);
214
214
  const opened = await openStore();
215
215
  if (!opened.store) return exitWith(opened.code);
216
- const [{ hashPassword }, { generateTemporaryPassword }] = await Promise.all([import("@warlock.js/core"), Promise.resolve().then(() => require("../auth-DzU0gHDG.cjs"))]);
216
+ const [{ hashPassword }, { generateTemporaryPassword }] = await Promise.all([import("@warlock.js/core"), Promise.resolve().then(() => require("../auth-DV2GA1A9.cjs"))]);
217
217
  await exitWith(await runResetAdmin({
218
218
  store: opened.store,
219
219
  now: Date.now,
@@ -1,6 +1,6 @@
1
- const require_panels = require("./panels-B0dAfGbJ.cjs");
1
+ const require_panels = require("./panels-CHd20RK5.cjs");
2
2
  const require_process_panel = require("./process-panel-DEOnLxoT.cjs");
3
- const require_stream_route = require("./stream-route-BGJa-zQu.cjs");
3
+ const require_stream_route = require("./stream-route-D4k-sJvW.cjs");
4
4
 
5
5
  //#region ../../packages/devtools/src/server/background-routes.ts
6
6
  /** Registers the route that returns work recorded outside any request. */
@@ -122,7 +122,8 @@ function developmentSessionView(deps) {
122
122
  csrf: null,
123
123
  expiresAt: null,
124
124
  instance: deps.instance ?? null,
125
- methods: null
125
+ methods: null,
126
+ share: null
126
127
  };
127
128
  }
128
129
  /** The tabs `GET api/panels` lists: the built-in tabs in `deps.builtInPanels` (default all), then the package panels. */
@@ -181,4 +182,4 @@ function mountDevtoolsRoutes(server, deps) {
181
182
 
182
183
  //#endregion
183
184
  exports.mountDevtoolsRoutes = mountDevtoolsRoutes;
184
- //# sourceMappingURL=server-B6xdeKS8.cjs.map
185
+ //# sourceMappingURL=server-C8JfggQU.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server-C8JfggQU.cjs","names":["listPanelInfos","checkDevtoolsPanels","processesDevtoolsPanel"],"sources":["../../../../../../../packages/devtools/src/server/background-routes.ts","../../../../../../../packages/devtools/src/server/guard.ts","../../../../../../../packages/devtools/src/server/session-routes.ts","../../../../../../../packages/devtools/src/server/index.ts"],"sourcesContent":["import type { FastifyInstance } from \"fastify\";\nimport type { MountDevtoolsRoutesDeps } from \"./types\";\n\n/** Registers the route that returns work recorded outside any request. */\nexport function registerBackgroundRoutes(\n server: FastifyInstance,\n deps: MountDevtoolsRoutesDeps,\n): void {\n server.get(\"/api/background\", async () => deps.collector.getBackground());\n}\n","import type { FastifyInstance, FastifyReply, FastifyRequest } from \"fastify\";\nimport type { MountDevtoolsRoutesDeps } from \"./types\";\n\nconst LOOPBACK_ADDRESSES = new Set([\"127.0.0.1\", \"::1\", \"::ffff:127.0.0.1\"]);\n\n/** Host names that always reach this machine, so DNS cannot be pointed at them. */\nconst LOOPBACK_HOSTS = new Set([\"localhost\", \"127.0.0.1\", \"[::1]\"]);\n\n/** Headers a proxy or tunnel adds; their presence means the loopback peer is not the visitor. */\nconst PROXY_HEADERS = [\"x-forwarded-for\", \"x-forwarded-host\", \"x-real-ip\", \"forwarded\"] as const;\n\n/** At most this many distinct refusals are logged per boot. */\nconst MAX_WARNINGS = 20;\n\n/**\n * Whether `address` is a loopback address. Deliberately reads\n * `request.socket.remoteAddress` rather than `request.ip`, which honours\n * `X-Forwarded-For` when the app trusts a proxy — a header any client can\n * set.\n */\nfunction isLoopbackAddress(address: string | undefined): boolean {\n return address !== undefined && LOOPBACK_ADDRESSES.has(address);\n}\n\n/** The lower-cased host name of a `Host` header value, without its port (`[::1]` keeps its brackets). */\nexport function hostnameOf(host: string): string {\n const value = host.trim().toLowerCase();\n\n if (value.startsWith(\"[\")) {\n const end = value.indexOf(\"]\");\n\n return end === -1 ? \"\" : value.slice(0, end + 1);\n }\n\n const colon = value.indexOf(\":\");\n const name = colon === -1 ? value : value.slice(0, colon);\n\n return name.endsWith(\".\") ? name.slice(0, -1) : name;\n}\n\n/**\n * Whether `hostname` is a loopback name or one of `allowedHosts`. An entry\n * starting with `.` matches that domain and every subdomain of it.\n */\nexport function isAllowedDevtoolsHost(\n hostname: string,\n allowedHosts: readonly string[] = [],\n): boolean {\n if (!hostname) return false;\n if (LOOPBACK_HOSTS.has(hostname) || hostname.endsWith(\".localhost\")) return true;\n\n return allowedHosts.some((entry) => {\n const allowed = entry.trim().toLowerCase();\n\n if (allowed.startsWith(\".\")) {\n return hostname === allowed.slice(1) || hostname.endsWith(allowed);\n }\n\n return hostname === allowed;\n });\n}\n\n/** The `Origin` header's host name, `\"\"` for `null` or an unparsable value. */\nfunction originHostname(origin: string): string {\n try {\n return new URL(origin).hostname.toLowerCase();\n } catch {\n return \"\";\n }\n}\n\n/**\n * Why `request` must be refused, or `undefined` when it may be served.\n * `\"not-local\"` is the silent case (production, or a remote socket). Beyond a\n * loopback socket, the request must be ADDRESSED to a loopback (or allowed)\n * host, come from such an origin, and not have passed through a proxy: a page\n * whose domain was re-pointed at 127.0.0.1, or a tunnel, also arrives on a\n * loopback socket.\n */\nfunction refusalReason(request: FastifyRequest, deps: MountDevtoolsRoutesDeps): string | undefined {\n if (!deps.isDevelopment() || !isLoopbackAddress(request.socket.remoteAddress)) {\n return \"not-local\";\n }\n\n const allowedHosts = deps.options.allowedHosts ?? [];\n const host = hostnameOf(request.headers.host ?? \"\");\n\n if (!isAllowedDevtoolsHost(host, allowedHosts)) {\n return `Devtools refused a request for host \"${host}\". Open the dashboard on localhost, or add the host to the devtools \"allowedHosts\" option.`;\n }\n\n const origin = request.headers.origin;\n\n if (origin !== undefined && !isAllowedDevtoolsHost(originHostname(origin), allowedHosts)) {\n return `Devtools refused a request from origin \"${origin}\". Only pages served from localhost or a host in the devtools \"allowedHosts\" option may call the dashboard.`;\n }\n\n if (\n !deps.options.allowProxied &&\n PROXY_HEADERS.some((name) => request.headers[name] !== undefined)\n ) {\n return 'Devtools refused a proxied request (it carries a forwarding header). Open the dashboard directly on localhost, or set the devtools \"allowProxied\" option for a local proxy nobody else can reach.';\n }\n\n return undefined;\n}\n\n/**\n * Registers the dev-only, local-only guard as an `onRequest` hook on\n * `server`. Callers must register this inside an encapsulated Fastify\n * context (a plugin/prefix) so the hook never reaches routes outside the\n * dashboard.\n */\nexport function registerDevtoolsGuard(\n server: FastifyInstance,\n deps: MountDevtoolsRoutesDeps,\n): void {\n // One terminal line per distinct refusal, so a misconfigured host is\n // explained once without flooding the log on every poll.\n const warned = new Set<string>();\n\n server.addHook(\"onRequest\", async (request: FastifyRequest, reply: FastifyReply) => {\n const reason = refusalReason(request, deps);\n\n if (reason === undefined) return;\n\n if (reason !== \"not-local\" && !warned.has(reason) && warned.size < MAX_WARNINGS) {\n warned.add(reason);\n deps.warn?.(reason);\n }\n\n // Returning the reply is what stops the lifecycle in an async hook;\n // without it Fastify still runs the handler after the 404 is sent.\n return reply.code(404).send();\n });\n}\n","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","import type { FastifyError, FastifyInstance } from \"fastify\";\nimport { checkDevtoolsPanels } from \"../panels\";\nimport { processesDevtoolsPanel } from \"../process-panel\";\nimport { registerAiRoutes } from \"./ai-routes\";\nimport { registerBackgroundRoutes } from \"./background-routes\";\nimport { registerExplainRoute, registerShapeExplainRoute } from \"./explain-route\";\nimport { registerInsightsRoutes } from \"./insights-routes\";\nimport { registerDevtoolsGuard } from \"./guard\";\nimport { registerLogRoutes } from \"./log-routes\";\nimport { registerMailRoutes } from \"./mail-routes\";\nimport { registerOpenApiRoutes } from \"./openapi-routes\";\nimport { registerPanelRoutes } from \"./panel-routes\";\nimport { registerRequestsRoutes } from \"./requests-routes\";\nimport { registerRouteRoutes } from \"./route-routes\";\nimport { registerSessionRoutes } from \"./session-routes\";\nimport { registerStreamRoute } from \"./stream-route\";\nimport type { MountDevtoolsRoutesDeps } from \"./types\";\nimport { registerUiAssets } from \"./ui-assets\";\n\nexport type { DevtoolsRequestLogSource, DevtoolsRouteRow, MountDevtoolsRoutesDeps } from \"./types\";\n\n/**\n * Mounts the devtools dashboard and its API under `deps.options.path` on\n * `server`. Every route is registered inside a single encapsulated Fastify\n * context so the dev-only, loopback-only guard never reaches the app's\n * other routes — the registered panels' data routes and files included.\n *\n * Throws before mounting anything when a panel is invalid or reuses an id.\n */\nexport function mountDevtoolsRoutes(server: FastifyInstance, deps: MountDevtoolsRoutesDeps): void {\n const panels = checkDevtoolsPanels([\n processesDevtoolsPanel(deps.processPanel),\n ...(deps.panels ?? []),\n ]);\n\n server.register(\n async (instance) => {\n registerDevtoolsGuard(instance, deps);\n\n instance.setErrorHandler((error: FastifyError, _request, reply) => {\n reply.code(error.statusCode ?? 500).send({ error: error.message });\n });\n\n registerUiAssets(instance);\n registerSessionRoutes(instance, deps, panels);\n registerRequestsRoutes(instance, deps);\n registerAiRoutes(instance, deps);\n registerBackgroundRoutes(instance, deps);\n registerMailRoutes(instance, deps);\n registerLogRoutes(instance, deps);\n registerRouteRoutes(instance, deps);\n registerPanelRoutes(instance, panels);\n registerOpenApiRoutes(instance, deps);\n registerExplainRoute(instance, deps);\n registerShapeExplainRoute(instance, deps);\n if (deps.insights) registerInsightsRoutes(instance, deps);\n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