agent-inspect 6.31.7 → 6.31.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/README.md +1 -1
- package/package.json +1 -1
- package/packages/cli/dist/{chunk-QV73NM25.mjs → chunk-SWUZRRDT.mjs} +158 -21
- package/packages/cli/dist/chunk-SWUZRRDT.mjs.map +1 -0
- package/packages/cli/dist/index.cjs +312 -52
- package/packages/cli/dist/index.cjs.map +1 -1
- package/packages/cli/dist/index.mjs +156 -36
- package/packages/cli/dist/index.mjs.map +1 -1
- package/packages/cli/dist/{src-KFOBXFPN.mjs → src-XFIPYODW.mjs} +3 -3
- package/packages/cli/dist/{src-KFOBXFPN.mjs.map → src-XFIPYODW.mjs.map} +1 -1
- package/packages/core/dist/advanced.cjs +200 -24
- 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 +89 -15
- package/packages/core/dist/advanced.mjs.map +1 -1
- package/packages/core/dist/checks.mjs +2 -2
- package/packages/core/dist/{chunk-LXYPM2ZO.mjs → chunk-2CCRUI42.mjs} +19 -318
- package/packages/core/dist/chunk-2CCRUI42.mjs.map +1 -0
- package/packages/core/dist/{chunk-QLYUWKK7.mjs → chunk-2IRRUNIN.mjs} +11 -5
- package/packages/core/dist/chunk-2IRRUNIN.mjs.map +1 -0
- package/packages/core/dist/{chunk-VQUB3WRI.mjs → chunk-3SPBELJB.mjs} +14 -3
- package/packages/core/dist/chunk-3SPBELJB.mjs.map +1 -0
- package/packages/core/dist/{chunk-3RV3JILQ.mjs → chunk-IJJSPJXV.mjs} +20 -12
- package/packages/core/dist/chunk-IJJSPJXV.mjs.map +1 -0
- package/packages/core/dist/chunk-L5WLVBW4.mjs +355 -0
- package/packages/core/dist/chunk-L5WLVBW4.mjs.map +1 -0
- package/packages/core/dist/exporters.cjs +110 -18
- package/packages/core/dist/exporters.cjs.map +1 -1
- package/packages/core/dist/exporters.mjs +110 -18
- package/packages/core/dist/exporters.mjs.map +1 -1
- package/packages/core/dist/index.cjs +12 -1
- package/packages/core/dist/index.cjs.map +1 -1
- package/packages/core/dist/index.mjs +2 -2
- package/packages/core/dist/persisted.cjs +344 -9
- package/packages/core/dist/persisted.cjs.map +1 -1
- package/packages/core/dist/persisted.d.cts +8 -1
- package/packages/core/dist/persisted.d.ts +8 -1
- package/packages/core/dist/persisted.mjs +3 -2
- package/packages/core/dist/persisted.mjs.map +1 -1
- package/packages/core/dist/readers.cjs +377 -87
- package/packages/core/dist/readers.cjs.map +1 -1
- package/packages/core/dist/readers.mjs +3 -3
- package/packages/cli/dist/chunk-QV73NM25.mjs.map +0 -1
- package/packages/core/dist/chunk-3RV3JILQ.mjs.map +0 -1
- package/packages/core/dist/chunk-FWK3Q3OJ.mjs +0 -56
- package/packages/core/dist/chunk-FWK3Q3OJ.mjs.map +0 -1
- package/packages/core/dist/chunk-LXYPM2ZO.mjs.map +0 -1
- package/packages/core/dist/chunk-QLYUWKK7.mjs.map +0 -1
- package/packages/core/dist/chunk-VQUB3WRI.mjs.map +0 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export { buildTraceFacts, createBaselineRegressionRule, createDecisionRule, createGuardrailRule, createLlmUsageRule, createMaxStepDurationRule, createObservedOutcomeRule, createRequireCompletedRule, createRetrievalRule, createRunDepthRule, createRunDurationRule, createRunEventCountRule, createRunStatusRule, createSafetyOversizedAttributeRule, createSafetyRawContentRule, createSafetyRedactionRule, createSafetySecretPatternRule, createStallDetectionRule, createStepOrderingRule, createStructureCycleRule, createStructureIncompleteRule, createStructureOrphanRule, createStructureParallelWidthRule, createStructureRelationshipRule, createToolFailureRule, createToolOrderingRule, createToolUsageRule, defineTraceContract, deriveFailureFacts, deriveRelationshipFacts, evaluateToolArgumentValue, evaluateTraceContract, evaluateTraceContractRead, explainTraceContract, extractToolArgumentPayload, lintTraceContract,
|
|
1
|
+
export { buildTraceFacts, createBaselineRegressionRule, createDecisionRule, createGuardrailRule, createLlmUsageRule, createMaxStepDurationRule, createObservedOutcomeRule, createRequireCompletedRule, createRetrievalRule, createRunDepthRule, createRunDurationRule, createRunEventCountRule, createRunStatusRule, createSafetyOversizedAttributeRule, createSafetyRawContentRule, createSafetyRedactionRule, createSafetySecretPatternRule, createStallDetectionRule, createStepOrderingRule, createStructureCycleRule, createStructureIncompleteRule, createStructureOrphanRule, createStructureParallelWidthRule, createStructureRelationshipRule, createToolFailureRule, createToolOrderingRule, createToolUsageRule, defineTraceContract, deriveFailureFacts, deriveRelationshipFacts, evaluateToolArgumentValue, evaluateTraceContract, evaluateTraceContractRead, explainTraceContract, extractToolArgumentPayload, lintTraceContract, resolveJsonPointer, resolveTraceContractScope, runTraceChecks, summarizeSemanticParity, workflowMetadataForRun } from './chunk-2CCRUI42.mjs';
|
|
2
2
|
import './chunk-N5PZAI6Q.mjs';
|
|
3
3
|
import './chunk-DK3OW6UI.mjs';
|
|
4
4
|
import './chunk-VLVCLAPB.mjs';
|
|
5
|
-
export { PROGRAMMATIC_DIAGNOSTIC_SPECS, formatProgrammaticDiagnostic } from './chunk-
|
|
5
|
+
export { PROGRAMMATIC_DIAGNOSTIC_SPECS, formatProgrammaticDiagnostic, projectLogicalEvents, resolveCanonicalToolName } from './chunk-L5WLVBW4.mjs';
|
|
6
6
|
import './chunk-7DHSWDKB.mjs';
|
|
7
7
|
export { ATTRIBUTION_CONFIDENCES, ATTRIBUTION_CONFIDENCE_RANK, isAttributionConfidence } from './chunk-EE5Z2GQ3.mjs';
|
|
8
8
|
import './chunk-7TGZLWEE.mjs';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { OBSERVED_OUTCOME_METHODS, extractOutcomesFromPersistedEvents, outcomesMatchingStatus } from './chunk-N5PZAI6Q.mjs';
|
|
2
2
|
import { DEFAULT_CREDENTIAL_SENSITIVE_KEYS, isCredentialSensitiveKey } from './chunk-VLVCLAPB.mjs';
|
|
3
|
-
import { formatProgrammaticDiagnostic } from './chunk-
|
|
3
|
+
import { formatProgrammaticDiagnostic, projectLogicalEvents, resolveCanonicalToolName } from './chunk-L5WLVBW4.mjs';
|
|
4
4
|
import { isAttributionConfidence, ATTRIBUTION_CONFIDENCES, ATTRIBUTION_CONFIDENCE_RANK } from './chunk-EE5Z2GQ3.mjs';
|
|
5
5
|
|
|
6
6
|
// packages/core/src/sessions/metadata.ts
|
|
@@ -67,310 +67,11 @@ function sessionKeyForRun(meta, options) {
|
|
|
67
67
|
return void 0;
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
-
// packages/core/src/checks/
|
|
70
|
+
// packages/core/src/checks/derived-failure.ts
|
|
71
71
|
function isRecord(value) {
|
|
72
72
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
73
73
|
}
|
|
74
|
-
function legacyEvent(event) {
|
|
75
|
-
const value = event.attributes?.legacyEvent;
|
|
76
|
-
return typeof value === "string" ? value : void 0;
|
|
77
|
-
}
|
|
78
|
-
function stepIdOf(event) {
|
|
79
|
-
const value = event.attributes?.stepId;
|
|
80
|
-
if (typeof value === "string" && value.trim() !== "") return value;
|
|
81
|
-
return void 0;
|
|
82
|
-
}
|
|
83
|
-
function cloneEvent(event) {
|
|
84
|
-
return {
|
|
85
|
-
...event,
|
|
86
|
-
...event.attributes !== void 0 ? { attributes: { ...event.attributes } } : {},
|
|
87
|
-
...event.error !== void 0 ? { error: { ...event.error } } : {},
|
|
88
|
-
...event.tokenUsage !== void 0 ? { tokenUsage: { ...event.tokenUsage } } : {},
|
|
89
|
-
...event.source !== void 0 ? { source: { ...event.source } } : {}
|
|
90
|
-
};
|
|
91
|
-
}
|
|
92
|
-
function mergeAttributes(start, complete) {
|
|
93
|
-
const merged = {
|
|
94
|
-
...isRecord(complete.attributes) ? complete.attributes : {},
|
|
95
|
-
...isRecord(start.attributes) ? start.attributes : {}
|
|
96
|
-
};
|
|
97
|
-
merged.legacyEvent = start.attributes?.legacyEvent ?? complete.attributes?.legacyEvent;
|
|
98
|
-
merged.legacyCompleteEvent = complete.attributes?.legacyEvent;
|
|
99
|
-
if (complete.attributes?.errorStack !== void 0) {
|
|
100
|
-
merged.errorStack = complete.attributes.errorStack;
|
|
101
|
-
}
|
|
102
|
-
return Object.keys(merged).length > 0 ? merged : void 0;
|
|
103
|
-
}
|
|
104
|
-
function pairStartComplete(start, complete) {
|
|
105
|
-
const attributes = mergeAttributes(start, complete);
|
|
106
|
-
const paired = {
|
|
107
|
-
...cloneEvent(start),
|
|
108
|
-
status: complete.status,
|
|
109
|
-
timestamp: complete.timestamp ?? start.timestamp,
|
|
110
|
-
...complete.endedAt !== void 0 ? { endedAt: complete.endedAt } : {},
|
|
111
|
-
...complete.durationMs !== void 0 ? { durationMs: complete.durationMs } : {},
|
|
112
|
-
...complete.error !== void 0 ? { error: { ...complete.error } } : {},
|
|
113
|
-
...complete.tokenUsage !== void 0 && start.tokenUsage === void 0 ? { tokenUsage: { ...complete.tokenUsage } } : {},
|
|
114
|
-
...attributes !== void 0 ? { attributes } : {}
|
|
115
|
-
};
|
|
116
|
-
return {
|
|
117
|
-
...paired,
|
|
118
|
-
sourceEventIds: Object.freeze([start.eventId, complete.eventId]),
|
|
119
|
-
projection: {
|
|
120
|
-
paired: true,
|
|
121
|
-
absorbedEventIds: Object.freeze([complete.eventId]),
|
|
122
|
-
parentNormalized: false,
|
|
123
|
-
...start.parentId !== void 0 ? { originalParentId: start.parentId } : {}
|
|
124
|
-
}
|
|
125
|
-
};
|
|
126
|
-
}
|
|
127
|
-
function asLogical(event, extras) {
|
|
128
|
-
return {
|
|
129
|
-
...cloneEvent(event),
|
|
130
|
-
sourceEventIds: Object.freeze([event.eventId]),
|
|
131
|
-
projection: {
|
|
132
|
-
paired: false,
|
|
133
|
-
absorbedEventIds: Object.freeze([]),
|
|
134
|
-
parentNormalized: extras?.parentNormalized === true,
|
|
135
|
-
...{}
|
|
136
|
-
}
|
|
137
|
-
};
|
|
138
|
-
}
|
|
139
|
-
function projectLogicalEvents(events) {
|
|
140
|
-
const diagnostics = [];
|
|
141
|
-
const byRun = /* @__PURE__ */ new Map();
|
|
142
|
-
for (const event of events) {
|
|
143
|
-
const list = byRun.get(event.runId) ?? [];
|
|
144
|
-
list.push(event);
|
|
145
|
-
byRun.set(event.runId, list);
|
|
146
|
-
}
|
|
147
|
-
const absorbedIds = /* @__PURE__ */ new Set();
|
|
148
|
-
const logicalByRawId = /* @__PURE__ */ new Map();
|
|
149
|
-
const stepIdToLogicalId = /* @__PURE__ */ new Map();
|
|
150
|
-
const logical = [];
|
|
151
|
-
const orderedRuns = [...byRun.keys()].sort((a, b) => a.localeCompare(b));
|
|
152
|
-
for (const runId of orderedRuns) {
|
|
153
|
-
const runEvents = byRun.get(runId) ?? [];
|
|
154
|
-
const starts = [];
|
|
155
|
-
const completes = [];
|
|
156
|
-
const others = [];
|
|
157
|
-
for (const event of runEvents) {
|
|
158
|
-
const legacy = legacyEvent(event);
|
|
159
|
-
if (legacy === "step_started" || legacy === "run_started" && event.status === "running") {
|
|
160
|
-
starts.push(event);
|
|
161
|
-
} else if (legacy === "step_completed" || legacy === "run_completed") {
|
|
162
|
-
completes.push(event);
|
|
163
|
-
} else {
|
|
164
|
-
others.push(event);
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
const usedCompletes = /* @__PURE__ */ new Set();
|
|
168
|
-
for (const start of starts) {
|
|
169
|
-
const stepId = stepIdOf(start);
|
|
170
|
-
let match;
|
|
171
|
-
if (legacyEvent(start) === "run_started") {
|
|
172
|
-
const candidates = completes.filter(
|
|
173
|
-
(c) => !usedCompletes.has(c.eventId) && legacyEvent(c) === "run_completed"
|
|
174
|
-
);
|
|
175
|
-
if (candidates.length > 1) {
|
|
176
|
-
diagnostics.push({
|
|
177
|
-
code: "AI_LOGICAL_PAIR_AMBIGUOUS",
|
|
178
|
-
message: `Multiple run_completed rows for run ${runId}; using first by eventId.`,
|
|
179
|
-
eventIds: candidates.map((c) => c.eventId)
|
|
180
|
-
});
|
|
181
|
-
candidates.sort((a, b) => a.eventId.localeCompare(b.eventId));
|
|
182
|
-
}
|
|
183
|
-
match = candidates[0];
|
|
184
|
-
} else if (stepId) {
|
|
185
|
-
const candidates = completes.filter(
|
|
186
|
-
(c) => !usedCompletes.has(c.eventId) && legacyEvent(c) === "step_completed" && stepIdOf(c) === stepId
|
|
187
|
-
);
|
|
188
|
-
if (candidates.length > 1) {
|
|
189
|
-
diagnostics.push({
|
|
190
|
-
code: "AI_LOGICAL_PAIR_AMBIGUOUS",
|
|
191
|
-
message: `Multiple step_completed rows for stepId ${stepId}; using first by eventId.`,
|
|
192
|
-
eventIds: candidates.map((c) => c.eventId)
|
|
193
|
-
});
|
|
194
|
-
candidates.sort((a, b) => a.eventId.localeCompare(b.eventId));
|
|
195
|
-
}
|
|
196
|
-
match = candidates[0];
|
|
197
|
-
}
|
|
198
|
-
if (match) {
|
|
199
|
-
usedCompletes.add(match.eventId);
|
|
200
|
-
absorbedIds.add(match.eventId);
|
|
201
|
-
const paired = pairStartComplete(start, match);
|
|
202
|
-
logical.push(paired);
|
|
203
|
-
logicalByRawId.set(start.eventId, paired);
|
|
204
|
-
logicalByRawId.set(match.eventId, paired);
|
|
205
|
-
if (stepId) stepIdToLogicalId.set(`${runId}:${stepId}`, paired.eventId);
|
|
206
|
-
} else {
|
|
207
|
-
diagnostics.push({
|
|
208
|
-
code: "AI_LOGICAL_PAIR_UNMATCHED_START",
|
|
209
|
-
message: `No matching complete for start ${start.eventId}.`,
|
|
210
|
-
eventIds: [start.eventId]
|
|
211
|
-
});
|
|
212
|
-
const alone = asLogical(start);
|
|
213
|
-
logical.push(alone);
|
|
214
|
-
logicalByRawId.set(start.eventId, alone);
|
|
215
|
-
if (stepId) stepIdToLogicalId.set(`${runId}:${stepId}`, alone.eventId);
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
for (const complete of completes) {
|
|
219
|
-
if (usedCompletes.has(complete.eventId)) continue;
|
|
220
|
-
diagnostics.push({
|
|
221
|
-
code: "AI_LOGICAL_PAIR_UNMATCHED_COMPLETE",
|
|
222
|
-
message: `No matching start for complete ${complete.eventId}.`,
|
|
223
|
-
eventIds: [complete.eventId]
|
|
224
|
-
});
|
|
225
|
-
const alone = asLogical(complete);
|
|
226
|
-
logical.push(alone);
|
|
227
|
-
logicalByRawId.set(complete.eventId, alone);
|
|
228
|
-
const stepId = stepIdOf(complete);
|
|
229
|
-
if (stepId && !stepIdToLogicalId.has(`${runId}:${stepId}`)) {
|
|
230
|
-
stepIdToLogicalId.set(`${runId}:${stepId}`, alone.eventId);
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
for (const event of others) {
|
|
234
|
-
const alone = asLogical(event);
|
|
235
|
-
logical.push(alone);
|
|
236
|
-
logicalByRawId.set(event.eventId, alone);
|
|
237
|
-
const stepId = stepIdOf(event);
|
|
238
|
-
if (stepId && !stepIdToLogicalId.has(`${runId}:${stepId}`)) {
|
|
239
|
-
stepIdToLogicalId.set(`${runId}:${stepId}`, alone.eventId);
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
const logicalById = new Map(logical.map((e) => [e.eventId, e]));
|
|
244
|
-
const normalized = [];
|
|
245
|
-
for (const event of logical) {
|
|
246
|
-
const originalParentId = event.parentId;
|
|
247
|
-
if (!originalParentId) {
|
|
248
|
-
normalized.push(event);
|
|
249
|
-
continue;
|
|
250
|
-
}
|
|
251
|
-
let nextParent = originalParentId;
|
|
252
|
-
let remapped = false;
|
|
253
|
-
const viaAbsorbed = logicalByRawId.get(originalParentId);
|
|
254
|
-
if (viaAbsorbed && viaAbsorbed.eventId !== originalParentId) {
|
|
255
|
-
nextParent = viaAbsorbed.eventId;
|
|
256
|
-
remapped = true;
|
|
257
|
-
} else if (!logicalById.has(originalParentId)) {
|
|
258
|
-
const viaStep = stepIdToLogicalId.get(`${event.runId}:${originalParentId}`);
|
|
259
|
-
if (viaStep) {
|
|
260
|
-
nextParent = viaStep;
|
|
261
|
-
remapped = true;
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
|
-
if (!remapped) {
|
|
265
|
-
if (originalParentId === event.eventId) {
|
|
266
|
-
diagnostics.push({
|
|
267
|
-
code: "AI_LOGICAL_SELF_PARENT_REMOVED",
|
|
268
|
-
message: formatProgrammaticDiagnostic(
|
|
269
|
-
"AI_TRACE_RELATIONSHIP_SELF_PARENT",
|
|
270
|
-
`Removed self-parent edge on ${event.eventId}.`
|
|
271
|
-
),
|
|
272
|
-
eventIds: [event.eventId]
|
|
273
|
-
});
|
|
274
|
-
const { parentId: _drop, ...rest } = event;
|
|
275
|
-
normalized.push({
|
|
276
|
-
...rest,
|
|
277
|
-
projection: {
|
|
278
|
-
...event.projection,
|
|
279
|
-
parentNormalized: true,
|
|
280
|
-
originalParentId
|
|
281
|
-
}
|
|
282
|
-
});
|
|
283
|
-
continue;
|
|
284
|
-
}
|
|
285
|
-
if (!logicalById.has(originalParentId) && !logicalByRawId.has(originalParentId)) {
|
|
286
|
-
const mapping = event.attributes?.parentMapping;
|
|
287
|
-
const unresolved = mapping === "unresolved" || event.attributes?.parentUnresolved === true || event.attributes?.unresolvedParent === true || // LangGraph/framework scaffolding sentinel labels are not event ids.
|
|
288
|
-
/^LangGraph$/i.test(originalParentId) || originalParentId.startsWith("unresolved:");
|
|
289
|
-
if (!unresolved) {
|
|
290
|
-
diagnostics.push({
|
|
291
|
-
code: "AI_LOGICAL_PARENT_UNRESOLVED",
|
|
292
|
-
message: `Parent ${originalParentId} unresolved for ${event.eventId}.`,
|
|
293
|
-
eventIds: [event.eventId]
|
|
294
|
-
});
|
|
295
|
-
}
|
|
296
|
-
}
|
|
297
|
-
normalized.push(event);
|
|
298
|
-
continue;
|
|
299
|
-
}
|
|
300
|
-
if (nextParent === event.eventId) {
|
|
301
|
-
diagnostics.push({
|
|
302
|
-
code: "AI_LOGICAL_SELF_PARENT_REMOVED",
|
|
303
|
-
message: formatProgrammaticDiagnostic(
|
|
304
|
-
"AI_TRACE_RELATIONSHIP_SELF_PARENT",
|
|
305
|
-
`Removed self-parent edge on ${event.eventId} (was ${originalParentId}).`
|
|
306
|
-
),
|
|
307
|
-
eventIds: [event.eventId]
|
|
308
|
-
});
|
|
309
|
-
const { parentId: _drop, ...rest } = event;
|
|
310
|
-
normalized.push({
|
|
311
|
-
...rest,
|
|
312
|
-
projection: {
|
|
313
|
-
...event.projection,
|
|
314
|
-
parentNormalized: true,
|
|
315
|
-
originalParentId
|
|
316
|
-
}
|
|
317
|
-
});
|
|
318
|
-
continue;
|
|
319
|
-
}
|
|
320
|
-
diagnostics.push({
|
|
321
|
-
code: "AI_LOGICAL_PARENT_REMAPPED",
|
|
322
|
-
message: `Remapped parent ${originalParentId} \u2192 ${nextParent} for ${event.eventId}.`,
|
|
323
|
-
eventIds: [event.eventId]
|
|
324
|
-
});
|
|
325
|
-
normalized.push({
|
|
326
|
-
...event,
|
|
327
|
-
parentId: nextParent,
|
|
328
|
-
projection: {
|
|
329
|
-
...event.projection,
|
|
330
|
-
parentNormalized: true,
|
|
331
|
-
originalParentId
|
|
332
|
-
}
|
|
333
|
-
});
|
|
334
|
-
}
|
|
335
|
-
const rawIndex = new Map(events.map((e, i) => [e.eventId, i]));
|
|
336
|
-
normalized.sort((a, b) => {
|
|
337
|
-
const ai = rawIndex.get(a.sourceEventIds[0]) ?? 0;
|
|
338
|
-
const bi = rawIndex.get(b.sourceEventIds[0]) ?? 0;
|
|
339
|
-
return ai - bi || a.eventId.localeCompare(b.eventId);
|
|
340
|
-
});
|
|
341
|
-
return {
|
|
342
|
-
logicalEvents: Object.freeze(normalized),
|
|
343
|
-
diagnostics: Object.freeze(diagnostics)
|
|
344
|
-
};
|
|
345
|
-
}
|
|
346
|
-
function resolveCanonicalToolName(event) {
|
|
347
|
-
const attrs2 = event.attributes;
|
|
348
|
-
const direct = pickString(attrs2, ["toolName", "tool"]);
|
|
349
|
-
if (direct) return direct;
|
|
350
|
-
const metadata = attrs2?.metadata;
|
|
351
|
-
if (isRecord(metadata)) {
|
|
352
|
-
const nested = pickString(metadata, ["toolName", "tool"]);
|
|
353
|
-
if (nested) return nested;
|
|
354
|
-
}
|
|
355
|
-
for (const prefix of ["tool:", "function:", "mcp-tools:"]) {
|
|
356
|
-
if (event.name.startsWith(prefix)) return event.name.slice(prefix.length);
|
|
357
|
-
}
|
|
358
|
-
return event.name;
|
|
359
|
-
}
|
|
360
74
|
function pickString(record, keys) {
|
|
361
|
-
if (!record) return void 0;
|
|
362
|
-
for (const key of keys) {
|
|
363
|
-
const value = record[key];
|
|
364
|
-
if (typeof value === "string" && value.trim() !== "") return value.trim();
|
|
365
|
-
}
|
|
366
|
-
return void 0;
|
|
367
|
-
}
|
|
368
|
-
|
|
369
|
-
// packages/core/src/checks/derived-failure.ts
|
|
370
|
-
function isRecord2(value) {
|
|
371
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
372
|
-
}
|
|
373
|
-
function pickString2(record, keys) {
|
|
374
75
|
if (!record) return void 0;
|
|
375
76
|
for (const key of keys) {
|
|
376
77
|
const value = record[key];
|
|
@@ -389,8 +90,8 @@ function pickNumber(record, keys) {
|
|
|
389
90
|
return void 0;
|
|
390
91
|
}
|
|
391
92
|
function eventMetadata(event) {
|
|
392
|
-
const attrs2 =
|
|
393
|
-
const nested = attrs2 !== void 0 &&
|
|
93
|
+
const attrs2 = isRecord(event.attributes) ? event.attributes : void 0;
|
|
94
|
+
const nested = attrs2 !== void 0 && isRecord(attrs2.metadata) ? attrs2.metadata : void 0;
|
|
394
95
|
return {
|
|
395
96
|
...attrs2 ?? {},
|
|
396
97
|
...nested ?? {}
|
|
@@ -404,10 +105,10 @@ function linkKeys(event) {
|
|
|
404
105
|
const meta = eventMetadata(event);
|
|
405
106
|
const keys = [];
|
|
406
107
|
for (const key of ["linkedStepId", "toolCallId", "mcpToolCallId"]) {
|
|
407
|
-
const value =
|
|
108
|
+
const value = pickString(meta, [key]);
|
|
408
109
|
if (value !== void 0) keys.push(`${key}:${value}`);
|
|
409
110
|
}
|
|
410
|
-
const stepId =
|
|
111
|
+
const stepId = pickString(meta, ["stepId"]);
|
|
411
112
|
if (stepId !== void 0) keys.push(`stepId:${stepId}`);
|
|
412
113
|
return keys;
|
|
413
114
|
}
|
|
@@ -425,12 +126,12 @@ function buildRunContexts(logicalEvents) {
|
|
|
425
126
|
if (event.kind === "RUN" && event.status !== void 0 && event.status !== "running") {
|
|
426
127
|
existing.status = event.status;
|
|
427
128
|
}
|
|
428
|
-
existing.retryOf ??=
|
|
129
|
+
existing.retryOf ??= pickString(meta, ["retryOf"]);
|
|
429
130
|
existing.attempt ??= pickNumber(meta, ["attempt", "retryAttempt", "retryCount"]);
|
|
430
|
-
existing.sessionId ??=
|
|
431
|
-
existing.groupId ??=
|
|
432
|
-
existing.parentGroupId ??=
|
|
433
|
-
existing.fallbackOf ??=
|
|
131
|
+
existing.sessionId ??= pickString(meta, ["sessionId", "conversationId"]);
|
|
132
|
+
existing.groupId ??= pickString(meta, ["groupId"]);
|
|
133
|
+
existing.parentGroupId ??= pickString(meta, ["parentGroupId"]);
|
|
134
|
+
existing.fallbackOf ??= pickString(meta, ["fallbackOf", "fallbackFrom"]);
|
|
434
135
|
byRun.set(event.runId, existing);
|
|
435
136
|
}
|
|
436
137
|
return byRun;
|
|
@@ -475,7 +176,7 @@ function collectCandidates(failure, logicalEvents, runs) {
|
|
|
475
176
|
});
|
|
476
177
|
continue;
|
|
477
178
|
}
|
|
478
|
-
if (eventRun?.fallbackOf === failure.runId ||
|
|
179
|
+
if (eventRun?.fallbackOf === failure.runId || pickString(eventMeta, ["fallbackOf", "fallbackFrom"]) === failure.runId) {
|
|
479
180
|
candidates.push({
|
|
480
181
|
event,
|
|
481
182
|
basis: "fallbackOf",
|
|
@@ -580,7 +281,7 @@ function classifyFailure(failure, candidates, runs, logicalEvents) {
|
|
|
580
281
|
};
|
|
581
282
|
}
|
|
582
283
|
const failureMeta = eventMetadata(failure);
|
|
583
|
-
const declaredSuccessor =
|
|
284
|
+
const declaredSuccessor = pickString(failureMeta, [
|
|
584
285
|
"retriedBy",
|
|
585
286
|
"nextRetryRunId",
|
|
586
287
|
"retryRunId"
|
|
@@ -3761,7 +3462,7 @@ function finishedEvents(context, kind) {
|
|
|
3761
3462
|
function toolInvocationEvents(context) {
|
|
3762
3463
|
return semanticEvents(context).filter((event) => event.kind === "TOOL");
|
|
3763
3464
|
}
|
|
3764
|
-
function
|
|
3465
|
+
function isRecord2(value) {
|
|
3765
3466
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
3766
3467
|
}
|
|
3767
3468
|
function eventMap(events) {
|
|
@@ -3815,7 +3516,7 @@ function pushValueEntries(entries, event, value, path, key, depth = 0) {
|
|
|
3815
3516
|
}
|
|
3816
3517
|
return;
|
|
3817
3518
|
}
|
|
3818
|
-
if (!
|
|
3519
|
+
if (!isRecord2(value)) return;
|
|
3819
3520
|
for (const nestedKey of Object.keys(value).sort((a, b) => a.localeCompare(b))) {
|
|
3820
3521
|
pushValueEntries(
|
|
3821
3522
|
entries,
|
|
@@ -5154,7 +4855,7 @@ function createSafetyOversizedAttributeRule(options) {
|
|
|
5154
4855
|
)
|
|
5155
4856
|
);
|
|
5156
4857
|
}
|
|
5157
|
-
if (
|
|
4858
|
+
if (isRecord2(entry.value) && options.maxObjectKeys !== void 0 && Object.keys(entry.value).length > options.maxObjectKeys) {
|
|
5158
4859
|
findings.push(
|
|
5159
4860
|
failFinding(
|
|
5160
4861
|
"safety.oversizedAttribute",
|
|
@@ -5445,6 +5146,6 @@ function runTraceChecks(input, options = {}) {
|
|
|
5445
5146
|
};
|
|
5446
5147
|
}
|
|
5447
5148
|
|
|
5448
|
-
export { buildTraceFacts, createBaselineRegressionRule, createDecisionRule, createGuardrailRule, createLlmUsageRule, createMaxStepDurationRule, createObservedOutcomeRule, createRequireCompletedRule, createRetrievalRule, createRunDepthRule, createRunDurationRule, createRunEventCountRule, createRunStatusRule, createSafetyOversizedAttributeRule, createSafetyRawContentRule, createSafetyRedactionRule, createSafetySecretPatternRule, createStallDetectionRule, createStepOrderingRule, createStructureCycleRule, createStructureIncompleteRule, createStructureOrphanRule, createStructureParallelWidthRule, createStructureRelationshipRule, createToolFailureRule, createToolOrderingRule, createToolUsageRule, defineTraceContract, deriveFailureFacts, deriveRelationshipFacts, evaluateToolArgumentValue, evaluateTraceContract, evaluateTraceContractRead, explainTraceContract, extractSessionWorkflowMetadata, extractToolArgumentPayload, lintTraceContract,
|
|
5449
|
-
//# sourceMappingURL=chunk-
|
|
5450
|
-
//# sourceMappingURL=chunk-
|
|
5149
|
+
export { buildTraceFacts, createBaselineRegressionRule, createDecisionRule, createGuardrailRule, createLlmUsageRule, createMaxStepDurationRule, createObservedOutcomeRule, createRequireCompletedRule, createRetrievalRule, createRunDepthRule, createRunDurationRule, createRunEventCountRule, createRunStatusRule, createSafetyOversizedAttributeRule, createSafetyRawContentRule, createSafetyRedactionRule, createSafetySecretPatternRule, createStallDetectionRule, createStepOrderingRule, createStructureCycleRule, createStructureIncompleteRule, createStructureOrphanRule, createStructureParallelWidthRule, createStructureRelationshipRule, createToolFailureRule, createToolOrderingRule, createToolUsageRule, defineTraceContract, deriveFailureFacts, deriveRelationshipFacts, evaluateToolArgumentValue, evaluateTraceContract, evaluateTraceContractRead, explainTraceContract, extractSessionWorkflowMetadata, extractToolArgumentPayload, lintTraceContract, resolveJsonPointer, resolveTraceContractScope, runTraceChecks, sessionKeyForRun, summarizeSemanticParity, workflowMetadataForRun };
|
|
5150
|
+
//# sourceMappingURL=chunk-2CCRUI42.mjs.map
|
|
5151
|
+
//# sourceMappingURL=chunk-2CCRUI42.mjs.map
|