agent-inspect 6.31.21 → 6.31.23
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/CHANGELOG.md +12 -0
- package/README.md +1 -1
- package/package.json +1 -1
- package/packages/cli/dist/{chunk-N5JN26MW.mjs → chunk-P27XTK5U.mjs} +347 -36
- package/packages/cli/dist/chunk-P27XTK5U.mjs.map +1 -0
- package/packages/cli/dist/index.cjs +434 -63
- package/packages/cli/dist/index.cjs.map +1 -1
- package/packages/cli/dist/index.mjs +81 -33
- package/packages/cli/dist/index.mjs.map +1 -1
- package/packages/cli/dist/{src-VMGRSTG7.mjs → src-EWZYLDST.mjs} +3 -3
- package/packages/cli/dist/{src-VMGRSTG7.mjs.map → src-EWZYLDST.mjs.map} +1 -1
- package/packages/core/dist/advanced.cjs +280 -10
- package/packages/core/dist/advanced.cjs.map +1 -1
- package/packages/core/dist/advanced.mjs +6 -5
- package/packages/core/dist/advanced.mjs.map +1 -1
- package/packages/core/dist/checks.cjs +185 -27
- package/packages/core/dist/checks.cjs.map +1 -1
- package/packages/core/dist/checks.mjs +2 -1
- package/packages/core/dist/{chunk-JE3TUFAQ.mjs → chunk-77PUPLPG.mjs} +14 -8
- package/packages/core/dist/chunk-77PUPLPG.mjs.map +1 -0
- package/packages/core/dist/chunk-AN5MOADW.mjs +204 -0
- package/packages/core/dist/chunk-AN5MOADW.mjs.map +1 -0
- package/packages/core/dist/{chunk-4CDX5GDS.mjs → chunk-IMCM42W6.mjs} +110 -99
- package/packages/core/dist/chunk-IMCM42W6.mjs.map +1 -0
- package/packages/core/dist/{chunk-YU6XT5A2.mjs → chunk-J2ST4VCX.mjs} +45 -3
- package/packages/core/dist/chunk-J2ST4VCX.mjs.map +1 -0
- package/packages/core/dist/{chunk-EIP5CNEL.mjs → chunk-JJSL346L.mjs} +58 -3
- package/packages/core/dist/chunk-JJSL346L.mjs.map +1 -0
- package/packages/core/dist/exporters.cjs +91 -29
- package/packages/core/dist/exporters.cjs.map +1 -1
- package/packages/core/dist/exporters.mjs +78 -29
- package/packages/core/dist/exporters.mjs.map +1 -1
- package/packages/core/dist/logs.cjs +206 -1
- package/packages/core/dist/logs.cjs.map +1 -1
- package/packages/core/dist/logs.mjs +3 -2
- package/packages/core/dist/logs.mjs.map +1 -1
- package/packages/core/dist/persisted.cjs +226 -8
- package/packages/core/dist/persisted.cjs.map +1 -1
- package/packages/core/dist/persisted.mjs +9 -5
- package/packages/core/dist/persisted.mjs.map +1 -1
- package/packages/core/dist/readers.cjs +276 -6
- package/packages/core/dist/readers.cjs.map +1 -1
- package/packages/core/dist/readers.mjs +4 -3
- package/packages/cli/dist/chunk-N5JN26MW.mjs.map +0 -1
- package/packages/core/dist/chunk-4CDX5GDS.mjs.map +0 -1
- package/packages/core/dist/chunk-EIP5CNEL.mjs.map +0 -1
- package/packages/core/dist/chunk-JE3TUFAQ.mjs.map +0 -1
- package/packages/core/dist/chunk-YU6XT5A2.mjs.map +0 -1
|
@@ -1217,6 +1217,20 @@ function exportOpenInference(tree, options) {
|
|
|
1217
1217
|
warnings
|
|
1218
1218
|
};
|
|
1219
1219
|
}
|
|
1220
|
+
|
|
1221
|
+
// packages/core/src/persisted/delivery-identity.ts
|
|
1222
|
+
var DELIVERY_CONFLICT_ATTR = "agent_inspect.delivery_conflict";
|
|
1223
|
+
var DELIVERY_EVENT_BASE_ATTR = "agent_inspect.delivery_event_base";
|
|
1224
|
+
var IDENTITY_CONFLICT_ATTR = {
|
|
1225
|
+
operationId: "agent_inspect.identity_conflict.operation_id",
|
|
1226
|
+
attemptId: "agent_inspect.identity_conflict.attempt_id",
|
|
1227
|
+
retryOf: "agent_inspect.identity_conflict.retry_of",
|
|
1228
|
+
attemptNumber: "agent_inspect.identity_conflict.attempt_number",
|
|
1229
|
+
/** Comma-separated field names when a conflict survives lossy bounding. */
|
|
1230
|
+
fields: "agent_inspect.identity_conflict.fields"
|
|
1231
|
+
};
|
|
1232
|
+
|
|
1233
|
+
// packages/core/src/exporters/otlp-json-exporter.ts
|
|
1220
1234
|
var OTLP_STATUS_CODE_UNSET = 0;
|
|
1221
1235
|
var OTLP_STATUS_CODE_OK = 1;
|
|
1222
1236
|
var OTLP_STATUS_CODE_ERROR = 2;
|
|
@@ -1266,43 +1280,85 @@ var STRUCTURAL_IDENTITY_KEYS = [
|
|
|
1266
1280
|
"attemptNumber",
|
|
1267
1281
|
"attempt"
|
|
1268
1282
|
];
|
|
1269
|
-
function
|
|
1283
|
+
function nestedBag(bag) {
|
|
1270
1284
|
if (!bag || typeof bag !== "object") return void 0;
|
|
1271
|
-
const
|
|
1272
|
-
if (typeof
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
if (
|
|
1277
|
-
|
|
1285
|
+
const nested = bag.metadata;
|
|
1286
|
+
if (!nested || typeof nested !== "object" || Array.isArray(nested)) return void 0;
|
|
1287
|
+
return nested;
|
|
1288
|
+
}
|
|
1289
|
+
function pickBoundedIdentityString(bag, key, maxLen) {
|
|
1290
|
+
if (!bag || typeof bag !== "object") return {};
|
|
1291
|
+
const directRaw = bag[key];
|
|
1292
|
+
const nestedRaw = nestedBag(bag)?.[key];
|
|
1293
|
+
const directFull = typeof directRaw === "string" && directRaw.trim() !== "" ? directRaw.trim() : void 0;
|
|
1294
|
+
const nestedFull = typeof nestedRaw === "string" && nestedRaw.trim() !== "" ? nestedRaw.trim() : void 0;
|
|
1295
|
+
const direct = directFull !== void 0 ? directFull.slice(0, maxLen) : void 0;
|
|
1296
|
+
const nested = nestedFull !== void 0 ? nestedFull.slice(0, maxLen) : void 0;
|
|
1297
|
+
if (directFull !== void 0 && nestedFull !== void 0 && directFull !== nestedFull) {
|
|
1298
|
+
return {
|
|
1299
|
+
value: direct,
|
|
1300
|
+
conflictAlternate: nested,
|
|
1301
|
+
truncatedCollision: direct === nested
|
|
1302
|
+
};
|
|
1278
1303
|
}
|
|
1279
|
-
|
|
1304
|
+
if (direct !== void 0) return { value: direct };
|
|
1305
|
+
if (nested !== void 0) return { value: nested };
|
|
1306
|
+
return {};
|
|
1280
1307
|
}
|
|
1281
1308
|
function pickBoundedIdentityNumber(bag, key) {
|
|
1282
|
-
if (!bag || typeof bag !== "object") return
|
|
1283
|
-
const
|
|
1284
|
-
|
|
1285
|
-
const
|
|
1286
|
-
|
|
1287
|
-
|
|
1309
|
+
if (!bag || typeof bag !== "object") return {};
|
|
1310
|
+
const directRaw = bag[key];
|
|
1311
|
+
const nestedRaw = nestedBag(bag)?.[key];
|
|
1312
|
+
const direct = typeof directRaw === "number" && Number.isFinite(directRaw) ? directRaw : void 0;
|
|
1313
|
+
const nested = typeof nestedRaw === "number" && Number.isFinite(nestedRaw) ? nestedRaw : void 0;
|
|
1314
|
+
if (direct !== void 0 && nested !== void 0 && direct !== nested) {
|
|
1315
|
+
return { value: direct, conflictAlternate: nested };
|
|
1316
|
+
}
|
|
1317
|
+
if (direct !== void 0) return { value: direct };
|
|
1318
|
+
if (nested !== void 0) return { value: nested };
|
|
1319
|
+
return {};
|
|
1288
1320
|
}
|
|
1289
1321
|
function appendStructuralIdentityAttrs(attrs, meta, maxLen) {
|
|
1290
|
-
const
|
|
1291
|
-
|
|
1292
|
-
|
|
1322
|
+
const conflicts = [];
|
|
1323
|
+
const emitString = (key, otlpKey, conflictKey) => {
|
|
1324
|
+
const picked = pickBoundedIdentityString(meta, key, maxLen);
|
|
1325
|
+
if (picked.value !== void 0) {
|
|
1326
|
+
attrs.push(stringAttr(otlpKey, picked.value));
|
|
1327
|
+
}
|
|
1328
|
+
if (picked.conflictAlternate !== void 0 || picked.truncatedCollision) {
|
|
1329
|
+
if (picked.conflictAlternate !== void 0) {
|
|
1330
|
+
attrs.push(stringAttr(conflictKey, picked.conflictAlternate));
|
|
1331
|
+
}
|
|
1332
|
+
conflicts.push(key);
|
|
1333
|
+
}
|
|
1334
|
+
};
|
|
1335
|
+
emitString("operationId", "agent_inspect.operation_id", IDENTITY_CONFLICT_ATTR.operationId);
|
|
1336
|
+
emitString("attemptId", "agent_inspect.attempt_id", IDENTITY_CONFLICT_ATTR.attemptId);
|
|
1337
|
+
emitString("retryOf", "agent_inspect.retry_of", IDENTITY_CONFLICT_ATTR.retryOf);
|
|
1338
|
+
const attemptNumberPrimary = pickBoundedIdentityNumber(meta, "attemptNumber");
|
|
1339
|
+
const attemptNumber = attemptNumberPrimary.value !== void 0 || attemptNumberPrimary.conflictAlternate !== void 0 ? attemptNumberPrimary : pickBoundedIdentityNumber(meta, "attempt");
|
|
1340
|
+
if (attemptNumber.value !== void 0) {
|
|
1341
|
+
attrs.push(intAttr("agent_inspect.attempt_number", attemptNumber.value));
|
|
1342
|
+
}
|
|
1343
|
+
if (attemptNumber.conflictAlternate !== void 0) {
|
|
1344
|
+
attrs.push(
|
|
1345
|
+
intAttr(IDENTITY_CONFLICT_ATTR.attemptNumber, attemptNumber.conflictAlternate)
|
|
1346
|
+
);
|
|
1347
|
+
conflicts.push("attemptNumber");
|
|
1293
1348
|
}
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1349
|
+
if (conflicts.length > 0) {
|
|
1350
|
+
attrs.push(
|
|
1351
|
+
stringAttr(IDENTITY_CONFLICT_ATTR.fields, conflicts.join(",").slice(0, maxLen))
|
|
1352
|
+
);
|
|
1297
1353
|
}
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
attrs.push(stringAttr("agent_inspect.retry_of", retryOf));
|
|
1354
|
+
if (meta?.[DELIVERY_CONFLICT_ATTR] === true) {
|
|
1355
|
+
attrs.push(boolAttr(DELIVERY_CONFLICT_ATTR, true));
|
|
1301
1356
|
}
|
|
1302
|
-
const
|
|
1303
|
-
if (
|
|
1304
|
-
attrs.push(
|
|
1357
|
+
const deliveryBase = meta?.[DELIVERY_EVENT_BASE_ATTR];
|
|
1358
|
+
if (typeof deliveryBase === "string" && deliveryBase.trim() !== "") {
|
|
1359
|
+
attrs.push(stringAttr(DELIVERY_EVENT_BASE_ATTR, deliveryBase.trim().slice(0, maxLen)));
|
|
1305
1360
|
}
|
|
1361
|
+
return conflicts;
|
|
1306
1362
|
}
|
|
1307
1363
|
function resolveSpanTimes(ev) {
|
|
1308
1364
|
const startedAtMs = typeof ev.attributes?.startedAtMs === "number" && Number.isFinite(ev.attributes.startedAtMs) ? ev.attributes.startedAtMs : void 0;
|
|
@@ -1325,7 +1381,8 @@ function exportOtlpJson(tree, options) {
|
|
|
1325
1381
|
"OTLP JSON export uses OTel GenAI-aligned attributes where applicable; experimental until verified against specific collectors.",
|
|
1326
1382
|
"Not OTLP gRPC/protobuf \u2014 JSON mapping only. Generated locally; no network upload.",
|
|
1327
1383
|
"Status and span kind use OTLP numeric enums (StatusCode 0/1/2, SpanKind INTERNAL=1).",
|
|
1328
|
-
"When present on source events, operationId/attemptId/retryOf/attemptNumber are emitted as bounded agent_inspect.* identity attributes (not a broad attribute dump)."
|
|
1384
|
+
"When present on source events, operationId/attemptId/retryOf/attemptNumber are emitted as bounded agent_inspect.* identity attributes (not a broad attribute dump).",
|
|
1385
|
+
"When direct and nested identity disagree, export prefers direct for non-strict consumers and emits agent_inspect.identity_conflict.* for the nested alternate; this does not certify conflicting identity."
|
|
1329
1386
|
];
|
|
1330
1387
|
const traceId = hexFrom2(`trace:${tree.runId}`, 16);
|
|
1331
1388
|
const includeAttributes = options?.includeAttributes ?? false;
|
|
@@ -1373,11 +1430,16 @@ function exportOtlpJson(tree, options) {
|
|
|
1373
1430
|
if (typeof inp === "number") attrs.push(intAttr("gen_ai.usage.input_tokens", inp));
|
|
1374
1431
|
if (typeof outp === "number") attrs.push(intAttr("gen_ai.usage.output_tokens", outp));
|
|
1375
1432
|
}
|
|
1376
|
-
appendStructuralIdentityAttrs(
|
|
1433
|
+
const identityConflicts = appendStructuralIdentityAttrs(
|
|
1377
1434
|
attrs,
|
|
1378
1435
|
meta && typeof meta === "object" ? meta : void 0,
|
|
1379
1436
|
maxLen
|
|
1380
1437
|
);
|
|
1438
|
+
if (identityConflicts.length > 0) {
|
|
1439
|
+
warnings.push(
|
|
1440
|
+
`Identity representation conflict on event ${ev.eventId}: ${identityConflicts.join(", ")} (direct preferred; nested retained on agent_inspect.identity_conflict.*).`
|
|
1441
|
+
);
|
|
1442
|
+
}
|
|
1381
1443
|
if (includeAttributes && meta && typeof meta === "object") {
|
|
1382
1444
|
const skipKeys = /* @__PURE__ */ new Set([
|
|
1383
1445
|
"tokens",
|