@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
package/dist/cli.cjs
CHANGED
|
@@ -1498,6 +1498,8 @@ function filterTraces(traces, options) {
|
|
|
1498
1498
|
}
|
|
1499
1499
|
|
|
1500
1500
|
// packages/core/src/timeline.ts
|
|
1501
|
+
var ROOT_TIMELINE_DEPTH = 0;
|
|
1502
|
+
var MAX_TIMELINE_DEPTH = 1e3;
|
|
1501
1503
|
function finite(n) {
|
|
1502
1504
|
return typeof n === "number" && Number.isFinite(n);
|
|
1503
1505
|
}
|
|
@@ -1568,16 +1570,51 @@ function buildRunTimeline(events, options = {}) {
|
|
|
1568
1570
|
const computeDepth = (stepId) => {
|
|
1569
1571
|
const cached = depthCache.get(stepId);
|
|
1570
1572
|
if (cached !== void 0) return cached;
|
|
1571
|
-
const
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1573
|
+
const ancestry = [];
|
|
1574
|
+
const ancestryIndexes = /* @__PURE__ */ new Map();
|
|
1575
|
+
let currentStepId = stepId;
|
|
1576
|
+
let resolvedDepth;
|
|
1577
|
+
while (resolvedDepth === void 0) {
|
|
1578
|
+
const cachedDepth = depthCache.get(currentStepId);
|
|
1579
|
+
if (cachedDepth !== void 0) {
|
|
1580
|
+
resolvedDepth = cachedDepth;
|
|
1581
|
+
continue;
|
|
1582
|
+
}
|
|
1583
|
+
const cycleStart = ancestryIndexes.get(currentStepId);
|
|
1584
|
+
if (cycleStart !== void 0) {
|
|
1585
|
+
const cycleStepIds = ancestry.splice(cycleStart);
|
|
1586
|
+
for (const cycleStepId of cycleStepIds) {
|
|
1587
|
+
depthCache.set(cycleStepId, ROOT_TIMELINE_DEPTH);
|
|
1588
|
+
}
|
|
1589
|
+
resolvedDepth = ROOT_TIMELINE_DEPTH;
|
|
1590
|
+
continue;
|
|
1591
|
+
}
|
|
1592
|
+
const currentStep = steps.get(currentStepId);
|
|
1593
|
+
if (!currentStep) {
|
|
1594
|
+
resolvedDepth = ROOT_TIMELINE_DEPTH;
|
|
1595
|
+
continue;
|
|
1596
|
+
}
|
|
1597
|
+
ancestryIndexes.set(currentStepId, ancestry.length);
|
|
1598
|
+
ancestry.push(currentStepId);
|
|
1599
|
+
const parentId = currentStep.parentId;
|
|
1600
|
+
if (typeof parentId !== "string" || parentId.trim() === "" || !steps.has(parentId)) {
|
|
1601
|
+
ancestry.pop();
|
|
1602
|
+
depthCache.set(currentStepId, ROOT_TIMELINE_DEPTH);
|
|
1603
|
+
resolvedDepth = ROOT_TIMELINE_DEPTH;
|
|
1604
|
+
continue;
|
|
1605
|
+
}
|
|
1606
|
+
currentStepId = parentId;
|
|
1607
|
+
}
|
|
1608
|
+
ancestry.reverse();
|
|
1609
|
+
for (const ancestorStepId of ancestry) {
|
|
1610
|
+
resolvedDepth = Math.min(MAX_TIMELINE_DEPTH, resolvedDepth + 1);
|
|
1611
|
+
depthCache.set(ancestorStepId, resolvedDepth);
|
|
1577
1612
|
}
|
|
1578
|
-
const
|
|
1579
|
-
|
|
1580
|
-
|
|
1613
|
+
const resolvedStepDepth = depthCache.get(stepId);
|
|
1614
|
+
if (resolvedStepDepth === void 0) {
|
|
1615
|
+
throw new Error(`Failed to resolve timeline depth for step "${stepId}"`);
|
|
1616
|
+
}
|
|
1617
|
+
return resolvedStepDepth;
|
|
1581
1618
|
};
|
|
1582
1619
|
const entries = [];
|
|
1583
1620
|
for (const [stepId, s] of steps.entries()) {
|
|
@@ -5052,6 +5089,23 @@ function persistedInspectEventToInspectEvent(event) {
|
|
|
5052
5089
|
if (event.durationMs !== void 0 && Number.isFinite(event.durationMs) && event.durationMs >= 0) {
|
|
5053
5090
|
out.durationMs = event.durationMs;
|
|
5054
5091
|
}
|
|
5092
|
+
if (event.startedAt !== void 0) {
|
|
5093
|
+
const started = parseIsoToMs3(event.startedAt);
|
|
5094
|
+
if (!started.invalidTimestamp) {
|
|
5095
|
+
attrs2.startedAtMs = started.ms;
|
|
5096
|
+
out.timestamp = started.ms;
|
|
5097
|
+
}
|
|
5098
|
+
}
|
|
5099
|
+
if (event.endedAt !== void 0) {
|
|
5100
|
+
const ended = parseIsoToMs3(event.endedAt);
|
|
5101
|
+
if (!ended.invalidTimestamp) {
|
|
5102
|
+
attrs2.endedAtMs = ended.ms;
|
|
5103
|
+
if (out.durationMs === void 0 && typeof attrs2.startedAtMs === "number" && ended.ms >= attrs2.startedAtMs) {
|
|
5104
|
+
out.durationMs = ended.ms - attrs2.startedAtMs;
|
|
5105
|
+
}
|
|
5106
|
+
}
|
|
5107
|
+
}
|
|
5108
|
+
out.attributes = compactAttributes3(attrs2);
|
|
5055
5109
|
return out;
|
|
5056
5110
|
}
|
|
5057
5111
|
function persistedInspectEventsToInspectEvents(events, options) {
|
|
@@ -5070,8 +5124,13 @@ function persistedInspectEventsToInspectEvents(events, options) {
|
|
|
5070
5124
|
}
|
|
5071
5125
|
|
|
5072
5126
|
// packages/core/src/persisted/tree-bridge.ts
|
|
5127
|
+
function logicalToPersisted(event) {
|
|
5128
|
+
const { sourceEventIds: _sourceEventIds, projection: _projection, ...rest } = event;
|
|
5129
|
+
return rest;
|
|
5130
|
+
}
|
|
5073
5131
|
function persistedInspectEventsToRunTrees(events, options) {
|
|
5074
|
-
const
|
|
5132
|
+
const sourceEvents = options?.coalesceLifecycle === true ? projectLogicalEvents(events).logicalEvents.map(logicalToPersisted) : events;
|
|
5133
|
+
const inspectEvents = persistedInspectEventsToInspectEvents(sourceEvents, {
|
|
5075
5134
|
skipInvalid: options?.skipInvalid
|
|
5076
5135
|
});
|
|
5077
5136
|
return new TreeBuilder().build(inspectEvents);
|
|
@@ -5765,7 +5824,7 @@ function mapOpenInferenceSpan(span, index, version) {
|
|
|
5765
5824
|
const errorMessage = isRecord10(span.status) && typeof span.status.message === "string" ? span.status.message : void 0;
|
|
5766
5825
|
const event = {
|
|
5767
5826
|
schemaVersion: "0.2",
|
|
5768
|
-
eventId: typeof rawAttributes["agent_inspect.event_id"] === "string" ? rawAttributes["agent_inspect.event_id"] : spanId
|
|
5827
|
+
eventId: typeof rawAttributes["agent_inspect.event_id"] === "string" ? rawAttributes["agent_inspect.event_id"] : `${traceId}:${spanId}`,
|
|
5769
5828
|
runId: typeof rawAttributes["agent_inspect.run_id"] === "string" ? rawAttributes["agent_inspect.run_id"] : traceId,
|
|
5770
5829
|
kind,
|
|
5771
5830
|
name,
|
|
@@ -5816,12 +5875,16 @@ function mapOpenInferenceEvents(document) {
|
|
|
5816
5875
|
const mapped = document.spans.map(
|
|
5817
5876
|
(span, index) => mapOpenInferenceSpan(span, index, document.version)
|
|
5818
5877
|
);
|
|
5819
|
-
const
|
|
5820
|
-
mapped.map((span) =>
|
|
5878
|
+
const spanKeyToEventId = new Map(
|
|
5879
|
+
mapped.map((span) => {
|
|
5880
|
+
const traceId = typeof span.event.trace?.traceId === "string" ? span.event.trace.traceId : "";
|
|
5881
|
+
return [`${traceId}:${span.spanId}`, span.event.eventId];
|
|
5882
|
+
})
|
|
5821
5883
|
);
|
|
5822
5884
|
for (const span of mapped) {
|
|
5823
5885
|
if (span.parentSpanId === void 0) continue;
|
|
5824
|
-
span.event.
|
|
5886
|
+
const traceId = typeof span.event.trace?.traceId === "string" ? span.event.trace.traceId : "";
|
|
5887
|
+
span.event.parentId = spanKeyToEventId.get(`${traceId}:${span.parentSpanId}`) ?? span.parentSpanId;
|
|
5825
5888
|
}
|
|
5826
5889
|
return {
|
|
5827
5890
|
events: mapped.map((span) => span.event),
|
|
@@ -6113,20 +6176,38 @@ function extractOtlpDocument(root) {
|
|
|
6113
6176
|
function mapOtlpStatus(status) {
|
|
6114
6177
|
if (!isRecord10(status)) return void 0;
|
|
6115
6178
|
const rawCode = status.code;
|
|
6116
|
-
if (typeof rawCode
|
|
6117
|
-
|
|
6118
|
-
|
|
6119
|
-
|
|
6120
|
-
|
|
6121
|
-
|
|
6122
|
-
|
|
6123
|
-
|
|
6124
|
-
|
|
6125
|
-
|
|
6126
|
-
|
|
6127
|
-
|
|
6128
|
-
|
|
6179
|
+
if (typeof rawCode === "number" && Number.isFinite(rawCode)) {
|
|
6180
|
+
switch (rawCode) {
|
|
6181
|
+
case 0:
|
|
6182
|
+
return "unknown";
|
|
6183
|
+
case 1:
|
|
6184
|
+
return "ok";
|
|
6185
|
+
case 2:
|
|
6186
|
+
return "error";
|
|
6187
|
+
default:
|
|
6188
|
+
return "unknown";
|
|
6189
|
+
}
|
|
6190
|
+
}
|
|
6191
|
+
if (typeof rawCode === "string") {
|
|
6192
|
+
const trimmed = rawCode.trim();
|
|
6193
|
+
if (/^\d+$/.test(trimmed)) {
|
|
6194
|
+
return mapOtlpStatus({ code: Number(trimmed) });
|
|
6195
|
+
}
|
|
6196
|
+
switch (trimmed.toUpperCase()) {
|
|
6197
|
+
case "STATUS_CODE_OK":
|
|
6198
|
+
case "OK":
|
|
6199
|
+
return "ok";
|
|
6200
|
+
case "STATUS_CODE_ERROR":
|
|
6201
|
+
case "ERROR":
|
|
6202
|
+
return "error";
|
|
6203
|
+
case "STATUS_CODE_UNSET":
|
|
6204
|
+
case "UNSET":
|
|
6205
|
+
return "unknown";
|
|
6206
|
+
default:
|
|
6207
|
+
return "unknown";
|
|
6208
|
+
}
|
|
6129
6209
|
}
|
|
6210
|
+
return void 0;
|
|
6130
6211
|
}
|
|
6131
6212
|
function readOtlpKind(attributes, pathPrefix) {
|
|
6132
6213
|
const warnings = [];
|
|
@@ -6352,7 +6433,7 @@ function mapOtlpSpan(context) {
|
|
|
6352
6433
|
const errorMessage = isRecord10(span.status) && typeof span.status.message === "string" ? span.status.message : void 0;
|
|
6353
6434
|
const event = {
|
|
6354
6435
|
schemaVersion: "0.2",
|
|
6355
|
-
eventId: typeof parsedSpanAttributes.attributes["agent_inspect.event_id"] === "string" ? parsedSpanAttributes.attributes["agent_inspect.event_id"] : spanId
|
|
6436
|
+
eventId: typeof parsedSpanAttributes.attributes["agent_inspect.event_id"] === "string" ? parsedSpanAttributes.attributes["agent_inspect.event_id"] : `${traceId}:${spanId}`,
|
|
6356
6437
|
runId: typeof parsedSpanAttributes.attributes["agent_inspect.run_id"] === "string" ? parsedSpanAttributes.attributes["agent_inspect.run_id"] : traceId,
|
|
6357
6438
|
kind,
|
|
6358
6439
|
name: readStringField(span, ["name"]) ?? spanId,
|
|
@@ -6401,12 +6482,16 @@ function mapOtlpSpan(context) {
|
|
|
6401
6482
|
}
|
|
6402
6483
|
function mapOtlpEventsToPersisted(document) {
|
|
6403
6484
|
const mapped = document.spans.map((span) => mapOtlpSpan(span));
|
|
6404
|
-
const
|
|
6405
|
-
mapped.map((span) =>
|
|
6485
|
+
const spanKeyToEventId = new Map(
|
|
6486
|
+
mapped.map((span) => {
|
|
6487
|
+
const traceId = typeof span.event.trace?.traceId === "string" ? span.event.trace.traceId : "";
|
|
6488
|
+
return [`${traceId}:${span.spanId}`, span.event.eventId];
|
|
6489
|
+
})
|
|
6406
6490
|
);
|
|
6407
6491
|
for (const span of mapped) {
|
|
6408
6492
|
if (span.parentSpanId === void 0) continue;
|
|
6409
|
-
span.event.
|
|
6493
|
+
const traceId = typeof span.event.trace?.traceId === "string" ? span.event.trace.traceId : "";
|
|
6494
|
+
span.event.parentId = spanKeyToEventId.get(`${traceId}:${span.parentSpanId}`) ?? span.parentSpanId;
|
|
6410
6495
|
}
|
|
6411
6496
|
return {
|
|
6412
6497
|
events: mapped.map((span) => span.event),
|
|
@@ -7310,11 +7395,13 @@ function exportOpenInference(tree, options) {
|
|
|
7310
7395
|
endNs = startNs + unixNano(ev.durationMs);
|
|
7311
7396
|
}
|
|
7312
7397
|
const { openInferenceKind } = mapInspectKindToOI(ev.kind, warnings);
|
|
7398
|
+
const meta = ev.attributes;
|
|
7399
|
+
const originalSource = typeof meta?.originalSourceType === "string" && meta.originalSourceType.trim() !== "" ? meta.originalSourceType.trim() : ev.source.type;
|
|
7313
7400
|
const attrs2 = {
|
|
7314
7401
|
"openinference.span.kind": openInferenceKind,
|
|
7315
7402
|
"agent_inspect.kind": ev.kind,
|
|
7316
7403
|
"agent_inspect.confidence": ev.confidence,
|
|
7317
|
-
"agent_inspect.source.type":
|
|
7404
|
+
"agent_inspect.source.type": originalSource,
|
|
7318
7405
|
"agent_inspect.run_id": tree.runId,
|
|
7319
7406
|
"agent_inspect.event_id": ev.eventId,
|
|
7320
7407
|
"agent_inspect.status": ev.status ?? "unset"
|
|
@@ -7322,9 +7409,9 @@ function exportOpenInference(tree, options) {
|
|
|
7322
7409
|
if (ev.durationMs !== void 0) {
|
|
7323
7410
|
attrs2["agent_inspect.duration_ms"] = ev.durationMs;
|
|
7324
7411
|
}
|
|
7325
|
-
const
|
|
7326
|
-
if (
|
|
7327
|
-
attrs2["llm.model_name"] =
|
|
7412
|
+
const requestModel = (typeof meta?.model === "string" && meta.model.trim() !== "" ? meta.model : void 0) ?? (typeof meta?.modelId === "string" && meta.modelId.trim() !== "" ? meta.modelId : void 0);
|
|
7413
|
+
if (requestModel !== void 0) {
|
|
7414
|
+
attrs2["llm.model_name"] = requestModel;
|
|
7328
7415
|
}
|
|
7329
7416
|
const tokens = meta?.tokens;
|
|
7330
7417
|
if (tokens && typeof tokens === "object" && tokens !== null) {
|
|
@@ -7334,8 +7421,9 @@ function exportOpenInference(tree, options) {
|
|
|
7334
7421
|
if (typeof outp === "number") attrs2["llm.token_count.completion"] = outp;
|
|
7335
7422
|
}
|
|
7336
7423
|
if (includeAttributes && meta && typeof meta === "object") {
|
|
7424
|
+
const skipKeys = /* @__PURE__ */ new Set(["tokens", "model", "modelId", "originalSourceType"]);
|
|
7337
7425
|
for (const [k, v] of Object.entries(meta)) {
|
|
7338
|
-
if (k
|
|
7426
|
+
if (skipKeys.has(k)) continue;
|
|
7339
7427
|
if (v !== void 0 && v !== null && typeof v !== "object") {
|
|
7340
7428
|
attrs2[`agent_inspect.preview.${k}`] = typeof v === "string" ? v.slice(0, maxLen) : v;
|
|
7341
7429
|
}
|
|
@@ -7378,6 +7466,10 @@ function exportOpenInference(tree, options) {
|
|
|
7378
7466
|
warnings
|
|
7379
7467
|
};
|
|
7380
7468
|
}
|
|
7469
|
+
var OTLP_STATUS_CODE_UNSET = 0;
|
|
7470
|
+
var OTLP_STATUS_CODE_OK = 1;
|
|
7471
|
+
var OTLP_STATUS_CODE_ERROR = 2;
|
|
7472
|
+
var OTLP_SPAN_KIND_INTERNAL = 1;
|
|
7381
7473
|
function hexFrom2(seed, byteLen) {
|
|
7382
7474
|
return crypto__default.default.createHash("sha256").update(seed, "utf8").digest("hex").slice(0, byteLen * 2);
|
|
7383
7475
|
}
|
|
@@ -7390,7 +7482,19 @@ function stringAttr2(key, value) {
|
|
|
7390
7482
|
return { key, value: { stringValue: value } };
|
|
7391
7483
|
}
|
|
7392
7484
|
function intAttr(key, value) {
|
|
7393
|
-
return { key, value: { intValue: String(value) } };
|
|
7485
|
+
return { key, value: { intValue: String(Math.trunc(value)) } };
|
|
7486
|
+
}
|
|
7487
|
+
function doubleAttr(key, value) {
|
|
7488
|
+
return { key, value: { doubleValue: value } };
|
|
7489
|
+
}
|
|
7490
|
+
function boolAttr(key, value) {
|
|
7491
|
+
return { key, value: { boolValue: value } };
|
|
7492
|
+
}
|
|
7493
|
+
function numberAttr(key, value) {
|
|
7494
|
+
if (Number.isFinite(value) && !Number.isInteger(value)) {
|
|
7495
|
+
return doubleAttr(key, value);
|
|
7496
|
+
}
|
|
7497
|
+
return intAttr(key, value);
|
|
7394
7498
|
}
|
|
7395
7499
|
function genAiOperationName(kind) {
|
|
7396
7500
|
switch (kind) {
|
|
@@ -7404,10 +7508,27 @@ function genAiOperationName(kind) {
|
|
|
7404
7508
|
return void 0;
|
|
7405
7509
|
}
|
|
7406
7510
|
}
|
|
7511
|
+
function resolveSpanTimes(ev) {
|
|
7512
|
+
const startedAtMs = typeof ev.attributes?.startedAtMs === "number" && Number.isFinite(ev.attributes.startedAtMs) ? ev.attributes.startedAtMs : void 0;
|
|
7513
|
+
const endedAtMs = typeof ev.attributes?.endedAtMs === "number" && Number.isFinite(ev.attributes.endedAtMs) ? ev.attributes.endedAtMs : void 0;
|
|
7514
|
+
const startMs = startedAtMs ?? ev.timestamp;
|
|
7515
|
+
const startNs = String(unixNano2(startMs));
|
|
7516
|
+
if (endedAtMs !== void 0) {
|
|
7517
|
+
return { startNs, endNs: String(unixNano2(endedAtMs)) };
|
|
7518
|
+
}
|
|
7519
|
+
if (ev.durationMs !== void 0 && Number.isFinite(ev.durationMs)) {
|
|
7520
|
+
return {
|
|
7521
|
+
startNs,
|
|
7522
|
+
endNs: String(unixNano2(startMs) + unixNano2(ev.durationMs))
|
|
7523
|
+
};
|
|
7524
|
+
}
|
|
7525
|
+
return { startNs };
|
|
7526
|
+
}
|
|
7407
7527
|
function exportOtlpJson(tree, options) {
|
|
7408
7528
|
const warnings = [
|
|
7409
7529
|
"OTLP JSON export uses OTel GenAI-aligned attributes where applicable; experimental until verified against specific collectors.",
|
|
7410
|
-
"Not OTLP gRPC/protobuf \u2014 JSON mapping only. Generated locally; no network upload."
|
|
7530
|
+
"Not OTLP gRPC/protobuf \u2014 JSON mapping only. Generated locally; no network upload.",
|
|
7531
|
+
"Status and span kind use OTLP numeric enums (StatusCode 0/1/2, SpanKind INTERNAL=1)."
|
|
7411
7532
|
];
|
|
7412
7533
|
const traceId = hexFrom2(`trace:${tree.runId}`, 16);
|
|
7413
7534
|
const includeAttributes = options?.includeAttributes ?? false;
|
|
@@ -7419,29 +7540,34 @@ function exportOtlpJson(tree, options) {
|
|
|
7419
7540
|
const ev = n.event;
|
|
7420
7541
|
const spanId = hexFrom2(`${tree.runId}:${ev.eventId}`, 8);
|
|
7421
7542
|
const parentSpanId = ev.parentId ? hexFrom2(`${tree.runId}:${ev.parentId}`, 8) : void 0;
|
|
7422
|
-
const startNs =
|
|
7423
|
-
|
|
7424
|
-
|
|
7425
|
-
endNs = String(unixNano2(ev.timestamp) + unixNano2(ev.durationMs));
|
|
7426
|
-
}
|
|
7543
|
+
const { startNs, endNs } = resolveSpanTimes(ev);
|
|
7544
|
+
const meta = ev.attributes;
|
|
7545
|
+
const originalSource = typeof meta?.originalSourceType === "string" && meta.originalSourceType.trim() !== "" ? meta.originalSourceType.trim() : ev.source.type;
|
|
7427
7546
|
const attrs2 = [
|
|
7428
7547
|
stringAttr2("agent_inspect.kind", ev.kind),
|
|
7429
7548
|
stringAttr2("agent_inspect.confidence", ev.confidence),
|
|
7430
|
-
stringAttr2("agent_inspect.source.type",
|
|
7549
|
+
stringAttr2("agent_inspect.source.type", originalSource),
|
|
7431
7550
|
stringAttr2("agent_inspect.run_id", tree.runId),
|
|
7432
7551
|
stringAttr2("agent_inspect.event_id", ev.eventId),
|
|
7433
7552
|
stringAttr2("agent_inspect.status", ev.status ?? "unset")
|
|
7434
7553
|
];
|
|
7435
7554
|
if (ev.durationMs !== void 0) {
|
|
7436
|
-
attrs2.push(
|
|
7555
|
+
attrs2.push(numberAttr("agent_inspect.duration_ms", ev.durationMs));
|
|
7437
7556
|
}
|
|
7438
7557
|
const op = genAiOperationName(ev.kind);
|
|
7439
7558
|
if (op !== void 0) {
|
|
7440
7559
|
attrs2.push(stringAttr2("gen_ai.operation.name", op));
|
|
7441
7560
|
}
|
|
7442
|
-
const
|
|
7443
|
-
if (
|
|
7444
|
-
attrs2.push(stringAttr2("gen_ai.request.model",
|
|
7561
|
+
const requestModel = (typeof meta?.model === "string" && meta.model.trim() !== "" ? meta.model : void 0) ?? (typeof meta?.modelId === "string" && meta.modelId.trim() !== "" ? meta.modelId : void 0);
|
|
7562
|
+
if (requestModel !== void 0) {
|
|
7563
|
+
attrs2.push(stringAttr2("gen_ai.request.model", requestModel.slice(0, maxLen)));
|
|
7564
|
+
}
|
|
7565
|
+
const responseModel = typeof meta?.responseModelId === "string" && meta.responseModelId.trim() !== "" ? meta.responseModelId : typeof meta?.responseModel === "string" && meta.responseModel.trim() !== "" ? meta.responseModel : void 0;
|
|
7566
|
+
if (responseModel !== void 0) {
|
|
7567
|
+
attrs2.push(stringAttr2("gen_ai.response.model", responseModel.slice(0, maxLen)));
|
|
7568
|
+
}
|
|
7569
|
+
if (typeof meta?.provider === "string" && meta.provider.trim() !== "") {
|
|
7570
|
+
attrs2.push(stringAttr2("gen_ai.provider.name", meta.provider.slice(0, maxLen)));
|
|
7445
7571
|
}
|
|
7446
7572
|
const tokens = meta?.tokens;
|
|
7447
7573
|
if (tokens && typeof tokens === "object" && tokens !== null) {
|
|
@@ -7451,31 +7577,39 @@ function exportOtlpJson(tree, options) {
|
|
|
7451
7577
|
if (typeof outp === "number") attrs2.push(intAttr("gen_ai.usage.output_tokens", outp));
|
|
7452
7578
|
}
|
|
7453
7579
|
if (includeAttributes && meta && typeof meta === "object") {
|
|
7580
|
+
const skipKeys = /* @__PURE__ */ new Set([
|
|
7581
|
+
"tokens",
|
|
7582
|
+
"model",
|
|
7583
|
+
"modelId",
|
|
7584
|
+
"responseModel",
|
|
7585
|
+
"responseModelId",
|
|
7586
|
+
"provider",
|
|
7587
|
+
"originalSourceType"
|
|
7588
|
+
]);
|
|
7454
7589
|
for (const [k, v] of Object.entries(meta)) {
|
|
7455
|
-
if (k
|
|
7456
|
-
if (typeof v === "string"
|
|
7457
|
-
attrs2.push(
|
|
7458
|
-
|
|
7459
|
-
|
|
7460
|
-
|
|
7461
|
-
|
|
7462
|
-
);
|
|
7590
|
+
if (skipKeys.has(k)) continue;
|
|
7591
|
+
if (typeof v === "string") {
|
|
7592
|
+
attrs2.push(stringAttr2(`agent_inspect.preview.${k}`, v.slice(0, maxLen)));
|
|
7593
|
+
} else if (typeof v === "number" && Number.isFinite(v)) {
|
|
7594
|
+
attrs2.push(numberAttr(`agent_inspect.preview.${k}`, v));
|
|
7595
|
+
} else if (typeof v === "boolean") {
|
|
7596
|
+
attrs2.push(boolAttr(`agent_inspect.preview.${k}`, v));
|
|
7463
7597
|
}
|
|
7464
7598
|
}
|
|
7465
7599
|
}
|
|
7466
|
-
let statusCode =
|
|
7600
|
+
let statusCode = OTLP_STATUS_CODE_UNSET;
|
|
7467
7601
|
let statusMessage;
|
|
7468
7602
|
if (ev.status === "error") {
|
|
7469
|
-
statusCode =
|
|
7603
|
+
statusCode = OTLP_STATUS_CODE_ERROR;
|
|
7470
7604
|
statusMessage = meta && typeof meta.error === "object" && meta.error !== null ? String(meta.error.message ?? "error").slice(0, maxLen) : "error";
|
|
7471
7605
|
} else if (ev.status === "ok") {
|
|
7472
|
-
statusCode =
|
|
7606
|
+
statusCode = OTLP_STATUS_CODE_OK;
|
|
7473
7607
|
}
|
|
7474
7608
|
const spanJson = {
|
|
7475
7609
|
traceId,
|
|
7476
7610
|
spanId,
|
|
7477
7611
|
name: ev.name,
|
|
7478
|
-
kind:
|
|
7612
|
+
kind: OTLP_SPAN_KIND_INTERNAL,
|
|
7479
7613
|
startTimeUnixNano: startNs,
|
|
7480
7614
|
attributes: attrs2,
|
|
7481
7615
|
status: {
|