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
|
@@ -4,6 +4,7 @@ import { escapeHtml, flattenTree, safeString, compactAttributes, stableJson, esc
|
|
|
4
4
|
export { compactAttributes, escapeHtml, escapeMarkdown, flattenTree, safeString, stableJson, summarizeTree } from './chunk-CAWPF22J.mjs';
|
|
5
5
|
import { resolveRedactionProfile, applyProfileMetadataCaps, truncateStringForProfile, stringContainsHighConfidenceCredential } from './chunk-EOXUEQB6.mjs';
|
|
6
6
|
import { Redactor, DEFAULT_REDACT_KEYS, isCredentialSensitiveKey } from './chunk-VLVCLAPB.mjs';
|
|
7
|
+
import { IDENTITY_CONFLICT_ATTR, DELIVERY_CONFLICT_ATTR, DELIVERY_EVENT_BASE_ATTR } from './chunk-AN5MOADW.mjs';
|
|
7
8
|
import './chunk-7DHSWDKB.mjs';
|
|
8
9
|
import './chunk-EE5Z2GQ3.mjs';
|
|
9
10
|
import './chunk-7TGZLWEE.mjs';
|
|
@@ -860,43 +861,85 @@ var STRUCTURAL_IDENTITY_KEYS = [
|
|
|
860
861
|
"attemptNumber",
|
|
861
862
|
"attempt"
|
|
862
863
|
];
|
|
863
|
-
function
|
|
864
|
+
function nestedBag(bag) {
|
|
864
865
|
if (!bag || typeof bag !== "object") return void 0;
|
|
865
|
-
const
|
|
866
|
-
if (typeof
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
if (
|
|
871
|
-
|
|
866
|
+
const nested = bag.metadata;
|
|
867
|
+
if (!nested || typeof nested !== "object" || Array.isArray(nested)) return void 0;
|
|
868
|
+
return nested;
|
|
869
|
+
}
|
|
870
|
+
function pickBoundedIdentityString(bag, key, maxLen) {
|
|
871
|
+
if (!bag || typeof bag !== "object") return {};
|
|
872
|
+
const directRaw = bag[key];
|
|
873
|
+
const nestedRaw = nestedBag(bag)?.[key];
|
|
874
|
+
const directFull = typeof directRaw === "string" && directRaw.trim() !== "" ? directRaw.trim() : void 0;
|
|
875
|
+
const nestedFull = typeof nestedRaw === "string" && nestedRaw.trim() !== "" ? nestedRaw.trim() : void 0;
|
|
876
|
+
const direct = directFull !== void 0 ? directFull.slice(0, maxLen) : void 0;
|
|
877
|
+
const nested = nestedFull !== void 0 ? nestedFull.slice(0, maxLen) : void 0;
|
|
878
|
+
if (directFull !== void 0 && nestedFull !== void 0 && directFull !== nestedFull) {
|
|
879
|
+
return {
|
|
880
|
+
value: direct,
|
|
881
|
+
conflictAlternate: nested,
|
|
882
|
+
truncatedCollision: direct === nested
|
|
883
|
+
};
|
|
872
884
|
}
|
|
873
|
-
|
|
885
|
+
if (direct !== void 0) return { value: direct };
|
|
886
|
+
if (nested !== void 0) return { value: nested };
|
|
887
|
+
return {};
|
|
874
888
|
}
|
|
875
889
|
function pickBoundedIdentityNumber(bag, key) {
|
|
876
|
-
if (!bag || typeof bag !== "object") return
|
|
877
|
-
const
|
|
878
|
-
|
|
879
|
-
const
|
|
880
|
-
|
|
881
|
-
|
|
890
|
+
if (!bag || typeof bag !== "object") return {};
|
|
891
|
+
const directRaw = bag[key];
|
|
892
|
+
const nestedRaw = nestedBag(bag)?.[key];
|
|
893
|
+
const direct = typeof directRaw === "number" && Number.isFinite(directRaw) ? directRaw : void 0;
|
|
894
|
+
const nested = typeof nestedRaw === "number" && Number.isFinite(nestedRaw) ? nestedRaw : void 0;
|
|
895
|
+
if (direct !== void 0 && nested !== void 0 && direct !== nested) {
|
|
896
|
+
return { value: direct, conflictAlternate: nested };
|
|
897
|
+
}
|
|
898
|
+
if (direct !== void 0) return { value: direct };
|
|
899
|
+
if (nested !== void 0) return { value: nested };
|
|
900
|
+
return {};
|
|
882
901
|
}
|
|
883
902
|
function appendStructuralIdentityAttrs(attrs, meta, maxLen) {
|
|
884
|
-
const
|
|
885
|
-
|
|
886
|
-
|
|
903
|
+
const conflicts = [];
|
|
904
|
+
const emitString = (key, otlpKey, conflictKey) => {
|
|
905
|
+
const picked = pickBoundedIdentityString(meta, key, maxLen);
|
|
906
|
+
if (picked.value !== void 0) {
|
|
907
|
+
attrs.push(stringAttr(otlpKey, picked.value));
|
|
908
|
+
}
|
|
909
|
+
if (picked.conflictAlternate !== void 0 || picked.truncatedCollision) {
|
|
910
|
+
if (picked.conflictAlternate !== void 0) {
|
|
911
|
+
attrs.push(stringAttr(conflictKey, picked.conflictAlternate));
|
|
912
|
+
}
|
|
913
|
+
conflicts.push(key);
|
|
914
|
+
}
|
|
915
|
+
};
|
|
916
|
+
emitString("operationId", "agent_inspect.operation_id", IDENTITY_CONFLICT_ATTR.operationId);
|
|
917
|
+
emitString("attemptId", "agent_inspect.attempt_id", IDENTITY_CONFLICT_ATTR.attemptId);
|
|
918
|
+
emitString("retryOf", "agent_inspect.retry_of", IDENTITY_CONFLICT_ATTR.retryOf);
|
|
919
|
+
const attemptNumberPrimary = pickBoundedIdentityNumber(meta, "attemptNumber");
|
|
920
|
+
const attemptNumber = attemptNumberPrimary.value !== void 0 || attemptNumberPrimary.conflictAlternate !== void 0 ? attemptNumberPrimary : pickBoundedIdentityNumber(meta, "attempt");
|
|
921
|
+
if (attemptNumber.value !== void 0) {
|
|
922
|
+
attrs.push(intAttr("agent_inspect.attempt_number", attemptNumber.value));
|
|
923
|
+
}
|
|
924
|
+
if (attemptNumber.conflictAlternate !== void 0) {
|
|
925
|
+
attrs.push(
|
|
926
|
+
intAttr(IDENTITY_CONFLICT_ATTR.attemptNumber, attemptNumber.conflictAlternate)
|
|
927
|
+
);
|
|
928
|
+
conflicts.push("attemptNumber");
|
|
887
929
|
}
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
930
|
+
if (conflicts.length > 0) {
|
|
931
|
+
attrs.push(
|
|
932
|
+
stringAttr(IDENTITY_CONFLICT_ATTR.fields, conflicts.join(",").slice(0, maxLen))
|
|
933
|
+
);
|
|
891
934
|
}
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
attrs.push(stringAttr("agent_inspect.retry_of", retryOf));
|
|
935
|
+
if (meta?.[DELIVERY_CONFLICT_ATTR] === true) {
|
|
936
|
+
attrs.push(boolAttr(DELIVERY_CONFLICT_ATTR, true));
|
|
895
937
|
}
|
|
896
|
-
const
|
|
897
|
-
if (
|
|
898
|
-
attrs.push(
|
|
938
|
+
const deliveryBase = meta?.[DELIVERY_EVENT_BASE_ATTR];
|
|
939
|
+
if (typeof deliveryBase === "string" && deliveryBase.trim() !== "") {
|
|
940
|
+
attrs.push(stringAttr(DELIVERY_EVENT_BASE_ATTR, deliveryBase.trim().slice(0, maxLen)));
|
|
899
941
|
}
|
|
942
|
+
return conflicts;
|
|
900
943
|
}
|
|
901
944
|
function resolveSpanTimes(ev) {
|
|
902
945
|
const startedAtMs = typeof ev.attributes?.startedAtMs === "number" && Number.isFinite(ev.attributes.startedAtMs) ? ev.attributes.startedAtMs : void 0;
|
|
@@ -919,7 +962,8 @@ function exportOtlpJson(tree, options) {
|
|
|
919
962
|
"OTLP JSON export uses OTel GenAI-aligned attributes where applicable; experimental until verified against specific collectors.",
|
|
920
963
|
"Not OTLP gRPC/protobuf \u2014 JSON mapping only. Generated locally; no network upload.",
|
|
921
964
|
"Status and span kind use OTLP numeric enums (StatusCode 0/1/2, SpanKind INTERNAL=1).",
|
|
922
|
-
"When present on source events, operationId/attemptId/retryOf/attemptNumber are emitted as bounded agent_inspect.* identity attributes (not a broad attribute dump)."
|
|
965
|
+
"When present on source events, operationId/attemptId/retryOf/attemptNumber are emitted as bounded agent_inspect.* identity attributes (not a broad attribute dump).",
|
|
966
|
+
"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."
|
|
923
967
|
];
|
|
924
968
|
const traceId = hexFrom2(`trace:${tree.runId}`, 16);
|
|
925
969
|
const includeAttributes = options?.includeAttributes ?? false;
|
|
@@ -967,11 +1011,16 @@ function exportOtlpJson(tree, options) {
|
|
|
967
1011
|
if (typeof inp === "number") attrs.push(intAttr("gen_ai.usage.input_tokens", inp));
|
|
968
1012
|
if (typeof outp === "number") attrs.push(intAttr("gen_ai.usage.output_tokens", outp));
|
|
969
1013
|
}
|
|
970
|
-
appendStructuralIdentityAttrs(
|
|
1014
|
+
const identityConflicts = appendStructuralIdentityAttrs(
|
|
971
1015
|
attrs,
|
|
972
1016
|
meta && typeof meta === "object" ? meta : void 0,
|
|
973
1017
|
maxLen
|
|
974
1018
|
);
|
|
1019
|
+
if (identityConflicts.length > 0) {
|
|
1020
|
+
warnings.push(
|
|
1021
|
+
`Identity representation conflict on event ${ev.eventId}: ${identityConflicts.join(", ")} (direct preferred; nested retained on agent_inspect.identity_conflict.*).`
|
|
1022
|
+
);
|
|
1023
|
+
}
|
|
975
1024
|
if (includeAttributes && meta && typeof meta === "object") {
|
|
976
1025
|
const skipKeys = /* @__PURE__ */ new Set([
|
|
977
1026
|
"tokens",
|