@warlock.js/ai-panoptic 5.59.0 → 5.60.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 CHANGED
@@ -4,6 +4,16 @@ All notable changes to `@warlock.js/ai-panoptic` 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.60.0 - 2026-11-19
8
+
9
+ ### Added
10
+
11
+ - `panoptic.evaluate`, `getEvaluateConfig()` and `isInsideWarlockApp()`; spans carry `agent.fallbackTrips` and `agent.refusals`.
12
+
13
+ ### Changed
14
+
15
+ - The Panoptic dashboard no longer starts inside a Warlock app (one notice points at the devtools AI pages), also when the app has no devtools and in a test run from the app folder. To keep it after upgrading, set `panoptic.dashboard.standalone: true`.
16
+
7
17
  ## 5.54.0 - 2026-11-16
8
18
 
9
19
  ### Added
package/cjs/index.cjs CHANGED
@@ -5,6 +5,7 @@ let node_path = require("node:path");
5
5
  let node_http = require("node:http");
6
6
  let node_crypto = require("node:crypto");
7
7
  let _warlock_js_logger = require("@warlock.js/logger");
8
+ let node_fs = require("node:fs");
8
9
 
9
10
  //#region ../../packages/ai-panoptic/src/exporters/utils/walk-spans.ts
10
11
  /**
@@ -136,7 +137,10 @@ function addAgentAttributes(attributes, extensions) {
136
137
  if (truncatedTrips > 0) attributes["agent.truncatedTrips"] = truncatedTrips;
137
138
  const providerCompactions = extensions.trips.reduce((count, trip) => count + (trip.blocks?.filter((block) => block.type === "compaction").length ?? 0), 0);
138
139
  if (providerCompactions > 0) attributes["agent.providerCompactions"] = providerCompactions;
140
+ const refusals = extensions.trips.filter((trip) => trip.finishReason === "refusal").length;
141
+ if (refusals > 0) attributes["agent.refusals"] = refusals;
139
142
  }
143
+ if (typeof extensions.fallbackTrips === "number") attributes["agent.fallbackTrips"] = extensions.fallbackTrips;
140
144
  if (extensions.compactions?.length) attributes["agent.compactions"] = extensions.compactions.map((record) => ({
141
145
  type: record.type,
142
146
  tripIndex: record.tripIndex,
@@ -1997,6 +2001,22 @@ function findSpanById(root, spanId) {
1997
2001
  }
1998
2002
  }
1999
2003
 
2004
+ //#endregion
2005
+ //#region ../../packages/ai-panoptic/src/evaluate/get-evaluate-config.ts
2006
+ /**
2007
+ * The evaluate settings of the applied Panoptic config: `panoptic.evaluate`,
2008
+ * else `panoptic.dashboard.evaluate` when `dashboard` is an object, else
2009
+ * `undefined`. Devtools' Evaluate page reads it, so grading works while the
2010
+ * standalone dashboard stays off inside a Warlock app.
2011
+ */
2012
+ function getEvaluateConfig() {
2013
+ const panopticConfig = (0, _warlock_js_ai.getAIConfig)().panoptic;
2014
+ if (panopticConfig === void 0) return;
2015
+ if (panopticConfig.evaluate !== void 0) return panopticConfig.evaluate;
2016
+ const dashboardConfig = panopticConfig.dashboard;
2017
+ return typeof dashboardConfig === "object" ? dashboardConfig.evaluate : void 0;
2018
+ }
2019
+
2000
2020
  //#endregion
2001
2021
  //#region ../../packages/ai-panoptic/src/dashboard/parse-query.ts
2002
2022
  /**
@@ -4367,9 +4387,53 @@ function openBrowser(url) {
4367
4387
  }).catch(() => {});
4368
4388
  }
4369
4389
 
4390
+ //#endregion
4391
+ //#region ../../packages/ai-panoptic/src/config/warlock-app.ts
4392
+ /**
4393
+ * The global key `@warlock.js/devtools` publishes once its dashboard is
4394
+ * mounted (`{ path, mode }`). Spelled out here so Panoptic never imports
4395
+ * devtools.
4396
+ */
4397
+ const DEVTOOLS_MOUNTED_KEY = Symbol.for("@warlock.js/devtools.mounted");
4398
+ const CONFIG_FILES = [
4399
+ "warlock.config.ts",
4400
+ "warlock.config.js",
4401
+ "warlock.config.mjs",
4402
+ "warlock.config.cjs"
4403
+ ];
4404
+ /**
4405
+ * Whether this process is a Warlock app: devtools published its marker,
4406
+ * `warlock start` set `WARLOCK_BOOT_SIGNAL`, or a `warlock.config.ts`
4407
+ * (`.js`, `.mjs`, `.cjs`) sits in the working directory. Never throws.
4408
+ */
4409
+ function isInsideWarlockApp(probe = {}) {
4410
+ try {
4411
+ if ((probe.global ?? globalThis)[DEVTOOLS_MOUNTED_KEY]) return true;
4412
+ if ((probe.env ?? process.env).WARLOCK_BOOT_SIGNAL) return true;
4413
+ const cwd = (probe.cwd ?? (() => process.cwd()))();
4414
+ const exists = probe.exists ?? node_fs.existsSync;
4415
+ return CONFIG_FILES.some((file) => exists((0, node_path.join)(cwd, file)));
4416
+ } catch {
4417
+ return false;
4418
+ }
4419
+ }
4420
+ /**
4421
+ * The devtools path to point at: the marker's `path` when devtools is
4422
+ * mounted, otherwise `/__warlock`.
4423
+ */
4424
+ function devtoolsPathHint(probe = {}) {
4425
+ try {
4426
+ const marker = (probe.global ?? globalThis)[DEVTOOLS_MOUNTED_KEY];
4427
+ if (marker && typeof marker.path === "string" && marker.path !== "") return marker.path;
4428
+ } catch {}
4429
+ return "/__warlock";
4430
+ }
4431
+
4370
4432
  //#endregion
4371
4433
  //#region ../../packages/ai-panoptic/src/config/apply-panoptic-config.ts
4372
4434
  let applied;
4435
+ /** Whether the "dashboard does not start inside a Warlock app" notice was logged in this process. */
4436
+ let noticeLogged = false;
4373
4437
  /** Traces kept by the store panoptic creates for the dashboard, unless `capacity` says otherwise. */
4374
4438
  const DEFAULT_DASHBOARD_STORE_CAPACITY = 1e3;
4375
4439
  /**
@@ -4396,10 +4460,18 @@ function applyPanopticConfig(config) {
4396
4460
  if (config === void 0) return;
4397
4461
  (0, _warlock_js_ai.setObserveAll)(Boolean(config.observeAll));
4398
4462
  if (applied === void 0) {
4463
+ let dashboardConfig = config.dashboard;
4464
+ if (dashboardConfig && isInsideWarlockApp() && !isStandalone(dashboardConfig)) {
4465
+ dashboardConfig = void 0;
4466
+ if (!noticeLogged) {
4467
+ noticeLogged = true;
4468
+ _warlock_js_logger.log.info("ai-panoptic", "dashboard", `Panoptic's dashboard does not start inside a Warlock app. Its views are in devtools under AI at ${devtoolsPathHint()} (install devtools with \`warlock add devtools\`). Set panoptic.dashboard.standalone to true to start it anyway.`);
4469
+ }
4470
+ }
4399
4471
  const exporters = [...config.exporters ?? []];
4400
4472
  let store = findStore(exporters);
4401
4473
  let cacheStore;
4402
- if (store === void 0 && config.dashboard) {
4474
+ if (store === void 0 && dashboardConfig) {
4403
4475
  const capacity = config.capacity ?? 1e3;
4404
4476
  if (config.cache !== void 0) {
4405
4477
  const onError = config.onError ?? ((error) => _warlock_js_logger.log.error("ai-panoptic", "cacheStore", error));
@@ -4418,9 +4490,9 @@ function applyPanopticConfig(config) {
4418
4490
  });
4419
4491
  (0, _warlock_js_ai.registerObserver)(toObserver(panopticInstance));
4420
4492
  applied = { panopticInstance };
4421
- if (config.dashboard && store !== void 0) {
4493
+ if (dashboardConfig && store !== void 0) {
4422
4494
  const resolvedStore = store;
4423
- (cacheStore !== void 0 ? cacheStore.ready() : Promise.resolve()).catch(() => {}).then(() => startDashboard(resolvedStore, config.dashboard ?? {})).then((handle) => {
4495
+ (cacheStore !== void 0 ? cacheStore.ready() : Promise.resolve()).catch(() => {}).then(() => startDashboard(resolvedStore, dashboardConfig ?? {})).then((handle) => {
4424
4496
  if (applied !== void 0) applied.dashboardHandle = handle;
4425
4497
  });
4426
4498
  }
@@ -4454,6 +4526,10 @@ function findStore(exporters) {
4454
4526
  function startDashboard(store, dashboardConfig) {
4455
4527
  return dashboard(store, typeof dashboardConfig === "object" ? dashboardConfig : {});
4456
4528
  }
4529
+ /** Whether the dashboard options force the standalone server. */
4530
+ function isStandalone(dashboardConfig) {
4531
+ return typeof dashboardConfig === "object" && dashboardConfig.standalone === true;
4532
+ }
4457
4533
 
4458
4534
  //#endregion
4459
4535
  //#region ../../packages/ai-panoptic/src/register.ts
@@ -4476,6 +4552,7 @@ exports.createCollector = createCollector;
4476
4552
  exports.createInMemoryTraceStore = createInMemoryTraceStore;
4477
4553
  exports.createPanopticMiddleware = createPanopticMiddleware;
4478
4554
  exports.dashboard = dashboard;
4555
+ exports.devtoolsPathHint = devtoolsPathHint;
4479
4556
  exports.emptyUsage = emptyUsage;
4480
4557
  exports.evaluateSystemPrompt = evaluateSystemPrompt;
4481
4558
  exports.extractLastSystemPrompt = extractLastSystemPrompt;
@@ -4485,10 +4562,12 @@ exports.filterTraces = filterTraces;
4485
4562
  exports.findSpanById = findSpanById;
4486
4563
  exports.formatSpanIO = formatSpanIO;
4487
4564
  exports.formatSpanLine = formatSpanLine;
4565
+ exports.getEvaluateConfig = getEvaluateConfig;
4488
4566
  exports.groupByPrompt = groupByPrompt;
4489
4567
  exports.groupBySession = groupBySession;
4490
4568
  exports.groupByType = groupByType;
4491
4569
  exports.heatIntensity = heatIntensity;
4570
+ exports.isInsideWarlockApp = isInsideWarlockApp;
4492
4571
  exports.langfuseExporter = langfuseExporter;
4493
4572
  exports.matchTrace = matchTrace;
4494
4573
  exports.matchesFilter = matchesFilter;