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
|
@@ -603,12 +603,12 @@ function persistedInspectEventToTraceEvents(event) {
|
|
|
603
603
|
if (!isPersistedInspectEvent(event)) {
|
|
604
604
|
throw new Error("Invalid PersistedInspectEvent: failed isPersistedInspectEvent");
|
|
605
605
|
}
|
|
606
|
-
const
|
|
607
|
-
if (
|
|
608
|
-
if (
|
|
609
|
-
if (
|
|
610
|
-
if (
|
|
611
|
-
if (
|
|
606
|
+
const legacyEvent2 = event.attributes?.legacyEvent;
|
|
607
|
+
if (legacyEvent2 === "run_started") return [fromLegacyRunStarted(event)];
|
|
608
|
+
if (legacyEvent2 === "run_completed") return [fromLegacyRunCompleted(event)];
|
|
609
|
+
if (legacyEvent2 === "step_started") return [fromLegacyStepStarted(event)];
|
|
610
|
+
if (legacyEvent2 === "step_completed") return [fromLegacyStepCompleted(event)];
|
|
611
|
+
if (legacyEvent2 === "outcome_observed") return [fromLegacyOutcomeObserved(event)];
|
|
612
612
|
if (event.kind === "RUN") {
|
|
613
613
|
return fromNativeRun(event);
|
|
614
614
|
}
|
|
@@ -5850,6 +5850,265 @@ function defaultSuiteConfigTemplate() {
|
|
|
5850
5850
|
};
|
|
5851
5851
|
}
|
|
5852
5852
|
|
|
5853
|
+
// packages/core/src/checks/logical-events.ts
|
|
5854
|
+
function isRecord7(value) {
|
|
5855
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
5856
|
+
}
|
|
5857
|
+
function legacyEvent(event) {
|
|
5858
|
+
const value = event.attributes?.legacyEvent;
|
|
5859
|
+
return typeof value === "string" ? value : void 0;
|
|
5860
|
+
}
|
|
5861
|
+
function stepIdOf(event) {
|
|
5862
|
+
const value = event.attributes?.stepId;
|
|
5863
|
+
if (typeof value === "string" && value.trim() !== "") return value;
|
|
5864
|
+
return void 0;
|
|
5865
|
+
}
|
|
5866
|
+
function cloneEvent(event) {
|
|
5867
|
+
return {
|
|
5868
|
+
...event,
|
|
5869
|
+
...event.attributes !== void 0 ? { attributes: { ...event.attributes } } : {},
|
|
5870
|
+
...event.error !== void 0 ? { error: { ...event.error } } : {},
|
|
5871
|
+
...event.tokenUsage !== void 0 ? { tokenUsage: { ...event.tokenUsage } } : {},
|
|
5872
|
+
...event.source !== void 0 ? { source: { ...event.source } } : {}
|
|
5873
|
+
};
|
|
5874
|
+
}
|
|
5875
|
+
function mergeAttributes(start, complete) {
|
|
5876
|
+
const merged = {
|
|
5877
|
+
...isRecord7(complete.attributes) ? complete.attributes : {},
|
|
5878
|
+
...isRecord7(start.attributes) ? start.attributes : {}
|
|
5879
|
+
};
|
|
5880
|
+
merged.legacyEvent = start.attributes?.legacyEvent ?? complete.attributes?.legacyEvent;
|
|
5881
|
+
merged.legacyCompleteEvent = complete.attributes?.legacyEvent;
|
|
5882
|
+
if (complete.attributes?.errorStack !== void 0) {
|
|
5883
|
+
merged.errorStack = complete.attributes.errorStack;
|
|
5884
|
+
}
|
|
5885
|
+
return Object.keys(merged).length > 0 ? merged : void 0;
|
|
5886
|
+
}
|
|
5887
|
+
function pairStartComplete(start, complete) {
|
|
5888
|
+
const attributes = mergeAttributes(start, complete);
|
|
5889
|
+
const paired = {
|
|
5890
|
+
...cloneEvent(start),
|
|
5891
|
+
status: complete.status,
|
|
5892
|
+
timestamp: complete.timestamp ?? start.timestamp,
|
|
5893
|
+
...complete.endedAt !== void 0 ? { endedAt: complete.endedAt } : {},
|
|
5894
|
+
...complete.durationMs !== void 0 ? { durationMs: complete.durationMs } : {},
|
|
5895
|
+
...complete.error !== void 0 ? { error: { ...complete.error } } : {},
|
|
5896
|
+
...complete.tokenUsage !== void 0 && start.tokenUsage === void 0 ? { tokenUsage: { ...complete.tokenUsage } } : {},
|
|
5897
|
+
...attributes !== void 0 ? { attributes } : {}
|
|
5898
|
+
};
|
|
5899
|
+
return {
|
|
5900
|
+
...paired,
|
|
5901
|
+
sourceEventIds: Object.freeze([start.eventId, complete.eventId]),
|
|
5902
|
+
projection: {
|
|
5903
|
+
paired: true,
|
|
5904
|
+
absorbedEventIds: Object.freeze([complete.eventId]),
|
|
5905
|
+
parentNormalized: false,
|
|
5906
|
+
...start.parentId !== void 0 ? { originalParentId: start.parentId } : {}
|
|
5907
|
+
}
|
|
5908
|
+
};
|
|
5909
|
+
}
|
|
5910
|
+
function asLogical(event, extras) {
|
|
5911
|
+
return {
|
|
5912
|
+
...cloneEvent(event),
|
|
5913
|
+
sourceEventIds: Object.freeze([event.eventId]),
|
|
5914
|
+
projection: {
|
|
5915
|
+
paired: false,
|
|
5916
|
+
absorbedEventIds: Object.freeze([]),
|
|
5917
|
+
parentNormalized: extras?.parentNormalized === true,
|
|
5918
|
+
...{}
|
|
5919
|
+
}
|
|
5920
|
+
};
|
|
5921
|
+
}
|
|
5922
|
+
function projectLogicalEvents(events) {
|
|
5923
|
+
const diagnostics = [];
|
|
5924
|
+
const byRun = /* @__PURE__ */ new Map();
|
|
5925
|
+
for (const event of events) {
|
|
5926
|
+
const list = byRun.get(event.runId) ?? [];
|
|
5927
|
+
list.push(event);
|
|
5928
|
+
byRun.set(event.runId, list);
|
|
5929
|
+
}
|
|
5930
|
+
const absorbedIds = /* @__PURE__ */ new Set();
|
|
5931
|
+
const logicalByRawId = /* @__PURE__ */ new Map();
|
|
5932
|
+
const stepIdToLogicalId = /* @__PURE__ */ new Map();
|
|
5933
|
+
const logical = [];
|
|
5934
|
+
const orderedRuns = [...byRun.keys()].sort((a, b) => a.localeCompare(b));
|
|
5935
|
+
for (const runId of orderedRuns) {
|
|
5936
|
+
const runEvents = byRun.get(runId) ?? [];
|
|
5937
|
+
const starts = [];
|
|
5938
|
+
const completes = [];
|
|
5939
|
+
const others = [];
|
|
5940
|
+
for (const event of runEvents) {
|
|
5941
|
+
const legacy = legacyEvent(event);
|
|
5942
|
+
if (legacy === "step_started" || legacy === "run_started" && event.status === "running") {
|
|
5943
|
+
starts.push(event);
|
|
5944
|
+
} else if (legacy === "step_completed" || legacy === "run_completed") {
|
|
5945
|
+
completes.push(event);
|
|
5946
|
+
} else {
|
|
5947
|
+
others.push(event);
|
|
5948
|
+
}
|
|
5949
|
+
}
|
|
5950
|
+
const usedCompletes = /* @__PURE__ */ new Set();
|
|
5951
|
+
for (const start of starts) {
|
|
5952
|
+
const stepId = stepIdOf(start);
|
|
5953
|
+
let match;
|
|
5954
|
+
if (legacyEvent(start) === "run_started") {
|
|
5955
|
+
const candidates = completes.filter(
|
|
5956
|
+
(c) => !usedCompletes.has(c.eventId) && legacyEvent(c) === "run_completed"
|
|
5957
|
+
);
|
|
5958
|
+
if (candidates.length > 1) {
|
|
5959
|
+
diagnostics.push({
|
|
5960
|
+
code: "AI_LOGICAL_PAIR_AMBIGUOUS",
|
|
5961
|
+
message: `Multiple run_completed rows for run ${runId}; using first by eventId.`,
|
|
5962
|
+
eventIds: candidates.map((c) => c.eventId)
|
|
5963
|
+
});
|
|
5964
|
+
candidates.sort((a, b) => a.eventId.localeCompare(b.eventId));
|
|
5965
|
+
}
|
|
5966
|
+
match = candidates[0];
|
|
5967
|
+
} else if (stepId) {
|
|
5968
|
+
const candidates = completes.filter(
|
|
5969
|
+
(c) => !usedCompletes.has(c.eventId) && legacyEvent(c) === "step_completed" && stepIdOf(c) === stepId
|
|
5970
|
+
);
|
|
5971
|
+
if (candidates.length > 1) {
|
|
5972
|
+
diagnostics.push({
|
|
5973
|
+
code: "AI_LOGICAL_PAIR_AMBIGUOUS",
|
|
5974
|
+
message: `Multiple step_completed rows for stepId ${stepId}; using first by eventId.`,
|
|
5975
|
+
eventIds: candidates.map((c) => c.eventId)
|
|
5976
|
+
});
|
|
5977
|
+
candidates.sort((a, b) => a.eventId.localeCompare(b.eventId));
|
|
5978
|
+
}
|
|
5979
|
+
match = candidates[0];
|
|
5980
|
+
}
|
|
5981
|
+
if (match) {
|
|
5982
|
+
usedCompletes.add(match.eventId);
|
|
5983
|
+
absorbedIds.add(match.eventId);
|
|
5984
|
+
const paired = pairStartComplete(start, match);
|
|
5985
|
+
logical.push(paired);
|
|
5986
|
+
logicalByRawId.set(start.eventId, paired);
|
|
5987
|
+
logicalByRawId.set(match.eventId, paired);
|
|
5988
|
+
if (stepId) stepIdToLogicalId.set(`${runId}:${stepId}`, paired.eventId);
|
|
5989
|
+
} else {
|
|
5990
|
+
diagnostics.push({
|
|
5991
|
+
code: "AI_LOGICAL_PAIR_UNMATCHED_START",
|
|
5992
|
+
message: `No matching complete for start ${start.eventId}.`,
|
|
5993
|
+
eventIds: [start.eventId]
|
|
5994
|
+
});
|
|
5995
|
+
const alone = asLogical(start);
|
|
5996
|
+
logical.push(alone);
|
|
5997
|
+
logicalByRawId.set(start.eventId, alone);
|
|
5998
|
+
if (stepId) stepIdToLogicalId.set(`${runId}:${stepId}`, alone.eventId);
|
|
5999
|
+
}
|
|
6000
|
+
}
|
|
6001
|
+
for (const complete of completes) {
|
|
6002
|
+
if (usedCompletes.has(complete.eventId)) continue;
|
|
6003
|
+
diagnostics.push({
|
|
6004
|
+
code: "AI_LOGICAL_PAIR_UNMATCHED_COMPLETE",
|
|
6005
|
+
message: `No matching start for complete ${complete.eventId}.`,
|
|
6006
|
+
eventIds: [complete.eventId]
|
|
6007
|
+
});
|
|
6008
|
+
const alone = asLogical(complete);
|
|
6009
|
+
logical.push(alone);
|
|
6010
|
+
logicalByRawId.set(complete.eventId, alone);
|
|
6011
|
+
const stepId = stepIdOf(complete);
|
|
6012
|
+
if (stepId && !stepIdToLogicalId.has(`${runId}:${stepId}`)) {
|
|
6013
|
+
stepIdToLogicalId.set(`${runId}:${stepId}`, alone.eventId);
|
|
6014
|
+
}
|
|
6015
|
+
}
|
|
6016
|
+
for (const event of others) {
|
|
6017
|
+
const alone = asLogical(event);
|
|
6018
|
+
logical.push(alone);
|
|
6019
|
+
logicalByRawId.set(event.eventId, alone);
|
|
6020
|
+
const stepId = stepIdOf(event);
|
|
6021
|
+
if (stepId && !stepIdToLogicalId.has(`${runId}:${stepId}`)) {
|
|
6022
|
+
stepIdToLogicalId.set(`${runId}:${stepId}`, alone.eventId);
|
|
6023
|
+
}
|
|
6024
|
+
}
|
|
6025
|
+
}
|
|
6026
|
+
const logicalById = new Map(logical.map((e) => [e.eventId, e]));
|
|
6027
|
+
const normalized = [];
|
|
6028
|
+
for (const event of logical) {
|
|
6029
|
+
const originalParentId = event.parentId;
|
|
6030
|
+
if (!originalParentId) {
|
|
6031
|
+
normalized.push(event);
|
|
6032
|
+
continue;
|
|
6033
|
+
}
|
|
6034
|
+
let nextParent = originalParentId;
|
|
6035
|
+
let remapped = false;
|
|
6036
|
+
const viaAbsorbed = logicalByRawId.get(originalParentId);
|
|
6037
|
+
if (viaAbsorbed && viaAbsorbed.eventId !== originalParentId) {
|
|
6038
|
+
nextParent = viaAbsorbed.eventId;
|
|
6039
|
+
remapped = true;
|
|
6040
|
+
} else if (!logicalById.has(originalParentId)) {
|
|
6041
|
+
const viaStep = stepIdToLogicalId.get(`${event.runId}:${originalParentId}`);
|
|
6042
|
+
if (viaStep) {
|
|
6043
|
+
nextParent = viaStep;
|
|
6044
|
+
remapped = true;
|
|
6045
|
+
}
|
|
6046
|
+
}
|
|
6047
|
+
if (!remapped) {
|
|
6048
|
+
if (!logicalById.has(originalParentId) && !logicalByRawId.has(originalParentId)) {
|
|
6049
|
+
const mapping = event.attributes?.parentMapping;
|
|
6050
|
+
const unresolved = mapping === "unresolved" || event.attributes?.parentUnresolved === true || event.attributes?.unresolvedParent === true || // LangGraph/framework scaffolding sentinel labels are not event ids.
|
|
6051
|
+
/^LangGraph$/i.test(originalParentId) || originalParentId.startsWith("unresolved:");
|
|
6052
|
+
if (!unresolved) {
|
|
6053
|
+
diagnostics.push({
|
|
6054
|
+
code: "AI_LOGICAL_PARENT_UNRESOLVED",
|
|
6055
|
+
message: `Parent ${originalParentId} unresolved for ${event.eventId}.`,
|
|
6056
|
+
eventIds: [event.eventId]
|
|
6057
|
+
});
|
|
6058
|
+
}
|
|
6059
|
+
}
|
|
6060
|
+
normalized.push(event);
|
|
6061
|
+
continue;
|
|
6062
|
+
}
|
|
6063
|
+
diagnostics.push({
|
|
6064
|
+
code: "AI_LOGICAL_PARENT_REMAPPED",
|
|
6065
|
+
message: `Remapped parent ${originalParentId} \u2192 ${nextParent} for ${event.eventId}.`,
|
|
6066
|
+
eventIds: [event.eventId]
|
|
6067
|
+
});
|
|
6068
|
+
normalized.push({
|
|
6069
|
+
...event,
|
|
6070
|
+
parentId: nextParent,
|
|
6071
|
+
projection: {
|
|
6072
|
+
...event.projection,
|
|
6073
|
+
parentNormalized: true,
|
|
6074
|
+
originalParentId
|
|
6075
|
+
}
|
|
6076
|
+
});
|
|
6077
|
+
}
|
|
6078
|
+
const rawIndex = new Map(events.map((e, i) => [e.eventId, i]));
|
|
6079
|
+
normalized.sort((a, b) => {
|
|
6080
|
+
const ai = rawIndex.get(a.sourceEventIds[0]) ?? 0;
|
|
6081
|
+
const bi = rawIndex.get(b.sourceEventIds[0]) ?? 0;
|
|
6082
|
+
return ai - bi || a.eventId.localeCompare(b.eventId);
|
|
6083
|
+
});
|
|
6084
|
+
return {
|
|
6085
|
+
logicalEvents: Object.freeze(normalized),
|
|
6086
|
+
diagnostics: Object.freeze(diagnostics)
|
|
6087
|
+
};
|
|
6088
|
+
}
|
|
6089
|
+
function resolveCanonicalToolName(event) {
|
|
6090
|
+
const attrs = event.attributes;
|
|
6091
|
+
const direct = pickString(attrs, ["toolName", "tool"]);
|
|
6092
|
+
if (direct) return direct;
|
|
6093
|
+
const metadata = attrs?.metadata;
|
|
6094
|
+
if (isRecord7(metadata)) {
|
|
6095
|
+
const nested = pickString(metadata, ["toolName", "tool"]);
|
|
6096
|
+
if (nested) return nested;
|
|
6097
|
+
}
|
|
6098
|
+
for (const prefix of ["tool:", "function:", "mcp-tools:"]) {
|
|
6099
|
+
if (event.name.startsWith(prefix)) return event.name.slice(prefix.length);
|
|
6100
|
+
}
|
|
6101
|
+
return event.name;
|
|
6102
|
+
}
|
|
6103
|
+
function pickString(record, keys) {
|
|
6104
|
+
if (!record) return void 0;
|
|
6105
|
+
for (const key of keys) {
|
|
6106
|
+
const value = record[key];
|
|
6107
|
+
if (typeof value === "string" && value.trim() !== "") return value.trim();
|
|
6108
|
+
}
|
|
6109
|
+
return void 0;
|
|
6110
|
+
}
|
|
6111
|
+
|
|
5853
6112
|
// packages/core/src/checks/index.ts
|
|
5854
6113
|
var SEVERITY_RANK = {
|
|
5855
6114
|
error: 0,
|
|
@@ -5908,7 +6167,11 @@ var DEFAULT_RAW_CONTENT_KEYS = [
|
|
|
5908
6167
|
"conversationtext",
|
|
5909
6168
|
"conversation_text"
|
|
5910
6169
|
];
|
|
5911
|
-
var DEFAULT_SAFE_RAW_CONTENT_PATH_PREFIXES = [
|
|
6170
|
+
var DEFAULT_SAFE_RAW_CONTENT_PATH_PREFIXES = [
|
|
6171
|
+
"tokenUsage",
|
|
6172
|
+
"usage",
|
|
6173
|
+
"tokens"
|
|
6174
|
+
];
|
|
5912
6175
|
var SAFE_USAGE_LEAF_KEYS = /* @__PURE__ */ new Set([
|
|
5913
6176
|
"input",
|
|
5914
6177
|
"output",
|
|
@@ -5984,10 +6247,13 @@ function buildFacts2(input, selectedRun) {
|
|
|
5984
6247
|
childrenByParentId.set(parentId, children);
|
|
5985
6248
|
}
|
|
5986
6249
|
}
|
|
6250
|
+
const projection = projectLogicalEvents(scopedEvents);
|
|
5987
6251
|
return {
|
|
5988
6252
|
format: input.read.format,
|
|
5989
6253
|
runs: Object.freeze([...input.read.runs]),
|
|
5990
6254
|
events: Object.freeze([...scopedEvents]),
|
|
6255
|
+
logicalEvents: projection.logicalEvents,
|
|
6256
|
+
logicalProjectionDiagnostics: projection.diagnostics,
|
|
5991
6257
|
readerWarnings: Object.freeze([...input.read.warnings]),
|
|
5992
6258
|
unsupportedFields: Object.freeze([...input.read.unsupportedFields]),
|
|
5993
6259
|
sourceFiles: Object.freeze([...input.read.sourceFiles]),
|
|
@@ -6180,7 +6446,10 @@ function failFinding(ruleId, message, evidence, expected, actual, meta) {
|
|
|
6180
6446
|
};
|
|
6181
6447
|
}
|
|
6182
6448
|
function toolName(event) {
|
|
6183
|
-
return
|
|
6449
|
+
return resolveCanonicalToolName(event);
|
|
6450
|
+
}
|
|
6451
|
+
function semanticEvents(context) {
|
|
6452
|
+
return context.logicalEvents ?? context.events;
|
|
6184
6453
|
}
|
|
6185
6454
|
function llmModel(event) {
|
|
6186
6455
|
return stringAttr(event, ["model", "modelId", "responseModelId", "modelName", "model_name"]) ?? stripPrefix(event.name, ["llm:", "generation:", "transcription:", "speech:"]);
|
|
@@ -6195,11 +6464,11 @@ function retryCount(event) {
|
|
|
6195
6464
|
return numericAttr(event, ["retryCount", "retryAttempt", "retry_attempt", "attempt"]);
|
|
6196
6465
|
}
|
|
6197
6466
|
function finishedEvents(context, kind) {
|
|
6198
|
-
return context.
|
|
6467
|
+
return semanticEvents(context).filter(
|
|
6199
6468
|
(event) => (kind === void 0 || event.kind === kind) && event.status !== "running"
|
|
6200
6469
|
);
|
|
6201
6470
|
}
|
|
6202
|
-
function
|
|
6471
|
+
function isRecord8(value) {
|
|
6203
6472
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
6204
6473
|
}
|
|
6205
6474
|
function eventMap(events) {
|
|
@@ -6250,7 +6519,7 @@ function pushValueEntries(entries, event, value, path14, key, depth = 0) {
|
|
|
6250
6519
|
}
|
|
6251
6520
|
return;
|
|
6252
6521
|
}
|
|
6253
|
-
if (!
|
|
6522
|
+
if (!isRecord8(value)) return;
|
|
6254
6523
|
for (const nestedKey of Object.keys(value).sort((a, b) => a.localeCompare(b))) {
|
|
6255
6524
|
pushValueEntries(
|
|
6256
6525
|
entries,
|
|
@@ -6330,14 +6599,11 @@ function signalName(event, attributeKeys, prefixes) {
|
|
|
6330
6599
|
return stringAttr(event, attributeKeys) ?? stripPrefix(event.name, prefixes);
|
|
6331
6600
|
}
|
|
6332
6601
|
function guardrailEvents(context) {
|
|
6333
|
-
return
|
|
6602
|
+
return finishedEvents(context).filter((event) => {
|
|
6334
6603
|
const name = event.name.toLowerCase();
|
|
6335
6604
|
if (name.startsWith("guardrail:") || name.includes(".guardrail.")) return true;
|
|
6336
6605
|
return stringAttr(event, ["guardrailName", "guardrail", "guardrailId"]) !== void 0;
|
|
6337
6606
|
});
|
|
6338
|
-
function finishedEvents2() {
|
|
6339
|
-
return context.events.filter((event) => event.status !== "running");
|
|
6340
|
-
}
|
|
6341
6607
|
}
|
|
6342
6608
|
function retryValue(event) {
|
|
6343
6609
|
return retryCount(event) ?? 0;
|
|
@@ -6358,7 +6624,7 @@ function treeShape(nodes) {
|
|
|
6358
6624
|
return lines;
|
|
6359
6625
|
}
|
|
6360
6626
|
function statusShape(context) {
|
|
6361
|
-
return context.
|
|
6627
|
+
return semanticEvents(context).map((event) => `${event.kind}:${event.name}:${event.status ?? "unknown"}`).sort((a, b) => a.localeCompare(b));
|
|
6362
6628
|
}
|
|
6363
6629
|
function toolShape(context) {
|
|
6364
6630
|
return finishedEvents(context, "TOOL").map(
|
|
@@ -6384,7 +6650,7 @@ function llmShape(context) {
|
|
|
6384
6650
|
);
|
|
6385
6651
|
}
|
|
6386
6652
|
function errorShape(context) {
|
|
6387
|
-
return context.
|
|
6653
|
+
return semanticEvents(context).filter((event) => event.status === "error" || event.error !== void 0).map(
|
|
6388
6654
|
(event) => [
|
|
6389
6655
|
event.kind,
|
|
6390
6656
|
event.name,
|
|
@@ -6402,7 +6668,7 @@ function guardrailShape(context) {
|
|
|
6402
6668
|
return guardrailEvents(context).map((event) => signalName(event, ["guardrailName", "guardrail", "guardrailId"], ["guardrail:"])).sort((a, b) => a.localeCompare(b));
|
|
6403
6669
|
}
|
|
6404
6670
|
function firstEvidenceForKind(context, kind, path14) {
|
|
6405
|
-
const event = context.
|
|
6671
|
+
const event = semanticEvents(context).find((candidate) => candidate.kind === kind);
|
|
6406
6672
|
return event ? [eventEvidence(event, path14)] : runEvidence(context.selectedRun);
|
|
6407
6673
|
}
|
|
6408
6674
|
function baselineDiffFinding(message, evidence, expected, actual) {
|
|
@@ -6430,7 +6696,7 @@ function createRunStatusRule(options = {}) {
|
|
|
6430
6696
|
);
|
|
6431
6697
|
}
|
|
6432
6698
|
if (!allowIncomplete) {
|
|
6433
|
-
const running = context.
|
|
6699
|
+
const running = semanticEvents(context).filter((event) => event.status === "running");
|
|
6434
6700
|
if (running.length > 0) {
|
|
6435
6701
|
findings.push(
|
|
6436
6702
|
failFinding(
|
|
@@ -6473,7 +6739,7 @@ function createMaxStepDurationRule(options) {
|
|
|
6473
6739
|
category: "run",
|
|
6474
6740
|
defaultSeverity: "error",
|
|
6475
6741
|
evaluate(context) {
|
|
6476
|
-
const over = context.
|
|
6742
|
+
const over = semanticEvents(context).filter((event) => {
|
|
6477
6743
|
const duration = eventDurationMs(event);
|
|
6478
6744
|
return duration !== void 0 && duration > options.maxDurationMs;
|
|
6479
6745
|
});
|
|
@@ -6502,7 +6768,7 @@ function createStallDetectionRule(options = {}) {
|
|
|
6502
6768
|
defaultSeverity: "warning",
|
|
6503
6769
|
evaluate(context) {
|
|
6504
6770
|
const findings = [];
|
|
6505
|
-
const running = context.
|
|
6771
|
+
const running = semanticEvents(context).filter((event) => event.status === "running");
|
|
6506
6772
|
if (running.length > 0) {
|
|
6507
6773
|
findings.push(
|
|
6508
6774
|
failFinding(
|
|
@@ -6515,7 +6781,7 @@ function createStallDetectionRule(options = {}) {
|
|
|
6515
6781
|
);
|
|
6516
6782
|
}
|
|
6517
6783
|
if (requireEndedAt) {
|
|
6518
|
-
const incomplete = context.
|
|
6784
|
+
const incomplete = semanticEvents(context).filter(
|
|
6519
6785
|
(event) => event.startedAt !== void 0 && event.endedAt === void 0 && event.status !== "running"
|
|
6520
6786
|
);
|
|
6521
6787
|
if (incomplete.length > 0) {
|
|
@@ -6553,7 +6819,7 @@ function createRequireCompletedRule() {
|
|
|
6553
6819
|
)
|
|
6554
6820
|
);
|
|
6555
6821
|
}
|
|
6556
|
-
const running = context.
|
|
6822
|
+
const running = semanticEvents(context).filter((event) => event.status === "running");
|
|
6557
6823
|
if (running.length > 0) {
|
|
6558
6824
|
findings.push(
|
|
6559
6825
|
failFinding(
|
|
@@ -6725,8 +6991,8 @@ function createStructureOrphanRule(options = {}) {
|
|
|
6725
6991
|
category: "structure",
|
|
6726
6992
|
defaultSeverity: "error",
|
|
6727
6993
|
evaluate(context) {
|
|
6728
|
-
const byId = eventMap(context
|
|
6729
|
-
const orphans = context.
|
|
6994
|
+
const byId = eventMap(semanticEvents(context));
|
|
6995
|
+
const orphans = semanticEvents(context).filter((event) => {
|
|
6730
6996
|
if (!event.parentId || byId.has(event.parentId)) return false;
|
|
6731
6997
|
return !(allowMarkedUnresolved && parentMarkedUnresolved(event));
|
|
6732
6998
|
});
|
|
@@ -6749,10 +7015,10 @@ function createStructureCycleRule() {
|
|
|
6749
7015
|
category: "structure",
|
|
6750
7016
|
defaultSeverity: "error",
|
|
6751
7017
|
evaluate(context) {
|
|
6752
|
-
const byId = eventMap(context
|
|
7018
|
+
const byId = eventMap(semanticEvents(context));
|
|
6753
7019
|
const seenCycles = /* @__PURE__ */ new Set();
|
|
6754
7020
|
const findings = [];
|
|
6755
|
-
for (const event of [...context
|
|
7021
|
+
for (const event of [...semanticEvents(context)].sort((a, b) => a.eventId.localeCompare(b.eventId))) {
|
|
6756
7022
|
const path14 = [];
|
|
6757
7023
|
const seenAt = /* @__PURE__ */ new Map();
|
|
6758
7024
|
let current = event;
|
|
@@ -6790,10 +7056,10 @@ function createStructureRelationshipRule(options = {}) {
|
|
|
6790
7056
|
category: "structure",
|
|
6791
7057
|
defaultSeverity: "error",
|
|
6792
7058
|
evaluate(context) {
|
|
6793
|
-
const byId = eventMap(context
|
|
7059
|
+
const byId = eventMap(semanticEvents(context));
|
|
6794
7060
|
const findings = [];
|
|
6795
7061
|
const minConfidence = options.minConfidence;
|
|
6796
|
-
for (const event of context
|
|
7062
|
+
for (const event of semanticEvents(context)) {
|
|
6797
7063
|
if (minConfidence && CONFIDENCE_RANK[event.confidence] < CONFIDENCE_RANK[minConfidence]) {
|
|
6798
7064
|
findings.push(
|
|
6799
7065
|
failFinding(
|
|
@@ -6861,7 +7127,7 @@ function createStructureParallelWidthRule(options) {
|
|
|
6861
7127
|
defaultSeverity: "error",
|
|
6862
7128
|
evaluate(context) {
|
|
6863
7129
|
const findings = [];
|
|
6864
|
-
const byId = eventMap(context
|
|
7130
|
+
const byId = eventMap(semanticEvents(context));
|
|
6865
7131
|
if (options.maxChildren !== void 0) {
|
|
6866
7132
|
for (const [parentId, children] of context.childrenByParentId.entries()) {
|
|
6867
7133
|
if (children.length <= options.maxChildren) continue;
|
|
@@ -6888,7 +7154,7 @@ function createStructureParallelWidthRule(options) {
|
|
|
6888
7154
|
}
|
|
6889
7155
|
}
|
|
6890
7156
|
if (options.maxConcurrent !== void 0) {
|
|
6891
|
-
const intervals = context.
|
|
7157
|
+
const intervals = semanticEvents(context).map((event) => ({ event, start: eventStartMs(event), end: eventEndMs(event) })).filter(
|
|
6892
7158
|
(item) => item.start !== void 0 && item.end !== void 0 && item.end > item.start
|
|
6893
7159
|
);
|
|
6894
7160
|
const points = intervals.flatMap((item) => [
|
|
@@ -7081,7 +7347,7 @@ function createSafetyOversizedAttributeRule(options) {
|
|
|
7081
7347
|
)
|
|
7082
7348
|
);
|
|
7083
7349
|
}
|
|
7084
|
-
if (
|
|
7350
|
+
if (isRecord8(entry.value) && options.maxObjectKeys !== void 0 && Object.keys(entry.value).length > options.maxObjectKeys) {
|
|
7085
7351
|
findings.push(
|
|
7086
7352
|
failFinding(
|
|
7087
7353
|
"safety.oversizedAttribute",
|
|
@@ -7332,14 +7598,14 @@ function runTraceChecks(input, options = {}) {
|
|
|
7332
7598
|
}
|
|
7333
7599
|
|
|
7334
7600
|
// packages/core/src/persisted/token-usage.ts
|
|
7335
|
-
function
|
|
7601
|
+
function isRecord9(value) {
|
|
7336
7602
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
7337
7603
|
}
|
|
7338
7604
|
function nonNegativeFinite(value) {
|
|
7339
7605
|
return typeof value === "number" && Number.isFinite(value) && value >= 0 ? value : void 0;
|
|
7340
7606
|
}
|
|
7341
7607
|
function normalizeTokenUsage(value) {
|
|
7342
|
-
if (!
|
|
7608
|
+
if (!isRecord9(value)) return void 0;
|
|
7343
7609
|
const input = nonNegativeFinite(value.input);
|
|
7344
7610
|
const output = nonNegativeFinite(value.output);
|
|
7345
7611
|
const suppliedTotal = nonNegativeFinite(value.total);
|
|
@@ -8108,7 +8374,7 @@ function persistedEventsForParsedTrace(parsed) {
|
|
|
8108
8374
|
sourceName: "agent-inspect-jsonl-reader"
|
|
8109
8375
|
});
|
|
8110
8376
|
}
|
|
8111
|
-
function
|
|
8377
|
+
function isRecord10(value) {
|
|
8112
8378
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
8113
8379
|
}
|
|
8114
8380
|
function isNonEmptyString4(value) {
|
|
@@ -8123,13 +8389,13 @@ function readStringField(record, keys) {
|
|
|
8123
8389
|
}
|
|
8124
8390
|
function readRecordField(record, key) {
|
|
8125
8391
|
const value = record[key];
|
|
8126
|
-
return
|
|
8392
|
+
return isRecord10(value) ? value : void 0;
|
|
8127
8393
|
}
|
|
8128
8394
|
function parseJsonDocument(content) {
|
|
8129
8395
|
return JSON.parse(content);
|
|
8130
8396
|
}
|
|
8131
8397
|
function looksLikeOpenInferenceSpan(value) {
|
|
8132
|
-
if (!
|
|
8398
|
+
if (!isRecord10(value)) return false;
|
|
8133
8399
|
const attributes = readRecordField(value, "attributes");
|
|
8134
8400
|
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);
|
|
8135
8401
|
}
|
|
@@ -8154,7 +8420,7 @@ function extractOpenInferenceDocument(root) {
|
|
|
8154
8420
|
unsupportedFields
|
|
8155
8421
|
};
|
|
8156
8422
|
}
|
|
8157
|
-
if (!
|
|
8423
|
+
if (!isRecord10(root)) return void 0;
|
|
8158
8424
|
const rootFormat = root.format;
|
|
8159
8425
|
const rootCompatibility = root.compatibility;
|
|
8160
8426
|
const version = typeof root.version === "string" && root.version.trim() !== "" ? root.version : void 0;
|
|
@@ -8294,7 +8560,7 @@ function summarizeAttributeValue(value) {
|
|
|
8294
8560
|
if (Array.isArray(value)) {
|
|
8295
8561
|
return { type: "array", length: value.length };
|
|
8296
8562
|
}
|
|
8297
|
-
if (
|
|
8563
|
+
if (isRecord10(value)) {
|
|
8298
8564
|
return { type: "object", keyCount: Object.keys(value).length };
|
|
8299
8565
|
}
|
|
8300
8566
|
if (value === null) {
|
|
@@ -8381,7 +8647,7 @@ function mapOpenInferenceKind(span, attributes, pathPrefix) {
|
|
|
8381
8647
|
}
|
|
8382
8648
|
}
|
|
8383
8649
|
function mapOpenInferenceStatus(status) {
|
|
8384
|
-
if (!
|
|
8650
|
+
if (!isRecord10(status)) return void 0;
|
|
8385
8651
|
const rawCode = status.code;
|
|
8386
8652
|
if (typeof rawCode !== "string") return void 0;
|
|
8387
8653
|
switch (rawCode.toUpperCase()) {
|
|
@@ -8481,7 +8747,7 @@ function mapOpenInferenceSpan(span, index, version) {
|
|
|
8481
8747
|
warnings.push(...kindWarnings);
|
|
8482
8748
|
const status = mapOpenInferenceStatus(span.status);
|
|
8483
8749
|
const tokenUsage = readOpenInferenceTokenUsage(rawAttributes);
|
|
8484
|
-
const errorMessage =
|
|
8750
|
+
const errorMessage = isRecord10(span.status) && typeof span.status.message === "string" ? span.status.message : void 0;
|
|
8485
8751
|
const event = {
|
|
8486
8752
|
schemaVersion: "0.2",
|
|
8487
8753
|
eventId: typeof rawAttributes["agent_inspect.event_id"] === "string" ? rawAttributes["agent_inspect.event_id"] : spanId,
|
|
@@ -8627,7 +8893,7 @@ var openInferenceJsonReader = {
|
|
|
8627
8893
|
}
|
|
8628
8894
|
};
|
|
8629
8895
|
function parseOtlpAnyValue(value, field, warnings, unsupportedFields) {
|
|
8630
|
-
if (!
|
|
8896
|
+
if (!isRecord10(value)) {
|
|
8631
8897
|
unsupportedFields.push(field);
|
|
8632
8898
|
warnings.push({
|
|
8633
8899
|
code: "otlp_attribute_value_invalid",
|
|
@@ -8649,15 +8915,15 @@ function parseOtlpAnyValue(value, field, warnings, unsupportedFields) {
|
|
|
8649
8915
|
if (typeof value.doubleValue === "number" && Number.isFinite(value.doubleValue)) {
|
|
8650
8916
|
return value.doubleValue;
|
|
8651
8917
|
}
|
|
8652
|
-
if (
|
|
8918
|
+
if (isRecord10(value.arrayValue) && Array.isArray(value.arrayValue.values)) {
|
|
8653
8919
|
return value.arrayValue.values.map(
|
|
8654
8920
|
(item, index) => parseOtlpAnyValue(item, `${field}.arrayValue.values[${index}]`, warnings, unsupportedFields)
|
|
8655
8921
|
);
|
|
8656
8922
|
}
|
|
8657
|
-
if (
|
|
8923
|
+
if (isRecord10(value.kvlistValue) && Array.isArray(value.kvlistValue.values)) {
|
|
8658
8924
|
const out = {};
|
|
8659
8925
|
for (const [index, item] of value.kvlistValue.values.entries()) {
|
|
8660
|
-
if (!
|
|
8926
|
+
if (!isRecord10(item) || typeof item.key !== "string") {
|
|
8661
8927
|
unsupportedFields.push(`${field}.kvlistValue.values[${index}]`);
|
|
8662
8928
|
continue;
|
|
8663
8929
|
}
|
|
@@ -8708,7 +8974,7 @@ function parseOtlpAttributes(value, pathPrefix) {
|
|
|
8708
8974
|
}
|
|
8709
8975
|
for (const [index, item] of value.entries()) {
|
|
8710
8976
|
const field = `${pathPrefix}[${index}]`;
|
|
8711
|
-
if (!
|
|
8977
|
+
if (!isRecord10(item) || typeof item.key !== "string") {
|
|
8712
8978
|
unsupportedFields.push(field);
|
|
8713
8979
|
warnings.push({
|
|
8714
8980
|
code: "otlp_attribute_invalid",
|
|
@@ -8731,16 +8997,16 @@ function parseOtlpAttributes(value, pathPrefix) {
|
|
|
8731
8997
|
return { attributes, warnings, unsupportedFields };
|
|
8732
8998
|
}
|
|
8733
8999
|
function looksLikeOtlpSpan(value) {
|
|
8734
|
-
return
|
|
9000
|
+
return isRecord10(value) && readStringField(value, ["traceId"]) !== void 0 && readStringField(value, ["spanId"]) !== void 0 && readStringField(value, ["name"]) !== void 0;
|
|
8735
9001
|
}
|
|
8736
9002
|
function extractOtlpDocument(root) {
|
|
8737
|
-
if (!
|
|
9003
|
+
if (!isRecord10(root) || !Array.isArray(root.resourceSpans)) return void 0;
|
|
8738
9004
|
const spans = [];
|
|
8739
9005
|
const warnings = [];
|
|
8740
9006
|
const unsupportedFields = [];
|
|
8741
9007
|
for (const [resourceIndex, resourceSpan] of root.resourceSpans.entries()) {
|
|
8742
9008
|
const resourcePath = `resourceSpans[${resourceIndex}]`;
|
|
8743
|
-
if (!
|
|
9009
|
+
if (!isRecord10(resourceSpan)) {
|
|
8744
9010
|
unsupportedFields.push(resourcePath);
|
|
8745
9011
|
continue;
|
|
8746
9012
|
}
|
|
@@ -8763,7 +9029,7 @@ function extractOtlpDocument(root) {
|
|
|
8763
9029
|
}
|
|
8764
9030
|
for (const [scopeIndex, scopeSpan] of resourceSpan.scopeSpans.entries()) {
|
|
8765
9031
|
const scopePath = `${resourcePath}.scopeSpans[${scopeIndex}]`;
|
|
8766
|
-
if (!
|
|
9032
|
+
if (!isRecord10(scopeSpan)) {
|
|
8767
9033
|
unsupportedFields.push(scopePath);
|
|
8768
9034
|
continue;
|
|
8769
9035
|
}
|
|
@@ -8830,7 +9096,7 @@ function extractOtlpDocument(root) {
|
|
|
8830
9096
|
};
|
|
8831
9097
|
}
|
|
8832
9098
|
function mapOtlpStatus(status) {
|
|
8833
|
-
if (!
|
|
9099
|
+
if (!isRecord10(status)) return void 0;
|
|
8834
9100
|
const rawCode = status.code;
|
|
8835
9101
|
if (typeof rawCode !== "string") return void 0;
|
|
8836
9102
|
switch (rawCode.toUpperCase()) {
|
|
@@ -8930,7 +9196,7 @@ function mapOtlpEvents(value, pathPrefix) {
|
|
|
8930
9196
|
const events = [];
|
|
8931
9197
|
for (const [index, event] of value.entries()) {
|
|
8932
9198
|
const eventPath = `${pathPrefix}[${index}]`;
|
|
8933
|
-
if (!
|
|
9199
|
+
if (!isRecord10(event)) {
|
|
8934
9200
|
unsupportedFields.push(eventPath);
|
|
8935
9201
|
continue;
|
|
8936
9202
|
}
|
|
@@ -9068,7 +9334,7 @@ function mapOtlpSpan(context) {
|
|
|
9068
9334
|
warnings.push(...kindWarnings);
|
|
9069
9335
|
const status = mapOtlpStatus(span.status);
|
|
9070
9336
|
const tokenUsage = readOtlpTokenUsage(parsedSpanAttributes.attributes);
|
|
9071
|
-
const errorMessage =
|
|
9337
|
+
const errorMessage = isRecord10(span.status) && typeof span.status.message === "string" ? span.status.message : void 0;
|
|
9072
9338
|
const event = {
|
|
9073
9339
|
schemaVersion: "0.2",
|
|
9074
9340
|
eventId: typeof parsedSpanAttributes.attributes["agent_inspect.event_id"] === "string" ? parsedSpanAttributes.attributes["agent_inspect.event_id"] : spanId,
|
|
@@ -10754,5 +11020,5 @@ function renderGateReport(result, options = {}) {
|
|
|
10754
11020
|
}
|
|
10755
11021
|
|
|
10756
11022
|
export { COHORT_METRIC_IDS, DEFAULT_SUITE_ARTIFACTS_DIR, EVIDENCE_FORMAT_VERSION, EVIDENCE_HTML_FILENAME, EVIDENCE_MANIFEST_FILENAME, Redactor, TraceDirectory, TraceReadError, TreeBuilder, aggregateBundleSafeStatus, aggregateSessionCheckResults, analyzeCohort, applyProfileMetadataCaps, assertBundlePathContained, assertEvidenceRelativePath, buildActivitySummary, buildBundleMetadata, buildBundleSummaryMarkdown, buildEvidenceCausalFailureViewHtml, buildEvidenceCiPackage, buildEvidenceCircuitViewHtml, buildEvidenceContractsViewHtml, buildEvidenceDiffViewHtml, buildEvidenceHtmlShell, buildEvidenceManifest, buildEvidenceOutcomesViewHtml, buildEvidenceProvenanceViewHtml, buildEvidenceSafetyViewHtml, buildEvidenceTimelineViewHtml, buildEvidenceToolsLlmViewHtml, buildEvidenceTreeViewHtml, buildLocalExplanation, buildPlaceholderArtifact, buildRunSummary, buildRunTimeline, buildRunWhatSummary, buildSessionIndex, buildTraceStats, buildZipArchive, bundleFailsOnSafety, bundleRunAssetRelativePath, collectTraceSchemaVersions, compactAttributes, createBaselineRegressionRule, createLlmUsageRule, createMaxStepDurationRule, createObservedOutcomeRule, createRequireCompletedRule, createRunDepthRule, createRunDurationRule, createRunStatusRule, createSafetyOversizedAttributeRule, createSafetyRawContentRule, createSafetyRedactionRule, createSafetySecretPatternRule, createStallDetectionRule, createStructureCycleRule, createStructureOrphanRule, createStructureParallelWidthRule, createStructureRelationshipRule, createToolUsageRule, defaultBundleOutputPath, defaultSuiteConfigTemplate, diffRuns, diffTraceEvents, enrichSessionRunRecord, escapeHtml, escapeMarkdown, extractMetadata, extractOutcomesFromTraceEvents, filterMetasBySessionScope, filterTraces, flattenTree, formatDuration2 as formatDuration, formatTimestamp, gateHasThresholds, getIndent, getTraceFilePath, inferEvidenceFileRole, isAgentInspectTrace, isPersistedInspectEvent, loadSessionRunRecords, loadSuiteConfig, loadTraceMetadataList, manualTraceEventsToComparableRun, nanoid, normalizeBundleOutputPath, openTrace, parseCohortMetricList, parseDuration, parseDurationFilter, parseGateList, parseTraceJsonl, persistedInspectEventsToTraceEvents, renderActivitySummaryHuman, renderCohortReport, renderErrorLine, renderGateReport, renderObservedOutcomesHtml, renderObservedOutcomesMarkdown, renderRunDiff, renderRunWhat, renderStepLine, renderSuiteReport, renderTimeline, renderTraceStats, resolveBundleRunIds, resolveRedactionProfile, resolveSuiteTemplate, resolveTraceDir, runGate, runSuite, runTraceChecks, safeString, sanitizeBundleRunId, searchTraces, serializeEvidenceManifest, sha256Hex, stableJson, summarizeObservedOutcomes, traceEventToPersistedInspectEvent, truncateName, truncateStringForProfile, validateEvent, validateSuiteConfig, verifyEvidenceDirectory, zeroKinds };
|
|
10757
|
-
//# sourceMappingURL=chunk-
|
|
10758
|
-
//# sourceMappingURL=chunk-
|
|
11023
|
+
//# sourceMappingURL=chunk-QOKTMZAY.mjs.map
|
|
11024
|
+
//# sourceMappingURL=chunk-QOKTMZAY.mjs.map
|