@warlock.js/devtools 5.58.0 → 5.59.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +15 -0
- package/cjs/{ai-source-DTpxumMA.cjs → ai-source-BdvMfyKw.cjs} +84 -17
- package/cjs/ai-source-BdvMfyKw.cjs.map +1 -0
- package/cjs/app-versions-DfpPZOI2.cjs +253 -0
- package/cjs/app-versions-DfpPZOI2.cjs.map +1 -0
- package/cjs/{auth-DV2GA1A9.cjs → auth-B3wyjJnQ.cjs} +20 -13
- package/cjs/auth-B3wyjJnQ.cjs.map +1 -0
- package/cjs/{boot-CyeHPFtk.cjs → boot-nczSvJ_F.cjs} +11 -10
- package/cjs/boot-nczSvJ_F.cjs.map +1 -0
- package/cjs/{capture-DcyBhdqw.cjs → capture-CuyT8Vab.cjs} +4 -4
- package/cjs/{capture-DcyBhdqw.cjs.map → capture-CuyT8Vab.cjs.map} +1 -1
- package/cjs/{cascade-store-DEGxAFDI.cjs → cascade-store-CuRRYzt_.cjs} +3 -3
- package/cjs/cascade-store-CuRRYzt_.cjs.map +1 -0
- package/cjs/{current-request-id-BoJJb3y7.cjs → current-request-id-CeQhRz9Q.cjs} +3 -3
- package/cjs/{current-request-id-BoJJb3y7.cjs.map → current-request-id-CeQhRz9Q.cjs.map} +1 -1
- package/cjs/{errors-DEqdWaqm.cjs → errors-BadbSDX8.cjs} +4 -4
- package/cjs/errors-BadbSDX8.cjs.map +1 -0
- package/cjs/{helpers-7k_Q-abk.cjs → helpers-BcMBFy9v.cjs} +9 -6
- package/cjs/{helpers-7k_Q-abk.cjs.map → helpers-BcMBFy9v.cjs.map} +1 -1
- package/cjs/{histogram-BRV5eHcp.cjs → histogram-DTOGnNBW.cjs} +6 -6
- package/cjs/{histogram-BRV5eHcp.cjs.map → histogram-DTOGnNBW.cjs.map} +1 -1
- package/cjs/{http-XNLYU2vS.cjs → http-Biauhqi0.cjs} +7 -7
- package/cjs/http-Biauhqi0.cjs.map +1 -0
- package/cjs/index.cjs +1 -1
- package/cjs/{insights-BBZnUpWO.cjs → insights-BjJA6Ret.cjs} +6 -6
- package/cjs/{insights-BBZnUpWO.cjs.map → insights-BjJA6Ret.cjs.map} +1 -1
- package/cjs/{migrations-DTTzCNpR.cjs → migrations-BP4cYTGo.cjs} +3 -3
- package/cjs/{migrations-DTTzCNpR.cjs.map → migrations-BP4cYTGo.cjs.map} +1 -1
- package/cjs/{options-CHhmQJic.cjs → options-B9FHbRAJ.cjs} +15 -3
- package/cjs/options-B9FHbRAJ.cjs.map +1 -0
- package/cjs/{panels-CHd20RK5.cjs → panels-D1ITm-jc.cjs} +5 -6
- package/cjs/{panels-CHd20RK5.cjs.map → panels-D1ITm-jc.cjs.map} +1 -1
- package/cjs/{process-panel-DEOnLxoT.cjs → process-panel-DskSA7Cm.cjs} +4 -4
- package/cjs/{process-panel-DEOnLxoT.cjs.map → process-panel-DskSA7Cm.cjs.map} +1 -1
- package/cjs/production/index.cjs +4 -4
- package/cjs/{server-C8JfggQU.cjs → server-D3XRbSSb.cjs} +7 -5
- package/cjs/server-D3XRbSSb.cjs.map +1 -0
- package/cjs/{src-DjOUdhKc.cjs → src-QcNghoYN.cjs} +12 -12
- package/cjs/{src-DjOUdhKc.cjs.map → src-QcNghoYN.cjs.map} +1 -1
- package/cjs/{store-C06KO_A1.cjs → store-CNFv3wVp.cjs} +2 -2
- package/cjs/{stream-route-D4k-sJvW.cjs → stream-route-BqyAlfxQ.cjs} +25 -11
- package/cjs/stream-route-BqyAlfxQ.cjs.map +1 -0
- package/esm/app-versions.mjs +74 -0
- package/esm/app-versions.mjs.map +1 -0
- package/esm/production/auth/helpers.mjs +8 -5
- package/esm/production/auth/helpers.mjs.map +1 -1
- package/esm/production/auth/service.mjs +14 -6
- package/esm/production/auth/service.mjs.map +1 -1
- package/esm/production/boot.mjs +1 -0
- package/esm/production/boot.mjs.map +1 -1
- package/esm/production/contracts.d.mts +7 -0
- package/esm/production/contracts.d.mts.map +1 -1
- package/esm/production/contracts.mjs.map +1 -1
- package/esm/production/errors.d.mts +1 -1
- package/esm/production/errors.mjs +3 -3
- package/esm/production/errors.mjs.map +1 -1
- package/esm/production/http/share-session.mjs.map +1 -1
- package/esm/production/insights/writer.mjs.map +1 -1
- package/esm/production/options.d.mts +5 -1
- package/esm/production/options.d.mts.map +1 -1
- package/esm/production/options.mjs +13 -1
- package/esm/production/options.mjs.map +1 -1
- package/esm/production/store/memory-store.mjs.map +1 -1
- package/esm/server/ai-routes.mjs +20 -6
- package/esm/server/ai-routes.mjs.map +1 -1
- package/esm/server/session-routes.mjs +3 -1
- package/esm/server/session-routes.mjs.map +1 -1
- package/esm/sources/ai-source.d.mts.map +1 -1
- package/esm/sources/ai-source.mjs +75 -7
- package/esm/sources/ai-source.mjs.map +1 -1
- package/esm/types.d.mts +10 -1
- package/esm/types.d.mts.map +1 -1
- package/llms-full.txt +25 -17
- package/package.json +8 -8
- package/skills/SKILL.md +25 -17
- package/ui/dashboard/assets/app.css +1 -1
- package/ui/dashboard/assets/app.js +16 -16
- package/ui/dashboard/build-info.json +7 -7
- package/cjs/ai-source-DTpxumMA.cjs.map +0 -1
- package/cjs/auth-DV2GA1A9.cjs.map +0 -1
- package/cjs/boot-CyeHPFtk.cjs.map +0 -1
- package/cjs/cascade-store-DEGxAFDI.cjs.map +0 -1
- package/cjs/contracts-CDuY-ahl.cjs +0 -116
- package/cjs/contracts-CDuY-ahl.cjs.map +0 -1
- package/cjs/errors-DEqdWaqm.cjs.map +0 -1
- package/cjs/http-XNLYU2vS.cjs.map +0 -1
- package/cjs/options-CHhmQJic.cjs.map +0 -1
- package/cjs/rolldown-runtime-Zuuoy_Rh.cjs +0 -52
- package/cjs/server-C8JfggQU.cjs.map +0 -1
- package/cjs/stream-route-D4k-sJvW.cjs.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,21 @@ All notable changes to `@warlock.js/devtools` are documented in this file.
|
|
|
4
4
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/). `@warlock.js/*` packages are released in lockstep — every package shares the same version number, so a version below may list only the changes that affected this package.
|
|
6
6
|
|
|
7
|
+
## 5.59.0 - 2026-11-19
|
|
8
|
+
|
|
9
|
+
### Added
|
|
10
|
+
|
|
11
|
+
- The dashboard uses the Warlock gold palette and logo, in the light and the dark theme, and shows the Warlock.js version in the sidebar header and the app's name and version in its footer. `DevtoolsSessionView` gains `warlockVersion` and `app`; both are `null` when signed out or not found, and only the app's own `package.json` name and version are read.
|
|
12
|
+
- Production option `twoFactor: "off"` requires no second factor (an account that has one is still asked for it); boot logs a warning when it is off.
|
|
13
|
+
- Production option `passwords: { minLength, rejectCommon }` sets the password rules for accounts, invites and the first admin (`minLength` is 8 or more, `rejectCommon` defaults to `true`).
|
|
14
|
+
- The AI tab tells which of four reasons it is empty: `@warlock.js/ai` is missing, `@warlock.js/ai-panoptic` is missing, Panoptic failed to load (with the load error and both versions), or observation is off. Each shows a title, one line and the command to run.
|
|
15
|
+
- A reconnect banner shows while the app is unreachable and panels refetch when it returns.
|
|
16
|
+
|
|
17
|
+
### Changed
|
|
18
|
+
|
|
19
|
+
- The `/ai` answer carries `reason`, `title`, `command` and `detail` when unavailable; `message` stays.
|
|
20
|
+
- A too-short password answers with the configured minimum length.
|
|
21
|
+
|
|
7
22
|
## 5.58.0 - 2026-11-18
|
|
8
23
|
|
|
9
24
|
### Added
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
const
|
|
1
|
+
const require_app_versions = require("./app-versions-DfpPZOI2.cjs");
|
|
2
2
|
let node_fs = require("node:fs");
|
|
3
3
|
let node_path = require("node:path");
|
|
4
|
-
node_path =
|
|
4
|
+
node_path = require_app_versions.__toESM(node_path, 1);
|
|
5
5
|
let node_url = require("node:url");
|
|
6
6
|
|
|
7
7
|
//#region ../../packages/devtools/src/ui-root.ts
|
|
@@ -86,7 +86,7 @@ const MAX_REQUEST_LINKS = 500;
|
|
|
86
86
|
* store first reported them.
|
|
87
87
|
*/
|
|
88
88
|
async function attachAgentTraceSource() {
|
|
89
|
-
const { currentRequestId } = await Promise.resolve().then(() => require("./current-request-id-
|
|
89
|
+
const { currentRequestId } = await Promise.resolve().then(() => require("./current-request-id-CeQhRz9Q.cjs")).then((n) => n.current_request_id_exports);
|
|
90
90
|
const listeners = /* @__PURE__ */ new Set();
|
|
91
91
|
const requestIds = /* @__PURE__ */ new Map();
|
|
92
92
|
let attachedStore;
|
|
@@ -211,7 +211,54 @@ function constructorName(object) {
|
|
|
211
211
|
|
|
212
212
|
//#endregion
|
|
213
213
|
//#region ../../packages/devtools/src/sources/ai-source.ts
|
|
214
|
-
|
|
214
|
+
/** Replaces absolute file paths in an error line with their package-relative part, or `<path>`. */
|
|
215
|
+
function redactPaths(text) {
|
|
216
|
+
return text.replace(/(?:file:\/\/)?(?:[A-Za-z]:)?[\\/][^\s'"`()]*/g, (match) => {
|
|
217
|
+
const normalized = match.replace(/^file:\/\//, "").replaceAll("\\", "/");
|
|
218
|
+
const index = normalized.lastIndexOf("node_modules/");
|
|
219
|
+
return index === -1 ? "<path>" : normalized.slice(index + 13);
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
const OBSERVATION_COMMAND = "ai.config({ panoptic: { observeAll: true } })";
|
|
223
|
+
/** The answer for each reason; `detail` carries the load error and versions for `panoptic-failed`. */
|
|
224
|
+
function describeAiUnavailable(reason, detail) {
|
|
225
|
+
switch (reason) {
|
|
226
|
+
case "ai-missing": return {
|
|
227
|
+
available: false,
|
|
228
|
+
reason,
|
|
229
|
+
title: "AI isn't installed",
|
|
230
|
+
message: "Add @warlock.js/ai to see AI runs here.",
|
|
231
|
+
command: "warlock add ai"
|
|
232
|
+
};
|
|
233
|
+
case "panoptic-missing": return {
|
|
234
|
+
available: false,
|
|
235
|
+
reason,
|
|
236
|
+
title: "Panoptic isn't installed",
|
|
237
|
+
message: "Your app uses @warlock.js/ai. Add Panoptic to see its runs.",
|
|
238
|
+
command: "warlock add ai-panoptic"
|
|
239
|
+
};
|
|
240
|
+
case "panoptic-failed": return {
|
|
241
|
+
available: false,
|
|
242
|
+
reason,
|
|
243
|
+
title: "Panoptic could not be loaded",
|
|
244
|
+
message: "Panoptic is installed but failed to load. Check that both packages share a version.",
|
|
245
|
+
detail
|
|
246
|
+
};
|
|
247
|
+
case "not-collected": return {
|
|
248
|
+
available: false,
|
|
249
|
+
reason,
|
|
250
|
+
title: "AI runs are not collected here",
|
|
251
|
+
message: "The production dashboard does not collect AI runs. Open the AI tab in development (warlock dev) to see them."
|
|
252
|
+
};
|
|
253
|
+
case "observation-off": return {
|
|
254
|
+
available: false,
|
|
255
|
+
reason,
|
|
256
|
+
title: "AI observation is off",
|
|
257
|
+
message: "Turn it on in src/config/ai.ts, then restart warlock dev.",
|
|
258
|
+
command: OBSERVATION_COMMAND
|
|
259
|
+
};
|
|
260
|
+
}
|
|
261
|
+
}
|
|
215
262
|
/** Summaries use root usage once: nested spans already roll up into it. */
|
|
216
263
|
function summarizeAiTrace(trace, cost) {
|
|
217
264
|
const models = /* @__PURE__ */ new Set();
|
|
@@ -293,19 +340,38 @@ function snapshotSpan(span) {
|
|
|
293
340
|
* Optional, lazy integration. Retains only traces collected after devtools boots,
|
|
294
341
|
* using Panoptic's bounded query store; existing exporter/cache stores stay independent.
|
|
295
342
|
*/
|
|
296
|
-
async function attachAiSource(capacity) {
|
|
343
|
+
async function attachAiSource(capacity, deps = {}) {
|
|
344
|
+
const aiPackage = "@warlock.js/ai";
|
|
345
|
+
const load = deps.load ?? ((name) => name === "@warlock.js/ai-panoptic" ? import("@warlock.js/ai-panoptic") : import(aiPackage));
|
|
346
|
+
const version = deps.version ?? ((name) => require_app_versions.installedVersion(name, process.cwd(), {}.resolve));
|
|
297
347
|
let panoptic;
|
|
298
348
|
try {
|
|
299
|
-
panoptic = await
|
|
349
|
+
panoptic = await load("@warlock.js/ai-panoptic");
|
|
300
350
|
if (typeof panoptic.subscribeTraces !== "function") throw new Error("Trace subscription unavailable");
|
|
301
|
-
} catch {
|
|
351
|
+
} catch (error) {
|
|
352
|
+
const aiVersion = version("@warlock.js/ai");
|
|
353
|
+
const panopticVersion = version("@warlock.js/ai-panoptic");
|
|
354
|
+
if (aiVersion === null) return {
|
|
355
|
+
...describeAiUnavailable("ai-missing"),
|
|
356
|
+
dispose() {}
|
|
357
|
+
};
|
|
358
|
+
if (panopticVersion === null) return {
|
|
359
|
+
...describeAiUnavailable("panoptic-missing"),
|
|
360
|
+
dispose() {}
|
|
361
|
+
};
|
|
302
362
|
return {
|
|
303
|
-
|
|
304
|
-
message: AI_INSTALL_GUIDANCE,
|
|
363
|
+
...describeAiUnavailable("panoptic-failed", `${redactPaths((error instanceof Error ? error.message : String(error)).split("\n")[0] ?? "").slice(0, 300)} (@warlock.js/ai ${aiVersion}, @warlock.js/ai-panoptic ${panopticVersion})`),
|
|
305
364
|
dispose() {}
|
|
306
365
|
};
|
|
307
366
|
}
|
|
308
|
-
|
|
367
|
+
let core;
|
|
368
|
+
try {
|
|
369
|
+
core = await load("@warlock.js/ai");
|
|
370
|
+
} catch {
|
|
371
|
+
core = void 0;
|
|
372
|
+
}
|
|
373
|
+
const observationOff = () => typeof core?.isObserveAll === "function" && typeof core.getObservers === "function" && !core.isObserveAll() && core.getObservers().length === 0;
|
|
374
|
+
const { currentRequestId } = await Promise.resolve().then(() => require("./current-request-id-CeQhRz9Q.cjs")).then((n) => n.current_request_id_exports);
|
|
309
375
|
const store = panoptic.createInMemoryTraceStore({ capacity });
|
|
310
376
|
const listeners = /* @__PURE__ */ new Set();
|
|
311
377
|
const detach = panoptic.subscribeTraces((trace) => {
|
|
@@ -325,6 +391,7 @@ async function attachAiSource(capacity) {
|
|
|
325
391
|
});
|
|
326
392
|
return {
|
|
327
393
|
available: true,
|
|
394
|
+
observationOff,
|
|
328
395
|
store,
|
|
329
396
|
summarize: (trace) => summarizeAiTrace(trace, panoptic.totalCostUsd(trace.usage)),
|
|
330
397
|
subscribe(listener) {
|
|
@@ -348,12 +415,6 @@ Object.defineProperty(exports, "AGENT_TRACE_INSTALL_GUIDANCE", {
|
|
|
348
415
|
return AGENT_TRACE_INSTALL_GUIDANCE;
|
|
349
416
|
}
|
|
350
417
|
});
|
|
351
|
-
Object.defineProperty(exports, "AI_INSTALL_GUIDANCE", {
|
|
352
|
-
enumerable: true,
|
|
353
|
-
get: function () {
|
|
354
|
-
return AI_INSTALL_GUIDANCE;
|
|
355
|
-
}
|
|
356
|
-
});
|
|
357
418
|
Object.defineProperty(exports, "attachAgentTraceSource", {
|
|
358
419
|
enumerable: true,
|
|
359
420
|
get: function () {
|
|
@@ -366,6 +427,12 @@ Object.defineProperty(exports, "attachAiSource", {
|
|
|
366
427
|
return attachAiSource;
|
|
367
428
|
}
|
|
368
429
|
});
|
|
430
|
+
Object.defineProperty(exports, "describeAiUnavailable", {
|
|
431
|
+
enumerable: true,
|
|
432
|
+
get: function () {
|
|
433
|
+
return describeAiUnavailable;
|
|
434
|
+
}
|
|
435
|
+
});
|
|
369
436
|
Object.defineProperty(exports, "resolveUiRoot", {
|
|
370
437
|
enumerable: true,
|
|
371
438
|
get: function () {
|
|
@@ -378,4 +445,4 @@ Object.defineProperty(exports, "toSafeValue", {
|
|
|
378
445
|
return toSafeValue;
|
|
379
446
|
}
|
|
380
447
|
});
|
|
381
|
-
//# sourceMappingURL=ai-source-
|
|
448
|
+
//# sourceMappingURL=ai-source-BdvMfyKw.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ai-source-BdvMfyKw.cjs","names":["existsSync","path","readFileSync","fileURLToPath","installedVersion"],"sources":["../../../../../../../packages/devtools/src/ui-root.ts","../../../../../../../packages/devtools/src/sources/agent-trace-source.ts","../../../../../../../packages/devtools/src/safe-value.ts","../../../../../../../packages/devtools/src/sources/ai-source.ts"],"sourcesContent":["import { existsSync, readFileSync } from \"node:fs\";\nimport path from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\n\nlet cachedUiRoot: string | undefined;\n\n/**\n * Whether `dir` is this package's root: it has the built dashboard\n * (`ui/dashboard/index.html`) or, before the first build, the Processes panel\n * view (`ui/panels/processes.js`), beside a `package.json` named\n * `@warlock.js/devtools`.\n */\nfunction isPackageRoot(dir: string): boolean {\n const hasUi =\n existsSync(path.join(dir, \"ui\", \"dashboard\", \"index.html\")) ||\n existsSync(path.join(dir, \"ui\", \"panels\", \"processes.js\"));\n const packageJson = path.join(dir, \"package.json\");\n\n if (!hasUi || !existsSync(packageJson)) {\n return false;\n }\n\n try {\n const parsed = JSON.parse(readFileSync(packageJson, \"utf8\")) as { name?: string };\n return parsed.name === \"@warlock.js/devtools\";\n } catch {\n return false;\n }\n}\n\n/**\n * Locate this package's `ui/` directory by walking up from the current\n * module's directory. Works from `src/` in development and from the built\n * `esm/`/`cjs/` output, since both sit beside `ui/` and `package.json` at\n * the package root.\n */\nexport function resolveUiRoot(): string {\n if (cachedUiRoot) {\n return cachedUiRoot;\n }\n\n let dir = path.dirname(fileURLToPath(import.meta.url));\n\n while (true) {\n if (isPackageRoot(dir)) {\n cachedUiRoot = path.join(dir, \"ui\");\n return cachedUiRoot;\n }\n\n const parent = path.dirname(dir);\n if (parent === dir) {\n throw new Error(\n \"Could not locate the devtools UI directory: no ancestor of \" +\n \"this module has ui/dashboard/index.html or ui/panels/processes.js beside a package.json named \" +\n \"@warlock.js/devtools.\",\n );\n }\n\n dir = parent;\n }\n}\n","import type { DevtoolsDisposer } from \"../types\";\n\n/**\n * Key `@warlock.js/ai` publishes its agent trace store under on\n * `globalThis`. Reading the store from the registry, not by importing the\n * package, keeps devtools free of an AI dependency and shares one store\n * even when two copies of the package are installed.\n */\nexport const AGENT_TRACES_KEY = Symbol.for(\"@warlock.js/ai.agentTraces\");\n\nexport const AGENT_TRACE_INSTALL_GUIDANCE =\n \"No agent traces yet. Install @warlock.js/ai 5.38 or newer and run an agent in development (agents record traces by default there; `trace: true` turns it on elsewhere), then reload.\";\n\n/** The part of `@warlock.js/ai`'s `AgentTrace` this panel reads; the rest passes through untouched. */\nexport type DevtoolsAgentTrace = {\n runId: string;\n agent: string;\n status: string;\n startedAt: string;\n durationMs?: number;\n model: { name: string; provider: string };\n usage: { input: number; output: number; total: number };\n cost?: number;\n turns: Array<{ toolCalls: Array<{ refusal?: string }> }>;\n};\n\n/** The part of `@warlock.js/ai`'s `AgentTraceStore` devtools uses. */\nexport type DevtoolsAgentTraceStore = {\n get(runId: string): DevtoolsAgentTrace | undefined;\n list(filter?: { limit?: number }): DevtoolsAgentTrace[];\n subscribe(listener: (event: { runId: string; status: string }) => void): () => void;\n};\n\nexport type DevtoolsAgentTraceEvent = { runId: string; status: string; requestId?: string };\n\n/** One row of the run list. */\nexport type DevtoolsAgentRun = {\n runId: string;\n agent: string;\n status: string;\n startedAt: string;\n durationMs?: number;\n model: string;\n turns: number;\n toolCalls: number;\n refusals: number;\n usage: { input: number; output: number };\n cost?: number;\n requestId?: string;\n};\n\n/** Reads agent traces from the shared store; the connector builds one in development only. */\nexport type DevtoolsAgentTraceSource = {\n /** `false` until `@warlock.js/ai` has created its store in this process. */\n available(): boolean;\n list(filter?: { requestId?: string }): DevtoolsAgentRun[];\n get(runId: string): DevtoolsAgentTrace | undefined;\n subscribe(listener: (event: DevtoolsAgentTraceEvent) => void): DevtoolsDisposer;\n dispose: DevtoolsDisposer;\n};\n\n/** One list row for a trace. */\nexport function summarizeAgentTrace(\n trace: DevtoolsAgentTrace,\n requestId?: string,\n): DevtoolsAgentRun {\n let toolCalls = 0;\n let refusals = 0;\n\n for (const turn of trace.turns) {\n toolCalls += turn.toolCalls.length;\n refusals += turn.toolCalls.filter((call) => call.refusal !== undefined).length;\n }\n\n return {\n runId: trace.runId,\n agent: trace.agent,\n status: trace.status,\n startedAt: trace.startedAt,\n durationMs: trace.durationMs,\n model: `${trace.model.provider}/${trace.model.name}`,\n turns: trace.turns.length,\n toolCalls,\n refusals,\n usage: { input: trace.usage.input, output: trace.usage.output },\n cost: trace.cost,\n ...(requestId ? { requestId } : {}),\n };\n}\n\nconst MAX_REQUEST_LINKS = 500;\n\n/**\n * Attach to the shared agent trace store. The store is looked up lazily on\n * every call, so it works whichever of devtools and `@warlock.js/ai` loads\n * first. Runs are linked to the HTTP request that was active when the\n * store first reported them.\n */\nexport async function attachAgentTraceSource(): Promise<DevtoolsAgentTraceSource> {\n const { currentRequestId } = await import(\"../current-request-id\");\n const listeners = new Set<(event: DevtoolsAgentTraceEvent) => void>();\n const requestIds = new Map<string, string>();\n let attachedStore: DevtoolsAgentTraceStore | undefined;\n let detach: (() => void) | undefined;\n\n const findStore = (): DevtoolsAgentTraceStore | undefined => {\n const store = (globalThis as { [AGENT_TRACES_KEY]?: DevtoolsAgentTraceStore })[\n AGENT_TRACES_KEY\n ];\n\n return store && typeof store.list === \"function\" ? store : undefined;\n };\n\n const ensureAttached = (): DevtoolsAgentTraceStore | undefined => {\n const store = findStore();\n\n if (store && store !== attachedStore) {\n detach?.();\n attachedStore = store;\n detach = store.subscribe((event) => {\n // Read the request id before anything asynchronous: the store\n // publishes synchronously from inside the agent run.\n let requestId = requestIds.get(event.runId);\n\n if (!requestId) {\n requestId = currentRequestId();\n\n if (requestId) {\n requestIds.set(event.runId, requestId);\n\n if (requestIds.size > MAX_REQUEST_LINKS) {\n const oldest = requestIds.keys().next();\n\n if (!oldest.done) requestIds.delete(oldest.value);\n }\n }\n }\n\n for (const listener of listeners) {\n try {\n listener({ ...event, ...(requestId ? { requestId } : {}) });\n } catch {\n /* isolate clients */\n }\n }\n });\n }\n\n return store;\n };\n\n ensureAttached();\n\n return {\n available: () => ensureAttached() !== undefined,\n\n list(filter) {\n const store = ensureAttached();\n\n if (!store) return [];\n\n return store\n .list()\n .map((trace) => summarizeAgentTrace(trace, requestIds.get(trace.runId)))\n .filter((run) => filter?.requestId === undefined || run.requestId === filter.requestId);\n },\n\n get: (runId) => ensureAttached()?.get(runId),\n\n subscribe(listener) {\n ensureAttached();\n listeners.add(listener);\n\n return () => {\n listeners.delete(listener);\n };\n },\n\n dispose() {\n detach?.();\n detach = undefined;\n attachedStore = undefined;\n listeners.clear();\n requestIds.clear();\n },\n };\n}\n","const MAX_DEPTH = 6;\n\n/**\n * A JSON-safe snapshot of a value devtools keeps for later display.\n *\n * Log contexts and phase attributes are app data: they can hold live objects\n * (a request, its socket) whose graphs are circular and which must not be kept\n * alive by the collector anyway. Plain objects and arrays are copied; anything\n * with a `toJSON()` is serialized through it; other class instances collapse\n * to `[ClassName]`, cycles to `[Circular]`, and nesting past a fixed depth to\n * `[Object]` / `[Array]`.\n */\nexport function toSafeValue(value: unknown): unknown {\n return snapshot(value, 0, new WeakSet());\n}\n\nfunction snapshot(value: unknown, depth: number, seen: WeakSet<object>): unknown {\n if (value === null || value === undefined) return value;\n\n switch (typeof value) {\n case \"string\":\n case \"number\":\n case \"boolean\":\n return value;\n case \"bigint\":\n return value.toString();\n case \"symbol\":\n return value.toString();\n case \"function\":\n return undefined;\n }\n\n const object = value as object;\n\n if (seen.has(object)) return \"[Circular]\";\n if (value instanceof Date)\n return Number.isNaN(value.getTime()) ? \"Invalid Date\" : value.toISOString();\n if (value instanceof Error) return { name: value.name, message: value.message };\n\n if (depth >= MAX_DEPTH) return Array.isArray(value) ? \"[Array]\" : \"[Object]\";\n\n seen.add(object);\n\n try {\n if (Array.isArray(value)) return value.map((item) => snapshot(item, depth + 1, seen));\n\n const prototype = Object.getPrototypeOf(object);\n\n if (prototype !== Object.prototype && prototype !== null) {\n const toJSON = (object as { toJSON?: unknown }).toJSON;\n\n if (typeof toJSON === \"function\") {\n try {\n return snapshot(toJSON.call(object), depth + 1, seen);\n } catch {\n return `[${constructorName(object)}]`;\n }\n }\n\n return `[${constructorName(object)}]`;\n }\n\n const copy: Record<string, unknown> = {};\n\n for (const [key, entry] of Object.entries(object)) {\n const safe = snapshot(entry, depth + 1, seen);\n if (safe !== undefined) copy[key] = safe;\n }\n\n return copy;\n } finally {\n seen.delete(object);\n }\n}\n\nfunction constructorName(object: object): string {\n return (object as { constructor?: { name?: string } }).constructor?.name || \"Object\";\n}\n","import type { Trace, TraceSpan, TraceStoreContract } from \"@warlock.js/ai-panoptic\";\nimport { installedVersion } from \"../app-versions\";\nimport { toSafeValue } from \"../safe-value\";\nimport type { DevtoolsDisposer } from \"../types\";\n\nexport type DevtoolsAiUnavailableReason =\n | \"ai-missing\"\n | \"panoptic-missing\"\n | \"panoptic-failed\"\n | \"observation-off\"\n | \"not-collected\";\n\n/** Why the AI tab is empty, as sent to the dashboard: a title, one line and an optional command. */\nexport type DevtoolsAiUnavailable = {\n available: false;\n reason: DevtoolsAiUnavailableReason;\n title: string;\n message: string;\n command?: string;\n detail?: string;\n};\n\n/** Replaces absolute file paths in an error line with their package-relative part, or `<path>`. */\nexport function redactPaths(text: string): string {\n return text.replace(/(?:file:\\/\\/)?(?:[A-Za-z]:)?[\\\\/][^\\s'\"`()]*/g, (match) => {\n const normalized = match.replace(/^file:\\/\\//, \"\").replaceAll(\"\\\\\", \"/\");\n const index = normalized.lastIndexOf(\"node_modules/\");\n\n return index === -1 ? \"<path>\" : normalized.slice(index + \"node_modules/\".length);\n });\n}\n\nconst OBSERVATION_COMMAND = \"ai.config({ panoptic: { observeAll: true } })\";\n\n/** The answer for each reason; `detail` carries the load error and versions for `panoptic-failed`. */\nexport function describeAiUnavailable(\n reason: DevtoolsAiUnavailableReason,\n detail?: string,\n): DevtoolsAiUnavailable {\n switch (reason) {\n case \"ai-missing\":\n return {\n available: false,\n reason,\n title: \"AI isn't installed\",\n message: \"Add @warlock.js/ai to see AI runs here.\",\n command: \"warlock add ai\",\n };\n case \"panoptic-missing\":\n return {\n available: false,\n reason,\n title: \"Panoptic isn't installed\",\n message: \"Your app uses @warlock.js/ai. Add Panoptic to see its runs.\",\n command: \"warlock add ai-panoptic\",\n };\n case \"panoptic-failed\":\n return {\n available: false,\n reason,\n title: \"Panoptic could not be loaded\",\n message:\n \"Panoptic is installed but failed to load. Check that both packages share a version.\",\n detail,\n };\n case \"not-collected\":\n return {\n available: false,\n reason,\n title: \"AI runs are not collected here\",\n message:\n \"The production dashboard does not collect AI runs. Open the AI tab in development (warlock dev) to see them.\",\n };\n case \"observation-off\":\n return {\n available: false,\n reason,\n title: \"AI observation is off\",\n message: \"Turn it on in src/config/ai.ts, then restart warlock dev.\",\n command: OBSERVATION_COMMAND,\n };\n }\n}\n\n/** Test seam: how packages are loaded and their versions read. */\nexport type AiSourceDeps = {\n load?: (name: string) => Promise<unknown>;\n version?: (name: string) => string | null;\n};\n\nexport type DevtoolsAiEvent = { traceId: string; requestId?: string };\n\n/** Only the connector's development branch constructs this source. */\nexport type DevtoolsAiSource =\n | (DevtoolsAiUnavailable & { dispose: DevtoolsDisposer })\n | {\n available: true;\n /** True when `@warlock.js/ai` has no `observeAll` and no registered observer (read per request). */\n observationOff?: () => boolean;\n store: TraceStoreContract;\n summarize: (trace: Trace) => DevtoolsAiRun;\n subscribe: (listener: (event: DevtoolsAiEvent) => void) => DevtoolsDisposer;\n dispose: DevtoolsDisposer;\n };\n\nexport type DevtoolsAiRun = {\n traceId: string;\n requestId?: string;\n sessionId?: string;\n name: string;\n status: TraceSpan[\"status\"];\n startedAt: string;\n duration: number;\n usage: Trace[\"usage\"];\n cost?: number;\n models: string[];\n toolCalls: number;\n retries: number;\n cacheHits?: number;\n incomplete: boolean;\n truncatedTrips: number;\n compactions: number;\n skippedCompactions: number;\n providerCompactions: number;\n};\n\n/** Summaries use root usage once: nested spans already roll up into it. */\nexport function summarizeAiTrace(trace: Trace, cost?: number): DevtoolsAiRun {\n const models = new Set<string>();\n let toolCalls = 0;\n let retries = 0;\n let cacheHits: number | undefined;\n let incomplete = false;\n let truncatedTrips = 0;\n let compactions = 0;\n let skippedCompactions = 0;\n let providerCompactions = 0;\n const visit = (span: TraceSpan): void => {\n const attributes = span.attributes ?? {};\n const model = attributes[\"agent.model.name\"];\n const provider = attributes[\"agent.model.provider\"];\n if (typeof model === \"string\")\n models.add(typeof provider === \"string\" ? `${provider}/${model}` : model);\n if (span.type === \"tool\") toolCalls += 1;\n if (typeof attributes.retries === \"number\") retries += attributes.retries;\n if (typeof attributes[\"agent.cacheHits\"] === \"number\")\n cacheHits = (cacheHits ?? 0) + attributes[\"agent.cacheHits\"];\n if (typeof attributes[\"agent.truncatedTrips\"] === \"number\")\n truncatedTrips += attributes[\"agent.truncatedTrips\"];\n if (typeof attributes[\"agent.providerCompactions\"] === \"number\")\n providerCompactions += attributes[\"agent.providerCompactions\"];\n if (Array.isArray(attributes[\"agent.compactions\"])) {\n const records: unknown[] = attributes[\"agent.compactions\"];\n for (const record of records) {\n if (typeof record !== \"object\" || record === null || !(\"type\" in record)) continue;\n if (record.type === \"applied\") compactions += 1;\n if (record.type === \"skipped\") skippedCompactions += 1;\n }\n }\n incomplete ||=\n span.status === \"incomplete\" ||\n span.error?.type === \"AgentIncompleteError\" ||\n span.error?.type === \"AGENT_INCOMPLETE\";\n span.children.forEach(visit);\n };\n visit(trace.root);\n return {\n traceId: trace.traceId,\n requestId: trace.requestId,\n sessionId: trace.sessionId,\n name: trace.root.name,\n status: trace.root.status,\n startedAt: trace.startedAt,\n duration: trace.duration,\n usage: trace.usage,\n cost,\n models: [...models],\n toolCalls,\n retries,\n cacheHits,\n incomplete,\n truncatedTrips,\n compactions,\n skippedCompactions,\n providerCompactions,\n };\n}\n\n/** Content-free snapshot; never retain prompts, completions or tool arguments/results. */\nfunction snapshotSpan(span: TraceSpan): TraceSpan {\n return {\n spanId: span.spanId,\n parentSpanId: span.parentSpanId,\n traceId: span.traceId,\n sessionId: span.sessionId,\n name: span.name,\n version: span.version,\n type: span.type,\n status: span.status,\n startedAt: span.startedAt,\n endedAt: span.endedAt,\n duration: span.duration,\n usage: structuredClone(span.usage),\n error: span.error ? { type: span.error.type, message: span.error.message } : undefined,\n attributes: toSafeValue(span.attributes) as Record<string, unknown> | undefined,\n children: span.children.map(snapshotSpan),\n };\n}\n\n/**\n * Optional, lazy integration. Retains only traces collected after devtools boots,\n * using Panoptic's bounded query store; existing exporter/cache stores stay independent.\n */\nexport async function attachAiSource(\n capacity: number,\n deps: AiSourceDeps = {},\n): Promise<DevtoolsAiSource> {\n const aiPackage: string = \"@warlock.js/ai\"; // not a dependency of devtools: never resolved at build time\n const load =\n deps.load ??\n ((name: string) =>\n name === \"@warlock.js/ai-panoptic\" ? import(\"@warlock.js/ai-panoptic\") : import(aiPackage));\n const version =\n deps.version ?? ((name: string) => installedVersion(name, process.cwd(), import.meta.resolve));\n let panoptic: typeof import(\"@warlock.js/ai-panoptic\");\n try {\n panoptic = (await load(\"@warlock.js/ai-panoptic\")) as typeof panoptic;\n if (typeof panoptic.subscribeTraces !== \"function\")\n throw new Error(\"Trace subscription unavailable\");\n } catch (error) {\n const aiVersion = version(\"@warlock.js/ai\");\n const panopticVersion = version(\"@warlock.js/ai-panoptic\");\n if (aiVersion === null) return { ...describeAiUnavailable(\"ai-missing\"), dispose() {} };\n if (panopticVersion === null)\n return { ...describeAiUnavailable(\"panoptic-missing\"), dispose() {} };\n const text = redactPaths(\n (error instanceof Error ? error.message : String(error)).split(\"\\n\")[0] ?? \"\",\n ).slice(0, 300);\n return {\n ...describeAiUnavailable(\n \"panoptic-failed\",\n `${text} (@warlock.js/ai ${aiVersion}, @warlock.js/ai-panoptic ${panopticVersion})`,\n ),\n dispose() {},\n };\n }\n\n let core: { isObserveAll?: () => boolean; getObservers?: () => readonly unknown[] } | undefined;\n try {\n core = (await load(\"@warlock.js/ai\")) as typeof core;\n } catch {\n core = undefined;\n }\n const observationOff = (): boolean =>\n typeof core?.isObserveAll === \"function\" &&\n typeof core.getObservers === \"function\" &&\n !core.isObserveAll() &&\n core.getObservers().length === 0;\n\n const { currentRequestId } = await import(\"../current-request-id\");\n const store = panoptic.createInMemoryTraceStore({ capacity });\n const listeners = new Set<(event: DevtoolsAiEvent) => void>();\n const detach = panoptic.subscribeTraces((trace) => {\n // Read ALS before any asynchronous exporter work, including for runs that\n // finish after the HTTP response. Never use sessionId as a request id.\n const requestId = currentRequestId() ?? trace.requestId;\n store.add({\n ...trace,\n requestId,\n usage: structuredClone(trace.usage),\n root: snapshotSpan(trace.root),\n });\n for (const listener of listeners) {\n try {\n listener({ traceId: trace.traceId, requestId });\n } catch {\n /* isolate clients */\n }\n }\n });\n\n return {\n available: true,\n observationOff,\n store,\n summarize: (trace) => summarizeAiTrace(trace, panoptic.totalCostUsd(trace.usage)),\n subscribe(listener) {\n listeners.add(listener);\n return () => {\n listeners.delete(listener);\n };\n },\n dispose() {\n detach();\n listeners.clear();\n store.clear();\n },\n };\n}\n"],"mappings":";;;;;;;AAIA,IAAI;;;;;;;AAQJ,SAAS,cAAc,KAAsB;CAC3C,MAAM,YACJA,oBAAWC,kBAAK,KAAK,KAAK,MAAM,aAAa,YAAY,CAAC,SAC1DD,oBAAWC,kBAAK,KAAK,KAAK,MAAM,UAAU,cAAc,CAAC;CAC3D,MAAM,cAAcA,kBAAK,KAAK,KAAK,cAAc;CAEjD,IAAI,CAAC,SAAS,KAACD,oBAAW,WAAW,GACnC,OAAO;CAGT,IAAI;EAEF,OADe,KAAK,UAAME,sBAAa,aAAa,MAAM,CAC9C,CAAC,CAAC,SAAS;CACzB,QAAQ;EACN,OAAO;CACT;AACF;;;;;;;AAQA,SAAgB,gBAAwB;CACtC,IAAI,cACF,OAAO;CAGT,IAAI,MAAMD,kBAAK,YAAQE,qEAA6B,CAAC;CAErD,OAAO,MAAM;EACX,IAAI,cAAc,GAAG,GAAG;GACtB,eAAeF,kBAAK,KAAK,KAAK,IAAI;GAClC,OAAO;EACT;EAEA,MAAM,SAASA,kBAAK,QAAQ,GAAG;EAC/B,IAAI,WAAW,KACb,MAAM,IAAI,MACR,gLAGF;EAGF,MAAM;CACR;AACF;;;;;;;;;;ACpDA,MAAa,mBAAmB,OAAO,IAAI,4BAA4B;AAEvE,MAAa,+BACX;;AAmDF,SAAgB,oBACd,OACA,WACkB;CAClB,IAAI,YAAY;CAChB,IAAI,WAAW;CAEf,KAAK,MAAM,QAA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;GAChB,MAAM,MAAM;EACd;CACF;AACF"}
|
|
@@ -0,0 +1,253 @@
|
|
|
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_path = require("node:path");
|
|
43
|
+
node_path = __toESM(node_path, 1);
|
|
44
|
+
let node_url = require("node:url");
|
|
45
|
+
|
|
46
|
+
//#region ../../packages/devtools/src/production/contracts.ts
|
|
47
|
+
/**
|
|
48
|
+
* Upper bounds (inclusive, ms) of the latency buckets every histogram uses.
|
|
49
|
+
* A histogram's `counts` has one more entry than this list: the last entry
|
|
50
|
+
* counts everything above the highest bound. Fixed bounds make histograms
|
|
51
|
+
* from several instances merge exactly.
|
|
52
|
+
*/
|
|
53
|
+
const DEVTOOLS_LATENCY_BUCKETS_MS = [
|
|
54
|
+
1,
|
|
55
|
+
2,
|
|
56
|
+
5,
|
|
57
|
+
10,
|
|
58
|
+
25,
|
|
59
|
+
50,
|
|
60
|
+
100,
|
|
61
|
+
250,
|
|
62
|
+
500,
|
|
63
|
+
1e3,
|
|
64
|
+
2500,
|
|
65
|
+
5e3,
|
|
66
|
+
1e4,
|
|
67
|
+
3e4
|
|
68
|
+
];
|
|
69
|
+
/**
|
|
70
|
+
* The built-in tabs, in display order, with whether production shows them
|
|
71
|
+
* when the project says nothing (`production.panels` overrides per id).
|
|
72
|
+
*/
|
|
73
|
+
const DEVTOOLS_BUILT_IN_PANELS = [
|
|
74
|
+
{
|
|
75
|
+
id: "requests",
|
|
76
|
+
title: "Requests",
|
|
77
|
+
production: true
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
id: "queries",
|
|
81
|
+
title: "Queries",
|
|
82
|
+
production: true
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
id: "routes",
|
|
86
|
+
title: "Routes",
|
|
87
|
+
production: true
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
id: "resources",
|
|
91
|
+
title: "Resources",
|
|
92
|
+
production: true
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
id: "health",
|
|
96
|
+
title: "Health",
|
|
97
|
+
production: true
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
id: "errors",
|
|
101
|
+
title: "Errors",
|
|
102
|
+
production: true
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
id: "logs",
|
|
106
|
+
title: "Logs",
|
|
107
|
+
production: true
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
id: "jobs",
|
|
111
|
+
title: "Jobs",
|
|
112
|
+
production: true
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
id: "mail",
|
|
116
|
+
title: "Mail",
|
|
117
|
+
production: false
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
id: "ai",
|
|
121
|
+
title: "AI",
|
|
122
|
+
production: false
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
id: "agents",
|
|
126
|
+
title: "Agents",
|
|
127
|
+
production: false
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
id: "api",
|
|
131
|
+
title: "API",
|
|
132
|
+
production: false
|
|
133
|
+
}
|
|
134
|
+
];
|
|
135
|
+
/** The audit types that count toward the account, IP and global failure limits. */
|
|
136
|
+
const DEVTOOLS_FAILURE_AUDIT_TYPES = [
|
|
137
|
+
"login.failed",
|
|
138
|
+
"mfa.failed",
|
|
139
|
+
"share.failed"
|
|
140
|
+
];
|
|
141
|
+
|
|
142
|
+
//#endregion
|
|
143
|
+
//#region ../../packages/devtools/src/app-versions.ts
|
|
144
|
+
/** The `version` of a `package.json` named `name`, or `null` when the file is not that package's. */
|
|
145
|
+
function versionIn(file, name) {
|
|
146
|
+
try {
|
|
147
|
+
const manifest = JSON.parse((0, node_fs.readFileSync)(file, "utf8"));
|
|
148
|
+
return manifest.name === name && typeof manifest.version === "string" ? manifest.version : null;
|
|
149
|
+
} catch {
|
|
150
|
+
return null;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* The installed version of a package, read from its `package.json` without
|
|
155
|
+
* going through its `exports` (published `@warlock.js/core` exports neither
|
|
156
|
+
* `./package.json` nor a `require` condition). It resolves the package's entry
|
|
157
|
+
* and walks up to the `package.json` with that name; when the entry cannot be
|
|
158
|
+
* resolved, it looks in each `node_modules` above `from`. `null` when unknown.
|
|
159
|
+
*/
|
|
160
|
+
function installedVersion(name, from, resolve) {
|
|
161
|
+
try {
|
|
162
|
+
const entry = resolve?.(name);
|
|
163
|
+
if (entry !== void 0) {
|
|
164
|
+
let folder = node_path.default.dirname(entry.startsWith("file:") ? (0, node_url.fileURLToPath)(entry) : entry);
|
|
165
|
+
for (;;) {
|
|
166
|
+
const version = versionIn(node_path.default.join(folder, "package.json"), name);
|
|
167
|
+
if (version !== null) return version;
|
|
168
|
+
const parent = node_path.default.dirname(folder);
|
|
169
|
+
if (parent === folder) break;
|
|
170
|
+
folder = parent;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
} catch {}
|
|
174
|
+
for (let folder = from;; folder = node_path.default.dirname(folder)) {
|
|
175
|
+
const version = versionIn(node_path.default.join(folder, "node_modules", ...name.split("/"), "package.json"), name);
|
|
176
|
+
if (version !== null) return version;
|
|
177
|
+
if (node_path.default.dirname(folder) === folder) return null;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* The app's `name` and `version` from the `package.json` in `root`. Only these
|
|
182
|
+
* two strings are read; `null` when the file is missing, unreadable or lacks
|
|
183
|
+
* either one.
|
|
184
|
+
*/
|
|
185
|
+
function readAppInfo(root) {
|
|
186
|
+
try {
|
|
187
|
+
const manifest = JSON.parse((0, node_fs.readFileSync)(node_path.default.join(root, "package.json"), "utf8"));
|
|
188
|
+
if (typeof manifest.name !== "string" || typeof manifest.version !== "string" || manifest.name === "" || manifest.version === "") return null;
|
|
189
|
+
return {
|
|
190
|
+
name: manifest.name.slice(0, 100),
|
|
191
|
+
version: manifest.version.slice(0, 50)
|
|
192
|
+
};
|
|
193
|
+
} catch {
|
|
194
|
+
return null;
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
let cached;
|
|
198
|
+
/**
|
|
199
|
+
* The installed `@warlock.js/core` version and the app's name and version,
|
|
200
|
+
* read once per process (`root` defaults to the working directory) and kept.
|
|
201
|
+
*/
|
|
202
|
+
function readVersions(root = process.cwd()) {
|
|
203
|
+
cached ??= {
|
|
204
|
+
warlockVersion: installedVersion("@warlock.js/core", root, typeof {}.resolve === "function" ? (specifier) => ({}).resolve(specifier) : void 0),
|
|
205
|
+
app: readAppInfo(root)
|
|
206
|
+
};
|
|
207
|
+
return cached;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
//#endregion
|
|
211
|
+
Object.defineProperty(exports, "DEVTOOLS_BUILT_IN_PANELS", {
|
|
212
|
+
enumerable: true,
|
|
213
|
+
get: function () {
|
|
214
|
+
return DEVTOOLS_BUILT_IN_PANELS;
|
|
215
|
+
}
|
|
216
|
+
});
|
|
217
|
+
Object.defineProperty(exports, "DEVTOOLS_FAILURE_AUDIT_TYPES", {
|
|
218
|
+
enumerable: true,
|
|
219
|
+
get: function () {
|
|
220
|
+
return DEVTOOLS_FAILURE_AUDIT_TYPES;
|
|
221
|
+
}
|
|
222
|
+
});
|
|
223
|
+
Object.defineProperty(exports, "DEVTOOLS_LATENCY_BUCKETS_MS", {
|
|
224
|
+
enumerable: true,
|
|
225
|
+
get: function () {
|
|
226
|
+
return DEVTOOLS_LATENCY_BUCKETS_MS;
|
|
227
|
+
}
|
|
228
|
+
});
|
|
229
|
+
Object.defineProperty(exports, "__exportAll", {
|
|
230
|
+
enumerable: true,
|
|
231
|
+
get: function () {
|
|
232
|
+
return __exportAll;
|
|
233
|
+
}
|
|
234
|
+
});
|
|
235
|
+
Object.defineProperty(exports, "__toESM", {
|
|
236
|
+
enumerable: true,
|
|
237
|
+
get: function () {
|
|
238
|
+
return __toESM;
|
|
239
|
+
}
|
|
240
|
+
});
|
|
241
|
+
Object.defineProperty(exports, "installedVersion", {
|
|
242
|
+
enumerable: true,
|
|
243
|
+
get: function () {
|
|
244
|
+
return installedVersion;
|
|
245
|
+
}
|
|
246
|
+
});
|
|
247
|
+
Object.defineProperty(exports, "readVersions", {
|
|
248
|
+
enumerable: true,
|
|
249
|
+
get: function () {
|
|
250
|
+
return readVersions;
|
|
251
|
+
}
|
|
252
|
+
});
|
|
253
|
+
//# sourceMappingURL=app-versions-DfpPZOI2.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"app-versions-DfpPZOI2.cjs","names":["readFileSync","path","fileURLToPath"],"sources":["../../../../../../../packages/devtools/src/production/contracts.ts","../../../../../../../packages/devtools/src/app-versions.ts"],"sourcesContent":["/**\n * The contracts of the devtools production monitor: the shapes the server\n * stores, the JSON its API returns, and the few constants both sides share.\n *\n * This file has NO imports, so the dashboard (`ui-src/`) can import its types\n * too. Every timestamp is epoch milliseconds, every duration milliseconds,\n * every size bytes. Absent values are `null`, never missing.\n */\n\n// ---------------------------------------------------------------------------\n// Modes, roles and stages\n// ---------------------------------------------------------------------------\n\n/** Where the dashboard runs: the loopback development dashboard or the signed-in production monitor. */\nexport type DevtoolsMode = \"development\" | \"production\";\n\n/** What an account may do: `admin` manages users and the dashboard, `viewer` reads. */\nexport type DevtoolsRole = \"admin\" | \"viewer\";\n\n/**\n * Where a browser session stands. Only `active` reaches the data routes;\n * every other stage reaches only the sign-in steps it needs next.\n */\nexport type DevtoolsSessionStage =\n | \"signed-out\"\n | \"password-change\"\n | \"mfa-enrol\"\n | \"mfa-verify\"\n | \"active\";\n\n/** How an account's current password was set. `env` and `reset` passwords must be changed at the next sign-in. */\nexport type DevtoolsPasswordSource = \"env\" | \"setup\" | \"invite\" | \"user\" | \"reset\";\n\n// ---------------------------------------------------------------------------\n// Instances\n// ---------------------------------------------------------------------------\n\n/** One process that runs the monitor (a pm2 or cluster worker, a container). */\nexport type DevtoolsInstanceInfo = {\n /** Stable for the life of the process: `<host>:<pid>:<start time base36>`. */\n id: string;\n /** What the dashboard shows: `<host> #<worker>` or `<host> pid <pid>`. */\n label: string;\n host: string;\n pid: number;\n /** pm2's `NODE_APP_INSTANCE` / `pm_id`, or the cluster worker id; `null` when neither is set. */\n worker: string | null;\n startedAt: number;\n /** When the instance last wrote its report (the current time for the instance answering). */\n seenAt: number;\n nodeVersion: string;\n};\n\n// ---------------------------------------------------------------------------\n// Histograms (mergeable across instances)\n// ---------------------------------------------------------------------------\n\n/**\n * Upper bounds (inclusive, ms) of the latency buckets every histogram uses.\n * A histogram's `counts` has one more entry than this list: the last entry\n * counts everything above the highest bound. Fixed bounds make histograms\n * from several instances merge exactly.\n */\nexport const DEVTOOLS_LATENCY_BUCKETS_MS = [\n 1, 2, 5, 10, 25, 50, 100, 250, 500, 1000, 2500, 5000, 10000, 30000,\n] as const;\n\n/** A latency histogram over `DEVTOOLS_LATENCY_BUCKETS_MS`. */\nexport type DevtoolsHistogram = {\n /** `DEVTOOLS_LATENCY_BUCKETS_MS.length + 1` entries. */\n counts: number[];\n count: number;\n sumMs: number;\n maxMs: number;\n};\n\n// ---------------------------------------------------------------------------\n// Query, route and error statistics\n// ---------------------------------------------------------------------------\n\n/** Statistics for one normalized query shape (literals and bindings replaced by `?`). */\nexport type DevtoolsQueryShapeStats = {\n /** First 16 hex characters of the SHA-256 of `shape`; the id the API and EXPLAIN use. */\n id: string;\n /** The normalized query, at most 2000 characters. Never holds a value. */\n shape: string;\n driver: \"postgres\" | \"mongodb\";\n connection: string;\n count: number;\n errors: number;\n histogram: DevtoolsHistogram;\n /** Sampled requests in which this shape reached the N+1 threshold, and the highest count in one request. */\n nPlusOne: { requests: number; maxPerRequest: number };\n /** The slowest run seen; its values stay in the process that ran it (see EXPLAIN). */\n slowest: {\n durationMs: number;\n at: number;\n route: string | null;\n requestId: string | null;\n instance: string;\n } | null;\n firstSeen: number;\n lastSeen: number;\n /** Whether EXPLAIN can run for this shape (a Postgres `SELECT`/`WITH`, or a MongoDB `find`/`aggregate`/`count`). */\n explainable: boolean;\n};\n\n/** Time spent in one named request phase (middleware, validation, handler, …) on one route. */\nexport type DevtoolsRoutePhaseStats = {\n name: string;\n count: number;\n sumMs: number;\n maxMs: number;\n};\n\n/** Statistics for one route pattern and method. */\nexport type DevtoolsRouteStats = {\n /** `\"<METHOD> <route pattern>\"`, e.g. `\"GET /posts/:slug\"`. */\n key: string;\n method: string;\n route: string;\n count: number;\n /** Responses with a 5xx status or a thrown error. */\n errors: number;\n histogram: DevtoolsHistogram;\n /** At most 30 phases, slowest total first. */\n phases: DevtoolsRoutePhaseStats[];\n slowest: { durationMs: number; at: number; requestId: string | null; instance: string } | null;\n};\n\n/** Errors grouped by fingerprint (normalized message + route + source). */\nexport type DevtoolsErrorGroup = {\n /** First 16 hex characters of the SHA-256 of the fingerprint. */\n id: string;\n /** The latest message as raised, at most 500 characters. */\n message: string;\n /** The error class name when known (`TypeError`). */\n name: string | null;\n source: \"request\" | \"log\";\n route: string | null;\n status: number | null;\n count: number;\n firstSeen: number;\n lastSeen: number;\n lastRequestId: string | null;\n /** The latest stack, at most 4000 characters; `null` when none was available. */\n stack: string | null;\n};\n\n/** A warn/error log entry kept for the Logs panel in production (no context: it may hold values). */\nexport type DevtoolsReportLogEntry = {\n level: \"debug\" | \"info\" | \"warn\" | \"error\" | \"success\";\n module: string;\n action: string;\n /** At most 1000 characters. */\n message: string;\n at: number;\n requestId: string | null;\n};\n\n// ---------------------------------------------------------------------------\n// Resources, health, jobs\n// ---------------------------------------------------------------------------\n\n/** One resource reading of a process. */\nexport type DevtoolsResourcePoint = {\n at: number;\n rssBytes: number;\n heapUsedBytes: number;\n heapTotalBytes: number;\n externalBytes: number;\n /** Process CPU time over wall time since the previous point, 0–100 per core (can exceed 100). */\n cpuPercent: number;\n eventLoopDelayP50Ms: number;\n eventLoopDelayP99Ms: number;\n eventLoopDelayMaxMs: number;\n /** `performance.eventLoopUtilization()` since the previous point, 0–1. */\n eventLoopUtilization: number;\n /** Garbage collections since the previous point. */\n gcCount: number;\n /** Total GC pause since the previous point. */\n gcPauseMs: number;\n};\n\n/** The latest resource reading plus values that change rarely. */\nexport type DevtoolsResourceSnapshot = DevtoolsResourcePoint & {\n heapLimitBytes: number;\n uptimeSeconds: number;\n /** Totals since the monitor started, by GC kind. */\n gcByKind: Record<\n \"minor\" | \"major\" | \"incremental\" | \"weakcb\",\n { count: number; pauseMs: number }\n >;\n};\n\n/** Readiness checks (core's `health` registry) of one process, with a short history. */\nexport type DevtoolsHealthReport = {\n status: \"ok\" | \"error\" | \"unknown\";\n checkedAt: number | null;\n checks: Record<string, boolean>;\n /** Newest last, at most 60 entries. */\n history: { at: number; status: \"ok\" | \"error\"; failed: string[] }[];\n};\n\n/** One scheduled job (`@warlock.js/scheduler`). */\nexport type DevtoolsScheduleInfo = {\n name: string;\n /** The cron expression, or `null` for an interval schedule. */\n cron: string | null;\n /** A readable interval such as `\"every 5 minutes\"`, or `null`. */\n interval: string | null;\n isRunning: boolean;\n lastRunAt: number | null;\n nextRunAt: number | null;\n lastDurationMs: number | null;\n lastError: string | null;\n runs: number;\n failures: number;\n};\n\n/** Background work of one process: schedules and queue counts, each `available: false` when its package is not installed. */\nexport type DevtoolsJobsReport = {\n available: { scheduler: boolean; queue: boolean };\n schedules: DevtoolsScheduleInfo[];\n /** Job counts per queue and state (`waiting`, `active`, `delayed`, `failed`, `completed`). */\n queues: { name: string; counts: Record<string, number> }[];\n};\n\n/** What the capture did since the process started. */\nexport type DevtoolsCaptureCounters = {\n sampleRate: number;\n requests: number;\n sampled: number;\n /** Unsampled requests kept as a summary because they were slow or failed. */\n keptUnsampled: number;\n /** Samples written to the database. */\n stored: number;\n /** Samples not written because the per-minute budget was spent. */\n droppedStored: number;\n /** Query shapes, routes and error groups evicted to keep memory bounded. */\n evictedShapes: number;\n evictedRoutes: number;\n evictedErrors: number;\n /** Queries not kept inside a sampled request because it reached its per-request limit. */\n droppedQueries: number;\n};\n\n/**\n * Everything one process reports, written to the database every\n * `reportIntervalMs` (one row per instance) and merged by the dashboard.\n * Serialized it stays under 256 KB: lists are trimmed from the end.\n */\nexport type DevtoolsInstanceReport = {\n instance: DevtoolsInstanceInfo;\n at: number;\n resources: { snapshot: DevtoolsResourceSnapshot; history: DevtoolsResourcePoint[] };\n /** At most 200, highest total time first. */\n queries: DevtoolsQueryShapeStats[];\n /** At most 200, highest total time first. */\n routes: DevtoolsRouteStats[];\n /** At most 50, newest first. */\n errors: DevtoolsErrorGroup[];\n /** At most 50, newest first. */\n logs: DevtoolsReportLogEntry[];\n health: DevtoolsHealthReport;\n jobs: DevtoolsJobsReport;\n capture: DevtoolsCaptureCounters;\n};\n\n// ---------------------------------------------------------------------------\n// Requests (stored samples)\n// ---------------------------------------------------------------------------\n\n/**\n * A request row. Matches the development `DevtoolsRequestSummary` field for\n * field, plus where it was captured.\n */\nexport type DevtoolsSampleSummary = {\n id: string;\n method: string;\n path: string;\n route?: string;\n status?: number;\n startedAt: number;\n durationMs?: number;\n queryCount: number;\n warningCount: number;\n /** Read from the persisted request log only. */\n persisted?: true;\n /** The instance that served the request. */\n instance?: string;\n /** Kept because it was slow or failed, without a timeline (the request was not sampled). */\n partial?: true;\n};\n\n/** A query inside a stored sample: the shape only, never the SQL text with values or the bindings. */\nexport type DevtoolsSampleQuery = {\n id: string;\n connection: string;\n driver: \"postgres\" | \"mongodb\";\n /** Same as `shape`: kept under this name so the request view renders it like a development query. */\n sql?: string;\n collection?: string;\n command?: string;\n shape: string;\n shapeId: string;\n startedAt: number;\n durationMs: number;\n rowCount?: number;\n error?: string;\n};\n\n/** The timeline of a sampled request, with every value removed (see the redaction rules). */\nexport type DevtoolsSampleDetail = DevtoolsSampleSummary & {\n error?: string;\n phases: { name: string; startedAt: number; durationMs: number }[];\n queries: DevtoolsSampleQuery[];\n /** Cache operation counts only; keys are not kept. */\n cache: { hits: number; misses: number; writes: number };\n /** Log entries without context. */\n logs: { level: string; module: string; action: string; message: string; at: number }[];\n warnings: { type: \"n+1\"; message: string; shape: string; count: number }[];\n /** Queries left out because the request reached `maxQueriesPerRequest`. */\n droppedQueries: number;\n};\n\n// ---------------------------------------------------------------------------\n// API views (what the dashboard reads)\n// ---------------------------------------------------------------------------\n\n/** `GET api/instances`. */\nexport type DevtoolsInstancesView = {\n /** The instance that answered this request. */\n current: string;\n /** Instances seen in the last 5 minutes (the answering one included), newest first. */\n instances: DevtoolsInstanceInfo[];\n};\n\n/** `GET api/resources?instance=<id|all>`. */\nexport type DevtoolsResourcesView = {\n instances: {\n instance: DevtoolsInstanceInfo;\n snapshot: DevtoolsResourceSnapshot;\n history: DevtoolsResourcePoint[];\n }[];\n};\n\n/** A shape row with figures computed from its histogram. */\nexport type DevtoolsQueryShapeRow = DevtoolsQueryShapeStats & {\n p50Ms: number;\n p95Ms: number;\n meanMs: number;\n /** Ids of the instances that reported this shape. */\n instances: string[];\n};\n\n/** `GET api/queries/stats?instance=&sort=total|p95|count|n+1&limit=`. */\nexport type DevtoolsQueryStatsView = {\n shapes: DevtoolsQueryShapeRow[];\n /** The sample rate the counts come from; counts are of sampled requests only. */\n sampleRate: number;\n instanceCount: number;\n evicted: number;\n};\n\n/** A route row with figures computed from its histogram. */\nexport type DevtoolsRouteStatsRow = DevtoolsRouteStats & {\n p50Ms: number;\n p95Ms: number;\n meanMs: number;\n instances: string[];\n};\n\n/** `GET api/routes/stats?instance=&sort=total|p95|count|errors&limit=`. */\nexport type DevtoolsRouteStatsView = {\n routes: DevtoolsRouteStatsRow[];\n sampleRate: number;\n instanceCount: number;\n};\n\n/** `GET api/health?instance=`. */\nexport type DevtoolsHealthView = {\n instances: { instance: DevtoolsInstanceInfo; report: DevtoolsHealthReport }[];\n};\n\n/** `GET api/errors?instance=&limit=`. */\nexport type DevtoolsErrorsView = {\n groups: (DevtoolsErrorGroup & { instances: string[] })[];\n};\n\n/**\n * One row of `GET api/logs?level=&module=&instance=` (newest first), in both\n * modes. Development rows carry `context` and no `instance`; production rows\n * carry `instance` and never `context`.\n */\nexport type DevtoolsLogRow = DevtoolsReportLogEntry & {\n instance: string | null;\n context?: unknown;\n};\n\n/** `GET api/logs`: the rows, newest first (a plain array, as in 5.55). */\nexport type DevtoolsLogsView = DevtoolsLogRow[];\n\n/** `GET api/jobs?instance=`. */\nexport type DevtoolsJobsView = {\n instances: { instance: DevtoolsInstanceInfo; report: DevtoolsJobsReport }[];\n};\n\n/** `POST api/queries/:shapeId/explain`. */\nexport type DevtoolsExplainResult = {\n shapeId: string;\n driver: \"postgres\" | \"mongodb\";\n /** `true` only when the project allows executing plans (`explain.executing`). */\n executing: boolean;\n plan: unknown;\n /** The instance whose example ran the EXPLAIN. */\n instance: string;\n};\n\n/** One dashboard tab, as `GET api/panels` lists it (enabled tabs only, in display order). */\nexport type DevtoolsPanelInfo = {\n id: string;\n title: string;\n /** `built-in` tabs are React views in the bundle; `package` tabs load `panels/<id>/view.js`. */\n type: \"built-in\" | \"package\";\n /** Whether the panel declares a shared view (`DevtoolsPanel.share`); always `false` for built-in tabs. */\n shareable: boolean;\n};\n\n/**\n * The built-in tabs, in display order, with whether production shows them\n * when the project says nothing (`production.panels` overrides per id).\n */\nexport const DEVTOOLS_BUILT_IN_PANELS = [\n { id: \"requests\", title: \"Requests\", production: true },\n { id: \"queries\", title: \"Queries\", production: true },\n { id: \"routes\", title: \"Routes\", production: true },\n { id: \"resources\", title: \"Resources\", production: true },\n { id: \"health\", title: \"Health\", production: true },\n { id: \"errors\", title: \"Errors\", production: true },\n { id: \"logs\", title: \"Logs\", production: true },\n { id: \"jobs\", title: \"Jobs\", production: true },\n { id: \"mail\", title: \"Mail\", production: false },\n { id: \"ai\", title: \"AI\", production: false },\n { id: \"agents\", title: \"Agents\", production: false },\n { id: \"api\", title: \"API\", production: false },\n] as const;\n\n/** The id of a built-in tab. */\nexport type DevtoolsBuiltInPanelId = (typeof DEVTOOLS_BUILT_IN_PANELS)[number][\"id\"];\n\n// ---------------------------------------------------------------------------\n// Accounts, sessions, invites\n// ---------------------------------------------------------------------------\n\n/** An account as the API shows it (never a hash or a secret). */\nexport type DevtoolsAccountView = {\n id: string;\n email: string;\n role: DevtoolsRole;\n twoFactor: {\n totp: boolean;\n passkeys: { id: string; name: string; createdAt: number; lastUsedAt: number | null }[];\n recoveryCodesLeft: number;\n };\n mustChangePassword: boolean;\n createdAt: number;\n lastLoginAt: number | null;\n};\n\n/** `GET api/auth/session`: who is signed in and what comes next. */\nexport type DevtoolsSessionView = {\n mode: DevtoolsMode;\n stage: DevtoolsSessionStage;\n /** `null` when signed out, and in development (no accounts there). */\n account: DevtoolsAccountView | null;\n /** `admin` in development; `null` when signed out. */\n role: DevtoolsRole | null;\n /** The token to send as `X-Devtools-Csrf` on every POST/PUT/PATCH/DELETE; `null` when signed out and in development. */\n csrf: string | null;\n /** When the session ends at the latest; `null` when signed out and in development. */\n expiresAt: number | null;\n /** The instance that answered; `null` when signed out. */\n instance: DevtoolsInstanceInfo | null;\n /** Sign-in methods the server offers; `null` when signed out. */\n methods: { totp: true; passkeys: boolean } | null;\n /** Read-only share links: `enabled` mirrors `production.share.enabled`; `null` when signed out and in development. */\n share: { enabled: boolean } | null;\n /** The installed `@warlock.js/core` version; `null` when signed out or not found. */\n warlockVersion: string | null;\n /** The app's own `package.json` name and version (nothing else is read); `null` when signed out or not found. */\n app: { name: string; version: string } | null;\n};\n\n/** `POST api/auth/login` body. */\nexport type DevtoolsLoginInput = { email: string; password: string };\n\n/** Answer of every sign-in step: the next stage, and the new CSRF token when the session changed. */\nexport type DevtoolsAuthStepResult = { stage: DevtoolsSessionStage; csrf: string | null };\n\n/** `POST api/auth/totp/start` (and `api/account/totp/start`). */\nexport type DevtoolsTotpEnrolment = {\n /** Base32, for manual entry. */\n secret: string;\n /** `otpauth://totp/...`, rendered as a QR code by the dashboard. */\n uri: string;\n issuer: string;\n account: string;\n};\n\n/** Recovery codes, shown once. */\nexport type DevtoolsRecoveryCodes = { codes: string[] };\n\n/** A pending or used invite. */\nexport type DevtoolsInviteView = {\n id: string;\n email: string;\n role: DevtoolsRole;\n createdAt: number;\n expiresAt: number;\n createdBy: string | null;\n usedAt: number | null;\n};\n\n/** `POST api/admin/invites`: the token appears only in this answer. */\nexport type DevtoolsCreatedInvite = { invite: DevtoolsInviteView; token: string };\n\n/** `GET api/admin/users`. */\nexport type DevtoolsUserListView = {\n accounts: DevtoolsAccountView[];\n invites: DevtoolsInviteView[];\n};\n\n/** A session as its owner sees it (`GET api/account/sessions`). */\nexport type DevtoolsSessionInfo = {\n id: string;\n current: boolean;\n createdAt: number;\n lastSeenAt: number;\n expiresAt: number;\n ip: string | null;\n userAgent: string | null;\n};\n\n// ---------------------------------------------------------------------------\n// Share links\n// ---------------------------------------------------------------------------\n\n/** Where a share link stands. `revoked` wins over `expired`. */\nexport type DevtoolsShareStatus = \"active\" | \"expired\" | \"revoked\";\n\n/** A share link as the admin screen shows it (never the token or its hash). */\nexport type DevtoolsShareView = {\n id: string;\n /** The id of the panel the link opens. */\n panel: string;\n /** What the admin called it, 1-80 characters. */\n label: string;\n /** The email of the admin who made it; `null` when that account is gone. */\n createdBy: string | null;\n createdAt: number;\n expiresAt: number;\n revokedAt: number | null;\n lastUsedAt: number | null;\n /** How many times the link was used, counted at most once a minute. */\n uses: number;\n status: DevtoolsShareStatus;\n};\n\n/** `GET api/admin/shares`. */\nexport type DevtoolsShareList = {\n enabled: boolean;\n /** The longest life a link may have, in days. */\n maxDays: number;\n /** The panels that declare a shared view. */\n panels: { id: string; title: string }[];\n /** Newest first. */\n shares: DevtoolsShareView[];\n};\n\n/** `POST api/admin/shares` body. `label` is 1-80 characters, `days` a whole number from 1 to `maxDays`. */\nexport type DevtoolsShareCreateInput = { panel: string; label: string; days: number };\n\n/** `POST api/admin/shares`: the URL (with the token in its fragment) appears only in this answer. */\nexport type DevtoolsCreatedShare = { share: DevtoolsShareView; url: string };\n\n/**\n * What a share link opens, answered by `POST api/share/open` and\n * `GET api/share/info`: the panel and the names the shared view may load.\n */\nexport type DevtoolsShareOpenAnswer = {\n panel: string;\n /** The panel's title. */\n title: string;\n label: string;\n expiresAt: number;\n /** Served names from the panel's `assets` the shared page may load. */\n assets: string[];\n /** Whether the shared page may load images from the panel's `files`. */\n files: boolean;\n};\n\n/** The longest label of a share link. */\nexport const DEVTOOLS_SHARE_LABEL_MAX = 80;\n\n// ---------------------------------------------------------------------------\n// Audit log\n// ---------------------------------------------------------------------------\n\n/** Every audited event. `login.failed` and `mfa.failed` are the ones rate limits count. */\nexport type DevtoolsAuditType =\n | \"admin.seeded\"\n | \"admin.reset\"\n | \"setup.completed\"\n | \"login.succeeded\"\n | \"login.failed\"\n | \"login.blocked\"\n | \"mfa.succeeded\"\n | \"mfa.failed\"\n | \"mfa.enrolled\"\n | \"mfa.removed\"\n | \"recovery-code.used\"\n | \"recovery-codes.regenerated\"\n | \"passkey.added\"\n | \"passkey.removed\"\n | \"password.changed\"\n | \"logout\"\n | \"session.revoked\"\n | \"invite.created\"\n | \"invite.revoked\"\n | \"invite.accepted\"\n | \"account.role-changed\"\n | \"account.removed\"\n | \"account.mfa-reset\"\n | \"account.signed-out\"\n | \"dashboard.disabled\"\n | \"dashboard.enabled\"\n | \"dashboard.locked\"\n | \"explain.run\"\n | \"requests.cleared\"\n | \"panel.action\"\n | \"share.created\"\n | \"share.revoked\"\n | \"share.failed\";\n\n/** The audit types that count toward the account, IP and global failure limits. */\nexport const DEVTOOLS_FAILURE_AUDIT_TYPES: readonly DevtoolsAuditType[] = [\n \"login.failed\",\n \"mfa.failed\",\n \"share.failed\",\n];\n\n/** One audit log entry. */\nexport type DevtoolsAuditEntry = {\n id: string;\n at: number;\n type: DevtoolsAuditType;\n /** The account acting or targeted; `null` for an unknown email or the CLI. */\n accountId: string | null;\n /** The email as typed or as stored, lower-cased; `null` when there was none. */\n email: string | null;\n /** `\"cli\"` for a command, else the client IP after trusted-proxy resolution. */\n ip: string | null;\n /** At most 200 characters. */\n userAgent: string | null;\n /** Small flat facts: target account, role, shape id, panel route. Never a secret. */\n detail: Record<string, string | number | boolean | null>;\n /** Short reference shown to users in error messages (8 characters). */\n ref: string;\n};\n\n// ---------------------------------------------------------------------------\n// Errors the API returns\n// ---------------------------------------------------------------------------\n\n/**\n * Error codes in API answers. Each has a fixed message (see\n * `DEVTOOLS_ERROR_MESSAGES` in `errors.ts`) that says what failed and what to\n * do next.\n */\nexport type DevtoolsErrorCode =\n | \"auth.invalid-credentials\"\n | \"auth.invalid-code\"\n | \"auth.invalid-setup-token\"\n | \"auth.password-too-short\"\n | \"auth.password-too-long\"\n | \"auth.password-common\"\n | \"auth.password-same-as-email\"\n | \"auth.password-unchanged\"\n | \"auth.wrong-current-password\"\n | \"auth.busy\"\n | \"invite.invalid\"\n | \"invite.email-taken\"\n | \"account.not-found\"\n | \"account.last-admin\"\n | \"account.self\"\n | \"account.last-factor\"\n | \"role.forbidden\"\n | \"csrf.invalid\"\n | \"passkey.unavailable\"\n | \"passkey.failed\"\n | \"explain.not-allowed\"\n | \"explain.unsupported\"\n | \"explain.elsewhere\"\n | \"explain.failed\"\n | \"request.not-found\"\n | \"request.invalid-filter\"\n | \"share.not-found\"\n | \"stream.too-many\"\n | \"input.invalid\"\n | \"server.error\";\n\n/** The JSON body of every failed API call. */\nexport type DevtoolsApiErrorBody = {\n /** What failed and what to do next. */\n error: string;\n code: DevtoolsErrorCode;\n /** Short reference to quote to an admin; also written to the audit log or server log. */\n ref?: string;\n /** The instance that answered, when it matters (`explain.elsewhere`). */\n instance?: string;\n};\n","import { readFileSync } from \"node:fs\";\nimport path from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\n\n/** The app's own name and version, as the dashboard shows them at the bottom of the sidebar. */\nexport type DevtoolsAppInfo = { name: string; version: string };\n\n/** The `version` of a `package.json` named `name`, or `null` when the file is not that package's. */\nfunction versionIn(file: string, name: string): string | null {\n try {\n const manifest = JSON.parse(readFileSync(file, \"utf8\")) as {\n name?: unknown;\n version?: unknown;\n };\n\n return manifest.name === name && typeof manifest.version === \"string\" ? manifest.version : null;\n } catch {\n return null;\n }\n}\n\n/**\n * The installed version of a package, read from its `package.json` without\n * going through its `exports` (published `@warlock.js/core` exports neither\n * `./package.json` nor a `require` condition). It resolves the package's entry\n * and walks up to the `package.json` with that name; when the entry cannot be\n * resolved, it looks in each `node_modules` above `from`. `null` when unknown.\n */\nexport function installedVersion(\n name: string,\n from: string,\n resolve: ((specifier: string) => string) | undefined,\n): string | null {\n try {\n const entry = resolve?.(name);\n\n if (entry !== undefined) {\n let folder = path.dirname(entry.startsWith(\"file:\") ? fileURLToPath(entry) : entry);\n\n for (;;) {\n const version = versionIn(path.join(folder, \"package.json\"), name);\n\n if (version !== null) return version;\n\n const parent = path.dirname(folder);\n\n if (parent === folder) break;\n\n folder = parent;\n }\n }\n } catch {\n // Not resolvable from here: look in the node_modules folders below.\n }\n\n for (let folder = from; ; folder = path.dirname(folder)) {\n const version = versionIn(\n path.join(folder, \"node_modules\", ...name.split(\"/\"), \"package.json\"),\n name,\n );\n\n if (version !== null) return version;\n if (path.dirname(folder) === folder) return null;\n }\n}\n\n/**\n * The app's `name` and `version` from the `package.json` in `root`. Only these\n * two strings are read; `null` when the file is missing, unreadable or lacks\n * either one.\n */\nexport function readAppInfo(root: string): DevtoolsAppInfo | null {\n try {\n const manifest = JSON.parse(readFileSync(path.join(root, \"package.json\"), \"utf8\")) as {\n name?: unknown;\n version?: unknown;\n };\n\n if (\n typeof manifest.name !== \"string\" ||\n typeof manifest.version !== \"string\" ||\n manifest.name === \"\" ||\n manifest.version === \"\"\n ) {\n return null;\n }\n\n return { name: manifest.name.slice(0, 100), version: manifest.version.slice(0, 50) };\n } catch {\n return null;\n }\n}\n\ntype Versions = { warlockVersion: string | null; app: DevtoolsAppInfo | null };\n\nlet cached: Versions | undefined;\n\n/**\n * The installed `@warlock.js/core` version and the app's name and version,\n * read once per process (`root` defaults to the working directory) and kept.\n */\nexport function readVersions(root: string = process.cwd()): Versions {\n cached ??= {\n warlockVersion: installedVersion(\n \"@warlock.js/core\",\n root,\n typeof import.meta.resolve === \"function\"\n ? (specifier: string) => import.meta.resolve(specifier)\n : undefined,\n ),\n app: readAppInfo(root),\n };\n\n return cached;\n}\n\n/** Forgets the cached versions (for tests). */\nexport function resetVersionsCache(): void {\n cached = undefined;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+DA,MAAa,8BAA8B;CACzC;CAAG;CAAG;CAAG;CAAI;CAAI;CAAI;CAAK;CAAK;CAAK;CAAM;CAAM;CAAM;CAAO;AAC/D;;;;;AAgXA,MAAa,2BAA2B;CACtC;EAAE,IAAI;EAAY,OAAO;EAAY,YAAY;CAAK;CACtD;EAAE,IAAI;EAAW,OAAO;EAAW,YAAY;CAAK;CACpD;EAAE,IAAI;EAAU,OAAO;EAAU,YAAY;CAAK;CAClD;EAAE,IAAI;EAAa,OAAO;EAAa,YAAY;CAAK;CACxD;EAAE,IAAI;EAAU,OAAO;EAAU,YAAY;CAAK;CAClD;EAAE,IAAI;EAAU,OAAO;EAAU,YAAY;CAAK;CAClD;EAAE,IAAI;EAAQ,OAAO;EAAQ,YAAY;CAAK;CAC9C;EAAE,IAAI;EAAQ,OAAO;EAAQ,YAAY;CAAK;CAC9C;EAAE,IAAI;EAAQ,OAAO;EAAQ,YAAY;CAAM;CAC/C;EAAE,IAAI;EAAM,OAAO;EAAM,YAAY;CAAM;CAC3C;EAAE,IAAI;EAAU,OAAO;EAAU,YAAY;CAAM;CACnD;EAAE,IAAI;EAAO,OAAO;EAAO,YAAY;CAAM;AAC/C;;AAwMA,MAAa,+BAA6D;CACxE;CACA;CACA;AACF;;;;;ACloBA,SAAS,UAAU,MAAc,MAA6B;CAC5D,IAAI;EACF,MAAM,WAAW,KAAK,UAAMA,sBAAa,MAAM,MAAM,CAAC;EAKtD,OAAO,SAAS,SAAS,QAAQ,OAAO,SAAS,YAAY,WAAW,SAAS,UAAU;CAC7F,QAAQ;EACN,OAAO;CACT;AACF;;;;;;;;AASA,SAAgB,iBACd,MACA,MACA,SACe;CACf,IAAI;EACF,MAAM,QAAQ,UAAU,IAAI;EA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