agent-inspect 6.18.0 → 6.19.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 +6 -0
- package/README.md +1 -1
- package/docs/API.md +2 -1
- package/package.json +1 -1
- package/packages/cli/dist/{chunk-S4TLTLXN.mjs → chunk-R7Y5SGH5.mjs} +348 -27
- package/packages/cli/dist/chunk-R7Y5SGH5.mjs.map +1 -0
- package/packages/cli/dist/index.cjs +375 -46
- package/packages/cli/dist/index.cjs.map +1 -1
- package/packages/cli/dist/index.mjs +6 -5
- package/packages/cli/dist/index.mjs.map +1 -1
- package/packages/cli/dist/{src-R6V5EZZH.mjs → src-T4EZERCX.mjs} +3 -3
- package/packages/cli/dist/{src-R6V5EZZH.mjs.map → src-T4EZERCX.mjs.map} +1 -1
- package/packages/core/dist/advanced.cjs.map +1 -1
- package/packages/core/dist/advanced.d.cts +13 -2
- package/packages/core/dist/advanced.d.ts +13 -2
- package/packages/core/dist/advanced.mjs +1 -1
- package/packages/core/dist/advanced.mjs.map +1 -1
- package/packages/core/dist/checks.cjs +334 -5
- package/packages/core/dist/checks.cjs.map +1 -1
- package/packages/core/dist/checks.d.cts +81 -4
- package/packages/core/dist/checks.d.ts +81 -4
- package/packages/core/dist/checks.mjs +1 -1
- package/packages/core/dist/{chunk-LQC7IED3.mjs → chunk-NABMW5DX.mjs} +336 -8
- package/packages/core/dist/chunk-NABMW5DX.mjs.map +1 -0
- package/packages/core/dist/{index-B9ZGvUVL.d.ts → index-AMAGuO_i.d.ts} +1 -1
- package/packages/core/dist/{index-DWu54Y28.d.cts → index-DCR816Yt.d.cts} +2 -2
- package/packages/core/dist/{index-DlwbVqEs.d.ts → index-DKwuGSe-.d.ts} +2 -2
- package/packages/core/dist/{index-B259NKkH.d.cts → index-vqr-g6ev.d.cts} +1 -1
- package/packages/core/dist/readers.d.cts +1 -1
- package/packages/core/dist/readers.d.ts +1 -1
- package/packages/cli/dist/chunk-S4TLTLXN.mjs.map +0 -1
- package/packages/core/dist/chunk-LQC7IED3.mjs.map +0 -1
|
@@ -6820,6 +6820,330 @@ var init_logical_events = __esm({
|
|
|
6820
6820
|
}
|
|
6821
6821
|
});
|
|
6822
6822
|
|
|
6823
|
+
// packages/core/src/checks/derived-failure.ts
|
|
6824
|
+
function isRecord8(value) {
|
|
6825
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
6826
|
+
}
|
|
6827
|
+
function pickString2(record, keys) {
|
|
6828
|
+
if (!record) return void 0;
|
|
6829
|
+
for (const key of keys) {
|
|
6830
|
+
const value = record[key];
|
|
6831
|
+
if (typeof value === "string" && value.trim() !== "") return value;
|
|
6832
|
+
}
|
|
6833
|
+
return void 0;
|
|
6834
|
+
}
|
|
6835
|
+
function pickNumber(record, keys) {
|
|
6836
|
+
if (!record) return void 0;
|
|
6837
|
+
for (const key of keys) {
|
|
6838
|
+
const value = record[key];
|
|
6839
|
+
if (typeof value === "number" && Number.isFinite(value) && value > 0) {
|
|
6840
|
+
return value;
|
|
6841
|
+
}
|
|
6842
|
+
}
|
|
6843
|
+
return void 0;
|
|
6844
|
+
}
|
|
6845
|
+
function eventMetadata(event) {
|
|
6846
|
+
const attrs = isRecord8(event.attributes) ? event.attributes : void 0;
|
|
6847
|
+
const nested = attrs !== void 0 && isRecord8(attrs.metadata) ? attrs.metadata : void 0;
|
|
6848
|
+
return {
|
|
6849
|
+
...attrs ?? {},
|
|
6850
|
+
...nested ?? {}
|
|
6851
|
+
};
|
|
6852
|
+
}
|
|
6853
|
+
function canonicalName(event) {
|
|
6854
|
+
if (event.kind === "TOOL") return resolveCanonicalToolName(event);
|
|
6855
|
+
return event.name;
|
|
6856
|
+
}
|
|
6857
|
+
function linkKeys(event) {
|
|
6858
|
+
const meta2 = eventMetadata(event);
|
|
6859
|
+
const keys = [];
|
|
6860
|
+
for (const key of ["linkedStepId", "toolCallId", "mcpToolCallId"]) {
|
|
6861
|
+
const value = pickString2(meta2, [key]);
|
|
6862
|
+
if (value !== void 0) keys.push(`${key}:${value}`);
|
|
6863
|
+
}
|
|
6864
|
+
const stepId = pickString2(meta2, ["stepId"]);
|
|
6865
|
+
if (stepId !== void 0) keys.push(`stepId:${stepId}`);
|
|
6866
|
+
return keys;
|
|
6867
|
+
}
|
|
6868
|
+
function buildRunContexts(logicalEvents) {
|
|
6869
|
+
const byRun = /* @__PURE__ */ new Map();
|
|
6870
|
+
for (const event of logicalEvents) {
|
|
6871
|
+
const existing = byRun.get(event.runId) ?? {
|
|
6872
|
+
runId: event.runId,
|
|
6873
|
+
name: event.name
|
|
6874
|
+
};
|
|
6875
|
+
const meta2 = eventMetadata(event);
|
|
6876
|
+
if (event.kind === "RUN" || existing.name === event.runId) {
|
|
6877
|
+
existing.name = event.name || existing.name;
|
|
6878
|
+
}
|
|
6879
|
+
if (event.kind === "RUN" && event.status !== void 0 && event.status !== "running") {
|
|
6880
|
+
existing.status = event.status;
|
|
6881
|
+
}
|
|
6882
|
+
existing.retryOf ??= pickString2(meta2, ["retryOf"]);
|
|
6883
|
+
existing.attempt ??= pickNumber(meta2, ["attempt", "retryAttempt", "retryCount"]);
|
|
6884
|
+
existing.sessionId ??= pickString2(meta2, ["sessionId", "conversationId"]);
|
|
6885
|
+
existing.groupId ??= pickString2(meta2, ["groupId"]);
|
|
6886
|
+
existing.parentGroupId ??= pickString2(meta2, ["parentGroupId"]);
|
|
6887
|
+
existing.fallbackOf ??= pickString2(meta2, ["fallbackOf", "fallbackFrom"]);
|
|
6888
|
+
byRun.set(event.runId, existing);
|
|
6889
|
+
}
|
|
6890
|
+
return byRun;
|
|
6891
|
+
}
|
|
6892
|
+
function sameCorrelationScope(a, b) {
|
|
6893
|
+
if (a.sessionId && b.sessionId && a.sessionId === b.sessionId) return true;
|
|
6894
|
+
if (a.groupId && b.groupId && a.groupId === b.groupId) return true;
|
|
6895
|
+
if (a.parentGroupId && b.parentGroupId && a.parentGroupId === b.parentGroupId) {
|
|
6896
|
+
return true;
|
|
6897
|
+
}
|
|
6898
|
+
return false;
|
|
6899
|
+
}
|
|
6900
|
+
function isSuccessful(event) {
|
|
6901
|
+
return event.status === "ok";
|
|
6902
|
+
}
|
|
6903
|
+
function isFailure(event) {
|
|
6904
|
+
return event.status === "error";
|
|
6905
|
+
}
|
|
6906
|
+
function compareEventOrder(a, b) {
|
|
6907
|
+
const byTime = a.timestamp.localeCompare(b.timestamp);
|
|
6908
|
+
if (byTime !== 0) return byTime;
|
|
6909
|
+
return a.eventId.localeCompare(b.eventId);
|
|
6910
|
+
}
|
|
6911
|
+
function collectCandidates(failure, logicalEvents, runs) {
|
|
6912
|
+
const failureRun = runs.get(failure.runId);
|
|
6913
|
+
const failureLinks = new Set(linkKeys(failure));
|
|
6914
|
+
const failureName = canonicalName(failure);
|
|
6915
|
+
const failureAttempt = pickNumber(eventMetadata(failure), ["attempt", "retryAttempt", "retryCount"]) ?? failureRun?.attempt;
|
|
6916
|
+
const candidates = [];
|
|
6917
|
+
for (const event of logicalEvents) {
|
|
6918
|
+
if (event.eventId === failure.eventId) continue;
|
|
6919
|
+
if (event.status === "running") continue;
|
|
6920
|
+
const eventRun = runs.get(event.runId);
|
|
6921
|
+
const eventMeta = eventMetadata(event);
|
|
6922
|
+
const sameRun = event.runId === failure.runId;
|
|
6923
|
+
if (eventRun?.retryOf === failure.runId) {
|
|
6924
|
+
candidates.push({
|
|
6925
|
+
event,
|
|
6926
|
+
basis: "retryOf",
|
|
6927
|
+
confidence: "explicit",
|
|
6928
|
+
viaRunId: event.runId
|
|
6929
|
+
});
|
|
6930
|
+
continue;
|
|
6931
|
+
}
|
|
6932
|
+
if (eventRun?.fallbackOf === failure.runId || pickString2(eventMeta, ["fallbackOf", "fallbackFrom"]) === failure.runId) {
|
|
6933
|
+
candidates.push({
|
|
6934
|
+
event,
|
|
6935
|
+
basis: "fallbackOf",
|
|
6936
|
+
confidence: "explicit",
|
|
6937
|
+
viaRunId: event.runId
|
|
6938
|
+
});
|
|
6939
|
+
continue;
|
|
6940
|
+
}
|
|
6941
|
+
if (sameRun && compareEventOrder(failure, event) >= 0) continue;
|
|
6942
|
+
const eventLinks = linkKeys(event);
|
|
6943
|
+
const sharedLink = eventLinks.find((key) => failureLinks.has(key));
|
|
6944
|
+
if (sharedLink !== void 0) {
|
|
6945
|
+
candidates.push({
|
|
6946
|
+
event,
|
|
6947
|
+
basis: sharedLink.split(":")[0] ?? "linkedId",
|
|
6948
|
+
confidence: "explicit"
|
|
6949
|
+
});
|
|
6950
|
+
continue;
|
|
6951
|
+
}
|
|
6952
|
+
const eventAttempt = pickNumber(eventMeta, ["attempt", "retryAttempt", "retryCount"]) ?? eventRun?.attempt;
|
|
6953
|
+
const sameParent = failure.parentId !== void 0 && event.parentId !== void 0 && failure.parentId === event.parentId;
|
|
6954
|
+
const differentParent = failure.parentId !== void 0 && event.parentId !== void 0 && failure.parentId !== event.parentId;
|
|
6955
|
+
const sessionScoped = failureRun !== void 0 && eventRun !== void 0 && sameCorrelationScope(failureRun, eventRun);
|
|
6956
|
+
if (canonicalName(event) === failureName && failureAttempt !== void 0 && eventAttempt !== void 0 && eventAttempt > failureAttempt && !differentParent && (sameParent || sessionScoped || sameRun)) {
|
|
6957
|
+
candidates.push({
|
|
6958
|
+
event,
|
|
6959
|
+
basis: "attempt-progression",
|
|
6960
|
+
confidence: "correlated",
|
|
6961
|
+
...event.runId !== failure.runId ? { viaRunId: event.runId } : {}
|
|
6962
|
+
});
|
|
6963
|
+
}
|
|
6964
|
+
}
|
|
6965
|
+
const byId = /* @__PURE__ */ new Map();
|
|
6966
|
+
for (const candidate of candidates) {
|
|
6967
|
+
const prev = byId.get(candidate.event.eventId);
|
|
6968
|
+
if (!prev || prev.confidence !== "explicit" && candidate.confidence === "explicit") {
|
|
6969
|
+
byId.set(candidate.event.eventId, candidate);
|
|
6970
|
+
}
|
|
6971
|
+
}
|
|
6972
|
+
return [...byId.values()].sort((a, b) => compareEventOrder(a.event, b.event));
|
|
6973
|
+
}
|
|
6974
|
+
function classifyFailure(failure, candidates, runs, logicalEvents) {
|
|
6975
|
+
const successful = candidates.filter((c) => isSuccessful(c.event));
|
|
6976
|
+
const unsuccessful = candidates.filter((c) => !isSuccessful(c.event));
|
|
6977
|
+
const retryRunIds = Object.freeze(
|
|
6978
|
+
[...new Set(candidates.map((c) => c.viaRunId).filter((id) => id !== void 0))].sort(
|
|
6979
|
+
(a, b) => a.localeCompare(b)
|
|
6980
|
+
)
|
|
6981
|
+
);
|
|
6982
|
+
if (successful.length > 1) {
|
|
6983
|
+
const distinctRuns = new Set(successful.map((c) => c.event.runId));
|
|
6984
|
+
const distinctParents = new Set(
|
|
6985
|
+
successful.map((c) => c.event.parentId ?? "").filter((id) => id !== "")
|
|
6986
|
+
);
|
|
6987
|
+
if (distinctRuns.size > 1 || distinctParents.size > 1) {
|
|
6988
|
+
return {
|
|
6989
|
+
eventId: failure.eventId,
|
|
6990
|
+
runId: failure.runId,
|
|
6991
|
+
name: failure.name,
|
|
6992
|
+
kind: failure.kind,
|
|
6993
|
+
role: "unknown",
|
|
6994
|
+
confidence: "unknown",
|
|
6995
|
+
basis: Object.freeze(["ambiguous-recovery-candidates"]),
|
|
6996
|
+
recoveryEventIds: Object.freeze(
|
|
6997
|
+
successful.map((c) => c.event.eventId).sort((a, b) => a.localeCompare(b))
|
|
6998
|
+
),
|
|
6999
|
+
retryRunIds
|
|
7000
|
+
};
|
|
7001
|
+
}
|
|
7002
|
+
}
|
|
7003
|
+
if (successful.length >= 1) {
|
|
7004
|
+
const best = successful[0];
|
|
7005
|
+
return {
|
|
7006
|
+
eventId: failure.eventId,
|
|
7007
|
+
runId: failure.runId,
|
|
7008
|
+
name: failure.name,
|
|
7009
|
+
kind: failure.kind,
|
|
7010
|
+
role: "recovered",
|
|
7011
|
+
confidence: best.confidence,
|
|
7012
|
+
basis: Object.freeze([best.basis]),
|
|
7013
|
+
recoveryEventIds: Object.freeze(
|
|
7014
|
+
successful.map((c) => c.event.eventId).sort((a, b) => a.localeCompare(b))
|
|
7015
|
+
),
|
|
7016
|
+
retryRunIds
|
|
7017
|
+
};
|
|
7018
|
+
}
|
|
7019
|
+
if (candidates.length > 0) {
|
|
7020
|
+
const best = candidates[0];
|
|
7021
|
+
return {
|
|
7022
|
+
eventId: failure.eventId,
|
|
7023
|
+
runId: failure.runId,
|
|
7024
|
+
name: failure.name,
|
|
7025
|
+
kind: failure.kind,
|
|
7026
|
+
role: "transient",
|
|
7027
|
+
confidence: best.confidence,
|
|
7028
|
+
basis: Object.freeze([
|
|
7029
|
+
best.basis,
|
|
7030
|
+
unsuccessful.some((c) => c.event.status === void 0) ? "retry-incomplete" : "retry-without-success"
|
|
7031
|
+
]),
|
|
7032
|
+
recoveryEventIds: Object.freeze([]),
|
|
7033
|
+
retryRunIds
|
|
7034
|
+
};
|
|
7035
|
+
}
|
|
7036
|
+
const failureMeta = eventMetadata(failure);
|
|
7037
|
+
const declaredSuccessor = pickString2(failureMeta, [
|
|
7038
|
+
"retriedBy",
|
|
7039
|
+
"nextRetryRunId",
|
|
7040
|
+
"retryRunId"
|
|
7041
|
+
]);
|
|
7042
|
+
if (declaredSuccessor !== void 0 && !runs.has(declaredSuccessor)) {
|
|
7043
|
+
return {
|
|
7044
|
+
eventId: failure.eventId,
|
|
7045
|
+
runId: failure.runId,
|
|
7046
|
+
name: failure.name,
|
|
7047
|
+
kind: failure.kind,
|
|
7048
|
+
role: "transient",
|
|
7049
|
+
confidence: "explicit",
|
|
7050
|
+
basis: Object.freeze(["retry-declared", "retry-run-missing"]),
|
|
7051
|
+
recoveryEventIds: Object.freeze([]),
|
|
7052
|
+
retryRunIds: Object.freeze([declaredSuccessor])
|
|
7053
|
+
};
|
|
7054
|
+
}
|
|
7055
|
+
for (const run of runs.values()) {
|
|
7056
|
+
if (run.retryOf === failure.runId) {
|
|
7057
|
+
return {
|
|
7058
|
+
eventId: failure.eventId,
|
|
7059
|
+
runId: failure.runId,
|
|
7060
|
+
name: failure.name,
|
|
7061
|
+
kind: failure.kind,
|
|
7062
|
+
role: "transient",
|
|
7063
|
+
confidence: "explicit",
|
|
7064
|
+
basis: Object.freeze(["retryOf", "retry-run-missing-or-empty"]),
|
|
7065
|
+
recoveryEventIds: Object.freeze([]),
|
|
7066
|
+
retryRunIds: Object.freeze([run.runId])
|
|
7067
|
+
};
|
|
7068
|
+
}
|
|
7069
|
+
}
|
|
7070
|
+
const failureRun = runs.get(failure.runId);
|
|
7071
|
+
const hasSuccessorDeclared = [...runs.values()].some((run) => run.retryOf === failure.runId);
|
|
7072
|
+
const isFinalInChain = failureRun !== void 0 && !hasSuccessorDeclared && (failureRun.retryOf !== void 0 || failureRun.attempt !== void 0 && failureRun.attempt > 1 || pickNumber(eventMetadata(failure), ["attempt"]) !== void 0);
|
|
7073
|
+
if (isFinalInChain && failureRun?.status === "error" && !logicalEvents.some(
|
|
7074
|
+
(event) => event.runId === failure.runId && event.eventId !== failure.eventId && isSuccessful(event) && canonicalName(event) === canonicalName(failure)
|
|
7075
|
+
)) {
|
|
7076
|
+
return {
|
|
7077
|
+
eventId: failure.eventId,
|
|
7078
|
+
runId: failure.runId,
|
|
7079
|
+
name: failure.name,
|
|
7080
|
+
kind: failure.kind,
|
|
7081
|
+
role: "terminal",
|
|
7082
|
+
confidence: failureRun.retryOf !== void 0 ? "explicit" : "correlated",
|
|
7083
|
+
basis: Object.freeze(["final-retry-chain-member", "enclosing-run-error"]),
|
|
7084
|
+
recoveryEventIds: Object.freeze([]),
|
|
7085
|
+
retryRunIds: Object.freeze(
|
|
7086
|
+
failureRun.retryOf !== void 0 ? [failureRun.retryOf] : []
|
|
7087
|
+
)
|
|
7088
|
+
};
|
|
7089
|
+
}
|
|
7090
|
+
return {
|
|
7091
|
+
eventId: failure.eventId,
|
|
7092
|
+
runId: failure.runId,
|
|
7093
|
+
name: failure.name,
|
|
7094
|
+
kind: failure.kind,
|
|
7095
|
+
role: "unknown",
|
|
7096
|
+
confidence: "unknown",
|
|
7097
|
+
basis: Object.freeze(["no-explicit-or-correlated-recovery"]),
|
|
7098
|
+
recoveryEventIds: Object.freeze([]),
|
|
7099
|
+
retryRunIds: Object.freeze([])
|
|
7100
|
+
};
|
|
7101
|
+
}
|
|
7102
|
+
function deriveFailureFacts(logicalEvents) {
|
|
7103
|
+
const runs = buildRunContexts(logicalEvents);
|
|
7104
|
+
const failures = logicalEvents.filter((event) => isFailure(event)).sort(compareEventOrder);
|
|
7105
|
+
const failureFacts = failures.map(
|
|
7106
|
+
(failure) => classifyFailure(failure, collectCandidates(failure, logicalEvents, runs), runs, logicalEvents)
|
|
7107
|
+
);
|
|
7108
|
+
const byRole = /* @__PURE__ */ new Map([
|
|
7109
|
+
["transient", []],
|
|
7110
|
+
["recovered", []],
|
|
7111
|
+
["terminal", []],
|
|
7112
|
+
["unknown", []]
|
|
7113
|
+
]);
|
|
7114
|
+
for (const fact2 of failureFacts) {
|
|
7115
|
+
byRole.get(fact2.role).push(fact2);
|
|
7116
|
+
}
|
|
7117
|
+
for (const [role, list2] of byRole) {
|
|
7118
|
+
byRole.set(
|
|
7119
|
+
role,
|
|
7120
|
+
Object.freeze(
|
|
7121
|
+
[...list2].sort((a, b) => {
|
|
7122
|
+
const byRun = a.runId.localeCompare(b.runId);
|
|
7123
|
+
if (byRun !== 0) return byRun;
|
|
7124
|
+
return a.eventId.localeCompare(b.eventId);
|
|
7125
|
+
})
|
|
7126
|
+
)
|
|
7127
|
+
);
|
|
7128
|
+
}
|
|
7129
|
+
const failureRoleCounts = {
|
|
7130
|
+
transient: byRole.get("transient").length,
|
|
7131
|
+
recovered: byRole.get("recovered").length,
|
|
7132
|
+
terminal: byRole.get("terminal").length,
|
|
7133
|
+
unknown: byRole.get("unknown").length
|
|
7134
|
+
};
|
|
7135
|
+
return {
|
|
7136
|
+
failureFacts: Object.freeze(failureFacts),
|
|
7137
|
+
failuresByRole: byRole,
|
|
7138
|
+
failureRoleCounts
|
|
7139
|
+
};
|
|
7140
|
+
}
|
|
7141
|
+
var init_derived_failure = __esm({
|
|
7142
|
+
"packages/core/src/checks/derived-failure.ts"() {
|
|
7143
|
+
init_logical_events();
|
|
7144
|
+
}
|
|
7145
|
+
});
|
|
7146
|
+
|
|
6823
7147
|
// packages/core/src/checks/trace-facts.ts
|
|
6824
7148
|
function summarizeSemanticParity(events) {
|
|
6825
7149
|
const projection = projectLogicalEvents(events);
|
|
@@ -6830,6 +7154,7 @@ function summarizeSemanticParity(events) {
|
|
|
6830
7154
|
const finishedToolNames = Object.freeze(
|
|
6831
7155
|
finishedTools.map((event) => resolveCanonicalToolName(event)).sort((a, b) => a.localeCompare(b))
|
|
6832
7156
|
);
|
|
7157
|
+
const derived = deriveFailureFacts(logical);
|
|
6833
7158
|
return {
|
|
6834
7159
|
rawEventCount: events.length,
|
|
6835
7160
|
logicalEventCount: logical.length,
|
|
@@ -6840,13 +7165,16 @@ function summarizeSemanticParity(events) {
|
|
|
6840
7165
|
parentRemapCount: projection.diagnostics.filter(
|
|
6841
7166
|
(item) => item.code === "AI_LOGICAL_PARENT_REMAPPED"
|
|
6842
7167
|
).length,
|
|
6843
|
-
diagnostics: projection.diagnostics
|
|
7168
|
+
diagnostics: projection.diagnostics,
|
|
7169
|
+
failureRoleCounts: derived.failureRoleCounts
|
|
6844
7170
|
};
|
|
6845
7171
|
}
|
|
6846
7172
|
var init_trace_facts = __esm({
|
|
6847
7173
|
"packages/core/src/checks/trace-facts.ts"() {
|
|
6848
7174
|
init_programmatic();
|
|
7175
|
+
init_derived_failure();
|
|
6849
7176
|
init_logical_events();
|
|
7177
|
+
init_derived_failure();
|
|
6850
7178
|
formatProgrammaticDiagnostic(
|
|
6851
7179
|
"AI_TRACE_FACTS_INPUT_NOT_NORMALIZED"
|
|
6852
7180
|
);
|
|
@@ -7174,7 +7502,7 @@ function finishedEvents(context, kind) {
|
|
|
7174
7502
|
function toolInvocationEvents(context) {
|
|
7175
7503
|
return semanticEvents(context).filter((event) => event.kind === "TOOL");
|
|
7176
7504
|
}
|
|
7177
|
-
function
|
|
7505
|
+
function isRecord9(value) {
|
|
7178
7506
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
7179
7507
|
}
|
|
7180
7508
|
function eventMap(events) {
|
|
@@ -7225,7 +7553,7 @@ function pushValueEntries(entries, event, value, path44, key, depth = 0) {
|
|
|
7225
7553
|
}
|
|
7226
7554
|
return;
|
|
7227
7555
|
}
|
|
7228
|
-
if (!
|
|
7556
|
+
if (!isRecord9(value)) return;
|
|
7229
7557
|
for (const nestedKey of Object.keys(value).sort((a, b) => a.localeCompare(b))) {
|
|
7230
7558
|
pushValueEntries(
|
|
7231
7559
|
entries,
|
|
@@ -8051,7 +8379,7 @@ function createSafetyOversizedAttributeRule(options) {
|
|
|
8051
8379
|
)
|
|
8052
8380
|
);
|
|
8053
8381
|
}
|
|
8054
|
-
if (
|
|
8382
|
+
if (isRecord9(entry.value) && options.maxObjectKeys !== void 0 && Object.keys(entry.value).length > options.maxObjectKeys) {
|
|
8055
8383
|
findings.push(
|
|
8056
8384
|
failFinding(
|
|
8057
8385
|
"safety.oversizedAttribute",
|
|
@@ -8437,14 +8765,14 @@ var init_checks2 = __esm({
|
|
|
8437
8765
|
});
|
|
8438
8766
|
|
|
8439
8767
|
// packages/core/src/persisted/token-usage.ts
|
|
8440
|
-
function
|
|
8768
|
+
function isRecord10(value) {
|
|
8441
8769
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
8442
8770
|
}
|
|
8443
8771
|
function nonNegativeFinite(value) {
|
|
8444
8772
|
return typeof value === "number" && Number.isFinite(value) && value >= 0 ? value : void 0;
|
|
8445
8773
|
}
|
|
8446
8774
|
function normalizeTokenUsage(value) {
|
|
8447
|
-
if (!
|
|
8775
|
+
if (!isRecord10(value)) return void 0;
|
|
8448
8776
|
const input3 = nonNegativeFinite(value.input);
|
|
8449
8777
|
const output2 = nonNegativeFinite(value.output);
|
|
8450
8778
|
const suppliedTotal = nonNegativeFinite(value.total);
|
|
@@ -9274,7 +9602,7 @@ function persistedEventsForParsedTrace(parsed) {
|
|
|
9274
9602
|
sourceName: "agent-inspect-jsonl-reader"
|
|
9275
9603
|
});
|
|
9276
9604
|
}
|
|
9277
|
-
function
|
|
9605
|
+
function isRecord11(value) {
|
|
9278
9606
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
9279
9607
|
}
|
|
9280
9608
|
function isNonEmptyString4(value) {
|
|
@@ -9289,13 +9617,13 @@ function readStringField(record, keys) {
|
|
|
9289
9617
|
}
|
|
9290
9618
|
function readRecordField(record, key) {
|
|
9291
9619
|
const value = record[key];
|
|
9292
|
-
return
|
|
9620
|
+
return isRecord11(value) ? value : void 0;
|
|
9293
9621
|
}
|
|
9294
9622
|
function parseJsonDocument(content) {
|
|
9295
9623
|
return JSON.parse(content);
|
|
9296
9624
|
}
|
|
9297
9625
|
function looksLikeOpenInferenceSpan(value) {
|
|
9298
|
-
if (!
|
|
9626
|
+
if (!isRecord11(value)) return false;
|
|
9299
9627
|
const attributes = readRecordField(value, "attributes");
|
|
9300
9628
|
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);
|
|
9301
9629
|
}
|
|
@@ -9320,7 +9648,7 @@ function extractOpenInferenceDocument(root) {
|
|
|
9320
9648
|
unsupportedFields
|
|
9321
9649
|
};
|
|
9322
9650
|
}
|
|
9323
|
-
if (!
|
|
9651
|
+
if (!isRecord11(root)) return void 0;
|
|
9324
9652
|
const rootFormat = root.format;
|
|
9325
9653
|
const rootCompatibility = root.compatibility;
|
|
9326
9654
|
const version2 = typeof root.version === "string" && root.version.trim() !== "" ? root.version : void 0;
|
|
@@ -9460,7 +9788,7 @@ function summarizeAttributeValue(value) {
|
|
|
9460
9788
|
if (Array.isArray(value)) {
|
|
9461
9789
|
return { type: "array", length: value.length };
|
|
9462
9790
|
}
|
|
9463
|
-
if (
|
|
9791
|
+
if (isRecord11(value)) {
|
|
9464
9792
|
return { type: "object", keyCount: Object.keys(value).length };
|
|
9465
9793
|
}
|
|
9466
9794
|
if (value === null) {
|
|
@@ -9547,7 +9875,7 @@ function mapOpenInferenceKind(span, attributes, pathPrefix) {
|
|
|
9547
9875
|
}
|
|
9548
9876
|
}
|
|
9549
9877
|
function mapOpenInferenceStatus(status) {
|
|
9550
|
-
if (!
|
|
9878
|
+
if (!isRecord11(status)) return void 0;
|
|
9551
9879
|
const rawCode = status.code;
|
|
9552
9880
|
if (typeof rawCode !== "string") return void 0;
|
|
9553
9881
|
switch (rawCode.toUpperCase()) {
|
|
@@ -9647,7 +9975,7 @@ function mapOpenInferenceSpan(span, index, version2) {
|
|
|
9647
9975
|
warnings.push(...kindWarnings);
|
|
9648
9976
|
const status = mapOpenInferenceStatus(span.status);
|
|
9649
9977
|
const tokenUsage = readOpenInferenceTokenUsage(rawAttributes);
|
|
9650
|
-
const errorMessage =
|
|
9978
|
+
const errorMessage = isRecord11(span.status) && typeof span.status.message === "string" ? span.status.message : void 0;
|
|
9651
9979
|
const event = {
|
|
9652
9980
|
schemaVersion: "0.2",
|
|
9653
9981
|
eventId: typeof rawAttributes["agent_inspect.event_id"] === "string" ? rawAttributes["agent_inspect.event_id"] : spanId,
|
|
@@ -9715,7 +10043,7 @@ function mapOpenInferenceEvents(document) {
|
|
|
9715
10043
|
};
|
|
9716
10044
|
}
|
|
9717
10045
|
function parseOtlpAnyValue(value, field, warnings, unsupportedFields) {
|
|
9718
|
-
if (!
|
|
10046
|
+
if (!isRecord11(value)) {
|
|
9719
10047
|
unsupportedFields.push(field);
|
|
9720
10048
|
warnings.push({
|
|
9721
10049
|
code: "otlp_attribute_value_invalid",
|
|
@@ -9737,15 +10065,15 @@ function parseOtlpAnyValue(value, field, warnings, unsupportedFields) {
|
|
|
9737
10065
|
if (typeof value.doubleValue === "number" && Number.isFinite(value.doubleValue)) {
|
|
9738
10066
|
return value.doubleValue;
|
|
9739
10067
|
}
|
|
9740
|
-
if (
|
|
10068
|
+
if (isRecord11(value.arrayValue) && Array.isArray(value.arrayValue.values)) {
|
|
9741
10069
|
return value.arrayValue.values.map(
|
|
9742
10070
|
(item, index) => parseOtlpAnyValue(item, `${field}.arrayValue.values[${index}]`, warnings, unsupportedFields)
|
|
9743
10071
|
);
|
|
9744
10072
|
}
|
|
9745
|
-
if (
|
|
10073
|
+
if (isRecord11(value.kvlistValue) && Array.isArray(value.kvlistValue.values)) {
|
|
9746
10074
|
const out = {};
|
|
9747
10075
|
for (const [index, item] of value.kvlistValue.values.entries()) {
|
|
9748
|
-
if (!
|
|
10076
|
+
if (!isRecord11(item) || typeof item.key !== "string") {
|
|
9749
10077
|
unsupportedFields.push(`${field}.kvlistValue.values[${index}]`);
|
|
9750
10078
|
continue;
|
|
9751
10079
|
}
|
|
@@ -9796,7 +10124,7 @@ function parseOtlpAttributes(value, pathPrefix) {
|
|
|
9796
10124
|
}
|
|
9797
10125
|
for (const [index, item] of value.entries()) {
|
|
9798
10126
|
const field = `${pathPrefix}[${index}]`;
|
|
9799
|
-
if (!
|
|
10127
|
+
if (!isRecord11(item) || typeof item.key !== "string") {
|
|
9800
10128
|
unsupportedFields.push(field);
|
|
9801
10129
|
warnings.push({
|
|
9802
10130
|
code: "otlp_attribute_invalid",
|
|
@@ -9819,16 +10147,16 @@ function parseOtlpAttributes(value, pathPrefix) {
|
|
|
9819
10147
|
return { attributes, warnings, unsupportedFields };
|
|
9820
10148
|
}
|
|
9821
10149
|
function looksLikeOtlpSpan(value) {
|
|
9822
|
-
return
|
|
10150
|
+
return isRecord11(value) && readStringField(value, ["traceId"]) !== void 0 && readStringField(value, ["spanId"]) !== void 0 && readStringField(value, ["name"]) !== void 0;
|
|
9823
10151
|
}
|
|
9824
10152
|
function extractOtlpDocument(root) {
|
|
9825
|
-
if (!
|
|
10153
|
+
if (!isRecord11(root) || !Array.isArray(root.resourceSpans)) return void 0;
|
|
9826
10154
|
const spans = [];
|
|
9827
10155
|
const warnings = [];
|
|
9828
10156
|
const unsupportedFields = [];
|
|
9829
10157
|
for (const [resourceIndex, resourceSpan] of root.resourceSpans.entries()) {
|
|
9830
10158
|
const resourcePath = `resourceSpans[${resourceIndex}]`;
|
|
9831
|
-
if (!
|
|
10159
|
+
if (!isRecord11(resourceSpan)) {
|
|
9832
10160
|
unsupportedFields.push(resourcePath);
|
|
9833
10161
|
continue;
|
|
9834
10162
|
}
|
|
@@ -9851,7 +10179,7 @@ function extractOtlpDocument(root) {
|
|
|
9851
10179
|
}
|
|
9852
10180
|
for (const [scopeIndex, scopeSpan] of resourceSpan.scopeSpans.entries()) {
|
|
9853
10181
|
const scopePath = `${resourcePath}.scopeSpans[${scopeIndex}]`;
|
|
9854
|
-
if (!
|
|
10182
|
+
if (!isRecord11(scopeSpan)) {
|
|
9855
10183
|
unsupportedFields.push(scopePath);
|
|
9856
10184
|
continue;
|
|
9857
10185
|
}
|
|
@@ -9918,7 +10246,7 @@ function extractOtlpDocument(root) {
|
|
|
9918
10246
|
};
|
|
9919
10247
|
}
|
|
9920
10248
|
function mapOtlpStatus(status) {
|
|
9921
|
-
if (!
|
|
10249
|
+
if (!isRecord11(status)) return void 0;
|
|
9922
10250
|
const rawCode = status.code;
|
|
9923
10251
|
if (typeof rawCode !== "string") return void 0;
|
|
9924
10252
|
switch (rawCode.toUpperCase()) {
|
|
@@ -10018,7 +10346,7 @@ function mapOtlpEvents(value, pathPrefix) {
|
|
|
10018
10346
|
const events = [];
|
|
10019
10347
|
for (const [index, event] of value.entries()) {
|
|
10020
10348
|
const eventPath = `${pathPrefix}[${index}]`;
|
|
10021
|
-
if (!
|
|
10349
|
+
if (!isRecord11(event)) {
|
|
10022
10350
|
unsupportedFields.push(eventPath);
|
|
10023
10351
|
continue;
|
|
10024
10352
|
}
|
|
@@ -10156,7 +10484,7 @@ function mapOtlpSpan(context) {
|
|
|
10156
10484
|
warnings.push(...kindWarnings);
|
|
10157
10485
|
const status = mapOtlpStatus(span.status);
|
|
10158
10486
|
const tokenUsage = readOtlpTokenUsage(parsedSpanAttributes.attributes);
|
|
10159
|
-
const errorMessage =
|
|
10487
|
+
const errorMessage = isRecord11(span.status) && typeof span.status.message === "string" ? span.status.message : void 0;
|
|
10160
10488
|
const event = {
|
|
10161
10489
|
schemaVersion: "0.2",
|
|
10162
10490
|
eventId: typeof parsedSpanAttributes.attributes["agent_inspect.event_id"] === "string" ? parsedSpanAttributes.attributes["agent_inspect.event_id"] : spanId,
|
|
@@ -12595,7 +12923,7 @@ var init_src = __esm({
|
|
|
12595
12923
|
});
|
|
12596
12924
|
|
|
12597
12925
|
// package.json
|
|
12598
|
-
var version = "6.
|
|
12926
|
+
var version = "6.19.0";
|
|
12599
12927
|
|
|
12600
12928
|
// packages/cli/src/list.ts
|
|
12601
12929
|
init_advanced();
|
|
@@ -13257,7 +13585,7 @@ async function view(runId, options = {}) {
|
|
|
13257
13585
|
process.exitCode = 1;
|
|
13258
13586
|
}
|
|
13259
13587
|
}
|
|
13260
|
-
function
|
|
13588
|
+
function isRecord12(v) {
|
|
13261
13589
|
return typeof v === "object" && v !== null && !Array.isArray(v);
|
|
13262
13590
|
}
|
|
13263
13591
|
function isNonEmptyStringArray(v) {
|
|
@@ -13269,7 +13597,7 @@ function validateRedact(redact2) {
|
|
|
13269
13597
|
}
|
|
13270
13598
|
for (const r of redact2) {
|
|
13271
13599
|
if (typeof r === "string") continue;
|
|
13272
|
-
if (!
|
|
13600
|
+
if (!isRecord12(r)) {
|
|
13273
13601
|
throw new Error("Invalid config: redact entries must be strings or objects");
|
|
13274
13602
|
}
|
|
13275
13603
|
if (typeof r.key !== "string" || r.key.trim() === "") {
|
|
@@ -13288,7 +13616,7 @@ function validateRedact(redact2) {
|
|
|
13288
13616
|
}
|
|
13289
13617
|
}
|
|
13290
13618
|
function validateMappings(mappings) {
|
|
13291
|
-
if (!
|
|
13619
|
+
if (!isRecord12(mappings)) {
|
|
13292
13620
|
throw new Error("Invalid config: mappings must be an object");
|
|
13293
13621
|
}
|
|
13294
13622
|
}
|
|
@@ -13338,7 +13666,7 @@ async function loadLogIngestConfig(configPath) {
|
|
|
13338
13666
|
const msg = e instanceof Error ? e.message : String(e);
|
|
13339
13667
|
throw new Error(`Invalid JSON in config file: ${configPath} (${msg})`);
|
|
13340
13668
|
}
|
|
13341
|
-
if (!
|
|
13669
|
+
if (!isRecord12(parsed)) {
|
|
13342
13670
|
throw new Error("Invalid config: expected a JSON object at top-level");
|
|
13343
13671
|
}
|
|
13344
13672
|
const user = parsed;
|
|
@@ -13375,7 +13703,7 @@ async function loadLogIngestConfig(configPath) {
|
|
|
13375
13703
|
}
|
|
13376
13704
|
return mergeLogIngestConfig(DEFAULT_LOG_INGEST_CONFIG, user);
|
|
13377
13705
|
}
|
|
13378
|
-
function
|
|
13706
|
+
function isRecord13(v) {
|
|
13379
13707
|
return typeof v === "object" && v !== null && !Array.isArray(v);
|
|
13380
13708
|
}
|
|
13381
13709
|
var JsonLogParser = class {
|
|
@@ -13400,7 +13728,7 @@ var JsonLogParser = class {
|
|
|
13400
13728
|
});
|
|
13401
13729
|
continue;
|
|
13402
13730
|
}
|
|
13403
|
-
if (!
|
|
13731
|
+
if (!isRecord13(parsed)) {
|
|
13404
13732
|
warnings.push({
|
|
13405
13733
|
code: "MALFORMED_JSON",
|
|
13406
13734
|
message: "JSON log line must be an object",
|
|
@@ -13431,7 +13759,7 @@ var JsonLogParser = class {
|
|
|
13431
13759
|
return this.parseLines(lines, filePath);
|
|
13432
13760
|
}
|
|
13433
13761
|
};
|
|
13434
|
-
function
|
|
13762
|
+
function isRecord14(v) {
|
|
13435
13763
|
return typeof v === "object" && v !== null && !Array.isArray(v);
|
|
13436
13764
|
}
|
|
13437
13765
|
function findLastJsonObjectSubstring(line) {
|
|
@@ -13507,7 +13835,7 @@ var Log4jsParser = class {
|
|
|
13507
13835
|
});
|
|
13508
13836
|
continue;
|
|
13509
13837
|
}
|
|
13510
|
-
if (!
|
|
13838
|
+
if (!isRecord14(parsed)) {
|
|
13511
13839
|
warnings.push({
|
|
13512
13840
|
code: "UNSUPPORTED_LOG4JS_PAYLOAD",
|
|
13513
13841
|
message: "Embedded JSON payload must be an object",
|
|
@@ -14386,7 +14714,7 @@ var EXPORT_PAYLOAD_VERSION = "0.1.2";
|
|
|
14386
14714
|
// packages/core/src/exporters/redact-export.ts
|
|
14387
14715
|
init_redactor();
|
|
14388
14716
|
init_redaction_profiles();
|
|
14389
|
-
function
|
|
14717
|
+
function isRecord15(value) {
|
|
14390
14718
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
14391
14719
|
}
|
|
14392
14720
|
function deepClone(value) {
|
|
@@ -14460,7 +14788,7 @@ function redactEventAttributes(attrs, redactor, maxMetadataValueLength, maxPrevi
|
|
|
14460
14788
|
0
|
|
14461
14789
|
);
|
|
14462
14790
|
const err = bounded.error;
|
|
14463
|
-
if (
|
|
14791
|
+
if (isRecord15(err) && typeof err.message === "string") {
|
|
14464
14792
|
bounded.error = {
|
|
14465
14793
|
...err,
|
|
14466
14794
|
message: truncateStringForProfile(
|
|
@@ -14490,7 +14818,7 @@ function redactErrorInfo(error, redactor, maxMetadataValueLength, maxPreviewLeng
|
|
|
14490
14818
|
maxPreviewLength
|
|
14491
14819
|
);
|
|
14492
14820
|
const redacted = record?.error;
|
|
14493
|
-
if (!
|
|
14821
|
+
if (!isRecord15(redacted) || typeof redacted.message !== "string") {
|
|
14494
14822
|
return void 0;
|
|
14495
14823
|
}
|
|
14496
14824
|
return {
|
|
@@ -14570,7 +14898,7 @@ function redactTraceEventsForReport(events, options) {
|
|
|
14570
14898
|
) : void 0;
|
|
14571
14899
|
const redactedActual = actualAttrs !== void 0 && "value" in actualAttrs ? actualAttrs.value : void 0;
|
|
14572
14900
|
const redactedEvidence = event.evidence !== void 0 ? redactEventAttributes(
|
|
14573
|
-
|
|
14901
|
+
isRecord15(event.evidence) ? event.evidence : { value: event.evidence },
|
|
14574
14902
|
redactor,
|
|
14575
14903
|
maxMetadataValueLength,
|
|
14576
14904
|
maxPreviewLength
|
|
@@ -16653,7 +16981,7 @@ var STRICT_PROFILE_EXTRA_KEYS2 = [
|
|
|
16653
16981
|
"retrieval",
|
|
16654
16982
|
"query"
|
|
16655
16983
|
];
|
|
16656
|
-
function
|
|
16984
|
+
function isRecord16(value) {
|
|
16657
16985
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
16658
16986
|
}
|
|
16659
16987
|
function toKey2(key) {
|
|
@@ -17033,7 +17361,7 @@ var Redactor2 = class {
|
|
|
17033
17361
|
});
|
|
17034
17362
|
return out;
|
|
17035
17363
|
}
|
|
17036
|
-
if (
|
|
17364
|
+
if (isRecord16(value)) {
|
|
17037
17365
|
if (state.seen.has(value)) return state.seen.get(value);
|
|
17038
17366
|
const out = {};
|
|
17039
17367
|
state.seen.set(value, out);
|
|
@@ -17066,7 +17394,7 @@ var REDACTION_POLICY_LIMITS = {
|
|
|
17066
17394
|
maxTypedQuantifier: 64
|
|
17067
17395
|
};
|
|
17068
17396
|
var SAFE_TYPED_PATTERN = /^[A-Za-z0-9_@./:=<>\-[\]()|+*?{},\\\s^$]+$/;
|
|
17069
|
-
function
|
|
17397
|
+
function isRecord17(value) {
|
|
17070
17398
|
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
17071
17399
|
}
|
|
17072
17400
|
function escapeRegExp(value) {
|
|
@@ -17136,7 +17464,7 @@ function assertBoundedTypedPattern(pattern, label) {
|
|
|
17136
17464
|
}
|
|
17137
17465
|
function compilePatternDetector(input3, index) {
|
|
17138
17466
|
const label = `patterns[${index}]`;
|
|
17139
|
-
if (!
|
|
17467
|
+
if (!isRecord17(input3)) throw new Error(`${label} must be an object.`);
|
|
17140
17468
|
const idRaw = input3.id;
|
|
17141
17469
|
if (typeof idRaw !== "string" || idRaw.trim() === "") {
|
|
17142
17470
|
throw new Error(`${label}.id must be a non-empty string.`);
|
|
@@ -17197,7 +17525,7 @@ function compilePatternDetector(input3, index) {
|
|
|
17197
17525
|
};
|
|
17198
17526
|
}
|
|
17199
17527
|
function compileRedactionPolicy(raw, policyPath) {
|
|
17200
|
-
if (!
|
|
17528
|
+
if (!isRecord17(raw)) {
|
|
17201
17529
|
throw new Error(`Redaction policy must be a JSON object (${policyPath}).`);
|
|
17202
17530
|
}
|
|
17203
17531
|
const diagnostics = [];
|
|
@@ -18207,7 +18535,7 @@ async function openCommand(input3, options = {}, stdin = process.stdin) {
|
|
|
18207
18535
|
|
|
18208
18536
|
// packages/cli/src/migrate.ts
|
|
18209
18537
|
init_advanced();
|
|
18210
|
-
function
|
|
18538
|
+
function isRecord18(value) {
|
|
18211
18539
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
18212
18540
|
}
|
|
18213
18541
|
function parseTarget(value) {
|
|
@@ -18216,7 +18544,7 @@ function parseTarget(value) {
|
|
|
18216
18544
|
throw new Error('Unsupported migration target. Use "--to 1.0".');
|
|
18217
18545
|
}
|
|
18218
18546
|
function formatOf(value) {
|
|
18219
|
-
if (!
|
|
18547
|
+
if (!isRecord18(value)) return "unknown";
|
|
18220
18548
|
if (value.schemaVersion === "0.1") return "0.1";
|
|
18221
18549
|
if (value.schemaVersion === "0.2") return "0.2";
|
|
18222
18550
|
if (value.schemaVersion === "1.0") return "1.0";
|
|
@@ -22569,7 +22897,8 @@ async function artifactsCommand(target, options = {}, stdin = process.stdin) {
|
|
|
22569
22897
|
finishedToolNames: [...parity.finishedToolNames],
|
|
22570
22898
|
pairedCount: parity.pairedCount,
|
|
22571
22899
|
parentRemapCount: parity.parentRemapCount,
|
|
22572
|
-
contractStatus: check.status === "pass" ? "pass" : check.status === "fail" ? "fail" : "error"
|
|
22900
|
+
contractStatus: check.status === "pass" ? "pass" : check.status === "fail" ? "fail" : "error",
|
|
22901
|
+
...parity.failureRoleCounts !== void 0 ? { failureRoleCounts: { ...parity.failureRoleCounts } } : {}
|
|
22573
22902
|
}
|
|
22574
22903
|
});
|
|
22575
22904
|
await writeArtifact(outputDir, "evidence.html", evidencePackage["evidence.html"], files);
|