@warlock.js/ai-panoptic 5.31.0 → 5.33.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 +18 -0
- package/cjs/index.cjs +72 -67
- package/cjs/index.cjs.map +1 -1
- package/esm/collector/collector.d.mts +3 -5
- package/esm/collector/collector.d.mts.map +1 -1
- package/esm/collector/collector.mjs +2 -0
- package/esm/collector/collector.mjs.map +1 -1
- package/esm/collector/content-capture.type.d.mts +4 -5
- package/esm/collector/content-capture.type.d.mts.map +1 -1
- package/esm/collector/extract-span-attributes.d.mts +1 -3
- package/esm/collector/extract-span-attributes.d.mts.map +1 -1
- package/esm/collector/extract-span-attributes.mjs +30 -6
- package/esm/collector/extract-span-attributes.mjs.map +1 -1
- package/esm/collector/index.d.mts +3 -1
- package/esm/collector/index.mjs +2 -1
- package/esm/collector/normalize-error.d.mts +1 -3
- package/esm/collector/normalize-error.d.mts.map +1 -1
- package/esm/collector/report-to-span.d.mts +1 -3
- package/esm/collector/report-to-span.d.mts.map +1 -1
- package/esm/collector/report-to-trace.d.mts +1 -3
- package/esm/collector/report-to-trace.d.mts.map +1 -1
- package/esm/collector/trace-subscriptions.d.mts +14 -0
- package/esm/collector/trace-subscriptions.d.mts.map +1 -0
- package/esm/collector/trace-subscriptions.mjs +26 -0
- package/esm/collector/trace-subscriptions.mjs.map +1 -0
- package/esm/config/apply-panoptic-config.d.mts +2 -3
- package/esm/config/apply-panoptic-config.d.mts.map +1 -1
- package/esm/config/index.d.mts +2 -1
- package/esm/config/index.mjs +1 -1
- package/esm/config/panoptic-config.type.d.mts +2 -4
- package/esm/config/panoptic-config.type.d.mts.map +1 -1
- package/esm/contracts/collector.contract.d.mts +1 -3
- package/esm/contracts/collector.contract.d.mts.map +1 -1
- package/esm/contracts/exporter.contract.d.mts +1 -3
- package/esm/contracts/exporter.contract.d.mts.map +1 -1
- package/esm/contracts/index.d.mts +2 -1
- package/esm/contracts/trace.type.d.mts +37 -20
- package/esm/contracts/trace.type.d.mts.map +1 -1
- package/esm/dashboard/dashboard.d.mts +1 -3
- package/esm/dashboard/dashboard.d.mts.map +1 -1
- package/esm/dashboard/dashboard.mjs +3 -2
- package/esm/dashboard/dashboard.mjs.map +1 -1
- package/esm/dashboard/dashboard.type.d.mts +9 -7
- package/esm/dashboard/dashboard.type.d.mts.map +1 -1
- package/esm/dashboard/index.d.mts +4 -1
- package/esm/dashboard/index.mjs +1 -1
- package/esm/dashboard/parse-query.d.mts +1 -1
- package/esm/dashboard/serve.d.mts +2 -1
- package/esm/dashboard/serve.mjs +1 -1
- package/esm/dashboard/serve.mjs.map +1 -1
- package/esm/dashboard/trace-filter.d.mts +44 -32
- package/esm/dashboard/trace-filter.d.mts.map +1 -1
- package/esm/evaluate/evaluate-system-prompt.d.mts +1 -3
- package/esm/evaluate/evaluate-system-prompt.d.mts.map +1 -1
- package/esm/evaluate/evaluate-system-prompt.mjs +3 -1
- package/esm/evaluate/evaluate-system-prompt.mjs.map +1 -1
- package/esm/evaluate/evaluate.type.d.mts +2 -4
- package/esm/evaluate/evaluate.type.d.mts.map +1 -1
- package/esm/evaluate/extract-last-system-prompt.d.mts +1 -3
- package/esm/evaluate/extract-last-system-prompt.d.mts.map +1 -1
- package/esm/evaluate/find-span-by-id.d.mts +1 -3
- package/esm/evaluate/find-span-by-id.d.mts.map +1 -1
- package/esm/evaluate/index.d.mts +2 -1
- package/esm/evaluate/index.mjs +1 -1
- package/esm/exporters/console/console-exporter.d.mts +2 -3
- package/esm/exporters/console/console-exporter.d.mts.map +1 -1
- package/esm/exporters/console/console-exporter.type.d.mts +2 -3
- package/esm/exporters/console/console-exporter.type.d.mts.map +1 -1
- package/esm/exporters/console/format-span-io.d.mts +2 -2
- package/esm/exporters/console/format-span-io.d.mts.map +1 -1
- package/esm/exporters/console/format-span-line.d.mts +2 -2
- package/esm/exporters/console/format-span-line.d.mts.map +1 -1
- package/esm/exporters/console/index.d.mts +2 -1
- package/esm/exporters/console/index.mjs +1 -1
- package/esm/exporters/file/file-exporter.d.mts +2 -3
- package/esm/exporters/file/file-exporter.d.mts.map +1 -1
- package/esm/exporters/file/file-exporter.type.d.mts +8 -5
- package/esm/exporters/file/file-exporter.type.d.mts.map +1 -1
- package/esm/exporters/file/index.d.mts +2 -1
- package/esm/exporters/index.d.mts +7 -1
- package/esm/exporters/index.mjs +1 -1
- package/esm/exporters/langfuse/index.d.mts +2 -1
- package/esm/exporters/langfuse/index.mjs +1 -1
- package/esm/exporters/langfuse/langfuse-exporter.d.mts +2 -3
- package/esm/exporters/langfuse/langfuse-exporter.d.mts.map +1 -1
- package/esm/exporters/langfuse/langfuse-exporter.mjs +1 -1
- package/esm/exporters/langfuse/langfuse-exporter.mjs.map +1 -1
- package/esm/exporters/langfuse/langfuse-exporter.type.d.mts +23 -17
- package/esm/exporters/langfuse/langfuse-exporter.type.d.mts.map +1 -1
- package/esm/exporters/otel/index.d.mts +2 -1
- package/esm/exporters/otel/index.mjs +1 -1
- package/esm/exporters/otel/otel-api.shim.type.d.mts +6 -7
- package/esm/exporters/otel/otel-api.shim.type.d.mts.map +1 -1
- package/esm/exporters/otel/otel-exporter.d.mts +2 -3
- package/esm/exporters/otel/otel-exporter.d.mts.map +1 -1
- package/esm/exporters/otel/otel-exporter.type.d.mts +1 -3
- package/esm/exporters/otel/otel-exporter.type.d.mts.map +1 -1
- package/esm/exporters/utils/gen-ai-attributes.d.mts +9 -7
- package/esm/exporters/utils/gen-ai-attributes.d.mts.map +1 -1
- package/esm/exporters/utils/index.d.mts +2 -1
- package/esm/exporters/utils/index.mjs +1 -1
- package/esm/exporters/utils/total-cost.d.mts +1 -3
- package/esm/exporters/utils/total-cost.d.mts.map +1 -1
- package/esm/exporters/utils/walk-spans.d.mts +2 -2
- package/esm/exporters/utils/walk-spans.d.mts.map +1 -1
- package/esm/index.d.mts +10 -1
- package/esm/index.mjs +2 -1
- package/esm/panoptic/index.d.mts +2 -1
- package/esm/panoptic/index.mjs +1 -1
- package/esm/panoptic/panoptic-middleware.d.mts +1 -3
- package/esm/panoptic/panoptic-middleware.d.mts.map +1 -1
- package/esm/panoptic/panoptic-target.type.d.mts +4 -5
- package/esm/panoptic/panoptic-target.type.d.mts.map +1 -1
- package/esm/panoptic/panoptic.d.mts +1 -3
- package/esm/panoptic/panoptic.d.mts.map +1 -1
- package/esm/panoptic/panoptic.type.d.mts +8 -7
- package/esm/panoptic/panoptic.type.d.mts.map +1 -1
- package/esm/store/cache-trace-store.d.mts +4 -6
- package/esm/store/cache-trace-store.d.mts.map +1 -1
- package/esm/store/cache-trace-store.mjs +1 -4
- package/esm/store/cache-trace-store.mjs.map +1 -1
- package/esm/store/in-memory-trace-store.d.mts +2 -4
- package/esm/store/in-memory-trace-store.d.mts.map +1 -1
- package/esm/store/in-memory-trace-store.mjs +1 -4
- package/esm/store/in-memory-trace-store.mjs.map +1 -1
- package/esm/store/index.d.mts +2 -1
- package/esm/store/index.mjs +1 -1
- package/esm/store/match-trace.d.mts +1 -3
- package/esm/store/match-trace.d.mts.map +1 -1
- package/esm/store/match-trace.mjs +1 -0
- package/esm/store/match-trace.mjs.map +1 -1
- package/esm/store/sum-usage.d.mts +4 -30
- package/esm/store/sum-usage.d.mts.map +1 -1
- package/esm/store/sum-usage.mjs +6 -49
- package/esm/store/sum-usage.mjs.map +1 -1
- package/esm/store/trace-aggregate.type.d.mts +12 -9
- package/esm/store/trace-aggregate.type.d.mts.map +1 -1
- package/esm/store/trace-query.type.d.mts +7 -5
- package/esm/store/trace-query.type.d.mts.map +1 -1
- package/esm/store/trace-store.contract.d.mts +1 -3
- package/esm/store/trace-store.contract.d.mts.map +1 -1
- package/llms-full.txt +105 -0
- package/package.json +4 -4
- package/skills/observe-with-panoptic/SKILL.md +35 -0
- package/skills/query-traces/SKILL.md +49 -0
- package/skills/use-local-dashboard/SKILL.md +21 -0
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { CollectorContract } from "../contracts/collector.contract.mjs";
|
|
2
2
|
import { ContentCaptureOptions } from "./content-capture.type.mjs";
|
|
3
|
-
|
|
4
3
|
//#region ../../packages/ai-panoptic/src/collector/collector.d.ts
|
|
5
4
|
/**
|
|
6
5
|
* Notified when a registered exporter throws during `collect` / `flush` /
|
|
@@ -8,9 +7,9 @@ import { ContentCaptureOptions } from "./content-capture.type.mjs";
|
|
|
8
7
|
* it) — this is purely a chance to surface it (route to your logger,
|
|
9
8
|
* bump a metric). Receives the exporter's `name` and the thrown error.
|
|
10
9
|
*/
|
|
11
|
-
type ExporterErrorHandler = (exporterName: string, error: unknown) => void;
|
|
10
|
+
export type ExporterErrorHandler = (exporterName: string, error: unknown) => void;
|
|
12
11
|
/** Options for {@link createCollector}. */
|
|
13
|
-
type CollectorOptions = ContentCaptureOptions & {
|
|
12
|
+
export type CollectorOptions = ContentCaptureOptions & {
|
|
14
13
|
/**
|
|
15
14
|
* Called when an exporter throws (and is isolated). Overrides the default
|
|
16
15
|
* one-time `console.warn` per exporter — route the failure to your own
|
|
@@ -31,7 +30,6 @@ type CollectorOptions = ContentCaptureOptions & {
|
|
|
31
30
|
* // on shutdown:
|
|
32
31
|
* await collector.shutdown();
|
|
33
32
|
*/
|
|
34
|
-
declare function createCollector(options?: CollectorOptions): CollectorContract;
|
|
33
|
+
export declare function createCollector(options?: CollectorOptions): CollectorContract;
|
|
35
34
|
//#endregion
|
|
36
|
-
export { CollectorOptions, ExporterErrorHandler, createCollector };
|
|
37
35
|
//# sourceMappingURL=collector.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"collector.d.mts","names":[],"sources":["../../../../../../../../packages/ai-panoptic/src/collector/collector.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"collector.d.mts","names":[],"sources":["../../../../../../../../packages/ai-panoptic/src/collector/collector.ts"],"mappings":";;;;;;;;;YAeY,wBAAwB,sBAAsB;;YAG9C,mBAAmB;;;;;;;EAO7B,UAAU;;;;;;;;;;;;;;wBA0JI,gBAAgB,UAAS,mBAAwB"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { walkSpans } from "../exporters/utils/walk-spans.mjs";
|
|
2
2
|
import { reportToTrace } from "./report-to-trace.mjs";
|
|
3
|
+
import { publishTrace } from "./trace-subscriptions.mjs";
|
|
3
4
|
|
|
4
5
|
//#region ../../packages/ai-panoptic/src/collector/collector.ts
|
|
5
6
|
/**
|
|
@@ -51,6 +52,7 @@ var Collector = class {
|
|
|
51
52
|
}
|
|
52
53
|
async collect(report, rootError) {
|
|
53
54
|
const trace = this.toTrace(report, rootError);
|
|
55
|
+
publishTrace(trace);
|
|
54
56
|
await this.dispatch(trace);
|
|
55
57
|
}
|
|
56
58
|
async flush() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"collector.mjs","names":[],"sources":["../../../../../../../../packages/ai-panoptic/src/collector/collector.ts"],"sourcesContent":["import type { BaseReport } from \"@warlock.js/ai\";\nimport type { CollectorContract } from \"../contracts/collector.contract\";\nimport type { ExporterContract } from \"../contracts/exporter.contract\";\nimport type { Trace } from \"../contracts/trace.type\";\nimport { walkSpans } from \"../exporters/utils/walk-spans\";\nimport type { ContentCaptureOptions } from \"./content-capture.type\";\nimport { reportToTrace } from \"./report-to-trace\";\n\n/**\n * Notified when a registered exporter throws during `collect` / `flush` /\n * `shutdown`. The failure stays isolated (the originating run never sees\n * it) — this is purely a chance to surface it (route to your logger,\n * bump a metric). Receives the exporter's `name` and the thrown error.\n */\nexport type ExporterErrorHandler = (exporterName: string, error: unknown) => void;\n\n/** Options for {@link createCollector}. */\nexport type CollectorOptions = ContentCaptureOptions & {\n /**\n * Called when an exporter throws (and is isolated). Overrides the default\n * one-time `console.warn` per exporter — route the failure to your own\n * logger / metrics instead. Errors thrown by the handler itself are\n * swallowed so observability never crashes the run.\n */\n onError?: ExporterErrorHandler;\n};\n\n/**\n * Drive the source end of the Panoptic pipeline: ingest core\n * `@warlock.js/ai` {@link BaseReport} trees, project them into {@link\n * Trace}s, and fan each trace out to every registered exporter.\n *\n * Owns exporter registration (deduped by `ExporterContract.name`), the\n * report→trace projection, and graceful shutdown so exporters drain\n * before exit. Instantiated fresh per collector via {@link\n * createCollector}; callers never see `new`.\n *\n * **Failure isolation.** An exporter that throws never propagates back\n * into the originating run — `collect`, `flush`, and `shutdown` settle\n * every exporter independently (mirrors how the core event hooks\n * swallow consumer errors). One broken exporter can neither crash the\n * agent loop nor stop sibling exporters from receiving the trace. The\n * failure is still **surfaced** — via the `onError` option, or a one-time\n * `console.warn` per exporter — so a misconfiguration (e.g. a missing\n * optional peer like `langfuse`) doesn't fail silently.\n */\nclass Collector implements CollectorContract {\n /**\n * Registered exporters in insertion order. A `Map` keyed by\n * `ExporterContract.name` gives O(1) dedupe on `use` while preserving\n * registration order for deterministic fan-out.\n */\n private readonly exporters = new Map<string, ExporterContract>();\n\n /**\n * Exporters already warned about on the default error path — so a\n * persistent misconfiguration surfaces once, not on every trace.\n */\n private readonly warnedExporters = new Set<string>();\n\n /**\n * Collector options: content capture threaded into every `toTrace`\n * projection (`captureContent` populates span `input` / `output`), plus\n * an optional `onError` for isolated exporter failures.\n */\n public constructor(private readonly options: CollectorOptions = {}) {}\n\n public use(exporter: ExporterContract): this {\n if (!this.exporters.has(exporter.name)) {\n this.exporters.set(exporter.name, exporter);\n }\n\n return this;\n }\n\n public toTrace(report: BaseReport, rootError?: unknown): Trace {\n return reportToTrace(report, rootError, this.options);\n }\n\n public async collect(report: BaseReport, rootError?: unknown): Promise<void> {\n const trace = this.toTrace(report, rootError);\n\n await this.dispatch(trace);\n }\n\n public async flush(): Promise<void> {\n await this.settleAll((exporter) => exporter.flush?.());\n }\n\n public async shutdown(): Promise<void> {\n await this.flush();\n\n await this.settleAll((exporter) => exporter.shutdown?.());\n\n this.exporters.clear();\n }\n\n /**\n * Fan one trace out to every exporter and, when an exporter advertises\n * the per-span hook, deliver every span in the finalized tree to it as\n * well. `exportSpan` is a post-completion per-span hook (not a live /\n * streaming feed — the trace is already finalized): we walk the tree in\n * pre-order with {@link walkSpans} so the exporter sees the root and\n * every descendant exactly once. Every invocation is isolated so a\n * throwing exporter can't abort the dispatch to its siblings or escape\n * into the originating run.\n */\n private async dispatch(trace: Trace): Promise<void> {\n await this.settleAll(async (exporter) => {\n await exporter.export(trace);\n\n if (exporter.exportSpan !== undefined) {\n for (const span of walkSpans(trace.root)) {\n await exporter.exportSpan(span);\n }\n }\n });\n }\n\n /**\n * Run `task` against every registered exporter and wait for all of\n * them to settle, swallowing individual rejections. `Promise.allSettled`\n * guarantees one failure neither rejects the batch nor blocks the\n * others — the contract's failure-isolation requirement.\n */\n private async settleAll(\n task: (exporter: ExporterContract) => void | Promise<void>,\n ): Promise<void> {\n const runs = [...this.exporters.entries()].map(([name, exporter]) =>\n Promise.resolve()\n .then(() => task(exporter))\n .catch((error: unknown) => this.reportExporterError(name, error)),\n );\n\n await Promise.allSettled(runs);\n }\n\n /**\n * Surface an isolated exporter failure. The originating run never sees it\n * (the isolation guarantee holds), but a silent failure is the wrong\n * default for a config error — e.g. a missing optional peer like\n * `langfuse` would otherwise drop every trace with no signal. The\n * supplied `onError` is called, or — by default — a `console.warn` is\n * emitted ONCE per exporter so the cause is visible without spamming.\n */\n private reportExporterError(name: string, error: unknown): void {\n if (this.options.onError) {\n try {\n this.options.onError(name, error);\n } catch {\n // Never let the error handler itself escape into the run.\n }\n return;\n }\n\n if (this.warnedExporters.has(name)) {\n return;\n }\n\n this.warnedExporters.add(name);\n const message = error instanceof Error ? error.message : String(error);\n console.warn(`[panoptic] exporter \"${name}\" failed and was isolated: ${message}`);\n }\n}\n\n/**\n * Create a Panoptic collector — the single integration point an app\n * wires into its agents/workflows (typically via the `onComplete`\n * report hook). Register exporters with `use`, then feed finalized root\n * reports to `collect`.\n *\n * @example\n * const collector = createCollector().use(otelExporter).use(langfuseExporter);\n * agent.on(\"onComplete\", ({ result }) => collector.collect(result.report));\n * // on shutdown:\n * await collector.shutdown();\n */\nexport function createCollector(options: CollectorOptions = {}): CollectorContract {\n return new Collector(options);\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"collector.mjs","names":[],"sources":["../../../../../../../../packages/ai-panoptic/src/collector/collector.ts"],"sourcesContent":["import type { BaseReport } from \"@warlock.js/ai\";\nimport type { CollectorContract } from \"../contracts/collector.contract\";\nimport type { ExporterContract } from \"../contracts/exporter.contract\";\nimport type { Trace } from \"../contracts/trace.type\";\nimport { walkSpans } from \"../exporters/utils/walk-spans\";\nimport type { ContentCaptureOptions } from \"./content-capture.type\";\nimport { reportToTrace } from \"./report-to-trace\";\nimport { publishTrace } from \"./trace-subscriptions\";\n\n/**\n * Notified when a registered exporter throws during `collect` / `flush` /\n * `shutdown`. The failure stays isolated (the originating run never sees\n * it) — this is purely a chance to surface it (route to your logger,\n * bump a metric). Receives the exporter's `name` and the thrown error.\n */\nexport type ExporterErrorHandler = (exporterName: string, error: unknown) => void;\n\n/** Options for {@link createCollector}. */\nexport type CollectorOptions = ContentCaptureOptions & {\n /**\n * Called when an exporter throws (and is isolated). Overrides the default\n * one-time `console.warn` per exporter — route the failure to your own\n * logger / metrics instead. Errors thrown by the handler itself are\n * swallowed so observability never crashes the run.\n */\n onError?: ExporterErrorHandler;\n};\n\n/**\n * Drive the source end of the Panoptic pipeline: ingest core\n * `@warlock.js/ai` {@link BaseReport} trees, project them into {@link\n * Trace}s, and fan each trace out to every registered exporter.\n *\n * Owns exporter registration (deduped by `ExporterContract.name`), the\n * report→trace projection, and graceful shutdown so exporters drain\n * before exit. Instantiated fresh per collector via {@link\n * createCollector}; callers never see `new`.\n *\n * **Failure isolation.** An exporter that throws never propagates back\n * into the originating run — `collect`, `flush`, and `shutdown` settle\n * every exporter independently (mirrors how the core event hooks\n * swallow consumer errors). One broken exporter can neither crash the\n * agent loop nor stop sibling exporters from receiving the trace. The\n * failure is still **surfaced** — via the `onError` option, or a one-time\n * `console.warn` per exporter — so a misconfiguration (e.g. a missing\n * optional peer like `langfuse`) doesn't fail silently.\n */\nclass Collector implements CollectorContract {\n /**\n * Registered exporters in insertion order. A `Map` keyed by\n * `ExporterContract.name` gives O(1) dedupe on `use` while preserving\n * registration order for deterministic fan-out.\n */\n private readonly exporters = new Map<string, ExporterContract>();\n\n /**\n * Exporters already warned about on the default error path — so a\n * persistent misconfiguration surfaces once, not on every trace.\n */\n private readonly warnedExporters = new Set<string>();\n\n /**\n * Collector options: content capture threaded into every `toTrace`\n * projection (`captureContent` populates span `input` / `output`), plus\n * an optional `onError` for isolated exporter failures.\n */\n public constructor(private readonly options: CollectorOptions = {}) {}\n\n public use(exporter: ExporterContract): this {\n if (!this.exporters.has(exporter.name)) {\n this.exporters.set(exporter.name, exporter);\n }\n\n return this;\n }\n\n public toTrace(report: BaseReport, rootError?: unknown): Trace {\n return reportToTrace(report, rootError, this.options);\n }\n\n public async collect(report: BaseReport, rootError?: unknown): Promise<void> {\n const trace = this.toTrace(report, rootError);\n\n publishTrace(trace);\n await this.dispatch(trace);\n }\n\n public async flush(): Promise<void> {\n await this.settleAll((exporter) => exporter.flush?.());\n }\n\n public async shutdown(): Promise<void> {\n await this.flush();\n\n await this.settleAll((exporter) => exporter.shutdown?.());\n\n this.exporters.clear();\n }\n\n /**\n * Fan one trace out to every exporter and, when an exporter advertises\n * the per-span hook, deliver every span in the finalized tree to it as\n * well. `exportSpan` is a post-completion per-span hook (not a live /\n * streaming feed — the trace is already finalized): we walk the tree in\n * pre-order with {@link walkSpans} so the exporter sees the root and\n * every descendant exactly once. Every invocation is isolated so a\n * throwing exporter can't abort the dispatch to its siblings or escape\n * into the originating run.\n */\n private async dispatch(trace: Trace): Promise<void> {\n await this.settleAll(async (exporter) => {\n await exporter.export(trace);\n\n if (exporter.exportSpan !== undefined) {\n for (const span of walkSpans(trace.root)) {\n await exporter.exportSpan(span);\n }\n }\n });\n }\n\n /**\n * Run `task` against every registered exporter and wait for all of\n * them to settle, swallowing individual rejections. `Promise.allSettled`\n * guarantees one failure neither rejects the batch nor blocks the\n * others — the contract's failure-isolation requirement.\n */\n private async settleAll(\n task: (exporter: ExporterContract) => void | Promise<void>,\n ): Promise<void> {\n const runs = [...this.exporters.entries()].map(([name, exporter]) =>\n Promise.resolve()\n .then(() => task(exporter))\n .catch((error: unknown) => this.reportExporterError(name, error)),\n );\n\n await Promise.allSettled(runs);\n }\n\n /**\n * Surface an isolated exporter failure. The originating run never sees it\n * (the isolation guarantee holds), but a silent failure is the wrong\n * default for a config error — e.g. a missing optional peer like\n * `langfuse` would otherwise drop every trace with no signal. The\n * supplied `onError` is called, or — by default — a `console.warn` is\n * emitted ONCE per exporter so the cause is visible without spamming.\n */\n private reportExporterError(name: string, error: unknown): void {\n if (this.options.onError) {\n try {\n this.options.onError(name, error);\n } catch {\n // Never let the error handler itself escape into the run.\n }\n return;\n }\n\n if (this.warnedExporters.has(name)) {\n return;\n }\n\n this.warnedExporters.add(name);\n const message = error instanceof Error ? error.message : String(error);\n console.warn(`[panoptic] exporter \"${name}\" failed and was isolated: ${message}`);\n }\n}\n\n/**\n * Create a Panoptic collector — the single integration point an app\n * wires into its agents/workflows (typically via the `onComplete`\n * report hook). Register exporters with `use`, then feed finalized root\n * reports to `collect`.\n *\n * @example\n * const collector = createCollector().use(otelExporter).use(langfuseExporter);\n * agent.on(\"onComplete\", ({ result }) => collector.collect(result.report));\n * // on shutdown:\n * await collector.shutdown();\n */\nexport function createCollector(options: CollectorOptions = {}): CollectorContract {\n return new Collector(options);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AA+CA,IAAM,YAAN,MAA6C;CAmBP;;;;;;CAbpC,AAAiB,4BAAY,IAAI,IAA8B;;;;;CAM/D,AAAiB,kCAAkB,IAAI,IAAY;;;;;;CAOnD,AAAO,YAAY,AAAiB,UAA4B,CAAC,GAAG;EAAhC;CAAiC;CAErE,AAAO,IAAI,UAAkC;EAC3C,IAAI,CAAC,KAAK,UAAU,IAAI,SAAS,IAAI,GACnC,KAAK,UAAU,IAAI,SAAS,MAAM,QAAQ;EAG5C,OAAO;CACT;CAEA,AAAO,QAAQ,QAAoB,WAA4B;EAC7D,OAAO,cAAc,QAAQ,WAAW,KAAK,OAAO;CACtD;CAEA,MAAa,QAAQ,QAAoB,WAAoC;EAC3E,MAAM,QAAQ,KAAK,QAAQ,QAAQ,SAAS;EAE5C,aAAa,KAAK;EAClB,MAAM,KAAK,SAAS,KAAK;CAC3B;CAEA,MAAa,QAAuB;EAClC,MAAM,KAAK,WAAW,aAAa,SAAS,QAAQ,CAAC;CACvD;CAEA,MAAa,WAA0B;EACrC,MAAM,KAAK,MAAM;EAEjB,MAAM,KAAK,WAAW,aAAa,SAAS,WAAW,CAAC;EAExD,KAAK,UAAU,MAAM;CACvB;;;;;;;;;;;CAYA,MAAc,SAAS,OAA6B;EAClD,MAAM,KAAK,UAAU,OAAO,aAAa;GACvC,MAAM,SAAS,OAAO,KAAK;GAE3B,IAAI,SAAS,eAAe,QAC1B,KAAK,MAAM,QAAQ,UAAU,MAAM,IAAI,GACrC,MAAM,SAAS,WAAW,IAAI;EAGpC,CAAC;CACH;;;;;;;CAQA,MAAc,UACZ,MACe;EACf,MAAM,OAAO,CAAC,GAAG,KAAK,UAAU,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,cACrD,QAAQ,QAAQ,CAAC,CACd,WAAW,KAAK,QAAQ,CAAC,CAAC,CAC1B,OAAO,UAAmB,KAAK,oBAAoB,MAAM,KAAK,CAAC,CACpE;EAEA,MAAM,QAAQ,WAAW,IAAI;CAC/B;;;;;;;;;CAUA,AAAQ,oBAAoB,MAAc,OAAsB;EAC9D,IAAI,KAAK,QAAQ,SAAS;GACxB,IAAI;IACF,KAAK,QAAQ,QAAQ,MAAM,KAAK;GAClC,QAAQ,CAER;GACA;EACF;EAEA,IAAI,KAAK,gBAAgB,IAAI,IAAI,GAC/B;EAGF,KAAK,gBAAgB,IAAI,IAAI;EAC7B,MAAM,UAAU,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;EACrE,QAAQ,KAAK,wBAAwB,KAAK,6BAA6B,SAAS;CAClF;AACF;;;;;;;;;;;;;AAcA,SAAgB,gBAAgB,UAA4B,CAAC,GAAsB;CACjF,OAAO,IAAI,UAAU,OAAO;AAC9B"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { ReportType } from "@warlock.js/ai";
|
|
2
|
-
|
|
3
2
|
//#region ../../packages/ai-panoptic/src/collector/content-capture.type.d.ts
|
|
4
3
|
/**
|
|
5
4
|
* Masker applied to each captured content value before it lands on a
|
|
@@ -12,7 +11,7 @@ import { ReportType } from "@warlock.js/ai";
|
|
|
12
11
|
* const redactContent: ContentRedactor = (value, { field }) =>
|
|
13
12
|
* field === "input" ? "[redacted prompt]" : value;
|
|
14
13
|
*/
|
|
15
|
-
type ContentRedactor = (value: unknown, meta: {
|
|
14
|
+
export type ContentRedactor = (value: unknown, meta: {
|
|
16
15
|
name: string;
|
|
17
16
|
type: ReportType;
|
|
18
17
|
field: "input" | "output";
|
|
@@ -29,12 +28,13 @@ type ContentRedactor = (value: unknown, meta: {
|
|
|
29
28
|
* OTel `gen_ai.prompt` / `gen_ai.completion`, and Langfuse
|
|
30
29
|
* `input` / `output`.
|
|
31
30
|
*/
|
|
32
|
-
type ContentCaptureOptions = {
|
|
31
|
+
export type ContentCaptureOptions = {
|
|
33
32
|
/**
|
|
34
33
|
* Copy the agent's first-trip prompt + final response, and each tool's
|
|
35
34
|
* args + result, onto `span.input` / `span.output`. Default `false`.
|
|
36
35
|
*/
|
|
37
|
-
captureContent?: boolean;
|
|
36
|
+
captureContent?: boolean;
|
|
37
|
+
/** Optional masker applied to every captured value before it is stored. */
|
|
38
38
|
redactContent?: ContentRedactor;
|
|
39
39
|
/**
|
|
40
40
|
* When `true`, emit the agent's complete `CapturedMessage[]` (every
|
|
@@ -48,5 +48,4 @@ type ContentCaptureOptions = {
|
|
|
48
48
|
fullHistory?: boolean;
|
|
49
49
|
};
|
|
50
50
|
//#endregion
|
|
51
|
-
export { ContentCaptureOptions, ContentRedactor };
|
|
52
51
|
//# sourceMappingURL=content-capture.type.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"content-capture.type.d.mts","names":[],"sources":["../../../../../../../../packages/ai-panoptic/src/collector/content-capture.type.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"content-capture.type.d.mts","names":[],"sources":["../../../../../../../../packages/ai-panoptic/src/collector/content-capture.type.ts"],"mappings":";;;;;;;;;;;;;YAaY,mBACV,gBACA;EAAQ;EAAc,MAAM;EAAY;;;;;;;;;;;;;;YAe9B;;;;;EAKV;;EAEA,gBAAgB;;;;;;;;;;EAUhB"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { BaseReport } from "@warlock.js/ai";
|
|
2
|
-
|
|
3
2
|
//#region ../../packages/ai-panoptic/src/collector/extract-span-attributes.d.ts
|
|
4
3
|
/**
|
|
5
4
|
* Build the free-form `TraceSpan.attributes` bag for one report node.
|
|
@@ -23,7 +22,6 @@ import { BaseReport } from "@warlock.js/ai";
|
|
|
23
22
|
* const attributes = extractSpanAttributes(agentReport);
|
|
24
23
|
* // { "agent.trips": 3, "agent.model.name": "gpt-4o", "agent.model.provider": "openai" }
|
|
25
24
|
*/
|
|
26
|
-
declare function extractSpanAttributes(report: BaseReport): Record<string, unknown> | undefined;
|
|
25
|
+
export declare function extractSpanAttributes(report: BaseReport): Record<string, unknown> | undefined;
|
|
27
26
|
//#endregion
|
|
28
|
-
export { extractSpanAttributes };
|
|
29
27
|
//# sourceMappingURL=extract-span-attributes.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extract-span-attributes.d.mts","names":[],"sources":["../../../../../../../../packages/ai-panoptic/src/collector/extract-span-attributes.ts"],"mappings":"
|
|
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"}
|
|
@@ -24,7 +24,16 @@
|
|
|
24
24
|
function extractSpanAttributes(report) {
|
|
25
25
|
const extensions = report;
|
|
26
26
|
const attributes = {};
|
|
27
|
-
if (report.attempts !== void 0 && report.attempts.length > 0)
|
|
27
|
+
if (report.attempts !== void 0 && report.attempts.length > 0) {
|
|
28
|
+
attributes["retries"] = report.attempts.length;
|
|
29
|
+
attributes["retry.attempts"] = report.attempts.map((attempt) => ({
|
|
30
|
+
index: attempt.index,
|
|
31
|
+
startedAt: attempt.startedAt,
|
|
32
|
+
endedAt: attempt.endedAt,
|
|
33
|
+
duration: attempt.duration,
|
|
34
|
+
status: attempt.status
|
|
35
|
+
}));
|
|
36
|
+
}
|
|
28
37
|
switch (report.type) {
|
|
29
38
|
case "agent":
|
|
30
39
|
addAgentAttributes(attributes, extensions);
|
|
@@ -39,16 +48,31 @@ function extractSpanAttributes(report) {
|
|
|
39
48
|
case "orchestrator":
|
|
40
49
|
addOrchestratorAttributes(attributes, extensions);
|
|
41
50
|
break;
|
|
42
|
-
case "tool":
|
|
43
|
-
addToolAttributes(attributes, extensions);
|
|
44
|
-
break;
|
|
45
|
-
default: break;
|
|
51
|
+
case "tool": addToolAttributes(attributes, extensions);
|
|
46
52
|
}
|
|
47
53
|
if (Object.keys(attributes).length === 0) return;
|
|
48
54
|
return attributes;
|
|
49
55
|
}
|
|
50
56
|
function addAgentAttributes(attributes, extensions) {
|
|
51
|
-
if (Array.isArray(extensions.trips))
|
|
57
|
+
if (Array.isArray(extensions.trips)) {
|
|
58
|
+
attributes["agent.trips"] = extensions.trips.length;
|
|
59
|
+
if (extensions.trips.some((trip) => trip.usage?.cachedTokens !== void 0)) attributes["agent.cacheHits"] = extensions.trips.filter((trip) => (trip.usage?.cachedTokens ?? 0) > 0).length;
|
|
60
|
+
const truncatedTrips = extensions.trips.filter((trip) => trip.finishReason === "length" || trip.finishReason === "context_exceeded").length;
|
|
61
|
+
if (truncatedTrips > 0) attributes["agent.truncatedTrips"] = truncatedTrips;
|
|
62
|
+
const providerCompactions = extensions.trips.reduce((count, trip) => count + (trip.blocks?.filter((block) => block.type === "compaction").length ?? 0), 0);
|
|
63
|
+
if (providerCompactions > 0) attributes["agent.providerCompactions"] = providerCompactions;
|
|
64
|
+
}
|
|
65
|
+
if (extensions.compactions?.length) attributes["agent.compactions"] = extensions.compactions.map((record) => ({
|
|
66
|
+
type: record.type,
|
|
67
|
+
tripIndex: record.tripIndex,
|
|
68
|
+
inputTokens: record.inputTokens,
|
|
69
|
+
counting: record.counting,
|
|
70
|
+
reason: record.reason,
|
|
71
|
+
...record.compaction ? {
|
|
72
|
+
replacesFromIndex: record.compaction.replacesFromIndex,
|
|
73
|
+
replacesToIndex: record.compaction.replacesToIndex
|
|
74
|
+
} : {}
|
|
75
|
+
}));
|
|
52
76
|
if (extensions.model?.name !== void 0) attributes["agent.model.name"] = extensions.model.name;
|
|
53
77
|
if (extensions.model?.provider !== void 0) attributes["agent.model.provider"] = extensions.model.provider;
|
|
54
78
|
if (extensions.promptName !== void 0) attributes["agent.promptName"] = extensions.promptName;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extract-span-attributes.mjs","names":[],"sources":["../../../../../../../../packages/ai-panoptic/src/collector/extract-span-attributes.ts"],"sourcesContent":["import type { BaseReport } 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?: unknown[];\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 }\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 }\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":";;;;;;;;;;;;;;;;;;;;;;;AAwDA,SAAgB,sBAAsB,QAAyD;CAC7F,MAAM,aAAa;CACnB,MAAM,aAAsC,CAAC;CAE7C,IAAI,OAAO,aAAa,UAAa,OAAO,SAAS,SAAS,GAC5D,WAAW,aAAa,OAAO,SAAS;CAG1C,QAAQ,OAAO,MAAf;EACE,KAAK;GACH,mBAAmB,YAAY,UAAU;GACzC;EAGF,KAAK;GACH,sBAAsB,YAAY,UAAU;GAC5C;EAGF,KAAK;EACL,KAAK;GAGH,wBAAwB,YAAY,UAAU;GAC9C;EAGF,KAAK;GACH,0BAA0B,YAAY,UAAU;GAChD;EAGF,KAAK;GACH,kBAAkB,YAAY,UAAU;GACxC;EAGF,SACE;CAEJ;CAEA,IAAI,OAAO,KAAK,UAAU,CAAC,CAAC,WAAW,GACrC;CAGF,OAAO;AACT;AAEA,SAAS,mBACP,YACA,YACM;CACN,IAAI,MAAM,QAAQ,WAAW,KAAK,GAChC,WAAW,iBAAiB,WAAW,MAAM;CAG/C,IAAI,WAAW,OAAO,SAAS,QAC7B,WAAW,sBAAsB,WAAW,MAAM;CAGpD,IAAI,WAAW,OAAO,aAAa,QACjC,WAAW,0BAA0B,WAAW,MAAM;CAOxD,IAAI,WAAW,eAAe,QAC5B,WAAW,sBAAsB,WAAW;CAG9C,IAAI,WAAW,kBAAkB,QAC/B,WAAW,yBAAyB,WAAW;AAEnD;AAEA,SAAS,sBACP,YACA,YACM;CACN,IAAI,WAAW,iBAAiB,QAC9B,WAAW,mBAAmB,WAAW;CAG3C,IAAI,WAAW,cAAc,QAC3B,WAAW,wBAAwB,WAAW;CAGhD,IAAI,WAAW,UAAU,QACvB,WAAW,oBAAoB,OAAO,KAAK,WAAW,KAAK,CAAC,CAAC;AAEjE;AAEA,SAAS,wBACP,YACA,YACM;CACN,IAAI,WAAW,mBAAmB,QAChC,WAAW,qBAAqB,WAAW;CAG7C,IAAI,WAAW,iBAAiB,QAC9B,WAAW,6BAA6B,WAAW;CAGrD,IAAI,WAAW,eAAe,QAC5B,WAAW,2BAA2B,WAAW;AAErD;AAEA,SAAS,0BACP,YACA,YACM;CACN,IAAI,WAAW,cAAc,QAC3B,WAAW,4BAA4B,WAAW;CAGpD,IAAI,WAAW,cAAc,QAC3B,WAAW,4BAA4B,WAAW;CAGpD,IAAI,MAAM,QAAQ,WAAW,KAAK,GAChC,WAAW,wBAAwB,WAAW,MAAM;AAExD;AAEA,SAAS,kBACP,YACA,YACM;CACN,IAAI,WAAW,cAAc,QAC3B,WAAW,oBAAoB,WAAW;CAG5C,IAAI,WAAW,WAAW,QACxB,WAAW,iBAAiB,WAAW;CAGzC,IAAI,WAAW,kBAAkB,QAC/B,WAAW,wBAAwB,WAAW;AAElD"}
|
|
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":";;;;;;;;;;;;;;;;;;;;;;;AAyDA,SAAgB,sBAAsB,QAAyD;CAC7F,MAAM,aAAa;CACnB,MAAM,aAAsC,CAAC;CAE7C,IAAI,OAAO,aAAa,UAAa,OAAO,SAAS,SAAS,GAAG;EAC/D,WAAW,aAAa,OAAO,SAAS;EACxC,WAAW,oBAAoB,OAAO,SAAS,KAAK,aAAa;GAC/D,OAAO,QAAQ;GACf,WAAW,QAAQ;GACnB,SAAS,QAAQ;GACjB,UAAU,QAAQ;GAClB,QAAQ,QAAQ;EAClB,EAAE;CACJ;CAEA,QAAQ,OAAO,MAAf;EACE,KAAK;GACH,mBAAmB,YAAY,UAAU;GACzC;EAGF,KAAK;GACH,sBAAsB,YAAY,UAAU;GAC5C;EAGF,KAAK;EACL,KAAK;GAGH,wBAAwB,YAAY,UAAU;GAC9C;EAGF,KAAK;GACH,0BAA0B,YAAY,UAAU;GAChD;EAGF,KAAK,QACH,kBAAkB,YAAY,UAAU;CAO5C;CAEA,IAAI,OAAO,KAAK,UAAU,CAAC,CAAC,WAAW,GACrC;CAGF,OAAO;AACT;AAEA,SAAS,mBACP,YACA,YACM;CACN,IAAI,MAAM,QAAQ,WAAW,KAAK,GAAG;EACnC,WAAW,iBAAiB,WAAW,MAAM;EAG7C,IAAI,WAAW,MAAM,MAAM,SAAS,KAAK,OAAO,iBAAiB,MAAS,GACxE,WAAW,qBAAqB,WAAW,MAAM,QAC9C,UAAU,KAAK,OAAO,gBAAgB,KAAK,CAC9C,CAAC,CAAC;EAEJ,MAAM,iBAAiB,WAAW,MAAM,QACrC,SAAS,KAAK,iBAAiB,YAAY,KAAK,iBAAiB,kBACpE,CAAC,CAAC;EACF,IAAI,iBAAiB,GAAG,WAAW,0BAA0B;EAC7D,MAAM,sBAAsB,WAAW,MAAM,QAC1C,OAAO,SACN,SAAS,KAAK,QAAQ,QAAQ,UAAU,MAAM,SAAS,YAAY,CAAC,CAAC,UAAU,IACjF,CACF;EACA,IAAI,sBAAsB,GAAG,WAAW,+BAA+B;CACzE;CAEA,IAAI,WAAW,aAAa,QAE1B,WAAW,uBAAuB,WAAW,YAAY,KAAK,YAAY;EACxE,MAAM,OAAO;EACb,WAAW,OAAO;EAClB,aAAa,OAAO;EACpB,UAAU,OAAO;EACjB,QAAQ,OAAO;EACf,GAAI,OAAO,aACP;GACE,mBAAmB,OAAO,WAAW;GACrC,iBAAiB,OAAO,WAAW;EACrC,IACA,CAAC;CACP,EAAE;CAGJ,IAAI,WAAW,OAAO,SAAS,QAC7B,WAAW,sBAAsB,WAAW,MAAM;CAGpD,IAAI,WAAW,OAAO,aAAa,QACjC,WAAW,0BAA0B,WAAW,MAAM;CAOxD,IAAI,WAAW,eAAe,QAC5B,WAAW,sBAAsB,WAAW;CAG9C,IAAI,WAAW,kBAAkB,QAC/B,WAAW,yBAAyB,WAAW;AAEnD;AAEA,SAAS,sBACP,YACA,YACM;CACN,IAAI,WAAW,iBAAiB,QAC9B,WAAW,mBAAmB,WAAW;CAG3C,IAAI,WAAW,cAAc,QAC3B,WAAW,wBAAwB,WAAW;CAGhD,IAAI,WAAW,UAAU,QACvB,WAAW,oBAAoB,OAAO,KAAK,WAAW,KAAK,CAAC,CAAC;AAEjE;AAEA,SAAS,wBACP,YACA,YACM;CACN,IAAI,WAAW,mBAAmB,QAChC,WAAW,qBAAqB,WAAW;CAG7C,IAAI,WAAW,iBAAiB,QAC9B,WAAW,6BAA6B,WAAW;CAGrD,IAAI,WAAW,eAAe,QAC5B,WAAW,2BAA2B,WAAW;AAErD;AAEA,SAAS,0BACP,YACA,YACM;CACN,IAAI,WAAW,cAAc,QAC3B,WAAW,4BAA4B,WAAW;CAGpD,IAAI,WAAW,cAAc,QAC3B,WAAW,4BAA4B,WAAW;CAGpD,IAAI,MAAM,QAAQ,WAAW,KAAK,GAChC,WAAW,wBAAwB,WAAW,MAAM;AAExD;AAEA,SAAS,kBACP,YACA,YACM;CACN,IAAI,WAAW,cAAc,QAC3B,WAAW,oBAAoB,WAAW;CAG5C,IAAI,WAAW,WAAW,QACxB,WAAW,iBAAiB,WAAW;CAGzC,IAAI,WAAW,kBAAkB,QAC/B,WAAW,wBAAwB,WAAW;AAElD"}
|
|
@@ -3,4 +3,6 @@ import { CollectorOptions, ExporterErrorHandler, createCollector } from "./colle
|
|
|
3
3
|
import { reportToTrace } from "./report-to-trace.mjs";
|
|
4
4
|
import { reportToSpan } from "./report-to-span.mjs";
|
|
5
5
|
import { extractSpanAttributes } from "./extract-span-attributes.mjs";
|
|
6
|
-
import { normalizeError } from "./normalize-error.mjs";
|
|
6
|
+
import { normalizeError } from "./normalize-error.mjs";
|
|
7
|
+
import { TraceListener, subscribeTraces } from "./trace-subscriptions.mjs";
|
|
8
|
+
export { type CollectorOptions, type ContentCaptureOptions, type ContentRedactor, type ExporterErrorHandler, type TraceListener, createCollector, extractSpanAttributes, normalizeError, reportToSpan, reportToTrace, subscribeTraces };
|
package/esm/collector/index.mjs
CHANGED
|
@@ -2,6 +2,7 @@ import { normalizeError } from "./normalize-error.mjs";
|
|
|
2
2
|
import { extractSpanAttributes } from "./extract-span-attributes.mjs";
|
|
3
3
|
import { reportToSpan } from "./report-to-span.mjs";
|
|
4
4
|
import { reportToTrace } from "./report-to-trace.mjs";
|
|
5
|
+
import { subscribeTraces } from "./trace-subscriptions.mjs";
|
|
5
6
|
import { createCollector } from "./collector.mjs";
|
|
6
7
|
|
|
7
|
-
export {
|
|
8
|
+
export { createCollector, extractSpanAttributes, normalizeError, reportToSpan, reportToTrace, subscribeTraces };
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { TraceSpanError } from "../contracts/trace.type.mjs";
|
|
2
|
-
|
|
3
2
|
//#region ../../packages/ai-panoptic/src/collector/normalize-error.d.ts
|
|
4
3
|
/**
|
|
5
4
|
* Project a captured execution error onto the structural
|
|
@@ -21,7 +20,6 @@ import { TraceSpanError } from "../contracts/trace.type.mjs";
|
|
|
21
20
|
* const spanError = normalizeError(report.error);
|
|
22
21
|
* // { type: "RATE_LIMIT", message: "429 Too Many Requests", stack: "..." }
|
|
23
22
|
*/
|
|
24
|
-
declare function normalizeError(error: unknown): TraceSpanError | undefined;
|
|
23
|
+
export declare function normalizeError(error: unknown): TraceSpanError | undefined;
|
|
25
24
|
//#endregion
|
|
26
|
-
export { normalizeError };
|
|
27
25
|
//# sourceMappingURL=normalize-error.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"normalize-error.d.mts","names":[],"sources":["../../../../../../../../packages/ai-panoptic/src/collector/normalize-error.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"normalize-error.d.mts","names":[],"sources":["../../../../../../../../packages/ai-panoptic/src/collector/normalize-error.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;wBAuBgB,eAAe,iBAAiB"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { TraceSpan } from "../contracts/trace.type.mjs";
|
|
2
2
|
import { ContentCaptureOptions } from "./content-capture.type.mjs";
|
|
3
3
|
import { BaseReport } from "@warlock.js/ai";
|
|
4
|
-
|
|
5
4
|
//#region ../../packages/ai-panoptic/src/collector/report-to-span.d.ts
|
|
6
5
|
/**
|
|
7
6
|
* Project one {@link BaseReport} node — and its entire subtree — into a
|
|
@@ -32,7 +31,6 @@ import { BaseReport } from "@warlock.js/ai";
|
|
|
32
31
|
* const root = reportToSpan(result.report);
|
|
33
32
|
* console.log(root.spanId, root.traceId, root.children.length);
|
|
34
33
|
*/
|
|
35
|
-
declare function reportToSpan(report: BaseReport, options?: ContentCaptureOptions): TraceSpan;
|
|
34
|
+
export declare function reportToSpan(report: BaseReport, options?: ContentCaptureOptions): TraceSpan;
|
|
36
35
|
//#endregion
|
|
37
|
-
export { reportToSpan };
|
|
38
36
|
//# sourceMappingURL=report-to-span.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"report-to-span.d.mts","names":[],"sources":["../../../../../../../../packages/ai-panoptic/src/collector/report-to-span.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"report-to-span.d.mts","names":[],"sources":["../../../../../../../../packages/ai-panoptic/src/collector/report-to-span.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBAmCgB,aAAa,QAAQ,YAAY,UAAU,wBAAwB"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { Trace } from "../contracts/trace.type.mjs";
|
|
2
2
|
import { ContentCaptureOptions } from "./content-capture.type.mjs";
|
|
3
3
|
import { BaseReport } from "@warlock.js/ai";
|
|
4
|
-
|
|
5
4
|
//#region ../../packages/ai-panoptic/src/collector/report-to-trace.d.ts
|
|
6
5
|
/**
|
|
7
6
|
* Project an outermost {@link BaseReport} (one whole `.execute()` /
|
|
@@ -33,7 +32,6 @@ import { BaseReport } from "@warlock.js/ai";
|
|
|
33
32
|
* const trace = reportToTrace(result.report, result.error);
|
|
34
33
|
* console.log(trace.traceId, trace.usage.total, trace.duration);
|
|
35
34
|
*/
|
|
36
|
-
declare function reportToTrace(report: BaseReport, rootError?: unknown, options?: ContentCaptureOptions): Trace;
|
|
35
|
+
export declare function reportToTrace(report: BaseReport, rootError?: unknown, options?: ContentCaptureOptions): Trace;
|
|
37
36
|
//#endregion
|
|
38
|
-
export { reportToTrace };
|
|
39
37
|
//# sourceMappingURL=report-to-trace.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"report-to-trace.d.mts","names":[],"sources":["../../../../../../../../packages/ai-panoptic/src/collector/report-to-trace.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"report-to-trace.d.mts","names":[],"sources":["../../../../../../../../packages/ai-panoptic/src/collector/report-to-trace.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBAoCgB,cACd,QAAQ,YACR,qBACA,UAAU,wBACT"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Trace } from "../contracts/trace.type.mjs";
|
|
2
|
+
//#region ../../packages/ai-panoptic/src/collector/trace-subscriptions.d.ts
|
|
3
|
+
/** Receives a finalized trace in the collecting call's async context. Treat it as read-only. */
|
|
4
|
+
export type TraceListener = (trace: Trace) => void | Promise<void>;
|
|
5
|
+
/**
|
|
6
|
+
* Subscribe to traces from every built-in collector in this process, including
|
|
7
|
+
* collectors created before subscribing. No replay or retention. Called before
|
|
8
|
+
* exporter dispatch, so adapters can read request-local context synchronously.
|
|
9
|
+
* Listener failures are isolated; async listeners are not awaited. The returned
|
|
10
|
+
* disposer removes only this subscription. Does not enable flow observation.
|
|
11
|
+
*/
|
|
12
|
+
export declare function subscribeTraces(listener: TraceListener): () => void;
|
|
13
|
+
//#endregion
|
|
14
|
+
//# sourceMappingURL=trace-subscriptions.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"trace-subscriptions.d.mts","names":[],"sources":["../../../../../../../../packages/ai-panoptic/src/collector/trace-subscriptions.ts"],"mappings":";;;YAGY,iBAAiB,OAAO,iBAAiB;;;;;;;;wBAWrC,gBAAgB,UAAU"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
//#region ../../packages/ai-panoptic/src/collector/trace-subscriptions.ts
|
|
2
|
+
const listeners = /* @__PURE__ */ new Set();
|
|
3
|
+
/**
|
|
4
|
+
* Subscribe to traces from every built-in collector in this process, including
|
|
5
|
+
* collectors created before subscribing. No replay or retention. Called before
|
|
6
|
+
* exporter dispatch, so adapters can read request-local context synchronously.
|
|
7
|
+
* Listener failures are isolated; async listeners are not awaited. The returned
|
|
8
|
+
* disposer removes only this subscription. Does not enable flow observation.
|
|
9
|
+
*/
|
|
10
|
+
function subscribeTraces(listener) {
|
|
11
|
+
const subscription = (trace) => listener(trace);
|
|
12
|
+
listeners.add(subscription);
|
|
13
|
+
return () => {
|
|
14
|
+
listeners.delete(subscription);
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
/** Internal collector notification; pure toTrace projections never publish. */
|
|
18
|
+
function publishTrace(trace) {
|
|
19
|
+
for (const listener of listeners) try {
|
|
20
|
+
Promise.resolve(listener(trace)).catch(() => {});
|
|
21
|
+
} catch {}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
//#endregion
|
|
25
|
+
export { publishTrace, subscribeTraces };
|
|
26
|
+
//# sourceMappingURL=trace-subscriptions.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"trace-subscriptions.mjs","names":[],"sources":["../../../../../../../../packages/ai-panoptic/src/collector/trace-subscriptions.ts"],"sourcesContent":["import type { Trace } from \"../contracts/trace.type\";\n\n/** Receives a finalized trace in the collecting call's async context. Treat it as read-only. */\nexport type TraceListener = (trace: Trace) => void | Promise<void>;\n\nconst listeners = new Set<TraceListener>();\n\n/**\n * Subscribe to traces from every built-in collector in this process, including\n * collectors created before subscribing. No replay or retention. Called before\n * exporter dispatch, so adapters can read request-local context synchronously.\n * Listener failures are isolated; async listeners are not awaited. The returned\n * disposer removes only this subscription. Does not enable flow observation.\n */\nexport function subscribeTraces(listener: TraceListener): () => void {\n const subscription: TraceListener = (trace) => listener(trace);\n listeners.add(subscription);\n return () => {\n listeners.delete(subscription);\n };\n}\n\n/** Internal collector notification; pure toTrace projections never publish. */\nexport function publishTrace(trace: Trace): void {\n for (const listener of listeners) {\n try {\n void Promise.resolve(listener(trace)).catch(() => {});\n } catch {\n // A dashboard or adapter must never fail the originating AI run.\n }\n }\n}\n"],"mappings":";AAKA,MAAM,4BAAY,IAAI,IAAmB;;;;;;;;AASzC,SAAgB,gBAAgB,UAAqC;CACnE,MAAM,gBAA+B,UAAU,SAAS,KAAK;CAC7D,UAAU,IAAI,YAAY;CAC1B,aAAa;EACX,UAAU,OAAO,YAAY;CAC/B;AACF;;AAGA,SAAgB,aAAa,OAAoB;CAC/C,KAAK,MAAM,YAAY,WACrB,IAAI;EACF,AAAK,QAAQ,QAAQ,SAAS,KAAK,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC;CACtD,QAAQ,CAER;AAEJ"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import "../dashboard/dashboard.type.mjs";
|
|
1
2
|
import { PanopticConfig } from "./panoptic-config.type.mjs";
|
|
2
|
-
|
|
3
3
|
//#region ../../packages/ai-panoptic/src/config/apply-panoptic-config.d.ts
|
|
4
4
|
/**
|
|
5
5
|
* Read a {@link PanopticConfig} and wire panoptic onto the core observe
|
|
@@ -21,7 +21,6 @@ import { PanopticConfig } from "./panoptic-config.type.mjs";
|
|
|
21
21
|
* one and a fresh store was created — primarily for tests; callers can
|
|
22
22
|
* ignore it.
|
|
23
23
|
*/
|
|
24
|
-
declare function applyPanopticConfig(config?: PanopticConfig): void;
|
|
24
|
+
export declare function applyPanopticConfig(config?: PanopticConfig): void;
|
|
25
25
|
//#endregion
|
|
26
|
-
export { applyPanopticConfig };
|
|
27
26
|
//# sourceMappingURL=apply-panoptic-config.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"apply-panoptic-config.d.mts","names":[],"sources":["../../../../../../../../packages/ai-panoptic/src/config/apply-panoptic-config.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"apply-panoptic-config.d.mts","names":[],"sources":["../../../../../../../../packages/ai-panoptic/src/config/apply-panoptic-config.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;wBAiDgB,oBAAoB,SAAS"}
|
package/esm/config/index.d.mts
CHANGED
package/esm/config/index.mjs
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { ExporterContract } from "../contracts/exporter.contract.mjs";
|
|
2
2
|
import { CacheDriverInput } from "../store/cache-trace-store.mjs";
|
|
3
3
|
import { DashboardOptions } from "../dashboard/dashboard.type.mjs";
|
|
4
|
-
|
|
5
4
|
//#region ../../packages/ai-panoptic/src/config/panoptic-config.type.d.ts
|
|
6
5
|
/**
|
|
7
6
|
* Declarative panoptic configuration, set once through the global
|
|
@@ -25,7 +24,7 @@ import { DashboardOptions } from "../dashboard/dashboard.type.mjs";
|
|
|
25
24
|
* },
|
|
26
25
|
* });
|
|
27
26
|
*/
|
|
28
|
-
type PanopticConfig = {
|
|
27
|
+
export type PanopticConfig = {
|
|
29
28
|
/**
|
|
30
29
|
* Exporters the collector feeds (a store, OTel, Langfuse, …). A
|
|
31
30
|
* {@link import("../store/in-memory-trace-store").createInMemoryTraceStore}
|
|
@@ -89,7 +88,6 @@ declare module "@warlock.js/ai" {
|
|
|
89
88
|
/** Declarative panoptic observability config. See {@link PanopticConfig}. */
|
|
90
89
|
panoptic?: PanopticConfig;
|
|
91
90
|
}
|
|
92
|
-
}
|
|
91
|
+
}
|
|
93
92
|
//#endregion
|
|
94
|
-
export { PanopticConfig };
|
|
95
93
|
//# sourceMappingURL=panoptic-config.type.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"panoptic-config.type.d.mts","names":[],"sources":["../../../../../../../../packages/ai-panoptic/src/config/panoptic-config.type.ts"],"mappings":";;;;;;;
|
|
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;;;;;;EAMtB;;;;;;EAMA;;;;;;EAMA;;;;;;;;;;;EAWA,WAAW;;;YAQD;;IAER,WAAW"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { Trace } from "./trace.type.mjs";
|
|
2
2
|
import { ExporterContract } from "./exporter.contract.mjs";
|
|
3
3
|
import { BaseReport } from "@warlock.js/ai";
|
|
4
|
-
|
|
5
4
|
//#region ../../packages/ai-panoptic/src/contracts/collector.contract.d.ts
|
|
6
5
|
/**
|
|
7
6
|
* Contract for the Panoptic collector — the source end of the
|
|
@@ -21,7 +20,7 @@ import { BaseReport } from "@warlock.js/ai";
|
|
|
21
20
|
* // on shutdown:
|
|
22
21
|
* await collector.shutdown();
|
|
23
22
|
*/
|
|
24
|
-
interface CollectorContract {
|
|
23
|
+
export interface CollectorContract {
|
|
25
24
|
/**
|
|
26
25
|
* Register an exporter. Returns the collector for chaining. Duplicate
|
|
27
26
|
* registration (same `ExporterContract.name`) is ignored.
|
|
@@ -59,5 +58,4 @@ interface CollectorContract {
|
|
|
59
58
|
shutdown(): Promise<void>;
|
|
60
59
|
}
|
|
61
60
|
//#endregion
|
|
62
|
-
export { CollectorContract };
|
|
63
61
|
//# sourceMappingURL=collector.contract.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"collector.contract.d.mts","names":[],"sources":["../../../../../../../../packages/ai-panoptic/src/contracts/collector.contract.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"collector.contract.d.mts","names":[],"sources":["../../../../../../../../packages/ai-panoptic/src/contracts/collector.contract.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;iBAsBiB;;;;;EAKf,IAAI,UAAU;;;;;;;;;;;;;EAcd,QAAQ,QAAQ,YAAY,sBAAsB;;;;;;;EAQlD,QAAQ,QAAQ,YAAY,sBAAsB;;;;;EAMlD,SAAS;;;;;EAMT,YAAY"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Trace, TraceSpan } from "./trace.type.mjs";
|
|
2
|
-
|
|
3
2
|
//#region ../../packages/ai-panoptic/src/contracts/exporter.contract.d.ts
|
|
4
3
|
/**
|
|
5
4
|
* Contract every Panoptic exporter implements. An exporter is the sink
|
|
@@ -35,7 +34,7 @@ import { Trace, TraceSpan } from "./trace.type.mjs";
|
|
|
35
34
|
* },
|
|
36
35
|
* };
|
|
37
36
|
*/
|
|
38
|
-
interface ExporterContract {
|
|
37
|
+
export interface ExporterContract {
|
|
39
38
|
/**
|
|
40
39
|
* Stable identifier for this exporter (e.g. `"otel"`, `"langfuse"`,
|
|
41
40
|
* `"console"`). Used in logs and to de-duplicate exporters registered
|
|
@@ -72,5 +71,4 @@ interface ExporterContract {
|
|
|
72
71
|
shutdown?(): void | Promise<void>;
|
|
73
72
|
}
|
|
74
73
|
//#endregion
|
|
75
|
-
export { ExporterContract };
|
|
76
74
|
//# sourceMappingURL=exporter.contract.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exporter.contract.d.mts","names":[],"sources":["../../../../../../../../packages/ai-panoptic/src/contracts/exporter.contract.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"exporter.contract.d.mts","names":[],"sources":["../../../../../../../../packages/ai-panoptic/src/contracts/exporter.contract.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAoCiB;;;;;;WAMN;;;;;;EAOT,OAAO,OAAO,eAAe;;;;;;;;;;EAW7B,YAAY,MAAM,mBAAmB;;;;;;EAOrC,iBAAiB;;;;;;EAOjB,oBAAoB"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import { Trace, TraceSpan, TraceSpanError } from "./trace.type.mjs";
|
|
2
2
|
import { ExporterContract } from "./exporter.contract.mjs";
|
|
3
|
-
import { CollectorContract } from "./collector.contract.mjs";
|
|
3
|
+
import { CollectorContract } from "./collector.contract.mjs";
|
|
4
|
+
export type { CollectorContract, ExporterContract, Trace, TraceSpan, TraceSpanError };
|