@agent-inspect/mcp-server 6.12.0 → 6.12.2
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/dist/{chunk-YSGVFUHF.mjs → chunk-J72IWHQK.mjs} +280 -38
- package/dist/chunk-J72IWHQK.mjs.map +1 -0
- package/dist/cli.cjs +278 -36
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.mjs +1 -1
- package/dist/index.cjs +278 -36
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +3 -3
- package/dist/chunk-YSGVFUHF.mjs.map +0 -1
|
@@ -669,12 +669,12 @@ function persistedInspectEventToTraceEvents(event) {
|
|
|
669
669
|
if (!isPersistedInspectEvent(event)) {
|
|
670
670
|
throw new Error("Invalid PersistedInspectEvent: failed isPersistedInspectEvent");
|
|
671
671
|
}
|
|
672
|
-
const
|
|
673
|
-
if (
|
|
674
|
-
if (
|
|
675
|
-
if (
|
|
676
|
-
if (
|
|
677
|
-
if (
|
|
672
|
+
const legacyEvent2 = event.attributes?.legacyEvent;
|
|
673
|
+
if (legacyEvent2 === "run_started") return [fromLegacyRunStarted(event)];
|
|
674
|
+
if (legacyEvent2 === "run_completed") return [fromLegacyRunCompleted(event)];
|
|
675
|
+
if (legacyEvent2 === "step_started") return [fromLegacyStepStarted(event)];
|
|
676
|
+
if (legacyEvent2 === "step_completed") return [fromLegacyStepCompleted(event)];
|
|
677
|
+
if (legacyEvent2 === "outcome_observed") return [fromLegacyOutcomeObserved(event)];
|
|
678
678
|
if (event.kind === "RUN") {
|
|
679
679
|
return fromNativeRun(event);
|
|
680
680
|
}
|
|
@@ -2567,6 +2567,238 @@ function diffRuns(left, right, options) {
|
|
|
2567
2567
|
return table;
|
|
2568
2568
|
})();
|
|
2569
2569
|
|
|
2570
|
+
// packages/core/src/checks/logical-events.ts
|
|
2571
|
+
function isRecord6(value) {
|
|
2572
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
2573
|
+
}
|
|
2574
|
+
function legacyEvent(event) {
|
|
2575
|
+
const value = event.attributes?.legacyEvent;
|
|
2576
|
+
return typeof value === "string" ? value : void 0;
|
|
2577
|
+
}
|
|
2578
|
+
function stepIdOf(event) {
|
|
2579
|
+
const value = event.attributes?.stepId;
|
|
2580
|
+
if (typeof value === "string" && value.trim() !== "") return value;
|
|
2581
|
+
return void 0;
|
|
2582
|
+
}
|
|
2583
|
+
function cloneEvent(event) {
|
|
2584
|
+
return {
|
|
2585
|
+
...event,
|
|
2586
|
+
...event.attributes !== void 0 ? { attributes: { ...event.attributes } } : {},
|
|
2587
|
+
...event.error !== void 0 ? { error: { ...event.error } } : {},
|
|
2588
|
+
...event.tokenUsage !== void 0 ? { tokenUsage: { ...event.tokenUsage } } : {},
|
|
2589
|
+
...event.source !== void 0 ? { source: { ...event.source } } : {}
|
|
2590
|
+
};
|
|
2591
|
+
}
|
|
2592
|
+
function mergeAttributes(start, complete) {
|
|
2593
|
+
const merged = {
|
|
2594
|
+
...isRecord6(complete.attributes) ? complete.attributes : {},
|
|
2595
|
+
...isRecord6(start.attributes) ? start.attributes : {}
|
|
2596
|
+
};
|
|
2597
|
+
merged.legacyEvent = start.attributes?.legacyEvent ?? complete.attributes?.legacyEvent;
|
|
2598
|
+
merged.legacyCompleteEvent = complete.attributes?.legacyEvent;
|
|
2599
|
+
if (complete.attributes?.errorStack !== void 0) {
|
|
2600
|
+
merged.errorStack = complete.attributes.errorStack;
|
|
2601
|
+
}
|
|
2602
|
+
return Object.keys(merged).length > 0 ? merged : void 0;
|
|
2603
|
+
}
|
|
2604
|
+
function pairStartComplete(start, complete) {
|
|
2605
|
+
const attributes = mergeAttributes(start, complete);
|
|
2606
|
+
const paired = {
|
|
2607
|
+
...cloneEvent(start),
|
|
2608
|
+
status: complete.status,
|
|
2609
|
+
timestamp: complete.timestamp ?? start.timestamp,
|
|
2610
|
+
...complete.endedAt !== void 0 ? { endedAt: complete.endedAt } : {},
|
|
2611
|
+
...complete.durationMs !== void 0 ? { durationMs: complete.durationMs } : {},
|
|
2612
|
+
...complete.error !== void 0 ? { error: { ...complete.error } } : {},
|
|
2613
|
+
...complete.tokenUsage !== void 0 && start.tokenUsage === void 0 ? { tokenUsage: { ...complete.tokenUsage } } : {},
|
|
2614
|
+
...attributes !== void 0 ? { attributes } : {}
|
|
2615
|
+
};
|
|
2616
|
+
return {
|
|
2617
|
+
...paired,
|
|
2618
|
+
sourceEventIds: Object.freeze([start.eventId, complete.eventId]),
|
|
2619
|
+
projection: {
|
|
2620
|
+
paired: true,
|
|
2621
|
+
absorbedEventIds: Object.freeze([complete.eventId]),
|
|
2622
|
+
parentNormalized: false,
|
|
2623
|
+
...start.parentId !== void 0 ? { originalParentId: start.parentId } : {}
|
|
2624
|
+
}
|
|
2625
|
+
};
|
|
2626
|
+
}
|
|
2627
|
+
function asLogical(event, extras) {
|
|
2628
|
+
return {
|
|
2629
|
+
...cloneEvent(event),
|
|
2630
|
+
sourceEventIds: Object.freeze([event.eventId]),
|
|
2631
|
+
projection: {
|
|
2632
|
+
paired: false,
|
|
2633
|
+
absorbedEventIds: Object.freeze([]),
|
|
2634
|
+
parentNormalized: extras?.parentNormalized === true,
|
|
2635
|
+
...{}
|
|
2636
|
+
}
|
|
2637
|
+
};
|
|
2638
|
+
}
|
|
2639
|
+
function projectLogicalEvents(events) {
|
|
2640
|
+
const diagnostics = [];
|
|
2641
|
+
const byRun = /* @__PURE__ */ new Map();
|
|
2642
|
+
for (const event of events) {
|
|
2643
|
+
const list = byRun.get(event.runId) ?? [];
|
|
2644
|
+
list.push(event);
|
|
2645
|
+
byRun.set(event.runId, list);
|
|
2646
|
+
}
|
|
2647
|
+
const absorbedIds = /* @__PURE__ */ new Set();
|
|
2648
|
+
const logicalByRawId = /* @__PURE__ */ new Map();
|
|
2649
|
+
const stepIdToLogicalId = /* @__PURE__ */ new Map();
|
|
2650
|
+
const logical = [];
|
|
2651
|
+
const orderedRuns = [...byRun.keys()].sort((a, b) => a.localeCompare(b));
|
|
2652
|
+
for (const runId of orderedRuns) {
|
|
2653
|
+
const runEvents = byRun.get(runId) ?? [];
|
|
2654
|
+
const starts = [];
|
|
2655
|
+
const completes = [];
|
|
2656
|
+
const others = [];
|
|
2657
|
+
for (const event of runEvents) {
|
|
2658
|
+
const legacy = legacyEvent(event);
|
|
2659
|
+
if (legacy === "step_started" || legacy === "run_started" && event.status === "running") {
|
|
2660
|
+
starts.push(event);
|
|
2661
|
+
} else if (legacy === "step_completed" || legacy === "run_completed") {
|
|
2662
|
+
completes.push(event);
|
|
2663
|
+
} else {
|
|
2664
|
+
others.push(event);
|
|
2665
|
+
}
|
|
2666
|
+
}
|
|
2667
|
+
const usedCompletes = /* @__PURE__ */ new Set();
|
|
2668
|
+
for (const start of starts) {
|
|
2669
|
+
const stepId = stepIdOf(start);
|
|
2670
|
+
let match;
|
|
2671
|
+
if (legacyEvent(start) === "run_started") {
|
|
2672
|
+
const candidates = completes.filter(
|
|
2673
|
+
(c) => !usedCompletes.has(c.eventId) && legacyEvent(c) === "run_completed"
|
|
2674
|
+
);
|
|
2675
|
+
if (candidates.length > 1) {
|
|
2676
|
+
diagnostics.push({
|
|
2677
|
+
code: "AI_LOGICAL_PAIR_AMBIGUOUS",
|
|
2678
|
+
message: `Multiple run_completed rows for run ${runId}; using first by eventId.`,
|
|
2679
|
+
eventIds: candidates.map((c) => c.eventId)
|
|
2680
|
+
});
|
|
2681
|
+
candidates.sort((a, b) => a.eventId.localeCompare(b.eventId));
|
|
2682
|
+
}
|
|
2683
|
+
match = candidates[0];
|
|
2684
|
+
} else if (stepId) {
|
|
2685
|
+
const candidates = completes.filter(
|
|
2686
|
+
(c) => !usedCompletes.has(c.eventId) && legacyEvent(c) === "step_completed" && stepIdOf(c) === stepId
|
|
2687
|
+
);
|
|
2688
|
+
if (candidates.length > 1) {
|
|
2689
|
+
diagnostics.push({
|
|
2690
|
+
code: "AI_LOGICAL_PAIR_AMBIGUOUS",
|
|
2691
|
+
message: `Multiple step_completed rows for stepId ${stepId}; using first by eventId.`,
|
|
2692
|
+
eventIds: candidates.map((c) => c.eventId)
|
|
2693
|
+
});
|
|
2694
|
+
candidates.sort((a, b) => a.eventId.localeCompare(b.eventId));
|
|
2695
|
+
}
|
|
2696
|
+
match = candidates[0];
|
|
2697
|
+
}
|
|
2698
|
+
if (match) {
|
|
2699
|
+
usedCompletes.add(match.eventId);
|
|
2700
|
+
absorbedIds.add(match.eventId);
|
|
2701
|
+
const paired = pairStartComplete(start, match);
|
|
2702
|
+
logical.push(paired);
|
|
2703
|
+
logicalByRawId.set(start.eventId, paired);
|
|
2704
|
+
logicalByRawId.set(match.eventId, paired);
|
|
2705
|
+
if (stepId) stepIdToLogicalId.set(`${runId}:${stepId}`, paired.eventId);
|
|
2706
|
+
} else {
|
|
2707
|
+
diagnostics.push({
|
|
2708
|
+
code: "AI_LOGICAL_PAIR_UNMATCHED_START",
|
|
2709
|
+
message: `No matching complete for start ${start.eventId}.`,
|
|
2710
|
+
eventIds: [start.eventId]
|
|
2711
|
+
});
|
|
2712
|
+
const alone = asLogical(start);
|
|
2713
|
+
logical.push(alone);
|
|
2714
|
+
logicalByRawId.set(start.eventId, alone);
|
|
2715
|
+
if (stepId) stepIdToLogicalId.set(`${runId}:${stepId}`, alone.eventId);
|
|
2716
|
+
}
|
|
2717
|
+
}
|
|
2718
|
+
for (const complete of completes) {
|
|
2719
|
+
if (usedCompletes.has(complete.eventId)) continue;
|
|
2720
|
+
diagnostics.push({
|
|
2721
|
+
code: "AI_LOGICAL_PAIR_UNMATCHED_COMPLETE",
|
|
2722
|
+
message: `No matching start for complete ${complete.eventId}.`,
|
|
2723
|
+
eventIds: [complete.eventId]
|
|
2724
|
+
});
|
|
2725
|
+
const alone = asLogical(complete);
|
|
2726
|
+
logical.push(alone);
|
|
2727
|
+
logicalByRawId.set(complete.eventId, alone);
|
|
2728
|
+
const stepId = stepIdOf(complete);
|
|
2729
|
+
if (stepId && !stepIdToLogicalId.has(`${runId}:${stepId}`)) {
|
|
2730
|
+
stepIdToLogicalId.set(`${runId}:${stepId}`, alone.eventId);
|
|
2731
|
+
}
|
|
2732
|
+
}
|
|
2733
|
+
for (const event of others) {
|
|
2734
|
+
const alone = asLogical(event);
|
|
2735
|
+
logical.push(alone);
|
|
2736
|
+
logicalByRawId.set(event.eventId, alone);
|
|
2737
|
+
const stepId = stepIdOf(event);
|
|
2738
|
+
if (stepId && !stepIdToLogicalId.has(`${runId}:${stepId}`)) {
|
|
2739
|
+
stepIdToLogicalId.set(`${runId}:${stepId}`, alone.eventId);
|
|
2740
|
+
}
|
|
2741
|
+
}
|
|
2742
|
+
}
|
|
2743
|
+
const logicalById = new Map(logical.map((e) => [e.eventId, e]));
|
|
2744
|
+
const normalized = [];
|
|
2745
|
+
for (const event of logical) {
|
|
2746
|
+
const originalParentId = event.parentId;
|
|
2747
|
+
if (!originalParentId) {
|
|
2748
|
+
normalized.push(event);
|
|
2749
|
+
continue;
|
|
2750
|
+
}
|
|
2751
|
+
let nextParent = originalParentId;
|
|
2752
|
+
let remapped = false;
|
|
2753
|
+
const viaAbsorbed = logicalByRawId.get(originalParentId);
|
|
2754
|
+
if (viaAbsorbed && viaAbsorbed.eventId !== originalParentId) {
|
|
2755
|
+
nextParent = viaAbsorbed.eventId;
|
|
2756
|
+
remapped = true;
|
|
2757
|
+
} else if (!logicalById.has(originalParentId)) {
|
|
2758
|
+
const viaStep = stepIdToLogicalId.get(`${event.runId}:${originalParentId}`);
|
|
2759
|
+
if (viaStep) {
|
|
2760
|
+
nextParent = viaStep;
|
|
2761
|
+
remapped = true;
|
|
2762
|
+
}
|
|
2763
|
+
}
|
|
2764
|
+
if (!remapped) {
|
|
2765
|
+
if (!logicalById.has(originalParentId) && !logicalByRawId.has(originalParentId)) {
|
|
2766
|
+
diagnostics.push({
|
|
2767
|
+
code: "AI_LOGICAL_PARENT_UNRESOLVED",
|
|
2768
|
+
message: `Parent ${originalParentId} unresolved for ${event.eventId}.`,
|
|
2769
|
+
eventIds: [event.eventId]
|
|
2770
|
+
});
|
|
2771
|
+
}
|
|
2772
|
+
normalized.push(event);
|
|
2773
|
+
continue;
|
|
2774
|
+
}
|
|
2775
|
+
diagnostics.push({
|
|
2776
|
+
code: "AI_LOGICAL_PARENT_REMAPPED",
|
|
2777
|
+
message: `Remapped parent ${originalParentId} \u2192 ${nextParent} for ${event.eventId}.`,
|
|
2778
|
+
eventIds: [event.eventId]
|
|
2779
|
+
});
|
|
2780
|
+
normalized.push({
|
|
2781
|
+
...event,
|
|
2782
|
+
parentId: nextParent,
|
|
2783
|
+
projection: {
|
|
2784
|
+
...event.projection,
|
|
2785
|
+
parentNormalized: true,
|
|
2786
|
+
originalParentId
|
|
2787
|
+
}
|
|
2788
|
+
});
|
|
2789
|
+
}
|
|
2790
|
+
const rawIndex = new Map(events.map((e, i) => [e.eventId, i]));
|
|
2791
|
+
normalized.sort((a, b) => {
|
|
2792
|
+
const ai = rawIndex.get(a.sourceEventIds[0]) ?? 0;
|
|
2793
|
+
const bi = rawIndex.get(b.sourceEventIds[0]) ?? 0;
|
|
2794
|
+
return ai - bi || a.eventId.localeCompare(b.eventId);
|
|
2795
|
+
});
|
|
2796
|
+
return {
|
|
2797
|
+
logicalEvents: Object.freeze(normalized),
|
|
2798
|
+
diagnostics: Object.freeze(diagnostics)
|
|
2799
|
+
};
|
|
2800
|
+
}
|
|
2801
|
+
|
|
2570
2802
|
// packages/core/src/checks/index.ts
|
|
2571
2803
|
var SEVERITY_RANK = {
|
|
2572
2804
|
error: 0,
|
|
@@ -2619,7 +2851,11 @@ var DEFAULT_RAW_CONTENT_KEYS = [
|
|
|
2619
2851
|
"conversationtext",
|
|
2620
2852
|
"conversation_text"
|
|
2621
2853
|
];
|
|
2622
|
-
var DEFAULT_SAFE_RAW_CONTENT_PATH_PREFIXES = [
|
|
2854
|
+
var DEFAULT_SAFE_RAW_CONTENT_PATH_PREFIXES = [
|
|
2855
|
+
"tokenUsage",
|
|
2856
|
+
"usage",
|
|
2857
|
+
"tokens"
|
|
2858
|
+
];
|
|
2623
2859
|
var SAFE_USAGE_LEAF_KEYS = /* @__PURE__ */ new Set([
|
|
2624
2860
|
"input",
|
|
2625
2861
|
"output",
|
|
@@ -2695,10 +2931,13 @@ function buildFacts(input, selectedRun) {
|
|
|
2695
2931
|
childrenByParentId.set(parentId, children);
|
|
2696
2932
|
}
|
|
2697
2933
|
}
|
|
2934
|
+
const projection = projectLogicalEvents(scopedEvents);
|
|
2698
2935
|
return {
|
|
2699
2936
|
format: input.read.format,
|
|
2700
2937
|
runs: Object.freeze([...input.read.runs]),
|
|
2701
2938
|
events: Object.freeze([...scopedEvents]),
|
|
2939
|
+
logicalEvents: projection.logicalEvents,
|
|
2940
|
+
logicalProjectionDiagnostics: projection.diagnostics,
|
|
2702
2941
|
readerWarnings: Object.freeze([...input.read.warnings]),
|
|
2703
2942
|
unsupportedFields: Object.freeze([...input.read.unsupportedFields]),
|
|
2704
2943
|
sourceFiles: Object.freeze([...input.read.sourceFiles]),
|
|
@@ -2863,7 +3102,10 @@ function failFinding(ruleId, message, evidence, expected, actual, meta) {
|
|
|
2863
3102
|
...meta?.action !== void 0 ? { action: meta.action } : {}
|
|
2864
3103
|
};
|
|
2865
3104
|
}
|
|
2866
|
-
function
|
|
3105
|
+
function semanticEvents(context) {
|
|
3106
|
+
return context.logicalEvents ?? context.events;
|
|
3107
|
+
}
|
|
3108
|
+
function isRecord7(value) {
|
|
2867
3109
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
2868
3110
|
}
|
|
2869
3111
|
function normalizedKey(value) {
|
|
@@ -2894,7 +3136,7 @@ function pushValueEntries(entries, event, value, path16, key, depth = 0) {
|
|
|
2894
3136
|
}
|
|
2895
3137
|
return;
|
|
2896
3138
|
}
|
|
2897
|
-
if (!
|
|
3139
|
+
if (!isRecord7(value)) return;
|
|
2898
3140
|
for (const nestedKey of Object.keys(value).sort((a, b) => a.localeCompare(b))) {
|
|
2899
3141
|
pushValueEntries(
|
|
2900
3142
|
entries,
|
|
@@ -2976,7 +3218,7 @@ function createRunStatusRule(options = {}) {
|
|
|
2976
3218
|
);
|
|
2977
3219
|
}
|
|
2978
3220
|
if (!allowIncomplete) {
|
|
2979
|
-
const running = context.
|
|
3221
|
+
const running = semanticEvents(context).filter((event) => event.status === "running");
|
|
2980
3222
|
if (running.length > 0) {
|
|
2981
3223
|
findings.push(
|
|
2982
3224
|
failFinding(
|
|
@@ -3144,7 +3386,7 @@ function createSafetyOversizedAttributeRule(options) {
|
|
|
3144
3386
|
)
|
|
3145
3387
|
);
|
|
3146
3388
|
}
|
|
3147
|
-
if (
|
|
3389
|
+
if (isRecord7(entry.value) && options.maxObjectKeys !== void 0 && Object.keys(entry.value).length > options.maxObjectKeys) {
|
|
3148
3390
|
findings.push(
|
|
3149
3391
|
failFinding(
|
|
3150
3392
|
"safety.oversizedAttribute",
|
|
@@ -3233,14 +3475,14 @@ function runTraceChecks(input, options = {}) {
|
|
|
3233
3475
|
}
|
|
3234
3476
|
|
|
3235
3477
|
// packages/core/src/persisted/token-usage.ts
|
|
3236
|
-
function
|
|
3478
|
+
function isRecord8(value) {
|
|
3237
3479
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
3238
3480
|
}
|
|
3239
3481
|
function nonNegativeFinite(value) {
|
|
3240
3482
|
return typeof value === "number" && Number.isFinite(value) && value >= 0 ? value : void 0;
|
|
3241
3483
|
}
|
|
3242
3484
|
function normalizeTokenUsage(value) {
|
|
3243
|
-
if (!
|
|
3485
|
+
if (!isRecord8(value)) return void 0;
|
|
3244
3486
|
const input = nonNegativeFinite(value.input);
|
|
3245
3487
|
const output = nonNegativeFinite(value.output);
|
|
3246
3488
|
const suppliedTotal = nonNegativeFinite(value.total);
|
|
@@ -4009,7 +4251,7 @@ function persistedEventsForParsedTrace(parsed) {
|
|
|
4009
4251
|
sourceName: "agent-inspect-jsonl-reader"
|
|
4010
4252
|
});
|
|
4011
4253
|
}
|
|
4012
|
-
function
|
|
4254
|
+
function isRecord9(value) {
|
|
4013
4255
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
4014
4256
|
}
|
|
4015
4257
|
function isNonEmptyString3(value) {
|
|
@@ -4024,13 +4266,13 @@ function readStringField(record, keys) {
|
|
|
4024
4266
|
}
|
|
4025
4267
|
function readRecordField(record, key) {
|
|
4026
4268
|
const value = record[key];
|
|
4027
|
-
return
|
|
4269
|
+
return isRecord9(value) ? value : void 0;
|
|
4028
4270
|
}
|
|
4029
4271
|
function parseJsonDocument(content) {
|
|
4030
4272
|
return JSON.parse(content);
|
|
4031
4273
|
}
|
|
4032
4274
|
function looksLikeOpenInferenceSpan(value) {
|
|
4033
|
-
if (!
|
|
4275
|
+
if (!isRecord9(value)) return false;
|
|
4034
4276
|
const attributes = readRecordField(value, "attributes");
|
|
4035
4277
|
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);
|
|
4036
4278
|
}
|
|
@@ -4055,7 +4297,7 @@ function extractOpenInferenceDocument(root) {
|
|
|
4055
4297
|
unsupportedFields
|
|
4056
4298
|
};
|
|
4057
4299
|
}
|
|
4058
|
-
if (!
|
|
4300
|
+
if (!isRecord9(root)) return void 0;
|
|
4059
4301
|
const rootFormat = root.format;
|
|
4060
4302
|
const rootCompatibility = root.compatibility;
|
|
4061
4303
|
const version = typeof root.version === "string" && root.version.trim() !== "" ? root.version : void 0;
|
|
@@ -4195,7 +4437,7 @@ function summarizeAttributeValue(value) {
|
|
|
4195
4437
|
if (Array.isArray(value)) {
|
|
4196
4438
|
return { type: "array", length: value.length };
|
|
4197
4439
|
}
|
|
4198
|
-
if (
|
|
4440
|
+
if (isRecord9(value)) {
|
|
4199
4441
|
return { type: "object", keyCount: Object.keys(value).length };
|
|
4200
4442
|
}
|
|
4201
4443
|
if (value === null) {
|
|
@@ -4282,7 +4524,7 @@ function mapOpenInferenceKind(span, attributes, pathPrefix) {
|
|
|
4282
4524
|
}
|
|
4283
4525
|
}
|
|
4284
4526
|
function mapOpenInferenceStatus(status) {
|
|
4285
|
-
if (!
|
|
4527
|
+
if (!isRecord9(status)) return void 0;
|
|
4286
4528
|
const rawCode = status.code;
|
|
4287
4529
|
if (typeof rawCode !== "string") return void 0;
|
|
4288
4530
|
switch (rawCode.toUpperCase()) {
|
|
@@ -4382,7 +4624,7 @@ function mapOpenInferenceSpan(span, index, version) {
|
|
|
4382
4624
|
warnings.push(...kindWarnings);
|
|
4383
4625
|
const status = mapOpenInferenceStatus(span.status);
|
|
4384
4626
|
const tokenUsage = readOpenInferenceTokenUsage(rawAttributes);
|
|
4385
|
-
const errorMessage =
|
|
4627
|
+
const errorMessage = isRecord9(span.status) && typeof span.status.message === "string" ? span.status.message : void 0;
|
|
4386
4628
|
const event = {
|
|
4387
4629
|
schemaVersion: "0.2",
|
|
4388
4630
|
eventId: typeof rawAttributes["agent_inspect.event_id"] === "string" ? rawAttributes["agent_inspect.event_id"] : spanId,
|
|
@@ -4528,7 +4770,7 @@ var openInferenceJsonReader = {
|
|
|
4528
4770
|
}
|
|
4529
4771
|
};
|
|
4530
4772
|
function parseOtlpAnyValue(value, field, warnings, unsupportedFields) {
|
|
4531
|
-
if (!
|
|
4773
|
+
if (!isRecord9(value)) {
|
|
4532
4774
|
unsupportedFields.push(field);
|
|
4533
4775
|
warnings.push({
|
|
4534
4776
|
code: "otlp_attribute_value_invalid",
|
|
@@ -4550,15 +4792,15 @@ function parseOtlpAnyValue(value, field, warnings, unsupportedFields) {
|
|
|
4550
4792
|
if (typeof value.doubleValue === "number" && Number.isFinite(value.doubleValue)) {
|
|
4551
4793
|
return value.doubleValue;
|
|
4552
4794
|
}
|
|
4553
|
-
if (
|
|
4795
|
+
if (isRecord9(value.arrayValue) && Array.isArray(value.arrayValue.values)) {
|
|
4554
4796
|
return value.arrayValue.values.map(
|
|
4555
4797
|
(item, index) => parseOtlpAnyValue(item, `${field}.arrayValue.values[${index}]`, warnings, unsupportedFields)
|
|
4556
4798
|
);
|
|
4557
4799
|
}
|
|
4558
|
-
if (
|
|
4800
|
+
if (isRecord9(value.kvlistValue) && Array.isArray(value.kvlistValue.values)) {
|
|
4559
4801
|
const out = {};
|
|
4560
4802
|
for (const [index, item] of value.kvlistValue.values.entries()) {
|
|
4561
|
-
if (!
|
|
4803
|
+
if (!isRecord9(item) || typeof item.key !== "string") {
|
|
4562
4804
|
unsupportedFields.push(`${field}.kvlistValue.values[${index}]`);
|
|
4563
4805
|
continue;
|
|
4564
4806
|
}
|
|
@@ -4609,7 +4851,7 @@ function parseOtlpAttributes(value, pathPrefix) {
|
|
|
4609
4851
|
}
|
|
4610
4852
|
for (const [index, item] of value.entries()) {
|
|
4611
4853
|
const field = `${pathPrefix}[${index}]`;
|
|
4612
|
-
if (!
|
|
4854
|
+
if (!isRecord9(item) || typeof item.key !== "string") {
|
|
4613
4855
|
unsupportedFields.push(field);
|
|
4614
4856
|
warnings.push({
|
|
4615
4857
|
code: "otlp_attribute_invalid",
|
|
@@ -4632,16 +4874,16 @@ function parseOtlpAttributes(value, pathPrefix) {
|
|
|
4632
4874
|
return { attributes, warnings, unsupportedFields };
|
|
4633
4875
|
}
|
|
4634
4876
|
function looksLikeOtlpSpan(value) {
|
|
4635
|
-
return
|
|
4877
|
+
return isRecord9(value) && readStringField(value, ["traceId"]) !== void 0 && readStringField(value, ["spanId"]) !== void 0 && readStringField(value, ["name"]) !== void 0;
|
|
4636
4878
|
}
|
|
4637
4879
|
function extractOtlpDocument(root) {
|
|
4638
|
-
if (!
|
|
4880
|
+
if (!isRecord9(root) || !Array.isArray(root.resourceSpans)) return void 0;
|
|
4639
4881
|
const spans = [];
|
|
4640
4882
|
const warnings = [];
|
|
4641
4883
|
const unsupportedFields = [];
|
|
4642
4884
|
for (const [resourceIndex, resourceSpan] of root.resourceSpans.entries()) {
|
|
4643
4885
|
const resourcePath = `resourceSpans[${resourceIndex}]`;
|
|
4644
|
-
if (!
|
|
4886
|
+
if (!isRecord9(resourceSpan)) {
|
|
4645
4887
|
unsupportedFields.push(resourcePath);
|
|
4646
4888
|
continue;
|
|
4647
4889
|
}
|
|
@@ -4664,7 +4906,7 @@ function extractOtlpDocument(root) {
|
|
|
4664
4906
|
}
|
|
4665
4907
|
for (const [scopeIndex, scopeSpan] of resourceSpan.scopeSpans.entries()) {
|
|
4666
4908
|
const scopePath = `${resourcePath}.scopeSpans[${scopeIndex}]`;
|
|
4667
|
-
if (!
|
|
4909
|
+
if (!isRecord9(scopeSpan)) {
|
|
4668
4910
|
unsupportedFields.push(scopePath);
|
|
4669
4911
|
continue;
|
|
4670
4912
|
}
|
|
@@ -4731,7 +4973,7 @@ function extractOtlpDocument(root) {
|
|
|
4731
4973
|
};
|
|
4732
4974
|
}
|
|
4733
4975
|
function mapOtlpStatus(status) {
|
|
4734
|
-
if (!
|
|
4976
|
+
if (!isRecord9(status)) return void 0;
|
|
4735
4977
|
const rawCode = status.code;
|
|
4736
4978
|
if (typeof rawCode !== "string") return void 0;
|
|
4737
4979
|
switch (rawCode.toUpperCase()) {
|
|
@@ -4831,7 +5073,7 @@ function mapOtlpEvents(value, pathPrefix) {
|
|
|
4831
5073
|
const events = [];
|
|
4832
5074
|
for (const [index, event] of value.entries()) {
|
|
4833
5075
|
const eventPath = `${pathPrefix}[${index}]`;
|
|
4834
|
-
if (!
|
|
5076
|
+
if (!isRecord9(event)) {
|
|
4835
5077
|
unsupportedFields.push(eventPath);
|
|
4836
5078
|
continue;
|
|
4837
5079
|
}
|
|
@@ -4969,7 +5211,7 @@ function mapOtlpSpan(context) {
|
|
|
4969
5211
|
warnings.push(...kindWarnings);
|
|
4970
5212
|
const status = mapOtlpStatus(span.status);
|
|
4971
5213
|
const tokenUsage = readOtlpTokenUsage(parsedSpanAttributes.attributes);
|
|
4972
|
-
const errorMessage =
|
|
5214
|
+
const errorMessage = isRecord9(span.status) && typeof span.status.message === "string" ? span.status.message : void 0;
|
|
4973
5215
|
const event = {
|
|
4974
5216
|
schemaVersion: "0.2",
|
|
4975
5217
|
eventId: typeof parsedSpanAttributes.attributes["agent_inspect.event_id"] === "string" ? parsedSpanAttributes.attributes["agent_inspect.event_id"] : spanId,
|
|
@@ -5315,7 +5557,7 @@ function openTrace(input, options = {}) {
|
|
|
5315
5557
|
var EXPORT_PAYLOAD_VERSION = "0.1.2";
|
|
5316
5558
|
|
|
5317
5559
|
// packages/core/src/exporters/redact-export.ts
|
|
5318
|
-
function
|
|
5560
|
+
function isRecord10(value) {
|
|
5319
5561
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
5320
5562
|
}
|
|
5321
5563
|
function deepClone(value) {
|
|
@@ -5389,7 +5631,7 @@ function redactEventAttributes(attrs, redactor, maxMetadataValueLength, maxPrevi
|
|
|
5389
5631
|
0
|
|
5390
5632
|
);
|
|
5391
5633
|
const err = bounded.error;
|
|
5392
|
-
if (
|
|
5634
|
+
if (isRecord10(err) && typeof err.message === "string") {
|
|
5393
5635
|
bounded.error = {
|
|
5394
5636
|
...err,
|
|
5395
5637
|
message: truncateStringForProfile(
|
|
@@ -6051,7 +6293,7 @@ var STRICT_PROFILE_EXTRA_KEYS2 = [
|
|
|
6051
6293
|
"retrieval",
|
|
6052
6294
|
"query"
|
|
6053
6295
|
];
|
|
6054
|
-
function
|
|
6296
|
+
function isRecord11(value) {
|
|
6055
6297
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
6056
6298
|
}
|
|
6057
6299
|
function toKey2(key) {
|
|
@@ -6416,7 +6658,7 @@ var Redactor2 = class {
|
|
|
6416
6658
|
});
|
|
6417
6659
|
return out;
|
|
6418
6660
|
}
|
|
6419
|
-
if (
|
|
6661
|
+
if (isRecord11(value)) {
|
|
6420
6662
|
if (state.seen.has(value)) return state.seen.get(value);
|
|
6421
6663
|
const out = {};
|
|
6422
6664
|
state.seen.set(value, out);
|
|
@@ -7237,5 +7479,5 @@ async function runReadOnlyMcpServer(options = {}) {
|
|
|
7237
7479
|
}
|
|
7238
7480
|
|
|
7239
7481
|
export { MCP_MAX_REQUEST_BYTES, MCP_PROTOCOL_VERSION, READ_ONLY_TOOLS, callReadOnlyTool, createMcpServerContext, handleMcpProtocolLine, runReadOnlyMcpServer };
|
|
7240
|
-
//# sourceMappingURL=chunk-
|
|
7241
|
-
//# sourceMappingURL=chunk-
|
|
7482
|
+
//# sourceMappingURL=chunk-J72IWHQK.mjs.map
|
|
7483
|
+
//# sourceMappingURL=chunk-J72IWHQK.mjs.map
|