@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.
@@ -1 +1 @@
1
- {"version":3,"file":"extract-span-attributes.d.mts","names":[],"sources":["../../../../../../../../packages/ai-panoptic/src/collector/extract-span-attributes.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;wBAyDgB,sBAAsB,QAAQ,aAAa"}
1
+ {"version":3,"file":"extract-span-attributes.d.mts","names":[],"sources":["../../../../../../../../packages/ai-panoptic/src/collector/extract-span-attributes.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;wBA0DgB,sBAAsB,QAAQ,aAAa"}
@@ -61,7 +61,10 @@ function addAgentAttributes(attributes, extensions) {
61
61
  if (truncatedTrips > 0) attributes["agent.truncatedTrips"] = truncatedTrips;
62
62
  const providerCompactions = extensions.trips.reduce((count, trip) => count + (trip.blocks?.filter((block) => block.type === "compaction").length ?? 0), 0);
63
63
  if (providerCompactions > 0) attributes["agent.providerCompactions"] = providerCompactions;
64
+ const refusals = extensions.trips.filter((trip) => trip.finishReason === "refusal").length;
65
+ if (refusals > 0) attributes["agent.refusals"] = refusals;
64
66
  }
67
+ if (typeof extensions.fallbackTrips === "number") attributes["agent.fallbackTrips"] = extensions.fallbackTrips;
65
68
  if (extensions.compactions?.length) attributes["agent.compactions"] = extensions.compactions.map((record) => ({
66
69
  type: record.type,
67
70
  tripIndex: record.tripIndex,
@@ -1 +1 @@
1
- {"version":3,"file":"extract-span-attributes.mjs","names":[],"sources":["../../../../../../../../packages/ai-panoptic/src/collector/extract-span-attributes.ts"],"sourcesContent":["import type { AgentCompactionRecord, BaseReport, LLMTrip } from \"@warlock.js/ai\";\n\n/**\n * Per-primitive `BaseReport` extension fields the collector surfaces as\n * span attributes. Declared as a structural superset (every field\n * optional) so a single reader can pull whatever the concrete report\n * carried without narrowing on `type` first — a `BaseReport` widened to\n * this shape exposes `undefined` for the fields its primitive doesn't\n * set, and the extractor simply skips those.\n *\n * Mirrors the public per-primitive report types in `@warlock.js/ai`\n * (`AgentReport`, `WorkflowReport`, `SupervisorReport`,\n * `OrchestratorReport`, `ToolCall`) — kept structural rather than a\n * union import so adding a new optional report field upstream is a\n * non-breaking read here.\n */\ntype ReportExtensions = {\n model?: { name?: string; provider?: string };\n trips?: LLMTrip[];\n compactions?: AgentCompactionRecord[];\n promptName?: string;\n promptVersion?: string;\n workflowName?: string;\n supervisorName?: string;\n signature?: string;\n terminatedBy?: string;\n iterations?: number;\n steps?: Record<string, unknown>;\n turns?: unknown[];\n turnIndex?: number;\n tripIndex?: number;\n callId?: string;\n recoveredFrom?: string;\n};\n\n/**\n * Build the free-form `TraceSpan.attributes` bag for one report node.\n *\n * The collector keeps the first-class span fields (identity, timing,\n * status, usage, error) on the span itself and routes everything\n * primitive-specific here — trip/step/iteration counts, the model\n * identity an agent ran against, the tool's originating trip index, a\n * supervisor's termination reason. Exporters forward this verbatim as\n * backend span attributes (OTel attributes, Langfuse metadata).\n *\n * Only populated keys are emitted; the function returns `undefined`\n * when the node carried no extra detail, so the optional\n * `TraceSpan.attributes` field stays absent rather than holding an\n * empty object (matches the contract's \"absent when empty\" note).\n *\n * Retry count is surfaced from the shared `BaseReport.attempts` for\n * every primitive so cost dashboards see the real call count.\n *\n * @example\n * const attributes = extractSpanAttributes(agentReport);\n * // { \"agent.trips\": 3, \"agent.model.name\": \"gpt-4o\", \"agent.model.provider\": \"openai\" }\n */\nexport function extractSpanAttributes(report: BaseReport): Record<string, unknown> | undefined {\n const extensions = report as BaseReport & ReportExtensions;\n const attributes: Record<string, unknown> = {};\n\n if (report.attempts !== undefined && report.attempts.length > 0) {\n attributes[\"retries\"] = report.attempts.length;\n attributes[\"retry.attempts\"] = report.attempts.map((attempt) => ({\n index: attempt.index,\n startedAt: attempt.startedAt,\n endedAt: attempt.endedAt,\n duration: attempt.duration,\n status: attempt.status,\n }));\n }\n\n switch (report.type) {\n case \"agent\": {\n addAgentAttributes(attributes, extensions);\n break;\n }\n\n case \"workflow\": {\n addWorkflowAttributes(attributes, extensions);\n break;\n }\n\n case \"supervisor\":\n case \"team\": {\n // ai.team reuses the supervisor engine, so a team report carries the\n // same supervisorName / terminatedBy / iterations fields.\n addSupervisorAttributes(attributes, extensions);\n break;\n }\n\n case \"orchestrator\": {\n addOrchestratorAttributes(attributes, extensions);\n break;\n }\n\n case \"tool\": {\n addToolAttributes(attributes, extensions);\n break;\n }\n\n default: {\n break;\n }\n }\n\n if (Object.keys(attributes).length === 0) {\n return undefined;\n }\n\n return attributes;\n}\n\nfunction addAgentAttributes(\n attributes: Record<string, unknown>,\n extensions: ReportExtensions,\n): void {\n if (Array.isArray(extensions.trips)) {\n attributes[\"agent.trips\"] = extensions.trips.length;\n // Reported provider cache reads only. Zero-token synthetic responses do\n // not identify semantic-cache hits in the core report contract.\n if (extensions.trips.some((trip) => trip.usage?.cachedTokens !== undefined)) {\n attributes[\"agent.cacheHits\"] = extensions.trips.filter(\n (trip) => (trip.usage?.cachedTokens ?? 0) > 0,\n ).length;\n }\n const truncatedTrips = extensions.trips.filter(\n (trip) => trip.finishReason === \"length\" || trip.finishReason === \"context_exceeded\",\n ).length;\n if (truncatedTrips > 0) attributes[\"agent.truncatedTrips\"] = truncatedTrips;\n const providerCompactions = extensions.trips.reduce(\n (count, trip) =>\n count + (trip.blocks?.filter((block) => block.type === \"compaction\").length ?? 0),\n 0,\n );\n if (providerCompactions > 0) attributes[\"agent.providerCompactions\"] = providerCompactions;\n }\n\n if (extensions.compactions?.length) {\n // Do not copy summary text, callback errors or raw conversation content.\n attributes[\"agent.compactions\"] = extensions.compactions.map((record) => ({\n type: record.type,\n tripIndex: record.tripIndex,\n inputTokens: record.inputTokens,\n counting: record.counting,\n reason: record.reason,\n ...(record.compaction\n ? {\n replacesFromIndex: record.compaction.replacesFromIndex,\n replacesToIndex: record.compaction.replacesToIndex,\n }\n : {}),\n }));\n }\n\n if (extensions.model?.name !== undefined) {\n attributes[\"agent.model.name\"] = extensions.model.name;\n }\n\n if (extensions.model?.provider !== undefined) {\n attributes[\"agent.model.provider\"] = extensions.model.provider;\n }\n\n // Prompt-version linkage (core `AgentReport.promptName` / `promptVersion`).\n // Present only when the agent ran against a *named* `ai.prompts` builder;\n // surfaced so the dashboard can group / filter runs by `name@version` and\n // attribute behavior shifts to a specific prompt revision.\n if (extensions.promptName !== undefined) {\n attributes[\"agent.promptName\"] = extensions.promptName;\n }\n\n if (extensions.promptVersion !== undefined) {\n attributes[\"agent.promptVersion\"] = extensions.promptVersion;\n }\n}\n\nfunction addWorkflowAttributes(\n attributes: Record<string, unknown>,\n extensions: ReportExtensions,\n): void {\n if (extensions.workflowName !== undefined) {\n attributes[\"workflow.name\"] = extensions.workflowName;\n }\n\n if (extensions.signature !== undefined) {\n attributes[\"workflow.signature\"] = extensions.signature;\n }\n\n if (extensions.steps !== undefined) {\n attributes[\"workflow.steps\"] = Object.keys(extensions.steps).length;\n }\n}\n\nfunction addSupervisorAttributes(\n attributes: Record<string, unknown>,\n extensions: ReportExtensions,\n): void {\n if (extensions.supervisorName !== undefined) {\n attributes[\"supervisor.name\"] = extensions.supervisorName;\n }\n\n if (extensions.terminatedBy !== undefined) {\n attributes[\"supervisor.terminatedBy\"] = extensions.terminatedBy;\n }\n\n if (extensions.iterations !== undefined) {\n attributes[\"supervisor.iterations\"] = extensions.iterations;\n }\n}\n\nfunction addOrchestratorAttributes(\n attributes: Record<string, unknown>,\n extensions: ReportExtensions,\n): void {\n if (extensions.turnIndex !== undefined) {\n attributes[\"orchestrator.turnIndex\"] = extensions.turnIndex;\n }\n\n if (extensions.signature !== undefined) {\n attributes[\"orchestrator.signature\"] = extensions.signature;\n }\n\n if (Array.isArray(extensions.turns)) {\n attributes[\"orchestrator.turns\"] = extensions.turns.length;\n }\n}\n\nfunction addToolAttributes(\n attributes: Record<string, unknown>,\n extensions: ReportExtensions,\n): void {\n if (extensions.tripIndex !== undefined) {\n attributes[\"tool.tripIndex\"] = extensions.tripIndex;\n }\n\n if (extensions.callId !== undefined) {\n attributes[\"tool.callId\"] = extensions.callId;\n }\n\n if (extensions.recoveredFrom !== undefined) {\n attributes[\"tool.recoveredFrom\"] = extensions.recoveredFrom;\n }\n}\n"],"mappings":"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"}
1
+ {"version":3,"file":"extract-span-attributes.mjs","names":[],"sources":["../../../../../../../../packages/ai-panoptic/src/collector/extract-span-attributes.ts"],"sourcesContent":["import type { AgentCompactionRecord, BaseReport, LLMTrip } from \"@warlock.js/ai\";\n\n/**\n * Per-primitive `BaseReport` extension fields the collector surfaces as\n * span attributes. Declared as a structural superset (every field\n * optional) so a single reader can pull whatever the concrete report\n * carried without narrowing on `type` first — a `BaseReport` widened to\n * this shape exposes `undefined` for the fields its primitive doesn't\n * set, and the extractor simply skips those.\n *\n * Mirrors the public per-primitive report types in `@warlock.js/ai`\n * (`AgentReport`, `WorkflowReport`, `SupervisorReport`,\n * `OrchestratorReport`, `ToolCall`) — kept structural rather than a\n * union import so adding a new optional report field upstream is a\n * non-breaking read here.\n */\ntype ReportExtensions = {\n model?: { name?: string; provider?: string };\n trips?: LLMTrip[];\n compactions?: AgentCompactionRecord[];\n promptName?: string;\n promptVersion?: string;\n workflowName?: string;\n supervisorName?: string;\n signature?: string;\n terminatedBy?: string;\n iterations?: number;\n steps?: Record<string, unknown>;\n turns?: unknown[];\n turnIndex?: number;\n tripIndex?: number;\n callId?: string;\n recoveredFrom?: string;\n fallbackTrips?: number;\n};\n\n/**\n * Build the free-form `TraceSpan.attributes` bag for one report node.\n *\n * The collector keeps the first-class span fields (identity, timing,\n * status, usage, error) on the span itself and routes everything\n * primitive-specific here — trip/step/iteration counts, the model\n * identity an agent ran against, the tool's originating trip index, a\n * supervisor's termination reason. Exporters forward this verbatim as\n * backend span attributes (OTel attributes, Langfuse metadata).\n *\n * Only populated keys are emitted; the function returns `undefined`\n * when the node carried no extra detail, so the optional\n * `TraceSpan.attributes` field stays absent rather than holding an\n * empty object (matches the contract's \"absent when empty\" note).\n *\n * Retry count is surfaced from the shared `BaseReport.attempts` for\n * every primitive so cost dashboards see the real call count.\n *\n * @example\n * const attributes = extractSpanAttributes(agentReport);\n * // { \"agent.trips\": 3, \"agent.model.name\": \"gpt-4o\", \"agent.model.provider\": \"openai\" }\n */\nexport function extractSpanAttributes(report: BaseReport): Record<string, unknown> | undefined {\n const extensions = report as BaseReport & ReportExtensions;\n const attributes: Record<string, unknown> = {};\n\n if (report.attempts !== undefined && report.attempts.length > 0) {\n attributes[\"retries\"] = report.attempts.length;\n attributes[\"retry.attempts\"] = report.attempts.map((attempt) => ({\n index: attempt.index,\n startedAt: attempt.startedAt,\n endedAt: attempt.endedAt,\n duration: attempt.duration,\n status: attempt.status,\n }));\n }\n\n switch (report.type) {\n case \"agent\": {\n addAgentAttributes(attributes, extensions);\n break;\n }\n\n case \"workflow\": {\n addWorkflowAttributes(attributes, extensions);\n break;\n }\n\n case \"supervisor\":\n case \"team\": {\n // ai.team reuses the supervisor engine, so a team report carries the\n // same supervisorName / terminatedBy / iterations fields.\n addSupervisorAttributes(attributes, extensions);\n break;\n }\n\n case \"orchestrator\": {\n addOrchestratorAttributes(attributes, extensions);\n break;\n }\n\n case \"tool\": {\n addToolAttributes(attributes, extensions);\n break;\n }\n\n default: {\n break;\n }\n }\n\n if (Object.keys(attributes).length === 0) {\n return undefined;\n }\n\n return attributes;\n}\n\nfunction addAgentAttributes(\n attributes: Record<string, unknown>,\n extensions: ReportExtensions,\n): void {\n if (Array.isArray(extensions.trips)) {\n attributes[\"agent.trips\"] = extensions.trips.length;\n // Reported provider cache reads only. Zero-token synthetic responses do\n // not identify semantic-cache hits in the core report contract.\n if (extensions.trips.some((trip) => trip.usage?.cachedTokens !== undefined)) {\n attributes[\"agent.cacheHits\"] = extensions.trips.filter(\n (trip) => (trip.usage?.cachedTokens ?? 0) > 0,\n ).length;\n }\n const truncatedTrips = extensions.trips.filter(\n (trip) => trip.finishReason === \"length\" || trip.finishReason === \"context_exceeded\",\n ).length;\n if (truncatedTrips > 0) attributes[\"agent.truncatedTrips\"] = truncatedTrips;\n const providerCompactions = extensions.trips.reduce(\n (count, trip) =>\n count + (trip.blocks?.filter((block) => block.type === \"compaction\").length ?? 0),\n 0,\n );\n if (providerCompactions > 0) attributes[\"agent.providerCompactions\"] = providerCompactions;\n const refusals = extensions.trips.filter((trip) => trip.finishReason === \"refusal\").length;\n if (refusals > 0) attributes[\"agent.refusals\"] = refusals;\n }\n\n if (typeof extensions.fallbackTrips === \"number\") {\n attributes[\"agent.fallbackTrips\"] = extensions.fallbackTrips;\n }\n\n if (extensions.compactions?.length) {\n // Do not copy summary text, callback errors or raw conversation content.\n attributes[\"agent.compactions\"] = extensions.compactions.map((record) => ({\n type: record.type,\n tripIndex: record.tripIndex,\n inputTokens: record.inputTokens,\n counting: record.counting,\n reason: record.reason,\n ...(record.compaction\n ? {\n replacesFromIndex: record.compaction.replacesFromIndex,\n replacesToIndex: record.compaction.replacesToIndex,\n }\n : {}),\n }));\n }\n\n if (extensions.model?.name !== undefined) {\n attributes[\"agent.model.name\"] = extensions.model.name;\n }\n\n if (extensions.model?.provider !== undefined) {\n attributes[\"agent.model.provider\"] = extensions.model.provider;\n }\n\n // Prompt-version linkage (core `AgentReport.promptName` / `promptVersion`).\n // Present only when the agent ran against a *named* `ai.prompts` builder;\n // surfaced so the dashboard can group / filter runs by `name@version` and\n // attribute behavior shifts to a specific prompt revision.\n if (extensions.promptName !== undefined) {\n attributes[\"agent.promptName\"] = extensions.promptName;\n }\n\n if (extensions.promptVersion !== undefined) {\n attributes[\"agent.promptVersion\"] = extensions.promptVersion;\n }\n}\n\nfunction addWorkflowAttributes(\n attributes: Record<string, unknown>,\n extensions: ReportExtensions,\n): void {\n if (extensions.workflowName !== undefined) {\n attributes[\"workflow.name\"] = extensions.workflowName;\n }\n\n if (extensions.signature !== undefined) {\n attributes[\"workflow.signature\"] = extensions.signature;\n }\n\n if (extensions.steps !== undefined) {\n attributes[\"workflow.steps\"] = Object.keys(extensions.steps).length;\n }\n}\n\nfunction addSupervisorAttributes(\n attributes: Record<string, unknown>,\n extensions: ReportExtensions,\n): void {\n if (extensions.supervisorName !== undefined) {\n attributes[\"supervisor.name\"] = extensions.supervisorName;\n }\n\n if (extensions.terminatedBy !== undefined) {\n attributes[\"supervisor.terminatedBy\"] = extensions.terminatedBy;\n }\n\n if (extensions.iterations !== undefined) {\n attributes[\"supervisor.iterations\"] = extensions.iterations;\n }\n}\n\nfunction addOrchestratorAttributes(\n attributes: Record<string, unknown>,\n extensions: ReportExtensions,\n): void {\n if (extensions.turnIndex !== undefined) {\n attributes[\"orchestrator.turnIndex\"] = extensions.turnIndex;\n }\n\n if (extensions.signature !== undefined) {\n attributes[\"orchestrator.signature\"] = extensions.signature;\n }\n\n if (Array.isArray(extensions.turns)) {\n attributes[\"orchestrator.turns\"] = extensions.turns.length;\n }\n}\n\nfunction addToolAttributes(\n attributes: Record<string, unknown>,\n extensions: ReportExtensions,\n): void {\n if (extensions.tripIndex !== undefined) {\n attributes[\"tool.tripIndex\"] = extensions.tripIndex;\n }\n\n if (extensions.callId !== undefined) {\n attributes[\"tool.callId\"] = extensions.callId;\n }\n\n if (extensions.recoveredFrom !== undefined) {\n attributes[\"tool.recoveredFrom\"] = extensions.recoveredFrom;\n }\n}\n"],"mappings":"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"}
@@ -1 +1 @@
1
- {"version":3,"file":"apply-panoptic-config.d.mts","names":[],"sources":["../../../../../../../../packages/ai-panoptic/src/config/apply-panoptic-config.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;wBAoDgB,oBAAoB,SAAS"}
1
+ {"version":3,"file":"apply-panoptic-config.d.mts","names":[],"sources":["../../../../../../../../packages/ai-panoptic/src/config/apply-panoptic-config.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;wBAwDgB,oBAAoB,SAAS"}
@@ -2,11 +2,14 @@ import { createCacheTraceStore } from "../store/cache-trace-store.mjs";
2
2
  import { createInMemoryTraceStore } from "../store/in-memory-trace-store.mjs";
3
3
  import { panoptic } from "../panoptic/panoptic.mjs";
4
4
  import { dashboard } from "../dashboard/dashboard.mjs";
5
+ import { devtoolsPathHint, isInsideWarlockApp } from "./warlock-app.mjs";
5
6
  import { registerObserver, setObserveAll } from "@warlock.js/ai";
6
7
  import { log } from "@warlock.js/logger";
7
8
 
8
9
  //#region ../../packages/ai-panoptic/src/config/apply-panoptic-config.ts
9
10
  let applied;
11
+ /** Whether the "dashboard does not start inside a Warlock app" notice was logged in this process. */
12
+ let noticeLogged = false;
10
13
  /** Traces kept by the store panoptic creates for the dashboard, unless `capacity` says otherwise. */
11
14
  const DEFAULT_DASHBOARD_STORE_CAPACITY = 1e3;
12
15
  /**
@@ -33,10 +36,18 @@ function applyPanopticConfig(config) {
33
36
  if (config === void 0) return;
34
37
  setObserveAll(Boolean(config.observeAll));
35
38
  if (applied === void 0) {
39
+ let dashboardConfig = config.dashboard;
40
+ if (dashboardConfig && isInsideWarlockApp() && !isStandalone(dashboardConfig)) {
41
+ dashboardConfig = void 0;
42
+ if (!noticeLogged) {
43
+ noticeLogged = true;
44
+ 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.`);
45
+ }
46
+ }
36
47
  const exporters = [...config.exporters ?? []];
37
48
  let store = findStore(exporters);
38
49
  let cacheStore;
39
- if (store === void 0 && config.dashboard) {
50
+ if (store === void 0 && dashboardConfig) {
40
51
  const capacity = config.capacity ?? 1e3;
41
52
  if (config.cache !== void 0) {
42
53
  const onError = config.onError ?? ((error) => log.error("ai-panoptic", "cacheStore", error));
@@ -55,9 +66,9 @@ function applyPanopticConfig(config) {
55
66
  });
56
67
  registerObserver(toObserver(panopticInstance));
57
68
  applied = { panopticInstance };
58
- if (config.dashboard && store !== void 0) {
69
+ if (dashboardConfig && store !== void 0) {
59
70
  const resolvedStore = store;
60
- (cacheStore !== void 0 ? cacheStore.ready() : Promise.resolve()).catch(() => {}).then(() => startDashboard(resolvedStore, config.dashboard ?? {})).then((handle) => {
71
+ (cacheStore !== void 0 ? cacheStore.ready() : Promise.resolve()).catch(() => {}).then(() => startDashboard(resolvedStore, dashboardConfig ?? {})).then((handle) => {
61
72
  if (applied !== void 0) applied.dashboardHandle = handle;
62
73
  });
63
74
  }
@@ -91,6 +102,10 @@ function findStore(exporters) {
91
102
  function startDashboard(store, dashboardConfig) {
92
103
  return dashboard(store, typeof dashboardConfig === "object" ? dashboardConfig : {});
93
104
  }
105
+ /** Whether the dashboard options force the standalone server. */
106
+ function isStandalone(dashboardConfig) {
107
+ return typeof dashboardConfig === "object" && dashboardConfig.standalone === true;
108
+ }
94
109
 
95
110
  //#endregion
96
111
  export { DEFAULT_DASHBOARD_STORE_CAPACITY, applyPanopticConfig };
@@ -1 +1 @@
1
- {"version":3,"file":"apply-panoptic-config.mjs","names":[],"sources":["../../../../../../../../packages/ai-panoptic/src/config/apply-panoptic-config.ts"],"sourcesContent":["import type { ExecutionReport, Observer } from \"@warlock.js/ai\";\nimport { registerObserver, setObserveAll } from \"@warlock.js/ai\";\nimport { log } from \"@warlock.js/logger\";\nimport type { ExporterContract } from \"../contracts/exporter.contract\";\nimport { dashboard } from \"../dashboard/dashboard\";\nimport type { DashboardHandle, DashboardOptions } from \"../dashboard/dashboard.type\";\nimport { panoptic } from \"../panoptic/panoptic\";\nimport type { Panoptic } from \"../panoptic/panoptic.type\";\nimport { createCacheTraceStore } from \"../store/cache-trace-store\";\nimport type { CacheTraceStoreHandle } from \"../store/cache-trace-store\";\nimport { createInMemoryTraceStore } from \"../store/in-memory-trace-store\";\nimport type { TraceStoreContract } from \"../store/trace-store.contract\";\nimport type { PanopticConfig } from \"./panoptic-config.type\";\n\n/**\n * Module-level applied state. Applying panoptic config is idempotent:\n * the collector is registered as a core `Observer` exactly once, the\n * dashboard is started at most once, and repeat calls only refresh the\n * `observeAll` flag (the latest config wins) without double-registering.\n */\ntype AppliedState = {\n /** The single collector registered as a core `Observer`. */\n panopticInstance: Panoptic;\n /** The dashboard handle, once started. Started at most once. */\n dashboardHandle?: DashboardHandle;\n};\n\nlet applied: AppliedState | undefined;\n\n/** Traces kept by the store panoptic creates for the dashboard, unless `capacity` says otherwise. */\nexport const DEFAULT_DASHBOARD_STORE_CAPACITY = 1000;\n\n/**\n * Read a {@link PanopticConfig} and wire panoptic onto the core observe\n * seam — the bridge `ai.config({ panoptic })` resolves through. Builds a\n * collector via the EXISTING {@link panoptic} factory (reusing its\n * collection pipeline, not reinventing it), registers it once via core's\n * `registerObserver` (the subscriber's `collect(report)` structurally IS\n * an {@link Observer}, threaded through a thin wrapper), sets\n * `observeAll`, and — when `config.dashboard` is set — starts the\n * dashboard over the config's store (a store-shaped exporter, or a fresh\n * in-memory store panoptic registers when none was supplied).\n *\n * **Idempotent.** Safe to call on every `onConfigApplied` notification:\n * the observer is registered once, the dashboard started once. Repeat\n * calls update `observeAll` to the latest value but never double-register\n * or double-start. `undefined` config is a no-op (nothing wired).\n *\n * @returns the resolved store-shaped exporter when the dashboard needs\n * one and a fresh store was created — primarily for tests; callers can\n * ignore it.\n */\nexport function applyPanopticConfig(config?: PanopticConfig): void {\n if (config === undefined) {\n return;\n }\n\n // observeAll always tracks the latest config, even on a repeat call.\n setObserveAll(Boolean(config.observeAll));\n\n if (applied === undefined) {\n const exporters = [...(config.exporters ?? [])];\n let store = findStore(exporters);\n\n // Track a cache store separately so we can await its hydration before\n // the dashboard reads it — the in-memory store needs no warm-up.\n let cacheStore: CacheTraceStoreHandle | undefined;\n\n // The dashboard needs a queryable store. If none was supplied via\n // exporters but a dashboard is requested, create one and register it\n // as an exporter so the collector fills it. A configured `cache` picks\n // the durable cache-backed store; otherwise fall back to in-memory so\n // the dashboard works with no cache configured.\n if (store === undefined && config.dashboard) {\n const capacity = config.capacity ?? DEFAULT_DASHBOARD_STORE_CAPACITY;\n\n if (config.cache !== undefined) {\n const onError =\n config.onError ?? ((error: unknown) => log.error(\"ai-panoptic\", \"cacheStore\", error));\n\n cacheStore = createCacheTraceStore(config.cache, { onError, capacity });\n store = cacheStore;\n } else {\n store = createInMemoryTraceStore({ capacity });\n }\n\n exporters.push(store as unknown as ExporterContract);\n }\n\n const panopticInstance = panoptic({\n exporters,\n captureContent: config.captureContent,\n fullHistory: config.fullHistory,\n });\n registerObserver(toObserver(panopticInstance));\n\n applied = { panopticInstance };\n\n if (config.dashboard && store !== undefined) {\n const resolvedStore = store;\n\n // Hydrate the cache mirror (if any) before serving, so a restart\n // surfaces previously-persisted traces immediately. A bare in-memory\n // store resolves the readyGate instantly.\n const readyGate = cacheStore !== undefined ? cacheStore.ready() : Promise.resolve();\n\n void readyGate\n .catch(() => {\n // Hydration is best-effort — never block the dashboard on it.\n })\n .then(() => startDashboard(resolvedStore, config.dashboard ?? {}))\n .then((handle) => {\n if (applied !== undefined) {\n applied.dashboardHandle = handle;\n }\n });\n }\n }\n}\n\n/**\n * Reset the applied state — internal, test-only. Closes any running\n * dashboard and forgets the registered collector so a fresh\n * `applyPanopticConfig` starts clean. NOT part of the public surface and\n * does NOT unregister from the core observer registry (use core's\n * `clearObservers` for that in tests).\n */\nexport async function resetAppliedPanopticConfig(): Promise<void> {\n const handle = applied?.dashboardHandle;\n applied = undefined;\n\n if (handle !== undefined) {\n await handle.close();\n }\n}\n\n/**\n * The currently-running dashboard handle, or `undefined` when no\n * dashboard is active. Internal, test-only — lets a spec await the\n * asynchronously-started dashboard. NOT part of the public surface.\n */\nexport function getActiveDashboardHandle(): DashboardHandle | undefined {\n return applied?.dashboardHandle;\n}\n\n/**\n * Wrap a {@link Panoptic} subscriber as a core {@link Observer}. The\n * subscriber already exposes `collect(report)` with a matching signature,\n * but the thin wrapper makes the structural adaptation explicit and keeps\n * the registered object a minimal `Observer` rather than the whole\n * subscriber surface.\n */\nfunction toObserver(instance: Panoptic): Observer {\n return {\n collect(report: ExecutionReport): Promise<void> {\n return instance.collect(report);\n },\n };\n}\n\n/**\n * Find the first exporter that satisfies the {@link TraceStoreContract}\n * read surface (`query` / `get` / `aggregate`) — the in-memory store\n * doubles as an exporter, so a store passed via `exporters` is reused for\n * the dashboard rather than creating a second one.\n */\nfunction findStore(exporters: ExporterContract[]): TraceStoreContract | undefined {\n for (const exporter of exporters) {\n const candidate = exporter as unknown as Partial<TraceStoreContract>;\n\n if (\n typeof candidate.query === \"function\" &&\n typeof candidate.get === \"function\" &&\n typeof candidate.aggregate === \"function\"\n ) {\n return candidate as TraceStoreContract;\n }\n }\n\n return undefined;\n}\n\n/** Start the dashboard, normalizing the `true | DashboardOptions` switch. */\nfunction startDashboard(\n store: TraceStoreContract,\n dashboardConfig: boolean | DashboardOptions,\n): Promise<DashboardHandle> {\n const options: DashboardOptions = typeof dashboardConfig === \"object\" ? dashboardConfig : {};\n\n return dashboard(store, options);\n}\n"],"mappings":";;;;;;;;AA2BA,IAAI;;AAGJ,MAAa,mCAAmC;;;;;;;;;;;;;;;;;;;;;AAsBhD,SAAgB,oBAAoB,QAA+B;CACjE,IAAI,WAAW,QACb;CAIF,cAAc,QAAQ,OAAO,UAAU,CAAC;CAExC,IAAI,YAAY,QAAW;EACzB,MAAM,YAAY,CAAC,GAAI,OAAO,aAAa,CAAC,CAAE;EAC9C,IAAI,QAAQ,UAAU,SAAS;EAI/B,IAAI;EAOJ,IAAI,UAAU,UAAa,OAAO,WAAW;GAC3C,MAAM,WAAW,OAAO;GAExB,IAAI,OAAO,UAAU,QAAW;IAC9B,MAAM,UACJ,OAAO,aAAa,UAAmB,IAAI,MAAM,eAAe,cAAc,KAAK;IAErF,aAAa,sBAAsB,OAAO,OAAO;KAAE;KAAS;IAAS,CAAC;IACtE,QAAQ;GACV,OACE,QAAQ,yBAAyB,EAAE,SAAS,CAAC;GAG/C,UAAU,KAAK,KAAoC;EACrD;EAEA,MAAM,mBAAmB,SAAS;GAChC;GACA,gBAAgB,OAAO;GACvB,aAAa,OAAO;EACtB,CAAC;EACD,iBAAiB,WAAW,gBAAgB,CAAC;EAE7C,UAAU,EAAE,iBAAiB;EAE7B,IAAI,OAAO,aAAa,UAAU,QAAW;GAC3C,MAAM,gBAAgB;GAOtB,CAFkB,eAAe,SAAY,WAAW,MAAM,IAAI,QAAQ,QAAQ,EAEpE,CACX,YAAY,CAEb,CAAC,CAAC,CACD,WAAW,eAAe,eAAe,OAAO,aAAa,CAAC,CAAC,CAAC,CAAC,CACjE,MAAM,WAAW;IAChB,IAAI,YAAY,QACd,QAAQ,kBAAkB;GAE9B,CAAC;EACL;CACF;AACF;;;;;;;;AAkCA,SAAS,WAAW,UAA8B;CAChD,OAAO,EACL,QAAQ,QAAwC;EAC9C,OAAO,SAAS,QAAQ,MAAM;CAChC,EACF;AACF;;;;;;;AAQA,SAAS,UAAU,WAA+D;CAChF,KAAK,MAAM,YAAY,WAAW;EAChC,MAAM,YAAY;EAElB,IACE,OAAO,UAAU,UAAU,cAC3B,OAAO,UAAU,QAAQ,cACzB,OAAO,UAAU,cAAc,YAE/B,OAAO;CAEX;AAGF;;AAGA,SAAS,eACP,OACA,iBAC0B;CAG1B,OAAO,UAAU,OAFiB,OAAO,oBAAoB,WAAW,kBAAkB,CAAC,CAE5D;AACjC"}
1
+ {"version":3,"file":"apply-panoptic-config.mjs","names":[],"sources":["../../../../../../../../packages/ai-panoptic/src/config/apply-panoptic-config.ts"],"sourcesContent":["import type { ExecutionReport, Observer } from \"@warlock.js/ai\";\nimport { registerObserver, setObserveAll } from \"@warlock.js/ai\";\nimport { log } from \"@warlock.js/logger\";\nimport type { ExporterContract } from \"../contracts/exporter.contract\";\nimport { dashboard } from \"../dashboard/dashboard\";\nimport type { DashboardHandle, DashboardOptions } from \"../dashboard/dashboard.type\";\nimport { panoptic } from \"../panoptic/panoptic\";\nimport type { Panoptic } from \"../panoptic/panoptic.type\";\nimport { createCacheTraceStore } from \"../store/cache-trace-store\";\nimport type { CacheTraceStoreHandle } from \"../store/cache-trace-store\";\nimport { createInMemoryTraceStore } from \"../store/in-memory-trace-store\";\nimport type { TraceStoreContract } from \"../store/trace-store.contract\";\nimport type { PanopticConfig } from \"./panoptic-config.type\";\nimport { devtoolsPathHint, isInsideWarlockApp } from \"./warlock-app\";\n\n/**\n * Module-level applied state. Applying panoptic config is idempotent:\n * the collector is registered as a core `Observer` exactly once, the\n * dashboard is started at most once, and repeat calls only refresh the\n * `observeAll` flag (the latest config wins) without double-registering.\n */\ntype AppliedState = {\n /** The single collector registered as a core `Observer`. */\n panopticInstance: Panoptic;\n /** The dashboard handle, once started. Started at most once. */\n dashboardHandle?: DashboardHandle;\n};\n\nlet applied: AppliedState | undefined;\n\n/** Whether the \"dashboard does not start inside a Warlock app\" notice was logged in this process. */\nlet noticeLogged = false;\n\n/** Traces kept by the store panoptic creates for the dashboard, unless `capacity` says otherwise. */\nexport const DEFAULT_DASHBOARD_STORE_CAPACITY = 1000;\n\n/**\n * Read a {@link PanopticConfig} and wire panoptic onto the core observe\n * seam — the bridge `ai.config({ panoptic })` resolves through. Builds a\n * collector via the EXISTING {@link panoptic} factory (reusing its\n * collection pipeline, not reinventing it), registers it once via core's\n * `registerObserver` (the subscriber's `collect(report)` structurally IS\n * an {@link Observer}, threaded through a thin wrapper), sets\n * `observeAll`, and — when `config.dashboard` is set — starts the\n * dashboard over the config's store (a store-shaped exporter, or a fresh\n * in-memory store panoptic registers when none was supplied).\n *\n * **Idempotent.** Safe to call on every `onConfigApplied` notification:\n * the observer is registered once, the dashboard started once. Repeat\n * calls update `observeAll` to the latest value but never double-register\n * or double-start. `undefined` config is a no-op (nothing wired).\n *\n * @returns the resolved store-shaped exporter when the dashboard needs\n * one and a fresh store was created — primarily for tests; callers can\n * ignore it.\n */\nexport function applyPanopticConfig(config?: PanopticConfig): void {\n if (config === undefined) {\n return;\n }\n\n // observeAll always tracks the latest config, even on a repeat call.\n setObserveAll(Boolean(config.observeAll));\n\n if (applied === undefined) {\n // Inside a Warlock app the devtools AI section replaces the standalone\n // dashboard, unless `dashboard.standalone` asks for it.\n let dashboardConfig = config.dashboard;\n\n if (dashboardConfig && isInsideWarlockApp() && !isStandalone(dashboardConfig)) {\n dashboardConfig = undefined;\n\n if (!noticeLogged) {\n noticeLogged = true;\n log.info(\n \"ai-panoptic\",\n \"dashboard\",\n `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.`,\n );\n }\n }\n\n const exporters = [...(config.exporters ?? [])];\n let store = findStore(exporters);\n\n // Track a cache store separately so we can await its hydration before\n // the dashboard reads it — the in-memory store needs no warm-up.\n let cacheStore: CacheTraceStoreHandle | undefined;\n\n // The dashboard needs a queryable store. If none was supplied via\n // exporters but a dashboard is requested, create one and register it\n // as an exporter so the collector fills it. A configured `cache` picks\n // the durable cache-backed store; otherwise fall back to in-memory so\n // the dashboard works with no cache configured.\n if (store === undefined && dashboardConfig) {\n const capacity = config.capacity ?? DEFAULT_DASHBOARD_STORE_CAPACITY;\n\n if (config.cache !== undefined) {\n const onError =\n config.onError ?? ((error: unknown) => log.error(\"ai-panoptic\", \"cacheStore\", error));\n\n cacheStore = createCacheTraceStore(config.cache, { onError, capacity });\n store = cacheStore;\n } else {\n store = createInMemoryTraceStore({ capacity });\n }\n\n exporters.push(store as unknown as ExporterContract);\n }\n\n const panopticInstance = panoptic({\n exporters,\n captureContent: config.captureContent,\n fullHistory: config.fullHistory,\n });\n registerObserver(toObserver(panopticInstance));\n\n applied = { panopticInstance };\n\n if (dashboardConfig && store !== undefined) {\n const resolvedStore = store;\n\n // Hydrate the cache mirror (if any) before serving, so a restart\n // surfaces previously-persisted traces immediately. A bare in-memory\n // store resolves the readyGate instantly.\n const readyGate = cacheStore !== undefined ? cacheStore.ready() : Promise.resolve();\n\n void readyGate\n .catch(() => {\n // Hydration is best-effort — never block the dashboard on it.\n })\n .then(() => startDashboard(resolvedStore, dashboardConfig ?? {}))\n .then((handle) => {\n if (applied !== undefined) {\n applied.dashboardHandle = handle;\n }\n });\n }\n }\n}\n\n/**\n * Reset the applied state — internal, test-only. Closes any running\n * dashboard and forgets the registered collector so a fresh\n * `applyPanopticConfig` starts clean. NOT part of the public surface and\n * does NOT unregister from the core observer registry (use core's\n * `clearObservers` for that in tests).\n */\nexport async function resetAppliedPanopticConfig(): Promise<void> {\n const handle = applied?.dashboardHandle;\n applied = undefined;\n noticeLogged = false;\n\n if (handle !== undefined) {\n await handle.close();\n }\n}\n\n/**\n * The currently-running dashboard handle, or `undefined` when no\n * dashboard is active. Internal, test-only — lets a spec await the\n * asynchronously-started dashboard. NOT part of the public surface.\n */\nexport function getActiveDashboardHandle(): DashboardHandle | undefined {\n return applied?.dashboardHandle;\n}\n\n/**\n * Wrap a {@link Panoptic} subscriber as a core {@link Observer}. The\n * subscriber already exposes `collect(report)` with a matching signature,\n * but the thin wrapper makes the structural adaptation explicit and keeps\n * the registered object a minimal `Observer` rather than the whole\n * subscriber surface.\n */\nfunction toObserver(instance: Panoptic): Observer {\n return {\n collect(report: ExecutionReport): Promise<void> {\n return instance.collect(report);\n },\n };\n}\n\n/**\n * Find the first exporter that satisfies the {@link TraceStoreContract}\n * read surface (`query` / `get` / `aggregate`) — the in-memory store\n * doubles as an exporter, so a store passed via `exporters` is reused for\n * the dashboard rather than creating a second one.\n */\nfunction findStore(exporters: ExporterContract[]): TraceStoreContract | undefined {\n for (const exporter of exporters) {\n const candidate = exporter as unknown as Partial<TraceStoreContract>;\n\n if (\n typeof candidate.query === \"function\" &&\n typeof candidate.get === \"function\" &&\n typeof candidate.aggregate === \"function\"\n ) {\n return candidate as TraceStoreContract;\n }\n }\n\n return undefined;\n}\n\n/** Start the dashboard, normalizing the `true | DashboardOptions` switch. */\nfunction startDashboard(\n store: TraceStoreContract,\n dashboardConfig: boolean | DashboardOptions,\n): Promise<DashboardHandle> {\n const options: DashboardOptions = typeof dashboardConfig === \"object\" ? dashboardConfig : {};\n\n return dashboard(store, options);\n}\n\n/** Whether the dashboard options force the standalone server. */\nfunction isStandalone(dashboardConfig: boolean | DashboardOptions): boolean {\n return typeof dashboardConfig === \"object\" && dashboardConfig.standalone === true;\n}\n"],"mappings":";;;;;;;;;AA4BA,IAAI;;AAGJ,IAAI,eAAe;;AAGnB,MAAa,mCAAmC;;;;;;;;;;;;;;;;;;;;;AAsBhD,SAAgB,oBAAoB,QAA+B;CACjE,IAAI,WAAW,QACb;CAIF,cAAc,QAAQ,OAAO,UAAU,CAAC;CAExC,IAAI,YAAY,QAAW;EAGzB,IAAI,kBAAkB,OAAO;EAE7B,IAAI,mBAAmB,mBAAmB,KAAK,CAAC,aAAa,eAAe,GAAG;GAC7E,kBAAkB;GAElB,IAAI,CAAC,cAAc;IACjB,eAAe;IACf,IAAI,KACF,eACA,aACA,mGAAmG,iBAAiB,EAAE,iHACxH;GACF;EACF;EAEA,MAAM,YAAY,CAAC,GAAI,OAAO,aAAa,CAAC,CAAE;EAC9C,IAAI,QAAQ,UAAU,SAAS;EAI/B,IAAI;EAOJ,IAAI,UAAU,UAAa,iBAAiB;GAC1C,MAAM,WAAW,OAAO;GAExB,IAAI,OAAO,UAAU,QAAW;IAC9B,MAAM,UACJ,OAAO,aAAa,UAAmB,IAAI,MAAM,eAAe,cAAc,KAAK;IAErF,aAAa,sBAAsB,OAAO,OAAO;KAAE;KAAS;IAAS,CAAC;IACtE,QAAQ;GACV,OACE,QAAQ,yBAAyB,EAAE,SAAS,CAAC;GAG/C,UAAU,KAAK,KAAoC;EACrD;EAEA,MAAM,mBAAmB,SAAS;GAChC;GACA,gBAAgB,OAAO;GACvB,aAAa,OAAO;EACtB,CAAC;EACD,iBAAiB,WAAW,gBAAgB,CAAC;EAE7C,UAAU,EAAE,iBAAiB;EAE7B,IAAI,mBAAmB,UAAU,QAAW;GAC1C,MAAM,gBAAgB;GAOtB,CAFkB,eAAe,SAAY,WAAW,MAAM,IAAI,QAAQ,QAAQ,EAEpE,CACX,YAAY,CAEb,CAAC,CAAC,CACD,WAAW,eAAe,eAAe,mBAAmB,CAAC,CAAC,CAAC,CAAC,CAChE,MAAM,WAAW;IAChB,IAAI,YAAY,QACd,QAAQ,kBAAkB;GAE9B,CAAC;EACL;CACF;AACF;;;;;;;;AAmCA,SAAS,WAAW,UAA8B;CAChD,OAAO,EACL,QAAQ,QAAwC;EAC9C,OAAO,SAAS,QAAQ,MAAM;CAChC,EACF;AACF;;;;;;;AAQA,SAAS,UAAU,WAA+D;CAChF,KAAK,MAAM,YAAY,WAAW;EAChC,MAAM,YAAY;EAElB,IACE,OAAO,UAAU,UAAU,cAC3B,OAAO,UAAU,QAAQ,cACzB,OAAO,UAAU,cAAc,YAE/B,OAAO;CAEX;AAGF;;AAGA,SAAS,eACP,OACA,iBAC0B;CAG1B,OAAO,UAAU,OAFiB,OAAO,oBAAoB,WAAW,kBAAkB,CAAC,CAE5D;AACjC;;AAGA,SAAS,aAAa,iBAAsD;CAC1E,OAAO,OAAO,oBAAoB,YAAY,gBAAgB,eAAe;AAC/E"}
@@ -1,3 +1,4 @@
1
1
  import { PanopticConfig } from "./panoptic-config.type.mjs";
2
2
  import { applyPanopticConfig } from "./apply-panoptic-config.mjs";
3
- export { type PanopticConfig, applyPanopticConfig };
3
+ import { WarlockAppProbe, devtoolsPathHint, isInsideWarlockApp } from "./warlock-app.mjs";
4
+ export { type PanopticConfig, applyPanopticConfig, devtoolsPathHint, isInsideWarlockApp };
@@ -1,3 +1,4 @@
1
+ import { devtoolsPathHint, isInsideWarlockApp } from "./warlock-app.mjs";
1
2
  import { applyPanopticConfig } from "./apply-panoptic-config.mjs";
2
3
 
3
- export { applyPanopticConfig };
4
+ export { applyPanopticConfig, devtoolsPathHint, isInsideWarlockApp };
@@ -1,5 +1,6 @@
1
1
  import { ExporterContract } from "../contracts/exporter.contract.mjs";
2
2
  import { CacheDriverInput } from "../store/cache-trace-store.mjs";
3
+ import { EvaluateConfig } from "../evaluate/evaluate.type.mjs";
3
4
  import { DashboardOptions } from "../dashboard/dashboard.type.mjs";
4
5
  //#region ../../packages/ai-panoptic/src/config/panoptic-config.type.d.ts
5
6
  /**
@@ -53,6 +54,13 @@ export type PanopticConfig = {
53
54
  * and registers when none was supplied.
54
55
  */
55
56
  dashboard?: boolean | DashboardOptions;
57
+ /**
58
+ * Settings for grading a system prompt with a judge model. Read through
59
+ * `getEvaluateConfig()` by the devtools Evaluate page, so grading works
60
+ * while the standalone dashboard stays off inside a Warlock app. When
61
+ * omitted, `dashboard.evaluate` is used.
62
+ */
63
+ evaluate?: EvaluateConfig;
56
64
  /**
57
65
  * How many traces the store panoptic creates for the dashboard keeps (the
58
66
  * in-memory store, or the cache-backed one when {@link cache} is set).
@@ -1 +1 @@
1
- {"version":3,"file":"panoptic-config.type.d.mts","names":[],"sources":["../../../../../../../../packages/ai-panoptic/src/config/panoptic-config.type.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;YA0BY;;;;;;;EAOV,YAAY;;;;;;;;;;;;;EAaZ,QAAQ;;;;;;;;EAQR,sBAAsB;;;;;;;EAOtB;;;;;;EAMA;;;;;;EAMA;;;;;;EAMA;;;;;;;;;;;EAWA,WAAW;;;YAQD;;IAER,WAAW"}
1
+ {"version":3,"file":"panoptic-config.type.d.mts","names":[],"sources":["../../../../../../../../packages/ai-panoptic/src/config/panoptic-config.type.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;YA2BY;;;;;;;EAOV,YAAY;;;;;;;;;;;;;EAaZ,QAAQ;;;;;;;;EAQR,sBAAsB;;;;;;;EAOtB,WAAW;;;;;;;EAOX;;;;;;EAMA;;;;;;EAMA;;;;;;EAMA;;;;;;;;;;;EAWA,WAAW;;;YAQD;;IAER,WAAW"}
@@ -0,0 +1,21 @@
1
+ //#region ../../packages/ai-panoptic/src/config/warlock-app.d.ts
2
+ /** Where the check looks; injectable for specs. */
3
+ export type WarlockAppProbe = {
4
+ cwd?: () => string;
5
+ env?: Readonly<Record<string, string | undefined>>;
6
+ exists?: (path: string) => boolean;
7
+ global?: Record<PropertyKey, unknown>;
8
+ };
9
+ /**
10
+ * Whether this process is a Warlock app: devtools published its marker,
11
+ * `warlock start` set `WARLOCK_BOOT_SIGNAL`, or a `warlock.config.ts`
12
+ * (`.js`, `.mjs`, `.cjs`) sits in the working directory. Never throws.
13
+ */
14
+ export declare function isInsideWarlockApp(probe?: WarlockAppProbe): boolean;
15
+ /**
16
+ * The devtools path to point at: the marker's `path` when devtools is
17
+ * mounted, otherwise `/__warlock`.
18
+ */
19
+ export declare function devtoolsPathHint(probe?: WarlockAppProbe): string;
20
+ //#endregion
21
+ //# sourceMappingURL=warlock-app.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"warlock-app.d.mts","names":[],"sources":["../../../../../../../../packages/ai-panoptic/src/config/warlock-app.ts"],"mappings":";;YAWY;EACV;EACA,MAAM,SAAS;EACf,UAAU;EACV,SAAS,OAAO;;;;;;;wBAeF,mBAAmB,QAAO;;;;;wBA2B1B,iBAAiB,QAAO"}
@@ -0,0 +1,47 @@
1
+ import { join } from "node:path";
2
+ import { existsSync } from "node:fs";
3
+
4
+ //#region ../../packages/ai-panoptic/src/config/warlock-app.ts
5
+ /**
6
+ * The global key `@warlock.js/devtools` publishes once its dashboard is
7
+ * mounted (`{ path, mode }`). Spelled out here so Panoptic never imports
8
+ * devtools.
9
+ */
10
+ const DEVTOOLS_MOUNTED_KEY = Symbol.for("@warlock.js/devtools.mounted");
11
+ const CONFIG_FILES = [
12
+ "warlock.config.ts",
13
+ "warlock.config.js",
14
+ "warlock.config.mjs",
15
+ "warlock.config.cjs"
16
+ ];
17
+ /**
18
+ * Whether this process is a Warlock app: devtools published its marker,
19
+ * `warlock start` set `WARLOCK_BOOT_SIGNAL`, or a `warlock.config.ts`
20
+ * (`.js`, `.mjs`, `.cjs`) sits in the working directory. Never throws.
21
+ */
22
+ function isInsideWarlockApp(probe = {}) {
23
+ try {
24
+ if ((probe.global ?? globalThis)[DEVTOOLS_MOUNTED_KEY]) return true;
25
+ if ((probe.env ?? process.env).WARLOCK_BOOT_SIGNAL) return true;
26
+ const cwd = (probe.cwd ?? (() => process.cwd()))();
27
+ const exists = probe.exists ?? existsSync;
28
+ return CONFIG_FILES.some((file) => exists(join(cwd, file)));
29
+ } catch {
30
+ return false;
31
+ }
32
+ }
33
+ /**
34
+ * The devtools path to point at: the marker's `path` when devtools is
35
+ * mounted, otherwise `/__warlock`.
36
+ */
37
+ function devtoolsPathHint(probe = {}) {
38
+ try {
39
+ const marker = (probe.global ?? globalThis)[DEVTOOLS_MOUNTED_KEY];
40
+ if (marker && typeof marker.path === "string" && marker.path !== "") return marker.path;
41
+ } catch {}
42
+ return "/__warlock";
43
+ }
44
+
45
+ //#endregion
46
+ export { DEVTOOLS_MOUNTED_KEY, devtoolsPathHint, isInsideWarlockApp };
47
+ //# sourceMappingURL=warlock-app.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"warlock-app.mjs","names":[],"sources":["../../../../../../../../packages/ai-panoptic/src/config/warlock-app.ts"],"sourcesContent":["import { existsSync } from \"node:fs\";\nimport { join } from \"node:path\";\n\n/**\n * The global key `@warlock.js/devtools` publishes once its dashboard is\n * mounted (`{ path, mode }`). Spelled out here so Panoptic never imports\n * devtools.\n */\nexport const DEVTOOLS_MOUNTED_KEY = Symbol.for(\"@warlock.js/devtools.mounted\");\n\n/** Where the check looks; injectable for specs. */\nexport type WarlockAppProbe = {\n cwd?: () => string;\n env?: Readonly<Record<string, string | undefined>>;\n exists?: (path: string) => boolean;\n global?: Record<PropertyKey, unknown>;\n};\n\nconst CONFIG_FILES = [\n \"warlock.config.ts\",\n \"warlock.config.js\",\n \"warlock.config.mjs\",\n \"warlock.config.cjs\",\n];\n\n/**\n * Whether this process is a Warlock app: devtools published its marker,\n * `warlock start` set `WARLOCK_BOOT_SIGNAL`, or a `warlock.config.ts`\n * (`.js`, `.mjs`, `.cjs`) sits in the working directory. Never throws.\n */\nexport function isInsideWarlockApp(probe: WarlockAppProbe = {}): boolean {\n try {\n const globals = probe.global ?? (globalThis as unknown as Record<PropertyKey, unknown>);\n\n if (globals[DEVTOOLS_MOUNTED_KEY]) {\n return true;\n }\n\n const env = probe.env ?? process.env;\n\n if (env.WARLOCK_BOOT_SIGNAL) {\n return true;\n }\n\n const cwd = (probe.cwd ?? (() => process.cwd()))();\n const exists = probe.exists ?? existsSync;\n\n return CONFIG_FILES.some((file) => exists(join(cwd, file)));\n } catch {\n return false;\n }\n}\n\n/**\n * The devtools path to point at: the marker's `path` when devtools is\n * mounted, otherwise `/__warlock`.\n */\nexport function devtoolsPathHint(probe: WarlockAppProbe = {}): string {\n try {\n const globals = probe.global ?? (globalThis as unknown as Record<PropertyKey, unknown>);\n const marker = globals[DEVTOOLS_MOUNTED_KEY] as { path?: unknown } | undefined;\n\n if (marker && typeof marker.path === \"string\" && marker.path !== \"\") {\n return marker.path;\n }\n } catch {\n // fall through to the default\n }\n\n return \"/__warlock\";\n}\n"],"mappings":";;;;;;;;;AAQA,MAAa,uBAAuB,OAAO,IAAI,8BAA8B;AAU7E,MAAM,eAAe;CACnB;CACA;CACA;CACA;AACF;;;;;;AAOA,SAAgB,mBAAmB,QAAyB,CAAC,GAAY;CACvE,IAAI;EAGF,KAFgB,MAAM,UAAW,WAEtB,CAAC,uBACV,OAAO;EAKT,KAFY,MAAM,OAAO,QAAQ,IAE1B,CAAC,qBACN,OAAO;EAGT,MAAM,OAAO,MAAM,cAAc,QAAQ,IAAI,GAAE,CAAE;EACjD,MAAM,SAAS,MAAM,UAAU;EAE/B,OAAO,aAAa,MAAM,SAAS,OAAO,KAAK,KAAK,IAAI,CAAC,CAAC;CAC5D,QAAQ;EACN,OAAO;CACT;AACF;;;;;AAMA,SAAgB,iBAAiB,QAAyB,CAAC,GAAW;CACpE,IAAI;EAEF,MAAM,UADU,MAAM,UAAW,WACX,CAAC;EAEvB,IAAI,UAAU,OAAO,OAAO,SAAS,YAAY,OAAO,SAAS,IAC/D,OAAO,OAAO;CAElB,QAAQ,CAER;CAEA,OAAO;AACT"}
@@ -60,6 +60,12 @@ export type DashboardOptions = {
60
60
  * every other route.
61
61
  */
62
62
  evaluate?: EvaluateConfig;
63
+ /**
64
+ * Start the dashboard even inside a Warlock app. By default Panoptic does
65
+ * not start it there (the devtools AI section shows the same traces) and
66
+ * logs one notice instead. Default `false`; ignored outside a Warlock app.
67
+ */
68
+ standalone?: boolean;
63
69
  };
64
70
  /**
65
71
  * Handle returned by {@link dashboard} once the server is listening.
@@ -1 +1 @@
1
- {"version":3,"file":"dashboard.type.d.mts","names":[],"sources":["../../../../../../../../packages/ai-panoptic/src/dashboard/dashboard.type.ts"],"mappings":";;;;;;;;;;;;;YAaY;;;;;;EAMV;;;;;;EAMA;;;;;;EAMA;;;;;EAKA;;EAEA;;;;;;;EAOA;;;;;;;EAOA;;;;;;;;;EASA,WAAW;;;;;;;YAQD;;WAED;;WAEA;;EAET,SAAS"}
1
+ {"version":3,"file":"dashboard.type.d.mts","names":[],"sources":["../../../../../../../../packages/ai-panoptic/src/dashboard/dashboard.type.ts"],"mappings":";;;;;;;;;;;;;YAaY;;;;;;EAMV;;;;;;EAMA;;;;;;EAMA;;;;;EAKA;;EAEA;;;;;;;EAOA;;;;;;;EAOA;;;;;;;;;EASA,WAAW;;;;;;EAMX;;;;;;;YAQU;;WAED;;WAEA;;EAET,SAAS"}
@@ -0,0 +1,11 @@
1
+ import { EvaluateConfig } from "./evaluate.type.mjs";
2
+ //#region ../../packages/ai-panoptic/src/evaluate/get-evaluate-config.d.ts
3
+ /**
4
+ * The evaluate settings of the applied Panoptic config: `panoptic.evaluate`,
5
+ * else `panoptic.dashboard.evaluate` when `dashboard` is an object, else
6
+ * `undefined`. Devtools' Evaluate page reads it, so grading works while the
7
+ * standalone dashboard stays off inside a Warlock app.
8
+ */
9
+ export declare function getEvaluateConfig(): EvaluateConfig | undefined;
10
+ //#endregion
11
+ //# sourceMappingURL=get-evaluate-config.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-evaluate-config.d.mts","names":[],"sources":["../../../../../../../../packages/ai-panoptic/src/evaluate/get-evaluate-config.ts"],"mappings":";;;;;;;;wBASgB,qBAAqB"}
@@ -0,0 +1,20 @@
1
+ import { getAIConfig } from "@warlock.js/ai";
2
+
3
+ //#region ../../packages/ai-panoptic/src/evaluate/get-evaluate-config.ts
4
+ /**
5
+ * The evaluate settings of the applied Panoptic config: `panoptic.evaluate`,
6
+ * else `panoptic.dashboard.evaluate` when `dashboard` is an object, else
7
+ * `undefined`. Devtools' Evaluate page reads it, so grading works while the
8
+ * standalone dashboard stays off inside a Warlock app.
9
+ */
10
+ function getEvaluateConfig() {
11
+ const panopticConfig = getAIConfig().panoptic;
12
+ if (panopticConfig === void 0) return;
13
+ if (panopticConfig.evaluate !== void 0) return panopticConfig.evaluate;
14
+ const dashboardConfig = panopticConfig.dashboard;
15
+ return typeof dashboardConfig === "object" ? dashboardConfig.evaluate : void 0;
16
+ }
17
+
18
+ //#endregion
19
+ export { getEvaluateConfig };
20
+ //# sourceMappingURL=get-evaluate-config.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-evaluate-config.mjs","names":[],"sources":["../../../../../../../../packages/ai-panoptic/src/evaluate/get-evaluate-config.ts"],"sourcesContent":["import { getAIConfig } from \"@warlock.js/ai\";\nimport type { EvaluateConfig } from \"./evaluate.type\";\n\n/**\n * The evaluate settings of the applied Panoptic config: `panoptic.evaluate`,\n * else `panoptic.dashboard.evaluate` when `dashboard` is an object, else\n * `undefined`. Devtools' Evaluate page reads it, so grading works while the\n * standalone dashboard stays off inside a Warlock app.\n */\nexport function getEvaluateConfig(): EvaluateConfig | undefined {\n const panopticConfig = getAIConfig().panoptic;\n\n if (panopticConfig === undefined) {\n return undefined;\n }\n\n if (panopticConfig.evaluate !== undefined) {\n return panopticConfig.evaluate;\n }\n\n const dashboardConfig = panopticConfig.dashboard;\n\n return typeof dashboardConfig === \"object\" ? dashboardConfig.evaluate : undefined;\n}\n"],"mappings":";;;;;;;;;AASA,SAAgB,oBAAgD;CAC9D,MAAM,iBAAiB,YAAY,CAAC,CAAC;CAErC,IAAI,mBAAmB,QACrB;CAGF,IAAI,eAAe,aAAa,QAC9B,OAAO,eAAe;CAGxB,MAAM,kBAAkB,eAAe;CAEvC,OAAO,OAAO,oBAAoB,WAAW,gBAAgB,WAAW;AAC1E"}
@@ -2,4 +2,5 @@ import { EvaluateConfig, EvaluateVerdict } from "./evaluate.type.mjs";
2
2
  import { evaluateSystemPrompt } from "./evaluate-system-prompt.mjs";
3
3
  import { extractLastSystemPrompt } from "./extract-last-system-prompt.mjs";
4
4
  import { findSpanById } from "./find-span-by-id.mjs";
5
- export { type EvaluateConfig, type EvaluateVerdict, evaluateSystemPrompt, extractLastSystemPrompt, findSpanById };
5
+ import { getEvaluateConfig } from "./get-evaluate-config.mjs";
6
+ export { type EvaluateConfig, type EvaluateVerdict, evaluateSystemPrompt, extractLastSystemPrompt, findSpanById, getEvaluateConfig };
@@ -1,5 +1,6 @@
1
1
  import { evaluateSystemPrompt } from "./evaluate-system-prompt.mjs";
2
2
  import { extractLastSystemPrompt } from "./extract-last-system-prompt.mjs";
3
3
  import { findSpanById } from "./find-span-by-id.mjs";
4
+ import { getEvaluateConfig } from "./get-evaluate-config.mjs";
4
5
 
5
- export { evaluateSystemPrompt, extractLastSystemPrompt, findSpanById };
6
+ export { evaluateSystemPrompt, extractLastSystemPrompt, findSpanById, getEvaluateConfig };
package/esm/index.d.mts CHANGED
@@ -41,6 +41,7 @@ import { EvaluateConfig, EvaluateVerdict } from "./evaluate/evaluate.type.mjs";
41
41
  import { evaluateSystemPrompt } from "./evaluate/evaluate-system-prompt.mjs";
42
42
  import { extractLastSystemPrompt } from "./evaluate/extract-last-system-prompt.mjs";
43
43
  import { findSpanById } from "./evaluate/find-span-by-id.mjs";
44
+ import { getEvaluateConfig } from "./evaluate/get-evaluate-config.mjs";
44
45
  import "./evaluate/index.mjs";
45
46
  import { DashboardHandle, DashboardOptions } from "./dashboard/dashboard.type.mjs";
46
47
  import { dashboard } from "./dashboard/dashboard.mjs";
@@ -49,6 +50,7 @@ import { TraceSpanSummary, TraceSummary } from "./dashboard/trace-summary.mjs";
49
50
  import "./dashboard/index.mjs";
50
51
  import { PanopticConfig } from "./config/panoptic-config.type.mjs";
51
52
  import { applyPanopticConfig } from "./config/apply-panoptic-config.mjs";
53
+ import { devtoolsPathHint, isInsideWarlockApp } from "./config/warlock-app.mjs";
52
54
  import "./config/index.mjs";
53
- export { type AttributeValue, type CacheDriverInput, type CacheTraceStoreHandle, type CacheTraceStoreOptions, type CollectorContract, type CollectorOptions, type CompletedEventPayload, type ConsoleExporterOptions, type ConsoleLike, type ContentCaptureOptions, type ContentRedactor, type DashboardHandle, type DashboardOptions, type EvaluateConfig, type EvaluateVerdict, type ExporterContract, type ExporterErrorHandler, type FileExporterOptions, GEN_AI_ATTRIBUTES, type InMemoryTraceStoreOptions, type LangfuseClientLike, type LangfuseExporterOptions, type LangfuseObservationBody, type LangfuseObservationEndBody, type LangfuseObservationLevel, type LangfuseObservationLike, type LangfuseTraceBody, type LangfuseTraceLike, type LangfuseUsageBody, NO_PROMPT_KEY, NO_SESSION_KEY, NO_TYPE_KEY, type OtelExporterOptions, type Panoptic, type PanopticConfig, type PanopticOptions, type PanopticTarget, type PromptGroup, type SessionGroup, type Trace, type TraceAggregate, type TraceFilter, type TraceListener, type TraceQuery, type TraceRecord, type TraceSpan, type TraceSpanError, type TraceSpanSummary, type TraceStoreContract, type TraceSummary, type TypeGroup, type TypeStat, WARLOCK_ATTRIBUTES, aggregateByType, applyPanopticConfig, consoleExporter, createCacheTraceStore, createCollector, createInMemoryTraceStore, createPanopticMiddleware, dashboard, emptyUsage, evaluateSystemPrompt, extractLastSystemPrompt, extractSpanAttributes, fileExporter, filterTraces, findSpanById, formatSpanIO, formatSpanLine, groupByPrompt, groupBySession, groupByType, heatIntensity, langfuseExporter, matchTrace, matchesFilter, maxNodeCost, normalizeError, otelExporter, panoptic, percentile, reportToSpan, reportToTrace, rollupCost, subscribeTraces, sumUsage, toGenAiAttributes, totalCostUsd, traceCost, tracePromptKey, walkSpans };
55
+ export { type AttributeValue, type CacheDriverInput, type CacheTraceStoreHandle, type CacheTraceStoreOptions, type CollectorContract, type CollectorOptions, type CompletedEventPayload, type ConsoleExporterOptions, type ConsoleLike, type ContentCaptureOptions, type ContentRedactor, type DashboardHandle, type DashboardOptions, type EvaluateConfig, type EvaluateVerdict, type ExporterContract, type ExporterErrorHandler, type FileExporterOptions, GEN_AI_ATTRIBUTES, type InMemoryTraceStoreOptions, type LangfuseClientLike, type LangfuseExporterOptions, type LangfuseObservationBody, type LangfuseObservationEndBody, type LangfuseObservationLevel, type LangfuseObservationLike, type LangfuseTraceBody, type LangfuseTraceLike, type LangfuseUsageBody, NO_PROMPT_KEY, NO_SESSION_KEY, NO_TYPE_KEY, type OtelExporterOptions, type Panoptic, type PanopticConfig, type PanopticOptions, type PanopticTarget, type PromptGroup, type SessionGroup, type Trace, type TraceAggregate, type TraceFilter, type TraceListener, type TraceQuery, type TraceRecord, type TraceSpan, type TraceSpanError, type TraceSpanSummary, type TraceStoreContract, type TraceSummary, type TypeGroup, type TypeStat, WARLOCK_ATTRIBUTES, aggregateByType, applyPanopticConfig, consoleExporter, createCacheTraceStore, createCollector, createInMemoryTraceStore, createPanopticMiddleware, dashboard, devtoolsPathHint, emptyUsage, evaluateSystemPrompt, extractLastSystemPrompt, extractSpanAttributes, fileExporter, filterTraces, findSpanById, formatSpanIO, formatSpanLine, getEvaluateConfig, groupByPrompt, groupBySession, groupByType, heatIntensity, isInsideWarlockApp, langfuseExporter, matchTrace, matchesFilter, maxNodeCost, normalizeError, otelExporter, panoptic, percentile, reportToSpan, reportToTrace, rollupCost, subscribeTraces, sumUsage, toGenAiAttributes, totalCostUsd, traceCost, tracePromptKey, walkSpans };
54
56
  import "./config/panoptic-config.type.mjs";
package/esm/index.mjs CHANGED
@@ -26,12 +26,14 @@ import "./panoptic/index.mjs";
26
26
  import { evaluateSystemPrompt } from "./evaluate/evaluate-system-prompt.mjs";
27
27
  import { extractLastSystemPrompt } from "./evaluate/extract-last-system-prompt.mjs";
28
28
  import { findSpanById } from "./evaluate/find-span-by-id.mjs";
29
+ import { getEvaluateConfig } from "./evaluate/get-evaluate-config.mjs";
29
30
  import "./evaluate/index.mjs";
30
31
  import { NO_PROMPT_KEY, NO_SESSION_KEY, NO_TYPE_KEY, aggregateByType, filterTraces, groupByPrompt, groupBySession, groupByType, heatIntensity, matchesFilter, maxNodeCost, percentile, rollupCost, traceCost, tracePromptKey } from "./dashboard/trace-filter.mjs";
31
32
  import { dashboard } from "./dashboard/dashboard.mjs";
32
33
  import "./dashboard/index.mjs";
34
+ import { devtoolsPathHint, isInsideWarlockApp } from "./config/warlock-app.mjs";
33
35
  import { applyPanopticConfig } from "./config/apply-panoptic-config.mjs";
34
36
  import "./config/index.mjs";
35
37
  import "./register.mjs";
36
38
 
37
- export { GEN_AI_ATTRIBUTES, NO_PROMPT_KEY, NO_SESSION_KEY, NO_TYPE_KEY, WARLOCK_ATTRIBUTES, aggregateByType, applyPanopticConfig, consoleExporter, createCacheTraceStore, createCollector, createInMemoryTraceStore, createPanopticMiddleware, dashboard, emptyUsage, evaluateSystemPrompt, extractLastSystemPrompt, extractSpanAttributes, fileExporter, filterTraces, findSpanById, formatSpanIO, formatSpanLine, groupByPrompt, groupBySession, groupByType, heatIntensity, langfuseExporter, matchTrace, matchesFilter, maxNodeCost, normalizeError, otelExporter, panoptic, percentile, reportToSpan, reportToTrace, rollupCost, subscribeTraces, sumUsage, toGenAiAttributes, totalCostUsd, traceCost, tracePromptKey, walkSpans };
39
+ export { GEN_AI_ATTRIBUTES, NO_PROMPT_KEY, NO_SESSION_KEY, NO_TYPE_KEY, WARLOCK_ATTRIBUTES, aggregateByType, applyPanopticConfig, consoleExporter, createCacheTraceStore, createCollector, createInMemoryTraceStore, createPanopticMiddleware, dashboard, devtoolsPathHint, emptyUsage, evaluateSystemPrompt, extractLastSystemPrompt, extractSpanAttributes, fileExporter, filterTraces, findSpanById, formatSpanIO, formatSpanLine, getEvaluateConfig, groupByPrompt, groupBySession, groupByType, heatIntensity, isInsideWarlockApp, langfuseExporter, matchTrace, matchesFilter, maxNodeCost, normalizeError, otelExporter, panoptic, percentile, reportToSpan, reportToTrace, rollupCost, subscribeTraces, sumUsage, toGenAiAttributes, totalCostUsd, traceCost, tracePromptKey, walkSpans };
package/llms-full.txt CHANGED
@@ -51,7 +51,7 @@ ai.config({
51
51
  panoptic: {
52
52
  dashboard: {
53
53
  evaluate: {
54
- model: openai.model("gpt-4o-mini"),
54
+ model: openai.model({ name: "gpt-4o-mini" }),
55
55
  instructions: "Must address the user by name. Never invent prices.",
56
56
  },
57
57
  },
@@ -70,6 +70,22 @@ Absent `evaluate` ⇒ the drawer never renders the button and a `POST` to its ro
70
70
  | `model` | yes | A `ModelContract`, or a `() => ModelContract \| Promise<ModelContract>` factory — mirrors `panoptic.cache`'s literal-or-factory ergonomics. Resolved fresh on every evaluate click (a deliberate, infrequent, human-triggered action — not the collector's hot path — so no memoization, unlike the cache store's driver). |
71
71
  | `instructions` | no | Default grading rubric/criteria, verbatim — the same shape `ai.prompts().validate({ criteria })` accepts. Seeds the dashboard's editable textarea (baked into the served page at boot, so the operator sees and can extend the actual default, not a blank box); the built-in prompt-quality rubric is used when neither this nor a per-run override is supplied. |
72
72
 
73
+ ## Top-level `panoptic.evaluate` and the devtools Evaluate page
74
+
75
+ `PanopticConfig.evaluate` takes the same `EvaluateConfig` as `dashboard.evaluate`. `getEvaluateConfig()` returns `panoptic.evaluate`, else `panoptic.dashboard.evaluate`, else `undefined`. The devtools **Evaluate** page (development only) reads it, so prompts can be graded while the standalone dashboard stays off inside a Warlock app:
76
+
77
+ ```ts
78
+ ai.config({
79
+ panoptic: {
80
+ observeAll: true,
81
+ evaluate: {
82
+ model: openai.model({ name: "gpt-4o-mini" }),
83
+ instructions: "Must state what the agent may never do.",
84
+ },
85
+ },
86
+ });
87
+ ```
88
+
73
89
  ## The UI
74
90
 
75
91
  Open a trace, select the span whose prompt you want graded (any span carrying a captured `[system, user]` pair or `fullHistory` message array — an agent span, not a tool span). An "Evaluate system prompt" button appears under the input/output block **only when that span actually has a system prompt to grade** (`extractLastSystemPrompt` finds one) — no dead button on tool spans or system-prompt-less runs.
@@ -836,6 +852,10 @@ So `dashboard: true` with no exporters Just Works — you get a store for free.
836
852
 
837
853
  **Idempotent.** Applying the config is safe on every `ai.config(...)` merge: the collector is registered as a core `Observer` exactly once and the dashboard is started at most once. Repeat calls only refresh the `observeAll` flag (latest config wins). `panoptic` undefined in the config is a no-op.
838
854
 
855
+ ## Inside a Warlock app it does not start
856
+
857
+ When the process is a Warlock app (devtools mounted, `WARLOCK_BOOT_SIGNAL` set by `warlock start`, or a `warlock.config.ts`/`.js`/`.mjs`/`.cjs` in the working directory), `dashboard` is skipped: no store, no port, and one `log.info("ai-panoptic", "dashboard", …)` notice per process pointing at the devtools **AI** section. `dashboard: { standalone: true }` starts it anyway; outside a Warlock app `standalone` is ignored and nothing changes. Exporters, `observeAll` and content capture are unaffected. `isInsideWarlockApp()`, `devtoolsPathHint()` (the devtools path the notice names: the mounted path, else `/__warlock`) and `getEvaluateConfig()` are exported from `@warlock.js/ai-panoptic`.
858
+
839
859
  ## What the UI shows
840
860
 
841
861
  The page is one self-contained, dependency-free vanilla-JS file (no bundler, no framework, works offline). It polls the JSON API every 2s and renders:
@@ -940,6 +960,8 @@ The store is the same object the collector writes to — wire the collector to i
940
960
 
941
961
  ### `DashboardOptions`
942
962
 
963
+ `standalone?: boolean` (default `false`) starts the dashboard even inside a Warlock app.
964
+
943
965
  Every field optional, every default safe:
944
966
 
945
967
  | Option | Default | Notes |
package/package.json CHANGED
@@ -19,9 +19,9 @@
19
19
  "peerDependencies": {
20
20
  "@opentelemetry/api": "*",
21
21
  "@opentelemetry/sdk-trace-base": "*",
22
- "@warlock.js/ai": "5.59.0",
23
- "@warlock.js/cache": "5.59.0",
24
- "@warlock.js/logger": "5.59.0",
22
+ "@warlock.js/ai": "5.60.0",
23
+ "@warlock.js/cache": "5.60.0",
24
+ "@warlock.js/logger": "5.60.0",
25
25
  "langfuse": "*"
26
26
  },
27
27
  "peerDependenciesMeta": {
@@ -41,7 +41,7 @@
41
41
  "dependencies": {
42
42
  "langfuse": "^3.38.20"
43
43
  },
44
- "version": "5.59.0",
44
+ "version": "5.60.0",
45
45
  "main": "./cjs/index.cjs",
46
46
  "module": "./esm/index.mjs",
47
47
  "types": "./esm/index.d.mts",
@@ -17,7 +17,7 @@ ai.config({
17
17
  panoptic: {
18
18
  dashboard: {
19
19
  evaluate: {
20
- model: openai.model("gpt-4o-mini"),
20
+ model: openai.model({ name: "gpt-4o-mini" }),
21
21
  instructions: "Must address the user by name. Never invent prices.",
22
22
  },
23
23
  },
@@ -36,6 +36,22 @@ Absent `evaluate` ⇒ the drawer never renders the button and a `POST` to its ro
36
36
  | `model` | yes | A `ModelContract`, or a `() => ModelContract \| Promise<ModelContract>` factory — mirrors `panoptic.cache`'s literal-or-factory ergonomics. Resolved fresh on every evaluate click (a deliberate, infrequent, human-triggered action — not the collector's hot path — so no memoization, unlike the cache store's driver). |
37
37
  | `instructions` | no | Default grading rubric/criteria, verbatim — the same shape `ai.prompts().validate({ criteria })` accepts. Seeds the dashboard's editable textarea (baked into the served page at boot, so the operator sees and can extend the actual default, not a blank box); the built-in prompt-quality rubric is used when neither this nor a per-run override is supplied. |
38
38
 
39
+ ## Top-level `panoptic.evaluate` and the devtools Evaluate page
40
+
41
+ `PanopticConfig.evaluate` takes the same `EvaluateConfig` as `dashboard.evaluate`. `getEvaluateConfig()` returns `panoptic.evaluate`, else `panoptic.dashboard.evaluate`, else `undefined`. The devtools **Evaluate** page (development only) reads it, so prompts can be graded while the standalone dashboard stays off inside a Warlock app:
42
+
43
+ ```ts
44
+ ai.config({
45
+ panoptic: {
46
+ observeAll: true,
47
+ evaluate: {
48
+ model: openai.model({ name: "gpt-4o-mini" }),
49
+ instructions: "Must state what the agent may never do.",
50
+ },
51
+ },
52
+ });
53
+ ```
54
+
39
55
  ## The UI
40
56
 
41
57
  Open a trace, select the span whose prompt you want graded (any span carrying a captured `[system, user]` pair or `fullHistory` message array — an agent span, not a tool span). An "Evaluate system prompt" button appears under the input/output block **only when that span actually has a system prompt to grade** (`extractLastSystemPrompt` finds one) — no dead button on tool spans or system-prompt-less runs.
@@ -44,6 +44,10 @@ So `dashboard: true` with no exporters Just Works — you get a store for free.
44
44
 
45
45
  **Idempotent.** Applying the config is safe on every `ai.config(...)` merge: the collector is registered as a core `Observer` exactly once and the dashboard is started at most once. Repeat calls only refresh the `observeAll` flag (latest config wins). `panoptic` undefined in the config is a no-op.
46
46
 
47
+ ## Inside a Warlock app it does not start
48
+
49
+ When the process is a Warlock app (devtools mounted, `WARLOCK_BOOT_SIGNAL` set by `warlock start`, or a `warlock.config.ts`/`.js`/`.mjs`/`.cjs` in the working directory), `dashboard` is skipped: no store, no port, and one `log.info("ai-panoptic", "dashboard", …)` notice per process pointing at the devtools **AI** section. `dashboard: { standalone: true }` starts it anyway; outside a Warlock app `standalone` is ignored and nothing changes. Exporters, `observeAll` and content capture are unaffected. `isInsideWarlockApp()`, `devtoolsPathHint()` (the devtools path the notice names: the mounted path, else `/__warlock`) and `getEvaluateConfig()` are exported from `@warlock.js/ai-panoptic`.
50
+
47
51
  ## What the UI shows
48
52
 
49
53
  The page is one self-contained, dependency-free vanilla-JS file (no bundler, no framework, works offline). It polls the JSON API every 2s and renders:
@@ -148,6 +152,8 @@ The store is the same object the collector writes to — wire the collector to i
148
152
 
149
153
  ### `DashboardOptions`
150
154
 
155
+ `standalone?: boolean` (default `false`) starts the dashboard even inside a Warlock app.
156
+
151
157
  Every field optional, every default safe:
152
158
 
153
159
  | Option | Default | Notes |