@agent-inspect/mcp-server 6.31.6 → 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-P72E7RLD.mjs → chunk-MXA5GAJQ.mjs} +196 -62
- package/dist/chunk-MXA5GAJQ.mjs.map +1 -0
- package/dist/cli.cjs +194 -60
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.mjs +1 -1
- package/dist/index.cjs +194 -60
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +3 -3
- package/dist/chunk-P72E7RLD.mjs.map +0 -1
|
@@ -1488,6 +1488,8 @@ function filterTraces(traces, options) {
|
|
|
1488
1488
|
}
|
|
1489
1489
|
|
|
1490
1490
|
// packages/core/src/timeline.ts
|
|
1491
|
+
var ROOT_TIMELINE_DEPTH = 0;
|
|
1492
|
+
var MAX_TIMELINE_DEPTH = 1e3;
|
|
1491
1493
|
function finite(n) {
|
|
1492
1494
|
return typeof n === "number" && Number.isFinite(n);
|
|
1493
1495
|
}
|
|
@@ -1558,16 +1560,51 @@ function buildRunTimeline(events, options = {}) {
|
|
|
1558
1560
|
const computeDepth = (stepId) => {
|
|
1559
1561
|
const cached = depthCache.get(stepId);
|
|
1560
1562
|
if (cached !== void 0) return cached;
|
|
1561
|
-
const
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1563
|
+
const ancestry = [];
|
|
1564
|
+
const ancestryIndexes = /* @__PURE__ */ new Map();
|
|
1565
|
+
let currentStepId = stepId;
|
|
1566
|
+
let resolvedDepth;
|
|
1567
|
+
while (resolvedDepth === void 0) {
|
|
1568
|
+
const cachedDepth = depthCache.get(currentStepId);
|
|
1569
|
+
if (cachedDepth !== void 0) {
|
|
1570
|
+
resolvedDepth = cachedDepth;
|
|
1571
|
+
continue;
|
|
1572
|
+
}
|
|
1573
|
+
const cycleStart = ancestryIndexes.get(currentStepId);
|
|
1574
|
+
if (cycleStart !== void 0) {
|
|
1575
|
+
const cycleStepIds = ancestry.splice(cycleStart);
|
|
1576
|
+
for (const cycleStepId of cycleStepIds) {
|
|
1577
|
+
depthCache.set(cycleStepId, ROOT_TIMELINE_DEPTH);
|
|
1578
|
+
}
|
|
1579
|
+
resolvedDepth = ROOT_TIMELINE_DEPTH;
|
|
1580
|
+
continue;
|
|
1581
|
+
}
|
|
1582
|
+
const currentStep = steps.get(currentStepId);
|
|
1583
|
+
if (!currentStep) {
|
|
1584
|
+
resolvedDepth = ROOT_TIMELINE_DEPTH;
|
|
1585
|
+
continue;
|
|
1586
|
+
}
|
|
1587
|
+
ancestryIndexes.set(currentStepId, ancestry.length);
|
|
1588
|
+
ancestry.push(currentStepId);
|
|
1589
|
+
const parentId = currentStep.parentId;
|
|
1590
|
+
if (typeof parentId !== "string" || parentId.trim() === "" || !steps.has(parentId)) {
|
|
1591
|
+
ancestry.pop();
|
|
1592
|
+
depthCache.set(currentStepId, ROOT_TIMELINE_DEPTH);
|
|
1593
|
+
resolvedDepth = ROOT_TIMELINE_DEPTH;
|
|
1594
|
+
continue;
|
|
1595
|
+
}
|
|
1596
|
+
currentStepId = parentId;
|
|
1597
|
+
}
|
|
1598
|
+
ancestry.reverse();
|
|
1599
|
+
for (const ancestorStepId of ancestry) {
|
|
1600
|
+
resolvedDepth = Math.min(MAX_TIMELINE_DEPTH, resolvedDepth + 1);
|
|
1601
|
+
depthCache.set(ancestorStepId, resolvedDepth);
|
|
1567
1602
|
}
|
|
1568
|
-
const
|
|
1569
|
-
|
|
1570
|
-
|
|
1603
|
+
const resolvedStepDepth = depthCache.get(stepId);
|
|
1604
|
+
if (resolvedStepDepth === void 0) {
|
|
1605
|
+
throw new Error(`Failed to resolve timeline depth for step "${stepId}"`);
|
|
1606
|
+
}
|
|
1607
|
+
return resolvedStepDepth;
|
|
1571
1608
|
};
|
|
1572
1609
|
const entries = [];
|
|
1573
1610
|
for (const [stepId, s] of steps.entries()) {
|
|
@@ -5042,6 +5079,23 @@ function persistedInspectEventToInspectEvent(event) {
|
|
|
5042
5079
|
if (event.durationMs !== void 0 && Number.isFinite(event.durationMs) && event.durationMs >= 0) {
|
|
5043
5080
|
out.durationMs = event.durationMs;
|
|
5044
5081
|
}
|
|
5082
|
+
if (event.startedAt !== void 0) {
|
|
5083
|
+
const started = parseIsoToMs3(event.startedAt);
|
|
5084
|
+
if (!started.invalidTimestamp) {
|
|
5085
|
+
attrs2.startedAtMs = started.ms;
|
|
5086
|
+
out.timestamp = started.ms;
|
|
5087
|
+
}
|
|
5088
|
+
}
|
|
5089
|
+
if (event.endedAt !== void 0) {
|
|
5090
|
+
const ended = parseIsoToMs3(event.endedAt);
|
|
5091
|
+
if (!ended.invalidTimestamp) {
|
|
5092
|
+
attrs2.endedAtMs = ended.ms;
|
|
5093
|
+
if (out.durationMs === void 0 && typeof attrs2.startedAtMs === "number" && ended.ms >= attrs2.startedAtMs) {
|
|
5094
|
+
out.durationMs = ended.ms - attrs2.startedAtMs;
|
|
5095
|
+
}
|
|
5096
|
+
}
|
|
5097
|
+
}
|
|
5098
|
+
out.attributes = compactAttributes3(attrs2);
|
|
5045
5099
|
return out;
|
|
5046
5100
|
}
|
|
5047
5101
|
function persistedInspectEventsToInspectEvents(events, options) {
|
|
@@ -5060,8 +5114,13 @@ function persistedInspectEventsToInspectEvents(events, options) {
|
|
|
5060
5114
|
}
|
|
5061
5115
|
|
|
5062
5116
|
// packages/core/src/persisted/tree-bridge.ts
|
|
5117
|
+
function logicalToPersisted(event) {
|
|
5118
|
+
const { sourceEventIds: _sourceEventIds, projection: _projection, ...rest } = event;
|
|
5119
|
+
return rest;
|
|
5120
|
+
}
|
|
5063
5121
|
function persistedInspectEventsToRunTrees(events, options) {
|
|
5064
|
-
const
|
|
5122
|
+
const sourceEvents = options?.coalesceLifecycle === true ? projectLogicalEvents(events).logicalEvents.map(logicalToPersisted) : events;
|
|
5123
|
+
const inspectEvents = persistedInspectEventsToInspectEvents(sourceEvents, {
|
|
5065
5124
|
skipInvalid: options?.skipInvalid
|
|
5066
5125
|
});
|
|
5067
5126
|
return new TreeBuilder().build(inspectEvents);
|
|
@@ -5755,7 +5814,7 @@ function mapOpenInferenceSpan(span, index, version) {
|
|
|
5755
5814
|
const errorMessage = isRecord10(span.status) && typeof span.status.message === "string" ? span.status.message : void 0;
|
|
5756
5815
|
const event = {
|
|
5757
5816
|
schemaVersion: "0.2",
|
|
5758
|
-
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}`,
|
|
5759
5818
|
runId: typeof rawAttributes["agent_inspect.run_id"] === "string" ? rawAttributes["agent_inspect.run_id"] : traceId,
|
|
5760
5819
|
kind,
|
|
5761
5820
|
name,
|
|
@@ -5806,12 +5865,16 @@ function mapOpenInferenceEvents(document) {
|
|
|
5806
5865
|
const mapped = document.spans.map(
|
|
5807
5866
|
(span, index) => mapOpenInferenceSpan(span, index, document.version)
|
|
5808
5867
|
);
|
|
5809
|
-
const
|
|
5810
|
-
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
|
+
})
|
|
5811
5873
|
);
|
|
5812
5874
|
for (const span of mapped) {
|
|
5813
5875
|
if (span.parentSpanId === void 0) continue;
|
|
5814
|
-
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;
|
|
5815
5878
|
}
|
|
5816
5879
|
return {
|
|
5817
5880
|
events: mapped.map((span) => span.event),
|
|
@@ -6103,20 +6166,38 @@ function extractOtlpDocument(root) {
|
|
|
6103
6166
|
function mapOtlpStatus(status) {
|
|
6104
6167
|
if (!isRecord10(status)) return void 0;
|
|
6105
6168
|
const rawCode = status.code;
|
|
6106
|
-
if (typeof rawCode
|
|
6107
|
-
|
|
6108
|
-
|
|
6109
|
-
|
|
6110
|
-
|
|
6111
|
-
|
|
6112
|
-
|
|
6113
|
-
|
|
6114
|
-
|
|
6115
|
-
|
|
6116
|
-
|
|
6117
|
-
|
|
6118
|
-
|
|
6169
|
+
if (typeof rawCode === "number" && Number.isFinite(rawCode)) {
|
|
6170
|
+
switch (rawCode) {
|
|
6171
|
+
case 0:
|
|
6172
|
+
return "unknown";
|
|
6173
|
+
case 1:
|
|
6174
|
+
return "ok";
|
|
6175
|
+
case 2:
|
|
6176
|
+
return "error";
|
|
6177
|
+
default:
|
|
6178
|
+
return "unknown";
|
|
6179
|
+
}
|
|
6180
|
+
}
|
|
6181
|
+
if (typeof rawCode === "string") {
|
|
6182
|
+
const trimmed = rawCode.trim();
|
|
6183
|
+
if (/^\d+$/.test(trimmed)) {
|
|
6184
|
+
return mapOtlpStatus({ code: Number(trimmed) });
|
|
6185
|
+
}
|
|
6186
|
+
switch (trimmed.toUpperCase()) {
|
|
6187
|
+
case "STATUS_CODE_OK":
|
|
6188
|
+
case "OK":
|
|
6189
|
+
return "ok";
|
|
6190
|
+
case "STATUS_CODE_ERROR":
|
|
6191
|
+
case "ERROR":
|
|
6192
|
+
return "error";
|
|
6193
|
+
case "STATUS_CODE_UNSET":
|
|
6194
|
+
case "UNSET":
|
|
6195
|
+
return "unknown";
|
|
6196
|
+
default:
|
|
6197
|
+
return "unknown";
|
|
6198
|
+
}
|
|
6119
6199
|
}
|
|
6200
|
+
return void 0;
|
|
6120
6201
|
}
|
|
6121
6202
|
function readOtlpKind(attributes, pathPrefix) {
|
|
6122
6203
|
const warnings = [];
|
|
@@ -6342,7 +6423,7 @@ function mapOtlpSpan(context) {
|
|
|
6342
6423
|
const errorMessage = isRecord10(span.status) && typeof span.status.message === "string" ? span.status.message : void 0;
|
|
6343
6424
|
const event = {
|
|
6344
6425
|
schemaVersion: "0.2",
|
|
6345
|
-
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}`,
|
|
6346
6427
|
runId: typeof parsedSpanAttributes.attributes["agent_inspect.run_id"] === "string" ? parsedSpanAttributes.attributes["agent_inspect.run_id"] : traceId,
|
|
6347
6428
|
kind,
|
|
6348
6429
|
name: readStringField(span, ["name"]) ?? spanId,
|
|
@@ -6391,12 +6472,16 @@ function mapOtlpSpan(context) {
|
|
|
6391
6472
|
}
|
|
6392
6473
|
function mapOtlpEventsToPersisted(document) {
|
|
6393
6474
|
const mapped = document.spans.map((span) => mapOtlpSpan(span));
|
|
6394
|
-
const
|
|
6395
|
-
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
|
+
})
|
|
6396
6480
|
);
|
|
6397
6481
|
for (const span of mapped) {
|
|
6398
6482
|
if (span.parentSpanId === void 0) continue;
|
|
6399
|
-
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;
|
|
6400
6485
|
}
|
|
6401
6486
|
return {
|
|
6402
6487
|
events: mapped.map((span) => span.event),
|
|
@@ -7300,11 +7385,13 @@ function exportOpenInference(tree, options) {
|
|
|
7300
7385
|
endNs = startNs + unixNano(ev.durationMs);
|
|
7301
7386
|
}
|
|
7302
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;
|
|
7303
7390
|
const attrs2 = {
|
|
7304
7391
|
"openinference.span.kind": openInferenceKind,
|
|
7305
7392
|
"agent_inspect.kind": ev.kind,
|
|
7306
7393
|
"agent_inspect.confidence": ev.confidence,
|
|
7307
|
-
"agent_inspect.source.type":
|
|
7394
|
+
"agent_inspect.source.type": originalSource,
|
|
7308
7395
|
"agent_inspect.run_id": tree.runId,
|
|
7309
7396
|
"agent_inspect.event_id": ev.eventId,
|
|
7310
7397
|
"agent_inspect.status": ev.status ?? "unset"
|
|
@@ -7312,9 +7399,9 @@ function exportOpenInference(tree, options) {
|
|
|
7312
7399
|
if (ev.durationMs !== void 0) {
|
|
7313
7400
|
attrs2["agent_inspect.duration_ms"] = ev.durationMs;
|
|
7314
7401
|
}
|
|
7315
|
-
const
|
|
7316
|
-
if (
|
|
7317
|
-
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;
|
|
7318
7405
|
}
|
|
7319
7406
|
const tokens = meta?.tokens;
|
|
7320
7407
|
if (tokens && typeof tokens === "object" && tokens !== null) {
|
|
@@ -7324,8 +7411,9 @@ function exportOpenInference(tree, options) {
|
|
|
7324
7411
|
if (typeof outp === "number") attrs2["llm.token_count.completion"] = outp;
|
|
7325
7412
|
}
|
|
7326
7413
|
if (includeAttributes && meta && typeof meta === "object") {
|
|
7414
|
+
const skipKeys = /* @__PURE__ */ new Set(["tokens", "model", "modelId", "originalSourceType"]);
|
|
7327
7415
|
for (const [k, v] of Object.entries(meta)) {
|
|
7328
|
-
if (k
|
|
7416
|
+
if (skipKeys.has(k)) continue;
|
|
7329
7417
|
if (v !== void 0 && v !== null && typeof v !== "object") {
|
|
7330
7418
|
attrs2[`agent_inspect.preview.${k}`] = typeof v === "string" ? v.slice(0, maxLen) : v;
|
|
7331
7419
|
}
|
|
@@ -7368,6 +7456,10 @@ function exportOpenInference(tree, options) {
|
|
|
7368
7456
|
warnings
|
|
7369
7457
|
};
|
|
7370
7458
|
}
|
|
7459
|
+
var OTLP_STATUS_CODE_UNSET = 0;
|
|
7460
|
+
var OTLP_STATUS_CODE_OK = 1;
|
|
7461
|
+
var OTLP_STATUS_CODE_ERROR = 2;
|
|
7462
|
+
var OTLP_SPAN_KIND_INTERNAL = 1;
|
|
7371
7463
|
function hexFrom2(seed, byteLen) {
|
|
7372
7464
|
return crypto.createHash("sha256").update(seed, "utf8").digest("hex").slice(0, byteLen * 2);
|
|
7373
7465
|
}
|
|
@@ -7380,7 +7472,19 @@ function stringAttr2(key, value) {
|
|
|
7380
7472
|
return { key, value: { stringValue: value } };
|
|
7381
7473
|
}
|
|
7382
7474
|
function intAttr(key, value) {
|
|
7383
|
-
return { key, value: { intValue: String(value) } };
|
|
7475
|
+
return { key, value: { intValue: String(Math.trunc(value)) } };
|
|
7476
|
+
}
|
|
7477
|
+
function doubleAttr(key, value) {
|
|
7478
|
+
return { key, value: { doubleValue: value } };
|
|
7479
|
+
}
|
|
7480
|
+
function boolAttr(key, value) {
|
|
7481
|
+
return { key, value: { boolValue: value } };
|
|
7482
|
+
}
|
|
7483
|
+
function numberAttr(key, value) {
|
|
7484
|
+
if (Number.isFinite(value) && !Number.isInteger(value)) {
|
|
7485
|
+
return doubleAttr(key, value);
|
|
7486
|
+
}
|
|
7487
|
+
return intAttr(key, value);
|
|
7384
7488
|
}
|
|
7385
7489
|
function genAiOperationName(kind) {
|
|
7386
7490
|
switch (kind) {
|
|
@@ -7394,10 +7498,27 @@ function genAiOperationName(kind) {
|
|
|
7394
7498
|
return void 0;
|
|
7395
7499
|
}
|
|
7396
7500
|
}
|
|
7501
|
+
function resolveSpanTimes(ev) {
|
|
7502
|
+
const startedAtMs = typeof ev.attributes?.startedAtMs === "number" && Number.isFinite(ev.attributes.startedAtMs) ? ev.attributes.startedAtMs : void 0;
|
|
7503
|
+
const endedAtMs = typeof ev.attributes?.endedAtMs === "number" && Number.isFinite(ev.attributes.endedAtMs) ? ev.attributes.endedAtMs : void 0;
|
|
7504
|
+
const startMs = startedAtMs ?? ev.timestamp;
|
|
7505
|
+
const startNs = String(unixNano2(startMs));
|
|
7506
|
+
if (endedAtMs !== void 0) {
|
|
7507
|
+
return { startNs, endNs: String(unixNano2(endedAtMs)) };
|
|
7508
|
+
}
|
|
7509
|
+
if (ev.durationMs !== void 0 && Number.isFinite(ev.durationMs)) {
|
|
7510
|
+
return {
|
|
7511
|
+
startNs,
|
|
7512
|
+
endNs: String(unixNano2(startMs) + unixNano2(ev.durationMs))
|
|
7513
|
+
};
|
|
7514
|
+
}
|
|
7515
|
+
return { startNs };
|
|
7516
|
+
}
|
|
7397
7517
|
function exportOtlpJson(tree, options) {
|
|
7398
7518
|
const warnings = [
|
|
7399
7519
|
"OTLP JSON export uses OTel GenAI-aligned attributes where applicable; experimental until verified against specific collectors.",
|
|
7400
|
-
"Not OTLP gRPC/protobuf \u2014 JSON mapping only. Generated locally; no network upload."
|
|
7520
|
+
"Not OTLP gRPC/protobuf \u2014 JSON mapping only. Generated locally; no network upload.",
|
|
7521
|
+
"Status and span kind use OTLP numeric enums (StatusCode 0/1/2, SpanKind INTERNAL=1)."
|
|
7401
7522
|
];
|
|
7402
7523
|
const traceId = hexFrom2(`trace:${tree.runId}`, 16);
|
|
7403
7524
|
const includeAttributes = options?.includeAttributes ?? false;
|
|
@@ -7409,29 +7530,34 @@ function exportOtlpJson(tree, options) {
|
|
|
7409
7530
|
const ev = n.event;
|
|
7410
7531
|
const spanId = hexFrom2(`${tree.runId}:${ev.eventId}`, 8);
|
|
7411
7532
|
const parentSpanId = ev.parentId ? hexFrom2(`${tree.runId}:${ev.parentId}`, 8) : void 0;
|
|
7412
|
-
const startNs =
|
|
7413
|
-
|
|
7414
|
-
|
|
7415
|
-
endNs = String(unixNano2(ev.timestamp) + unixNano2(ev.durationMs));
|
|
7416
|
-
}
|
|
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;
|
|
7417
7536
|
const attrs2 = [
|
|
7418
7537
|
stringAttr2("agent_inspect.kind", ev.kind),
|
|
7419
7538
|
stringAttr2("agent_inspect.confidence", ev.confidence),
|
|
7420
|
-
stringAttr2("agent_inspect.source.type",
|
|
7539
|
+
stringAttr2("agent_inspect.source.type", originalSource),
|
|
7421
7540
|
stringAttr2("agent_inspect.run_id", tree.runId),
|
|
7422
7541
|
stringAttr2("agent_inspect.event_id", ev.eventId),
|
|
7423
7542
|
stringAttr2("agent_inspect.status", ev.status ?? "unset")
|
|
7424
7543
|
];
|
|
7425
7544
|
if (ev.durationMs !== void 0) {
|
|
7426
|
-
attrs2.push(
|
|
7545
|
+
attrs2.push(numberAttr("agent_inspect.duration_ms", ev.durationMs));
|
|
7427
7546
|
}
|
|
7428
7547
|
const op = genAiOperationName(ev.kind);
|
|
7429
7548
|
if (op !== void 0) {
|
|
7430
7549
|
attrs2.push(stringAttr2("gen_ai.operation.name", op));
|
|
7431
7550
|
}
|
|
7432
|
-
const
|
|
7433
|
-
if (
|
|
7434
|
-
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)));
|
|
7435
7561
|
}
|
|
7436
7562
|
const tokens = meta?.tokens;
|
|
7437
7563
|
if (tokens && typeof tokens === "object" && tokens !== null) {
|
|
@@ -7441,31 +7567,39 @@ function exportOtlpJson(tree, options) {
|
|
|
7441
7567
|
if (typeof outp === "number") attrs2.push(intAttr("gen_ai.usage.output_tokens", outp));
|
|
7442
7568
|
}
|
|
7443
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
|
+
]);
|
|
7444
7579
|
for (const [k, v] of Object.entries(meta)) {
|
|
7445
|
-
if (k
|
|
7446
|
-
if (typeof v === "string"
|
|
7447
|
-
attrs2.push(
|
|
7448
|
-
|
|
7449
|
-
|
|
7450
|
-
|
|
7451
|
-
|
|
7452
|
-
);
|
|
7580
|
+
if (skipKeys.has(k)) continue;
|
|
7581
|
+
if (typeof v === "string") {
|
|
7582
|
+
attrs2.push(stringAttr2(`agent_inspect.preview.${k}`, v.slice(0, maxLen)));
|
|
7583
|
+
} else if (typeof v === "number" && Number.isFinite(v)) {
|
|
7584
|
+
attrs2.push(numberAttr(`agent_inspect.preview.${k}`, v));
|
|
7585
|
+
} else if (typeof v === "boolean") {
|
|
7586
|
+
attrs2.push(boolAttr(`agent_inspect.preview.${k}`, v));
|
|
7453
7587
|
}
|
|
7454
7588
|
}
|
|
7455
7589
|
}
|
|
7456
|
-
let statusCode =
|
|
7590
|
+
let statusCode = OTLP_STATUS_CODE_UNSET;
|
|
7457
7591
|
let statusMessage;
|
|
7458
7592
|
if (ev.status === "error") {
|
|
7459
|
-
statusCode =
|
|
7593
|
+
statusCode = OTLP_STATUS_CODE_ERROR;
|
|
7460
7594
|
statusMessage = meta && typeof meta.error === "object" && meta.error !== null ? String(meta.error.message ?? "error").slice(0, maxLen) : "error";
|
|
7461
7595
|
} else if (ev.status === "ok") {
|
|
7462
|
-
statusCode =
|
|
7596
|
+
statusCode = OTLP_STATUS_CODE_OK;
|
|
7463
7597
|
}
|
|
7464
7598
|
const spanJson = {
|
|
7465
7599
|
traceId,
|
|
7466
7600
|
spanId,
|
|
7467
7601
|
name: ev.name,
|
|
7468
|
-
kind:
|
|
7602
|
+
kind: OTLP_SPAN_KIND_INTERNAL,
|
|
7469
7603
|
startTimeUnixNano: startNs,
|
|
7470
7604
|
attributes: attrs2,
|
|
7471
7605
|
status: {
|
|
@@ -9130,5 +9264,5 @@ async function runReadOnlyMcpServer(options = {}) {
|
|
|
9130
9264
|
}
|
|
9131
9265
|
|
|
9132
9266
|
export { MCP_MAX_REQUEST_BYTES, MCP_PROTOCOL_VERSION, MCP_SERVER_INSTRUCTIONS, READ_ONLY_TOOLS, TRACE_DATA_UNTRUSTED_WARNING, callReadOnlyTool, createMcpServerContext, handleMcpProtocolLine, runReadOnlyMcpServer };
|
|
9133
|
-
//# sourceMappingURL=chunk-
|
|
9134
|
-
//# sourceMappingURL=chunk-
|
|
9267
|
+
//# sourceMappingURL=chunk-MXA5GAJQ.mjs.map
|
|
9268
|
+
//# sourceMappingURL=chunk-MXA5GAJQ.mjs.map
|