agent-inspect 6.12.1 → 6.13.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 +20 -0
- package/README.md +1 -1
- package/docs/KNOWN-ISSUES.md +1 -0
- package/package.json +2 -2
- package/packages/cli/dist/{chunk-XTAA733P.mjs → chunk-QOKTMZAY.mjs} +321 -55
- package/packages/cli/dist/chunk-QOKTMZAY.mjs.map +1 -0
- package/packages/cli/dist/index.cjs +350 -70
- package/packages/cli/dist/index.cjs.map +1 -1
- package/packages/cli/dist/index.mjs +4 -4
- package/packages/cli/dist/index.mjs.map +1 -1
- package/packages/cli/dist/{src-G7PM24W2.mjs → src-MU4PS6GO.mjs} +3 -3
- package/packages/cli/dist/{src-G7PM24W2.mjs.map → src-MU4PS6GO.mjs.map} +1 -1
- package/packages/core/dist/advanced.cjs +295 -30
- package/packages/core/dist/advanced.cjs.map +1 -1
- package/packages/core/dist/advanced.d.cts +1 -1
- package/packages/core/dist/advanced.d.ts +1 -1
- package/packages/core/dist/advanced.mjs +1 -1
- package/packages/core/dist/checks.cjs +368 -32
- package/packages/core/dist/checks.cjs.map +1 -1
- package/packages/core/dist/checks.d.cts +58 -4
- package/packages/core/dist/checks.d.ts +58 -4
- package/packages/core/dist/checks.mjs +1 -1
- package/packages/core/dist/{chunk-QT6CQ2XA.mjs → chunk-BS2QCAJX.mjs} +367 -35
- package/packages/core/dist/chunk-BS2QCAJX.mjs.map +1 -0
- package/packages/core/dist/{index-BO7l0iAe.d.ts → index-Bu_vOjql.d.ts} +72 -1
- package/packages/core/dist/{index-mdFcxSOR.d.cts → index-CmXMS-MF.d.cts} +72 -1
- package/packages/cli/dist/chunk-XTAA733P.mjs.map +0 -1
- package/packages/core/dist/chunk-QT6CQ2XA.mjs.map +0 -1
|
@@ -697,12 +697,12 @@ function persistedInspectEventToTraceEvents(event) {
|
|
|
697
697
|
if (!isPersistedInspectEvent(event)) {
|
|
698
698
|
throw new Error("Invalid PersistedInspectEvent: failed isPersistedInspectEvent");
|
|
699
699
|
}
|
|
700
|
-
const
|
|
701
|
-
if (
|
|
702
|
-
if (
|
|
703
|
-
if (
|
|
704
|
-
if (
|
|
705
|
-
if (
|
|
700
|
+
const legacyEvent2 = event.attributes?.legacyEvent;
|
|
701
|
+
if (legacyEvent2 === "run_started") return [fromLegacyRunStarted(event)];
|
|
702
|
+
if (legacyEvent2 === "run_completed") return [fromLegacyRunCompleted(event)];
|
|
703
|
+
if (legacyEvent2 === "step_started") return [fromLegacyStepStarted(event)];
|
|
704
|
+
if (legacyEvent2 === "step_completed") return [fromLegacyStepCompleted(event)];
|
|
705
|
+
if (legacyEvent2 === "outcome_observed") return [fromLegacyOutcomeObserved(event)];
|
|
706
706
|
if (event.kind === "RUN") {
|
|
707
707
|
return fromNativeRun(event);
|
|
708
708
|
}
|
|
@@ -7458,6 +7458,265 @@ async function resolveSuiteCaseTrace(suiteCase, options) {
|
|
|
7458
7458
|
};
|
|
7459
7459
|
}
|
|
7460
7460
|
|
|
7461
|
+
// packages/core/src/checks/logical-events.ts
|
|
7462
|
+
function isRecord8(value) {
|
|
7463
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
7464
|
+
}
|
|
7465
|
+
function legacyEvent(event) {
|
|
7466
|
+
const value = event.attributes?.legacyEvent;
|
|
7467
|
+
return typeof value === "string" ? value : void 0;
|
|
7468
|
+
}
|
|
7469
|
+
function stepIdOf(event) {
|
|
7470
|
+
const value = event.attributes?.stepId;
|
|
7471
|
+
if (typeof value === "string" && value.trim() !== "") return value;
|
|
7472
|
+
return void 0;
|
|
7473
|
+
}
|
|
7474
|
+
function cloneEvent(event) {
|
|
7475
|
+
return {
|
|
7476
|
+
...event,
|
|
7477
|
+
...event.attributes !== void 0 ? { attributes: { ...event.attributes } } : {},
|
|
7478
|
+
...event.error !== void 0 ? { error: { ...event.error } } : {},
|
|
7479
|
+
...event.tokenUsage !== void 0 ? { tokenUsage: { ...event.tokenUsage } } : {},
|
|
7480
|
+
...event.source !== void 0 ? { source: { ...event.source } } : {}
|
|
7481
|
+
};
|
|
7482
|
+
}
|
|
7483
|
+
function mergeAttributes(start, complete) {
|
|
7484
|
+
const merged = {
|
|
7485
|
+
...isRecord8(complete.attributes) ? complete.attributes : {},
|
|
7486
|
+
...isRecord8(start.attributes) ? start.attributes : {}
|
|
7487
|
+
};
|
|
7488
|
+
merged.legacyEvent = start.attributes?.legacyEvent ?? complete.attributes?.legacyEvent;
|
|
7489
|
+
merged.legacyCompleteEvent = complete.attributes?.legacyEvent;
|
|
7490
|
+
if (complete.attributes?.errorStack !== void 0) {
|
|
7491
|
+
merged.errorStack = complete.attributes.errorStack;
|
|
7492
|
+
}
|
|
7493
|
+
return Object.keys(merged).length > 0 ? merged : void 0;
|
|
7494
|
+
}
|
|
7495
|
+
function pairStartComplete(start, complete) {
|
|
7496
|
+
const attributes = mergeAttributes(start, complete);
|
|
7497
|
+
const paired = {
|
|
7498
|
+
...cloneEvent(start),
|
|
7499
|
+
status: complete.status,
|
|
7500
|
+
timestamp: complete.timestamp ?? start.timestamp,
|
|
7501
|
+
...complete.endedAt !== void 0 ? { endedAt: complete.endedAt } : {},
|
|
7502
|
+
...complete.durationMs !== void 0 ? { durationMs: complete.durationMs } : {},
|
|
7503
|
+
...complete.error !== void 0 ? { error: { ...complete.error } } : {},
|
|
7504
|
+
...complete.tokenUsage !== void 0 && start.tokenUsage === void 0 ? { tokenUsage: { ...complete.tokenUsage } } : {},
|
|
7505
|
+
...attributes !== void 0 ? { attributes } : {}
|
|
7506
|
+
};
|
|
7507
|
+
return {
|
|
7508
|
+
...paired,
|
|
7509
|
+
sourceEventIds: Object.freeze([start.eventId, complete.eventId]),
|
|
7510
|
+
projection: {
|
|
7511
|
+
paired: true,
|
|
7512
|
+
absorbedEventIds: Object.freeze([complete.eventId]),
|
|
7513
|
+
parentNormalized: false,
|
|
7514
|
+
...start.parentId !== void 0 ? { originalParentId: start.parentId } : {}
|
|
7515
|
+
}
|
|
7516
|
+
};
|
|
7517
|
+
}
|
|
7518
|
+
function asLogical(event, extras) {
|
|
7519
|
+
return {
|
|
7520
|
+
...cloneEvent(event),
|
|
7521
|
+
sourceEventIds: Object.freeze([event.eventId]),
|
|
7522
|
+
projection: {
|
|
7523
|
+
paired: false,
|
|
7524
|
+
absorbedEventIds: Object.freeze([]),
|
|
7525
|
+
parentNormalized: extras?.parentNormalized === true,
|
|
7526
|
+
...{}
|
|
7527
|
+
}
|
|
7528
|
+
};
|
|
7529
|
+
}
|
|
7530
|
+
function projectLogicalEvents(events) {
|
|
7531
|
+
const diagnostics = [];
|
|
7532
|
+
const byRun = /* @__PURE__ */ new Map();
|
|
7533
|
+
for (const event of events) {
|
|
7534
|
+
const list = byRun.get(event.runId) ?? [];
|
|
7535
|
+
list.push(event);
|
|
7536
|
+
byRun.set(event.runId, list);
|
|
7537
|
+
}
|
|
7538
|
+
const absorbedIds = /* @__PURE__ */ new Set();
|
|
7539
|
+
const logicalByRawId = /* @__PURE__ */ new Map();
|
|
7540
|
+
const stepIdToLogicalId = /* @__PURE__ */ new Map();
|
|
7541
|
+
const logical = [];
|
|
7542
|
+
const orderedRuns = [...byRun.keys()].sort((a, b) => a.localeCompare(b));
|
|
7543
|
+
for (const runId of orderedRuns) {
|
|
7544
|
+
const runEvents = byRun.get(runId) ?? [];
|
|
7545
|
+
const starts = [];
|
|
7546
|
+
const completes = [];
|
|
7547
|
+
const others = [];
|
|
7548
|
+
for (const event of runEvents) {
|
|
7549
|
+
const legacy = legacyEvent(event);
|
|
7550
|
+
if (legacy === "step_started" || legacy === "run_started" && event.status === "running") {
|
|
7551
|
+
starts.push(event);
|
|
7552
|
+
} else if (legacy === "step_completed" || legacy === "run_completed") {
|
|
7553
|
+
completes.push(event);
|
|
7554
|
+
} else {
|
|
7555
|
+
others.push(event);
|
|
7556
|
+
}
|
|
7557
|
+
}
|
|
7558
|
+
const usedCompletes = /* @__PURE__ */ new Set();
|
|
7559
|
+
for (const start of starts) {
|
|
7560
|
+
const stepId = stepIdOf(start);
|
|
7561
|
+
let match;
|
|
7562
|
+
if (legacyEvent(start) === "run_started") {
|
|
7563
|
+
const candidates = completes.filter(
|
|
7564
|
+
(c) => !usedCompletes.has(c.eventId) && legacyEvent(c) === "run_completed"
|
|
7565
|
+
);
|
|
7566
|
+
if (candidates.length > 1) {
|
|
7567
|
+
diagnostics.push({
|
|
7568
|
+
code: "AI_LOGICAL_PAIR_AMBIGUOUS",
|
|
7569
|
+
message: `Multiple run_completed rows for run ${runId}; using first by eventId.`,
|
|
7570
|
+
eventIds: candidates.map((c) => c.eventId)
|
|
7571
|
+
});
|
|
7572
|
+
candidates.sort((a, b) => a.eventId.localeCompare(b.eventId));
|
|
7573
|
+
}
|
|
7574
|
+
match = candidates[0];
|
|
7575
|
+
} else if (stepId) {
|
|
7576
|
+
const candidates = completes.filter(
|
|
7577
|
+
(c) => !usedCompletes.has(c.eventId) && legacyEvent(c) === "step_completed" && stepIdOf(c) === stepId
|
|
7578
|
+
);
|
|
7579
|
+
if (candidates.length > 1) {
|
|
7580
|
+
diagnostics.push({
|
|
7581
|
+
code: "AI_LOGICAL_PAIR_AMBIGUOUS",
|
|
7582
|
+
message: `Multiple step_completed rows for stepId ${stepId}; using first by eventId.`,
|
|
7583
|
+
eventIds: candidates.map((c) => c.eventId)
|
|
7584
|
+
});
|
|
7585
|
+
candidates.sort((a, b) => a.eventId.localeCompare(b.eventId));
|
|
7586
|
+
}
|
|
7587
|
+
match = candidates[0];
|
|
7588
|
+
}
|
|
7589
|
+
if (match) {
|
|
7590
|
+
usedCompletes.add(match.eventId);
|
|
7591
|
+
absorbedIds.add(match.eventId);
|
|
7592
|
+
const paired = pairStartComplete(start, match);
|
|
7593
|
+
logical.push(paired);
|
|
7594
|
+
logicalByRawId.set(start.eventId, paired);
|
|
7595
|
+
logicalByRawId.set(match.eventId, paired);
|
|
7596
|
+
if (stepId) stepIdToLogicalId.set(`${runId}:${stepId}`, paired.eventId);
|
|
7597
|
+
} else {
|
|
7598
|
+
diagnostics.push({
|
|
7599
|
+
code: "AI_LOGICAL_PAIR_UNMATCHED_START",
|
|
7600
|
+
message: `No matching complete for start ${start.eventId}.`,
|
|
7601
|
+
eventIds: [start.eventId]
|
|
7602
|
+
});
|
|
7603
|
+
const alone = asLogical(start);
|
|
7604
|
+
logical.push(alone);
|
|
7605
|
+
logicalByRawId.set(start.eventId, alone);
|
|
7606
|
+
if (stepId) stepIdToLogicalId.set(`${runId}:${stepId}`, alone.eventId);
|
|
7607
|
+
}
|
|
7608
|
+
}
|
|
7609
|
+
for (const complete of completes) {
|
|
7610
|
+
if (usedCompletes.has(complete.eventId)) continue;
|
|
7611
|
+
diagnostics.push({
|
|
7612
|
+
code: "AI_LOGICAL_PAIR_UNMATCHED_COMPLETE",
|
|
7613
|
+
message: `No matching start for complete ${complete.eventId}.`,
|
|
7614
|
+
eventIds: [complete.eventId]
|
|
7615
|
+
});
|
|
7616
|
+
const alone = asLogical(complete);
|
|
7617
|
+
logical.push(alone);
|
|
7618
|
+
logicalByRawId.set(complete.eventId, alone);
|
|
7619
|
+
const stepId = stepIdOf(complete);
|
|
7620
|
+
if (stepId && !stepIdToLogicalId.has(`${runId}:${stepId}`)) {
|
|
7621
|
+
stepIdToLogicalId.set(`${runId}:${stepId}`, alone.eventId);
|
|
7622
|
+
}
|
|
7623
|
+
}
|
|
7624
|
+
for (const event of others) {
|
|
7625
|
+
const alone = asLogical(event);
|
|
7626
|
+
logical.push(alone);
|
|
7627
|
+
logicalByRawId.set(event.eventId, alone);
|
|
7628
|
+
const stepId = stepIdOf(event);
|
|
7629
|
+
if (stepId && !stepIdToLogicalId.has(`${runId}:${stepId}`)) {
|
|
7630
|
+
stepIdToLogicalId.set(`${runId}:${stepId}`, alone.eventId);
|
|
7631
|
+
}
|
|
7632
|
+
}
|
|
7633
|
+
}
|
|
7634
|
+
const logicalById = new Map(logical.map((e) => [e.eventId, e]));
|
|
7635
|
+
const normalized = [];
|
|
7636
|
+
for (const event of logical) {
|
|
7637
|
+
const originalParentId = event.parentId;
|
|
7638
|
+
if (!originalParentId) {
|
|
7639
|
+
normalized.push(event);
|
|
7640
|
+
continue;
|
|
7641
|
+
}
|
|
7642
|
+
let nextParent = originalParentId;
|
|
7643
|
+
let remapped = false;
|
|
7644
|
+
const viaAbsorbed = logicalByRawId.get(originalParentId);
|
|
7645
|
+
if (viaAbsorbed && viaAbsorbed.eventId !== originalParentId) {
|
|
7646
|
+
nextParent = viaAbsorbed.eventId;
|
|
7647
|
+
remapped = true;
|
|
7648
|
+
} else if (!logicalById.has(originalParentId)) {
|
|
7649
|
+
const viaStep = stepIdToLogicalId.get(`${event.runId}:${originalParentId}`);
|
|
7650
|
+
if (viaStep) {
|
|
7651
|
+
nextParent = viaStep;
|
|
7652
|
+
remapped = true;
|
|
7653
|
+
}
|
|
7654
|
+
}
|
|
7655
|
+
if (!remapped) {
|
|
7656
|
+
if (!logicalById.has(originalParentId) && !logicalByRawId.has(originalParentId)) {
|
|
7657
|
+
const mapping = event.attributes?.parentMapping;
|
|
7658
|
+
const unresolved = mapping === "unresolved" || event.attributes?.parentUnresolved === true || event.attributes?.unresolvedParent === true || // LangGraph/framework scaffolding sentinel labels are not event ids.
|
|
7659
|
+
/^LangGraph$/i.test(originalParentId) || originalParentId.startsWith("unresolved:");
|
|
7660
|
+
if (!unresolved) {
|
|
7661
|
+
diagnostics.push({
|
|
7662
|
+
code: "AI_LOGICAL_PARENT_UNRESOLVED",
|
|
7663
|
+
message: `Parent ${originalParentId} unresolved for ${event.eventId}.`,
|
|
7664
|
+
eventIds: [event.eventId]
|
|
7665
|
+
});
|
|
7666
|
+
}
|
|
7667
|
+
}
|
|
7668
|
+
normalized.push(event);
|
|
7669
|
+
continue;
|
|
7670
|
+
}
|
|
7671
|
+
diagnostics.push({
|
|
7672
|
+
code: "AI_LOGICAL_PARENT_REMAPPED",
|
|
7673
|
+
message: `Remapped parent ${originalParentId} \u2192 ${nextParent} for ${event.eventId}.`,
|
|
7674
|
+
eventIds: [event.eventId]
|
|
7675
|
+
});
|
|
7676
|
+
normalized.push({
|
|
7677
|
+
...event,
|
|
7678
|
+
parentId: nextParent,
|
|
7679
|
+
projection: {
|
|
7680
|
+
...event.projection,
|
|
7681
|
+
parentNormalized: true,
|
|
7682
|
+
originalParentId
|
|
7683
|
+
}
|
|
7684
|
+
});
|
|
7685
|
+
}
|
|
7686
|
+
const rawIndex = new Map(events.map((e, i) => [e.eventId, i]));
|
|
7687
|
+
normalized.sort((a, b) => {
|
|
7688
|
+
const ai = rawIndex.get(a.sourceEventIds[0]) ?? 0;
|
|
7689
|
+
const bi = rawIndex.get(b.sourceEventIds[0]) ?? 0;
|
|
7690
|
+
return ai - bi || a.eventId.localeCompare(b.eventId);
|
|
7691
|
+
});
|
|
7692
|
+
return {
|
|
7693
|
+
logicalEvents: Object.freeze(normalized),
|
|
7694
|
+
diagnostics: Object.freeze(diagnostics)
|
|
7695
|
+
};
|
|
7696
|
+
}
|
|
7697
|
+
function resolveCanonicalToolName(event) {
|
|
7698
|
+
const attrs = event.attributes;
|
|
7699
|
+
const direct = pickString(attrs, ["toolName", "tool"]);
|
|
7700
|
+
if (direct) return direct;
|
|
7701
|
+
const metadata = attrs?.metadata;
|
|
7702
|
+
if (isRecord8(metadata)) {
|
|
7703
|
+
const nested = pickString(metadata, ["toolName", "tool"]);
|
|
7704
|
+
if (nested) return nested;
|
|
7705
|
+
}
|
|
7706
|
+
for (const prefix of ["tool:", "function:", "mcp-tools:"]) {
|
|
7707
|
+
if (event.name.startsWith(prefix)) return event.name.slice(prefix.length);
|
|
7708
|
+
}
|
|
7709
|
+
return event.name;
|
|
7710
|
+
}
|
|
7711
|
+
function pickString(record, keys) {
|
|
7712
|
+
if (!record) return void 0;
|
|
7713
|
+
for (const key of keys) {
|
|
7714
|
+
const value = record[key];
|
|
7715
|
+
if (typeof value === "string" && value.trim() !== "") return value.trim();
|
|
7716
|
+
}
|
|
7717
|
+
return void 0;
|
|
7718
|
+
}
|
|
7719
|
+
|
|
7461
7720
|
// packages/core/src/checks/index.ts
|
|
7462
7721
|
var SEVERITY_RANK = {
|
|
7463
7722
|
error: 0,
|
|
@@ -7521,10 +7780,13 @@ function buildFacts2(input, selectedRun) {
|
|
|
7521
7780
|
childrenByParentId.set(parentId, children);
|
|
7522
7781
|
}
|
|
7523
7782
|
}
|
|
7783
|
+
const projection = projectLogicalEvents(scopedEvents);
|
|
7524
7784
|
return {
|
|
7525
7785
|
format: input.read.format,
|
|
7526
7786
|
runs: Object.freeze([...input.read.runs]),
|
|
7527
7787
|
events: Object.freeze([...scopedEvents]),
|
|
7788
|
+
logicalEvents: projection.logicalEvents,
|
|
7789
|
+
logicalProjectionDiagnostics: projection.diagnostics,
|
|
7528
7790
|
readerWarnings: Object.freeze([...input.read.warnings]),
|
|
7529
7791
|
unsupportedFields: Object.freeze([...input.read.unsupportedFields]),
|
|
7530
7792
|
sourceFiles: Object.freeze([...input.read.sourceFiles]),
|
|
@@ -7703,7 +7965,10 @@ function failFinding(ruleId, message, evidence, expected, actual, meta) {
|
|
|
7703
7965
|
};
|
|
7704
7966
|
}
|
|
7705
7967
|
function toolName(event) {
|
|
7706
|
-
return
|
|
7968
|
+
return resolveCanonicalToolName(event);
|
|
7969
|
+
}
|
|
7970
|
+
function semanticEvents(context) {
|
|
7971
|
+
return context.logicalEvents ?? context.events;
|
|
7707
7972
|
}
|
|
7708
7973
|
function llmModel(event) {
|
|
7709
7974
|
return stringAttr(event, ["model", "modelId", "responseModelId", "modelName", "model_name"]) ?? stripPrefix(event.name, ["llm:", "generation:", "transcription:", "speech:"]);
|
|
@@ -7715,7 +7980,7 @@ function llmFinishReason(event) {
|
|
|
7715
7980
|
return stringAttr(event, ["finishReason", "rawFinishReason", "finish_reason"]);
|
|
7716
7981
|
}
|
|
7717
7982
|
function finishedEvents(context, kind) {
|
|
7718
|
-
return context.
|
|
7983
|
+
return semanticEvents(context).filter(
|
|
7719
7984
|
(event) => (kind === void 0 || event.kind === kind) && event.status !== "running"
|
|
7720
7985
|
);
|
|
7721
7986
|
}
|
|
@@ -7741,7 +8006,7 @@ function createRunStatusRule(options = {}) {
|
|
|
7741
8006
|
);
|
|
7742
8007
|
}
|
|
7743
8008
|
if (!allowIncomplete) {
|
|
7744
|
-
const running = context.
|
|
8009
|
+
const running = semanticEvents(context).filter((event) => event.status === "running");
|
|
7745
8010
|
if (running.length > 0) {
|
|
7746
8011
|
findings.push(
|
|
7747
8012
|
failFinding(
|
|
@@ -7978,14 +8243,14 @@ function runTraceChecks(input, options = {}) {
|
|
|
7978
8243
|
}
|
|
7979
8244
|
|
|
7980
8245
|
// packages/core/src/persisted/token-usage.ts
|
|
7981
|
-
function
|
|
8246
|
+
function isRecord9(value) {
|
|
7982
8247
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
7983
8248
|
}
|
|
7984
8249
|
function nonNegativeFinite(value) {
|
|
7985
8250
|
return typeof value === "number" && Number.isFinite(value) && value >= 0 ? value : void 0;
|
|
7986
8251
|
}
|
|
7987
8252
|
function normalizeTokenUsage(value) {
|
|
7988
|
-
if (!
|
|
8253
|
+
if (!isRecord9(value)) return void 0;
|
|
7989
8254
|
const input = nonNegativeFinite(value.input);
|
|
7990
8255
|
const output = nonNegativeFinite(value.output);
|
|
7991
8256
|
const suppliedTotal = nonNegativeFinite(value.total);
|
|
@@ -8754,7 +9019,7 @@ function persistedEventsForParsedTrace(parsed) {
|
|
|
8754
9019
|
sourceName: "agent-inspect-jsonl-reader"
|
|
8755
9020
|
});
|
|
8756
9021
|
}
|
|
8757
|
-
function
|
|
9022
|
+
function isRecord10(value) {
|
|
8758
9023
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
8759
9024
|
}
|
|
8760
9025
|
function isNonEmptyString4(value) {
|
|
@@ -8769,13 +9034,13 @@ function readStringField(record, keys) {
|
|
|
8769
9034
|
}
|
|
8770
9035
|
function readRecordField(record, key) {
|
|
8771
9036
|
const value = record[key];
|
|
8772
|
-
return
|
|
9037
|
+
return isRecord10(value) ? value : void 0;
|
|
8773
9038
|
}
|
|
8774
9039
|
function parseJsonDocument(content) {
|
|
8775
9040
|
return JSON.parse(content);
|
|
8776
9041
|
}
|
|
8777
9042
|
function looksLikeOpenInferenceSpan(value) {
|
|
8778
|
-
if (!
|
|
9043
|
+
if (!isRecord10(value)) return false;
|
|
8779
9044
|
const attributes = readRecordField(value, "attributes");
|
|
8780
9045
|
return readStringField(value, ["trace_id", "traceId"]) !== void 0 && readStringField(value, ["span_id", "spanId"]) !== void 0 && (readStringField(value, ["name"]) !== void 0 || attributes?.["openinference.span.kind"] !== void 0);
|
|
8781
9046
|
}
|
|
@@ -8800,7 +9065,7 @@ function extractOpenInferenceDocument(root) {
|
|
|
8800
9065
|
unsupportedFields
|
|
8801
9066
|
};
|
|
8802
9067
|
}
|
|
8803
|
-
if (!
|
|
9068
|
+
if (!isRecord10(root)) return void 0;
|
|
8804
9069
|
const rootFormat = root.format;
|
|
8805
9070
|
const rootCompatibility = root.compatibility;
|
|
8806
9071
|
const version = typeof root.version === "string" && root.version.trim() !== "" ? root.version : void 0;
|
|
@@ -8940,7 +9205,7 @@ function summarizeAttributeValue(value) {
|
|
|
8940
9205
|
if (Array.isArray(value)) {
|
|
8941
9206
|
return { type: "array", length: value.length };
|
|
8942
9207
|
}
|
|
8943
|
-
if (
|
|
9208
|
+
if (isRecord10(value)) {
|
|
8944
9209
|
return { type: "object", keyCount: Object.keys(value).length };
|
|
8945
9210
|
}
|
|
8946
9211
|
if (value === null) {
|
|
@@ -9027,7 +9292,7 @@ function mapOpenInferenceKind(span, attributes, pathPrefix) {
|
|
|
9027
9292
|
}
|
|
9028
9293
|
}
|
|
9029
9294
|
function mapOpenInferenceStatus(status) {
|
|
9030
|
-
if (!
|
|
9295
|
+
if (!isRecord10(status)) return void 0;
|
|
9031
9296
|
const rawCode = status.code;
|
|
9032
9297
|
if (typeof rawCode !== "string") return void 0;
|
|
9033
9298
|
switch (rawCode.toUpperCase()) {
|
|
@@ -9127,7 +9392,7 @@ function mapOpenInferenceSpan(span, index, version) {
|
|
|
9127
9392
|
warnings.push(...kindWarnings);
|
|
9128
9393
|
const status = mapOpenInferenceStatus(span.status);
|
|
9129
9394
|
const tokenUsage = readOpenInferenceTokenUsage(rawAttributes);
|
|
9130
|
-
const errorMessage =
|
|
9395
|
+
const errorMessage = isRecord10(span.status) && typeof span.status.message === "string" ? span.status.message : void 0;
|
|
9131
9396
|
const event = {
|
|
9132
9397
|
schemaVersion: "0.2",
|
|
9133
9398
|
eventId: typeof rawAttributes["agent_inspect.event_id"] === "string" ? rawAttributes["agent_inspect.event_id"] : spanId,
|
|
@@ -9273,7 +9538,7 @@ var openInferenceJsonReader = {
|
|
|
9273
9538
|
}
|
|
9274
9539
|
};
|
|
9275
9540
|
function parseOtlpAnyValue(value, field, warnings, unsupportedFields) {
|
|
9276
|
-
if (!
|
|
9541
|
+
if (!isRecord10(value)) {
|
|
9277
9542
|
unsupportedFields.push(field);
|
|
9278
9543
|
warnings.push({
|
|
9279
9544
|
code: "otlp_attribute_value_invalid",
|
|
@@ -9295,15 +9560,15 @@ function parseOtlpAnyValue(value, field, warnings, unsupportedFields) {
|
|
|
9295
9560
|
if (typeof value.doubleValue === "number" && Number.isFinite(value.doubleValue)) {
|
|
9296
9561
|
return value.doubleValue;
|
|
9297
9562
|
}
|
|
9298
|
-
if (
|
|
9563
|
+
if (isRecord10(value.arrayValue) && Array.isArray(value.arrayValue.values)) {
|
|
9299
9564
|
return value.arrayValue.values.map(
|
|
9300
9565
|
(item, index) => parseOtlpAnyValue(item, `${field}.arrayValue.values[${index}]`, warnings, unsupportedFields)
|
|
9301
9566
|
);
|
|
9302
9567
|
}
|
|
9303
|
-
if (
|
|
9568
|
+
if (isRecord10(value.kvlistValue) && Array.isArray(value.kvlistValue.values)) {
|
|
9304
9569
|
const out = {};
|
|
9305
9570
|
for (const [index, item] of value.kvlistValue.values.entries()) {
|
|
9306
|
-
if (!
|
|
9571
|
+
if (!isRecord10(item) || typeof item.key !== "string") {
|
|
9307
9572
|
unsupportedFields.push(`${field}.kvlistValue.values[${index}]`);
|
|
9308
9573
|
continue;
|
|
9309
9574
|
}
|
|
@@ -9354,7 +9619,7 @@ function parseOtlpAttributes(value, pathPrefix) {
|
|
|
9354
9619
|
}
|
|
9355
9620
|
for (const [index, item] of value.entries()) {
|
|
9356
9621
|
const field = `${pathPrefix}[${index}]`;
|
|
9357
|
-
if (!
|
|
9622
|
+
if (!isRecord10(item) || typeof item.key !== "string") {
|
|
9358
9623
|
unsupportedFields.push(field);
|
|
9359
9624
|
warnings.push({
|
|
9360
9625
|
code: "otlp_attribute_invalid",
|
|
@@ -9377,16 +9642,16 @@ function parseOtlpAttributes(value, pathPrefix) {
|
|
|
9377
9642
|
return { attributes, warnings, unsupportedFields };
|
|
9378
9643
|
}
|
|
9379
9644
|
function looksLikeOtlpSpan(value) {
|
|
9380
|
-
return
|
|
9645
|
+
return isRecord10(value) && readStringField(value, ["traceId"]) !== void 0 && readStringField(value, ["spanId"]) !== void 0 && readStringField(value, ["name"]) !== void 0;
|
|
9381
9646
|
}
|
|
9382
9647
|
function extractOtlpDocument(root) {
|
|
9383
|
-
if (!
|
|
9648
|
+
if (!isRecord10(root) || !Array.isArray(root.resourceSpans)) return void 0;
|
|
9384
9649
|
const spans = [];
|
|
9385
9650
|
const warnings = [];
|
|
9386
9651
|
const unsupportedFields = [];
|
|
9387
9652
|
for (const [resourceIndex, resourceSpan] of root.resourceSpans.entries()) {
|
|
9388
9653
|
const resourcePath = `resourceSpans[${resourceIndex}]`;
|
|
9389
|
-
if (!
|
|
9654
|
+
if (!isRecord10(resourceSpan)) {
|
|
9390
9655
|
unsupportedFields.push(resourcePath);
|
|
9391
9656
|
continue;
|
|
9392
9657
|
}
|
|
@@ -9409,7 +9674,7 @@ function extractOtlpDocument(root) {
|
|
|
9409
9674
|
}
|
|
9410
9675
|
for (const [scopeIndex, scopeSpan] of resourceSpan.scopeSpans.entries()) {
|
|
9411
9676
|
const scopePath = `${resourcePath}.scopeSpans[${scopeIndex}]`;
|
|
9412
|
-
if (!
|
|
9677
|
+
if (!isRecord10(scopeSpan)) {
|
|
9413
9678
|
unsupportedFields.push(scopePath);
|
|
9414
9679
|
continue;
|
|
9415
9680
|
}
|
|
@@ -9476,7 +9741,7 @@ function extractOtlpDocument(root) {
|
|
|
9476
9741
|
};
|
|
9477
9742
|
}
|
|
9478
9743
|
function mapOtlpStatus(status) {
|
|
9479
|
-
if (!
|
|
9744
|
+
if (!isRecord10(status)) return void 0;
|
|
9480
9745
|
const rawCode = status.code;
|
|
9481
9746
|
if (typeof rawCode !== "string") return void 0;
|
|
9482
9747
|
switch (rawCode.toUpperCase()) {
|
|
@@ -9576,7 +9841,7 @@ function mapOtlpEvents(value, pathPrefix) {
|
|
|
9576
9841
|
const events = [];
|
|
9577
9842
|
for (const [index, event] of value.entries()) {
|
|
9578
9843
|
const eventPath = `${pathPrefix}[${index}]`;
|
|
9579
|
-
if (!
|
|
9844
|
+
if (!isRecord10(event)) {
|
|
9580
9845
|
unsupportedFields.push(eventPath);
|
|
9581
9846
|
continue;
|
|
9582
9847
|
}
|
|
@@ -9714,7 +9979,7 @@ function mapOtlpSpan(context) {
|
|
|
9714
9979
|
warnings.push(...kindWarnings);
|
|
9715
9980
|
const status = mapOtlpStatus(span.status);
|
|
9716
9981
|
const tokenUsage = readOtlpTokenUsage(parsedSpanAttributes.attributes);
|
|
9717
|
-
const errorMessage =
|
|
9982
|
+
const errorMessage = isRecord10(span.status) && typeof span.status.message === "string" ? span.status.message : void 0;
|
|
9718
9983
|
const event = {
|
|
9719
9984
|
schemaVersion: "0.2",
|
|
9720
9985
|
eventId: typeof parsedSpanAttributes.attributes["agent_inspect.event_id"] === "string" ? parsedSpanAttributes.attributes["agent_inspect.event_id"] : spanId,
|