agent-inspect 6.31.21 → 6.31.22
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 +6 -0
- package/README.md +1 -1
- package/package.json +1 -1
- package/packages/cli/dist/{chunk-N5JN26MW.mjs → chunk-EMWA5EKU.mjs} +300 -31
- package/packages/cli/dist/chunk-EMWA5EKU.mjs.map +1 -0
- package/packages/cli/dist/index.cjs +379 -56
- package/packages/cli/dist/index.cjs.map +1 -1
- package/packages/cli/dist/index.mjs +75 -31
- package/packages/cli/dist/index.mjs.map +1 -1
- package/packages/cli/dist/{src-VMGRSTG7.mjs → src-VZHGOLTO.mjs} +3 -3
- package/packages/cli/dist/{src-VMGRSTG7.mjs.map → src-VZHGOLTO.mjs.map} +1 -1
- package/packages/core/dist/advanced.cjs +247 -5
- 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 +160 -27
- package/packages/core/dist/checks.cjs.map +1 -1
- package/packages/core/dist/checks.mjs +2 -1
- package/packages/core/dist/chunk-GCZUWY47.mjs +182 -0
- package/packages/core/dist/chunk-GCZUWY47.mjs.map +1 -0
- package/packages/core/dist/{chunk-JE3TUFAQ.mjs → chunk-RBXD7BNX.mjs} +3 -3
- package/packages/core/dist/{chunk-JE3TUFAQ.mjs.map → chunk-RBXD7BNX.mjs.map} +1 -1
- package/packages/core/dist/{chunk-YU6XT5A2.mjs → chunk-S4NU55LU.mjs} +45 -3
- package/packages/core/dist/chunk-S4NU55LU.mjs.map +1 -0
- package/packages/core/dist/{chunk-EIP5CNEL.mjs → chunk-UPGBMRL4.mjs} +49 -3
- package/packages/core/dist/chunk-UPGBMRL4.mjs.map +1 -0
- package/packages/core/dist/{chunk-4CDX5GDS.mjs → chunk-ZOF6ON65.mjs} +104 -99
- package/packages/core/dist/chunk-ZOF6ON65.mjs.map +1 -0
- package/packages/core/dist/exporters.cjs +82 -27
- package/packages/core/dist/exporters.cjs.map +1 -1
- package/packages/core/dist/exporters.mjs +72 -27
- package/packages/core/dist/exporters.mjs.map +1 -1
- package/packages/core/dist/logs.cjs +197 -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 +197 -1
- package/packages/core/dist/persisted.cjs.map +1 -1
- package/packages/core/dist/persisted.mjs +4 -3
- package/packages/core/dist/persisted.mjs.map +1 -1
- package/packages/core/dist/readers.cjs +243 -1
- 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-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 } from './chunk-GCZUWY47.mjs';
|
|
7
8
|
import './chunk-7DHSWDKB.mjs';
|
|
8
9
|
import './chunk-EE5Z2GQ3.mjs';
|
|
9
10
|
import './chunk-7TGZLWEE.mjs';
|
|
@@ -860,43 +861,81 @@ 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
|
-
|
|
872
|
-
|
|
873
|
-
|
|
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 direct = typeof directRaw === "string" && directRaw.trim() !== "" ? directRaw.trim().slice(0, maxLen) : void 0;
|
|
875
|
+
const nested = typeof nestedRaw === "string" && nestedRaw.trim() !== "" ? nestedRaw.trim().slice(0, maxLen) : void 0;
|
|
876
|
+
if (direct !== void 0 && nested !== void 0 && direct !== nested) {
|
|
877
|
+
return { value: direct, conflictAlternate: nested };
|
|
878
|
+
}
|
|
879
|
+
if (direct !== void 0) return { value: direct };
|
|
880
|
+
if (nested !== void 0) return { value: nested };
|
|
881
|
+
return {};
|
|
874
882
|
}
|
|
875
883
|
function pickBoundedIdentityNumber(bag, key) {
|
|
876
|
-
if (!bag || typeof bag !== "object") return
|
|
877
|
-
const
|
|
878
|
-
|
|
879
|
-
const
|
|
880
|
-
|
|
881
|
-
|
|
884
|
+
if (!bag || typeof bag !== "object") return {};
|
|
885
|
+
const directRaw = bag[key];
|
|
886
|
+
const nestedRaw = nestedBag(bag)?.[key];
|
|
887
|
+
const direct = typeof directRaw === "number" && Number.isFinite(directRaw) ? directRaw : void 0;
|
|
888
|
+
const nested = typeof nestedRaw === "number" && Number.isFinite(nestedRaw) ? nestedRaw : void 0;
|
|
889
|
+
if (direct !== void 0 && nested !== void 0 && direct !== nested) {
|
|
890
|
+
return { value: direct, conflictAlternate: nested };
|
|
891
|
+
}
|
|
892
|
+
if (direct !== void 0) return { value: direct };
|
|
893
|
+
if (nested !== void 0) return { value: nested };
|
|
894
|
+
return {};
|
|
882
895
|
}
|
|
883
896
|
function appendStructuralIdentityAttrs(attrs, meta, maxLen) {
|
|
897
|
+
const conflicts = [];
|
|
884
898
|
const operationId = pickBoundedIdentityString(meta, "operationId", maxLen);
|
|
885
|
-
if (operationId !== void 0) {
|
|
886
|
-
attrs.push(stringAttr("agent_inspect.operation_id", operationId));
|
|
899
|
+
if (operationId.value !== void 0) {
|
|
900
|
+
attrs.push(stringAttr("agent_inspect.operation_id", operationId.value));
|
|
901
|
+
}
|
|
902
|
+
if (operationId.conflictAlternate !== void 0) {
|
|
903
|
+
attrs.push(
|
|
904
|
+
stringAttr(IDENTITY_CONFLICT_ATTR.operationId, operationId.conflictAlternate)
|
|
905
|
+
);
|
|
906
|
+
conflicts.push("operationId");
|
|
887
907
|
}
|
|
888
908
|
const attemptId = pickBoundedIdentityString(meta, "attemptId", maxLen);
|
|
889
|
-
if (attemptId !== void 0) {
|
|
890
|
-
attrs.push(stringAttr("agent_inspect.attempt_id", attemptId));
|
|
909
|
+
if (attemptId.value !== void 0) {
|
|
910
|
+
attrs.push(stringAttr("agent_inspect.attempt_id", attemptId.value));
|
|
911
|
+
}
|
|
912
|
+
if (attemptId.conflictAlternate !== void 0) {
|
|
913
|
+
attrs.push(stringAttr(IDENTITY_CONFLICT_ATTR.attemptId, attemptId.conflictAlternate));
|
|
914
|
+
conflicts.push("attemptId");
|
|
891
915
|
}
|
|
892
916
|
const retryOf = pickBoundedIdentityString(meta, "retryOf", maxLen);
|
|
893
|
-
if (retryOf !== void 0) {
|
|
894
|
-
attrs.push(stringAttr("agent_inspect.retry_of", retryOf));
|
|
917
|
+
if (retryOf.value !== void 0) {
|
|
918
|
+
attrs.push(stringAttr("agent_inspect.retry_of", retryOf.value));
|
|
919
|
+
}
|
|
920
|
+
if (retryOf.conflictAlternate !== void 0) {
|
|
921
|
+
attrs.push(stringAttr(IDENTITY_CONFLICT_ATTR.retryOf, retryOf.conflictAlternate));
|
|
922
|
+
conflicts.push("retryOf");
|
|
895
923
|
}
|
|
896
|
-
const
|
|
897
|
-
|
|
898
|
-
|
|
924
|
+
const attemptNumberPrimary = pickBoundedIdentityNumber(meta, "attemptNumber");
|
|
925
|
+
const attemptNumber = attemptNumberPrimary.value !== void 0 || attemptNumberPrimary.conflictAlternate !== void 0 ? attemptNumberPrimary : pickBoundedIdentityNumber(meta, "attempt");
|
|
926
|
+
if (attemptNumber.value !== void 0) {
|
|
927
|
+
attrs.push(intAttr("agent_inspect.attempt_number", attemptNumber.value));
|
|
928
|
+
}
|
|
929
|
+
if (attemptNumber.conflictAlternate !== void 0) {
|
|
930
|
+
attrs.push(
|
|
931
|
+
intAttr(IDENTITY_CONFLICT_ATTR.attemptNumber, attemptNumber.conflictAlternate)
|
|
932
|
+
);
|
|
933
|
+
conflicts.push("attemptNumber");
|
|
899
934
|
}
|
|
935
|
+
if (meta?.[DELIVERY_CONFLICT_ATTR] === true) {
|
|
936
|
+
attrs.push(boolAttr(DELIVERY_CONFLICT_ATTR, true));
|
|
937
|
+
}
|
|
938
|
+
return conflicts;
|
|
900
939
|
}
|
|
901
940
|
function resolveSpanTimes(ev) {
|
|
902
941
|
const startedAtMs = typeof ev.attributes?.startedAtMs === "number" && Number.isFinite(ev.attributes.startedAtMs) ? ev.attributes.startedAtMs : void 0;
|
|
@@ -919,7 +958,8 @@ function exportOtlpJson(tree, options) {
|
|
|
919
958
|
"OTLP JSON export uses OTel GenAI-aligned attributes where applicable; experimental until verified against specific collectors.",
|
|
920
959
|
"Not OTLP gRPC/protobuf \u2014 JSON mapping only. Generated locally; no network upload.",
|
|
921
960
|
"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)."
|
|
961
|
+
"When present on source events, operationId/attemptId/retryOf/attemptNumber are emitted as bounded agent_inspect.* identity attributes (not a broad attribute dump).",
|
|
962
|
+
"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
963
|
];
|
|
924
964
|
const traceId = hexFrom2(`trace:${tree.runId}`, 16);
|
|
925
965
|
const includeAttributes = options?.includeAttributes ?? false;
|
|
@@ -967,11 +1007,16 @@ function exportOtlpJson(tree, options) {
|
|
|
967
1007
|
if (typeof inp === "number") attrs.push(intAttr("gen_ai.usage.input_tokens", inp));
|
|
968
1008
|
if (typeof outp === "number") attrs.push(intAttr("gen_ai.usage.output_tokens", outp));
|
|
969
1009
|
}
|
|
970
|
-
appendStructuralIdentityAttrs(
|
|
1010
|
+
const identityConflicts = appendStructuralIdentityAttrs(
|
|
971
1011
|
attrs,
|
|
972
1012
|
meta && typeof meta === "object" ? meta : void 0,
|
|
973
1013
|
maxLen
|
|
974
1014
|
);
|
|
1015
|
+
if (identityConflicts.length > 0) {
|
|
1016
|
+
warnings.push(
|
|
1017
|
+
`Identity representation conflict on event ${ev.eventId}: ${identityConflicts.join(", ")} (direct preferred; nested retained on agent_inspect.identity_conflict.*).`
|
|
1018
|
+
);
|
|
1019
|
+
}
|
|
975
1020
|
if (includeAttributes && meta && typeof meta === "object") {
|
|
976
1021
|
const skipKeys = /* @__PURE__ */ new Set([
|
|
977
1022
|
"tokens",
|