@tangle-network/agent-eval 1.0.23 → 1.0.24
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 +41 -0
- package/dist/adapters/http.d.ts +2 -2
- package/dist/{agent-profile-C80hNPYb.d.ts → agent-profile-DC_v4p1f.d.ts} +3 -3
- package/dist/{agent-profile-C80hNPYb.d.ts.map → agent-profile-DC_v4p1f.d.ts.map} +1 -1
- package/dist/analyst/index.d.ts +14 -14
- package/dist/analyst/index.js +9 -9
- package/dist/{analyze-runs-DbHQHvDC.d.ts → analyze-runs-DGr7mpC3.d.ts} +4 -4
- package/dist/{analyze-runs-DbHQHvDC.d.ts.map → analyze-runs-DGr7mpC3.d.ts.map} +1 -1
- package/dist/app-grade/index.d.ts +4 -4
- package/dist/app-grade/index.js +3 -3
- package/dist/{benchmark-command-DkUpd9Q6.js → benchmark-command-DRAHkn4D.js} +8 -9
- package/dist/{benchmark-command-DkUpd9Q6.js.map → benchmark-command-DRAHkn4D.js.map} +1 -1
- package/dist/benchmarks/index.d.ts +4 -4
- package/dist/benchmarks/index.js +3 -3
- package/dist/campaign/index.d.ts +7 -7
- package/dist/campaign/index.js +4 -4
- package/dist/{campaign-D00Tbey-.js → campaign-C9QC27C2.js} +6 -6
- package/dist/{campaign-D00Tbey-.js.map → campaign-C9QC27C2.js.map} +1 -1
- package/dist/{chat-client-Zz97O3NB.js → chat-client-9XLgWrQ7.js} +5 -3
- package/dist/chat-client-9XLgWrQ7.js.map +1 -0
- package/dist/{chat-json-call-Dgi7-RH-.js → chat-json-call-CaNO3k0A.js} +2 -2
- package/dist/{chat-json-call-Dgi7-RH-.js.map → chat-json-call-CaNO3k0A.js.map} +1 -1
- package/dist/cli.js +3 -3
- package/dist/{cluster-Cd0MRbr9.d.ts → cluster-CkzP4h3T.d.ts} +4 -2
- package/dist/{cluster-Cd0MRbr9.d.ts.map → cluster-CkzP4h3T.d.ts.map} +1 -1
- package/dist/{completion-verifier-DFyYFezn.js → completion-verifier-BYLOcQt7.js} +5 -4
- package/dist/completion-verifier-BYLOcQt7.js.map +1 -0
- package/dist/{completion-verifier-BEpsr3N4.d.ts → completion-verifier-CJVDPv2T.d.ts} +3 -2
- package/dist/{completion-verifier-BEpsr3N4.d.ts.map → completion-verifier-CJVDPv2T.d.ts.map} +1 -1
- package/dist/contract/index.d.ts +10 -10
- package/dist/contract/index.js +7 -8
- package/dist/contract/index.js.map +1 -1
- package/dist/{cost-ledger-DfhStGcZ.js → cost-ledger-1CwUnVOd.js} +145 -3
- package/dist/cost-ledger-1CwUnVOd.js.map +1 -0
- package/dist/{decision-point-Di2LATNH.js → decision-point-CQOczIIH.js} +2 -2
- package/dist/{decision-point-Di2LATNH.js.map → decision-point-CQOczIIH.js.map} +1 -1
- package/dist/{default-registry-CjgRr-l7.d.ts → default-registry-C_Akmpui.d.ts} +7 -7
- package/dist/{default-registry-CjgRr-l7.d.ts.map → default-registry-C_Akmpui.d.ts.map} +1 -1
- package/dist/{default-registry-CdFbxPnr.js → default-registry-D-xd7KxV.js} +5 -5
- package/dist/{default-registry-CdFbxPnr.js.map → default-registry-D-xd7KxV.js.map} +1 -1
- package/dist/{define-agent-eval-BV16x8C0.js → define-agent-eval-BLVewqJm.js} +3 -3
- package/dist/{define-agent-eval-BV16x8C0.js.map → define-agent-eval-BLVewqJm.js.map} +1 -1
- package/dist/{define-agent-eval-BQBwKHwF.d.ts → define-agent-eval-nNPC7cD5.d.ts} +7 -7
- package/dist/{define-agent-eval-BQBwKHwF.d.ts.map → define-agent-eval-nNPC7cD5.d.ts.map} +1 -1
- package/dist/diagnosis/index.d.ts +2 -2
- package/dist/{dspy-rlm-engine-cWyn8G1a.js → dspy-rlm-engine-BS_jxE0P.js} +4 -4
- package/dist/{dspy-rlm-engine-cWyn8G1a.js.map → dspy-rlm-engine-BS_jxE0P.js.map} +1 -1
- package/dist/{engine-s3t6uYH9.d.ts → engine-B0gr15-l.d.ts} +2 -2
- package/dist/{engine-s3t6uYH9.d.ts.map → engine-B0gr15-l.d.ts.map} +1 -1
- package/dist/{evaluation-bU_bhlv-.js → evaluation-C_GJvEEG.js} +2 -2
- package/dist/{evaluation-bU_bhlv-.js.map → evaluation-C_GJvEEG.js.map} +1 -1
- package/dist/{evaluation-DRgHKEVV.d.ts → evaluation-mk3u_ZJC.d.ts} +4 -4
- package/dist/{evaluation-DRgHKEVV.d.ts.map → evaluation-mk3u_ZJC.d.ts.map} +1 -1
- package/dist/evaluation.d.ts +1 -1
- package/dist/evaluation.js +1 -1
- package/dist/{exact-types-DTlZSygs.d.ts → exact-types-Blq7YvsK.d.ts} +2 -2
- package/dist/{exact-types-DTlZSygs.d.ts.map → exact-types-Blq7YvsK.d.ts.map} +1 -1
- package/dist/experiment/index.d.ts +3 -3
- package/dist/{external-optimizer-process-2ImGH_LR.js → external-optimizer-process-m9xln7zN.js} +2 -2
- package/dist/{external-optimizer-process-2ImGH_LR.js.map → external-optimizer-process-m9xln7zN.js.map} +1 -1
- package/dist/{external-optimizer-subprocess-_C_2yriN.js → external-optimizer-subprocess-GO6s84Ov.js} +3 -3
- package/dist/{external-optimizer-subprocess-_C_2yriN.js.map → external-optimizer-subprocess-GO6s84Ov.js.map} +1 -1
- package/dist/{feedback-trajectory-DrKk79NU.d.ts → feedback-trajectory-D3oISeGl.d.ts} +3 -3
- package/dist/{feedback-trajectory-DrKk79NU.d.ts.map → feedback-trajectory-D3oISeGl.d.ts.map} +1 -1
- package/dist/{findings-store-BSuaV3dN.js → findings-store-CTy71Lnr.js} +5 -5
- package/dist/{findings-store-BSuaV3dN.js.map → findings-store-CTy71Lnr.js.map} +1 -1
- package/dist/fuzz.js +1 -1
- package/dist/{index-DNXFzSpc.d.ts → index-BN6htPVi.d.ts} +2 -2
- package/dist/{index-DNXFzSpc.d.ts.map → index-BN6htPVi.d.ts.map} +1 -1
- package/dist/{index-DAnkXnwF.d.ts → index-BdFlQP54.d.ts} +3 -3
- package/dist/{index-DAnkXnwF.d.ts.map → index-BdFlQP54.d.ts.map} +1 -1
- package/dist/{index-DtX456kD.d.ts → index-CxuK3sxA.d.ts} +9 -9
- package/dist/{index-DtX456kD.d.ts.map → index-CxuK3sxA.d.ts.map} +1 -1
- package/dist/{index-DZ_aqB7v.d.ts → index-Dodw93oW.d.ts} +23 -23
- package/dist/{index-DZ_aqB7v.d.ts.map → index-Dodw93oW.d.ts.map} +1 -1
- package/dist/{index-DjrXBogW.d.ts → index-IE8O0HNr.d.ts} +8 -8
- package/dist/{index-DjrXBogW.d.ts.map → index-IE8O0HNr.d.ts.map} +1 -1
- package/dist/{index-DwscLCQX.d.ts → index-KAYaJtMA.d.ts} +3 -3
- package/dist/{index-DwscLCQX.d.ts.map → index-KAYaJtMA.d.ts.map} +1 -1
- package/dist/{index-DLZp90hM.d.ts → index-cp5gkylN.d.ts} +10 -10
- package/dist/{index-DLZp90hM.d.ts.map → index-cp5gkylN.d.ts.map} +1 -1
- package/dist/index.d.ts +27 -27
- package/dist/index.js +62 -21
- package/dist/index.js.map +1 -1
- package/dist/{integrity-CrmnGB2T.d.ts → integrity-zeWMeTQt.d.ts} +2 -2
- package/dist/{integrity-CrmnGB2T.d.ts.map → integrity-zeWMeTQt.d.ts.map} +1 -1
- package/dist/{judge-gate-CrN0PaAL.js → judge-gate-DsoI5tx7.js} +2 -2
- package/dist/{judge-gate-CrN0PaAL.js.map → judge-gate-DsoI5tx7.js.map} +1 -1
- package/dist/{kind-factory-CV0FNCMM.js → kind-factory-CJXaE1oF.js} +2 -2
- package/dist/{kind-factory-CV0FNCMM.js.map → kind-factory-CJXaE1oF.js.map} +1 -1
- package/dist/{llm-client-DMMSg-Ro.js → llm-client-Bj-TooRS.js} +11 -11
- package/dist/{llm-client-DMMSg-Ro.js.map → llm-client-Bj-TooRS.js.map} +1 -1
- package/dist/{llm-judge-Cbh7OHaO.js → llm-judge-DzAT7Wka.js} +5 -5
- package/dist/{llm-judge-Cbh7OHaO.js.map → llm-judge-DzAT7Wka.js.map} +1 -1
- package/dist/{matrix-8NhGDcmi.d.ts → matrix-Diw3yJCG.d.ts} +3 -4
- package/dist/matrix-Diw3yJCG.d.ts.map +1 -0
- package/dist/meta-eval/index.d.ts +2 -2
- package/dist/meta-eval/index.js +2 -2
- package/dist/multishot/golden/index.d.ts +1 -1
- package/dist/multishot/index.d.ts +3 -2
- package/dist/multishot/index.d.ts.map +1 -1
- package/dist/multishot/index.js +3 -3
- package/dist/multishot/index.js.map +1 -1
- package/dist/openapi.json +1 -1
- package/dist/{paired-promotion-decision-DJU3fZxH.d.ts → paired-promotion-decision-COeOgNHG.d.ts} +2 -2
- package/dist/{paired-promotion-decision-DJU3fZxH.d.ts.map → paired-promotion-decision-COeOgNHG.d.ts.map} +1 -1
- package/dist/{prime-protocol-CKxq_-cx.d.ts → prime-protocol-bRbh6dqd.d.ts} +2 -2
- package/dist/{prime-protocol-CKxq_-cx.d.ts.map → prime-protocol-bRbh6dqd.d.ts.map} +1 -1
- package/dist/{promotion-gate-HDtliGsh.d.ts → promotion-gate-XglbDCNo.d.ts} +2 -2
- package/dist/{promotion-gate-HDtliGsh.d.ts.map → promotion-gate-XglbDCNo.d.ts.map} +1 -1
- package/dist/{proposal-findings-DWs94yT8.js → proposal-findings-CS6LoGGp.js} +2 -2
- package/dist/{proposal-findings-DWs94yT8.js.map → proposal-findings-CS6LoGGp.js.map} +1 -1
- package/dist/{registry-BnenKvxM.d.ts → registry-Pfeqsr5k.d.ts} +4 -4
- package/dist/{registry-BnenKvxM.d.ts.map → registry-Pfeqsr5k.d.ts.map} +1 -1
- package/dist/reporting.d.ts +4 -4
- package/dist/{researcher-DEpedkOZ.d.ts → researcher-DlyjP5uq.d.ts} +4 -4
- package/dist/{researcher-DEpedkOZ.d.ts.map → researcher-DlyjP5uq.d.ts.map} +1 -1
- package/dist/rl.d.ts +8 -8
- package/dist/rl.js.map +1 -1
- package/dist/rollout/index.d.ts +2 -2
- package/dist/rollout/index.js +1 -1
- package/dist/{rollout-DWl3Gg6A.js → rollout-Dh5q6CPA.js} +2 -2
- package/dist/{rollout-DWl3Gg6A.js.map → rollout-Dh5q6CPA.js.map} +1 -1
- package/dist/search/index.d.ts +2 -2
- package/dist/{search-kernel-CoDJ21q9.d.ts → search-kernel-6P1dRpJ4.d.ts} +3 -3
- package/dist/{search-kernel-CoDJ21q9.d.ts.map → search-kernel-6P1dRpJ4.d.ts.map} +1 -1
- package/dist/{sequential-BCzXKQab.d.ts → sequential-OeSwJ2uG.d.ts} +2 -2
- package/dist/{sequential-BCzXKQab.d.ts.map → sequential-OeSwJ2uG.d.ts.map} +1 -1
- package/dist/{server-DFVwfoZq.js → server-BorE0Y3O.js} +16 -5
- package/dist/server-BorE0Y3O.js.map +1 -0
- package/dist/{skillopt-optimization-method-B1Hkfexf.js → skillopt-optimization-method-BtX7xXDd.js} +5 -5
- package/dist/{skillopt-optimization-method-B1Hkfexf.js.map → skillopt-optimization-method-BtX7xXDd.js.map} +1 -1
- package/dist/{statistical-heldout-e2hbqDui.d.ts → statistical-heldout-vjrs8iyO.d.ts} +5 -5
- package/dist/{statistical-heldout-e2hbqDui.d.ts.map → statistical-heldout-vjrs8iyO.d.ts.map} +1 -1
- package/dist/statistics.d.ts +2 -2
- package/dist/{store-otlp-C-jyj3WX.js → store-otlp-CmgKDr0O.js} +2 -2
- package/dist/{store-otlp-C-jyj3WX.js.map → store-otlp-CmgKDr0O.js.map} +1 -1
- package/dist/{store-tool-spans-mlmGj6n3.d.ts → store-tool-spans-BemsQEhd.d.ts} +5 -5
- package/dist/{store-tool-spans-mlmGj6n3.d.ts.map → store-tool-spans-BemsQEhd.d.ts.map} +1 -1
- package/dist/{store-tool-spans-DalWlKY8.js → store-tool-spans-CW24axM0.js} +3 -3
- package/dist/{store-tool-spans-DalWlKY8.js.map → store-tool-spans-CW24axM0.js.map} +1 -1
- package/dist/{summary-report-DsiORzPc.d.ts → summary-report-vdhE20Zf.d.ts} +2 -2
- package/dist/{summary-report-DsiORzPc.d.ts.map → summary-report-vdhE20Zf.d.ts.map} +1 -1
- package/dist/supervisor-run/index.d.ts +1 -1
- package/dist/{systemone-B93onE_a.d.ts → systemone-DFUN9DL1.d.ts} +7 -7
- package/dist/{systemone-B93onE_a.d.ts.map → systemone-DFUN9DL1.d.ts.map} +1 -1
- package/dist/{systemone-review-BIggseLt.d.ts → systemone-review-4CKmHvr5.d.ts} +2 -2
- package/dist/{systemone-review-BIggseLt.d.ts.map → systemone-review-4CKmHvr5.d.ts.map} +1 -1
- package/dist/systemone.d.ts +3 -3
- package/dist/systemone.js +2 -2
- package/dist/{tool-groups-CCiATVZw.d.ts → tool-groups-Dpl3picW.d.ts} +3 -3
- package/dist/tool-groups-Dpl3picW.d.ts.map +1 -0
- package/dist/{trace-questions-B7lkyOlo.d.ts → trace-questions-oT2fZWJ8.d.ts} +3 -3
- package/dist/{trace-questions-B7lkyOlo.d.ts.map → trace-questions-oT2fZWJ8.d.ts.map} +1 -1
- package/dist/trace-repair/index.d.ts +1 -1
- package/dist/traces.d.ts +5 -5
- package/dist/traces.js +3 -3
- package/dist/{types-Ob1blgI2.d.ts → types-6GuPL-Vt.d.ts} +2 -2
- package/dist/{types-Ob1blgI2.d.ts.map → types-6GuPL-Vt.d.ts.map} +1 -1
- package/dist/{types-efIQ03Uo.d.ts → types-C9yEqDjQ.d.ts} +4 -4
- package/dist/{types-efIQ03Uo.d.ts.map → types-C9yEqDjQ.d.ts.map} +1 -1
- package/dist/{types-3uX8odDK.d.ts → types-CP3rkpir.d.ts} +2 -2
- package/dist/{types-3uX8odDK.d.ts.map → types-CP3rkpir.d.ts.map} +1 -1
- package/dist/{types-DUVhW5V1.d.ts → types-CwHU7U9J.d.ts} +2 -2
- package/dist/{types-DUVhW5V1.d.ts.map → types-CwHU7U9J.d.ts.map} +1 -1
- package/dist/wire/index.d.ts +4 -4
- package/dist/wire/index.d.ts.map +1 -1
- package/dist/wire/index.js +1 -1
- package/docs/wire-protocol.md +1 -1
- package/package.json +1 -1
- package/dist/chat-client-Zz97O3NB.js.map +0 -1
- package/dist/completion-verifier-DFyYFezn.js.map +0 -1
- package/dist/cost-ledger-DfhStGcZ.js.map +0 -1
- package/dist/matrix-8NhGDcmi.d.ts.map +0 -1
- package/dist/metrics-zALlR17s.js +0 -146
- package/dist/metrics-zALlR17s.js.map +0 -1
- package/dist/server-DFVwfoZq.js.map +0 -1
- package/dist/tool-groups-CCiATVZw.d.ts.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"store-tool-spans-DalWlKY8.js","names":[],"sources":["../src/trace/capture-fetch.ts","../src/trace/otel.ts","../src/trace-analyst/prompts.ts","../src/trace-analyst/analyst.ts","../src/trace-analyst/insights.ts","../src/trace/otlp-flat.ts","../src/trace-analyst/store-tool-spans.ts"],"sourcesContent":["/**\n * Wrap a provider `fetch` and record request, response, and error events.\n *\n * The returned value is a plain `typeof fetch`. Capture is best-effort by\n * default; set `failClosed` when telemetry loss must stop the provider call.\n */\n\nimport {\n type ExtractedUsage,\n extractUsage,\n extractUsageFromSse,\n type SseUsageMode,\n} from './extract-usage'\nimport {\n defaultProviderRedactor,\n type ProviderRedactor,\n providerFromBaseUrl,\n type RawProviderDirection,\n type RawProviderEvent,\n type RawProviderSink,\n} from './raw-provider-sink'\n\nexport interface CaptureFetchContext {\n /** Logical run id stamped on every captured event. Required — without it\n * the raw events can't be paired with their parent `Run`. */\n runId: string\n /** Optional logical span id (enables span-level sink filtering). */\n spanId?: string\n /** Resolved base URL (normalised, no trailing slash). Used for the event's\n * `baseUrl` and for endpoint-path extraction. */\n baseUrl: string\n /** Model id the caller intends to invoke. Stamped on every event. */\n model: string\n /** Provider override. When omitted, `providerFromBaseUrl(baseUrl)`. */\n provider?: string\n}\n\nexport interface CaptureFetchOptions {\n /** Override the capture-time redactor. Default `defaultProviderRedactor`. */\n redactor?: ProviderRedactor\n /** Cap on captured response-body bytes; beyond it the body is truncated and\n * `body_truncated` is added to `redactedFields`. Default 2 MiB. */\n responseBodyByteCap?: number\n /** When true, a sink-write failure propagates to the caller. Default false\n * — capture is best-effort so a sink failure never kills the LLM call. */\n failClosed?: boolean\n /**\n * Invoked with the token usage parsed off each successful response (JSON or\n * SSE), keyed by the captured context. Lets a caller fold usage → cost without\n * re-cloning the response themselves. Not called when the response carries no\n * usage. Best-effort: a throw here is swallowed (it never kills the LLM call)\n * unless `failClosed` is set.\n */\n onUsage?: (usage: ExtractedUsage, ctx: CaptureFetchContext) => void\n /** How repeated SSE usage events should be reconciled. Default `cumulative`. */\n sseUsageMode?: SseUsageMode\n}\n\nconst DEFAULT_BODY_CAP = 2 * 1024 * 1024\n\nfunction headersToRecord(headers: Headers | undefined): Record<string, string> | undefined {\n if (!headers) return undefined\n const out: Record<string, string> = {}\n headers.forEach((value, key) => {\n out[key.toLowerCase()] = value\n })\n return Object.keys(out).length > 0 ? out : undefined\n}\n\nfunction parseMaybeJson(text: string): unknown {\n if (text.length === 0) return undefined\n try {\n return JSON.parse(text)\n } catch {\n return text\n }\n}\n\n/** Best-effort request-body read across the `fetch` input forms. */\nasync function readRequestBody(\n input: RequestInfo | URL,\n init: RequestInit | undefined,\n): Promise<unknown> {\n if (typeof init?.body === 'string') return parseMaybeJson(init.body)\n if (init?.body != null) return undefined // streams / FormData / Blob — not captured\n if (input instanceof Request) {\n try {\n return parseMaybeJson(await input.clone().text())\n } catch {\n return undefined\n }\n }\n return undefined\n}\n\nfunction endpointFromUrl(url: string, baseUrl: string): string {\n const normalisedBase = baseUrl.replace(/\\/+$/, '')\n if (url.startsWith(normalisedBase)) return url.slice(normalisedBase.length) || '/'\n try {\n return new URL(url).pathname\n } catch {\n return url\n }\n}\n\nexport function captureFetchToRawSink(\n fetch: typeof globalThis.fetch,\n sink: RawProviderSink,\n ctx: CaptureFetchContext,\n opts: CaptureFetchOptions = {},\n): typeof globalThis.fetch {\n const provider = ctx.provider ?? providerFromBaseUrl(ctx.baseUrl)\n const redactor = opts.redactor ?? defaultProviderRedactor\n const bodyCap = opts.responseBodyByteCap ?? DEFAULT_BODY_CAP\n let warned = false\n\n const baseEvent = (direction: RawProviderDirection, endpoint: string): RawProviderEvent => ({\n eventId: crypto.randomUUID(),\n runId: ctx.runId,\n spanId: ctx.spanId,\n provider,\n model: ctx.model,\n endpoint,\n baseUrl: ctx.baseUrl,\n attemptIndex: 0, // retries are re-invocations one layer up; documented in 0.x\n direction,\n timestamp: Date.now(),\n redactedFields: [],\n })\n\n const record = async (event: RawProviderEvent): Promise<void> => {\n try {\n await sink.record(redactor(event))\n } catch (err) {\n if (opts.failClosed) throw err\n if (!warned) {\n warned = true\n console.warn(\n `captureFetchToRawSink: sink.record failed (capture is best-effort) — ${\n err instanceof Error ? err.message : String(err)\n }`,\n )\n }\n }\n }\n\n return async (input: RequestInfo | URL, init?: RequestInit): Promise<Response> => {\n const url =\n typeof input === 'string' ? input : input instanceof URL ? input.toString() : input.url\n const method = (init?.method ?? (input instanceof Request ? input.method : 'GET')).toUpperCase()\n const endpoint = endpointFromUrl(url, ctx.baseUrl)\n\n const reqHeaders = new Headers(\n init?.headers ?? (input instanceof Request ? input.headers : undefined),\n )\n await record({\n ...baseEvent('request', endpoint),\n requestHeaders: { ...headersToRecord(reqHeaders), 'x-http-method': method },\n requestBody: await readRequestBody(input, init),\n })\n\n const start = Date.now()\n let response: Response\n try {\n response = await fetch(input, init)\n } catch (err) {\n await record({\n ...baseEvent('error', endpoint),\n durationMs: Date.now() - start,\n errorMessage: err instanceof Error ? err.message : String(err),\n })\n throw err\n }\n\n // Read the body off a clone so the caller still consumes the original.\n let responseBody: unknown\n let rawText: string | undefined\n const redactedFields: string[] = []\n try {\n rawText = await response.clone().text()\n if (rawText.length > bodyCap) {\n responseBody = rawText.slice(0, bodyCap)\n redactedFields.push('body_truncated')\n } else {\n responseBody = parseMaybeJson(rawText)\n }\n } catch {\n responseBody = undefined\n }\n\n if (opts.onUsage && rawText !== undefined) {\n // Reuse the body already read for capture; no extra clone. JSON first,\n // then SSE accumulation. A throw in the consumer's callback is swallowed\n // (best-effort) unless failClosed is set — the LLM call must not die here.\n try {\n const parsedForUsage = parseMaybeJson(rawText)\n const usage =\n extractUsage(parsedForUsage) ??\n (typeof parsedForUsage === 'string'\n ? extractUsageFromSse(rawText, { mode: opts.sseUsageMode })\n : null)\n if (usage) opts.onUsage(usage, ctx)\n } catch (err) {\n if (opts.failClosed) throw err\n }\n }\n\n await record({\n ...baseEvent('response', endpoint),\n durationMs: Date.now() - start,\n statusCode: response.status,\n responseHeaders: headersToRecord(response.headers),\n responseBody,\n redactedFields,\n })\n\n return response\n }\n}\n","/**\n * OpenTelemetry JSON export — maps TraceSchema v1 to OTLP/JSON so\n * traces render natively in Jaeger / Honeycomb / Langfuse / Grafana.\n *\n * Wire format only. We do NOT depend on the @opentelemetry SDK — that\n * would drag in polyfills incompatible with Workers/Edge. Consumers\n * push the JSON to their collector of choice via HTTP.\n *\n * Reference: OTLP 1.3.2 (ResourceSpans / ScopeSpans / Span).\n */\n\nimport { toW3CSpanId, toW3CTraceId } from '@tangle-network/agent-trace-contract'\nimport {\n msToUnixNano,\n type OtlpSpan,\n type OtlpTraceExport,\n otlpTraceExport,\n toOtlpAttributes,\n} from '@tangle-network/agent-trace-contract/otlp'\nimport {\n applyLlmSpanOtlpAttributes,\n applyToolSpanOtlpAttributes,\n OPENINFERENCE_SPAN_KIND,\n traceSpanKindToOpenInferenceKind,\n} from './otlp-attributes'\nimport type { Span, TraceEvent } from './schema'\nimport type { TraceStore } from './store'\n\nconst OTEL_AGENT_EVAL_SCOPE = { name: '@tangle-network/agent-eval', version: '0.3.0' }\n\nexport type { OtlpResourceSpans, OtlpSpan } from '@tangle-network/agent-trace-contract/otlp'\nexport type OtlpExport = OtlpTraceExport\n\n/** Export a single run's spans + events in OTLP/JSON. */\nexport async function exportRunAsOtlp(\n store: TraceStore,\n runId: string,\n resourceAttrs: Record<string, string | number | boolean> = {},\n): Promise<OtlpExport> {\n const run = await store.getRun(runId)\n if (!run) throw new Error(`run ${runId} not found`)\n const spans = await store.spans({ runId })\n const events = await store.events({ runId })\n const eventsBySpan = new Map<string, TraceEvent[]>()\n for (const e of events) {\n if (!e.spanId) continue\n const arr = eventsBySpan.get(e.spanId) ?? []\n arr.push(e)\n eventsBySpan.set(e.spanId, arr)\n }\n const traceId = toW3CTraceId(run.runId)\n const otlpSpans: OtlpSpan[] = spans.map((s) =>\n spanToOtlp(s, traceId, eventsBySpan.get(s.spanId) ?? []),\n )\n const resource = toOtlpAttributes({\n 'service.name': 'agent-eval',\n 'run.id': run.runId,\n 'run.scenario_id': run.scenarioId,\n 'run.variant_id': run.variantId ?? '',\n 'run.dataset_version': run.datasetVersion ?? '',\n 'run.code_sha': run.codeSha ?? '',\n 'run.model_fingerprint': run.modelFingerprint ?? '',\n ...resourceAttrs,\n })\n return otlpTraceExport(resource, OTEL_AGENT_EVAL_SCOPE, otlpSpans)\n}\n\nfunction spanToOtlp(span: Span, traceId: string, events: TraceEvent[]): OtlpSpan {\n const endedAt = span.endedAt ?? span.startedAt\n return {\n traceId,\n spanId: toW3CSpanId(span.spanId),\n parentSpanId: span.parentSpanId ? toW3CSpanId(span.parentSpanId) : undefined,\n name: span.name,\n kind: 1, // SPAN_KIND_INTERNAL\n startTimeUnixNano: msToUnixNano(span.startedAt),\n endTimeUnixNano: msToUnixNano(endedAt),\n attributes: toOtlpAttributes(flattenSpanAttributes(span)),\n events: events.map((e) => ({\n timeUnixNano: msToUnixNano(e.timestamp),\n name: e.kind,\n attributes: toOtlpAttributes(flattenPayload(e.payload)),\n })),\n status: span.status === 'error' ? { code: 2, message: span.error } : { code: 1 },\n }\n}\n\nfunction flattenSpanAttributes(span: Span): Record<string, string | number | boolean> {\n const base: Record<string, string | number | boolean> = {}\n if (span.attributes) {\n for (const [k, v] of Object.entries(span.attributes)) {\n if (typeof v === 'string' || typeof v === 'number' || typeof v === 'boolean') base[k] = v\n }\n }\n base[OPENINFERENCE_SPAN_KIND] = traceSpanKindToOpenInferenceKind(span.kind)\n if (span.kind === 'llm') {\n applyLlmSpanOtlpAttributes(base, span)\n } else if (span.kind === 'tool') {\n applyToolSpanOtlpAttributes(base, span)\n } else if (span.kind === 'retrieval') {\n base['retrieval.query'] = span.query\n base['retrieval.hits'] = span.hits.length\n } else if (span.kind === 'judge') {\n base['judge.id'] = span.judgeId\n base['judge.dimension'] = span.dimension\n base['judge.score'] = span.score\n base['judge.target_span_id'] = span.targetSpanId\n } else if (span.kind === 'sandbox') {\n if (span.image) base['sandbox.image'] = span.image\n if (span.exitCode !== undefined) base['sandbox.exit_code'] = span.exitCode\n if (span.testsPassed !== undefined) base['sandbox.tests_passed'] = span.testsPassed\n if (span.testsTotal !== undefined) base['sandbox.tests_total'] = span.testsTotal\n }\n return base\n}\n\nfunction flattenPayload(\n payload: Record<string, unknown>,\n): Record<string, string | number | boolean> {\n const out: Record<string, string | number | boolean> = {}\n for (const [k, v] of Object.entries(payload)) {\n if (typeof v === 'string' || typeof v === 'number' || typeof v === 'boolean') out[k] = v\n else out[k] = JSON.stringify(v)\n }\n return out\n}\n","/** General policy for recursive, evidence-backed trace analysis. */\n\nexport const TRACE_ANALYST_ACTOR_DESCRIPTION = `Answer the question by inspecting the OTLP trace dataset with the available tools.\n\n1. Call getDatasetOverview first. Use its real trace ids and dataset size to plan the investigation.\n2. Narrow with queryTraces and countTraces before scanning large payloads.\n3. For a small trace, use viewTrace. For a large trace, use searchTrace and then viewSpans or searchSpan.\n4. Never invent a trace id, span id, tool result, error, frequency, or final outcome.\n5. When a search reports has_more, refine the query before drawing a conclusion.\n6. Use llm_query only over evidence already loaded. A recursive query cannot inspect traces itself.\n7. Cite exact evidence URIs returned by the tools. Include a short exact excerpt when it supports the claim.\n8. Return no finding when the available evidence cannot support one.\n\nThe prose answer must directly answer the question and state important uncertainty.\nThe findings array contains only actionable or decision-relevant claims supported by inspected evidence.`\n\nexport const TRACE_ANALYST_ACTOR_DESCRIPTION_VERSION = 'trace-analyst-research-v1-2026-07-30'\n","import { randomUUID } from 'node:crypto'\nimport type {\n TraceAnalysisEngine,\n TraceAnalysisEngineResult,\n TraceAnalystLimits,\n} from '../analyst/engine'\nimport { runTraceAnalyst } from '../analyst/kind-factory'\nimport type { TraceToolGroupName } from '../analyst/tool-groups'\nimport type { AnalystFinding, AnalystUsageReceipt } from '../analyst/types'\nimport type { CostLedgerHandle } from '../cost-ledger'\nimport { TRACE_ANALYST_ACTOR_DESCRIPTION, TRACE_ANALYST_ACTOR_DESCRIPTION_VERSION } from './prompts'\nimport type { TraceAnalysisStore } from './store'\nimport { OtlpFileTraceStore } from './store-otlp'\n\nexport interface AnalyzeTracesInput {\n question: string\n id?: string\n description?: string\n area?: string\n}\n\nexport type AnalyzeTracesResult = TraceAnalysisEngineResult\n\nexport interface AnalyzeTracesOptions {\n /** OTLP JSONL path or a caller-owned store. */\n source: string | TraceAnalysisStore\n /** Recursive research engine. */\n engine: TraceAnalysisEngine\n /** Override the general trace-research policy. */\n instructions?: string\n /** Smallest tool set that can answer the question. Default: all. */\n toolGroup?: TraceToolGroupName\n limits?: Partial<TraceAnalystLimits>\n runId?: string\n budgetUsd?: number\n costLedger?: CostLedgerHandle\n costPhase?: string\n priorFindings?: readonly AnalystFinding[]\n upstreamFindings?: readonly AnalystFinding[]\n recordUsage?: (receipt: AnalystUsageReceipt) => void\n tags?: Record<string, string>\n log?: (message: string, fields?: Record<string, unknown>) => void\n signal?: AbortSignal\n}\n\n/**\n * Answer one question by recursively inspecting a trace store.\n *\n * The returned answer, cited findings, engine steps, call counts, and runtime\n * identity are one audit record. A direct one-shot model call is not used.\n */\nexport async function analyzeTraces(\n input: AnalyzeTracesInput,\n options: AnalyzeTracesOptions,\n): Promise<AnalyzeTracesResult> {\n if (typeof input.question !== 'string' || !input.question.trim()) {\n throw new TypeError('analyzeTraces: input.question must be a non-empty string')\n }\n const id = input.id?.trim() || 'trace-analysis'\n const store =\n typeof options.source === 'string'\n ? new OtlpFileTraceStore({ path: options.source })\n : options.source\n if (store instanceof OtlpFileTraceStore) {\n await store.ensureIndexed(options.signal ? { signal: options.signal } : undefined)\n }\n\n return runTraceAnalyst({\n definition: {\n id,\n description:\n input.description?.trim() ||\n 'Answers a caller-defined question by recursively inspecting trace evidence.',\n area: input.area?.trim() || 'trace-analysis',\n version: TRACE_ANALYST_ACTOR_DESCRIPTION_VERSION,\n question: input.question,\n instructions: options.instructions ?? TRACE_ANALYST_ACTOR_DESCRIPTION,\n toolGroup: options.toolGroup ?? 'all',\n limits: options.limits,\n },\n engine: options.engine,\n store,\n context: {\n runId: options.runId ?? id,\n correlationId: randomUUID(),\n budgetUsd: options.budgetUsd,\n costLedger: options.costLedger,\n costPhase: options.costPhase ?? 'trace-analysis',\n priorFindings: options.priorFindings,\n upstreamFindings: options.upstreamFindings,\n recordUsage: options.recordUsage,\n tags: options.tags,\n log: options.log,\n signal: options.signal,\n },\n })\n}\n","import type { SearchArtifactRef } from '../campaign/search-ledger-types'\nimport { LEDGER_HASH_PATTERN } from '../ledger-core/canonical'\n\nexport interface TraceInsightTask {\n id: string\n name: string\n prompt?: string\n difficulty?: string\n tags?: string[]\n outcome?: string\n score?: number\n gaps?: string[]\n}\n\nexport interface TraceInsightSuite {\n name: string\n collectionId?: string\n tasks: TraceInsightTask[]\n}\n\nexport interface TraceInsightFinding {\n kind: string\n severity?: string\n taskIds: string[]\n evidence?: string\n proposedFixClass?: string\n /** Narrative evidence remains a note; customer attribution uses byte-backed evidence only. */\n attribution?: TraceInsightAttribution\n}\n\n/** A byte-backed observation. Locators are not identities; every link carries a digest. */\nexport interface TraceInsightEvidence {\n subject: {\n verticalId: string\n taskId: string\n cellId: string | null\n attemptId: string | null\n company: string | null\n tool: string | null\n toolRevision: string | null\n }\n artifacts: Record<\n 'seed' | 'task' | 'cell' | 'request' | 'response' | 'document' | 'controls' | 'binding',\n SearchArtifactRef | null\n >\n spans: Array<{ traceId: string; spanId: string; artifact: SearchArtifactRef }>\n}\n\nexport type TraceInsightAttribution = TraceInsightEvidence &\n (\n | { outcome: 'unknown'; evidenceClass: 'unknown'; reasons: string[] }\n | {\n outcome: 'tool-failure'\n evidenceClass: 'validated-request-response'\n proof: SearchArtifactRef\n authority: SearchArtifactRef\n }\n | {\n outcome: 'documentation-failure'\n evidenceClass: 'authoritative-execution'\n documentation: 'stale' | 'contradictory'\n proof: SearchArtifactRef\n authority: SearchArtifactRef\n }\n | {\n outcome: 'documentation-failure'\n evidenceClass: 'paired-corrected-document'\n proof: SearchArtifactRef\n plan: SearchArtifactRef\n comparisonId: string\n correctedEvidence: SearchArtifactRef\n }\n )\n\nfunction evidenceRecord(value: unknown): value is Record<string, unknown> {\n return value !== null && typeof value === 'object' && !Array.isArray(value)\n}\n\nfunction evidenceText(value: unknown): value is string {\n return typeof value === 'string' && value.trim().length > 0\n}\n\n/** Structural validation only. The producer must verify bytes and execute the evidence rule. */\nexport function isTraceInsightArtifact(value: unknown): value is SearchArtifactRef {\n if (\n !evidenceRecord(value) ||\n !evidenceText(value.role) ||\n !evidenceText(value.uri) ||\n typeof value.sha256 !== 'string' ||\n !LEDGER_HASH_PATTERN.test(value.sha256) ||\n !Number.isSafeInteger(value.byteLength) ||\n (value.byteLength as number) < 0\n )\n return false\n // Customer reports must not turn a locator into an executable link.\n try {\n const url = new URL(value.uri)\n return ['https:', 'file:'].includes(url.protocol) && !url.username && !url.password\n } catch {\n return /^artifacts\\/[a-f0-9]{64}$/.test(value.uri)\n }\n}\n\nexport function isTraceInsightEvidence(value: unknown): value is TraceInsightEvidence {\n if (\n !evidenceRecord(value) ||\n !evidenceRecord(value.subject) ||\n !evidenceRecord(value.artifacts) ||\n !Array.isArray(value.spans)\n )\n return false\n const subject = value.subject\n if (!evidenceText(subject.verticalId) || !evidenceText(subject.taskId)) return false\n for (const field of ['cellId', 'attemptId', 'company', 'tool', 'toolRevision']) {\n if (subject[field] !== null && !evidenceText(subject[field])) return false\n }\n for (const role of [\n 'seed',\n 'task',\n 'cell',\n 'request',\n 'response',\n 'document',\n 'controls',\n 'binding',\n ]) {\n const artifact = value.artifacts[role]\n if (artifact !== null && (!isTraceInsightArtifact(artifact) || artifact.role !== role))\n return false\n }\n return value.spans.every(\n (span) =>\n evidenceRecord(span) &&\n typeof span.traceId === 'string' &&\n /^[a-f0-9]{32}$/.test(span.traceId) &&\n !/^0+$/.test(span.traceId) &&\n typeof span.spanId === 'string' &&\n /^[a-f0-9]{16}$/.test(span.spanId) &&\n !/^0+$/.test(span.spanId) &&\n isTraceInsightArtifact(span.artifact) &&\n span.artifact.role === 'span',\n )\n}\n\nexport function isTraceInsightAttribution(value: unknown): value is TraceInsightAttribution {\n if (!isTraceInsightEvidence(value)) return false\n const attribution = value as TraceInsightEvidence & Record<string, unknown>\n if (attribution.outcome === 'unknown') {\n return (\n attribution.evidenceClass === 'unknown' &&\n Array.isArray(attribution.reasons) &&\n attribution.reasons.length > 0 &&\n attribution.reasons.every(evidenceText)\n )\n }\n if (\n Object.values(value.subject).some((entry) => entry === null) ||\n Object.values(value.artifacts).some((artifact) => artifact === null) ||\n value.spans.length === 0 ||\n !isTraceInsightArtifact(attribution.proof)\n )\n return false\n if (attribution.outcome === 'tool-failure') {\n return (\n attribution.evidenceClass === 'validated-request-response' &&\n attribution.proof.role === 'execution' &&\n isTraceInsightArtifact(attribution.authority) &&\n attribution.authority.role === 'authority'\n )\n }\n if (attribution.outcome !== 'documentation-failure') return false\n if (attribution.evidenceClass === 'authoritative-execution') {\n return (\n (attribution.documentation === 'stale' || attribution.documentation === 'contradictory') &&\n attribution.proof.role === 'execution' &&\n isTraceInsightArtifact(attribution.authority) &&\n attribution.authority.role === 'authority'\n )\n }\n return (\n attribution.evidenceClass === 'paired-corrected-document' &&\n attribution.proof.role === 'publication' &&\n isTraceInsightArtifact(attribution.plan) &&\n attribution.plan.role === 'plan' &&\n isTraceInsightArtifact(attribution.correctedEvidence) &&\n attribution.correctedEvidence.role === 'binding' &&\n evidenceText(attribution.comparisonId)\n )\n}\n\nexport interface TraceInsightQuestion {\n id: string\n question: string\n why: string\n}\n\nexport interface TraceInsightPanelRole {\n id: string\n name: string\n responsibility: string\n}\n\nexport interface TraceInsightPromptInput {\n suite: TraceInsightSuite\n findings?: TraceInsightFinding[]\n agent?: Record<string, unknown>\n totals?: Record<string, unknown>\n maxRepresentativeTraces?: number\n}\n\nexport interface TraceInsightContext {\n suite: TraceInsightSuite\n scope: string\n keywords: string[]\n questions: TraceInsightQuestion[]\n panel: TraceInsightPanelRole[]\n findings: TraceInsightFinding[]\n agent: Record<string, unknown> | null\n totals: Record<string, unknown> | null\n}\n\nexport interface TraceInsightQualityGate {\n id: string\n label: string\n passed: boolean\n severity: 'critical' | 'high' | 'medium' | 'low'\n detail: string\n}\n\nexport interface TraceInsightReadiness {\n score: number\n grade: 'external-ready' | 'internal-review' | 'raw-analysis'\n gates: TraceInsightQualityGate[]\n}\n\nconst DOMAIN_STOP_WORDS = new Set([\n 'and',\n 'advanced',\n 'app',\n 'build',\n 'create',\n 'easy',\n 'expert',\n 'extreme',\n 'for',\n 'from',\n 'hard',\n 'implementation',\n 'integrate',\n 'medium',\n 'project',\n 'task',\n 'the',\n 'this',\n 'with',\n 'workflow',\n])\n\nexport function tokenizeDomainWords(value: string): string[] {\n return [...value.matchAll(/[A-Za-z][A-Za-z0-9.+#-]{2,}/g)]\n .map((match) => match[0].toLowerCase())\n .filter((word) => !DOMAIN_STOP_WORDS.has(word))\n}\n\nexport function inferDomainKeywords(suite: TraceInsightSuite): string[] {\n const suiteWords = new Set(tokenizeDomainWords(`${suite.name} ${suite.collectionId ?? ''}`))\n const source = [\n suite.name,\n suite.collectionId ?? '',\n ...suite.tasks.flatMap((task) => [\n task.id,\n task.name,\n task.prompt ?? '',\n task.difficulty ?? '',\n ...(task.tags ?? []),\n ...(task.gaps ?? []),\n ]),\n ].join(' ')\n const counts = new Map<string, number>()\n for (const word of tokenizeDomainWords(source)) counts.set(word, (counts.get(word) ?? 0) + 1)\n return [...counts.entries()]\n .filter(([word, count]) => count >= 2 || suiteWords.has(word))\n .sort((a, b) => b[1] - a[1] || a[0].localeCompare(b[0]))\n .map(([word]) => word)\n .slice(0, 18)\n}\n\nexport function domainEvidencePattern(keywords: string[]): RegExp {\n const escaped = keywords\n .filter((keyword) => keyword.length >= 3)\n .map((keyword) => keyword.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&'))\n return escaped.length > 0\n ? new RegExp(`(?<![A-Za-z0-9])(?:${escaped.join('|')})(?![A-Za-z0-9])`, 'i')\n : /(?<![A-Za-z0-9])(?:sdk|api|css|dns|xml|provider|client|service|integration|webhook|transaction|auth|oauth|graphql|rest)(?![A-Za-z0-9])/i\n}\n\nexport function describeTraceInsightScope(suite: TraceInsightSuite): string {\n const taskLabel =\n suite.tasks.length === 1\n ? '1 implementation task'\n : `${suite.tasks.length} implementation tasks`\n const tags = new Map<string, number>()\n for (const task of suite.tasks) {\n for (const tag of task.tags ?? []) tags.set(tag, (tags.get(tag) ?? 0) + 1)\n }\n const topTags = [...tags.entries()]\n .sort((a, b) => b[1] - a[1] || a[0].localeCompare(b[0]))\n .slice(0, 8)\n .map(([tag]) => tag)\n if (topTags.length > 0) return `${taskLabel} across ${topTags.join(', ')}.`\n const difficulties = [\n ...new Set(\n suite.tasks.map((task) => task.difficulty).filter((value): value is string => Boolean(value)),\n ),\n ].join(', ')\n return `${taskLabel} across ${difficulties || 'the selected benchmark scope'}.`\n}\n\nfunction planTraceInsightQuestions(input: TraceInsightPromptInput): TraceInsightQuestion[] {\n const hasFailures = input.suite.tasks.some((task) => task.outcome && task.outcome !== 'satisfied')\n const hasMultipleShots = input.suite.tasks.some((task) =>\n (task.gaps ?? []).some((gap) => /shot|review|retry|continue/i.test(gap)),\n )\n const questions: TraceInsightQuestion[] = [\n {\n id: 'execution-path',\n question: 'What did the worker actually do before the first meaningful implementation edit?',\n why: 'Separates grounded execution from polished but shallow output.',\n },\n {\n id: 'research-grounding',\n question:\n 'Did the worker inspect docs, source, examples, or package references before committing to an implementation path?',\n why: 'Identifies whether failures came from weak retrieval, weak examples, or premature coding.',\n },\n {\n id: 'domain-proof',\n question:\n 'Which tasks produced executable domain proof versus UI copy, placeholders, or inferred behavior?',\n why: 'Keeps product-quality claims tied to concrete evidence.',\n },\n {\n id: 'root-cause',\n question:\n 'For each major failure cluster, is the likely root cause prompt/scaffold, docs/examples, SDK/API ergonomics, evaluator, runtime, or model behavior?',\n why: 'Turns trace observations into actionable ownership.',\n },\n {\n id: 'evidence-quality',\n question:\n 'Which external-facing claims are directly supported by trace ids, span ids, verifier findings, reviewer notes, or generated code?',\n why: 'Prevents unsupported customer-report conclusions.',\n },\n ]\n if (hasMultipleShots) {\n questions.push({\n id: 'reviewer-lift',\n question: 'Where did reviewer feedback improve score, stall, or regress across shots?',\n why: 'Shows whether the driver loop is learning or merely repeating work.',\n })\n }\n if (hasFailures) {\n questions.push({\n id: 'optimization-targets',\n question:\n 'Which prompt, evaluator, scaffold, or workflow changes should feed the next GEPA/autoresearch optimization run?',\n why: 'Connects benchmark evidence to the optimization loop.',\n })\n }\n return questions\n}\n\nexport function buildTraceInsightContext(input: TraceInsightPromptInput): TraceInsightContext {\n return {\n suite: input.suite,\n scope: describeTraceInsightScope(input.suite),\n keywords: inferDomainKeywords(input.suite),\n questions: planTraceInsightQuestions(input),\n panel: defaultTraceInsightPanel(),\n findings: input.findings ?? [],\n agent: input.agent ?? null,\n totals: input.totals ?? null,\n }\n}\n\nexport function scoreTraceInsightReadiness(context: TraceInsightContext): TraceInsightReadiness {\n const failedTasks = context.suite.tasks.filter(\n (task) => task.outcome && task.outcome !== 'satisfied',\n )\n const findingTaskIds = new Set(context.findings.flatMap((finding) => finding.taskIds))\n const failedTasksWithFindings = failedTasks.filter((task) => findingTaskIds.has(task.id))\n const tasksWithGaps = context.suite.tasks.filter((task) => (task.gaps ?? []).length > 0)\n const gates: TraceInsightQualityGate[] = [\n {\n id: 'domain-context',\n label: 'Domain context inferred',\n passed: context.keywords.length > 0,\n severity: 'high',\n detail:\n context.keywords.length > 0\n ? `${context.keywords.length} domain terms inferred: ${context.keywords.slice(0, 8).join(', ')}`\n : 'No domain terms were inferred from suite, tasks, prompts, tags, or gaps.',\n },\n {\n id: 'panel-coverage',\n label: 'Analyst panel planned',\n passed: context.panel.length >= 4 && context.questions.length >= 5,\n severity: 'high',\n detail: `${context.panel.length} panel roles and ${context.questions.length} investigation questions planned.`,\n },\n {\n id: 'failure-coverage',\n label: 'Failures mapped to findings',\n passed:\n failedTasks.length === 0 || failedTasksWithFindings.length / failedTasks.length >= 0.5,\n severity: 'critical',\n detail:\n failedTasks.length === 0\n ? 'No failed tasks in suite.'\n : `${failedTasksWithFindings.length}/${failedTasks.length} failed tasks appear in finding clusters.`,\n },\n {\n id: 'gap-evidence',\n label: 'Task gaps captured',\n passed: failedTasks.length === 0 || tasksWithGaps.length / failedTasks.length >= 0.5,\n severity: 'medium',\n detail: `${tasksWithGaps.length} tasks include explicit evaluator or analyst gaps.`,\n },\n {\n id: 'attribution-evidence',\n label: 'Evidence-classed customer findings',\n passed:\n failedTasks.every((task) =>\n context.findings.some(\n (finding) =>\n finding.taskIds.includes(task.id) && finding.attribution?.subject.taskId === task.id,\n ),\n ) &&\n context.findings.every(\n (finding) =>\n isTraceInsightAttribution(finding.attribution) &&\n finding.taskIds.length === 1 &&\n finding.taskIds[0] === finding.attribution.subject.taskId,\n ),\n severity: 'critical',\n detail:\n 'Every finding needs an explicit evidence class and byte-backed links, or an explicit unknown; prose is not attribution evidence.',\n },\n ]\n const penalty = gates.reduce((sum, gate) => {\n if (gate.passed) return sum\n if (gate.severity === 'critical') return sum + 35\n if (gate.severity === 'high') return sum + 20\n if (gate.severity === 'medium') return sum + 10\n return sum + 5\n }, 0)\n const score = Math.max(0, Math.min(1, 1 - penalty / 100))\n return {\n score,\n grade: score >= 0.9 ? 'external-ready' : score >= 0.7 ? 'internal-review' : 'raw-analysis',\n gates,\n }\n}\n\nfunction defaultTraceInsightPanel(): TraceInsightPanelRole[] {\n return [\n {\n id: 'trace-forensics',\n name: 'Trace Forensics',\n responsibility:\n 'Reconstruct what the worker did in order, including research, edits, reviewer interventions, verifier feedback, and stop reason.',\n },\n {\n id: 'root-cause',\n name: 'Root Cause',\n responsibility:\n 'Map failures to prompt/scaffold, docs/examples, SDK/API/product ergonomics, evaluator, runtime, or model behavior.',\n },\n {\n id: 'optimization',\n name: 'Optimization',\n responsibility:\n 'Identify prompt, reviewer, evaluator, scaffold, and GEPA/autoresearch changes that should be tested next.',\n },\n {\n id: 'external-evidence',\n name: 'External Evidence',\n responsibility:\n 'Separate customer-safe claims from internal harness findings and reject conclusions without task, trace, span, code, reviewer, or verifier evidence.',\n },\n ]\n}\n\nexport function buildTraceInsightPrompt(input: TraceInsightPromptInput): string {\n const context = buildTraceInsightContext(input)\n const maxRepresentativeTraces = input.maxRepresentativeTraces ?? 6\n return `Analyze this benchmark run and produce evidence-backed trace intelligence.\n\nAudience:\n- internal AI/product leadership\n- possible customer-facing report for ${input.suite.name}\n\nInvestigation plan:\n${context.questions.map((item, index) => `${index + 1}. ${item.question} (${item.why})`).join('\\n')}\n\nAnalyst panel:\n${context.panel.map((role) => `- ${role.name}: ${role.responsibility}`).join('\\n')}\n\nIf the task branches are independent, use subagents for the panel roles above and aggregate their findings. Do not run a panel role unless its answer will change the final report.\n\nRequired output:\n1. Executive verdict: what this run proves and does not prove.\n2. The investigation questions you answered and the evidence used.\n3. Failure taxonomy: agent prompting, evaluator/harness, docs/examples, SDK/API/product integration, infra.\n4. Evidence-backed examples with trace ids/task ids and concrete verifier findings.\n5. Highest-ROI fixes for the benchmark harness, prompt/GEPA optimization, and customer-facing product/docs surface.\n6. What is safe for an external report versus what must stay internal.\n7. One rerun plan that would validate lift after optimization.\n\nBudget:\n- Inspect the dataset overview, the failure summary, and at most ${maxRepresentativeTraces} representative traces.\n- Prefer traces named in the failure summary over broad exploration.\n- Do not do exhaustive trace sweeps.\n- Return the final report as soon as the taxonomy and examples are supported.\n\nRun summary:\n${JSON.stringify(\n {\n suite: input.suite.name,\n scope: context.scope,\n inferredKeywords: context.keywords,\n agent: context.agent,\n totals: context.totals,\n findings: context.findings.map((finding) => ({\n kind: finding.kind,\n severity: finding.severity,\n taskCount: finding.taskIds.length,\n proposedFixClass: finding.proposedFixClass,\n attribution: finding.attribution,\n })),\n failures: input.suite.tasks\n .filter((task) => task.outcome && task.outcome !== 'satisfied')\n .map((task) => ({\n task: task.id,\n difficulty: task.difficulty,\n outcome: task.outcome,\n score: task.score,\n gaps: task.gaps ?? [],\n })),\n },\n null,\n 2,\n)}\n\nUse the trace tools. Do not invent facts. Cite task ids. Separate customer-facing claims from internal harness/model findings.\nCustomer attribution must preserve the supplied evidence class and artifact links. A narrative, regex label, observational rate, or document age is not causal evidence. Without validated request/response execution or a supported registered corrected-document comparison, report unknown; do not guess a failing company or tool.`\n}\n","/** Canonical flattened OTLP span shape shared by trace producers and readers. */\n\nimport type { SpanStatus } from './schema'\n\nexport type OtlpStatusCode = 'STATUS_CODE_OK' | 'STATUS_CODE_ERROR' | 'STATUS_CODE_UNSET'\n\nexport interface OtlpFlatLine {\n trace_id: string\n span_id: string\n parent_span_id: string | null\n name: string\n kind: string\n start_time: string\n end_time: string\n status: {\n code: OtlpStatusCode\n message?: string\n }\n resource: { attributes: Record<string, unknown> }\n attributes: Record<string, unknown>\n events?: Array<{ name: string; timeUnixNano?: string; attributes?: Record<string, unknown> }>\n}\n\ninterface CreateOtlpFlatLineInput {\n traceId: string\n spanId: string\n parentSpanId: string | null\n name: string\n kind: string\n startTime: string\n endTime: string\n statusCode: OtlpStatusCode\n statusMessage?: string\n resource: OtlpFlatLine['resource']\n attributes: Record<string, unknown>\n events?: OtlpFlatLine['events']\n}\n\nexport function createOtlpFlatLine(input: CreateOtlpFlatLineInput): OtlpFlatLine {\n return {\n trace_id: input.traceId,\n span_id: input.spanId,\n parent_span_id: input.parentSpanId,\n name: input.name,\n kind: input.kind,\n start_time: input.startTime,\n end_time: input.endTime,\n status: {\n code: input.statusCode,\n ...(input.statusMessage !== undefined ? { message: input.statusMessage } : {}),\n },\n resource: input.resource,\n attributes: input.attributes,\n ...(input.events && input.events.length > 0 ? { events: input.events } : {}),\n }\n}\n\n/** Map the canonical trace status while letting each caller choose its legacy default. */\nexport function spanStatusToOtlp(\n status: SpanStatus | undefined,\n error: string | undefined,\n defaultCode: OtlpStatusCode,\n): OtlpStatusCode {\n if (status === 'error' || error) return 'STATUS_CODE_ERROR'\n if (status === 'ok') return 'STATUS_CODE_OK'\n return defaultCode\n}\n\n/** Convert epoch milliseconds, returning `undefined` for invalid or out-of-range values. */\nexport function epochMillisToIso(value: number): string | undefined {\n if (!Number.isFinite(value)) return undefined\n try {\n return new Date(value).toISOString()\n } catch {\n return undefined\n }\n}\n","import { CaptureIntegrityError } from '../errors'\nimport { applyToolSpanOtlpAttributes, OPENINFERENCE_SPAN_KIND } from '../trace/otlp-attributes'\nimport { createOtlpFlatLine, epochMillisToIso, spanStatusToOtlp } from '../trace/otlp-flat'\nimport type { ToolSpan } from '../trace/schema'\nimport type { TraceAnalysisStore } from './store'\nimport { BufferTraceStore } from './store-otlp'\nimport type { ToolSpansToTraceAnalysisStoreOptions } from './store-otlp-buffered'\n\n/** Missing tool spans cannot distinguish a tool-free run from broken capture. */\nexport class ToolTraceMissingError extends CaptureIntegrityError {\n constructor() {\n super('toolSpansToTraceAnalysisStore: no tool spans supplied; trace evidence is missing')\n }\n}\n\n/**\n * Snapshot canonical tool spans into the read interface used by trace analysts.\n * One run becomes one trace while arguments, results, errors, and timing remain searchable.\n */\nexport function toolSpansToTraceAnalysisStore(\n spans: readonly ToolSpan[] | null | undefined,\n options: ToolSpansToTraceAnalysisStoreOptions = {},\n): TraceAnalysisStore {\n if (!spans || spans.length === 0) throw new ToolTraceMissingError()\n\n const seen = new Set<string>()\n const lines = spans.map((span, index) => {\n assertToolSpanIdentity(span, index)\n const identity = `${span.runId}\\u0000${span.spanId}`\n if (seen.has(identity)) {\n throw new CaptureIntegrityError(\n `toolSpansToTraceAnalysisStore: duplicate span '${span.spanId}' in run '${span.runId}'`,\n )\n }\n seen.add(identity)\n\n const attributes = { ...(span.attributes ?? {}) }\n applyToolSpanOtlpAttributes(attributes, span)\n attributes[OPENINFERENCE_SPAN_KIND] = 'TOOL'\n\n const endedAt = span.endedAt ?? span.startedAt + (span.latencyMs ?? 0)\n const line = createOtlpFlatLine({\n traceId: span.runId,\n spanId: span.spanId,\n parentSpanId: span.parentSpanId ?? null,\n name: span.name,\n kind: 'SPAN_KIND_INTERNAL',\n startTime: toolSpanTimeIso(span.startedAt, span.spanId, 'startedAt'),\n endTime: toolSpanTimeIso(endedAt, span.spanId, 'endedAt'),\n statusCode: spanStatusToOtlp(span.status, span.error, 'STATUS_CODE_UNSET'),\n statusMessage: span.error,\n resource: { attributes: {} },\n attributes,\n })\n try {\n return JSON.stringify(line)\n } catch (cause) {\n throw new CaptureIntegrityError(\n `toolSpansToTraceAnalysisStore: span '${span.spanId}' in run '${span.runId}' is not JSON-serializable`,\n { cause },\n )\n }\n })\n\n return new BufferTraceStore(Buffer.from(`${lines.join('\\n')}\\n`, 'utf8'), options)\n}\n\nfunction assertToolSpanIdentity(span: ToolSpan, index: number): void {\n if (span.kind !== 'tool') {\n throw new CaptureIntegrityError(\n `toolSpansToTraceAnalysisStore: span at index ${index} has kind '${String(span.kind)}', not 'tool'`,\n )\n }\n if (!span.runId || !span.spanId || !span.name || !span.toolName) {\n throw new CaptureIntegrityError(\n `toolSpansToTraceAnalysisStore: span at index ${index} is missing runId, spanId, name, or toolName`,\n )\n }\n if (!Number.isFinite(span.startedAt)) {\n throw new CaptureIntegrityError(\n `toolSpansToTraceAnalysisStore: span '${span.spanId}' has invalid startedAt`,\n )\n }\n if (span.endedAt !== undefined && !Number.isFinite(span.endedAt)) {\n throw new CaptureIntegrityError(\n `toolSpansToTraceAnalysisStore: span '${span.spanId}' has invalid endedAt`,\n )\n }\n if (span.endedAt !== undefined && span.endedAt < span.startedAt) {\n throw new CaptureIntegrityError(\n `toolSpansToTraceAnalysisStore: span '${span.spanId}' ends before it starts`,\n )\n }\n if (span.latencyMs !== undefined && (!Number.isFinite(span.latencyMs) || span.latencyMs < 0)) {\n throw new CaptureIntegrityError(\n `toolSpansToTraceAnalysisStore: span '${span.spanId}' has invalid latencyMs`,\n )\n }\n}\n\nfunction toolSpanTimeIso(value: number, spanId: string, field: string): string {\n const iso = epochMillisToIso(value)\n if (iso) return iso\n throw new CaptureIntegrityError(\n `toolSpansToTraceAnalysisStore: span '${spanId}' has invalid ${field}`,\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AA0DA,MAAM,mBAAmB;AAEzB,SAAS,gBAAgB,SAAkE;CACzF,IAAI,CAAC,SAAS,OAAO,KAAA;CACrB,MAAM,MAA8B,CAAC;CACrC,QAAQ,SAAS,OAAO,QAAQ;EAC9B,IAAI,IAAI,YAAY,KAAK;CAC3B,CAAC;CACD,OAAO,OAAO,KAAK,GAAG,CAAC,CAAC,SAAS,IAAI,MAAM,KAAA;AAC7C;AAEA,SAAS,eAAe,MAAuB;CAC7C,IAAI,KAAK,WAAW,GAAG,OAAO,KAAA;CAC9B,IAAI;EACF,OAAO,KAAK,MAAM,IAAI;CACxB,QAAQ;EACN,OAAO;CACT;AACF;;AAGA,eAAe,gBACb,OACA,MACkB;CAClB,IAAI,OAAO,MAAM,SAAS,UAAU,OAAO,eAAe,KAAK,IAAI;CACnE,IAAI,MAAM,QAAQ,MAAM,OAAO,KAAA;CAC/B,IAAI,iBAAiB,SACnB,IAAI;EACF,OAAO,eAAe,MAAM,MAAM,MAAM,CAAC,CAAC,KAAK,CAAC;CAClD,QAAQ;EACN;CACF;AAGJ;AAEA,SAAS,gBAAgB,KAAa,SAAyB;CAC7D,MAAM,iBAAiB,QAAQ,QAAQ,QAAQ,EAAE;CACjD,IAAI,IAAI,WAAW,cAAc,GAAG,OAAO,IAAI,MAAM,eAAe,MAAM,KAAK;CAC/E,IAAI;EACF,OAAO,IAAI,IAAI,GAAG,CAAC,CAAC;CACtB,QAAQ;EACN,OAAO;CACT;AAC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OAAO;AACnF;AAEA,SAAS,uBAAuB,MAAgB,OAAqB;CACnE,IAAI,KAAK,SAAS,QAChB,MAAM,IAAI,sBACR,gDAAgD,MAAM,aAAa,OAAO,KAAK,IAAI,EAAE,cACvF;CAEF,IAAI,CAAC,KAAK,SAAS,CAAC,KAAK,UAAU,CAAC,KAAK,QAAQ,CAAC,KAAK,UACrD,MAAM,IAAI,sBACR,gDAAgD,MAAM,6CACxD;CAEF,IAAI,CAAC,OAAO,SAAS,KAAK,SAAS,GACjC,MAAM,IAAI,sBACR,wCAAwC,KAAK,OAAO,wBACtD;CAEF,IAAI,KAAK,YAAY,KAAA,KAAa,CAAC,OAAO,SAAS,KAAK,OAAO,GAC7D,MAAM,IAAI,sBACR,wCAAwC,KAAK,OAAO,sBACtD;CAEF,IAAI,KAAK,YAAY,KAAA,KAAa,KAAK,UAAU,KAAK,WACpD,MAAM,IAAI,sBACR,wCAAwC,KAAK,OAAO,wBACtD;CAEF,IAAI,KAAK,cAAc,KAAA,MAAc,CAAC,OAAO,SAAS,KAAK,SAAS,KAAK,KAAK,YAAY,IACxF,MAAM,IAAI,sBACR,wCAAwC,KAAK,OAAO,wBACtD;AAEJ;AAEA,SAAS,gBAAgB,OAAe,QAAgB,OAAuB;CAC7E,MAAM,MAAM,iBAAiB,KAAK;CAClC,IAAI,KAAK,OAAO;CAChB,MAAM,IAAI,sBACR,wCAAwC,OAAO,gBAAgB,OACjE;AACF"}
|
|
1
|
+
{"version":3,"file":"store-tool-spans-CW24axM0.js","names":[],"sources":["../src/trace/capture-fetch.ts","../src/trace/otel.ts","../src/trace-analyst/prompts.ts","../src/trace-analyst/analyst.ts","../src/trace-analyst/insights.ts","../src/trace/otlp-flat.ts","../src/trace-analyst/store-tool-spans.ts"],"sourcesContent":["/**\n * Wrap a provider `fetch` and record request, response, and error events.\n *\n * The returned value is a plain `typeof fetch`. Capture is best-effort by\n * default; set `failClosed` when telemetry loss must stop the provider call.\n */\n\nimport {\n type ExtractedUsage,\n extractUsage,\n extractUsageFromSse,\n type SseUsageMode,\n} from './extract-usage'\nimport {\n defaultProviderRedactor,\n type ProviderRedactor,\n providerFromBaseUrl,\n type RawProviderDirection,\n type RawProviderEvent,\n type RawProviderSink,\n} from './raw-provider-sink'\n\nexport interface CaptureFetchContext {\n /** Logical run id stamped on every captured event. Required — without it\n * the raw events can't be paired with their parent `Run`. */\n runId: string\n /** Optional logical span id (enables span-level sink filtering). */\n spanId?: string\n /** Resolved base URL (normalised, no trailing slash). Used for the event's\n * `baseUrl` and for endpoint-path extraction. */\n baseUrl: string\n /** Model id the caller intends to invoke. Stamped on every event. */\n model: string\n /** Provider override. When omitted, `providerFromBaseUrl(baseUrl)`. */\n provider?: string\n}\n\nexport interface CaptureFetchOptions {\n /** Override the capture-time redactor. Default `defaultProviderRedactor`. */\n redactor?: ProviderRedactor\n /** Cap on captured response-body bytes; beyond it the body is truncated and\n * `body_truncated` is added to `redactedFields`. Default 2 MiB. */\n responseBodyByteCap?: number\n /** When true, a sink-write failure propagates to the caller. Default false\n * — capture is best-effort so a sink failure never kills the LLM call. */\n failClosed?: boolean\n /**\n * Invoked with the token usage parsed off each successful response (JSON or\n * SSE), keyed by the captured context. Lets a caller fold usage → cost without\n * re-cloning the response themselves. Not called when the response carries no\n * usage. Best-effort: a throw here is swallowed (it never kills the LLM call)\n * unless `failClosed` is set.\n */\n onUsage?: (usage: ExtractedUsage, ctx: CaptureFetchContext) => void\n /** How repeated SSE usage events should be reconciled. Default `cumulative`. */\n sseUsageMode?: SseUsageMode\n}\n\nconst DEFAULT_BODY_CAP = 2 * 1024 * 1024\n\nfunction headersToRecord(headers: Headers | undefined): Record<string, string> | undefined {\n if (!headers) return undefined\n const out: Record<string, string> = {}\n headers.forEach((value, key) => {\n out[key.toLowerCase()] = value\n })\n return Object.keys(out).length > 0 ? out : undefined\n}\n\nfunction parseMaybeJson(text: string): unknown {\n if (text.length === 0) return undefined\n try {\n return JSON.parse(text)\n } catch {\n return text\n }\n}\n\n/** Best-effort request-body read across the `fetch` input forms. */\nasync function readRequestBody(\n input: RequestInfo | URL,\n init: RequestInit | undefined,\n): Promise<unknown> {\n if (typeof init?.body === 'string') return parseMaybeJson(init.body)\n if (init?.body != null) return undefined // streams / FormData / Blob — not captured\n if (input instanceof Request) {\n try {\n return parseMaybeJson(await input.clone().text())\n } catch {\n return undefined\n }\n }\n return undefined\n}\n\nfunction endpointFromUrl(url: string, baseUrl: string): string {\n const normalisedBase = baseUrl.replace(/\\/+$/, '')\n if (url.startsWith(normalisedBase)) return url.slice(normalisedBase.length) || '/'\n try {\n return new URL(url).pathname\n } catch {\n return url\n }\n}\n\nexport function captureFetchToRawSink(\n fetch: typeof globalThis.fetch,\n sink: RawProviderSink,\n ctx: CaptureFetchContext,\n opts: CaptureFetchOptions = {},\n): typeof globalThis.fetch {\n const provider = ctx.provider ?? providerFromBaseUrl(ctx.baseUrl)\n const redactor = opts.redactor ?? defaultProviderRedactor\n const bodyCap = opts.responseBodyByteCap ?? DEFAULT_BODY_CAP\n let warned = false\n\n const baseEvent = (direction: RawProviderDirection, endpoint: string): RawProviderEvent => ({\n eventId: crypto.randomUUID(),\n runId: ctx.runId,\n spanId: ctx.spanId,\n provider,\n model: ctx.model,\n endpoint,\n baseUrl: ctx.baseUrl,\n attemptIndex: 0, // retries are re-invocations one layer up; documented in 0.x\n direction,\n timestamp: Date.now(),\n redactedFields: [],\n })\n\n const record = async (event: RawProviderEvent): Promise<void> => {\n try {\n await sink.record(redactor(event))\n } catch (err) {\n if (opts.failClosed) throw err\n if (!warned) {\n warned = true\n console.warn(\n `captureFetchToRawSink: sink.record failed (capture is best-effort) — ${\n err instanceof Error ? err.message : String(err)\n }`,\n )\n }\n }\n }\n\n return async (input: RequestInfo | URL, init?: RequestInit): Promise<Response> => {\n const url =\n typeof input === 'string' ? input : input instanceof URL ? input.toString() : input.url\n const method = (init?.method ?? (input instanceof Request ? input.method : 'GET')).toUpperCase()\n const endpoint = endpointFromUrl(url, ctx.baseUrl)\n\n const reqHeaders = new Headers(\n init?.headers ?? (input instanceof Request ? input.headers : undefined),\n )\n await record({\n ...baseEvent('request', endpoint),\n requestHeaders: { ...headersToRecord(reqHeaders), 'x-http-method': method },\n requestBody: await readRequestBody(input, init),\n })\n\n const start = Date.now()\n let response: Response\n try {\n response = await fetch(input, init)\n } catch (err) {\n await record({\n ...baseEvent('error', endpoint),\n durationMs: Date.now() - start,\n errorMessage: err instanceof Error ? err.message : String(err),\n })\n throw err\n }\n\n // Read the body off a clone so the caller still consumes the original.\n let responseBody: unknown\n let rawText: string | undefined\n const redactedFields: string[] = []\n try {\n rawText = await response.clone().text()\n if (rawText.length > bodyCap) {\n responseBody = rawText.slice(0, bodyCap)\n redactedFields.push('body_truncated')\n } else {\n responseBody = parseMaybeJson(rawText)\n }\n } catch {\n responseBody = undefined\n }\n\n if (opts.onUsage && rawText !== undefined) {\n // Reuse the body already read for capture; no extra clone. JSON first,\n // then SSE accumulation. A throw in the consumer's callback is swallowed\n // (best-effort) unless failClosed is set — the LLM call must not die here.\n try {\n const parsedForUsage = parseMaybeJson(rawText)\n const usage =\n extractUsage(parsedForUsage) ??\n (typeof parsedForUsage === 'string'\n ? extractUsageFromSse(rawText, { mode: opts.sseUsageMode })\n : null)\n if (usage) opts.onUsage(usage, ctx)\n } catch (err) {\n if (opts.failClosed) throw err\n }\n }\n\n await record({\n ...baseEvent('response', endpoint),\n durationMs: Date.now() - start,\n statusCode: response.status,\n responseHeaders: headersToRecord(response.headers),\n responseBody,\n redactedFields,\n })\n\n return response\n }\n}\n","/**\n * OpenTelemetry JSON export — maps TraceSchema v1 to OTLP/JSON so\n * traces render natively in Jaeger / Honeycomb / Langfuse / Grafana.\n *\n * Wire format only. We do NOT depend on the @opentelemetry SDK — that\n * would drag in polyfills incompatible with Workers/Edge. Consumers\n * push the JSON to their collector of choice via HTTP.\n *\n * Reference: OTLP 1.3.2 (ResourceSpans / ScopeSpans / Span).\n */\n\nimport { toW3CSpanId, toW3CTraceId } from '@tangle-network/agent-trace-contract'\nimport {\n msToUnixNano,\n type OtlpSpan,\n type OtlpTraceExport,\n otlpTraceExport,\n toOtlpAttributes,\n} from '@tangle-network/agent-trace-contract/otlp'\nimport {\n applyLlmSpanOtlpAttributes,\n applyToolSpanOtlpAttributes,\n OPENINFERENCE_SPAN_KIND,\n traceSpanKindToOpenInferenceKind,\n} from './otlp-attributes'\nimport type { Span, TraceEvent } from './schema'\nimport type { TraceStore } from './store'\n\nconst OTEL_AGENT_EVAL_SCOPE = { name: '@tangle-network/agent-eval', version: '0.3.0' }\n\nexport type { OtlpResourceSpans, OtlpSpan } from '@tangle-network/agent-trace-contract/otlp'\nexport type OtlpExport = OtlpTraceExport\n\n/** Export a single run's spans + events in OTLP/JSON. */\nexport async function exportRunAsOtlp(\n store: TraceStore,\n runId: string,\n resourceAttrs: Record<string, string | number | boolean> = {},\n): Promise<OtlpExport> {\n const run = await store.getRun(runId)\n if (!run) throw new Error(`run ${runId} not found`)\n const spans = await store.spans({ runId })\n const events = await store.events({ runId })\n const eventsBySpan = new Map<string, TraceEvent[]>()\n for (const e of events) {\n if (!e.spanId) continue\n const arr = eventsBySpan.get(e.spanId) ?? []\n arr.push(e)\n eventsBySpan.set(e.spanId, arr)\n }\n const traceId = toW3CTraceId(run.runId)\n const otlpSpans: OtlpSpan[] = spans.map((s) =>\n spanToOtlp(s, traceId, eventsBySpan.get(s.spanId) ?? []),\n )\n const resource = toOtlpAttributes({\n 'service.name': 'agent-eval',\n 'run.id': run.runId,\n 'run.scenario_id': run.scenarioId,\n 'run.variant_id': run.variantId ?? '',\n 'run.dataset_version': run.datasetVersion ?? '',\n 'run.code_sha': run.codeSha ?? '',\n 'run.model_fingerprint': run.modelFingerprint ?? '',\n ...resourceAttrs,\n })\n return otlpTraceExport(resource, OTEL_AGENT_EVAL_SCOPE, otlpSpans)\n}\n\nfunction spanToOtlp(span: Span, traceId: string, events: TraceEvent[]): OtlpSpan {\n const endedAt = span.endedAt ?? span.startedAt\n return {\n traceId,\n spanId: toW3CSpanId(span.spanId),\n parentSpanId: span.parentSpanId ? toW3CSpanId(span.parentSpanId) : undefined,\n name: span.name,\n kind: 1, // SPAN_KIND_INTERNAL\n startTimeUnixNano: msToUnixNano(span.startedAt),\n endTimeUnixNano: msToUnixNano(endedAt),\n attributes: toOtlpAttributes(flattenSpanAttributes(span)),\n events: events.map((e) => ({\n timeUnixNano: msToUnixNano(e.timestamp),\n name: e.kind,\n attributes: toOtlpAttributes(flattenPayload(e.payload)),\n })),\n status: span.status === 'error' ? { code: 2, message: span.error } : { code: 1 },\n }\n}\n\nfunction flattenSpanAttributes(span: Span): Record<string, string | number | boolean> {\n const base: Record<string, string | number | boolean> = {}\n if (span.attributes) {\n for (const [k, v] of Object.entries(span.attributes)) {\n if (typeof v === 'string' || typeof v === 'number' || typeof v === 'boolean') base[k] = v\n }\n }\n base[OPENINFERENCE_SPAN_KIND] = traceSpanKindToOpenInferenceKind(span.kind)\n if (span.kind === 'llm') {\n applyLlmSpanOtlpAttributes(base, span)\n } else if (span.kind === 'tool') {\n applyToolSpanOtlpAttributes(base, span)\n } else if (span.kind === 'retrieval') {\n base['retrieval.query'] = span.query\n base['retrieval.hits'] = span.hits.length\n } else if (span.kind === 'judge') {\n base['judge.id'] = span.judgeId\n base['judge.dimension'] = span.dimension\n base['judge.score'] = span.score\n base['judge.target_span_id'] = span.targetSpanId\n } else if (span.kind === 'sandbox') {\n if (span.image) base['sandbox.image'] = span.image\n if (span.exitCode !== undefined) base['sandbox.exit_code'] = span.exitCode\n if (span.testsPassed !== undefined) base['sandbox.tests_passed'] = span.testsPassed\n if (span.testsTotal !== undefined) base['sandbox.tests_total'] = span.testsTotal\n }\n return base\n}\n\nfunction flattenPayload(\n payload: Record<string, unknown>,\n): Record<string, string | number | boolean> {\n const out: Record<string, string | number | boolean> = {}\n for (const [k, v] of Object.entries(payload)) {\n if (typeof v === 'string' || typeof v === 'number' || typeof v === 'boolean') out[k] = v\n else out[k] = JSON.stringify(v)\n }\n return out\n}\n","/** General policy for recursive, evidence-backed trace analysis. */\n\nexport const TRACE_ANALYST_ACTOR_DESCRIPTION = `Answer the question by inspecting the OTLP trace dataset with the available tools.\n\n1. Call getDatasetOverview first. Use its real trace ids and dataset size to plan the investigation.\n2. Narrow with queryTraces and countTraces before scanning large payloads.\n3. For a small trace, use viewTrace. For a large trace, use searchTrace and then viewSpans or searchSpan.\n4. Never invent a trace id, span id, tool result, error, frequency, or final outcome.\n5. When a search reports has_more, refine the query before drawing a conclusion.\n6. Use llm_query only over evidence already loaded. A recursive query cannot inspect traces itself.\n7. Cite exact evidence URIs returned by the tools. Include a short exact excerpt when it supports the claim.\n8. Return no finding when the available evidence cannot support one.\n\nThe prose answer must directly answer the question and state important uncertainty.\nThe findings array contains only actionable or decision-relevant claims supported by inspected evidence.`\n\nexport const TRACE_ANALYST_ACTOR_DESCRIPTION_VERSION = 'trace-analyst-research-v1-2026-07-30'\n","import { randomUUID } from 'node:crypto'\nimport type {\n TraceAnalysisEngine,\n TraceAnalysisEngineResult,\n TraceAnalystLimits,\n} from '../analyst/engine'\nimport { runTraceAnalyst } from '../analyst/kind-factory'\nimport type { TraceToolGroupName } from '../analyst/tool-groups'\nimport type { AnalystFinding, AnalystUsageReceipt } from '../analyst/types'\nimport type { CostLedgerHandle } from '../cost-ledger'\nimport { TRACE_ANALYST_ACTOR_DESCRIPTION, TRACE_ANALYST_ACTOR_DESCRIPTION_VERSION } from './prompts'\nimport type { TraceAnalysisStore } from './store'\nimport { OtlpFileTraceStore } from './store-otlp'\n\nexport interface AnalyzeTracesInput {\n question: string\n id?: string\n description?: string\n area?: string\n}\n\nexport type AnalyzeTracesResult = TraceAnalysisEngineResult\n\nexport interface AnalyzeTracesOptions {\n /** OTLP JSONL path or a caller-owned store. */\n source: string | TraceAnalysisStore\n /** Recursive research engine. */\n engine: TraceAnalysisEngine\n /** Override the general trace-research policy. */\n instructions?: string\n /** Smallest tool set that can answer the question. Default: all. */\n toolGroup?: TraceToolGroupName\n limits?: Partial<TraceAnalystLimits>\n runId?: string\n budgetUsd?: number\n costLedger?: CostLedgerHandle\n costPhase?: string\n priorFindings?: readonly AnalystFinding[]\n upstreamFindings?: readonly AnalystFinding[]\n recordUsage?: (receipt: AnalystUsageReceipt) => void\n tags?: Record<string, string>\n log?: (message: string, fields?: Record<string, unknown>) => void\n signal?: AbortSignal\n}\n\n/**\n * Answer one question by recursively inspecting a trace store.\n *\n * The returned answer, cited findings, engine steps, call counts, and runtime\n * identity are one audit record. A direct one-shot model call is not used.\n */\nexport async function analyzeTraces(\n input: AnalyzeTracesInput,\n options: AnalyzeTracesOptions,\n): Promise<AnalyzeTracesResult> {\n if (typeof input.question !== 'string' || !input.question.trim()) {\n throw new TypeError('analyzeTraces: input.question must be a non-empty string')\n }\n const id = input.id?.trim() || 'trace-analysis'\n const store =\n typeof options.source === 'string'\n ? new OtlpFileTraceStore({ path: options.source })\n : options.source\n if (store instanceof OtlpFileTraceStore) {\n await store.ensureIndexed(options.signal ? { signal: options.signal } : undefined)\n }\n\n return runTraceAnalyst({\n definition: {\n id,\n description:\n input.description?.trim() ||\n 'Answers a caller-defined question by recursively inspecting trace evidence.',\n area: input.area?.trim() || 'trace-analysis',\n version: TRACE_ANALYST_ACTOR_DESCRIPTION_VERSION,\n question: input.question,\n instructions: options.instructions ?? TRACE_ANALYST_ACTOR_DESCRIPTION,\n toolGroup: options.toolGroup ?? 'all',\n limits: options.limits,\n },\n engine: options.engine,\n store,\n context: {\n runId: options.runId ?? id,\n correlationId: randomUUID(),\n budgetUsd: options.budgetUsd,\n costLedger: options.costLedger,\n costPhase: options.costPhase ?? 'trace-analysis',\n priorFindings: options.priorFindings,\n upstreamFindings: options.upstreamFindings,\n recordUsage: options.recordUsage,\n tags: options.tags,\n log: options.log,\n signal: options.signal,\n },\n })\n}\n","import type { SearchArtifactRef } from '../campaign/search-ledger-types'\nimport { LEDGER_HASH_PATTERN } from '../ledger-core/canonical'\n\nexport interface TraceInsightTask {\n id: string\n name: string\n prompt?: string\n difficulty?: string\n tags?: string[]\n outcome?: string\n score?: number\n gaps?: string[]\n}\n\nexport interface TraceInsightSuite {\n name: string\n collectionId?: string\n tasks: TraceInsightTask[]\n}\n\nexport interface TraceInsightFinding {\n kind: string\n severity?: string\n taskIds: string[]\n evidence?: string\n proposedFixClass?: string\n /** Narrative evidence remains a note; customer attribution uses byte-backed evidence only. */\n attribution?: TraceInsightAttribution\n}\n\n/** A byte-backed observation. Locators are not identities; every link carries a digest. */\nexport interface TraceInsightEvidence {\n subject: {\n verticalId: string\n taskId: string\n cellId: string | null\n attemptId: string | null\n company: string | null\n tool: string | null\n toolRevision: string | null\n }\n artifacts: Record<\n 'seed' | 'task' | 'cell' | 'request' | 'response' | 'document' | 'controls' | 'binding',\n SearchArtifactRef | null\n >\n spans: Array<{ traceId: string; spanId: string; artifact: SearchArtifactRef }>\n}\n\nexport type TraceInsightAttribution = TraceInsightEvidence &\n (\n | { outcome: 'unknown'; evidenceClass: 'unknown'; reasons: string[] }\n | {\n outcome: 'tool-failure'\n evidenceClass: 'validated-request-response'\n proof: SearchArtifactRef\n authority: SearchArtifactRef\n }\n | {\n outcome: 'documentation-failure'\n evidenceClass: 'authoritative-execution'\n documentation: 'stale' | 'contradictory'\n proof: SearchArtifactRef\n authority: SearchArtifactRef\n }\n | {\n outcome: 'documentation-failure'\n evidenceClass: 'paired-corrected-document'\n proof: SearchArtifactRef\n plan: SearchArtifactRef\n comparisonId: string\n correctedEvidence: SearchArtifactRef\n }\n )\n\nfunction evidenceRecord(value: unknown): value is Record<string, unknown> {\n return value !== null && typeof value === 'object' && !Array.isArray(value)\n}\n\nfunction evidenceText(value: unknown): value is string {\n return typeof value === 'string' && value.trim().length > 0\n}\n\n/** Structural validation only. The producer must verify bytes and execute the evidence rule. */\nexport function isTraceInsightArtifact(value: unknown): value is SearchArtifactRef {\n if (\n !evidenceRecord(value) ||\n !evidenceText(value.role) ||\n !evidenceText(value.uri) ||\n typeof value.sha256 !== 'string' ||\n !LEDGER_HASH_PATTERN.test(value.sha256) ||\n !Number.isSafeInteger(value.byteLength) ||\n (value.byteLength as number) < 0\n )\n return false\n // Customer reports must not turn a locator into an executable link.\n try {\n const url = new URL(value.uri)\n return ['https:', 'file:'].includes(url.protocol) && !url.username && !url.password\n } catch {\n return /^artifacts\\/[a-f0-9]{64}$/.test(value.uri)\n }\n}\n\nexport function isTraceInsightEvidence(value: unknown): value is TraceInsightEvidence {\n if (\n !evidenceRecord(value) ||\n !evidenceRecord(value.subject) ||\n !evidenceRecord(value.artifacts) ||\n !Array.isArray(value.spans)\n )\n return false\n const subject = value.subject\n if (!evidenceText(subject.verticalId) || !evidenceText(subject.taskId)) return false\n for (const field of ['cellId', 'attemptId', 'company', 'tool', 'toolRevision']) {\n if (subject[field] !== null && !evidenceText(subject[field])) return false\n }\n for (const role of [\n 'seed',\n 'task',\n 'cell',\n 'request',\n 'response',\n 'document',\n 'controls',\n 'binding',\n ]) {\n const artifact = value.artifacts[role]\n if (artifact !== null && (!isTraceInsightArtifact(artifact) || artifact.role !== role))\n return false\n }\n return value.spans.every(\n (span) =>\n evidenceRecord(span) &&\n typeof span.traceId === 'string' &&\n /^[a-f0-9]{32}$/.test(span.traceId) &&\n !/^0+$/.test(span.traceId) &&\n typeof span.spanId === 'string' &&\n /^[a-f0-9]{16}$/.test(span.spanId) &&\n !/^0+$/.test(span.spanId) &&\n isTraceInsightArtifact(span.artifact) &&\n span.artifact.role === 'span',\n )\n}\n\nexport function isTraceInsightAttribution(value: unknown): value is TraceInsightAttribution {\n if (!isTraceInsightEvidence(value)) return false\n const attribution = value as TraceInsightEvidence & Record<string, unknown>\n if (attribution.outcome === 'unknown') {\n return (\n attribution.evidenceClass === 'unknown' &&\n Array.isArray(attribution.reasons) &&\n attribution.reasons.length > 0 &&\n attribution.reasons.every(evidenceText)\n )\n }\n if (\n Object.values(value.subject).some((entry) => entry === null) ||\n Object.values(value.artifacts).some((artifact) => artifact === null) ||\n value.spans.length === 0 ||\n !isTraceInsightArtifact(attribution.proof)\n )\n return false\n if (attribution.outcome === 'tool-failure') {\n return (\n attribution.evidenceClass === 'validated-request-response' &&\n attribution.proof.role === 'execution' &&\n isTraceInsightArtifact(attribution.authority) &&\n attribution.authority.role === 'authority'\n )\n }\n if (attribution.outcome !== 'documentation-failure') return false\n if (attribution.evidenceClass === 'authoritative-execution') {\n return (\n (attribution.documentation === 'stale' || attribution.documentation === 'contradictory') &&\n attribution.proof.role === 'execution' &&\n isTraceInsightArtifact(attribution.authority) &&\n attribution.authority.role === 'authority'\n )\n }\n return (\n attribution.evidenceClass === 'paired-corrected-document' &&\n attribution.proof.role === 'publication' &&\n isTraceInsightArtifact(attribution.plan) &&\n attribution.plan.role === 'plan' &&\n isTraceInsightArtifact(attribution.correctedEvidence) &&\n attribution.correctedEvidence.role === 'binding' &&\n evidenceText(attribution.comparisonId)\n )\n}\n\nexport interface TraceInsightQuestion {\n id: string\n question: string\n why: string\n}\n\nexport interface TraceInsightPanelRole {\n id: string\n name: string\n responsibility: string\n}\n\nexport interface TraceInsightPromptInput {\n suite: TraceInsightSuite\n findings?: TraceInsightFinding[]\n agent?: Record<string, unknown>\n totals?: Record<string, unknown>\n maxRepresentativeTraces?: number\n}\n\nexport interface TraceInsightContext {\n suite: TraceInsightSuite\n scope: string\n keywords: string[]\n questions: TraceInsightQuestion[]\n panel: TraceInsightPanelRole[]\n findings: TraceInsightFinding[]\n agent: Record<string, unknown> | null\n totals: Record<string, unknown> | null\n}\n\nexport interface TraceInsightQualityGate {\n id: string\n label: string\n passed: boolean\n severity: 'critical' | 'high' | 'medium' | 'low'\n detail: string\n}\n\nexport interface TraceInsightReadiness {\n score: number\n grade: 'external-ready' | 'internal-review' | 'raw-analysis'\n gates: TraceInsightQualityGate[]\n}\n\nconst DOMAIN_STOP_WORDS = new Set([\n 'and',\n 'advanced',\n 'app',\n 'build',\n 'create',\n 'easy',\n 'expert',\n 'extreme',\n 'for',\n 'from',\n 'hard',\n 'implementation',\n 'integrate',\n 'medium',\n 'project',\n 'task',\n 'the',\n 'this',\n 'with',\n 'workflow',\n])\n\nexport function tokenizeDomainWords(value: string): string[] {\n return [...value.matchAll(/[A-Za-z][A-Za-z0-9.+#-]{2,}/g)]\n .map((match) => match[0].toLowerCase())\n .filter((word) => !DOMAIN_STOP_WORDS.has(word))\n}\n\nexport function inferDomainKeywords(suite: TraceInsightSuite): string[] {\n const suiteWords = new Set(tokenizeDomainWords(`${suite.name} ${suite.collectionId ?? ''}`))\n const source = [\n suite.name,\n suite.collectionId ?? '',\n ...suite.tasks.flatMap((task) => [\n task.id,\n task.name,\n task.prompt ?? '',\n task.difficulty ?? '',\n ...(task.tags ?? []),\n ...(task.gaps ?? []),\n ]),\n ].join(' ')\n const counts = new Map<string, number>()\n for (const word of tokenizeDomainWords(source)) counts.set(word, (counts.get(word) ?? 0) + 1)\n return [...counts.entries()]\n .filter(([word, count]) => count >= 2 || suiteWords.has(word))\n .sort((a, b) => b[1] - a[1] || a[0].localeCompare(b[0]))\n .map(([word]) => word)\n .slice(0, 18)\n}\n\nexport function domainEvidencePattern(keywords: string[]): RegExp {\n const escaped = keywords\n .filter((keyword) => keyword.length >= 3)\n .map((keyword) => keyword.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&'))\n return escaped.length > 0\n ? new RegExp(`(?<![A-Za-z0-9])(?:${escaped.join('|')})(?![A-Za-z0-9])`, 'i')\n : /(?<![A-Za-z0-9])(?:sdk|api|css|dns|xml|provider|client|service|integration|webhook|transaction|auth|oauth|graphql|rest)(?![A-Za-z0-9])/i\n}\n\nexport function describeTraceInsightScope(suite: TraceInsightSuite): string {\n const taskLabel =\n suite.tasks.length === 1\n ? '1 implementation task'\n : `${suite.tasks.length} implementation tasks`\n const tags = new Map<string, number>()\n for (const task of suite.tasks) {\n for (const tag of task.tags ?? []) tags.set(tag, (tags.get(tag) ?? 0) + 1)\n }\n const topTags = [...tags.entries()]\n .sort((a, b) => b[1] - a[1] || a[0].localeCompare(b[0]))\n .slice(0, 8)\n .map(([tag]) => tag)\n if (topTags.length > 0) return `${taskLabel} across ${topTags.join(', ')}.`\n const difficulties = [\n ...new Set(\n suite.tasks.map((task) => task.difficulty).filter((value): value is string => Boolean(value)),\n ),\n ].join(', ')\n return `${taskLabel} across ${difficulties || 'the selected benchmark scope'}.`\n}\n\nfunction planTraceInsightQuestions(input: TraceInsightPromptInput): TraceInsightQuestion[] {\n const hasFailures = input.suite.tasks.some((task) => task.outcome && task.outcome !== 'satisfied')\n const hasMultipleShots = input.suite.tasks.some((task) =>\n (task.gaps ?? []).some((gap) => /shot|review|retry|continue/i.test(gap)),\n )\n const questions: TraceInsightQuestion[] = [\n {\n id: 'execution-path',\n question: 'What did the worker actually do before the first meaningful implementation edit?',\n why: 'Separates grounded execution from polished but shallow output.',\n },\n {\n id: 'research-grounding',\n question:\n 'Did the worker inspect docs, source, examples, or package references before committing to an implementation path?',\n why: 'Identifies whether failures came from weak retrieval, weak examples, or premature coding.',\n },\n {\n id: 'domain-proof',\n question:\n 'Which tasks produced executable domain proof versus UI copy, placeholders, or inferred behavior?',\n why: 'Keeps product-quality claims tied to concrete evidence.',\n },\n {\n id: 'root-cause',\n question:\n 'For each major failure cluster, is the likely root cause prompt/scaffold, docs/examples, SDK/API ergonomics, evaluator, runtime, or model behavior?',\n why: 'Turns trace observations into actionable ownership.',\n },\n {\n id: 'evidence-quality',\n question:\n 'Which external-facing claims are directly supported by trace ids, span ids, verifier findings, reviewer notes, or generated code?',\n why: 'Prevents unsupported customer-report conclusions.',\n },\n ]\n if (hasMultipleShots) {\n questions.push({\n id: 'reviewer-lift',\n question: 'Where did reviewer feedback improve score, stall, or regress across shots?',\n why: 'Shows whether the driver loop is learning or merely repeating work.',\n })\n }\n if (hasFailures) {\n questions.push({\n id: 'optimization-targets',\n question:\n 'Which prompt, evaluator, scaffold, or workflow changes should feed the next GEPA/autoresearch optimization run?',\n why: 'Connects benchmark evidence to the optimization loop.',\n })\n }\n return questions\n}\n\nexport function buildTraceInsightContext(input: TraceInsightPromptInput): TraceInsightContext {\n return {\n suite: input.suite,\n scope: describeTraceInsightScope(input.suite),\n keywords: inferDomainKeywords(input.suite),\n questions: planTraceInsightQuestions(input),\n panel: defaultTraceInsightPanel(),\n findings: input.findings ?? [],\n agent: input.agent ?? null,\n totals: input.totals ?? null,\n }\n}\n\nexport function scoreTraceInsightReadiness(context: TraceInsightContext): TraceInsightReadiness {\n const failedTasks = context.suite.tasks.filter(\n (task) => task.outcome && task.outcome !== 'satisfied',\n )\n const findingTaskIds = new Set(context.findings.flatMap((finding) => finding.taskIds))\n const failedTasksWithFindings = failedTasks.filter((task) => findingTaskIds.has(task.id))\n const tasksWithGaps = context.suite.tasks.filter((task) => (task.gaps ?? []).length > 0)\n const gates: TraceInsightQualityGate[] = [\n {\n id: 'domain-context',\n label: 'Domain context inferred',\n passed: context.keywords.length > 0,\n severity: 'high',\n detail:\n context.keywords.length > 0\n ? `${context.keywords.length} domain terms inferred: ${context.keywords.slice(0, 8).join(', ')}`\n : 'No domain terms were inferred from suite, tasks, prompts, tags, or gaps.',\n },\n {\n id: 'panel-coverage',\n label: 'Analyst panel planned',\n passed: context.panel.length >= 4 && context.questions.length >= 5,\n severity: 'high',\n detail: `${context.panel.length} panel roles and ${context.questions.length} investigation questions planned.`,\n },\n {\n id: 'failure-coverage',\n label: 'Failures mapped to findings',\n passed:\n failedTasks.length === 0 || failedTasksWithFindings.length / failedTasks.length >= 0.5,\n severity: 'critical',\n detail:\n failedTasks.length === 0\n ? 'No failed tasks in suite.'\n : `${failedTasksWithFindings.length}/${failedTasks.length} failed tasks appear in finding clusters.`,\n },\n {\n id: 'gap-evidence',\n label: 'Task gaps captured',\n passed: failedTasks.length === 0 || tasksWithGaps.length / failedTasks.length >= 0.5,\n severity: 'medium',\n detail: `${tasksWithGaps.length} tasks include explicit evaluator or analyst gaps.`,\n },\n {\n id: 'attribution-evidence',\n label: 'Evidence-classed customer findings',\n passed:\n failedTasks.every((task) =>\n context.findings.some(\n (finding) =>\n finding.taskIds.includes(task.id) && finding.attribution?.subject.taskId === task.id,\n ),\n ) &&\n context.findings.every(\n (finding) =>\n isTraceInsightAttribution(finding.attribution) &&\n finding.taskIds.length === 1 &&\n finding.taskIds[0] === finding.attribution.subject.taskId,\n ),\n severity: 'critical',\n detail:\n 'Every finding needs an explicit evidence class and byte-backed links, or an explicit unknown; prose is not attribution evidence.',\n },\n ]\n const penalty = gates.reduce((sum, gate) => {\n if (gate.passed) return sum\n if (gate.severity === 'critical') return sum + 35\n if (gate.severity === 'high') return sum + 20\n if (gate.severity === 'medium') return sum + 10\n return sum + 5\n }, 0)\n const score = Math.max(0, Math.min(1, 1 - penalty / 100))\n return {\n score,\n grade: score >= 0.9 ? 'external-ready' : score >= 0.7 ? 'internal-review' : 'raw-analysis',\n gates,\n }\n}\n\nfunction defaultTraceInsightPanel(): TraceInsightPanelRole[] {\n return [\n {\n id: 'trace-forensics',\n name: 'Trace Forensics',\n responsibility:\n 'Reconstruct what the worker did in order, including research, edits, reviewer interventions, verifier feedback, and stop reason.',\n },\n {\n id: 'root-cause',\n name: 'Root Cause',\n responsibility:\n 'Map failures to prompt/scaffold, docs/examples, SDK/API/product ergonomics, evaluator, runtime, or model behavior.',\n },\n {\n id: 'optimization',\n name: 'Optimization',\n responsibility:\n 'Identify prompt, reviewer, evaluator, scaffold, and GEPA/autoresearch changes that should be tested next.',\n },\n {\n id: 'external-evidence',\n name: 'External Evidence',\n responsibility:\n 'Separate customer-safe claims from internal harness findings and reject conclusions without task, trace, span, code, reviewer, or verifier evidence.',\n },\n ]\n}\n\nexport function buildTraceInsightPrompt(input: TraceInsightPromptInput): string {\n const context = buildTraceInsightContext(input)\n const maxRepresentativeTraces = input.maxRepresentativeTraces ?? 6\n return `Analyze this benchmark run and produce evidence-backed trace intelligence.\n\nAudience:\n- internal AI/product leadership\n- possible customer-facing report for ${input.suite.name}\n\nInvestigation plan:\n${context.questions.map((item, index) => `${index + 1}. ${item.question} (${item.why})`).join('\\n')}\n\nAnalyst panel:\n${context.panel.map((role) => `- ${role.name}: ${role.responsibility}`).join('\\n')}\n\nIf the task branches are independent, use subagents for the panel roles above and aggregate their findings. Do not run a panel role unless its answer will change the final report.\n\nRequired output:\n1. Executive verdict: what this run proves and does not prove.\n2. The investigation questions you answered and the evidence used.\n3. Failure taxonomy: agent prompting, evaluator/harness, docs/examples, SDK/API/product integration, infra.\n4. Evidence-backed examples with trace ids/task ids and concrete verifier findings.\n5. Highest-ROI fixes for the benchmark harness, prompt/GEPA optimization, and customer-facing product/docs surface.\n6. What is safe for an external report versus what must stay internal.\n7. One rerun plan that would validate lift after optimization.\n\nBudget:\n- Inspect the dataset overview, the failure summary, and at most ${maxRepresentativeTraces} representative traces.\n- Prefer traces named in the failure summary over broad exploration.\n- Do not do exhaustive trace sweeps.\n- Return the final report as soon as the taxonomy and examples are supported.\n\nRun summary:\n${JSON.stringify(\n {\n suite: input.suite.name,\n scope: context.scope,\n inferredKeywords: context.keywords,\n agent: context.agent,\n totals: context.totals,\n findings: context.findings.map((finding) => ({\n kind: finding.kind,\n severity: finding.severity,\n taskCount: finding.taskIds.length,\n proposedFixClass: finding.proposedFixClass,\n attribution: finding.attribution,\n })),\n failures: input.suite.tasks\n .filter((task) => task.outcome && task.outcome !== 'satisfied')\n .map((task) => ({\n task: task.id,\n difficulty: task.difficulty,\n outcome: task.outcome,\n score: task.score,\n gaps: task.gaps ?? [],\n })),\n },\n null,\n 2,\n)}\n\nUse the trace tools. Do not invent facts. Cite task ids. Separate customer-facing claims from internal harness/model findings.\nCustomer attribution must preserve the supplied evidence class and artifact links. A narrative, regex label, observational rate, or document age is not causal evidence. Without validated request/response execution or a supported registered corrected-document comparison, report unknown; do not guess a failing company or tool.`\n}\n","/** Canonical flattened OTLP span shape shared by trace producers and readers. */\n\nimport type { SpanStatus } from './schema'\n\nexport type OtlpStatusCode = 'STATUS_CODE_OK' | 'STATUS_CODE_ERROR' | 'STATUS_CODE_UNSET'\n\nexport interface OtlpFlatLine {\n trace_id: string\n span_id: string\n parent_span_id: string | null\n name: string\n kind: string\n start_time: string\n end_time: string\n status: {\n code: OtlpStatusCode\n message?: string\n }\n resource: { attributes: Record<string, unknown> }\n attributes: Record<string, unknown>\n events?: Array<{ name: string; timeUnixNano?: string; attributes?: Record<string, unknown> }>\n}\n\ninterface CreateOtlpFlatLineInput {\n traceId: string\n spanId: string\n parentSpanId: string | null\n name: string\n kind: string\n startTime: string\n endTime: string\n statusCode: OtlpStatusCode\n statusMessage?: string\n resource: OtlpFlatLine['resource']\n attributes: Record<string, unknown>\n events?: OtlpFlatLine['events']\n}\n\nexport function createOtlpFlatLine(input: CreateOtlpFlatLineInput): OtlpFlatLine {\n return {\n trace_id: input.traceId,\n span_id: input.spanId,\n parent_span_id: input.parentSpanId,\n name: input.name,\n kind: input.kind,\n start_time: input.startTime,\n end_time: input.endTime,\n status: {\n code: input.statusCode,\n ...(input.statusMessage !== undefined ? { message: input.statusMessage } : {}),\n },\n resource: input.resource,\n attributes: input.attributes,\n ...(input.events && input.events.length > 0 ? { events: input.events } : {}),\n }\n}\n\n/** Map the canonical trace status while letting each caller choose its legacy default. */\nexport function spanStatusToOtlp(\n status: SpanStatus | undefined,\n error: string | undefined,\n defaultCode: OtlpStatusCode,\n): OtlpStatusCode {\n if (status === 'error' || error) return 'STATUS_CODE_ERROR'\n if (status === 'ok') return 'STATUS_CODE_OK'\n return defaultCode\n}\n\n/** Convert epoch milliseconds, returning `undefined` for invalid or out-of-range values. */\nexport function epochMillisToIso(value: number): string | undefined {\n if (!Number.isFinite(value)) return undefined\n try {\n return new Date(value).toISOString()\n } catch {\n return undefined\n }\n}\n","import { CaptureIntegrityError } from '../errors'\nimport { applyToolSpanOtlpAttributes, OPENINFERENCE_SPAN_KIND } from '../trace/otlp-attributes'\nimport { createOtlpFlatLine, epochMillisToIso, spanStatusToOtlp } from '../trace/otlp-flat'\nimport type { ToolSpan } from '../trace/schema'\nimport type { TraceAnalysisStore } from './store'\nimport { BufferTraceStore } from './store-otlp'\nimport type { ToolSpansToTraceAnalysisStoreOptions } from './store-otlp-buffered'\n\n/** Missing tool spans cannot distinguish a tool-free run from broken capture. */\nexport class ToolTraceMissingError extends CaptureIntegrityError {\n constructor() {\n super('toolSpansToTraceAnalysisStore: no tool spans supplied; trace evidence is missing')\n }\n}\n\n/**\n * Snapshot canonical tool spans into the read interface used by trace analysts.\n * One run becomes one trace while arguments, results, errors, and timing remain searchable.\n */\nexport function toolSpansToTraceAnalysisStore(\n spans: readonly ToolSpan[] | null | undefined,\n options: ToolSpansToTraceAnalysisStoreOptions = {},\n): TraceAnalysisStore {\n if (!spans || spans.length === 0) throw new ToolTraceMissingError()\n\n const seen = new Set<string>()\n const lines = spans.map((span, index) => {\n assertToolSpanIdentity(span, index)\n const identity = `${span.runId}\\u0000${span.spanId}`\n if (seen.has(identity)) {\n throw new CaptureIntegrityError(\n `toolSpansToTraceAnalysisStore: duplicate span '${span.spanId}' in run '${span.runId}'`,\n )\n }\n seen.add(identity)\n\n const attributes = { ...(span.attributes ?? {}) }\n applyToolSpanOtlpAttributes(attributes, span)\n attributes[OPENINFERENCE_SPAN_KIND] = 'TOOL'\n\n const endedAt = span.endedAt ?? span.startedAt + (span.latencyMs ?? 0)\n const line = createOtlpFlatLine({\n traceId: span.runId,\n spanId: span.spanId,\n parentSpanId: span.parentSpanId ?? null,\n name: span.name,\n kind: 'SPAN_KIND_INTERNAL',\n startTime: toolSpanTimeIso(span.startedAt, span.spanId, 'startedAt'),\n endTime: toolSpanTimeIso(endedAt, span.spanId, 'endedAt'),\n statusCode: spanStatusToOtlp(span.status, span.error, 'STATUS_CODE_UNSET'),\n statusMessage: span.error,\n resource: { attributes: {} },\n attributes,\n })\n try {\n return JSON.stringify(line)\n } catch (cause) {\n throw new CaptureIntegrityError(\n `toolSpansToTraceAnalysisStore: span '${span.spanId}' in run '${span.runId}' is not JSON-serializable`,\n { cause },\n )\n }\n })\n\n return new BufferTraceStore(Buffer.from(`${lines.join('\\n')}\\n`, 'utf8'), options)\n}\n\nfunction assertToolSpanIdentity(span: ToolSpan, index: number): void {\n if (span.kind !== 'tool') {\n throw new CaptureIntegrityError(\n `toolSpansToTraceAnalysisStore: span at index ${index} has kind '${String(span.kind)}', not 'tool'`,\n )\n }\n if (!span.runId || !span.spanId || !span.name || !span.toolName) {\n throw new CaptureIntegrityError(\n `toolSpansToTraceAnalysisStore: span at index ${index} is missing runId, spanId, name, or toolName`,\n )\n }\n if (!Number.isFinite(span.startedAt)) {\n throw new CaptureIntegrityError(\n `toolSpansToTraceAnalysisStore: span '${span.spanId}' has invalid startedAt`,\n )\n }\n if (span.endedAt !== undefined && !Number.isFinite(span.endedAt)) {\n throw new CaptureIntegrityError(\n `toolSpansToTraceAnalysisStore: span '${span.spanId}' has invalid endedAt`,\n )\n }\n if (span.endedAt !== undefined && span.endedAt < span.startedAt) {\n throw new CaptureIntegrityError(\n `toolSpansToTraceAnalysisStore: span '${span.spanId}' ends before it starts`,\n )\n }\n if (span.latencyMs !== undefined && (!Number.isFinite(span.latencyMs) || span.latencyMs < 0)) {\n throw new CaptureIntegrityError(\n `toolSpansToTraceAnalysisStore: span '${span.spanId}' has invalid latencyMs`,\n )\n }\n}\n\nfunction toolSpanTimeIso(value: number, spanId: string, field: string): string {\n const iso = epochMillisToIso(value)\n if (iso) return iso\n throw new CaptureIntegrityError(\n `toolSpansToTraceAnalysisStore: span '${spanId}' has invalid ${field}`,\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AA0DA,MAAM,mBAAmB;AAEzB,SAAS,gBAAgB,SAAkE;CACzF,IAAI,CAAC,SAAS,OAAO,KAAA;CACrB,MAAM,MAA8B,CAAC;CACrC,QAAQ,SAAS,OAAO,QAAQ;EAC9B,IAAI,IAAI,YAAY,KAAK;CAC3B,CAAC;CACD,OAAO,OAAO,KAAK,GAAG,CAAC,CAAC,SAAS,IAAI,MAAM,KAAA;AAC7C;AAEA,SAAS,eAAe,MAAuB;CAC7C,IAAI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AC,OAAO,SAAS,KAAK,SAAS,KAAK,KAAK,YAAY,IACxF,MAAM,IAAI,sBACR,wCAAwC,KAAK,OAAO,wBACtD;AAEJ;AAEA,SAAS,gBAAgB,OAAe,QAAgB,OAAuB;CAC7E,MAAM,MAAM,iBAAiB,KAAK;CAClC,IAAI,KAAK,OAAO;CAChB,MAAM,IAAI,sBACR,wCAAwC,OAAO,gBAAgB,OACjE;AACF"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { a as RunRecord } from "./run-record-pBlhZizT.js";
|
|
2
2
|
import "./reward-ap_R9mCH.js";
|
|
3
|
-
import { r as PairedDecisionStatistic } from "./paired-promotion-decision-
|
|
3
|
+
import { r as PairedDecisionStatistic } from "./paired-promotion-decision-COeOgNHG.js";
|
|
4
4
|
import { n as FailureClusterReport } from "./failure-cluster-DOoa7CBg.js";
|
|
5
5
|
type HeldOutGateRejectionCode = 'few_runs' | 'incomplete_coverage' | 'missing_split_scores' | 'missing_cost' | 'negative_delta' | 'indeterminate_delta' | 'overfit_gap' | 'cost_ceiling';
|
|
6
6
|
/**
|
|
@@ -530,4 +530,4 @@ interface ResearchReport {
|
|
|
530
530
|
*/
|
|
531
531
|
declare function researchReport(runs: RunRecord[], opts?: ResearchReportOptions): Promise<ResearchReport>;
|
|
532
532
|
export { HeldOutGateRejectionCode as C, HeldOutGateDecision as S, gainHistogram as _, ResearchReportOptions as a, HeldOutGate as b, RESEARCH_REPORT_HARD_PAIR_FLOOR as c, GainDistributionOptions as d, ParetoFigureSpec as f, SummaryTableRow as g, SummaryTableOptions as h, ResearchReportMethodology as i, GainDistributionBin as l, SummaryTable as m, ResearchReportCandidate as n, ResearchReportRecommendation as o, ParetoPoint as p, ResearchReportDecision as r, researchReport as s, ResearchReport as t, GainDistributionFigureSpec as u, summaryTable as v, SplitCoverage as w, HeldOutGateConfig as x, GateEvidence as y };
|
|
533
|
-
//# sourceMappingURL=summary-report-
|
|
533
|
+
//# sourceMappingURL=summary-report-vdhE20Zf.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"summary-report-
|
|
1
|
+
{"version":3,"file":"summary-report-vdhE20Zf.d.ts","names":[],"sources":["../src/held-out-gate.ts","../src/summary-report-figures.ts","../src/research-report-analysis.ts","../src/research-report.ts"],"mappings":";;;;KAuIY;;;;;;;;UAiBK;;EAEf;;;EAGA;;;;EAIA;;EAEA;;EAEA;;;EAGA;;UAGe;;;;EAIf;;;;;EAKA;;;;;;;;;;;EAWA;;;;EAIA;;;EAGA;;EAEA;;EAEA;;;;EAIA;;;;;;;;;;;;;;;;;EAiBA;;;;;;;;;;;;;;EAcA;;;;KAKG,iBAAiB;UAEL;;EAEf;;EAEA;;EAEA;;;;;;;;EAQA,iBAAiB;;;;;EAKjB,gBAAgB;;;;;EAKhB;;;;;;;;;EASA,gBAAgB;;;EAGhB;;;EAGA;IAAY;IAAa;;;;EAGzB;;;;;;;EAOA;IAAW;IAAW;IAAW;IAAqB;;;;;;EAKtD;;;;;EAKA;;EAEA;;EAEA;;EAEA;;EAEA;;;;;EAKA;;;EAGA;;;;;;;EAOA;;UAGe;;EAEf;;EAEA;;EAEA;;EAEA,UAAU;;EAEV;;EAEA,eAAe;;;;;;;cAQJ;mBACM;mBACA;mBACA;mBACA;mBACA;mBACA;mBACA;mBACA;mBACA;mBACA;EAEL,YAAA,QAAQ;;;;EAoCpB,SAAS,WAAW,aAAa,UAAU,cAAc;;;UAiCjD;;;;;;UAoEA;;;UAiCA;;;UAkEA;;;;;;;UAqDA;;UCvnBO;;;EAGf;;EAEA;;EAEA;;EAEA;;UAGe;EACf;EACA;EACA;EACA;EACA;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;;UAGe;EACf,MAAM;EACN;EACA;;EAEA;;;;;;;iBAQc,aAAa,MAAM,aAAa,OAAM,sBAA2B;UA4FhE;EACf;;EAEA;;EAEA;;EAEA;;;EAGA;;;EAGA;;UAGe;EACf;EACA;EACA,QAAQ;EACR;IAAQ;IAAc;;;UAiEP;;EAEf;;EAEA;;EAEA;;UAGe;EACf;EACA;EACA;EACA;;EAEA;;EAEA;;EAEA;EACA,MAAM;EACN;EACA;IAAM;IAAa;;;UAGJ;;EAEf;;EAEA;;EAEA;;EAEA;;EAEA;;;;;;;iBAQc,cACd,MAAM,aACN,qBACA,oBACA,OAAM,0BACL;;;;;;cC5QU;KCWD;UAOK;;EAEf;;EAEA;;EAEA;;EAEA;;EAEA;;;;;;;;;EASA;;;;;;;EAOA;IAAS;IAAa;;;;;;EAKtB;;;;;EAKA;;EAEA,gBAAgB,eAAe;;EAE/B,kBAAkB;;EAElB;;EAEA;;EAEA;;;;;;EAMA;;UAGe;EACf,UAAU;EACV;EACA;EACA;EACA;;UAGe;EACf;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;IAAU;IAAa;;;;;;;EAMvB;EACA;;;;;;;EAOA;EACA;EACA,OAAO;EACP,UAAU;EACV;;UAGe;;;;;EAKf;;EAEA;;EAEA;;EAEA;;EAEA;;UAGe;EACf;EACA;EACA;EACA;EACA;;;;;;EAMA;EACA;EACA;IAAQ;IAAa;;EACrB;EACA,gBAAgB;EAChB,YAAY;EACZ,SAAS;EACT;IACE,QAAQ;IACR,OAAO;;EAET,aAAa;EACb,kBAAkB;EAClB;EACA;;;;;;;;;;;;;;;;;;;;;iBAsBoB,eACpB,MAAM,aACN,OAAM,wBACL,QAAQ"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { b as RolloutSplit, h as RolloutLine } from "../schema-PDKQ_iNE.js";
|
|
2
|
-
import { A as WorkerTurnCoverage, C as SupervisorRunTreeGapCode, D as WallDistribution, E as Unavailable, M as showMeasured, N as unavailable, O as WorkerLogSource, S as SupervisorRunTreeGap, T as TerminalFailure, _ as SupervisorRunReader, a as OrchestrationMetrics, b as SupervisorRunSources, c as PerWorkerRow, d as RollupCellRow, f as SourceLimits, g as SupervisorRunNodeRole, h as SteerBreakdown, i as NamedResourceReceipt, j as isUnavailable, k as WorkerNativeSession, l as ResourceSpendRecord, m as SpendMeasurements, n as EconomicsMetrics, o as OutcomeMetrics, p as SpendMeasurement, r as Measured, s as PatchStats, t as DecisionMetrics, u as RoleSpend, v as SupervisorRunReport, w as SupervisorStatusSource, x as SupervisorRunTree, y as SupervisorRunRollup } from "../types-
|
|
2
|
+
import { A as WorkerTurnCoverage, C as SupervisorRunTreeGapCode, D as WallDistribution, E as Unavailable, M as showMeasured, N as unavailable, O as WorkerLogSource, S as SupervisorRunTreeGap, T as TerminalFailure, _ as SupervisorRunReader, a as OrchestrationMetrics, b as SupervisorRunSources, c as PerWorkerRow, d as RollupCellRow, f as SourceLimits, g as SupervisorRunNodeRole, h as SteerBreakdown, i as NamedResourceReceipt, j as isUnavailable, k as WorkerNativeSession, l as ResourceSpendRecord, m as SpendMeasurements, n as EconomicsMetrics, o as OutcomeMetrics, p as SpendMeasurement, r as Measured, s as PatchStats, t as DecisionMetrics, u as RoleSpend, v as SupervisorRunReport, w as SupervisorStatusSource, x as SupervisorRunTree, y as SupervisorRunRollup } from "../types-CwHU7U9J.js";
|
|
3
3
|
/**
|
|
4
4
|
* Analyze already-read supervisor-run bytes. Pure and synchronous: same bytes
|
|
5
5
|
* in, same report out (modulo `generatedAt`, which `now` pins in tests).
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { f as CostReceiptInput, m as CustomTokenPricing } from "./cost-ledger-Czro9wmo.js";
|
|
2
|
-
import { D as FindingLayer, M as FindingScope, T as FindingCalibration, i as AnalystFinding, m as EvidenceRef, n as AnalystContext, t as Analyst } from "./types-
|
|
2
|
+
import { D as FindingLayer, M as FindingScope, T as FindingCalibration, i as AnalystFinding, m as EvidenceRef, n as AnalystContext, t as Analyst } from "./types-6GuPL-Vt.js";
|
|
3
3
|
import { r as LedgerHash } from "./canonical-gLeHiqzd.js";
|
|
4
|
-
import { R as Scenario, S as JudgeConfig, w as JudgeScore } from "./types-
|
|
5
|
-
import { l as ExactCapableAnalyst } from "./exact-types-
|
|
6
|
-
import { a as EvaluationResult, o as EvaluatorOptions, r as EvaluationContext } from "./evaluation-
|
|
4
|
+
import { R as Scenario, S as JudgeConfig, w as JudgeScore } from "./types-C9yEqDjQ.js";
|
|
5
|
+
import { l as ExactCapableAnalyst } from "./exact-types-Blq7YvsK.js";
|
|
6
|
+
import { a as EvaluationResult, o as EvaluatorOptions, r as EvaluationContext } from "./evaluation-mk3u_ZJC.js";
|
|
7
7
|
import { a as SystemOneJson, d as SystemOneRequest, g as SystemOneState, o as SystemOneQuestion, p as SystemOneResult, s as SystemOneQuestions } from "./systemone-protocol-C4t7JH4Y.js";
|
|
8
|
-
import { Yt as calibrationFromPairs } from "./index-
|
|
9
|
-
import "./systemone-review-
|
|
8
|
+
import { Yt as calibrationFromPairs } from "./index-KAYaJtMA.js";
|
|
9
|
+
import "./systemone-review-4CKmHvr5.js";
|
|
10
10
|
import { z } from "zod";
|
|
11
11
|
/**
|
|
12
12
|
* One persisted row. We attach `run_id` on disk so a single file can
|
|
@@ -389,4 +389,4 @@ interface SystemOneAnalystOptions<I, Q extends SystemOneQuestions = SystemOneQue
|
|
|
389
389
|
}
|
|
390
390
|
declare function systemOneAnalyst<I, Q extends SystemOneQuestions = SystemOneQuestions>(options: SystemOneAnalystOptions<I, Q>): Analyst<I>;
|
|
391
391
|
export { DecisionRoute as A, DiffPolicy as B, DecisionPointOptions as C, decisionPoint as D, DecisionQuestions as E, FindingsTimeStep as F, FindingsStore as H, LedgerFinding as I, diffFindingsOverTime as L, FindingsLedgerOutcome as M, FindingsLedgerRead as N, decisionQuestionDigest as O, FindingsQuery as P, openFindingsLedger as R, DecisionInvocation as S, DecisionQuestionPolicy as T, PersistedFinding as U, FindingsDiff as V, diffFindings as W, assessSystemOneDomainMatch as _, SystemOneOptions as a, DECISION_POINT_AUC_BAR as b, systemOneEvaluator as c, SystemOneDomainCoverage as d, SystemOneDomainEvidence as f, SystemOneDomainMatchThresholds as g, SystemOneDomainMatchReport as h, SystemOneJudgeOptions as i, FindingsLedger as j, DecisionRecord as k, systemOneJudge as l, SystemOneDomainMatchReason as m, SystemOneEvaluate as n, normalizedSystemOneScore as o, SystemOneDomainMatchInput as p, SystemOneEvaluatorOptions as r, systemOneAnalyst as s, SystemOneAnalystOptions as t, PreparedSystemOneDomainMatch as u, prepareSystemOneDomainMatch as v, DecisionPointResult as w, DECISION_POINT_MIN_KAPPA as x, systemOneChoiceMargin as y, queryFindings as z };
|
|
392
|
-
//# sourceMappingURL=systemone-
|
|
392
|
+
//# sourceMappingURL=systemone-DFUN9DL1.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"systemone-
|
|
1
|
+
{"version":3,"file":"systemone-DFUN9DL1.d.ts","names":["_$__meta_eval0.calibrationFromPairs"],"sources":["../src/analyst/findings-store.ts","../src/analyst/findings-ledger.ts","../src/decision-point-records.ts","../src/decision-point.ts","../src/systemone-domain-match.ts","../src/systemone.ts"],"mappings":";;;;;;;;;;;;;;;UA8BiB,yBAAyB;EACxC;;cAGW;WAGiB;mBAFX;EAEW,YAAA;EAItB,OAAO,eAAe,UAAU,mBAAmB;;EAQzD,WAAW;;EAkBX,QAAQ,gBAAgB;;UAOT;;EAEf,UAAU;;EAEV,aAAa;;EAEb,WAAW;;;;;EAKX,SAAS;IAAQ,UAAU;IAAkB,SAAS;;;UAGvC;;;;;;;;EAQf,cAAc,UAAU,gBAAgB,SAAS;;;;;;iBAkBnC,aACd,UAAU,oBACV,SAAS,oBACT,SAAQ,aACP;;UC9Dc,sBAAsB;;EAErC;EACA,WAAW;;UAGI;EACf,UAAU;;EAEV,YAAY;;KAGF,sBAAsB;EAC5B;EAAiB,OAAO;;EAExB;EACA;IAAS;IAA8C;;;UAG5C;WACN;EACT,OACE,eACA,mBAAmB,mBAClB,QAAQ;IAAwB;IAAkB;;EACrD,QAAQ,QAAQ,sBAAsB;;;iBAwFxB,mBAAmB;EAAW;IAAiB;UA0C9C;EACf,QAAQ,wBAAwB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,qBAAqB,4BACjE,KAAK;EACb;EACA;EACA,WAAW,QAAQ;EACnB,kBAAkB,oBAAoB;EACtC,WAAW,MAAM,OAAO,GAAG,SAAS,mBAAmB,IAAI,QAAQ;EACnE,cAAc,OAAO,GAAG,SAAS,mBAAmB,iBAAiB,QAAQ;EAC7E,WACE,OAAO,gBAAgB,IACvB,OAAO,GACP,SAAS,mBACN,mBAAmB,QAAQ;EAChC,UACE,QAAQ,iBAAiB,gBAAgB,KACzC,OAAO,GACP,SAAS,0BACC;;iBAGE,iBAAiB,GAAG,UAAU,qBAAqB,oBACjE,SAAS,wBAAwB,GAAG,KACnC,QAAQ"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { i as AnalystFinding } from "./types-
|
|
1
|
+
import { i as AnalystFinding } from "./types-6GuPL-Vt.js";
|
|
2
2
|
import { d as SystemOneRequest, p as SystemOneResult, s as SystemOneQuestions } from "./systemone-protocol-C4t7JH4Y.js";
|
|
3
3
|
import { z } from "zod";
|
|
4
4
|
declare const checkSchema: z.ZodObject<{
|
|
@@ -71,4 +71,4 @@ declare function systemOneReviewFindings<Q extends SystemOneQuestions>(review: P
|
|
|
71
71
|
producedAt?: string;
|
|
72
72
|
}): AnalystFinding[];
|
|
73
73
|
export { SystemOneReviewReport as a, systemOneReviewFindings as c, SystemOneReviewInput as i, SystemOneReviewAssessment as n, assessSystemOneReview as o, SystemOneReviewCheck as r, prepareSystemOneReview as s, PreparedSystemOneReview as t };
|
|
74
|
-
//# sourceMappingURL=systemone-review-
|
|
74
|
+
//# sourceMappingURL=systemone-review-4CKmHvr5.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"systemone-review-
|
|
1
|
+
{"version":3,"file":"systemone-review-4CKmHvr5.d.ts","names":[],"sources":["../src/systemone-review.ts"],"mappings":";;;cAcM,aAAW,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0Bb,EAAA,KAAA;;KAGQ,uBAAuB,EAAE,aAAa;UACjC,qBAAqB,UAAU,qBAAqB;EACnE;EACA,SAAS,iBAAiB;EAC1B,WAAW,WAAW,IAAI;;UAGX,wBAAwB,UAAU,qBAAqB,4BAC9D,qBAAqB;;EAE7B;;UAGe;EACf;EACA;EACA;;EAQA;EACA;EACA;EACA;EACA,OAAO;;UAGQ;EACf;EACA;EACA;EACA,aAAa;;;iBAWC,6BAA6B,UAAU,oBACrD,OAAO,qBAAqB,KAC3B,wBAAwB;;iBAuCX,sBAAsB,UAAU,oBAC9C,QAAQ,wBAAwB,IAChC,eACC;;iBAyDa,wBAAwB,UAAU,oBAChD,QAAQ,wBAAwB,IAChC,QAAQ,gBAAgB,IACxB;EAAW;EAAmB;IAC7B"}
|
package/dist/systemone.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { a as EvaluationResult, c as asJudge, i as EvaluationJudgeOptions, l as createEvaluator, n as EvaluationAnalystOptions, o as EvaluatorOptions, r as EvaluationContext, s as asAnalyst, t as CostedEvaluator } from "./evaluation-
|
|
1
|
+
import { a as EvaluationResult, c as asJudge, i as EvaluationJudgeOptions, l as createEvaluator, n as EvaluationAnalystOptions, o as EvaluatorOptions, r as EvaluationContext, s as asAnalyst, t as CostedEvaluator } from "./evaluation-mk3u_ZJC.js";
|
|
2
2
|
import { C as systemOneUsage, S as systemOneConfidence, _ as normalizeSystemOneResult, a as SystemOneJson, b as parseSystemOneRequest, c as SystemOneRecordedQuestion, d as SystemOneRequest, f as SystemOneResponseError, g as SystemOneState, h as SystemOneScoreCriteria, i as SystemOneDescription, l as SystemOneRecordedQuestions, m as SystemOneResultProfile, n as SystemOneAnswer, o as SystemOneQuestion, p as SystemOneResult, r as SystemOneAnswerFor, s as SystemOneQuestions, u as SystemOneRecordedRequest, x as parseSystemOneResult, y as parseSystemOneRecordedRequest } from "./systemone-protocol-C4t7JH4Y.js";
|
|
3
|
-
import { A as DecisionRoute, C as DecisionPointOptions, D as decisionPoint, E as DecisionQuestions, O as decisionQuestionDigest, S as DecisionInvocation, T as DecisionQuestionPolicy, _ as assessSystemOneDomainMatch, a as SystemOneOptions, b as DECISION_POINT_AUC_BAR, c as systemOneEvaluator, d as SystemOneDomainCoverage, f as SystemOneDomainEvidence, g as SystemOneDomainMatchThresholds, h as SystemOneDomainMatchReport, i as SystemOneJudgeOptions, k as DecisionRecord, l as systemOneJudge, m as SystemOneDomainMatchReason, n as SystemOneEvaluate, o as normalizedSystemOneScore, p as SystemOneDomainMatchInput, r as SystemOneEvaluatorOptions, s as systemOneAnalyst, t as SystemOneAnalystOptions, u as PreparedSystemOneDomainMatch, v as prepareSystemOneDomainMatch, w as DecisionPointResult, x as DECISION_POINT_MIN_KAPPA, y as systemOneChoiceMargin } from "./systemone-
|
|
4
|
-
import { a as SystemOneReviewReport, c as systemOneReviewFindings, i as SystemOneReviewInput, n as SystemOneReviewAssessment, o as assessSystemOneReview, r as SystemOneReviewCheck, s as prepareSystemOneReview, t as PreparedSystemOneReview } from "./systemone-review-
|
|
3
|
+
import { A as DecisionRoute, C as DecisionPointOptions, D as decisionPoint, E as DecisionQuestions, O as decisionQuestionDigest, S as DecisionInvocation, T as DecisionQuestionPolicy, _ as assessSystemOneDomainMatch, a as SystemOneOptions, b as DECISION_POINT_AUC_BAR, c as systemOneEvaluator, d as SystemOneDomainCoverage, f as SystemOneDomainEvidence, g as SystemOneDomainMatchThresholds, h as SystemOneDomainMatchReport, i as SystemOneJudgeOptions, k as DecisionRecord, l as systemOneJudge, m as SystemOneDomainMatchReason, n as SystemOneEvaluate, o as normalizedSystemOneScore, p as SystemOneDomainMatchInput, r as SystemOneEvaluatorOptions, s as systemOneAnalyst, t as SystemOneAnalystOptions, u as PreparedSystemOneDomainMatch, v as prepareSystemOneDomainMatch, w as DecisionPointResult, x as DECISION_POINT_MIN_KAPPA, y as systemOneChoiceMargin } from "./systemone-DFUN9DL1.js";
|
|
4
|
+
import { a as SystemOneReviewReport, c as systemOneReviewFindings, i as SystemOneReviewInput, n as SystemOneReviewAssessment, o as assessSystemOneReview, r as SystemOneReviewCheck, s as prepareSystemOneReview, t as PreparedSystemOneReview } from "./systemone-review-4CKmHvr5.js";
|
|
5
5
|
export { CostedEvaluator, DECISION_POINT_AUC_BAR, DECISION_POINT_MIN_KAPPA, DecisionInvocation, DecisionPointOptions, DecisionPointResult, DecisionQuestionPolicy, DecisionQuestions, type DecisionRecord, type DecisionRoute, EvaluationAnalystOptions, EvaluationContext, EvaluationJudgeOptions, EvaluationResult, EvaluatorOptions, PreparedSystemOneDomainMatch, PreparedSystemOneReview, SystemOneAnalystOptions, type SystemOneAnswer, type SystemOneAnswerFor, type SystemOneDescription, SystemOneDomainCoverage, SystemOneDomainEvidence, SystemOneDomainMatchInput, SystemOneDomainMatchReason, SystemOneDomainMatchReport, SystemOneDomainMatchThresholds, SystemOneEvaluate, SystemOneEvaluatorOptions, type SystemOneJson, SystemOneJudgeOptions, SystemOneOptions, type SystemOneQuestion, type SystemOneQuestions, type SystemOneRecordedQuestion, type SystemOneRecordedQuestions, type SystemOneRecordedRequest, type SystemOneRequest, SystemOneResponseError, type SystemOneResult, type SystemOneResultProfile, SystemOneReviewAssessment, SystemOneReviewCheck, SystemOneReviewInput, SystemOneReviewReport, type SystemOneScoreCriteria, type SystemOneState, asAnalyst, asJudge, assessSystemOneDomainMatch, assessSystemOneReview, createEvaluator, decisionPoint, decisionQuestionDigest, normalizeSystemOneResult, normalizedSystemOneScore, parseSystemOneRecordedRequest, parseSystemOneRequest, parseSystemOneResult, prepareSystemOneDomainMatch, prepareSystemOneReview, systemOneAnalyst, systemOneChoiceMargin, systemOneConfidence, systemOneEvaluator, systemOneJudge, systemOneReviewFindings, systemOneUsage };
|
package/dist/systemone.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SystemOneResponseError, normalizeSystemOneResult, parseSystemOneRecordedRequest, parseSystemOneRequest, parseSystemOneResult, systemOneConfidence, systemOneUsage } from "./systemone-protocol.js";
|
|
2
|
-
import { a as normalizedSystemOneScore, c as systemOneJudge, d as systemOneChoiceMargin, i as decisionQuestionDigest, l as assessSystemOneDomainMatch, n as DECISION_POINT_MIN_KAPPA, o as systemOneAnalyst, r as decisionPoint, s as systemOneEvaluator, t as DECISION_POINT_AUC_BAR, u as prepareSystemOneDomainMatch } from "./decision-point-
|
|
3
|
-
import { n as asJudge, r as createEvaluator, t as asAnalyst } from "./evaluation-
|
|
2
|
+
import { a as normalizedSystemOneScore, c as systemOneJudge, d as systemOneChoiceMargin, i as decisionQuestionDigest, l as assessSystemOneDomainMatch, n as DECISION_POINT_MIN_KAPPA, o as systemOneAnalyst, r as decisionPoint, s as systemOneEvaluator, t as DECISION_POINT_AUC_BAR, u as prepareSystemOneDomainMatch } from "./decision-point-CQOczIIH.js";
|
|
3
|
+
import { n as asJudge, r as createEvaluator, t as asAnalyst } from "./evaluation-C_GJvEEG.js";
|
|
4
4
|
import { n as prepareSystemOneReview, r as systemOneReviewFindings, t as assessSystemOneReview } from "./systemone-review-BusEIzsg.js";
|
|
5
5
|
export { DECISION_POINT_AUC_BAR, DECISION_POINT_MIN_KAPPA, SystemOneResponseError, asAnalyst, asJudge, assessSystemOneDomainMatch, assessSystemOneReview, createEvaluator, decisionPoint, decisionQuestionDigest, normalizeSystemOneResult, normalizedSystemOneScore, parseSystemOneRecordedRequest, parseSystemOneRequest, parseSystemOneResult, prepareSystemOneDomainMatch, prepareSystemOneReview, systemOneAnalyst, systemOneChoiceMargin, systemOneConfidence, systemOneEvaluator, systemOneJudge, systemOneReviewFindings, systemOneUsage };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Y as TraceAnalysisStore } from "./types-
|
|
2
|
-
import { p as TraceAnalysisToolDescriptor } from "./engine-
|
|
1
|
+
import { Y as TraceAnalysisStore } from "./types-6GuPL-Vt.js";
|
|
2
|
+
import { p as TraceAnalysisToolDescriptor } from "./engine-B0gr15-l.js";
|
|
3
3
|
/** Named tool sets. Kinds pass `tools: TRACE_TOOL_GROUPS.failureForensics` etc. */
|
|
4
4
|
type TraceToolGroupName =
|
|
5
5
|
/** All available tools. Use for open-ended discovery kinds. */
|
|
@@ -23,4 +23,4 @@ type TraceToolGroupName =
|
|
|
23
23
|
*/
|
|
24
24
|
declare function buildTraceToolsForGroup(group: TraceToolGroupName, store: TraceAnalysisStore): TraceAnalysisToolDescriptor[];
|
|
25
25
|
export { buildTraceToolsForGroup as n, TraceToolGroupName as t };
|
|
26
|
-
//# sourceMappingURL=tool-groups-
|
|
26
|
+
//# sourceMappingURL=tool-groups-Dpl3picW.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool-groups-Dpl3picW.d.ts","names":[],"sources":["../src/analyst/tool-groups.ts"],"mappings":";;;KAmBY;;;;;;;;;;;;;;;;;;;;iBAyDI,wBACd,OAAO,oBACP,OAAO,qBACN"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { o as CostLedgerHandle } from "./cost-ledger-Czro9wmo.js";
|
|
2
|
-
import { Y as TraceAnalysisStore } from "./types-
|
|
3
|
-
import { i as TraceAnalystLimits, s as RawAnalystFinding, t as TraceAnalysisEngine } from "./engine-
|
|
2
|
+
import { Y as TraceAnalysisStore } from "./types-6GuPL-Vt.js";
|
|
3
|
+
import { i as TraceAnalystLimits, s as RawAnalystFinding, t as TraceAnalysisEngine } from "./engine-B0gr15-l.js";
|
|
4
4
|
/** One question to ask of the store. */
|
|
5
5
|
interface TraceQuestionSpec {
|
|
6
6
|
/** Stable id: letters, digits, dot, underscore, hyphen. */
|
|
@@ -58,4 +58,4 @@ interface TraceQuestionOutcome {
|
|
|
58
58
|
*/
|
|
59
59
|
declare function askTraceQuestions(opts: AskTraceQuestionsOptions): Promise<TraceQuestionOutcome[]>;
|
|
60
60
|
export { askTraceQuestions as a, VerifiedTraceFinding as i, TraceQuestionOutcome as n, TraceQuestionSpec as r, AskTraceQuestionsOptions as t };
|
|
61
|
-
//# sourceMappingURL=trace-questions-
|
|
61
|
+
//# sourceMappingURL=trace-questions-oT2fZWJ8.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"trace-questions-
|
|
1
|
+
{"version":3,"file":"trace-questions-oT2fZWJ8.d.ts","names":[],"sources":["../src/analyst/trace-questions.ts"],"mappings":";;;;UA6BiB;;WAEN;WACA;;WAEA;;UAGM;WACN,oBAAoB;WACpB,OAAO;WACP,QAAQ;;WAER,YAAY;;WAEZ;;WAEA;;WAEA;;WAEA;;WAEA;WACA,SAAS,QAAQ;WACjB,SAAS;WACT,OAAO,iBAAiB,SAAS;;;UAI3B;WACN,SAAS;;WAET;;WAEA;;WAEA;;UAGM;WACN;WACA;WACA;WACA;;WAEA;WACA,mBAAmB;;WAEnB;WACA;;;;;;;iBAyBW,kBACpB,MAAM,2BACL,QAAQ"}
|
|
@@ -2,7 +2,7 @@ import { m as CustomTokenPricing, o as CostLedgerHandle, u as CostProvenance } f
|
|
|
2
2
|
import { r as CaptureIntegrityError } from "../errors-E9I2hldP.js";
|
|
3
3
|
import { d as RunTokenUsage } from "../run-record-pBlhZizT.js";
|
|
4
4
|
import { t as DefaultVerdict } from "../verdict-D_qiBQ6_.js";
|
|
5
|
-
import { i as TraceAnalystLimits, t as TraceAnalysisEngine } from "../engine-
|
|
5
|
+
import { i as TraceAnalystLimits, t as TraceAnalysisEngine } from "../engine-B0gr15-l.js";
|
|
6
6
|
import { t as PrimeBridgeTransport } from "../prime-bridge-transport-Cfqir_Im.js";
|
|
7
7
|
import { i as RecordedTrajectoryStep } from "../steps-B8fYY_Vo.js";
|
|
8
8
|
type ParsedAction = {
|
package/dist/traces.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { c as ValidationError, o as LimitExceededError, s as NotFoundError, t as AgentEvalError } from "./errors-E9I2hldP.js";
|
|
2
2
|
import { C as TraceRunOutcome, E as isToolSpan, S as TraceEvent, T as isLlmSpan, _ as Span, a as FAILURE_CLASSES, b as SpanStatus, c as JudgeSpan, d as RetrievalSpan, f as Run, g as SandboxSpan, h as RunStatus, i as EventKind, l as LlmSpan, m as RunLayer, n as BudgetLedgerEntry, o as FailureClass, p as RunCaptureReport, r as BudgetSpec, s as GenericSpan, t as Artifact, u as Message, v as SpanBase, w as isJudgeSpan, x as ToolSpan, y as SpanKind } from "./schema-CkIvnmLU.js";
|
|
3
3
|
import { a as RunRecord, c as RunSplitTag, d as RunTokenUsage, u as RunTerminalOutcome } from "./run-record-pBlhZizT.js";
|
|
4
|
-
import { $ as ErrorCluster, G as ReadSpanSourceInput, J as TRACE_ANALYSIS_LIMITS, K as ReadSpanSourceResult, Q as DatasetOverview, U as createBoundedTraceAnalysisStore, W as BoundedTraceAnalysisStoreOptions, X as TraceAnalysisStoreContext, Y as TraceAnalysisStore, Z as DEFAULT_TRACE_ANALYST_BUDGETS, at as TraceAnalystFilters, ct as TraceAnalystSpanStatus, dt as ViewTraceOversized, et as QueryTracesPage, ft as ViewTraceResult, it as TraceAnalystByteBudgets, lt as TraceAnalystTraceSummary, nt as SearchTraceResult, ot as TraceAnalystSpan, q as SpanSourceReader, rt as SpanMatchRecord, st as TraceAnalystSpanKind, tt as SearchSpanResult, ut as ViewSpansResult } from "./types-
|
|
5
|
-
import { $ as
|
|
4
|
+
import { $ as ErrorCluster, G as ReadSpanSourceInput, J as TRACE_ANALYSIS_LIMITS, K as ReadSpanSourceResult, Q as DatasetOverview, U as createBoundedTraceAnalysisStore, W as BoundedTraceAnalysisStoreOptions, X as TraceAnalysisStoreContext, Y as TraceAnalysisStore, Z as DEFAULT_TRACE_ANALYST_BUDGETS, at as TraceAnalystFilters, ct as TraceAnalystSpanStatus, dt as ViewTraceOversized, et as QueryTracesPage, ft as ViewTraceResult, it as TraceAnalystByteBudgets, lt as TraceAnalystTraceSummary, nt as SearchTraceResult, ot as TraceAnalystSpan, q as SpanSourceReader, rt as SpanMatchRecord, st as TraceAnalystSpanKind, tt as SearchSpanResult, ut as ViewSpansResult } from "./types-6GuPL-Vt.js";
|
|
5
|
+
import { $ as InMemoryRawProviderSink, Q as FileSystemRawProviderSinkOptions, Z as FileSystemRawProviderSink, at as RawProviderSink, et as InMemoryRawProviderSinkOptions, it as RawProviderEvent, nt as ProviderRedactor, ot as RawProviderSinkFilter, rt as RawProviderDirection, tt as NoopRawProviderSink } from "./cluster-CkzP4h3T.js";
|
|
6
6
|
import { a as RunFilter, i as InMemoryTraceStore, n as FileSystemTraceStore, o as SpanFilter, r as FileSystemTraceStoreOptions, s as TraceStore, t as EventFilter } from "./store-CMs5wGXP.js";
|
|
7
7
|
import { a as SpanHandle, i as RunCompleteHookContext, n as CaptureWrite, o as TraceEmitter, r as RunCompleteHook, s as TraceEmitterOptions, t as CaptureErrorHandler } from "./emitter-mAXC5PSN.js";
|
|
8
|
-
import { d as BuildTraceAnalysisToolsOptions, f as TRACE_ANALYST_TOOL_NAMESPACE, h as buildTraceAnalysisToolDescriptors, m as UNTRUSTED_TRACE_TEXT, p as TraceAnalysisToolDescriptor } from "./engine-
|
|
9
|
-
import { A as TraceInsightReadiness, B as isTraceInsightEvidence, C as TraceInsightContext, D as TraceInsightPromptInput, E as TraceInsightPanelRole, F as describeTraceInsightScope, G as AnalyzeTracesResult, H as tokenizeDomainWords, I as domainEvidencePattern, K as analyzeTraces, L as inferDomainKeywords, M as TraceInsightTask, N as buildTraceInsightContext, O as TraceInsightQualityGate, P as buildTraceInsightPrompt, R as isTraceInsightArtifact, S as TraceInsightAttribution, T as TraceInsightFinding, U as AnalyzeTracesInput, V as scoreTraceInsightReadiness, W as AnalyzeTracesOptions, _ as ToolSpansToTraceAnalysisStoreOptions, a as captureFetchToRawSink, b as OtlpSpan, c as ExtractedUsage, d as extractUsageFromSse, f as OtlpFileTraceStore, g as spanRecordsToTraceAnalysisStore, h as otlpTextToTraceAnalysisStore, i as CaptureFetchOptions, j as TraceInsightSuite, k as TraceInsightQuestion, l as SseUsageMode, m as SpanRecordsToTraceAnalysisStoreOptions, n as toolSpansToTraceAnalysisStore, o as OtlpFlatLine, p as OtlpFileTraceStoreOptions, r as CaptureFetchContext, s as ExtractUsageFromSseOptions, t as ToolTraceMissingError, u as extractUsage, v as OtlpExport, w as TraceInsightEvidence, x as exportRunAsOtlp, y as OtlpResourceSpans, z as isTraceInsightAttribution } from "./store-tool-spans-
|
|
10
|
-
import { a as RunIntegrityReport, i as RunIntegrityIssueCode, n as RunIntegrityExpectations, o as assertRunCaptured, r as RunIntegrityIssue, t as RunIntegrityError } from "./integrity-
|
|
8
|
+
import { d as BuildTraceAnalysisToolsOptions, f as TRACE_ANALYST_TOOL_NAMESPACE, h as buildTraceAnalysisToolDescriptors, m as UNTRUSTED_TRACE_TEXT, p as TraceAnalysisToolDescriptor } from "./engine-B0gr15-l.js";
|
|
9
|
+
import { A as TraceInsightReadiness, B as isTraceInsightEvidence, C as TraceInsightContext, D as TraceInsightPromptInput, E as TraceInsightPanelRole, F as describeTraceInsightScope, G as AnalyzeTracesResult, H as tokenizeDomainWords, I as domainEvidencePattern, K as analyzeTraces, L as inferDomainKeywords, M as TraceInsightTask, N as buildTraceInsightContext, O as TraceInsightQualityGate, P as buildTraceInsightPrompt, R as isTraceInsightArtifact, S as TraceInsightAttribution, T as TraceInsightFinding, U as AnalyzeTracesInput, V as scoreTraceInsightReadiness, W as AnalyzeTracesOptions, _ as ToolSpansToTraceAnalysisStoreOptions, a as captureFetchToRawSink, b as OtlpSpan, c as ExtractedUsage, d as extractUsageFromSse, f as OtlpFileTraceStore, g as spanRecordsToTraceAnalysisStore, h as otlpTextToTraceAnalysisStore, i as CaptureFetchOptions, j as TraceInsightSuite, k as TraceInsightQuestion, l as SseUsageMode, m as SpanRecordsToTraceAnalysisStoreOptions, n as toolSpansToTraceAnalysisStore, o as OtlpFlatLine, p as OtlpFileTraceStoreOptions, r as CaptureFetchContext, s as ExtractUsageFromSseOptions, t as ToolTraceMissingError, u as extractUsage, v as OtlpExport, w as TraceInsightEvidence, x as exportRunAsOtlp, y as OtlpResourceSpans, z as isTraceInsightAttribution } from "./store-tool-spans-BemsQEhd.js";
|
|
10
|
+
import { a as RunIntegrityReport, i as RunIntegrityIssueCode, n as RunIntegrityExpectations, o as assertRunCaptured, r as RunIntegrityIssue, t as RunIntegrityError } from "./integrity-zeWMeTQt.js";
|
|
11
11
|
import { C as classifyKey, E as normalizeKey, _ as redactText, a as RedactionFinding, c as SafetyCategory, d as ShareSafetyVerdict, f as assessShareSafety, g as redactForShare, h as redact, i as RedactOptions, l as ShareSafetyFinding, m as emptyRedactionReport, o as RedactionProfile, p as combineVerdicts, r as REDACTION_VERSION, s as RedactionReport, t as AssessOptions, u as ShareSafetyStatus, v as shareAllowed, w as detectCredential } from "./redact-jrT0APTU.js";
|
|
12
12
|
import { D as asNumber, E as applyLlmSpanOtlpAttributes, O as contextInputTokens, T as TOOL_NAME_ATTR_KEYS, _ as LlmSpanOtlpInput, a as LLM_CACHE_WRITE_TOKEN_ATTR_KEYS, c as LLM_COST_USD, d as LLM_MODEL_ATTR_KEYS, f as LLM_MODEL_NAME, g as LLM_REASONING_TOKEN_ATTR_KEYS, h as LLM_REASONING_TOKENS, i as LLM_CACHE_WRITE_TOKENS, k as firstNumberAttr, l as LLM_INPUT_TOKENS, m as LLM_OUTPUT_TOKEN_ATTR_KEYS, n as LLM_CACHED_TOKENS, o as LLM_CONTEXT_TOKENS, p as LLM_OUTPUT_TOKENS, r as LLM_CACHED_TOKEN_ATTR_KEYS, s as LLM_COST_ATTR_KEYS, t as INPUT_VALUE, u as LLM_INPUT_TOKEN_ATTR_KEYS, v as OPENINFERENCE_SPAN_KIND, w as TOOL_NAME, x as SPAN_KIND_ATTR_KEYS, y as OUTPUT_VALUE } from "./attribute-vocabulary-5oo8ykIx.js";
|
|
13
13
|
import { a as llmSpans, c as toolSpans, i as judgeSpans, n as argHash, o as runFailureClass, r as groupBy, s as runsForScenario, t as RunMetric } from "./query-UD0B08Sb.js";
|
package/dist/traces.js
CHANGED
|
@@ -2,16 +2,16 @@ import { i as isToolSpan, n as isJudgeSpan, r as isLlmSpan, t as FAILURE_CLASSES
|
|
|
2
2
|
import { c as validateRunRecord, i as modelHasSnapshot } from "./run-record-DmX_ESC5.js";
|
|
3
3
|
import { a as llmSpans, c as runsForScenario, i as judgeSpans, l as toolSpans, n as groupBy, o as runFailureClass, t as argHash } from "./query-CGXzO9d4.js";
|
|
4
4
|
import { a as emptyRedactionReport, c as redactText, f as classifyKey, g as normalizeKey, i as combineVerdicts, l as shareAllowed, n as REDACTION_VERSION, o as redact, p as detectCredential, r as assessShareSafety, s as redactForShare } from "./redact-zp_ILC4l.js";
|
|
5
|
-
import { C as asString, D as projectOtlpFlatLine, E as firstStringAttr, O as spanEpochMillis, S as TraceNotFoundError, _ as TraceAnalysisStoreContractError, a as UNTRUSTED_TRACE_TEXT, b as TraceFileMissingError, c as createBoundedTraceAnalysisStore, g as TraceAnalysisLimitError, h as SpanNotFoundError, i as TRACE_ANALYST_TOOL_NAMESPACE, m as TRACE_ANALYSIS_LIMITS, o as buildTraceAnalysisToolDescriptors, p as DEFAULT_TRACE_ANALYST_BUDGETS, v as TraceAnalysisValidationError, w as compareSpanTime, x as TraceFileTooLargeError } from "./kind-factory-
|
|
5
|
+
import { C as asString, D as projectOtlpFlatLine, E as firstStringAttr, O as spanEpochMillis, S as TraceNotFoundError, _ as TraceAnalysisStoreContractError, a as UNTRUSTED_TRACE_TEXT, b as TraceFileMissingError, c as createBoundedTraceAnalysisStore, g as TraceAnalysisLimitError, h as SpanNotFoundError, i as TRACE_ANALYST_TOOL_NAMESPACE, m as TRACE_ANALYSIS_LIMITS, o as buildTraceAnalysisToolDescriptors, p as DEFAULT_TRACE_ANALYST_BUDGETS, v as TraceAnalysisValidationError, w as compareSpanTime, x as TraceFileTooLargeError } from "./kind-factory-CJXaE1oF.js";
|
|
6
6
|
import { INPUT_VALUE, LLM_CACHED_TOKENS, LLM_CACHED_TOKEN_ATTR_KEYS, LLM_CACHE_WRITE_TOKENS, LLM_CACHE_WRITE_TOKEN_ATTR_KEYS, LLM_CONTEXT_TOKENS, LLM_COST_ATTR_KEYS, LLM_COST_USD, LLM_INPUT_TOKENS, LLM_INPUT_TOKEN_ATTR_KEYS, LLM_MODEL_ATTR_KEYS, LLM_MODEL_NAME, LLM_OUTPUT_TOKENS, LLM_OUTPUT_TOKEN_ATTR_KEYS, LLM_REASONING_TOKENS, LLM_REASONING_TOKEN_ATTR_KEYS, OPENINFERENCE_SPAN_KIND, OUTPUT_VALUE, SPAN_KIND_ATTR_KEYS, TOOL_NAME, TOOL_NAME_ATTR_KEYS, applyLlmSpanOtlpAttributes, asNumber, contextInputTokens, firstNumberAttr } from "./trace-attributes.js";
|
|
7
7
|
import { n as extractUsageFromSse, t as extractUsage } from "./extract-usage-ISFqhfDz.js";
|
|
8
8
|
import { n as InMemoryRawProviderSink, r as NoopRawProviderSink, t as FileSystemRawProviderSink } from "./raw-provider-sink-RbaEv2vB.js";
|
|
9
|
-
import { _ as exportRunAsOtlp, a as spanStatusToOtlp, c as describeTraceInsightScope, d as isTraceInsightArtifact, f as isTraceInsightAttribution, g as analyzeTraces, h as tokenizeDomainWords, i as epochMillisToIso, l as domainEvidencePattern, m as scoreTraceInsightReadiness, n as toolSpansToTraceAnalysisStore, o as buildTraceInsightContext, p as isTraceInsightEvidence, r as createOtlpFlatLine, s as buildTraceInsightPrompt, t as ToolTraceMissingError, u as inferDomainKeywords, v as captureFetchToRawSink } from "./store-tool-spans-
|
|
9
|
+
import { _ as exportRunAsOtlp, a as spanStatusToOtlp, c as describeTraceInsightScope, d as isTraceInsightArtifact, f as isTraceInsightAttribution, g as analyzeTraces, h as tokenizeDomainWords, i as epochMillisToIso, l as domainEvidencePattern, m as scoreTraceInsightReadiness, n as toolSpansToTraceAnalysisStore, o as buildTraceInsightContext, p as isTraceInsightEvidence, r as createOtlpFlatLine, s as buildTraceInsightPrompt, t as ToolTraceMissingError, u as inferDomainKeywords, v as captureFetchToRawSink } from "./store-tool-spans-CW24axM0.js";
|
|
10
10
|
import { t as TraceEmitter } from "./emitter-DhQ65mza.js";
|
|
11
11
|
import { n as assertRunCaptured, t as RunIntegrityError } from "./integrity-DOHt1mwU.js";
|
|
12
12
|
import { n as traceSpanKindToOpenInferenceKind, t as applyToolSpanOtlpAttributes } from "./otlp-attributes-Boeb7gtH.js";
|
|
13
13
|
import { n as InMemoryTraceStore, t as FileSystemTraceStore } from "./store-ZykIyQmy.js";
|
|
14
|
-
import { a as spanRecordsToTraceAnalysisStore, i as otlpTextToTraceAnalysisStore, r as OtlpFileTraceStore } from "./store-otlp-
|
|
14
|
+
import { a as spanRecordsToTraceAnalysisStore, i as otlpTextToTraceAnalysisStore, r as OtlpFileTraceStore } from "./store-otlp-CmgKDr0O.js";
|
|
15
15
|
import { i as summarizeTraceErrors, n as recordAggregateMeasurements, r as summarizeExecutionMeasurements, t as readTaskFailureLabels } from "./task-failure-attributes-CC6VuIpk.js";
|
|
16
16
|
import { readFileSync, readdirSync, statSync, writeFileSync } from "node:fs";
|
|
17
17
|
import { join } from "node:path";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { o as CostLedgerHandle, u as CostProvenance } from "./cost-ledger-Czro9wmo.js";
|
|
2
2
|
import { a as RunRecord, d as RunTokenUsage } from "./run-record-pBlhZizT.js";
|
|
3
|
-
import { O as ChatClient, g as JudgeInput, t as BootstrapInterval } from "./cluster-
|
|
3
|
+
import { O as ChatClient, g as JudgeInput, t as BootstrapInterval } from "./cluster-CkzP4h3T.js";
|
|
4
4
|
import { z } from "zod";
|
|
5
5
|
import { SpanKind } from "@tangle-network/agent-trace-contract";
|
|
6
6
|
import { RE2JS } from "re2js";
|
|
@@ -1012,4 +1012,4 @@ type AnalystRunEvent = {
|
|
|
1012
1012
|
result: AnalystRunResult;
|
|
1013
1013
|
};
|
|
1014
1014
|
export { ErrorCluster as $, FindingParseOutcome as A, FindingTreatment as B, CalibrationInterval as C, FindingLayer as D, FindingEvidenceUnit as E, independentUnitCount as F, ReadSpanSourceInput as G, TreatmentLayer as H, lineageRoots as I, TRACE_ANALYSIS_LIMITS as J, ReadSpanSourceResult as K, parseAnalystFinding as L, FindingScope as M, FindingScopeReading as N, FindingMeasure as O, ProposalFindingSchema as P, DatasetOverview as Q, readFindingScope as R, makeProposalFinding as S, FindingCalibration as T, createBoundedTraceAnalysisStore as U, TREATMENT_LAYERS as V, BoundedTraceAnalysisStoreOptions as W, TraceAnalysisStoreContext as X, TraceAnalysisStore as Y, DEFAULT_TRACE_ANALYST_BUDGETS as Z, ExecutionProbeRequest as _, AnalystFindingSchemaVersion as a, TraceAnalystFilters as at, computeFindingId as b, AnalystRunEvent as c, TraceAnalystSpanStatus as ct, AnalystRunSummary as d, ViewTraceOversized as dt, QueryTracesPage as et, AnalystSeverity as f, ViewTraceResult as ft, ExecutionProbeOutcome as g, ExecutionProbe as h, AnalystFinding as i, TraceAnalystByteBudgets as it, FindingReaderLabel as j, FindingMethod as k, AnalystRunInputs as l, TraceAnalystTraceSummary as lt, EvidenceRef as m, AnalystContext as n, SearchTraceResult as nt, AnalystInputKind as o, TraceAnalystSpan as ot, AnalystUsageReceipt as p, SpanSourceReader as q, AnalystCost as r, SpanMatchRecord as rt, AnalystRequirements as s, TraceAnalystSpanKind as st, Analyst as t, SearchSpanResult as tt, AnalystRunResult as u, ViewSpansResult as ut, ProposalFinding as v, FINDING_LAYERS as w, makeFinding as x, ProposalFindingOrigin as y, FindingConditions as z };
|
|
1015
|
-
//# sourceMappingURL=types-
|
|
1015
|
+
//# sourceMappingURL=types-6GuPL-Vt.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types-
|
|
1
|
+
{"version":3,"file":"types-6GuPL-Vt.d.ts","names":[],"sources":["../src/trace-analyst/types.ts","../src/trace-analyst/store-contract.ts","../src/trace-analyst/store-boundary.ts","../src/analyst/finding-composition.ts","../src/analyst/finding-scope.ts","../src/analyst/types.ts"],"mappings":";;;;;;;;;;;KAsBY,uBAAuB;KAEvB;;;;UAKK;EACf;EACA;EACA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