@warlock.js/ai-panoptic 5.31.0 → 5.32.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (135) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/cjs/index.cjs +16 -65
  3. package/cjs/index.cjs.map +1 -1
  4. package/esm/collector/collector.d.mts +3 -5
  5. package/esm/collector/collector.d.mts.map +1 -1
  6. package/esm/collector/content-capture.type.d.mts +4 -5
  7. package/esm/collector/content-capture.type.d.mts.map +1 -1
  8. package/esm/collector/extract-span-attributes.d.mts +1 -3
  9. package/esm/collector/extract-span-attributes.d.mts.map +1 -1
  10. package/esm/collector/extract-span-attributes.mjs +1 -4
  11. package/esm/collector/extract-span-attributes.mjs.map +1 -1
  12. package/esm/collector/index.d.mts +2 -1
  13. package/esm/collector/index.mjs +1 -1
  14. package/esm/collector/normalize-error.d.mts +1 -3
  15. package/esm/collector/normalize-error.d.mts.map +1 -1
  16. package/esm/collector/report-to-span.d.mts +1 -3
  17. package/esm/collector/report-to-span.d.mts.map +1 -1
  18. package/esm/collector/report-to-trace.d.mts +1 -3
  19. package/esm/collector/report-to-trace.d.mts.map +1 -1
  20. package/esm/config/apply-panoptic-config.d.mts +2 -3
  21. package/esm/config/apply-panoptic-config.d.mts.map +1 -1
  22. package/esm/config/index.d.mts +2 -1
  23. package/esm/config/index.mjs +1 -1
  24. package/esm/config/panoptic-config.type.d.mts +2 -4
  25. package/esm/config/panoptic-config.type.d.mts.map +1 -1
  26. package/esm/contracts/collector.contract.d.mts +1 -3
  27. package/esm/contracts/collector.contract.d.mts.map +1 -1
  28. package/esm/contracts/exporter.contract.d.mts +1 -3
  29. package/esm/contracts/exporter.contract.d.mts.map +1 -1
  30. package/esm/contracts/index.d.mts +2 -1
  31. package/esm/contracts/trace.type.d.mts +35 -20
  32. package/esm/contracts/trace.type.d.mts.map +1 -1
  33. package/esm/dashboard/dashboard.d.mts +1 -3
  34. package/esm/dashboard/dashboard.d.mts.map +1 -1
  35. package/esm/dashboard/dashboard.mjs +3 -2
  36. package/esm/dashboard/dashboard.mjs.map +1 -1
  37. package/esm/dashboard/dashboard.type.d.mts +9 -7
  38. package/esm/dashboard/dashboard.type.d.mts.map +1 -1
  39. package/esm/dashboard/index.d.mts +4 -1
  40. package/esm/dashboard/index.mjs +1 -1
  41. package/esm/dashboard/parse-query.d.mts +1 -1
  42. package/esm/dashboard/serve.d.mts +2 -1
  43. package/esm/dashboard/serve.mjs +1 -1
  44. package/esm/dashboard/serve.mjs.map +1 -1
  45. package/esm/dashboard/trace-filter.d.mts +44 -32
  46. package/esm/dashboard/trace-filter.d.mts.map +1 -1
  47. package/esm/evaluate/evaluate-system-prompt.d.mts +1 -3
  48. package/esm/evaluate/evaluate-system-prompt.d.mts.map +1 -1
  49. package/esm/evaluate/evaluate-system-prompt.mjs +3 -1
  50. package/esm/evaluate/evaluate-system-prompt.mjs.map +1 -1
  51. package/esm/evaluate/evaluate.type.d.mts +2 -4
  52. package/esm/evaluate/evaluate.type.d.mts.map +1 -1
  53. package/esm/evaluate/extract-last-system-prompt.d.mts +1 -3
  54. package/esm/evaluate/extract-last-system-prompt.d.mts.map +1 -1
  55. package/esm/evaluate/find-span-by-id.d.mts +1 -3
  56. package/esm/evaluate/find-span-by-id.d.mts.map +1 -1
  57. package/esm/evaluate/index.d.mts +2 -1
  58. package/esm/evaluate/index.mjs +1 -1
  59. package/esm/exporters/console/console-exporter.d.mts +2 -3
  60. package/esm/exporters/console/console-exporter.d.mts.map +1 -1
  61. package/esm/exporters/console/console-exporter.type.d.mts +2 -3
  62. package/esm/exporters/console/console-exporter.type.d.mts.map +1 -1
  63. package/esm/exporters/console/format-span-io.d.mts +2 -2
  64. package/esm/exporters/console/format-span-io.d.mts.map +1 -1
  65. package/esm/exporters/console/format-span-line.d.mts +2 -2
  66. package/esm/exporters/console/format-span-line.d.mts.map +1 -1
  67. package/esm/exporters/console/index.d.mts +2 -1
  68. package/esm/exporters/console/index.mjs +1 -1
  69. package/esm/exporters/file/file-exporter.d.mts +2 -3
  70. package/esm/exporters/file/file-exporter.d.mts.map +1 -1
  71. package/esm/exporters/file/file-exporter.type.d.mts +8 -5
  72. package/esm/exporters/file/file-exporter.type.d.mts.map +1 -1
  73. package/esm/exporters/file/index.d.mts +2 -1
  74. package/esm/exporters/index.d.mts +7 -1
  75. package/esm/exporters/index.mjs +1 -1
  76. package/esm/exporters/langfuse/index.d.mts +2 -1
  77. package/esm/exporters/langfuse/index.mjs +1 -1
  78. package/esm/exporters/langfuse/langfuse-exporter.d.mts +2 -3
  79. package/esm/exporters/langfuse/langfuse-exporter.d.mts.map +1 -1
  80. package/esm/exporters/langfuse/langfuse-exporter.mjs +1 -1
  81. package/esm/exporters/langfuse/langfuse-exporter.mjs.map +1 -1
  82. package/esm/exporters/langfuse/langfuse-exporter.type.d.mts +23 -17
  83. package/esm/exporters/langfuse/langfuse-exporter.type.d.mts.map +1 -1
  84. package/esm/exporters/otel/index.d.mts +2 -1
  85. package/esm/exporters/otel/index.mjs +1 -1
  86. package/esm/exporters/otel/otel-api.shim.type.d.mts +6 -7
  87. package/esm/exporters/otel/otel-api.shim.type.d.mts.map +1 -1
  88. package/esm/exporters/otel/otel-exporter.d.mts +2 -3
  89. package/esm/exporters/otel/otel-exporter.d.mts.map +1 -1
  90. package/esm/exporters/otel/otel-exporter.type.d.mts +1 -3
  91. package/esm/exporters/otel/otel-exporter.type.d.mts.map +1 -1
  92. package/esm/exporters/utils/gen-ai-attributes.d.mts +9 -7
  93. package/esm/exporters/utils/gen-ai-attributes.d.mts.map +1 -1
  94. package/esm/exporters/utils/index.d.mts +2 -1
  95. package/esm/exporters/utils/index.mjs +1 -1
  96. package/esm/exporters/utils/total-cost.d.mts +1 -3
  97. package/esm/exporters/utils/total-cost.d.mts.map +1 -1
  98. package/esm/exporters/utils/walk-spans.d.mts +2 -2
  99. package/esm/exporters/utils/walk-spans.d.mts.map +1 -1
  100. package/esm/index.d.mts +8 -0
  101. package/esm/panoptic/index.d.mts +2 -1
  102. package/esm/panoptic/index.mjs +1 -1
  103. package/esm/panoptic/panoptic-middleware.d.mts +1 -3
  104. package/esm/panoptic/panoptic-middleware.d.mts.map +1 -1
  105. package/esm/panoptic/panoptic-target.type.d.mts +4 -5
  106. package/esm/panoptic/panoptic-target.type.d.mts.map +1 -1
  107. package/esm/panoptic/panoptic.d.mts +1 -3
  108. package/esm/panoptic/panoptic.d.mts.map +1 -1
  109. package/esm/panoptic/panoptic.type.d.mts +8 -7
  110. package/esm/panoptic/panoptic.type.d.mts.map +1 -1
  111. package/esm/store/cache-trace-store.d.mts +4 -6
  112. package/esm/store/cache-trace-store.d.mts.map +1 -1
  113. package/esm/store/cache-trace-store.mjs +1 -4
  114. package/esm/store/cache-trace-store.mjs.map +1 -1
  115. package/esm/store/in-memory-trace-store.d.mts +2 -4
  116. package/esm/store/in-memory-trace-store.d.mts.map +1 -1
  117. package/esm/store/in-memory-trace-store.mjs +1 -4
  118. package/esm/store/in-memory-trace-store.mjs.map +1 -1
  119. package/esm/store/index.d.mts +2 -1
  120. package/esm/store/index.mjs +1 -1
  121. package/esm/store/match-trace.d.mts +1 -3
  122. package/esm/store/match-trace.d.mts.map +1 -1
  123. package/esm/store/sum-usage.d.mts +4 -30
  124. package/esm/store/sum-usage.d.mts.map +1 -1
  125. package/esm/store/sum-usage.mjs +6 -49
  126. package/esm/store/sum-usage.mjs.map +1 -1
  127. package/esm/store/trace-aggregate.type.d.mts +12 -9
  128. package/esm/store/trace-aggregate.type.d.mts.map +1 -1
  129. package/esm/store/trace-query.type.d.mts +5 -5
  130. package/esm/store/trace-query.type.d.mts.map +1 -1
  131. package/esm/store/trace-store.contract.d.mts +1 -3
  132. package/esm/store/trace-store.contract.d.mts.map +1 -1
  133. package/llms-full.txt +14 -0
  134. package/package.json +4 -4
  135. package/skills/query-traces/SKILL.md +14 -0
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.32.0 - 2026-10-18
8
+
9
+ ### Changed
10
+
11
+ - Pin the package development compiler to TypeScript 7.0.2 and use explicit Node types and source roots with supported module resolution.
12
+
13
+ ### Fixed
14
+
15
+ - Use the canonical usage rollup for trace aggregates, retaining hosted-tool counters and historical request fees alongside cache lifetime and mixed-provider cache semantics.
16
+
7
17
  ## 5.31.0 - 2026-10-18
8
18
 
9
19
  ### Fixed
package/cjs/index.cjs CHANGED
@@ -114,10 +114,7 @@ function extractSpanAttributes(report) {
114
114
  case "orchestrator":
115
115
  addOrchestratorAttributes(attributes, extensions);
116
116
  break;
117
- case "tool":
118
- addToolAttributes(attributes, extensions);
119
- break;
120
- default: break;
117
+ case "tool": addToolAttributes(attributes, extensions);
121
118
  }
122
119
  if (Object.keys(attributes).length === 0) return;
123
120
  return attributes;
@@ -502,48 +499,14 @@ function toEpoch(bound) {
502
499
 
503
500
  //#endregion
504
501
  //#region ../../packages/ai-panoptic/src/store/sum-usage.ts
505
- /**
506
- * Fold a child {@link Usage} into a running accumulator. Token channels
507
- * (`input` / `output` / `total`) always sum; the optional cache /
508
- * reasoning channels (`cachedTokens` / `cacheWriteTokens` /
509
- * `reasoningTokens`) sum only when at least one side reported them, so
510
- * a provider that never meters a channel doesn't fabricate a `0` for
511
- * it. The `cost` breakdown is merged with the core framework's
512
- * {@link accumulateCost}, keeping cost-rollup semantics identical to a
513
- * native report tree — an unpriced contributor never erases a priced
514
- * one.
515
- *
516
- * Pure: returns a fresh `Usage`, never mutates either argument. Seed an
517
- * aggregation with {@link emptyUsage}.
518
- *
519
- * @example
520
- * let total = emptyUsage();
521
- * for (const trace of traces) {
522
- * total = sumUsage(total, trace.usage);
523
- * }
524
- */
502
+ /** Return an independent all-channel usage rollup, preserving hosted-tool counters. */
525
503
  function sumUsage(accumulator, next) {
526
- const merged = {
527
- input: accumulator.input + next.input,
528
- output: accumulator.output + next.output,
529
- total: accumulator.total + next.total
530
- };
531
- const cachedTokens = sumOptional(accumulator.cachedTokens, next.cachedTokens);
532
- if (cachedTokens !== void 0) merged.cachedTokens = cachedTokens;
533
- const cacheWriteTokens = sumOptional(accumulator.cacheWriteTokens, next.cacheWriteTokens);
534
- if (cacheWriteTokens !== void 0) merged.cacheWriteTokens = cacheWriteTokens;
535
- const reasoningTokens = sumOptional(accumulator.reasoningTokens, next.reasoningTokens);
536
- if (reasoningTokens !== void 0) merged.reasoningTokens = reasoningTokens;
537
- const cost = (0, _warlock_js_ai.accumulateCost)(accumulator.cost, next.cost);
538
- if (cost !== void 0) merged.cost = cost;
504
+ const merged = emptyUsage();
505
+ (0, _warlock_js_ai.mergeUsage)(merged, accumulator);
506
+ (0, _warlock_js_ai.mergeUsage)(merged, next);
539
507
  return merged;
540
508
  }
541
- /**
542
- * A zero-valued {@link Usage} to seed an aggregation. Only the required
543
- * token channels are set; optional channels stay absent until a
544
- * contributor reports them, preserving the "never reported" vs
545
- * "reported as 0" distinction.
546
- */
509
+ /** Seed an aggregation without claiming any optional counter was reported. */
547
510
  function emptyUsage() {
548
511
  return {
549
512
  input: 0,
@@ -551,15 +514,6 @@ function emptyUsage() {
551
514
  total: 0
552
515
  };
553
516
  }
554
- /**
555
- * Add two optional token counts, treating either side's `undefined` as
556
- * zero — but return `undefined` when both are absent, so an unreported
557
- * channel stays unreported rather than collapsing to `0`.
558
- */
559
- function sumOptional(accumulator, next) {
560
- if (accumulator === void 0 && next === void 0) return;
561
- return (accumulator ?? 0) + (next ?? 0);
562
- }
563
517
 
564
518
  //#endregion
565
519
  //#region ../../packages/ai-panoptic/src/store/cache-trace-store.ts
@@ -785,10 +739,7 @@ var CacheTraceStore = class {
785
739
  case "incomplete":
786
740
  aggregate.failed += 1;
787
741
  break;
788
- case "cancelled":
789
- aggregate.cancelled += 1;
790
- break;
791
- default: break;
742
+ case "cancelled": aggregate.cancelled += 1;
792
743
  }
793
744
  }
794
745
  /**
@@ -941,10 +892,7 @@ var InMemoryTraceStore = class {
941
892
  case "incomplete":
942
893
  aggregate.failed += 1;
943
894
  break;
944
- case "cancelled":
945
- aggregate.cancelled += 1;
946
- break;
947
- default: break;
895
+ case "cancelled": aggregate.cancelled += 1;
948
896
  }
949
897
  }
950
898
  /**
@@ -1535,7 +1483,7 @@ function ownUsage(span) {
1535
1483
  * rolled-up subtree totals next to an own-usage `usage` block. Cost is
1536
1484
  * omitted for the same reason; Langfuse prices the own tokens itself.
1537
1485
  */
1538
- const LANGFUSE_METADATA_OMIT = new Set([
1486
+ const LANGFUSE_METADATA_OMIT = /* @__PURE__ */ new Set([
1539
1487
  GEN_AI_ATTRIBUTES.usageInputTokens,
1540
1488
  GEN_AI_ATTRIBUTES.usageOutputTokens,
1541
1489
  WARLOCK_ATTRIBUTES.totalTokens,
@@ -1935,7 +1883,9 @@ function panoptic(options = {}) {
1935
1883
  * the caller (the dashboard route) is expected to catch.
1936
1884
  */
1937
1885
  async function evaluateSystemPrompt(systemPrompt, config, instructionsOverride) {
1938
- return (0, _warlock_js_ai.judgePromptBody)(systemPrompt, typeof config.model === "function" ? await config.model() : config.model, instructionsOverride?.trim() || config.instructions);
1886
+ const model = typeof config.model === "function" ? await config.model() : config.model;
1887
+ const instructions = instructionsOverride?.trim() || config.instructions;
1888
+ return (0, _warlock_js_ai.judgePromptBody)(systemPrompt, model, instructions);
1939
1889
  }
1940
1890
 
1941
1891
  //#endregion
@@ -3524,7 +3474,7 @@ function encodeForInlineScript(value) {
3524
3474
  //#endregion
3525
3475
  //#region ../../packages/ai-panoptic/src/dashboard/serve.ts
3526
3476
  /** Hard cap on the evaluate route's request body — well beyond a real instructions string. */
3527
- const MAX_EVALUATE_BODY_BYTES = 64 * 1024;
3477
+ const MAX_EVALUATE_BODY_BYTES = 65536;
3528
3478
  /**
3529
3479
  * Security response headers added to every dashboard response (S4):
3530
3480
  * block MIME-sniffing, framing, referrer leakage, and lock the page's
@@ -3806,13 +3756,14 @@ function dashboard(store, options = {}) {
3806
3756
  const basePath = normalizeBasePath(options.basePath);
3807
3757
  if (!isLoopbackHost(host) && !options.authToken) return Promise.reject(/* @__PURE__ */ new Error(`Panoptic dashboard: binding to a non-loopback host ("${host}") requires an \`authToken\` (the dashboard exposes raw prompt content). Pass \`authToken\`, or bind to 127.0.0.1.`));
3808
3758
  const allowedHosts = (options.allowedHosts ?? defaultAllowedHosts(host)).map((h) => h.toLowerCase());
3809
- const server = (0, node_http.createServer)(createRequestHandler(store, {
3759
+ const handler = createRequestHandler(store, {
3810
3760
  basePath,
3811
3761
  title,
3812
3762
  authToken: options.authToken,
3813
3763
  allowedHosts,
3814
3764
  evaluate: options.evaluate
3815
- }));
3765
+ });
3766
+ const server = (0, node_http.createServer)(handler);
3816
3767
  return new Promise((resolve, reject) => {
3817
3768
  const onError = (error) => {
3818
3769
  server.off("error", onError);