@warlock.js/devtools 5.55.0 → 5.56.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 (234) hide show
  1. package/CHANGELOG.md +29 -0
  2. package/README.md +26 -13
  3. package/cjs/ai-source-DTpxumMA.cjs +381 -0
  4. package/cjs/ai-source-DTpxumMA.cjs.map +1 -0
  5. package/cjs/auth-DzU0gHDG.cjs +1655 -0
  6. package/cjs/auth-DzU0gHDG.cjs.map +1 -0
  7. package/cjs/boot-BQi0Etor.cjs +138 -0
  8. package/cjs/boot-BQi0Etor.cjs.map +1 -0
  9. package/cjs/capture-CqIiaznN.cjs +1342 -0
  10. package/cjs/capture-CqIiaznN.cjs.map +1 -0
  11. package/cjs/cascade-store-pHjKeSFm.cjs +863 -0
  12. package/cjs/cascade-store-pHjKeSFm.cjs.map +1 -0
  13. package/cjs/collector-CJbQbzzK.cjs +271 -0
  14. package/cjs/collector-CJbQbzzK.cjs.map +1 -0
  15. package/cjs/contracts-CVmplkNb.cjs +112 -0
  16. package/cjs/contracts-CVmplkNb.cjs.map +1 -0
  17. package/cjs/current-request-id-BoJJb3y7.cjs +37 -0
  18. package/cjs/current-request-id-BoJJb3y7.cjs.map +1 -0
  19. package/cjs/errors-CyZp5yS-.cjs +177 -0
  20. package/cjs/errors-CyZp5yS-.cjs.map +1 -0
  21. package/cjs/histogram-BaI-PnCv.cjs +102 -0
  22. package/cjs/histogram-BaI-PnCv.cjs.map +1 -0
  23. package/cjs/http-CabcUwBx.cjs +870 -0
  24. package/cjs/http-CabcUwBx.cjs.map +1 -0
  25. package/cjs/index.cjs +1 -1
  26. package/cjs/insights-BKtqxdnP.cjs +811 -0
  27. package/cjs/insights-BKtqxdnP.cjs.map +1 -0
  28. package/cjs/ip-DbNhPOzi.cjs +153 -0
  29. package/cjs/ip-DbNhPOzi.cjs.map +1 -0
  30. package/cjs/migrations-w7GMsrQw.cjs +297 -0
  31. package/cjs/migrations-w7GMsrQw.cjs.map +1 -0
  32. package/cjs/openapi-CC7OAUc6.cjs +52 -0
  33. package/cjs/openapi-CC7OAUc6.cjs.map +1 -0
  34. package/cjs/options-CWqFC5__.cjs +181 -0
  35. package/cjs/options-CWqFC5__.cjs.map +1 -0
  36. package/cjs/panels-B0dAfGbJ.cjs +298 -0
  37. package/cjs/panels-B0dAfGbJ.cjs.map +1 -0
  38. package/cjs/process-panel-DEOnLxoT.cjs +48 -0
  39. package/cjs/process-panel-DEOnLxoT.cjs.map +1 -0
  40. package/cjs/production/index.cjs +238 -0
  41. package/cjs/production/index.cjs.map +1 -0
  42. package/cjs/rolldown-runtime-Zuuoy_Rh.cjs +52 -0
  43. package/cjs/server-B6xdeKS8.cjs +184 -0
  44. package/cjs/server-B6xdeKS8.cjs.map +1 -0
  45. package/cjs/{src-Xwm3Eel9.cjs → src-Ce-3Lniv.cjs} +163 -295
  46. package/cjs/src-Ce-3Lniv.cjs.map +1 -0
  47. package/cjs/store-aq207T8v.cjs +9 -0
  48. package/cjs/stream-route-BGJa-zQu.cjs +875 -0
  49. package/cjs/stream-route-BGJa-zQu.cjs.map +1 -0
  50. package/esm/devtools-connector.d.mts +16 -13
  51. package/esm/devtools-connector.d.mts.map +1 -1
  52. package/esm/devtools-connector.mjs +127 -18
  53. package/esm/devtools-connector.mjs.map +1 -1
  54. package/esm/index.d.mts +3 -2
  55. package/esm/options.mjs +2 -1
  56. package/esm/options.mjs.map +1 -1
  57. package/esm/panels.mjs +50 -5
  58. package/esm/panels.mjs.map +1 -1
  59. package/esm/production/auth/common-passwords.mjs +303 -0
  60. package/esm/production/auth/common-passwords.mjs.map +1 -0
  61. package/esm/production/auth/default-crypto.mjs +19 -0
  62. package/esm/production/auth/default-crypto.mjs.map +1 -0
  63. package/esm/production/auth/helpers.mjs +77 -0
  64. package/esm/production/auth/helpers.mjs.map +1 -0
  65. package/esm/production/auth/index.mjs +6 -0
  66. package/esm/production/auth/passkeys.mjs +96 -0
  67. package/esm/production/auth/passkeys.mjs.map +1 -0
  68. package/esm/production/auth/service.mjs +1166 -0
  69. package/esm/production/auth/service.mjs.map +1 -0
  70. package/esm/production/boot.mjs +138 -0
  71. package/esm/production/boot.mjs.map +1 -0
  72. package/esm/production/capture/dev-stats.mjs +83 -0
  73. package/esm/production/capture/dev-stats.mjs.map +1 -0
  74. package/esm/production/capture/engine.mjs +442 -0
  75. package/esm/production/capture/engine.mjs.map +1 -0
  76. package/esm/production/capture/explain.mjs +271 -0
  77. package/esm/production/capture/explain.mjs.map +1 -0
  78. package/esm/production/capture/filter.mjs +24 -0
  79. package/esm/production/capture/filter.mjs.map +1 -0
  80. package/esm/production/capture/index.mjs +7 -0
  81. package/esm/production/capture/production-capture.mjs +134 -0
  82. package/esm/production/capture/production-capture.mjs.map +1 -0
  83. package/esm/production/capture/redact.mjs +109 -0
  84. package/esm/production/capture/redact.mjs.map +1 -0
  85. package/esm/production/capture/stats-stores.mjs +300 -0
  86. package/esm/production/capture/stats-stores.mjs.map +1 -0
  87. package/esm/production/cli/actions.mjs +151 -0
  88. package/esm/production/cli/actions.mjs.map +1 -0
  89. package/esm/production/cli/index.d.mts +17 -0
  90. package/esm/production/cli/index.d.mts.map +1 -0
  91. package/esm/production/cli/index.mjs +86 -0
  92. package/esm/production/cli/index.mjs.map +1 -0
  93. package/esm/production/contracts.d.mts +592 -0
  94. package/esm/production/contracts.d.mts.map +1 -0
  95. package/esm/production/contracts.mjs +95 -0
  96. package/esm/production/contracts.mjs.map +1 -0
  97. package/esm/production/errors.d.mts +31 -0
  98. package/esm/production/errors.d.mts.map +1 -0
  99. package/esm/production/errors.mjs +142 -0
  100. package/esm/production/errors.mjs.map +1 -0
  101. package/esm/production/http/access.mjs +124 -0
  102. package/esm/production/http/access.mjs.map +1 -0
  103. package/esm/production/http/auth-routes.mjs +280 -0
  104. package/esm/production/http/auth-routes.mjs.map +1 -0
  105. package/esm/production/http/client.mjs +57 -0
  106. package/esm/production/http/client.mjs.map +1 -0
  107. package/esm/production/http/constants.mjs +11 -0
  108. package/esm/production/http/constants.mjs.map +1 -0
  109. package/esm/production/http/context.mjs +14 -0
  110. package/esm/production/http/context.mjs.map +1 -0
  111. package/esm/production/http/cookie.mjs +39 -0
  112. package/esm/production/http/cookie.mjs.map +1 -0
  113. package/esm/production/http/headers.mjs +25 -0
  114. package/esm/production/http/headers.mjs.map +1 -0
  115. package/esm/production/http/index.mjs +10 -0
  116. package/esm/production/http/ip.mjs +130 -0
  117. package/esm/production/http/ip.mjs.map +1 -0
  118. package/esm/production/http/mount.mjs +300 -0
  119. package/esm/production/http/mount.mjs.map +1 -0
  120. package/esm/production/http/state.mjs +54 -0
  121. package/esm/production/http/state.mjs.map +1 -0
  122. package/esm/production/index.d.mts +6 -0
  123. package/esm/production/index.mjs +5 -0
  124. package/esm/production/insights/cap-report.mjs +67 -0
  125. package/esm/production/insights/cap-report.mjs.map +1 -0
  126. package/esm/production/insights/health.mjs +88 -0
  127. package/esm/production/insights/health.mjs.map +1 -0
  128. package/esm/production/insights/index.mjs +10 -0
  129. package/esm/production/insights/insights.mjs +167 -0
  130. package/esm/production/insights/insights.mjs.map +1 -0
  131. package/esm/production/insights/instance.mjs +24 -0
  132. package/esm/production/insights/instance.mjs.map +1 -0
  133. package/esm/production/insights/jobs.mjs +100 -0
  134. package/esm/production/insights/jobs.mjs.map +1 -0
  135. package/esm/production/insights/reporter.mjs +59 -0
  136. package/esm/production/insights/reporter.mjs.map +1 -0
  137. package/esm/production/insights/resources.mjs +139 -0
  138. package/esm/production/insights/resources.mjs.map +1 -0
  139. package/esm/production/insights/writer.mjs +72 -0
  140. package/esm/production/insights/writer.mjs.map +1 -0
  141. package/esm/production/openapi.mjs +52 -0
  142. package/esm/production/openapi.mjs.map +1 -0
  143. package/esm/production/options.d.mts +60 -0
  144. package/esm/production/options.d.mts.map +1 -0
  145. package/esm/production/options.mjs +170 -0
  146. package/esm/production/options.mjs.map +1 -0
  147. package/esm/production/stats/histogram.mjs +67 -0
  148. package/esm/production/stats/histogram.mjs.map +1 -0
  149. package/esm/production/stats/merge.mjs +106 -0
  150. package/esm/production/stats/merge.mjs.map +1 -0
  151. package/esm/production/store/cascade-store.mjs +322 -0
  152. package/esm/production/store/cascade-store.mjs.map +1 -0
  153. package/esm/production/store/index.mjs +5 -0
  154. package/esm/production/store/mapping.mjs +258 -0
  155. package/esm/production/store/mapping.mjs.map +1 -0
  156. package/esm/production/store/memory-store.mjs +291 -0
  157. package/esm/production/store/memory-store.mjs.map +1 -0
  158. package/esm/production/store/migrations.d.mts +11 -0
  159. package/esm/production/store/migrations.d.mts.map +1 -0
  160. package/esm/production/store/migrations.mjs +29 -0
  161. package/esm/production/store/migrations.mjs.map +1 -0
  162. package/esm/production/store/models/account.migration.mjs +34 -0
  163. package/esm/production/store/models/account.migration.mjs.map +1 -0
  164. package/esm/production/store/models/account.model.mjs +13 -0
  165. package/esm/production/store/models/account.model.mjs.map +1 -0
  166. package/esm/production/store/models/audit.migration.mjs +30 -0
  167. package/esm/production/store/models/audit.migration.mjs.map +1 -0
  168. package/esm/production/store/models/audit.model.mjs +13 -0
  169. package/esm/production/store/models/audit.model.mjs.map +1 -0
  170. package/esm/production/store/models/base.mjs +27 -0
  171. package/esm/production/store/models/base.mjs.map +1 -0
  172. package/esm/production/store/models/index.mjs +17 -0
  173. package/esm/production/store/models/invite.migration.mjs +26 -0
  174. package/esm/production/store/models/invite.migration.mjs.map +1 -0
  175. package/esm/production/store/models/invite.model.mjs +13 -0
  176. package/esm/production/store/models/invite.model.mjs.map +1 -0
  177. package/esm/production/store/models/report.migration.mjs +20 -0
  178. package/esm/production/store/models/report.migration.mjs.map +1 -0
  179. package/esm/production/store/models/report.model.mjs +13 -0
  180. package/esm/production/store/models/report.model.mjs.map +1 -0
  181. package/esm/production/store/models/sample.migration.mjs +25 -0
  182. package/esm/production/store/models/sample.migration.mjs.map +1 -0
  183. package/esm/production/store/models/sample.model.mjs +13 -0
  184. package/esm/production/store/models/sample.model.mjs.map +1 -0
  185. package/esm/production/store/models/session.migration.mjs +31 -0
  186. package/esm/production/store/models/session.migration.mjs.map +1 -0
  187. package/esm/production/store/models/session.model.mjs +13 -0
  188. package/esm/production/store/models/session.model.mjs.map +1 -0
  189. package/esm/production/store/models/state.migration.mjs +26 -0
  190. package/esm/production/store/models/state.migration.mjs.map +1 -0
  191. package/esm/production/store/models/state.model.mjs +13 -0
  192. package/esm/production/store/models/state.model.mjs.map +1 -0
  193. package/esm/query-shape.mjs +14 -1
  194. package/esm/query-shape.mjs.map +1 -1
  195. package/esm/server/explain-route.mjs +26 -1
  196. package/esm/server/explain-route.mjs.map +1 -1
  197. package/esm/server/index.mjs +9 -4
  198. package/esm/server/index.mjs.map +1 -1
  199. package/esm/server/insights-routes.mjs +62 -0
  200. package/esm/server/insights-routes.mjs.map +1 -0
  201. package/esm/server/log-routes.mjs +32 -5
  202. package/esm/server/log-routes.mjs.map +1 -1
  203. package/esm/server/openapi-routes.mjs +3 -2
  204. package/esm/server/openapi-routes.mjs.map +1 -1
  205. package/esm/server/requests-routes.mjs +125 -0
  206. package/esm/server/requests-routes.mjs.map +1 -1
  207. package/esm/server/session-routes.mjs +42 -0
  208. package/esm/server/session-routes.mjs.map +1 -0
  209. package/esm/server/stream-route.mjs +81 -11
  210. package/esm/server/stream-route.mjs.map +1 -1
  211. package/esm/server/ui-assets.mjs +34 -25
  212. package/esm/server/ui-assets.mjs.map +1 -1
  213. package/esm/sources/log-source.mjs +14 -1
  214. package/esm/sources/log-source.mjs.map +1 -1
  215. package/esm/types.d.mts +202 -1
  216. package/esm/types.d.mts.map +1 -1
  217. package/esm/ui-root.mjs +9 -4
  218. package/esm/ui-root.mjs.map +1 -1
  219. package/llms-full.txt +159 -21
  220. package/llms.txt +2 -2
  221. package/package.json +32 -8
  222. package/skills/SKILL.md +159 -21
  223. package/ui/dashboard/assets/app.css +3 -0
  224. package/ui/dashboard/assets/app.js +50 -0
  225. package/ui/dashboard/build-info.json +21 -0
  226. package/ui/dashboard/index.html +15 -0
  227. package/cjs/ai-source-Dz_3tlZ5.cjs +0 -703
  228. package/cjs/ai-source-Dz_3tlZ5.cjs.map +0 -1
  229. package/cjs/server-B11ShQYE.cjs +0 -628
  230. package/cjs/server-B11ShQYE.cjs.map +0 -1
  231. package/cjs/src-Xwm3Eel9.cjs.map +0 -1
  232. package/ui/app.css +0 -376
  233. package/ui/app.js +0 -1158
  234. package/ui/index.html +0 -28
@@ -1,703 +0,0 @@
1
- //#region \0rolldown/runtime.js
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __exportAll = (all, no_symbols) => {
9
- let target = {};
10
- for (var name in all) {
11
- __defProp(target, name, {
12
- get: all[name],
13
- enumerable: true
14
- });
15
- }
16
- if (!no_symbols) {
17
- __defProp(target, Symbol.toStringTag, { value: "Module" });
18
- }
19
- return target;
20
- };
21
- var __copyProps = (to, from, except, desc) => {
22
- if (from && typeof from === "object" || typeof from === "function") {
23
- for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
24
- key = keys[i];
25
- if (!__hasOwnProp.call(to, key) && key !== except) {
26
- __defProp(to, key, {
27
- get: ((k) => from[k]).bind(null, key),
28
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
29
- });
30
- }
31
- }
32
- }
33
- return to;
34
- };
35
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, "default") ? __defProp(target, "default", {
36
- value: mod,
37
- enumerable: true
38
- }) : target, mod));
39
-
40
- //#endregion
41
- let node_fs = require("node:fs");
42
- let node_module = require("node:module");
43
- let node_path = require("node:path");
44
- node_path = __toESM(node_path, 1);
45
- let node_url = require("node:url");
46
-
47
- //#region ../../packages/devtools/src/panels.ts
48
- /**
49
- * Ids the dashboard already uses for its own tabs, API segments and URLs. A
50
- * panel's routes live under `<path>/api/<id>`, so these would collide.
51
- */
52
- const RESERVED_PANEL_IDS = /* @__PURE__ */ new Set([
53
- "agents",
54
- "ai",
55
- "api",
56
- "assets",
57
- "background",
58
- "docs",
59
- "logs",
60
- "mail",
61
- "mails",
62
- "panels",
63
- "queries",
64
- "requests",
65
- "routes",
66
- "stream"
67
- ]);
68
- const PANEL_ID = /^[a-z][a-z0-9-]*$/;
69
- const ASSET_NAME = /^[A-Za-z0-9_][A-Za-z0-9._-]*$/;
70
- const METHODS = /* @__PURE__ */ new Set([
71
- "GET",
72
- "POST",
73
- "PUT",
74
- "PATCH",
75
- "DELETE"
76
- ]);
77
- /** Content types for the files a panel may serve; anything else is sent as bytes. */
78
- const CONTENT_TYPES = {
79
- ".js": "text/javascript; charset=utf-8",
80
- ".mjs": "text/javascript; charset=utf-8",
81
- ".css": "text/css; charset=utf-8",
82
- ".json": "application/json; charset=utf-8",
83
- ".svg": "image/svg+xml",
84
- ".png": "image/png",
85
- ".woff2": "font/woff2"
86
- };
87
- /** The content type a panel file is served with, from its served name. */
88
- function panelContentType(name) {
89
- return CONTENT_TYPES[node_path.default.extname(name).toLowerCase()] ?? "application/octet-stream";
90
- }
91
- /** An absolute file path from a path or `file:` URL, or `undefined` for anything else. */
92
- function toFilePath(value) {
93
- if (value instanceof URL) return value.protocol === "file:" ? (0, node_url.fileURLToPath)(value) : void 0;
94
- if (typeof value !== "string" || value === "") return void 0;
95
- if (value.startsWith("file:")) return (0, node_url.fileURLToPath)(value);
96
- return node_path.default.isAbsolute(value) ? value : void 0;
97
- }
98
- function isFile(file) {
99
- return (0, node_fs.existsSync)(file) && (0, node_fs.statSync)(file).isFile();
100
- }
101
- /**
102
- * Validates `value` as a panel and returns it ready to mount. Throws an
103
- * error that names the panel and what to change; `taken` maps the ids
104
- * already registered to their titles and receives this panel's id.
105
- */
106
- function checkDevtoolsPanel(value, taken) {
107
- const panel = value ?? {};
108
- const id = panel.id;
109
- if (typeof id !== "string" || !PANEL_ID.test(id)) throw new Error(`A devtools panel needs an "id" of lower-case letters, digits and dashes that starts with a letter; got ${JSON.stringify(id)}.`);
110
- if (RESERVED_PANEL_IDS.has(id)) throw new Error(`Devtools panel id "${id}" is used by the dashboard itself; give the panel another id.`);
111
- const existing = taken.get(id);
112
- if (existing !== void 0) throw new Error(`Devtools panel id "${id}" is already registered by the "${existing}" panel; each panel needs its own id.`);
113
- if (typeof panel.title !== "string" || panel.title.trim() === "") throw new Error(`Devtools panel "${id}" needs a "title" for its tab.`);
114
- const view = toFilePath(panel.view);
115
- if (view === void 0) throw new Error(`Devtools panel "${id}" needs a "view": an absolute path or file: URL of its browser module.`);
116
- if (!isFile(view)) throw new Error(`The view module of devtools panel "${id}" was not found at ${view}.`);
117
- const seen = /* @__PURE__ */ new Set();
118
- const routes = (panel.routes ?? []).map((route) => {
119
- const method = route.method ?? "GET";
120
- if (!METHODS.has(method)) throw new Error(`Devtools panel "${id}" has a route with method "${String(method)}"; use GET, POST, PUT, PATCH or DELETE.`);
121
- if (typeof route.path !== "string" || route.path !== "" && !route.path.startsWith("/")) throw new Error(`Devtools panel "${id}" has a route path ${JSON.stringify(route.path)}; use "" or a path starting with "/".`);
122
- if (typeof route.handler !== "function") throw new Error(`Devtools panel "${id}" route ${method} "${route.path}" has no handler.`);
123
- if (seen.has(`${method} ${route.path}`)) throw new Error(`Devtools panel "${id}" lists route ${method} "${route.path}" twice; keep one.`);
124
- seen.add(`${method} ${route.path}`);
125
- return {
126
- ...route,
127
- method
128
- };
129
- });
130
- const assets = {};
131
- for (const [name, source] of Object.entries(panel.assets ?? {})) {
132
- if (!ASSET_NAME.test(name) || name === "view.js") throw new Error(`Devtools panel "${id}" has an asset named ${JSON.stringify(name)}; use a plain file name other than "view.js".`);
133
- const file = toFilePath(source);
134
- 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.`);
135
- assets[name] = file;
136
- }
137
- taken.set(id, panel.title);
138
- return {
139
- id,
140
- title: panel.title,
141
- view,
142
- routes,
143
- assets
144
- };
145
- }
146
- /** Validates a list of panels; the first invalid or duplicate one throws. */
147
- function checkDevtoolsPanels(panels) {
148
- const taken = /* @__PURE__ */ new Map();
149
- return panels.map((panel) => checkDevtoolsPanel(panel, taken));
150
- }
151
- /** The URL or specifier to import for a `panels` entry. */
152
- function resolvePanelSpecifier(entry, root) {
153
- if (entry.startsWith("./") || entry.startsWith("../") || node_path.default.isAbsolute(entry)) return (0, node_url.pathToFileURL)(node_path.default.resolve(root, entry)).href;
154
- return resolveFromNodeModules(entry, root) ?? resolveWithRequire(entry, root) ?? entry;
155
- }
156
- /** Picks the file an `exports` target names: `import`, then `default`, then `node`. */
157
- function exportTarget(target) {
158
- if (typeof target === "string") return target;
159
- if (Array.isArray(target)) {
160
- for (const item of target) {
161
- const found = exportTarget(item);
162
- if (found !== void 0) return found;
163
- }
164
- return;
165
- }
166
- if (target !== null && typeof target === "object") {
167
- const conditions = target;
168
- for (const condition of [
169
- "import",
170
- "node",
171
- "default"
172
- ]) {
173
- const found = exportTarget(conditions[condition]);
174
- if (found !== void 0) return found;
175
- }
176
- }
177
- }
178
- /**
179
- * Resolves a package specifier by looking it up in the `node_modules` folders
180
- * above the app root and reading its `exports` map. `createRequire().resolve`
181
- * cannot do this for a package that only has an `import` condition.
182
- */
183
- function resolveFromNodeModules(entry, root) {
184
- const parts = entry.split("/");
185
- const nameLength = entry.startsWith("@") ? 2 : 1;
186
- const name = parts.slice(0, nameLength).join("/");
187
- const subpath = parts.length > nameLength ? `./${parts.slice(nameLength).join("/")}` : ".";
188
- if (!name) return void 0;
189
- let directory = node_path.default.resolve(root);
190
- for (;;) {
191
- const packageDirectory = node_path.default.join(directory, "node_modules", name);
192
- const manifestFile = node_path.default.join(packageDirectory, "package.json");
193
- if ((0, node_fs.existsSync)(manifestFile)) try {
194
- const manifest = JSON.parse((0, node_fs.readFileSync)(manifestFile, "utf8"));
195
- const exported = manifest.exports;
196
- const map = exported !== null && typeof exported === "object" && !Array.isArray(exported) ? exported : void 0;
197
- const hasSubpaths = map !== void 0 && Object.keys(map).some((key) => key.startsWith("."));
198
- const target = exported === void 0 ? subpath === "." ? manifest.main ?? "index.js" : subpath : hasSubpaths ? exportTarget(map?.[subpath]) : subpath === "." ? exportTarget(exported) : void 0;
199
- if (target === void 0) return void 0;
200
- const file = node_path.default.resolve(packageDirectory, target);
201
- return isFile(file) ? (0, node_url.pathToFileURL)(file).href : void 0;
202
- } catch {
203
- return;
204
- }
205
- const parent = node_path.default.dirname(directory);
206
- if (parent === directory) return void 0;
207
- directory = parent;
208
- }
209
- }
210
- /** The `require` resolution, for packages the `node_modules` lookup does not understand. */
211
- function resolveWithRequire(entry, root) {
212
- try {
213
- return (0, node_url.pathToFileURL)((0, node_module.createRequire)(node_path.default.join(root, "package.json")).resolve(entry)).href;
214
- } catch {
215
- return;
216
- }
217
- }
218
- /** The panels a module's default export describes. */
219
- async function panelsOf(exported, root) {
220
- const value = typeof exported === "function" ? await exported({ root }) : exported;
221
- return Array.isArray(value) ? value : [value];
222
- }
223
- /**
224
- * Loads the devtools `panels` option: imports each module entry, reads its
225
- * default export, and validates every panel. An entry that fails to load and
226
- * a panel that is invalid or reuses an id are reported through `warn` and
227
- * skipped, so one broken panel never stops the dashboard.
228
- */
229
- async function loadDevtoolsPanels(entries, options) {
230
- if (!Array.isArray(entries)) {
231
- options.warn(`The devtools "panels" option must be a list, such as panels: ["@warlock.js/grimoire/devtools"]; got ${JSON.stringify(entries)}. No panel was added.`);
232
- return [];
233
- }
234
- const importModule = options.importModule ?? ((specifier) => import(specifier));
235
- const taken = new Map(options.taken ?? []);
236
- const panels = [];
237
- for (const entry of entries) {
238
- let candidates;
239
- try {
240
- if (typeof entry === "string") {
241
- const module = await importModule(resolvePanelSpecifier(entry, options.root));
242
- if (module.default === void 0) throw new Error("the module has no default export");
243
- candidates = await panelsOf(module.default, options.root);
244
- } else candidates = [entry];
245
- } catch (error) {
246
- 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.`);
247
- continue;
248
- }
249
- for (const candidate of candidates) try {
250
- panels.push(checkDevtoolsPanel(candidate, taken));
251
- } catch (error) {
252
- options.warn(`${describe(error)} The panel was not added.`);
253
- }
254
- }
255
- return panels;
256
- }
257
- function describe(error) {
258
- return error instanceof Error ? error.message : String(error);
259
- }
260
-
261
- //#endregion
262
- //#region ../../packages/devtools/src/ui-root.ts
263
- let cachedUiRoot;
264
- /** Whether `dir` is this package's root: it has `ui/index.html` beside a `package.json` named `@warlock.js/devtools`. */
265
- function isPackageRoot(dir) {
266
- const indexHtml = node_path.default.join(dir, "ui", "index.html");
267
- const packageJson = node_path.default.join(dir, "package.json");
268
- if (!(0, node_fs.existsSync)(indexHtml) || !(0, node_fs.existsSync)(packageJson)) return false;
269
- try {
270
- return JSON.parse((0, node_fs.readFileSync)(packageJson, "utf8")).name === "@warlock.js/devtools";
271
- } catch {
272
- return false;
273
- }
274
- }
275
- /**
276
- * Locate this package's `ui/` directory by walking up from the current
277
- * module's directory. Works from `src/` in development and from the built
278
- * `esm/`/`cjs/` output, since both sit beside `ui/` and `package.json` at
279
- * the package root.
280
- */
281
- function resolveUiRoot() {
282
- if (cachedUiRoot) return cachedUiRoot;
283
- let dir = node_path.default.dirname((0, node_url.fileURLToPath)(require("url").pathToFileURL(__filename).href));
284
- while (true) {
285
- if (isPackageRoot(dir)) {
286
- cachedUiRoot = node_path.default.join(dir, "ui");
287
- return cachedUiRoot;
288
- }
289
- const parent = node_path.default.dirname(dir);
290
- if (parent === dir) throw new Error("Could not locate the devtools UI directory: no ancestor of this module has a ui/index.html beside a package.json named @warlock.js/devtools.");
291
- dir = parent;
292
- }
293
- }
294
-
295
- //#endregion
296
- //#region ../../packages/devtools/src/process-panel.ts
297
- /** Load app-owned generated registration only when devtools boots in development. */
298
- async function loadProcessPanel() {
299
- const core = await import("@warlock.js/core");
300
- if (!("srcPath" in core)) return void 0;
301
- const { srcPath } = core;
302
- const { existsSync } = await import("node:fs");
303
- const { pathToFileURL } = await import("node:url");
304
- const file = srcPath("app/processes/devtools.ts");
305
- if (!existsSync(file)) return void 0;
306
- return (await import(pathToFileURL(file).href)).processPanel;
307
- }
308
- /**
309
- * The built-in **Processes** tab, registered like any other panel:
310
- * `GET <path>/api/processes` lists the app's supervised processes (an empty
311
- * list without a registration) and `ui/panels/processes.js` renders them.
312
- */
313
- function processesDevtoolsPanel(processPanel) {
314
- return {
315
- id: "processes",
316
- title: "Processes",
317
- view: node_path.default.join(resolveUiRoot(), "panels", "processes.js"),
318
- routes: [{
319
- path: "",
320
- handler: async () => processPanel ? await processPanel.list() : []
321
- }]
322
- };
323
- }
324
-
325
- //#endregion
326
- //#region ../../packages/devtools/src/sources/agent-trace-source.ts
327
- /**
328
- * Key `@warlock.js/ai` publishes its agent trace store under on
329
- * `globalThis`. Reading the store from the registry, not by importing the
330
- * package, keeps devtools free of an AI dependency and shares one store
331
- * even when two copies of the package are installed.
332
- */
333
- const AGENT_TRACES_KEY = Symbol.for("@warlock.js/ai.agentTraces");
334
- const AGENT_TRACE_INSTALL_GUIDANCE = "No agent traces yet. Install @warlock.js/ai 5.38 or newer and run an agent in development (agents record traces by default there; `trace: true` turns it on elsewhere), then reload.";
335
- /** One list row for a trace. */
336
- function summarizeAgentTrace(trace, requestId) {
337
- let toolCalls = 0;
338
- let refusals = 0;
339
- for (const turn of trace.turns) {
340
- toolCalls += turn.toolCalls.length;
341
- refusals += turn.toolCalls.filter((call) => call.refusal !== void 0).length;
342
- }
343
- return {
344
- runId: trace.runId,
345
- agent: trace.agent,
346
- status: trace.status,
347
- startedAt: trace.startedAt,
348
- durationMs: trace.durationMs,
349
- model: `${trace.model.provider}/${trace.model.name}`,
350
- turns: trace.turns.length,
351
- toolCalls,
352
- refusals,
353
- usage: {
354
- input: trace.usage.input,
355
- output: trace.usage.output
356
- },
357
- cost: trace.cost,
358
- ...requestId ? { requestId } : {}
359
- };
360
- }
361
- const MAX_REQUEST_LINKS = 500;
362
- /**
363
- * Attach to the shared agent trace store. The store is looked up lazily on
364
- * every call, so it works whichever of devtools and `@warlock.js/ai` loads
365
- * first. Runs are linked to the HTTP request that was active when the
366
- * store first reported them.
367
- */
368
- async function attachAgentTraceSource() {
369
- const { currentRequestId } = await Promise.resolve().then(() => require("./src-Xwm3Eel9.cjs")).then((n) => n.current_request_id_exports);
370
- const listeners = /* @__PURE__ */ new Set();
371
- const requestIds = /* @__PURE__ */ new Map();
372
- let attachedStore;
373
- let detach;
374
- const findStore = () => {
375
- const store = globalThis[AGENT_TRACES_KEY];
376
- return store && typeof store.list === "function" ? store : void 0;
377
- };
378
- const ensureAttached = () => {
379
- const store = findStore();
380
- if (store && store !== attachedStore) {
381
- detach?.();
382
- attachedStore = store;
383
- detach = store.subscribe((event) => {
384
- let requestId = requestIds.get(event.runId);
385
- if (!requestId) {
386
- requestId = currentRequestId();
387
- if (requestId) {
388
- requestIds.set(event.runId, requestId);
389
- if (requestIds.size > MAX_REQUEST_LINKS) {
390
- const oldest = requestIds.keys().next();
391
- if (!oldest.done) requestIds.delete(oldest.value);
392
- }
393
- }
394
- }
395
- for (const listener of listeners) try {
396
- listener({
397
- ...event,
398
- ...requestId ? { requestId } : {}
399
- });
400
- } catch {}
401
- });
402
- }
403
- return store;
404
- };
405
- ensureAttached();
406
- return {
407
- available: () => ensureAttached() !== void 0,
408
- list(filter) {
409
- const store = ensureAttached();
410
- if (!store) return [];
411
- return store.list().map((trace) => summarizeAgentTrace(trace, requestIds.get(trace.runId))).filter((run) => filter?.requestId === void 0 || run.requestId === filter.requestId);
412
- },
413
- get: (runId) => ensureAttached()?.get(runId),
414
- subscribe(listener) {
415
- ensureAttached();
416
- listeners.add(listener);
417
- return () => {
418
- listeners.delete(listener);
419
- };
420
- },
421
- dispose() {
422
- detach?.();
423
- detach = void 0;
424
- attachedStore = void 0;
425
- listeners.clear();
426
- requestIds.clear();
427
- }
428
- };
429
- }
430
-
431
- //#endregion
432
- //#region ../../packages/devtools/src/safe-value.ts
433
- const MAX_DEPTH = 6;
434
- /**
435
- * A JSON-safe snapshot of a value devtools keeps for later display.
436
- *
437
- * Log contexts and phase attributes are app data: they can hold live objects
438
- * (a request, its socket) whose graphs are circular and which must not be kept
439
- * alive by the collector anyway. Plain objects and arrays are copied; anything
440
- * with a `toJSON()` is serialized through it; other class instances collapse
441
- * to `[ClassName]`, cycles to `[Circular]`, and nesting past a fixed depth to
442
- * `[Object]` / `[Array]`.
443
- */
444
- function toSafeValue(value) {
445
- return snapshot(value, 0, /* @__PURE__ */ new WeakSet());
446
- }
447
- function snapshot(value, depth, seen) {
448
- if (value === null || value === void 0) return value;
449
- switch (typeof value) {
450
- case "string":
451
- case "number":
452
- case "boolean": return value;
453
- case "bigint": return value.toString();
454
- case "symbol": return value.toString();
455
- case "function": return;
456
- }
457
- const object = value;
458
- if (seen.has(object)) return "[Circular]";
459
- if (value instanceof Date) return Number.isNaN(value.getTime()) ? "Invalid Date" : value.toISOString();
460
- if (value instanceof Error) return {
461
- name: value.name,
462
- message: value.message
463
- };
464
- if (depth >= MAX_DEPTH) return Array.isArray(value) ? "[Array]" : "[Object]";
465
- seen.add(object);
466
- try {
467
- if (Array.isArray(value)) return value.map((item) => snapshot(item, depth + 1, seen));
468
- const prototype = Object.getPrototypeOf(object);
469
- if (prototype !== Object.prototype && prototype !== null) {
470
- const toJSON = object.toJSON;
471
- if (typeof toJSON === "function") try {
472
- return snapshot(toJSON.call(object), depth + 1, seen);
473
- } catch {
474
- return `[${constructorName(object)}]`;
475
- }
476
- return `[${constructorName(object)}]`;
477
- }
478
- const copy = {};
479
- for (const [key, entry] of Object.entries(object)) {
480
- const safe = snapshot(entry, depth + 1, seen);
481
- if (safe !== void 0) copy[key] = safe;
482
- }
483
- return copy;
484
- } finally {
485
- seen.delete(object);
486
- }
487
- }
488
- function constructorName(object) {
489
- return object.constructor?.name || "Object";
490
- }
491
-
492
- //#endregion
493
- //#region ../../packages/devtools/src/sources/ai-source.ts
494
- 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.";
495
- /** Summaries use root usage once: nested spans already roll up into it. */
496
- function summarizeAiTrace(trace, cost) {
497
- const models = /* @__PURE__ */ new Set();
498
- let toolCalls = 0;
499
- let retries = 0;
500
- let cacheHits;
501
- let incomplete = false;
502
- let truncatedTrips = 0;
503
- let compactions = 0;
504
- let skippedCompactions = 0;
505
- let providerCompactions = 0;
506
- const visit = (span) => {
507
- const attributes = span.attributes ?? {};
508
- const model = attributes["agent.model.name"];
509
- const provider = attributes["agent.model.provider"];
510
- if (typeof model === "string") models.add(typeof provider === "string" ? `${provider}/${model}` : model);
511
- if (span.type === "tool") toolCalls += 1;
512
- if (typeof attributes.retries === "number") retries += attributes.retries;
513
- if (typeof attributes["agent.cacheHits"] === "number") cacheHits = (cacheHits ?? 0) + attributes["agent.cacheHits"];
514
- if (typeof attributes["agent.truncatedTrips"] === "number") truncatedTrips += attributes["agent.truncatedTrips"];
515
- if (typeof attributes["agent.providerCompactions"] === "number") providerCompactions += attributes["agent.providerCompactions"];
516
- if (Array.isArray(attributes["agent.compactions"])) {
517
- const records = attributes["agent.compactions"];
518
- for (const record of records) {
519
- if (typeof record !== "object" || record === null || !("type" in record)) continue;
520
- if (record.type === "applied") compactions += 1;
521
- if (record.type === "skipped") skippedCompactions += 1;
522
- }
523
- }
524
- incomplete ||= span.status === "incomplete" || span.error?.type === "AgentIncompleteError" || span.error?.type === "AGENT_INCOMPLETE";
525
- span.children.forEach(visit);
526
- };
527
- visit(trace.root);
528
- return {
529
- traceId: trace.traceId,
530
- requestId: trace.requestId,
531
- sessionId: trace.sessionId,
532
- name: trace.root.name,
533
- status: trace.root.status,
534
- startedAt: trace.startedAt,
535
- duration: trace.duration,
536
- usage: trace.usage,
537
- cost,
538
- models: [...models],
539
- toolCalls,
540
- retries,
541
- cacheHits,
542
- incomplete,
543
- truncatedTrips,
544
- compactions,
545
- skippedCompactions,
546
- providerCompactions
547
- };
548
- }
549
- /** Content-free snapshot; never retain prompts, completions or tool arguments/results. */
550
- function snapshotSpan(span) {
551
- return {
552
- spanId: span.spanId,
553
- parentSpanId: span.parentSpanId,
554
- traceId: span.traceId,
555
- sessionId: span.sessionId,
556
- name: span.name,
557
- version: span.version,
558
- type: span.type,
559
- status: span.status,
560
- startedAt: span.startedAt,
561
- endedAt: span.endedAt,
562
- duration: span.duration,
563
- usage: structuredClone(span.usage),
564
- error: span.error ? {
565
- type: span.error.type,
566
- message: span.error.message
567
- } : void 0,
568
- attributes: toSafeValue(span.attributes),
569
- children: span.children.map(snapshotSpan)
570
- };
571
- }
572
- /**
573
- * Optional, lazy integration. Retains only traces collected after devtools boots,
574
- * using Panoptic's bounded query store; existing exporter/cache stores stay independent.
575
- */
576
- async function attachAiSource(capacity) {
577
- let panoptic;
578
- try {
579
- panoptic = await import("@warlock.js/ai-panoptic");
580
- if (typeof panoptic.subscribeTraces !== "function") throw new Error("Trace subscription unavailable");
581
- } catch {
582
- return {
583
- available: false,
584
- message: AI_INSTALL_GUIDANCE,
585
- dispose() {}
586
- };
587
- }
588
- const { currentRequestId } = await Promise.resolve().then(() => require("./src-Xwm3Eel9.cjs")).then((n) => n.current_request_id_exports);
589
- const store = panoptic.createInMemoryTraceStore({ capacity });
590
- const listeners = /* @__PURE__ */ new Set();
591
- const detach = panoptic.subscribeTraces((trace) => {
592
- const requestId = currentRequestId() ?? trace.requestId;
593
- store.add({
594
- ...trace,
595
- requestId,
596
- usage: structuredClone(trace.usage),
597
- root: snapshotSpan(trace.root)
598
- });
599
- for (const listener of listeners) try {
600
- listener({
601
- traceId: trace.traceId,
602
- requestId
603
- });
604
- } catch {}
605
- });
606
- return {
607
- available: true,
608
- store,
609
- summarize: (trace) => summarizeAiTrace(trace, panoptic.totalCostUsd(trace.usage)),
610
- subscribe(listener) {
611
- listeners.add(listener);
612
- return () => {
613
- listeners.delete(listener);
614
- };
615
- },
616
- dispose() {
617
- detach();
618
- listeners.clear();
619
- store.clear();
620
- }
621
- };
622
- }
623
-
624
- //#endregion
625
- Object.defineProperty(exports, "AGENT_TRACE_INSTALL_GUIDANCE", {
626
- enumerable: true,
627
- get: function () {
628
- return AGENT_TRACE_INSTALL_GUIDANCE;
629
- }
630
- });
631
- Object.defineProperty(exports, "AI_INSTALL_GUIDANCE", {
632
- enumerable: true,
633
- get: function () {
634
- return AI_INSTALL_GUIDANCE;
635
- }
636
- });
637
- Object.defineProperty(exports, "__exportAll", {
638
- enumerable: true,
639
- get: function () {
640
- return __exportAll;
641
- }
642
- });
643
- Object.defineProperty(exports, "__toESM", {
644
- enumerable: true,
645
- get: function () {
646
- return __toESM;
647
- }
648
- });
649
- Object.defineProperty(exports, "attachAgentTraceSource", {
650
- enumerable: true,
651
- get: function () {
652
- return attachAgentTraceSource;
653
- }
654
- });
655
- Object.defineProperty(exports, "attachAiSource", {
656
- enumerable: true,
657
- get: function () {
658
- return attachAiSource;
659
- }
660
- });
661
- Object.defineProperty(exports, "checkDevtoolsPanels", {
662
- enumerable: true,
663
- get: function () {
664
- return checkDevtoolsPanels;
665
- }
666
- });
667
- Object.defineProperty(exports, "loadDevtoolsPanels", {
668
- enumerable: true,
669
- get: function () {
670
- return loadDevtoolsPanels;
671
- }
672
- });
673
- Object.defineProperty(exports, "loadProcessPanel", {
674
- enumerable: true,
675
- get: function () {
676
- return loadProcessPanel;
677
- }
678
- });
679
- Object.defineProperty(exports, "panelContentType", {
680
- enumerable: true,
681
- get: function () {
682
- return panelContentType;
683
- }
684
- });
685
- Object.defineProperty(exports, "processesDevtoolsPanel", {
686
- enumerable: true,
687
- get: function () {
688
- return processesDevtoolsPanel;
689
- }
690
- });
691
- Object.defineProperty(exports, "resolveUiRoot", {
692
- enumerable: true,
693
- get: function () {
694
- return resolveUiRoot;
695
- }
696
- });
697
- Object.defineProperty(exports, "toSafeValue", {
698
- enumerable: true,
699
- get: function () {
700
- return toSafeValue;
701
- }
702
- });
703
- //# sourceMappingURL=ai-source-Dz_3tlZ5.cjs.map