@agent-inspect/mcp-server 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/dist/{chunk-J2LULLKC.mjs → chunk-U3JBHSNB.mjs} +68 -23
- package/dist/chunk-U3JBHSNB.mjs.map +1 -0
- package/dist/cli.cjs +66 -21
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.mjs +1 -1
- package/dist/index.cjs +66 -21
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +3 -3
- package/dist/chunk-J2LULLKC.mjs.map +0 -1
package/dist/cli.cjs
CHANGED
|
@@ -1075,7 +1075,18 @@ async function readTraceEventsFromFile(filePath) {
|
|
|
1075
1075
|
}
|
|
1076
1076
|
|
|
1077
1077
|
// packages/core/src/context.ts
|
|
1078
|
-
|
|
1078
|
+
var GLOBAL_CONTEXT_ALS_KEY = "agent-inspect:execution-context-als:v1";
|
|
1079
|
+
function getSharedContextStorage() {
|
|
1080
|
+
const host = globalThis;
|
|
1081
|
+
const existing = host[GLOBAL_CONTEXT_ALS_KEY];
|
|
1082
|
+
if (existing instanceof async_hooks.AsyncLocalStorage) {
|
|
1083
|
+
return existing;
|
|
1084
|
+
}
|
|
1085
|
+
const created = new async_hooks.AsyncLocalStorage();
|
|
1086
|
+
host[GLOBAL_CONTEXT_ALS_KEY] = created;
|
|
1087
|
+
return created;
|
|
1088
|
+
}
|
|
1089
|
+
getSharedContextStorage();
|
|
1079
1090
|
|
|
1080
1091
|
// packages/core/src/outcomes/types.ts
|
|
1081
1092
|
var OBSERVED_OUTCOME_STATUSES = [
|
|
@@ -5124,8 +5135,13 @@ function persistedInspectEventsToInspectEvents(events, options) {
|
|
|
5124
5135
|
}
|
|
5125
5136
|
|
|
5126
5137
|
// packages/core/src/persisted/tree-bridge.ts
|
|
5138
|
+
function logicalToPersisted(event) {
|
|
5139
|
+
const { sourceEventIds: _sourceEventIds, projection: _projection, ...rest } = event;
|
|
5140
|
+
return rest;
|
|
5141
|
+
}
|
|
5127
5142
|
function persistedInspectEventsToRunTrees(events, options) {
|
|
5128
|
-
const
|
|
5143
|
+
const sourceEvents = options?.coalesceLifecycle === true ? projectLogicalEvents(events).logicalEvents.map(logicalToPersisted) : events;
|
|
5144
|
+
const inspectEvents = persistedInspectEventsToInspectEvents(sourceEvents, {
|
|
5129
5145
|
skipInvalid: options?.skipInvalid
|
|
5130
5146
|
});
|
|
5131
5147
|
return new TreeBuilder().build(inspectEvents);
|
|
@@ -5819,7 +5835,7 @@ function mapOpenInferenceSpan(span, index, version) {
|
|
|
5819
5835
|
const errorMessage = isRecord10(span.status) && typeof span.status.message === "string" ? span.status.message : void 0;
|
|
5820
5836
|
const event = {
|
|
5821
5837
|
schemaVersion: "0.2",
|
|
5822
|
-
eventId: typeof rawAttributes["agent_inspect.event_id"] === "string" ? rawAttributes["agent_inspect.event_id"] : spanId
|
|
5838
|
+
eventId: typeof rawAttributes["agent_inspect.event_id"] === "string" ? rawAttributes["agent_inspect.event_id"] : `${traceId}:${spanId}`,
|
|
5823
5839
|
runId: typeof rawAttributes["agent_inspect.run_id"] === "string" ? rawAttributes["agent_inspect.run_id"] : traceId,
|
|
5824
5840
|
kind,
|
|
5825
5841
|
name,
|
|
@@ -5870,12 +5886,16 @@ function mapOpenInferenceEvents(document) {
|
|
|
5870
5886
|
const mapped = document.spans.map(
|
|
5871
5887
|
(span, index) => mapOpenInferenceSpan(span, index, document.version)
|
|
5872
5888
|
);
|
|
5873
|
-
const
|
|
5874
|
-
mapped.map((span) =>
|
|
5889
|
+
const spanKeyToEventId = new Map(
|
|
5890
|
+
mapped.map((span) => {
|
|
5891
|
+
const traceId = typeof span.event.trace?.traceId === "string" ? span.event.trace.traceId : "";
|
|
5892
|
+
return [`${traceId}:${span.spanId}`, span.event.eventId];
|
|
5893
|
+
})
|
|
5875
5894
|
);
|
|
5876
5895
|
for (const span of mapped) {
|
|
5877
5896
|
if (span.parentSpanId === void 0) continue;
|
|
5878
|
-
span.event.
|
|
5897
|
+
const traceId = typeof span.event.trace?.traceId === "string" ? span.event.trace.traceId : "";
|
|
5898
|
+
span.event.parentId = spanKeyToEventId.get(`${traceId}:${span.parentSpanId}`) ?? span.parentSpanId;
|
|
5879
5899
|
}
|
|
5880
5900
|
return {
|
|
5881
5901
|
events: mapped.map((span) => span.event),
|
|
@@ -6424,7 +6444,7 @@ function mapOtlpSpan(context) {
|
|
|
6424
6444
|
const errorMessage = isRecord10(span.status) && typeof span.status.message === "string" ? span.status.message : void 0;
|
|
6425
6445
|
const event = {
|
|
6426
6446
|
schemaVersion: "0.2",
|
|
6427
|
-
eventId: typeof parsedSpanAttributes.attributes["agent_inspect.event_id"] === "string" ? parsedSpanAttributes.attributes["agent_inspect.event_id"] : spanId
|
|
6447
|
+
eventId: typeof parsedSpanAttributes.attributes["agent_inspect.event_id"] === "string" ? parsedSpanAttributes.attributes["agent_inspect.event_id"] : `${traceId}:${spanId}`,
|
|
6428
6448
|
runId: typeof parsedSpanAttributes.attributes["agent_inspect.run_id"] === "string" ? parsedSpanAttributes.attributes["agent_inspect.run_id"] : traceId,
|
|
6429
6449
|
kind,
|
|
6430
6450
|
name: readStringField(span, ["name"]) ?? spanId,
|
|
@@ -6473,12 +6493,16 @@ function mapOtlpSpan(context) {
|
|
|
6473
6493
|
}
|
|
6474
6494
|
function mapOtlpEventsToPersisted(document) {
|
|
6475
6495
|
const mapped = document.spans.map((span) => mapOtlpSpan(span));
|
|
6476
|
-
const
|
|
6477
|
-
mapped.map((span) =>
|
|
6496
|
+
const spanKeyToEventId = new Map(
|
|
6497
|
+
mapped.map((span) => {
|
|
6498
|
+
const traceId = typeof span.event.trace?.traceId === "string" ? span.event.trace.traceId : "";
|
|
6499
|
+
return [`${traceId}:${span.spanId}`, span.event.eventId];
|
|
6500
|
+
})
|
|
6478
6501
|
);
|
|
6479
6502
|
for (const span of mapped) {
|
|
6480
6503
|
if (span.parentSpanId === void 0) continue;
|
|
6481
|
-
span.event.
|
|
6504
|
+
const traceId = typeof span.event.trace?.traceId === "string" ? span.event.trace.traceId : "";
|
|
6505
|
+
span.event.parentId = spanKeyToEventId.get(`${traceId}:${span.parentSpanId}`) ?? span.parentSpanId;
|
|
6482
6506
|
}
|
|
6483
6507
|
return {
|
|
6484
6508
|
events: mapped.map((span) => span.event),
|
|
@@ -7382,11 +7406,13 @@ function exportOpenInference(tree, options) {
|
|
|
7382
7406
|
endNs = startNs + unixNano(ev.durationMs);
|
|
7383
7407
|
}
|
|
7384
7408
|
const { openInferenceKind } = mapInspectKindToOI(ev.kind, warnings);
|
|
7409
|
+
const meta = ev.attributes;
|
|
7410
|
+
const originalSource = typeof meta?.originalSourceType === "string" && meta.originalSourceType.trim() !== "" ? meta.originalSourceType.trim() : ev.source.type;
|
|
7385
7411
|
const attrs2 = {
|
|
7386
7412
|
"openinference.span.kind": openInferenceKind,
|
|
7387
7413
|
"agent_inspect.kind": ev.kind,
|
|
7388
7414
|
"agent_inspect.confidence": ev.confidence,
|
|
7389
|
-
"agent_inspect.source.type":
|
|
7415
|
+
"agent_inspect.source.type": originalSource,
|
|
7390
7416
|
"agent_inspect.run_id": tree.runId,
|
|
7391
7417
|
"agent_inspect.event_id": ev.eventId,
|
|
7392
7418
|
"agent_inspect.status": ev.status ?? "unset"
|
|
@@ -7394,9 +7420,9 @@ function exportOpenInference(tree, options) {
|
|
|
7394
7420
|
if (ev.durationMs !== void 0) {
|
|
7395
7421
|
attrs2["agent_inspect.duration_ms"] = ev.durationMs;
|
|
7396
7422
|
}
|
|
7397
|
-
const
|
|
7398
|
-
if (
|
|
7399
|
-
attrs2["llm.model_name"] =
|
|
7423
|
+
const requestModel = (typeof meta?.model === "string" && meta.model.trim() !== "" ? meta.model : void 0) ?? (typeof meta?.modelId === "string" && meta.modelId.trim() !== "" ? meta.modelId : void 0);
|
|
7424
|
+
if (requestModel !== void 0) {
|
|
7425
|
+
attrs2["llm.model_name"] = requestModel;
|
|
7400
7426
|
}
|
|
7401
7427
|
const tokens = meta?.tokens;
|
|
7402
7428
|
if (tokens && typeof tokens === "object" && tokens !== null) {
|
|
@@ -7406,8 +7432,9 @@ function exportOpenInference(tree, options) {
|
|
|
7406
7432
|
if (typeof outp === "number") attrs2["llm.token_count.completion"] = outp;
|
|
7407
7433
|
}
|
|
7408
7434
|
if (includeAttributes && meta && typeof meta === "object") {
|
|
7435
|
+
const skipKeys = /* @__PURE__ */ new Set(["tokens", "model", "modelId", "originalSourceType"]);
|
|
7409
7436
|
for (const [k, v] of Object.entries(meta)) {
|
|
7410
|
-
if (k
|
|
7437
|
+
if (skipKeys.has(k)) continue;
|
|
7411
7438
|
if (v !== void 0 && v !== null && typeof v !== "object") {
|
|
7412
7439
|
attrs2[`agent_inspect.preview.${k}`] = typeof v === "string" ? v.slice(0, maxLen) : v;
|
|
7413
7440
|
}
|
|
@@ -7525,24 +7552,33 @@ function exportOtlpJson(tree, options) {
|
|
|
7525
7552
|
const spanId = hexFrom2(`${tree.runId}:${ev.eventId}`, 8);
|
|
7526
7553
|
const parentSpanId = ev.parentId ? hexFrom2(`${tree.runId}:${ev.parentId}`, 8) : void 0;
|
|
7527
7554
|
const { startNs, endNs } = resolveSpanTimes(ev);
|
|
7555
|
+
const meta = ev.attributes;
|
|
7556
|
+
const originalSource = typeof meta?.originalSourceType === "string" && meta.originalSourceType.trim() !== "" ? meta.originalSourceType.trim() : ev.source.type;
|
|
7528
7557
|
const attrs2 = [
|
|
7529
7558
|
stringAttr2("agent_inspect.kind", ev.kind),
|
|
7530
7559
|
stringAttr2("agent_inspect.confidence", ev.confidence),
|
|
7531
|
-
stringAttr2("agent_inspect.source.type",
|
|
7560
|
+
stringAttr2("agent_inspect.source.type", originalSource),
|
|
7532
7561
|
stringAttr2("agent_inspect.run_id", tree.runId),
|
|
7533
7562
|
stringAttr2("agent_inspect.event_id", ev.eventId),
|
|
7534
7563
|
stringAttr2("agent_inspect.status", ev.status ?? "unset")
|
|
7535
7564
|
];
|
|
7536
7565
|
if (ev.durationMs !== void 0) {
|
|
7537
|
-
attrs2.push(
|
|
7566
|
+
attrs2.push(numberAttr("agent_inspect.duration_ms", ev.durationMs));
|
|
7538
7567
|
}
|
|
7539
7568
|
const op = genAiOperationName(ev.kind);
|
|
7540
7569
|
if (op !== void 0) {
|
|
7541
7570
|
attrs2.push(stringAttr2("gen_ai.operation.name", op));
|
|
7542
7571
|
}
|
|
7543
|
-
const
|
|
7544
|
-
if (
|
|
7545
|
-
attrs2.push(stringAttr2("gen_ai.request.model",
|
|
7572
|
+
const requestModel = (typeof meta?.model === "string" && meta.model.trim() !== "" ? meta.model : void 0) ?? (typeof meta?.modelId === "string" && meta.modelId.trim() !== "" ? meta.modelId : void 0);
|
|
7573
|
+
if (requestModel !== void 0) {
|
|
7574
|
+
attrs2.push(stringAttr2("gen_ai.request.model", requestModel.slice(0, maxLen)));
|
|
7575
|
+
}
|
|
7576
|
+
const responseModel = typeof meta?.responseModelId === "string" && meta.responseModelId.trim() !== "" ? meta.responseModelId : typeof meta?.responseModel === "string" && meta.responseModel.trim() !== "" ? meta.responseModel : void 0;
|
|
7577
|
+
if (responseModel !== void 0) {
|
|
7578
|
+
attrs2.push(stringAttr2("gen_ai.response.model", responseModel.slice(0, maxLen)));
|
|
7579
|
+
}
|
|
7580
|
+
if (typeof meta?.provider === "string" && meta.provider.trim() !== "") {
|
|
7581
|
+
attrs2.push(stringAttr2("gen_ai.provider.name", meta.provider.slice(0, maxLen)));
|
|
7546
7582
|
}
|
|
7547
7583
|
const tokens = meta?.tokens;
|
|
7548
7584
|
if (tokens && typeof tokens === "object" && tokens !== null) {
|
|
@@ -7552,8 +7588,17 @@ function exportOtlpJson(tree, options) {
|
|
|
7552
7588
|
if (typeof outp === "number") attrs2.push(intAttr("gen_ai.usage.output_tokens", outp));
|
|
7553
7589
|
}
|
|
7554
7590
|
if (includeAttributes && meta && typeof meta === "object") {
|
|
7591
|
+
const skipKeys = /* @__PURE__ */ new Set([
|
|
7592
|
+
"tokens",
|
|
7593
|
+
"model",
|
|
7594
|
+
"modelId",
|
|
7595
|
+
"responseModel",
|
|
7596
|
+
"responseModelId",
|
|
7597
|
+
"provider",
|
|
7598
|
+
"originalSourceType"
|
|
7599
|
+
]);
|
|
7555
7600
|
for (const [k, v] of Object.entries(meta)) {
|
|
7556
|
-
if (k
|
|
7601
|
+
if (skipKeys.has(k)) continue;
|
|
7557
7602
|
if (typeof v === "string") {
|
|
7558
7603
|
attrs2.push(stringAttr2(`agent_inspect.preview.${k}`, v.slice(0, maxLen)));
|
|
7559
7604
|
} else if (typeof v === "number" && Number.isFinite(v)) {
|