@agent-inspect/mcp-server 6.20.0 → 6.22.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/dist/{chunk-4FSMUSWK.mjs → chunk-URVZD6JW.mjs} +300 -81
- package/dist/chunk-URVZD6JW.mjs.map +1 -0
- package/dist/cli.cjs +298 -79
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.mjs +1 -1
- package/dist/index.cjs +298 -79
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +3 -3
- package/dist/chunk-4FSMUSWK.mjs.map +0 -1
|
@@ -472,16 +472,16 @@ function pickRunMetadata(attributes) {
|
|
|
472
472
|
return Object.keys(metadata).length > 0 ? metadata : void 0;
|
|
473
473
|
}
|
|
474
474
|
function resolveStepId(event) {
|
|
475
|
-
const
|
|
476
|
-
if (
|
|
477
|
-
return
|
|
475
|
+
const attrs2 = event.attributes;
|
|
476
|
+
if (attrs2 && typeof attrs2.stepId === "string" && attrs2.stepId.trim() !== "") {
|
|
477
|
+
return attrs2.stepId;
|
|
478
478
|
}
|
|
479
479
|
return event.eventId;
|
|
480
480
|
}
|
|
481
481
|
function resolveStepType(event) {
|
|
482
|
-
const
|
|
483
|
-
if (
|
|
484
|
-
const t =
|
|
482
|
+
const attrs2 = event.attributes;
|
|
483
|
+
if (attrs2 && typeof attrs2.stepType === "string") {
|
|
484
|
+
const t = attrs2.stepType;
|
|
485
485
|
if (t === "run" || t === "llm" || t === "tool" || t === "decision" || t === "logic" || t === "state" || t === "custom") {
|
|
486
486
|
return t;
|
|
487
487
|
}
|
|
@@ -562,26 +562,26 @@ function fromLegacyStepCompleted(event) {
|
|
|
562
562
|
return out;
|
|
563
563
|
}
|
|
564
564
|
function fromLegacyOutcomeObserved(event) {
|
|
565
|
-
const
|
|
566
|
-
const observedAtRaw =
|
|
565
|
+
const attrs2 = event.attributes ?? {};
|
|
566
|
+
const observedAtRaw = attrs2.observedAt;
|
|
567
567
|
const observedAt = typeof observedAtRaw === "string" ? Date.parse(observedAtRaw) : typeof observedAtRaw === "number" && Number.isFinite(observedAtRaw) ? observedAtRaw : resolveTimes(event).timestamp;
|
|
568
|
-
const status =
|
|
568
|
+
const status = attrs2.outcomeStatus;
|
|
569
569
|
const out = {
|
|
570
570
|
schemaVersion: "0.1",
|
|
571
571
|
event: "outcome_observed",
|
|
572
572
|
timestamp: observedAt,
|
|
573
573
|
runId: event.runId,
|
|
574
|
-
outcomeId: typeof
|
|
574
|
+
outcomeId: typeof attrs2.outcomeId === "string" ? attrs2.outcomeId : event.eventId,
|
|
575
575
|
name: event.name,
|
|
576
|
-
expectation: typeof
|
|
576
|
+
expectation: typeof attrs2.expectation === "string" ? attrs2.expectation : event.name,
|
|
577
577
|
status: status === "passed" || status === "failed" || status === "unknown" || status === "skipped" ? status : "unknown",
|
|
578
578
|
observedAt
|
|
579
579
|
};
|
|
580
580
|
if (event.parentId !== void 0) out.parentId = event.parentId;
|
|
581
|
-
if (typeof
|
|
582
|
-
if (
|
|
581
|
+
if (typeof attrs2.method === "string") out.method = attrs2.method;
|
|
582
|
+
if (attrs2.actual !== void 0) out.actual = attrs2.actual;
|
|
583
583
|
if (event.outputSummary !== void 0) out.actual = event.outputSummary;
|
|
584
|
-
if (
|
|
584
|
+
if (attrs2.evidence !== void 0) out.evidence = attrs2.evidence;
|
|
585
585
|
return out;
|
|
586
586
|
}
|
|
587
587
|
function fromNativeOutcome(event) {
|
|
@@ -966,6 +966,17 @@ var OBSERVED_OUTCOME_STATUSES = [
|
|
|
966
966
|
"unknown",
|
|
967
967
|
"skipped"
|
|
968
968
|
];
|
|
969
|
+
var OBSERVED_OUTCOME_METHODS = [
|
|
970
|
+
"dom",
|
|
971
|
+
"accessibility",
|
|
972
|
+
"snapshot",
|
|
973
|
+
"network",
|
|
974
|
+
"storage",
|
|
975
|
+
"filesystem",
|
|
976
|
+
"database",
|
|
977
|
+
"queue",
|
|
978
|
+
"custom"
|
|
979
|
+
];
|
|
969
980
|
var OUTCOME_LEGACY_EVENT = "outcome_observed";
|
|
970
981
|
|
|
971
982
|
// packages/core/src/outcomes/validate.ts
|
|
@@ -1978,6 +1989,63 @@ async function loadTraceMetadataList(_traceDir, fileNames, getPath) {
|
|
|
1978
1989
|
return metas;
|
|
1979
1990
|
}
|
|
1980
1991
|
|
|
1992
|
+
// packages/core/src/sessions/metadata.ts
|
|
1993
|
+
function isNonEmptyString3(value) {
|
|
1994
|
+
return typeof value === "string" && value.trim() !== "";
|
|
1995
|
+
}
|
|
1996
|
+
function finitePositiveInt(value) {
|
|
1997
|
+
if (typeof value !== "number" || !Number.isFinite(value) || value < 1) {
|
|
1998
|
+
return void 0;
|
|
1999
|
+
}
|
|
2000
|
+
return Math.trunc(value);
|
|
2001
|
+
}
|
|
2002
|
+
function extractSessionWorkflowMetadata(record) {
|
|
2003
|
+
if (!record) return void 0;
|
|
2004
|
+
const out = {};
|
|
2005
|
+
let found = false;
|
|
2006
|
+
const assignString = (key, value) => {
|
|
2007
|
+
if (isNonEmptyString3(value)) {
|
|
2008
|
+
out[key] = value.trim();
|
|
2009
|
+
found = true;
|
|
2010
|
+
}
|
|
2011
|
+
};
|
|
2012
|
+
assignString("sessionId", record.sessionId);
|
|
2013
|
+
assignString("conversationId", record.conversationId);
|
|
2014
|
+
assignString("groupId", record.groupId);
|
|
2015
|
+
assignString("parentGroupId", record.parentGroupId);
|
|
2016
|
+
assignString("retryOf", record.retryOf);
|
|
2017
|
+
assignString("retryReason", record.retryReason);
|
|
2018
|
+
assignString("handoffFrom", record.handoffFrom);
|
|
2019
|
+
assignString("handoffTo", record.handoffTo);
|
|
2020
|
+
assignString("subAgentId", record.subAgentId);
|
|
2021
|
+
assignString("subAgentName", record.subAgentName);
|
|
2022
|
+
assignString("jobId", record.jobId);
|
|
2023
|
+
assignString("queueName", record.queueName);
|
|
2024
|
+
assignString("workflowName", record.workflowName);
|
|
2025
|
+
assignString("workflowStep", record.workflowStep);
|
|
2026
|
+
assignString("toolCallId", record.toolCallId);
|
|
2027
|
+
assignString("mcpToolCallId", record.mcpToolCallId);
|
|
2028
|
+
assignString("linkedStepId", record.linkedStepId);
|
|
2029
|
+
assignString("operationId", record.operationId);
|
|
2030
|
+
assignString("attemptId", record.attemptId);
|
|
2031
|
+
assignString("fallbackOf", record.fallbackOf);
|
|
2032
|
+
assignString("idempotencyKey", record.idempotencyKey);
|
|
2033
|
+
assignString("correlationId", record.correlationId);
|
|
2034
|
+
assignString("requestId", record.requestId);
|
|
2035
|
+
assignString("decisionId", record.decisionId);
|
|
2036
|
+
const attempt = finitePositiveInt(record.attempt);
|
|
2037
|
+
if (attempt !== void 0) {
|
|
2038
|
+
out.attempt = attempt;
|
|
2039
|
+
found = true;
|
|
2040
|
+
}
|
|
2041
|
+
const attemptNumber = finitePositiveInt(record.attemptNumber);
|
|
2042
|
+
if (attemptNumber !== void 0) {
|
|
2043
|
+
out.attemptNumber = attemptNumber;
|
|
2044
|
+
found = true;
|
|
2045
|
+
}
|
|
2046
|
+
return found ? out : void 0;
|
|
2047
|
+
}
|
|
2048
|
+
|
|
1981
2049
|
// packages/core/src/bundle/safety-status.ts
|
|
1982
2050
|
function aggregateBundleSafeStatus(statuses) {
|
|
1983
2051
|
if (statuses.length === 0) return "UNKNOWN";
|
|
@@ -2190,17 +2258,17 @@ function stableJson(value, pretty) {
|
|
|
2190
2258
|
const sorted = sortKeysDeep(value);
|
|
2191
2259
|
return pretty === true ? JSON.stringify(sorted, null, 2) : JSON.stringify(sorted);
|
|
2192
2260
|
}
|
|
2193
|
-
function compactAttributes(
|
|
2194
|
-
if (
|
|
2261
|
+
function compactAttributes(attrs2, options) {
|
|
2262
|
+
if (attrs2 === void 0) return {};
|
|
2195
2263
|
const maxLen = options?.maxLength ?? 500;
|
|
2196
2264
|
const redacted = options?.redacted ?? true;
|
|
2197
2265
|
const out = {};
|
|
2198
|
-
for (const key of Object.keys(
|
|
2266
|
+
for (const key of Object.keys(attrs2).sort()) {
|
|
2199
2267
|
if (redacted && shouldRedactKey(key)) {
|
|
2200
2268
|
out[key] = "[REDACTED]";
|
|
2201
2269
|
continue;
|
|
2202
2270
|
}
|
|
2203
|
-
const v =
|
|
2271
|
+
const v = attrs2[key];
|
|
2204
2272
|
out[key] = compactValue(v, maxLen, redacted);
|
|
2205
2273
|
}
|
|
2206
2274
|
return out;
|
|
@@ -3011,10 +3079,10 @@ function projectLogicalEvents(events) {
|
|
|
3011
3079
|
};
|
|
3012
3080
|
}
|
|
3013
3081
|
function resolveCanonicalToolName(event) {
|
|
3014
|
-
const
|
|
3015
|
-
const direct = pickString(
|
|
3082
|
+
const attrs2 = event.attributes;
|
|
3083
|
+
const direct = pickString(attrs2, ["toolName", "tool"]);
|
|
3016
3084
|
if (direct) return direct;
|
|
3017
|
-
const metadata =
|
|
3085
|
+
const metadata = attrs2?.metadata;
|
|
3018
3086
|
if (isRecord6(metadata)) {
|
|
3019
3087
|
const nested = pickString(metadata, ["toolName", "tool"]);
|
|
3020
3088
|
if (nested) return nested;
|
|
@@ -3056,10 +3124,10 @@ function pickNumber(record, keys) {
|
|
|
3056
3124
|
return void 0;
|
|
3057
3125
|
}
|
|
3058
3126
|
function eventMetadata(event) {
|
|
3059
|
-
const
|
|
3060
|
-
const nested =
|
|
3127
|
+
const attrs2 = isRecord7(event.attributes) ? event.attributes : void 0;
|
|
3128
|
+
const nested = attrs2 !== void 0 && isRecord7(attrs2.metadata) ? attrs2.metadata : void 0;
|
|
3061
3129
|
return {
|
|
3062
|
-
...
|
|
3130
|
+
...attrs2 ?? {},
|
|
3063
3131
|
...nested ?? {}
|
|
3064
3132
|
};
|
|
3065
3133
|
}
|
|
@@ -3352,6 +3420,151 @@ function deriveFailureFacts(logicalEvents) {
|
|
|
3352
3420
|
};
|
|
3353
3421
|
}
|
|
3354
3422
|
|
|
3423
|
+
// packages/core/src/checks/relationship-facts.ts
|
|
3424
|
+
function attrs(event) {
|
|
3425
|
+
return event.attributes && typeof event.attributes === "object" ? event.attributes : {};
|
|
3426
|
+
}
|
|
3427
|
+
function stringAttr(record, key) {
|
|
3428
|
+
const value = record[key];
|
|
3429
|
+
return typeof value === "string" && value.trim() !== "" ? value.trim() : void 0;
|
|
3430
|
+
}
|
|
3431
|
+
function deriveRelationshipFacts(events) {
|
|
3432
|
+
const relationships = [];
|
|
3433
|
+
const diagnostics = [];
|
|
3434
|
+
const byId = new Map(events.map((event) => [event.eventId, event]));
|
|
3435
|
+
const seen = /* @__PURE__ */ new Set();
|
|
3436
|
+
const push = (edge) => {
|
|
3437
|
+
const key = `${edge.type}:${edge.fromEventId}:${edge.toEventId ?? ""}:${edge.externalRef ?? ""}`;
|
|
3438
|
+
if (seen.has(key)) return;
|
|
3439
|
+
seen.add(key);
|
|
3440
|
+
relationships.push(edge);
|
|
3441
|
+
};
|
|
3442
|
+
for (const event of events) {
|
|
3443
|
+
if (event.parentId) {
|
|
3444
|
+
push({
|
|
3445
|
+
type: "parent-child",
|
|
3446
|
+
fromEventId: event.parentId,
|
|
3447
|
+
toEventId: event.eventId,
|
|
3448
|
+
confidence: byId.has(event.parentId) ? "explicit" : "unknown",
|
|
3449
|
+
basis: ["persisted.parentId"]
|
|
3450
|
+
});
|
|
3451
|
+
if (!byId.has(event.parentId)) {
|
|
3452
|
+
diagnostics.push({
|
|
3453
|
+
code: "AI_RELATIONSHIP_PARENT_MISSING",
|
|
3454
|
+
message: `parentId ${event.parentId} is not present in the event set.`,
|
|
3455
|
+
eventId: event.eventId
|
|
3456
|
+
});
|
|
3457
|
+
}
|
|
3458
|
+
}
|
|
3459
|
+
const bag = attrs(event);
|
|
3460
|
+
const meta = extractSessionWorkflowMetadata(bag) ?? {};
|
|
3461
|
+
const nested = bag.metadata && typeof bag.metadata === "object" ? extractSessionWorkflowMetadata(bag.metadata) : void 0;
|
|
3462
|
+
const workflow = { ...meta, ...nested };
|
|
3463
|
+
if (workflow.retryOf) {
|
|
3464
|
+
const target = events.find((candidate) => candidate.runId === workflow.retryOf);
|
|
3465
|
+
push({
|
|
3466
|
+
type: "retry-of",
|
|
3467
|
+
fromEventId: event.eventId,
|
|
3468
|
+
...target ? { toEventId: target.eventId } : {},
|
|
3469
|
+
externalRef: workflow.retryOf,
|
|
3470
|
+
confidence: target ? "explicit" : "correlated",
|
|
3471
|
+
basis: ["attributes.retryOf"]
|
|
3472
|
+
});
|
|
3473
|
+
}
|
|
3474
|
+
const attemptOf = stringAttr(bag, "attemptOf") ?? stringAttr(bag, "operationId");
|
|
3475
|
+
if (attemptOf && workflow.attempt !== void 0) {
|
|
3476
|
+
push({
|
|
3477
|
+
type: "attempt-of",
|
|
3478
|
+
fromEventId: event.eventId,
|
|
3479
|
+
externalRef: attemptOf,
|
|
3480
|
+
confidence: "explicit",
|
|
3481
|
+
basis: workflow.attempt !== void 0 ? ["attributes.attempt", "attributes.operationId"] : ["attributes.operationId"]
|
|
3482
|
+
});
|
|
3483
|
+
}
|
|
3484
|
+
const fallbackOf = stringAttr(bag, "fallbackOf");
|
|
3485
|
+
if (fallbackOf) {
|
|
3486
|
+
push({
|
|
3487
|
+
type: "fallback-of",
|
|
3488
|
+
fromEventId: event.eventId,
|
|
3489
|
+
externalRef: fallbackOf,
|
|
3490
|
+
confidence: "explicit",
|
|
3491
|
+
basis: ["attributes.fallbackOf"]
|
|
3492
|
+
});
|
|
3493
|
+
}
|
|
3494
|
+
const remediationOf = stringAttr(bag, "remediationOf");
|
|
3495
|
+
if (remediationOf) {
|
|
3496
|
+
push({
|
|
3497
|
+
type: "remediation-of",
|
|
3498
|
+
fromEventId: event.eventId,
|
|
3499
|
+
externalRef: remediationOf,
|
|
3500
|
+
confidence: "explicit",
|
|
3501
|
+
basis: ["attributes.remediationOf"]
|
|
3502
|
+
});
|
|
3503
|
+
}
|
|
3504
|
+
const evidenceFor = stringAttr(bag, "evidenceFor");
|
|
3505
|
+
if (evidenceFor) {
|
|
3506
|
+
push({
|
|
3507
|
+
type: "evidence-for",
|
|
3508
|
+
fromEventId: event.eventId,
|
|
3509
|
+
...byId.has(evidenceFor) ? { toEventId: evidenceFor } : { externalRef: evidenceFor },
|
|
3510
|
+
confidence: byId.has(evidenceFor) ? "explicit" : "correlated",
|
|
3511
|
+
basis: ["attributes.evidenceFor"]
|
|
3512
|
+
});
|
|
3513
|
+
}
|
|
3514
|
+
const acceptedBy = stringAttr(bag, "acceptedBy");
|
|
3515
|
+
if (acceptedBy) {
|
|
3516
|
+
push({
|
|
3517
|
+
type: "accepted-by",
|
|
3518
|
+
fromEventId: event.eventId,
|
|
3519
|
+
...byId.has(acceptedBy) ? { toEventId: acceptedBy } : { externalRef: acceptedBy },
|
|
3520
|
+
confidence: byId.has(acceptedBy) ? "explicit" : "correlated",
|
|
3521
|
+
basis: ["attributes.acceptedBy"]
|
|
3522
|
+
});
|
|
3523
|
+
}
|
|
3524
|
+
const supersedes = stringAttr(bag, "supersedes");
|
|
3525
|
+
if (supersedes) {
|
|
3526
|
+
push({
|
|
3527
|
+
type: "supersedes",
|
|
3528
|
+
fromEventId: event.eventId,
|
|
3529
|
+
...byId.has(supersedes) ? { toEventId: supersedes } : { externalRef: supersedes },
|
|
3530
|
+
confidence: byId.has(supersedes) ? "explicit" : "correlated",
|
|
3531
|
+
basis: ["attributes.supersedes"]
|
|
3532
|
+
});
|
|
3533
|
+
}
|
|
3534
|
+
const sourceLineage = stringAttr(bag, "sourceLineage") ?? stringAttr(bag, "sourceEventId");
|
|
3535
|
+
if (sourceLineage) {
|
|
3536
|
+
push({
|
|
3537
|
+
type: "source-lineage",
|
|
3538
|
+
fromEventId: event.eventId,
|
|
3539
|
+
externalRef: sourceLineage,
|
|
3540
|
+
confidence: "explicit",
|
|
3541
|
+
basis: ["attributes.sourceLineage"]
|
|
3542
|
+
});
|
|
3543
|
+
}
|
|
3544
|
+
const unsupported = stringAttr(bag, "relationshipType");
|
|
3545
|
+
if (unsupported && unsupported !== "parent-child" && ![
|
|
3546
|
+
"source-lineage",
|
|
3547
|
+
"attempt-of",
|
|
3548
|
+
"retry-of",
|
|
3549
|
+
"fallback-of",
|
|
3550
|
+
"remediation-of",
|
|
3551
|
+
"evidence-for",
|
|
3552
|
+
"accepted-by",
|
|
3553
|
+
"supersedes"
|
|
3554
|
+
].includes(unsupported)) {
|
|
3555
|
+
diagnostics.push({
|
|
3556
|
+
code: "AI_RELATIONSHIP_UNSUPPORTED_TYPE",
|
|
3557
|
+
message: `Unsupported relationshipType ${unsupported} was reported without flattening.`,
|
|
3558
|
+
eventId: event.eventId
|
|
3559
|
+
});
|
|
3560
|
+
}
|
|
3561
|
+
}
|
|
3562
|
+
return {
|
|
3563
|
+
relationships: Object.freeze(relationships),
|
|
3564
|
+
diagnostics: Object.freeze(diagnostics)
|
|
3565
|
+
};
|
|
3566
|
+
}
|
|
3567
|
+
|
|
3355
3568
|
// packages/core/src/checks/trace-facts.ts
|
|
3356
3569
|
function summarizeSemanticParity(events) {
|
|
3357
3570
|
const projection = projectLogicalEvents(events);
|
|
@@ -3438,6 +3651,7 @@ function buildTraceFacts(input) {
|
|
|
3438
3651
|
toolsByName.set(name, Object.freeze([...list]));
|
|
3439
3652
|
}
|
|
3440
3653
|
const derived = deriveFailureFacts(projection.logicalEvents);
|
|
3654
|
+
const relationship = deriveRelationshipFacts(events);
|
|
3441
3655
|
const summary = summarizeSemanticParity(events);
|
|
3442
3656
|
return {
|
|
3443
3657
|
rawEvents: Object.freeze([...events]),
|
|
@@ -3451,10 +3665,15 @@ function buildTraceFacts(input) {
|
|
|
3451
3665
|
failureRoleCounts: derived.failureRoleCounts
|
|
3452
3666
|
},
|
|
3453
3667
|
failureFacts: derived.failureFacts,
|
|
3454
|
-
failuresByRole: derived.failuresByRole
|
|
3668
|
+
failuresByRole: derived.failuresByRole,
|
|
3669
|
+
relationships: relationship.relationships,
|
|
3670
|
+
relationshipDiagnostics: relationship.diagnostics
|
|
3455
3671
|
};
|
|
3456
3672
|
}
|
|
3457
3673
|
|
|
3674
|
+
// packages/core/src/checks/contract.ts
|
|
3675
|
+
new Set(OBSERVED_OUTCOME_METHODS);
|
|
3676
|
+
|
|
3458
3677
|
// packages/core/src/checks/index.ts
|
|
3459
3678
|
var SEVERITY_RANK = {
|
|
3460
3679
|
error: 0,
|
|
@@ -4630,20 +4849,20 @@ function parseIsoToMs3(iso) {
|
|
|
4630
4849
|
return { ms: parsed, invalidTimestamp: false };
|
|
4631
4850
|
}
|
|
4632
4851
|
function mapPersistedSourceToInspect(event) {
|
|
4633
|
-
const
|
|
4852
|
+
const attrs2 = event.attributes ?? {};
|
|
4634
4853
|
const sourceName = event.source.name;
|
|
4635
4854
|
if (sourceName === "pino") {
|
|
4636
4855
|
return {
|
|
4637
4856
|
type: "pino",
|
|
4638
|
-
file: typeof
|
|
4639
|
-
line: typeof
|
|
4857
|
+
file: typeof attrs2.sourceFile === "string" ? attrs2.sourceFile : void 0,
|
|
4858
|
+
line: typeof attrs2.sourceLine === "number" ? attrs2.sourceLine : void 0
|
|
4640
4859
|
};
|
|
4641
4860
|
}
|
|
4642
4861
|
if (sourceName === "winston") {
|
|
4643
4862
|
return {
|
|
4644
4863
|
type: "winston",
|
|
4645
|
-
file: typeof
|
|
4646
|
-
line: typeof
|
|
4864
|
+
file: typeof attrs2.sourceFile === "string" ? attrs2.sourceFile : void 0,
|
|
4865
|
+
line: typeof attrs2.sourceLine === "number" ? attrs2.sourceLine : void 0
|
|
4647
4866
|
};
|
|
4648
4867
|
}
|
|
4649
4868
|
const mapType = (t) => {
|
|
@@ -4664,55 +4883,55 @@ function mapPersistedSourceToInspect(event) {
|
|
|
4664
4883
|
};
|
|
4665
4884
|
return {
|
|
4666
4885
|
type: mapType(event.source.type),
|
|
4667
|
-
file: typeof
|
|
4668
|
-
line: typeof
|
|
4886
|
+
file: typeof attrs2.sourceFile === "string" ? attrs2.sourceFile : void 0,
|
|
4887
|
+
line: typeof attrs2.sourceLine === "number" ? attrs2.sourceLine : void 0
|
|
4669
4888
|
};
|
|
4670
4889
|
}
|
|
4671
4890
|
function buildInspectAttributes(event) {
|
|
4672
|
-
const
|
|
4891
|
+
const attrs2 = event.attributes !== void 0 ? { ...event.attributes } : {};
|
|
4673
4892
|
if (event.inputSummary !== void 0) {
|
|
4674
|
-
|
|
4893
|
+
attrs2.inputSummary = event.inputSummary;
|
|
4675
4894
|
}
|
|
4676
4895
|
if (event.outputSummary !== void 0) {
|
|
4677
|
-
|
|
4896
|
+
attrs2.outputSummary = event.outputSummary;
|
|
4678
4897
|
}
|
|
4679
4898
|
if (event.error) {
|
|
4680
4899
|
if (event.error.name !== void 0) {
|
|
4681
|
-
|
|
4900
|
+
attrs2.errorName = event.error.name;
|
|
4682
4901
|
}
|
|
4683
|
-
|
|
4902
|
+
attrs2.errorMessage = event.error.message;
|
|
4684
4903
|
if (event.error.code !== void 0) {
|
|
4685
|
-
|
|
4904
|
+
attrs2.errorCode = event.error.code;
|
|
4686
4905
|
}
|
|
4687
4906
|
}
|
|
4688
4907
|
if (event.tokenUsage) {
|
|
4689
|
-
|
|
4908
|
+
attrs2.tokens = { ...event.tokenUsage };
|
|
4690
4909
|
}
|
|
4691
4910
|
if (event.source.type === "ai-sdk" || event.source.type === "otel") {
|
|
4692
|
-
|
|
4911
|
+
attrs2.originalSourceType = event.source.type;
|
|
4693
4912
|
}
|
|
4694
4913
|
if (event.source.name !== void 0) {
|
|
4695
|
-
|
|
4914
|
+
attrs2.sourceName = event.source.name;
|
|
4696
4915
|
}
|
|
4697
4916
|
if (event.source.version !== void 0) {
|
|
4698
|
-
|
|
4917
|
+
attrs2.sourceVersion = event.source.version;
|
|
4699
4918
|
}
|
|
4700
|
-
return
|
|
4919
|
+
return attrs2;
|
|
4701
4920
|
}
|
|
4702
4921
|
function persistedInspectEventToInspectEvent(event) {
|
|
4703
4922
|
if (!isPersistedInspectEvent(event)) {
|
|
4704
4923
|
throw new Error("Invalid PersistedInspectEvent: failed isPersistedInspectEvent");
|
|
4705
4924
|
}
|
|
4706
4925
|
const ts = parseIsoToMs3(event.timestamp);
|
|
4707
|
-
const
|
|
4926
|
+
const attrs2 = buildInspectAttributes(event);
|
|
4708
4927
|
if (ts.invalidTimestamp) {
|
|
4709
|
-
|
|
4928
|
+
attrs2.invalidTimestamp = true;
|
|
4710
4929
|
}
|
|
4711
4930
|
let status;
|
|
4712
4931
|
if (event.status === "running" || event.status === "ok" || event.status === "error") {
|
|
4713
4932
|
status = event.status;
|
|
4714
4933
|
} else if (event.status === "unknown") {
|
|
4715
|
-
|
|
4934
|
+
attrs2.persistedStatus = "unknown";
|
|
4716
4935
|
}
|
|
4717
4936
|
const out = {
|
|
4718
4937
|
eventId: event.eventId,
|
|
@@ -4722,7 +4941,7 @@ function persistedInspectEventToInspectEvent(event) {
|
|
|
4722
4941
|
timestamp: ts.ms,
|
|
4723
4942
|
confidence: event.confidence,
|
|
4724
4943
|
source: mapPersistedSourceToInspect(event),
|
|
4725
|
-
attributes: compactAttributes3(
|
|
4944
|
+
attributes: compactAttributes3(attrs2)
|
|
4726
4945
|
};
|
|
4727
4946
|
if (event.parentId !== void 0) {
|
|
4728
4947
|
out.parentId = event.parentId;
|
|
@@ -5065,13 +5284,13 @@ function persistedEventsForParsedTrace(parsed) {
|
|
|
5065
5284
|
function isRecord10(value) {
|
|
5066
5285
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
5067
5286
|
}
|
|
5068
|
-
function
|
|
5287
|
+
function isNonEmptyString4(value) {
|
|
5069
5288
|
return typeof value === "string" && value.trim() !== "";
|
|
5070
5289
|
}
|
|
5071
5290
|
function readStringField(record, keys) {
|
|
5072
5291
|
for (const key of keys) {
|
|
5073
5292
|
const value = record[key];
|
|
5074
|
-
if (
|
|
5293
|
+
if (isNonEmptyString4(value)) return value;
|
|
5075
5294
|
}
|
|
5076
5295
|
return void 0;
|
|
5077
5296
|
}
|
|
@@ -5205,7 +5424,7 @@ function parseUnixNanoToIso(value) {
|
|
|
5205
5424
|
return void 0;
|
|
5206
5425
|
}
|
|
5207
5426
|
function parseIsoTime(value) {
|
|
5208
|
-
if (!
|
|
5427
|
+
if (!isNonEmptyString4(value)) return void 0;
|
|
5209
5428
|
const ms = Date.parse(value);
|
|
5210
5429
|
if (!Number.isFinite(ms)) return void 0;
|
|
5211
5430
|
return new Date(ms).toISOString();
|
|
@@ -6433,11 +6652,11 @@ function boundValue(value, key, maxMetadataValueLength, maxPreviewLength, seen,
|
|
|
6433
6652
|
depth + 1
|
|
6434
6653
|
);
|
|
6435
6654
|
}
|
|
6436
|
-
function redactEventAttributes(
|
|
6437
|
-
if (!
|
|
6438
|
-
return
|
|
6655
|
+
function redactEventAttributes(attrs2, redactor, maxMetadataValueLength, maxPreviewLength) {
|
|
6656
|
+
if (!attrs2 || Object.keys(attrs2).length === 0) {
|
|
6657
|
+
return attrs2;
|
|
6439
6658
|
}
|
|
6440
|
-
const redacted = redactor.redactRecord(
|
|
6659
|
+
const redacted = redactor.redactRecord(attrs2);
|
|
6441
6660
|
const seen = /* @__PURE__ */ new WeakSet();
|
|
6442
6661
|
const bounded = boundAttributeValues(
|
|
6443
6662
|
redacted,
|
|
@@ -6823,7 +7042,7 @@ function exportOpenInference(tree, options) {
|
|
|
6823
7042
|
endNs = startNs + unixNano(ev.durationMs);
|
|
6824
7043
|
}
|
|
6825
7044
|
const { openInferenceKind } = mapInspectKindToOI(ev.kind, warnings);
|
|
6826
|
-
const
|
|
7045
|
+
const attrs2 = {
|
|
6827
7046
|
"openinference.span.kind": openInferenceKind,
|
|
6828
7047
|
"agent_inspect.kind": ev.kind,
|
|
6829
7048
|
"agent_inspect.confidence": ev.confidence,
|
|
@@ -6833,24 +7052,24 @@ function exportOpenInference(tree, options) {
|
|
|
6833
7052
|
"agent_inspect.status": ev.status ?? "unset"
|
|
6834
7053
|
};
|
|
6835
7054
|
if (ev.durationMs !== void 0) {
|
|
6836
|
-
|
|
7055
|
+
attrs2["agent_inspect.duration_ms"] = ev.durationMs;
|
|
6837
7056
|
}
|
|
6838
7057
|
const meta = ev.attributes;
|
|
6839
7058
|
if (meta?.model !== void 0 && typeof meta.model === "string") {
|
|
6840
|
-
|
|
7059
|
+
attrs2["llm.model_name"] = meta.model;
|
|
6841
7060
|
}
|
|
6842
7061
|
const tokens = meta?.tokens;
|
|
6843
7062
|
if (tokens && typeof tokens === "object" && tokens !== null) {
|
|
6844
7063
|
const inp = tokens.input;
|
|
6845
7064
|
const outp = tokens.output;
|
|
6846
|
-
if (typeof inp === "number")
|
|
6847
|
-
if (typeof outp === "number")
|
|
7065
|
+
if (typeof inp === "number") attrs2["llm.token_count.prompt"] = inp;
|
|
7066
|
+
if (typeof outp === "number") attrs2["llm.token_count.completion"] = outp;
|
|
6848
7067
|
}
|
|
6849
7068
|
if (includeAttributes && meta && typeof meta === "object") {
|
|
6850
7069
|
for (const [k, v] of Object.entries(meta)) {
|
|
6851
7070
|
if (k === "tokens" || k === "model") continue;
|
|
6852
7071
|
if (v !== void 0 && v !== null && typeof v !== "object") {
|
|
6853
|
-
|
|
7072
|
+
attrs2[`agent_inspect.preview.${k}`] = typeof v === "string" ? v.slice(0, maxLen) : v;
|
|
6854
7073
|
}
|
|
6855
7074
|
}
|
|
6856
7075
|
}
|
|
@@ -6870,7 +7089,7 @@ function exportOpenInference(tree, options) {
|
|
|
6870
7089
|
name: ev.name,
|
|
6871
7090
|
start_time_unix_nano: startNs.toString(),
|
|
6872
7091
|
end_time_unix_nano: endNs?.toString(),
|
|
6873
|
-
attributes:
|
|
7092
|
+
attributes: attrs2,
|
|
6874
7093
|
status
|
|
6875
7094
|
});
|
|
6876
7095
|
}
|
|
@@ -6894,7 +7113,7 @@ function exportOpenInference(tree, options) {
|
|
|
6894
7113
|
function hexFrom2(seed, byteLen) {
|
|
6895
7114
|
return crypto.createHash("sha256").update(seed, "utf8").digest("hex").slice(0, byteLen * 2);
|
|
6896
7115
|
}
|
|
6897
|
-
function
|
|
7116
|
+
function stringAttr2(key, value) {
|
|
6898
7117
|
return { key, value: { stringValue: value } };
|
|
6899
7118
|
}
|
|
6900
7119
|
function intAttr(key, value) {
|
|
@@ -6932,38 +7151,38 @@ function exportOtlpJson(tree, options) {
|
|
|
6932
7151
|
if (ev.durationMs !== void 0 && Number.isFinite(ev.durationMs)) {
|
|
6933
7152
|
endNs = String(Math.round(ev.timestamp * 1e6 + ev.durationMs * 1e6));
|
|
6934
7153
|
}
|
|
6935
|
-
const
|
|
6936
|
-
|
|
6937
|
-
|
|
6938
|
-
|
|
6939
|
-
|
|
6940
|
-
|
|
6941
|
-
|
|
7154
|
+
const attrs2 = [
|
|
7155
|
+
stringAttr2("agent_inspect.kind", ev.kind),
|
|
7156
|
+
stringAttr2("agent_inspect.confidence", ev.confidence),
|
|
7157
|
+
stringAttr2("agent_inspect.source.type", ev.source.type),
|
|
7158
|
+
stringAttr2("agent_inspect.run_id", tree.runId),
|
|
7159
|
+
stringAttr2("agent_inspect.event_id", ev.eventId),
|
|
7160
|
+
stringAttr2("agent_inspect.status", ev.status ?? "unset")
|
|
6942
7161
|
];
|
|
6943
7162
|
if (ev.durationMs !== void 0) {
|
|
6944
|
-
|
|
7163
|
+
attrs2.push(intAttr("agent_inspect.duration_ms", ev.durationMs));
|
|
6945
7164
|
}
|
|
6946
7165
|
const op = genAiOperationName(ev.kind);
|
|
6947
7166
|
if (op !== void 0) {
|
|
6948
|
-
|
|
7167
|
+
attrs2.push(stringAttr2("gen_ai.operation.name", op));
|
|
6949
7168
|
}
|
|
6950
7169
|
const meta = ev.attributes;
|
|
6951
7170
|
if (meta?.model !== void 0 && typeof meta.model === "string") {
|
|
6952
|
-
|
|
7171
|
+
attrs2.push(stringAttr2("gen_ai.request.model", meta.model.slice(0, maxLen)));
|
|
6953
7172
|
}
|
|
6954
7173
|
const tokens = meta?.tokens;
|
|
6955
7174
|
if (tokens && typeof tokens === "object" && tokens !== null) {
|
|
6956
7175
|
const inp = tokens.input;
|
|
6957
7176
|
const outp = tokens.output;
|
|
6958
|
-
if (typeof inp === "number")
|
|
6959
|
-
if (typeof outp === "number")
|
|
7177
|
+
if (typeof inp === "number") attrs2.push(intAttr("gen_ai.usage.input_tokens", inp));
|
|
7178
|
+
if (typeof outp === "number") attrs2.push(intAttr("gen_ai.usage.output_tokens", outp));
|
|
6960
7179
|
}
|
|
6961
7180
|
if (includeAttributes && meta && typeof meta === "object") {
|
|
6962
7181
|
for (const [k, v] of Object.entries(meta)) {
|
|
6963
7182
|
if (k === "tokens" || k === "model") continue;
|
|
6964
7183
|
if (typeof v === "string" || typeof v === "number" || typeof v === "boolean") {
|
|
6965
|
-
|
|
6966
|
-
|
|
7184
|
+
attrs2.push(
|
|
7185
|
+
stringAttr2(
|
|
6967
7186
|
`agent_inspect.preview.${k}`,
|
|
6968
7187
|
typeof v === "string" ? v.slice(0, maxLen) : String(v)
|
|
6969
7188
|
)
|
|
@@ -6985,7 +7204,7 @@ function exportOtlpJson(tree, options) {
|
|
|
6985
7204
|
name: ev.name,
|
|
6986
7205
|
kind: "SPAN_KIND_INTERNAL",
|
|
6987
7206
|
startTimeUnixNano: startNs,
|
|
6988
|
-
attributes:
|
|
7207
|
+
attributes: attrs2,
|
|
6989
7208
|
status: {
|
|
6990
7209
|
code: statusCode,
|
|
6991
7210
|
...statusMessage !== void 0 ? { message: statusMessage } : {}
|
|
@@ -7003,7 +7222,7 @@ function exportOtlpJson(tree, options) {
|
|
|
7003
7222
|
resourceSpans: [
|
|
7004
7223
|
{
|
|
7005
7224
|
resource: {
|
|
7006
|
-
attributes: [
|
|
7225
|
+
attributes: [stringAttr2("service.name", "agent-inspect")]
|
|
7007
7226
|
},
|
|
7008
7227
|
scopeSpans: [
|
|
7009
7228
|
{
|
|
@@ -7744,7 +7963,7 @@ var FLAGSHIP_TOOLS = [
|
|
|
7744
7963
|
{
|
|
7745
7964
|
name: "get_contract_failures",
|
|
7746
7965
|
description: withUntrustedTraceWarning(
|
|
7747
|
-
"Deterministic
|
|
7966
|
+
"Deterministic run-status check failures for one run. Actor-scoped TraceContracts and observation provenance (scope / requireProvenance) are evaluated via the TypeScript agent-inspect/checks API (evaluateTraceContract), not this MCP tool."
|
|
7748
7967
|
),
|
|
7749
7968
|
inputSchema: RUN_ID_SCHEMA
|
|
7750
7969
|
},
|
|
@@ -8432,5 +8651,5 @@ async function runReadOnlyMcpServer(options = {}) {
|
|
|
8432
8651
|
}
|
|
8433
8652
|
|
|
8434
8653
|
export { MCP_MAX_REQUEST_BYTES, MCP_PROTOCOL_VERSION, MCP_SERVER_INSTRUCTIONS, READ_ONLY_TOOLS, TRACE_DATA_UNTRUSTED_WARNING, callReadOnlyTool, createMcpServerContext, handleMcpProtocolLine, runReadOnlyMcpServer };
|
|
8435
|
-
//# sourceMappingURL=chunk-
|
|
8436
|
-
//# sourceMappingURL=chunk-
|
|
8654
|
+
//# sourceMappingURL=chunk-URVZD6JW.mjs.map
|
|
8655
|
+
//# sourceMappingURL=chunk-URVZD6JW.mjs.map
|