@tangle-network/agent-eval 0.184.0 → 0.185.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/dist/adapters/http.d.ts +1 -1
- package/dist/analyst/index.d.ts +6 -331
- package/dist/analyst/index.d.ts.map +1 -1
- package/dist/analyst/index.js +7 -6
- package/dist/analyst/index.js.map +1 -1
- package/dist/analyze-runs-CrYhqXop.d.ts +75 -0
- package/dist/analyze-runs-CrYhqXop.d.ts.map +1 -0
- package/dist/{define-agent-eval-RTekxhUE.js → analyze-runs-sTygaDyD.js} +4 -811
- package/dist/analyze-runs-sTygaDyD.js.map +1 -0
- package/dist/{benchmark-command-DlSePljH.js → benchmark-command-kvq7yFY4.js} +9 -47
- package/dist/benchmark-command-kvq7yFY4.js.map +1 -0
- package/dist/benchmarks/index.js +2 -2
- package/dist/campaign/index.js +7 -6
- package/dist/{campaign-D6puiGFO.js → campaign-eJgtRs-W.js} +8 -7
- package/dist/{campaign-D6puiGFO.js.map → campaign-eJgtRs-W.js.map} +1 -1
- package/dist/{campaign-evidence-aWEmfROB.js → campaign-evidence-BsrCmBSE.js} +4 -255
- package/dist/campaign-evidence-BsrCmBSE.js.map +1 -0
- package/dist/cli.js +1 -1
- package/dist/contract/index.d.ts +3 -3
- package/dist/contract/index.js +10 -279
- package/dist/contract/index.js.map +1 -1
- package/dist/{default-registry-DYB4aHVn.d.ts → default-registry-CXv9kHMt.d.ts} +3 -3
- package/dist/{default-registry-DYB4aHVn.d.ts.map → default-registry-CXv9kHMt.d.ts.map} +1 -1
- package/dist/{default-registry-CpLko4jB.js → default-registry-xiHrldW8.js} +3 -2
- package/dist/{default-registry-CpLko4jB.js.map → default-registry-xiHrldW8.js.map} +1 -1
- package/dist/define-agent-eval-D4uumjl3.js +813 -0
- package/dist/define-agent-eval-D4uumjl3.js.map +1 -0
- package/dist/diagnosis/index.d.ts +319 -0
- package/dist/diagnosis/index.d.ts.map +1 -0
- package/dist/diagnosis/index.js +1328 -0
- package/dist/diagnosis/index.js.map +1 -0
- package/dist/{dspy-rlm-engine-Da-l3CpD.js → dspy-rlm-engine-BE9lCzzL.js} +2 -2
- package/dist/{dspy-rlm-engine-Da-l3CpD.js.map → dspy-rlm-engine-BE9lCzzL.js.map} +1 -1
- package/dist/{engine-D1ykrAKR.d.ts → engine-cXUK-WHS.d.ts} +3 -75
- package/dist/engine-cXUK-WHS.d.ts.map +1 -0
- package/dist/equal-terms-Blx9Zk5I.js +25 -0
- package/dist/equal-terms-Blx9Zk5I.js.map +1 -0
- package/dist/experiment/index.js +4 -3
- package/dist/experiment/index.js.map +1 -1
- package/dist/{index-58wex7KV.d.ts → index-BQWfAFeH.d.ts} +3 -3
- package/dist/{index-58wex7KV.d.ts.map → index-BQWfAFeH.d.ts.map} +1 -1
- package/dist/{index-DVrtLO5j.d.ts → index-C8_iU8KL.d.ts} +3 -3
- package/dist/{index-DVrtLO5j.d.ts.map → index-C8_iU8KL.d.ts.map} +1 -1
- package/dist/index.d.ts +5 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +12 -11
- package/dist/index.js.map +1 -1
- package/dist/{kind-factory-DE088Zhv.js → kind-factory-V79Hw0AU.js} +4 -82
- package/dist/kind-factory-V79Hw0AU.js.map +1 -0
- package/dist/{llm-judge-C5wbADA5.js → llm-judge-FWWhEb31.js} +5 -3
- package/dist/{llm-judge-C5wbADA5.js.map → llm-judge-FWWhEb31.js.map} +1 -1
- package/dist/openapi.json +1 -1
- package/dist/otel-spans-CQY1pNiN.js +275 -0
- package/dist/otel-spans-CQY1pNiN.js.map +1 -0
- package/dist/otlp-attributes-BpC_blLF.js +83 -0
- package/dist/otlp-attributes-BpC_blLF.js.map +1 -0
- package/dist/{run-record-BhMVsHR1.js → paired-promotion-decision-ClJh_9nK.js} +2 -215
- package/dist/paired-promotion-decision-ClJh_9nK.js.map +1 -0
- package/dist/prime-bridge-transport-Z3cpKGoV.js +43 -0
- package/dist/prime-bridge-transport-Z3cpKGoV.js.map +1 -0
- package/dist/prime-protocol-CDBcL9NM.d.ts +331 -0
- package/dist/prime-protocol-CDBcL9NM.d.ts.map +1 -0
- package/dist/{prime-protocol-6tZTVsWm.js → prime-protocol-DcAK9pC8.js} +2 -23
- package/dist/prime-protocol-DcAK9pC8.js.map +1 -0
- package/dist/{produced-state-D3uWsY8t.js → produced-state-CmB02tr2.js} +3 -3
- package/dist/{produced-state-D3uWsY8t.js.map → produced-state-CmB02tr2.js.map} +1 -1
- package/dist/{promotion-policy-CD-bUeyR.js → promotion-policy-DdrYWHDh.js} +3 -3
- package/dist/{promotion-policy-CD-bUeyR.js.map → promotion-policy-DdrYWHDh.js.map} +1 -1
- package/dist/rl.js +2 -1
- package/dist/rl.js.map +1 -1
- package/dist/run-record-CNNzWGpB.js +216 -0
- package/dist/run-record-CNNzWGpB.js.map +1 -0
- package/dist/{semantic-concept-judge-5r9hDEBA.js → semantic-concept-judge-Cnt0TWp0.js} +3 -3
- package/dist/{semantic-concept-judge-5r9hDEBA.js.map → semantic-concept-judge-Cnt0TWp0.js.map} +1 -1
- package/dist/{sequential-BfDkCBGo.js → sequential-PgLEqcTJ.js} +2 -2
- package/dist/{sequential-BfDkCBGo.js.map → sequential-PgLEqcTJ.js.map} +1 -1
- package/dist/{skillopt-optimization-method-B2zxoDk0.js → skillopt-optimization-method-FSk8b5FQ.js} +4 -3
- package/dist/{skillopt-optimization-method-B2zxoDk0.js.map → skillopt-optimization-method-FSk8b5FQ.js.map} +1 -1
- package/dist/statistical-heldout-CeWT_W7y.js +256 -0
- package/dist/statistical-heldout-CeWT_W7y.js.map +1 -0
- package/dist/{store-otlp-rU5PFlOB.js → store-otlp-2gYCy-v0.js} +2 -2
- package/dist/{store-otlp-rU5PFlOB.js.map → store-otlp-2gYCy-v0.js.map} +1 -1
- package/dist/{store-tool-spans-zrtftcRe.js → store-tool-spans-B1e6Auc2.js} +4 -3
- package/dist/{store-tool-spans-zrtftcRe.js.map → store-tool-spans-B1e6Auc2.js.map} +1 -1
- package/dist/{store-tool-spans-DwdokbHg.d.ts → store-tool-spans-BrdfPaVh.d.ts} +3 -3
- package/dist/{store-tool-spans-DwdokbHg.d.ts.map → store-tool-spans-BrdfPaVh.d.ts.map} +1 -1
- package/dist/{task-failure-attributes-BOxjfbhr.js → task-failure-attributes-B34TiMBe.js} +2 -2
- package/dist/{task-failure-attributes-BOxjfbhr.js.map → task-failure-attributes-B34TiMBe.js.map} +1 -1
- package/dist/{tool-groups-qHMydbAH.d.ts → tool-groups-eOOgYGaM.d.ts} +2 -2
- package/dist/tool-groups-eOOgYGaM.d.ts.map +1 -0
- package/dist/trace-repair/index.d.ts +1 -1
- package/dist/trace-repair/index.js +2 -1
- package/dist/trace-repair/index.js.map +1 -1
- package/dist/traces.d.ts +2 -2
- package/dist/traces.js +5 -4
- package/dist/traces.js.map +1 -1
- package/docs/diagnosis.md +42 -0
- package/package.json +7 -1
- package/dist/benchmark-command-DlSePljH.js.map +0 -1
- package/dist/campaign-evidence-aWEmfROB.js.map +0 -1
- package/dist/define-agent-eval-RTekxhUE.js.map +0 -1
- package/dist/engine-D1ykrAKR.d.ts.map +0 -1
- package/dist/kind-factory-DE088Zhv.js.map +0 -1
- package/dist/prime-protocol-6tZTVsWm.js.map +0 -1
- package/dist/run-record-BhMVsHR1.js.map +0 -1
- package/dist/tool-groups-qHMydbAH.d.ts.map +0 -1
package/dist/contract/index.js
CHANGED
|
@@ -1,25 +1,24 @@
|
|
|
1
|
-
import { s as ValidationError } from "../errors-Dngq5h35.js";
|
|
2
1
|
import { a as hashCanonical } from "../canonical-BsZVgBhW.js";
|
|
3
2
|
import { r as pairedBootstrap } from "../paired-tests-C8iCsioC.js";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
3
|
+
import { t as decidePairedPromotion } from "../paired-promotion-decision-ClJh_9nK.js";
|
|
4
|
+
import { a as heldoutSignificance } from "../statistical-heldout-CeWT_W7y.js";
|
|
5
|
+
import { n as summarizeExecution, t as analyzeRuns } from "../analyze-runs-sTygaDyD.js";
|
|
7
6
|
import { a as parseRunRecordSafe } from "../run-record-tg_5H2IK.js";
|
|
8
|
-
import { X as runCampaign, Y as runEval, a as transientDispatchFailure, c as compareOptimizationMethods, h as runImprovementLoop, t as llmJudge, z as defaultProductionGate } from "../llm-judge-
|
|
7
|
+
import { X as runCampaign, Y as runEval, a as transientDispatchFailure, c as compareOptimizationMethods, h as runImprovementLoop, t as llmJudge, z as defaultProductionGate } from "../llm-judge-FWWhEb31.js";
|
|
9
8
|
import { i as isModelPriced, n as estimateCost } from "../metrics-DOMpkoeb.js";
|
|
10
9
|
import { i as CostLedger } from "../cost-ledger-_IbkejCF.js";
|
|
10
|
+
import { Z as campaignSplitDigest } from "../campaign-evidence-BsrCmBSE.js";
|
|
11
11
|
import { f as mapConcurrentRange } from "../journal-BuRLm6ho.js";
|
|
12
12
|
import { C as inMemoryCampaignStorage, S as fsCampaignStorage } from "../external-optimizer-subprocess-DMgmqTB6.js";
|
|
13
13
|
import { i as makeProposalFinding } from "../types-C8VBbiw6.js";
|
|
14
|
-
import {
|
|
15
|
-
import { t as buildDefaultAnalystRegistry } from "../default-registry-
|
|
16
|
-
import { LLM_MODEL_ATTR_KEYS, SPAN_KIND_ATTR_KEYS } from "../trace-attributes.js";
|
|
14
|
+
import { n as SelfImproveRunError, r as selfImprove, t as defineAgentEval } from "../define-agent-eval-D4uumjl3.js";
|
|
15
|
+
import { t as buildDefaultAnalystRegistry } from "../default-registry-xiHrldW8.js";
|
|
17
16
|
import { t as extractUsage } from "../extract-usage-BrQ8mCLX.js";
|
|
18
17
|
import { t as createChatClient } from "../chat-client-DqPqWzVV.js";
|
|
19
18
|
import { n as InMemoryOutcomeStore, t as FileSystemOutcomeStore } from "../outcome-store-BXlkwMPR.js";
|
|
20
|
-
import { i as
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
19
|
+
import { a as externalTextOptimizationMethod, c as REFERENCE_EQUIVALENCE_INPUT_LIMITS, d as runReferenceEquivalenceJudge, i as composeGate, l as REFERENCE_EQUIVALENCE_JUDGE_VERSION, n as gepaOptimizationMethod, r as heldOutGate, t as skillOptOptimizationMethod, u as createReferenceEquivalenceJudge } from "../skillopt-optimization-method-FSk8b5FQ.js";
|
|
20
|
+
import { n as paretoPolicy, r as paretoSignificanceGate, t as buildEvidenceVector } from "../promotion-policy-DdrYWHDh.js";
|
|
21
|
+
import { t as fromOtelSpans } from "../otel-spans-CQY1pNiN.js";
|
|
23
22
|
import { createHash } from "node:crypto";
|
|
24
23
|
import { agentCandidateBenchmarkSuiteSchema, agentCandidateBenchmarkTaskSchema, agentCandidateBundleSchema, agentCandidateEvaluationPolicySchema, agentCandidateExperimentSchema, agentImprovementMeasuredComparisonSchema, agentProfileImprovementExperimentSchema, agentProfileImprovementMeasuredComparisonSchema, agentProfileImprovementRunCellSchema, agentProfileImprovementRunReceiptSchema, agentProfileImprovementSuiteInputsSchema, agentProfileImprovementSuiteSchema, agentProfileImprovementTaskSchema, candidateExecutionEvidenceSchema, canonicalCandidateDigest, canonicalCandidateJson, numbersApproximatelyEqual, omitTopLevelDigest } from "@tangle-network/agent-interface";
|
|
25
24
|
import { createReadStream } from "node:fs";
|
|
@@ -3343,274 +3342,6 @@ function fromFeedbackTable(opts) {
|
|
|
3343
3342
|
};
|
|
3344
3343
|
}
|
|
3345
3344
|
//#endregion
|
|
3346
|
-
//#region src/contract/intake/otel-spans.ts
|
|
3347
|
-
/**
|
|
3348
|
-
* # `intake/otel-spans` — OTel `TraceSpanEvent[]` → `RunRecord[]`.
|
|
3349
|
-
*
|
|
3350
|
-
* Turns an existing observability stream into the substrate-canonical
|
|
3351
|
-
* `RunRecord` shape so consumers with logs but no eval discipline can
|
|
3352
|
-
* call `analyzeRuns()` against their production traffic immediately.
|
|
3353
|
-
*
|
|
3354
|
-
* Pivot rule: spans are grouped by `tangle.runId` (the same attribute the
|
|
3355
|
-
* hosted-tier wire format uses) or, when absent, by `traceId`. One group
|
|
3356
|
-
* becomes one `RunRecord`. The root span (no `parentSpanId`) supplies:
|
|
3357
|
-
*
|
|
3358
|
-
* - `runId` (the group key)
|
|
3359
|
-
* - `wallMs` from `endTimeUnixNano - startTimeUnixNano`
|
|
3360
|
-
* - `model` from `gen_ai.request.model` / `llm.model` / `tangle.model`
|
|
3361
|
-
* - task failure class and detail from explicit `tangle.task.*` attributes
|
|
3362
|
-
* - cost from `cost.usd` / `gen_ai.usage.cost_usd` / `tangle.cost.usd`
|
|
3363
|
-
* - token usage from model-call input, output, cache-read, and cache-write
|
|
3364
|
-
* attributes without double-counting aggregate parent spans
|
|
3365
|
-
* - task quality from an explicit `scoreForRun` callback or a designated
|
|
3366
|
-
* evaluation attribute on a root / `EVALUATOR` span; `outcome.raw`
|
|
3367
|
-
* collects every numeric attribute without promoting it to task quality.
|
|
3368
|
-
*
|
|
3369
|
-
* Errored tool, model, and child-agent spans contribute to execution-error
|
|
3370
|
-
* counts. Root process, guardrail, evaluator, propagated parent, and unknown
|
|
3371
|
-
* errors retain separate counters. Only one failed root can set
|
|
3372
|
-
* `RunRecord.terminalOutcome` and `RunRecord.terminalFailureReason`; a child
|
|
3373
|
-
* error cannot become a task failure.
|
|
3374
|
-
*/
|
|
3375
|
-
const TASK_SCORE_ATTR_KEYS = [
|
|
3376
|
-
"gen_ai.evaluation.score.value",
|
|
3377
|
-
"tangle.task.score",
|
|
3378
|
-
"eval.score",
|
|
3379
|
-
"tangle.score"
|
|
3380
|
-
];
|
|
3381
|
-
const MODEL_KEYS = [
|
|
3382
|
-
"tangle.model",
|
|
3383
|
-
...LLM_MODEL_ATTR_KEYS,
|
|
3384
|
-
"model"
|
|
3385
|
-
];
|
|
3386
|
-
const PROMPT_HASH_KEYS = ["tangle.prompt_hash", "prompt.hash"];
|
|
3387
|
-
const CONFIG_HASH_KEYS = ["tangle.config_hash", "config.hash"];
|
|
3388
|
-
function fromOtelSpans(opts) {
|
|
3389
|
-
const { spans, defaultSplit = "holdout", experimentId = "otel-corpus" } = opts;
|
|
3390
|
-
const grouped = groupSpans(spans);
|
|
3391
|
-
const runs = [];
|
|
3392
|
-
for (const [groupKey, groupSpans] of grouped) {
|
|
3393
|
-
const root = findRoot(groupSpans);
|
|
3394
|
-
if (!root) continue;
|
|
3395
|
-
const measurements = summarizeExecutionMeasurements(groupSpans.map((span) => ({
|
|
3396
|
-
id: span.spanId,
|
|
3397
|
-
...span.parentSpanId ? { parentId: span.parentSpanId } : {},
|
|
3398
|
-
attributes: span.attributes,
|
|
3399
|
-
modelCall: isExplicitModelCall(span),
|
|
3400
|
-
aggregate: isExplicitAggregate(span)
|
|
3401
|
-
})));
|
|
3402
|
-
const callSpanIds = new Set(measurements.callSpanIds);
|
|
3403
|
-
const callSpans = groupSpans.filter((span) => callSpanIds.has(span.spanId));
|
|
3404
|
-
const wallMs = unixNanoDurationMs(root.startTimeUnixNano, root.endTimeUnixNano);
|
|
3405
|
-
const model = readAttrString(callSpans, MODEL_KEYS) ?? readAttrString(groupSpans, MODEL_KEYS) ?? "unknown@unknown";
|
|
3406
|
-
const capturedCost = (measurements.cost.complete ? measurements.cost.value : void 0) ?? measurements.aggregate?.costUsd;
|
|
3407
|
-
const costUsd = capturedCost ?? null;
|
|
3408
|
-
const scenarioId = readConsistentScenarioId(groupKey, groupSpans) ?? groupKey;
|
|
3409
|
-
const promptHash = readAttrString(groupSpans, PROMPT_HASH_KEYS) ?? "sha256:unknown";
|
|
3410
|
-
const configHash = readAttrString(groupSpans, CONFIG_HASH_KEYS) ?? "sha256:unknown";
|
|
3411
|
-
const score = resolveTaskScore(groupKey, groupSpans, opts.scoreForRun);
|
|
3412
|
-
const taskFailure = readTaskFailureLabels(groupSpans.filter((span) => !span.parentSpanId && isTerminalRootCandidate(span)), `fromOtelSpans: run '${groupKey}'`);
|
|
3413
|
-
const rawNumeric = collectNumericAttrs(groupSpans);
|
|
3414
|
-
const errorSummary = summarizeTraceErrors(groupSpans.map((span) => ({
|
|
3415
|
-
id: spanIdentity(span),
|
|
3416
|
-
...span.parentSpanId ? { parentId: parentIdentity(span) } : {},
|
|
3417
|
-
role: errorRoleForSpan(span),
|
|
3418
|
-
error: span.status?.code === "ERROR",
|
|
3419
|
-
processRoot: !span.parentSpanId && isTerminalRootCandidate(span)
|
|
3420
|
-
})));
|
|
3421
|
-
rawNumeric.error_span_count = errorSummary.total;
|
|
3422
|
-
rawNumeric.execution_error_count = errorSummary.execution;
|
|
3423
|
-
rawNumeric.process_error_count = errorSummary.process;
|
|
3424
|
-
rawNumeric.guardrail_error_count = errorSummary.guardrail;
|
|
3425
|
-
rawNumeric.judge_error_count = errorSummary.evaluation;
|
|
3426
|
-
rawNumeric.propagated_error_count = errorSummary.propagated;
|
|
3427
|
-
rawNumeric.unclassified_error_count = errorSummary.unclassified;
|
|
3428
|
-
rawNumeric.llm_span_count = measurements.modelCallCount;
|
|
3429
|
-
if (measurements.cost.value !== void 0 && !measurements.cost.complete) rawNumeric.partial_observed_cost_usd = measurements.cost.value;
|
|
3430
|
-
recordAggregateMeasurements(rawNumeric, measurements.aggregate);
|
|
3431
|
-
const judgeScores = score !== void 0 ? {
|
|
3432
|
-
perJudge: { "otel-derived": { score } },
|
|
3433
|
-
perDimMean: { score },
|
|
3434
|
-
composite: score
|
|
3435
|
-
} : void 0;
|
|
3436
|
-
const terminalOutcome = terminalOutcomeFromRoots(groupSpans);
|
|
3437
|
-
const failedRoot = terminalOutcome === "failed" ? groupSpans.find((span) => !span.parentSpanId && isTerminalRootCandidate(span) && span.status?.code === "ERROR") : void 0;
|
|
3438
|
-
const outcome = {
|
|
3439
|
-
raw: rawNumeric,
|
|
3440
|
-
...judgeScores ? { judgeScores } : {}
|
|
3441
|
-
};
|
|
3442
|
-
if (score !== void 0) if (defaultSplit === "holdout") outcome.holdoutScore = score;
|
|
3443
|
-
else outcome.searchScore = score;
|
|
3444
|
-
runs.push({
|
|
3445
|
-
runId: groupKey,
|
|
3446
|
-
experimentId,
|
|
3447
|
-
candidateId: root.attributes["tangle.candidateId"] ?? "otel-default",
|
|
3448
|
-
seed: 0,
|
|
3449
|
-
model,
|
|
3450
|
-
promptHash,
|
|
3451
|
-
configHash,
|
|
3452
|
-
commitSha: root.attributes["tangle.commit_sha"] ?? "unknown",
|
|
3453
|
-
wallMs,
|
|
3454
|
-
costUsd,
|
|
3455
|
-
costProvenance: capturedCost === void 0 ? {
|
|
3456
|
-
kind: "uncaptured",
|
|
3457
|
-
usd: null
|
|
3458
|
-
} : {
|
|
3459
|
-
kind: "observed",
|
|
3460
|
-
usd: capturedCost
|
|
3461
|
-
},
|
|
3462
|
-
tokenUsage: measurements.tokenUsage,
|
|
3463
|
-
terminalOutcome,
|
|
3464
|
-
...failedRoot ? { terminalFailureReason: failedRoot.status?.message ?? failedRoot.name } : {},
|
|
3465
|
-
outcome,
|
|
3466
|
-
...taskFailure,
|
|
3467
|
-
splitTag: defaultSplit,
|
|
3468
|
-
scenarioId
|
|
3469
|
-
});
|
|
3470
|
-
}
|
|
3471
|
-
return runs;
|
|
3472
|
-
}
|
|
3473
|
-
function terminalOutcomeFromRoots(spans) {
|
|
3474
|
-
const roots = spans.filter((span) => !span.parentSpanId && isTerminalRootCandidate(span));
|
|
3475
|
-
if (roots.length !== 1) return "unknown";
|
|
3476
|
-
if (roots[0].status?.code === "OK") return "succeeded";
|
|
3477
|
-
if (roots[0].status?.code === "ERROR") return "failed";
|
|
3478
|
-
return "unknown";
|
|
3479
|
-
}
|
|
3480
|
-
function isTerminalRootCandidate(span) {
|
|
3481
|
-
const role = errorRoleForSpan(span);
|
|
3482
|
-
if (role === "LLM" || role === "TOOL" || role === "GUARDRAIL" || role === "EVALUATOR") return false;
|
|
3483
|
-
return true;
|
|
3484
|
-
}
|
|
3485
|
-
function readSpanKind(span) {
|
|
3486
|
-
return readAttrString([span], [...SPAN_KIND_ATTR_KEYS, "span.kind"])?.toUpperCase();
|
|
3487
|
-
}
|
|
3488
|
-
function errorRoleForSpan(span) {
|
|
3489
|
-
return classifyOtlpSpanRole({
|
|
3490
|
-
kind: readSpanKind(span),
|
|
3491
|
-
name: span.name,
|
|
3492
|
-
attributes: span.attributes
|
|
3493
|
-
});
|
|
3494
|
-
}
|
|
3495
|
-
function spanIdentity(span) {
|
|
3496
|
-
return `${span.traceId}:${span.spanId}`;
|
|
3497
|
-
}
|
|
3498
|
-
function parentIdentity(span) {
|
|
3499
|
-
return `${span.traceId}:${span.parentSpanId}`;
|
|
3500
|
-
}
|
|
3501
|
-
function isExplicitModelCall(span) {
|
|
3502
|
-
return isOtlpModelCall({
|
|
3503
|
-
kind: readSpanKind(span),
|
|
3504
|
-
name: span.name,
|
|
3505
|
-
attributes: span.attributes
|
|
3506
|
-
});
|
|
3507
|
-
}
|
|
3508
|
-
function isExplicitAggregate(span) {
|
|
3509
|
-
const kind = readSpanKind(span);
|
|
3510
|
-
return kind !== void 0 && kind !== "LLM";
|
|
3511
|
-
}
|
|
3512
|
-
function groupSpans(spans) {
|
|
3513
|
-
const m = /* @__PURE__ */ new Map();
|
|
3514
|
-
for (const span of spans) {
|
|
3515
|
-
const key = span["tangle.runId"] ?? span.traceId;
|
|
3516
|
-
const list = m.get(key) ?? [];
|
|
3517
|
-
list.push(span);
|
|
3518
|
-
m.set(key, list);
|
|
3519
|
-
}
|
|
3520
|
-
return m;
|
|
3521
|
-
}
|
|
3522
|
-
function findRoot(group) {
|
|
3523
|
-
const structuralRoots = group.filter((span) => !span.parentSpanId);
|
|
3524
|
-
const terminalRoots = structuralRoots.filter(isTerminalRootCandidate);
|
|
3525
|
-
return orderSpans(terminalRoots.length > 0 ? terminalRoots : structuralRoots.length > 0 ? structuralRoots : group)[0];
|
|
3526
|
-
}
|
|
3527
|
-
function readAttrString(spans, keys) {
|
|
3528
|
-
for (const span of spans) for (const key of keys) {
|
|
3529
|
-
const v = span.attributes[key];
|
|
3530
|
-
if (typeof v === "string" && v.length > 0) return v;
|
|
3531
|
-
}
|
|
3532
|
-
}
|
|
3533
|
-
function readConsistentScenarioId(runId, spans) {
|
|
3534
|
-
const values = /* @__PURE__ */ new Set();
|
|
3535
|
-
for (const span of spans) {
|
|
3536
|
-
const topLevel = span["tangle.scenarioId"];
|
|
3537
|
-
if (typeof topLevel === "string" && topLevel.length > 0) values.add(topLevel);
|
|
3538
|
-
const attribute = span.attributes["tangle.scenarioId"];
|
|
3539
|
-
if (typeof attribute === "string" && attribute.length > 0) values.add(attribute);
|
|
3540
|
-
}
|
|
3541
|
-
if (values.size > 1) throw new ValidationError(`fromOtelSpans: conflicting scenario ids for run '${runId}': ${[...values].sort().join(", ")}`);
|
|
3542
|
-
return values.values().next().value;
|
|
3543
|
-
}
|
|
3544
|
-
function resolveTaskScore(runId, spans, scoreForRun) {
|
|
3545
|
-
const orderedSpans = orderSpans(spans);
|
|
3546
|
-
const sources = [];
|
|
3547
|
-
if (scoreForRun) {
|
|
3548
|
-
const supplied = scoreForRun(runId, orderedSpans);
|
|
3549
|
-
if (supplied !== void 0) {
|
|
3550
|
-
if (typeof supplied !== "number" || !Number.isFinite(supplied)) throw new ValidationError(`fromOtelSpans: scoreForRun returned a non-finite number for run '${runId}'`);
|
|
3551
|
-
sources.push({
|
|
3552
|
-
label: "scoreForRun",
|
|
3553
|
-
value: supplied
|
|
3554
|
-
});
|
|
3555
|
-
}
|
|
3556
|
-
}
|
|
3557
|
-
for (const span of orderedSpans) {
|
|
3558
|
-
const role = errorRoleForSpan(span);
|
|
3559
|
-
if (span.parentSpanId && role !== "EVALUATOR") continue;
|
|
3560
|
-
if (role === "EVALUATOR" && span.status?.code === "ERROR") continue;
|
|
3561
|
-
for (const key of TASK_SCORE_ATTR_KEYS) {
|
|
3562
|
-
if (!Object.hasOwn(span.attributes, key)) continue;
|
|
3563
|
-
sources.push({
|
|
3564
|
-
label: `span '${span.spanId}' attribute '${key}'`,
|
|
3565
|
-
value: parseTaskScoreAttribute(runId, span.spanId, key, span.attributes[key])
|
|
3566
|
-
});
|
|
3567
|
-
}
|
|
3568
|
-
}
|
|
3569
|
-
if (sources.length === 0) return void 0;
|
|
3570
|
-
sources.sort((left, right) => left.label.localeCompare(right.label));
|
|
3571
|
-
const score = sources[0].value;
|
|
3572
|
-
if (sources.some((source) => source.value !== score)) throw new ValidationError(`fromOtelSpans: conflicting task-quality scores for run '${runId}': ${sources.map((source) => `${source.label}=${source.value}`).join(", ")}`);
|
|
3573
|
-
return score;
|
|
3574
|
-
}
|
|
3575
|
-
function parseTaskScoreAttribute(runId, spanId, key, value) {
|
|
3576
|
-
const source = `span '${spanId}' attribute '${key}'`;
|
|
3577
|
-
if (typeof value === "string") {
|
|
3578
|
-
if (value.trim().length === 0) throw new ValidationError(`fromOtelSpans: ${source} is blank for run '${runId}'; task quality must be finite`);
|
|
3579
|
-
const parsed = Number(value);
|
|
3580
|
-
if (Number.isFinite(parsed)) return parsed;
|
|
3581
|
-
} else if (typeof value === "number" && Number.isFinite(value)) return value;
|
|
3582
|
-
throw new ValidationError(`fromOtelSpans: ${source} is not a finite task-quality score for run '${runId}'`);
|
|
3583
|
-
}
|
|
3584
|
-
function orderSpans(spans) {
|
|
3585
|
-
return [...spans].sort((left, right) => compareUnixNano(left.startTimeUnixNano, right.startTimeUnixNano) || left.spanId.localeCompare(right.spanId));
|
|
3586
|
-
}
|
|
3587
|
-
function parseUnixNano(value) {
|
|
3588
|
-
try {
|
|
3589
|
-
return BigInt(value);
|
|
3590
|
-
} catch {
|
|
3591
|
-
throw new ValidationError(`fromOtelSpans: invalid Unix nanosecond timestamp '${value}'`);
|
|
3592
|
-
}
|
|
3593
|
-
}
|
|
3594
|
-
function compareUnixNano(left, right) {
|
|
3595
|
-
const leftValue = parseUnixNano(left);
|
|
3596
|
-
const rightValue = parseUnixNano(right);
|
|
3597
|
-
return leftValue < rightValue ? -1 : leftValue > rightValue ? 1 : 0;
|
|
3598
|
-
}
|
|
3599
|
-
function unixNanoDurationMs(start, end) {
|
|
3600
|
-
const delta = parseUnixNano(end) - parseUnixNano(start);
|
|
3601
|
-
if (delta <= 0n) return 0;
|
|
3602
|
-
const wholeMs = delta / 1000000n;
|
|
3603
|
-
const fractionalMs = delta % 1000000n;
|
|
3604
|
-
const value = Number(wholeMs) + Number(fractionalMs) / 1e6;
|
|
3605
|
-
if (!Number.isSafeInteger(Number(wholeMs))) throw new ValidationError("fromOtelSpans: span duration exceeds the safe millisecond range");
|
|
3606
|
-
return value;
|
|
3607
|
-
}
|
|
3608
|
-
function collectNumericAttrs(spans) {
|
|
3609
|
-
const raw = {};
|
|
3610
|
-
for (const span of spans) for (const [k, v] of Object.entries(span.attributes)) if (typeof v === "number" && Number.isFinite(v)) raw[k] = v;
|
|
3611
|
-
return raw;
|
|
3612
|
-
}
|
|
3613
|
-
//#endregion
|
|
3614
3345
|
export { FileSystemOutcomeStore, InMemoryOutcomeStore, REFERENCE_EQUIVALENCE_INPUT_LIMITS, REFERENCE_EQUIVALENCE_JUDGE_VERSION, SelfImproveRunError, analyzeRuns, buildDefaultAnalystRegistry, buildEvidenceVector, campaignSplitDigest, compareOptimizationMethods, composeGate, createChatClient, createReferenceEquivalenceJudge, defaultProductionGate, defineAgentEval, diffGenerations, diffRunBaselineToWinner, diffRuns, evalReportingSuite, evaluatePairedMeasurements, externalTextOptimizationMethod, fromClaudeCodeSession, fromCodexSession, fromFeedbackTable, fromKimiCodeSession, fromOpenCodeSession, fromOtelSpans, fromPiSession, fromRunRecordDir, fsCampaignStorage, gepaOptimizationMethod, heldOutGate, inMemoryCampaignStorage, llmJudge, makeProposalFinding, measuredComparisonFromAgentProfileImprovementExperiment, measuredComparisonFromCandidateExperiment, observeCodeAgentSession, observeCodeAgentStore, paretoPolicy, paretoSignificanceGate, parseAgentTrace, parseCodeAgentJsonl, parseCodeAgentJsonlFile, partitionRunsByAuthoringModel, runAgentProfileImprovementExperiment, runCampaign, runCandidateExperiment, runEval, runImprovementLoop, runReferenceEquivalenceJudge, sealAgentProfileImprovementExperiment, sealAgentProfileImprovementSuite, sealAgentProfileImprovementTask, sealCandidateBenchmarkSuite, sealCandidateBenchmarkTask, sealCandidateExperiment, selfImprove, skillOptOptimizationMethod, streamCodeAgentJsonlFile, summarizeExecution, transientDispatchFailure, verifyAgentProfileImprovementExperimentComparison, verifyCandidateExperiment, verifyCandidateExperimentComparison };
|
|
3615
3346
|
|
|
3616
3347
|
//# sourceMappingURL=index.js.map
|