@agent-inspect/mcp-server 6.31.7 → 6.31.8
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-MXA5GAJQ.mjs} +56 -22
- package/dist/chunk-MXA5GAJQ.mjs.map +1 -0
- package/dist/cli.cjs +54 -20
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.mjs +1 -1
- package/dist/index.cjs +54 -20
- 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
|
@@ -5114,8 +5114,13 @@ function persistedInspectEventsToInspectEvents(events, options) {
|
|
|
5114
5114
|
}
|
|
5115
5115
|
|
|
5116
5116
|
// packages/core/src/persisted/tree-bridge.ts
|
|
5117
|
+
function logicalToPersisted(event) {
|
|
5118
|
+
const { sourceEventIds: _sourceEventIds, projection: _projection, ...rest } = event;
|
|
5119
|
+
return rest;
|
|
5120
|
+
}
|
|
5117
5121
|
function persistedInspectEventsToRunTrees(events, options) {
|
|
5118
|
-
const
|
|
5122
|
+
const sourceEvents = options?.coalesceLifecycle === true ? projectLogicalEvents(events).logicalEvents.map(logicalToPersisted) : events;
|
|
5123
|
+
const inspectEvents = persistedInspectEventsToInspectEvents(sourceEvents, {
|
|
5119
5124
|
skipInvalid: options?.skipInvalid
|
|
5120
5125
|
});
|
|
5121
5126
|
return new TreeBuilder().build(inspectEvents);
|
|
@@ -5809,7 +5814,7 @@ function mapOpenInferenceSpan(span, index, version) {
|
|
|
5809
5814
|
const errorMessage = isRecord10(span.status) && typeof span.status.message === "string" ? span.status.message : void 0;
|
|
5810
5815
|
const event = {
|
|
5811
5816
|
schemaVersion: "0.2",
|
|
5812
|
-
eventId: typeof rawAttributes["agent_inspect.event_id"] === "string" ? rawAttributes["agent_inspect.event_id"] : spanId
|
|
5817
|
+
eventId: typeof rawAttributes["agent_inspect.event_id"] === "string" ? rawAttributes["agent_inspect.event_id"] : `${traceId}:${spanId}`,
|
|
5813
5818
|
runId: typeof rawAttributes["agent_inspect.run_id"] === "string" ? rawAttributes["agent_inspect.run_id"] : traceId,
|
|
5814
5819
|
kind,
|
|
5815
5820
|
name,
|
|
@@ -5860,12 +5865,16 @@ function mapOpenInferenceEvents(document) {
|
|
|
5860
5865
|
const mapped = document.spans.map(
|
|
5861
5866
|
(span, index) => mapOpenInferenceSpan(span, index, document.version)
|
|
5862
5867
|
);
|
|
5863
|
-
const
|
|
5864
|
-
mapped.map((span) =>
|
|
5868
|
+
const spanKeyToEventId = new Map(
|
|
5869
|
+
mapped.map((span) => {
|
|
5870
|
+
const traceId = typeof span.event.trace?.traceId === "string" ? span.event.trace.traceId : "";
|
|
5871
|
+
return [`${traceId}:${span.spanId}`, span.event.eventId];
|
|
5872
|
+
})
|
|
5865
5873
|
);
|
|
5866
5874
|
for (const span of mapped) {
|
|
5867
5875
|
if (span.parentSpanId === void 0) continue;
|
|
5868
|
-
span.event.
|
|
5876
|
+
const traceId = typeof span.event.trace?.traceId === "string" ? span.event.trace.traceId : "";
|
|
5877
|
+
span.event.parentId = spanKeyToEventId.get(`${traceId}:${span.parentSpanId}`) ?? span.parentSpanId;
|
|
5869
5878
|
}
|
|
5870
5879
|
return {
|
|
5871
5880
|
events: mapped.map((span) => span.event),
|
|
@@ -6414,7 +6423,7 @@ function mapOtlpSpan(context) {
|
|
|
6414
6423
|
const errorMessage = isRecord10(span.status) && typeof span.status.message === "string" ? span.status.message : void 0;
|
|
6415
6424
|
const event = {
|
|
6416
6425
|
schemaVersion: "0.2",
|
|
6417
|
-
eventId: typeof parsedSpanAttributes.attributes["agent_inspect.event_id"] === "string" ? parsedSpanAttributes.attributes["agent_inspect.event_id"] : spanId
|
|
6426
|
+
eventId: typeof parsedSpanAttributes.attributes["agent_inspect.event_id"] === "string" ? parsedSpanAttributes.attributes["agent_inspect.event_id"] : `${traceId}:${spanId}`,
|
|
6418
6427
|
runId: typeof parsedSpanAttributes.attributes["agent_inspect.run_id"] === "string" ? parsedSpanAttributes.attributes["agent_inspect.run_id"] : traceId,
|
|
6419
6428
|
kind,
|
|
6420
6429
|
name: readStringField(span, ["name"]) ?? spanId,
|
|
@@ -6463,12 +6472,16 @@ function mapOtlpSpan(context) {
|
|
|
6463
6472
|
}
|
|
6464
6473
|
function mapOtlpEventsToPersisted(document) {
|
|
6465
6474
|
const mapped = document.spans.map((span) => mapOtlpSpan(span));
|
|
6466
|
-
const
|
|
6467
|
-
mapped.map((span) =>
|
|
6475
|
+
const spanKeyToEventId = new Map(
|
|
6476
|
+
mapped.map((span) => {
|
|
6477
|
+
const traceId = typeof span.event.trace?.traceId === "string" ? span.event.trace.traceId : "";
|
|
6478
|
+
return [`${traceId}:${span.spanId}`, span.event.eventId];
|
|
6479
|
+
})
|
|
6468
6480
|
);
|
|
6469
6481
|
for (const span of mapped) {
|
|
6470
6482
|
if (span.parentSpanId === void 0) continue;
|
|
6471
|
-
span.event.
|
|
6483
|
+
const traceId = typeof span.event.trace?.traceId === "string" ? span.event.trace.traceId : "";
|
|
6484
|
+
span.event.parentId = spanKeyToEventId.get(`${traceId}:${span.parentSpanId}`) ?? span.parentSpanId;
|
|
6472
6485
|
}
|
|
6473
6486
|
return {
|
|
6474
6487
|
events: mapped.map((span) => span.event),
|
|
@@ -7372,11 +7385,13 @@ function exportOpenInference(tree, options) {
|
|
|
7372
7385
|
endNs = startNs + unixNano(ev.durationMs);
|
|
7373
7386
|
}
|
|
7374
7387
|
const { openInferenceKind } = mapInspectKindToOI(ev.kind, warnings);
|
|
7388
|
+
const meta = ev.attributes;
|
|
7389
|
+
const originalSource = typeof meta?.originalSourceType === "string" && meta.originalSourceType.trim() !== "" ? meta.originalSourceType.trim() : ev.source.type;
|
|
7375
7390
|
const attrs2 = {
|
|
7376
7391
|
"openinference.span.kind": openInferenceKind,
|
|
7377
7392
|
"agent_inspect.kind": ev.kind,
|
|
7378
7393
|
"agent_inspect.confidence": ev.confidence,
|
|
7379
|
-
"agent_inspect.source.type":
|
|
7394
|
+
"agent_inspect.source.type": originalSource,
|
|
7380
7395
|
"agent_inspect.run_id": tree.runId,
|
|
7381
7396
|
"agent_inspect.event_id": ev.eventId,
|
|
7382
7397
|
"agent_inspect.status": ev.status ?? "unset"
|
|
@@ -7384,9 +7399,9 @@ function exportOpenInference(tree, options) {
|
|
|
7384
7399
|
if (ev.durationMs !== void 0) {
|
|
7385
7400
|
attrs2["agent_inspect.duration_ms"] = ev.durationMs;
|
|
7386
7401
|
}
|
|
7387
|
-
const
|
|
7388
|
-
if (
|
|
7389
|
-
attrs2["llm.model_name"] =
|
|
7402
|
+
const requestModel = (typeof meta?.model === "string" && meta.model.trim() !== "" ? meta.model : void 0) ?? (typeof meta?.modelId === "string" && meta.modelId.trim() !== "" ? meta.modelId : void 0);
|
|
7403
|
+
if (requestModel !== void 0) {
|
|
7404
|
+
attrs2["llm.model_name"] = requestModel;
|
|
7390
7405
|
}
|
|
7391
7406
|
const tokens = meta?.tokens;
|
|
7392
7407
|
if (tokens && typeof tokens === "object" && tokens !== null) {
|
|
@@ -7396,8 +7411,9 @@ function exportOpenInference(tree, options) {
|
|
|
7396
7411
|
if (typeof outp === "number") attrs2["llm.token_count.completion"] = outp;
|
|
7397
7412
|
}
|
|
7398
7413
|
if (includeAttributes && meta && typeof meta === "object") {
|
|
7414
|
+
const skipKeys = /* @__PURE__ */ new Set(["tokens", "model", "modelId", "originalSourceType"]);
|
|
7399
7415
|
for (const [k, v] of Object.entries(meta)) {
|
|
7400
|
-
if (k
|
|
7416
|
+
if (skipKeys.has(k)) continue;
|
|
7401
7417
|
if (v !== void 0 && v !== null && typeof v !== "object") {
|
|
7402
7418
|
attrs2[`agent_inspect.preview.${k}`] = typeof v === "string" ? v.slice(0, maxLen) : v;
|
|
7403
7419
|
}
|
|
@@ -7515,24 +7531,33 @@ function exportOtlpJson(tree, options) {
|
|
|
7515
7531
|
const spanId = hexFrom2(`${tree.runId}:${ev.eventId}`, 8);
|
|
7516
7532
|
const parentSpanId = ev.parentId ? hexFrom2(`${tree.runId}:${ev.parentId}`, 8) : void 0;
|
|
7517
7533
|
const { startNs, endNs } = resolveSpanTimes(ev);
|
|
7534
|
+
const meta = ev.attributes;
|
|
7535
|
+
const originalSource = typeof meta?.originalSourceType === "string" && meta.originalSourceType.trim() !== "" ? meta.originalSourceType.trim() : ev.source.type;
|
|
7518
7536
|
const attrs2 = [
|
|
7519
7537
|
stringAttr2("agent_inspect.kind", ev.kind),
|
|
7520
7538
|
stringAttr2("agent_inspect.confidence", ev.confidence),
|
|
7521
|
-
stringAttr2("agent_inspect.source.type",
|
|
7539
|
+
stringAttr2("agent_inspect.source.type", originalSource),
|
|
7522
7540
|
stringAttr2("agent_inspect.run_id", tree.runId),
|
|
7523
7541
|
stringAttr2("agent_inspect.event_id", ev.eventId),
|
|
7524
7542
|
stringAttr2("agent_inspect.status", ev.status ?? "unset")
|
|
7525
7543
|
];
|
|
7526
7544
|
if (ev.durationMs !== void 0) {
|
|
7527
|
-
attrs2.push(
|
|
7545
|
+
attrs2.push(numberAttr("agent_inspect.duration_ms", ev.durationMs));
|
|
7528
7546
|
}
|
|
7529
7547
|
const op = genAiOperationName(ev.kind);
|
|
7530
7548
|
if (op !== void 0) {
|
|
7531
7549
|
attrs2.push(stringAttr2("gen_ai.operation.name", op));
|
|
7532
7550
|
}
|
|
7533
|
-
const
|
|
7534
|
-
if (
|
|
7535
|
-
attrs2.push(stringAttr2("gen_ai.request.model",
|
|
7551
|
+
const requestModel = (typeof meta?.model === "string" && meta.model.trim() !== "" ? meta.model : void 0) ?? (typeof meta?.modelId === "string" && meta.modelId.trim() !== "" ? meta.modelId : void 0);
|
|
7552
|
+
if (requestModel !== void 0) {
|
|
7553
|
+
attrs2.push(stringAttr2("gen_ai.request.model", requestModel.slice(0, maxLen)));
|
|
7554
|
+
}
|
|
7555
|
+
const responseModel = typeof meta?.responseModelId === "string" && meta.responseModelId.trim() !== "" ? meta.responseModelId : typeof meta?.responseModel === "string" && meta.responseModel.trim() !== "" ? meta.responseModel : void 0;
|
|
7556
|
+
if (responseModel !== void 0) {
|
|
7557
|
+
attrs2.push(stringAttr2("gen_ai.response.model", responseModel.slice(0, maxLen)));
|
|
7558
|
+
}
|
|
7559
|
+
if (typeof meta?.provider === "string" && meta.provider.trim() !== "") {
|
|
7560
|
+
attrs2.push(stringAttr2("gen_ai.provider.name", meta.provider.slice(0, maxLen)));
|
|
7536
7561
|
}
|
|
7537
7562
|
const tokens = meta?.tokens;
|
|
7538
7563
|
if (tokens && typeof tokens === "object" && tokens !== null) {
|
|
@@ -7542,8 +7567,17 @@ function exportOtlpJson(tree, options) {
|
|
|
7542
7567
|
if (typeof outp === "number") attrs2.push(intAttr("gen_ai.usage.output_tokens", outp));
|
|
7543
7568
|
}
|
|
7544
7569
|
if (includeAttributes && meta && typeof meta === "object") {
|
|
7570
|
+
const skipKeys = /* @__PURE__ */ new Set([
|
|
7571
|
+
"tokens",
|
|
7572
|
+
"model",
|
|
7573
|
+
"modelId",
|
|
7574
|
+
"responseModel",
|
|
7575
|
+
"responseModelId",
|
|
7576
|
+
"provider",
|
|
7577
|
+
"originalSourceType"
|
|
7578
|
+
]);
|
|
7545
7579
|
for (const [k, v] of Object.entries(meta)) {
|
|
7546
|
-
if (k
|
|
7580
|
+
if (skipKeys.has(k)) continue;
|
|
7547
7581
|
if (typeof v === "string") {
|
|
7548
7582
|
attrs2.push(stringAttr2(`agent_inspect.preview.${k}`, v.slice(0, maxLen)));
|
|
7549
7583
|
} else if (typeof v === "number" && Number.isFinite(v)) {
|
|
@@ -9230,5 +9264,5 @@ async function runReadOnlyMcpServer(options = {}) {
|
|
|
9230
9264
|
}
|
|
9231
9265
|
|
|
9232
9266
|
export { MCP_MAX_REQUEST_BYTES, MCP_PROTOCOL_VERSION, MCP_SERVER_INSTRUCTIONS, READ_ONLY_TOOLS, TRACE_DATA_UNTRUSTED_WARNING, callReadOnlyTool, createMcpServerContext, handleMcpProtocolLine, runReadOnlyMcpServer };
|
|
9233
|
-
//# sourceMappingURL=chunk-
|
|
9234
|
-
//# sourceMappingURL=chunk-
|
|
9267
|
+
//# sourceMappingURL=chunk-MXA5GAJQ.mjs.map
|
|
9268
|
+
//# sourceMappingURL=chunk-MXA5GAJQ.mjs.map
|