@senpi/runtime 3.0.6-dev.runtime-phase-2.20260630134307 → 3.0.6-dev.runtime-phase-2.20260630134410
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/actions/close-position/close-position.action.d.ts +1 -1
- package/dist/actions/close-position/close-position.action.d.ts.map +1 -1
- package/dist/actions/close-position/close-position.action.js +15 -14
- package/dist/actions/close-position/close-position.action.js.map +1 -1
- package/dist/actions/event-derivation.d.ts +60 -0
- package/dist/actions/event-derivation.d.ts.map +1 -0
- package/dist/actions/event-derivation.js +179 -0
- package/dist/actions/event-derivation.js.map +1 -0
- package/dist/actions/llm-decision/anthropic-llm-decision.d.ts +5 -9
- package/dist/actions/llm-decision/anthropic-llm-decision.d.ts.map +1 -1
- package/dist/actions/llm-decision/anthropic-llm-decision.js +6 -87
- package/dist/actions/llm-decision/anthropic-llm-decision.js.map +1 -1
- package/dist/actions/llm-decision/factory.d.ts +0 -6
- package/dist/actions/llm-decision/factory.d.ts.map +1 -1
- package/dist/actions/llm-decision/factory.js +0 -2
- package/dist/actions/llm-decision/factory.js.map +1 -1
- package/dist/actions/llm-decision/openclaw-llm-decision.d.ts.map +1 -1
- package/dist/actions/llm-decision/openclaw-llm-decision.js +21 -2
- package/dist/actions/llm-decision/openclaw-llm-decision.js.map +1 -1
- package/dist/actions/open-position/open-position.action.d.ts +1 -1
- package/dist/actions/open-position/open-position.action.d.ts.map +1 -1
- package/dist/actions/open-position/open-position.action.js +28 -21
- package/dist/actions/open-position/open-position.action.js.map +1 -1
- package/dist/actions/position-tracker/position-tracker.action.d.ts.map +1 -1
- package/dist/actions/position-tracker/position-tracker.action.js +2 -4
- package/dist/actions/position-tracker/position-tracker.action.js.map +1 -1
- package/dist/actions/tracking-helpers.d.ts +41 -3
- package/dist/actions/tracking-helpers.d.ts.map +1 -1
- package/dist/actions/tracking-helpers.js +100 -11
- package/dist/actions/tracking-helpers.js.map +1 -1
- package/dist/dsl/plugin/index.d.ts +8 -0
- package/dist/dsl/plugin/index.d.ts.map +1 -1
- package/dist/dsl/plugin/index.js +36 -2
- package/dist/dsl/plugin/index.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +28 -13
- package/dist/index.js.map +1 -1
- package/dist/recording/otel/attributes.d.ts +2 -0
- package/dist/recording/otel/attributes.d.ts.map +1 -1
- package/dist/recording/otel/attributes.js +1 -1
- package/dist/recording/otel/attributes.js.map +1 -1
- package/dist/recording/otel/mappers.d.ts.map +1 -1
- package/dist/recording/otel/mappers.js +1 -0
- package/dist/recording/otel/mappers.js.map +1 -1
- package/dist/recording/records.d.ts +7 -1
- package/dist/recording/records.d.ts.map +1 -1
- package/dist/recording/wiring/emitter-factory.d.ts +0 -5
- package/dist/recording/wiring/emitter-factory.d.ts.map +1 -1
- package/dist/recording/wiring/emitter-factory.js +0 -18
- package/dist/recording/wiring/emitter-factory.js.map +1 -1
- package/dist/recording/wiring/index.d.ts +1 -1
- package/dist/recording/wiring/index.d.ts.map +1 -1
- package/dist/recording/wiring/index.js +1 -1
- package/dist/recording/wiring/index.js.map +1 -1
- package/dist/recording/wiring/record-builders.d.ts.map +1 -1
- package/dist/recording/wiring/record-builders.js +5 -2
- package/dist/recording/wiring/record-builders.js.map +1 -1
- package/dist/runtime/auto-update/coordinator.js +2 -2
- package/dist/runtime/auto-update/coordinator.js.map +1 -1
- package/dist/runtime/create-actions.d.ts.map +1 -1
- package/dist/runtime/create-actions.js +0 -10
- package/dist/runtime/create-actions.js.map +1 -1
- package/dist/runtime/domain-events.d.ts +43 -0
- package/dist/runtime/domain-events.d.ts.map +1 -0
- package/dist/runtime/domain-events.js +181 -0
- package/dist/runtime/domain-events.js.map +1 -0
- package/dist/runtime/lifecycle-events.d.ts +43 -0
- package/dist/runtime/lifecycle-events.d.ts.map +1 -0
- package/dist/runtime/lifecycle-events.js +139 -0
- package/dist/runtime/lifecycle-events.js.map +1 -0
- package/dist/runtime/notifications.js +2 -2
- package/dist/runtime/notifications.js.map +1 -1
- package/dist/runtime/runtime-schema.d.ts +124 -173
- package/dist/runtime/runtime-schema.d.ts.map +1 -1
- package/dist/runtime/runtime-schema.js +4 -4
- package/dist/runtime/runtime-schema.js.map +1 -1
- package/dist/runtime/runtime.d.ts +1 -0
- package/dist/runtime/runtime.d.ts.map +1 -1
- package/dist/runtime/runtime.js +62 -52
- package/dist/runtime/runtime.js.map +1 -1
- package/dist/runtime/strategy-lifecycle.d.ts.map +1 -1
- package/dist/runtime/strategy-lifecycle.js +13 -1
- package/dist/runtime/strategy-lifecycle.js.map +1 -1
- package/dist/runtime-api/routes/signals.d.ts +1 -1
- package/dist/runtime-api/routes/signals.d.ts.map +1 -1
- package/dist/runtime-api/routes/signals.js +2 -8
- package/dist/runtime-api/routes/signals.js.map +1 -1
- package/dist/senpi/client.d.ts +10 -0
- package/dist/senpi/client.d.ts.map +1 -1
- package/dist/senpi/client.js +71 -49
- package/dist/senpi/client.js.map +1 -1
- package/dist/skills-manager/coordinator.js +3 -3
- package/dist/skills-manager/coordinator.js.map +1 -1
- package/dist/telemetry/metrics.d.ts +47 -0
- package/dist/telemetry/metrics.d.ts.map +1 -0
- package/dist/telemetry/metrics.js +154 -0
- package/dist/telemetry/metrics.js.map +1 -0
- package/dist/telemetry/otel-sdk.d.ts +23 -35
- package/dist/telemetry/otel-sdk.d.ts.map +1 -1
- package/dist/telemetry/otel-sdk.js +83 -54
- package/dist/telemetry/otel-sdk.js.map +1 -1
- package/dist/telemetry/trace-identity.d.ts +2 -1
- package/dist/telemetry/trace-identity.d.ts.map +1 -1
- package/dist/telemetry/trace-identity.js +2 -1
- package/dist/telemetry/trace-identity.js.map +1 -1
- package/dist/telemetry/tracing.d.ts +2 -1
- package/dist/telemetry/tracing.d.ts.map +1 -1
- package/dist/telemetry/tracing.js +1 -1
- package/dist/telemetry/tracing.js.map +1 -1
- package/dist/tracking/context.d.ts +6 -0
- package/dist/tracking/context.d.ts.map +1 -1
- package/dist/tracking/context.js.map +1 -1
- package/dist/tracking/spans/constants.d.ts +4 -11
- package/dist/tracking/spans/constants.d.ts.map +1 -1
- package/dist/tracking/spans/constants.js +4 -23
- package/dist/tracking/spans/constants.js.map +1 -1
- package/dist/tracking/spans/gen-ai.d.ts +70 -0
- package/dist/tracking/spans/gen-ai.d.ts.map +1 -0
- package/dist/tracking/spans/gen-ai.js +330 -0
- package/dist/tracking/spans/gen-ai.js.map +1 -0
- package/dist/tracking/spans/index.d.ts +6 -8
- package/dist/tracking/spans/index.d.ts.map +1 -1
- package/dist/tracking/spans/index.js +6 -11
- package/dist/tracking/spans/index.js.map +1 -1
- package/dist/tracking/spans/redact-pii.d.ts +19 -21
- package/dist/tracking/spans/redact-pii.d.ts.map +1 -1
- package/dist/tracking/spans/redact-pii.js +31 -31
- package/dist/tracking/spans/redact-pii.js.map +1 -1
- package/dist/tracking/spans/span-hooks.d.ts +0 -17
- package/dist/tracking/spans/span-hooks.d.ts.map +1 -1
- package/dist/tracking/spans/span-hooks.js +407 -207
- package/dist/tracking/spans/span-hooks.js.map +1 -1
- package/dist/utils/event-catalog.d.ts +269 -0
- package/dist/utils/event-catalog.d.ts.map +1 -0
- package/dist/utils/event-catalog.js +91 -0
- package/dist/utils/event-catalog.js.map +1 -0
- package/dist/utils/logger.d.ts +58 -5
- package/dist/utils/logger.d.ts.map +1 -1
- package/dist/utils/logger.js +359 -27
- package/dist/utils/logger.js.map +1 -1
- package/package.json +2 -1
- package/dist/tracking/spans/fan-out-span-transport.d.ts +0 -22
- package/dist/tracking/spans/fan-out-span-transport.d.ts.map +0 -1
- package/dist/tracking/spans/fan-out-span-transport.js +0 -49
- package/dist/tracking/spans/fan-out-span-transport.js.map +0 -1
- package/dist/tracking/spans/otel/fit-row-budget.d.ts +0 -22
- package/dist/tracking/spans/otel/fit-row-budget.d.ts.map +0 -1
- package/dist/tracking/spans/otel/fit-row-budget.js +0 -91
- package/dist/tracking/spans/otel/fit-row-budget.js.map +0 -1
- package/dist/tracking/spans/otel/map-span-to-trace-row.d.ts +0 -16
- package/dist/tracking/spans/otel/map-span-to-trace-row.d.ts.map +0 -1
- package/dist/tracking/spans/otel/map-span-to-trace-row.js +0 -227
- package/dist/tracking/spans/otel/map-span-to-trace-row.js.map +0 -1
- package/dist/tracking/spans/otel/recording-span-transport.d.ts +0 -43
- package/dist/tracking/spans/otel/recording-span-transport.d.ts.map +0 -1
- package/dist/tracking/spans/otel/recording-span-transport.js +0 -67
- package/dist/tracking/spans/otel/recording-span-transport.js.map +0 -1
- package/dist/tracking/spans/otel/span-ids.d.ts +0 -22
- package/dist/tracking/spans/otel/span-ids.d.ts.map +0 -1
- package/dist/tracking/spans/otel/span-ids.js +0 -32
- package/dist/tracking/spans/otel/span-ids.js.map +0 -1
- package/dist/tracking/spans/plugin-span-tracker.d.ts +0 -9
- package/dist/tracking/spans/plugin-span-tracker.d.ts.map +0 -1
- package/dist/tracking/spans/plugin-span-tracker.js +0 -115
- package/dist/tracking/spans/plugin-span-tracker.js.map +0 -1
- package/dist/tracking/spans/span-tracker.d.ts +0 -133
- package/dist/tracking/spans/span-tracker.d.ts.map +0 -1
- package/dist/tracking/spans/span-tracker.js +0 -721
- package/dist/tracking/spans/span-tracker.js.map +0 -1
- package/dist/tracking/spans/span-transport.d.ts +0 -71
- package/dist/tracking/spans/span-transport.d.ts.map +0 -1
- package/dist/tracking/spans/span-transport.js +0 -240
- package/dist/tracking/spans/span-transport.js.map +0 -1
- package/dist/tracking/spans/types.d.ts +0 -101
- package/dist/tracking/spans/types.d.ts.map +0 -1
- package/dist/tracking/spans/types.js +0 -6
- package/dist/tracking/spans/types.js.map +0 -1
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Row-aware size fitting for the OTEL ingest leg.
|
|
3
|
-
*
|
|
4
|
-
* The legacy field-level truncation (`truncateSpanData`, 2 MB/field) is sized for
|
|
5
|
-
* the legacy `/api/v1/tracking/spans` endpoint, which has no tight per-row cap.
|
|
6
|
-
* The OTEL `/v1/traces` route rejects any row whose *serialized JSON* exceeds
|
|
7
|
-
* 256 KB (`MAX_ROW_BYTES`) — and a row that flattens `data.input`/`data.output`/
|
|
8
|
-
* `messages` into `SpanAttributes` blows that even when each individual field is
|
|
9
|
-
* well under the 2 MB cap. So the recording leg needs its own row-aware budget:
|
|
10
|
-
* trim the largest `SpanAttributes` values (the heavy payloads) with a visible
|
|
11
|
-
* marker until the whole serialized row fits. Structural fields and small
|
|
12
|
-
* attributes are never touched.
|
|
13
|
-
*/
|
|
14
|
-
/**
|
|
15
|
-
* Target serialized size for an OTEL trace row. Below the server's 256 KB
|
|
16
|
-
* `MAX_ROW_BYTES` cap, with headroom for UTF-8 byte/char skew and the small
|
|
17
|
-
* field-set differences between the client row and the server's reconstruction.
|
|
18
|
-
*/
|
|
19
|
-
export const OTEL_ROW_BYTE_BUDGET = 245_000;
|
|
20
|
-
const FIT_MARKER = "…[truncated to fit otel row cap]";
|
|
21
|
-
/** Always retain at least this many chars of a trimmed value as a front preview. */
|
|
22
|
-
const MIN_KEEP = 64;
|
|
23
|
-
/**
|
|
24
|
-
* Trim priority by attribute — higher is sacrificed first. The intent mirrors
|
|
25
|
-
* `sanitizePayloadValue` (drop bulk, keep the prompt): when a row is over budget
|
|
26
|
-
* we shed the high-volume / low-signal payloads (message history, system prompt,
|
|
27
|
-
* tool I/O) and protect the two things worth querying — the user prompt
|
|
28
|
-
* (`gen_ai.prompt`, weight 0) and the model output (`gen_ai.completion`, weight
|
|
29
|
-
* 10) — trimming them only as a last resort. Unlisted keys take the default.
|
|
30
|
-
*/
|
|
31
|
-
const TRIM_WEIGHT = {
|
|
32
|
-
"gen_ai.input.messages": 100,
|
|
33
|
-
"gen_ai.system_instructions": 90,
|
|
34
|
-
"tool.input": 80,
|
|
35
|
-
"tool.output": 80,
|
|
36
|
-
"data.input": 70,
|
|
37
|
-
"data.output": 70,
|
|
38
|
-
"data.messages": 70,
|
|
39
|
-
"gen_ai.completion": 10,
|
|
40
|
-
"gen_ai.prompt": 0,
|
|
41
|
-
};
|
|
42
|
-
const DEFAULT_TRIM_WEIGHT = 50;
|
|
43
|
-
function trimWeight(key) {
|
|
44
|
-
return key in TRIM_WEIGHT ? TRIM_WEIGHT[key] : DEFAULT_TRIM_WEIGHT;
|
|
45
|
-
}
|
|
46
|
-
function byteLen(s) {
|
|
47
|
-
return Buffer.byteLength(s, "utf8");
|
|
48
|
-
}
|
|
49
|
-
export function fitTraceRowToBudget(row, maxBytes = OTEL_ROW_BYTE_BUDGET) {
|
|
50
|
-
if (byteLen(JSON.stringify(row)) <= maxBytes)
|
|
51
|
-
return row;
|
|
52
|
-
const attrs = { ...row.SpanAttributes };
|
|
53
|
-
// Each pass trims the current largest value; re-stripping any prior marker so
|
|
54
|
-
// the same value can be trimmed again (handles UTF-8 byte/char skew). The
|
|
55
|
-
// guard is a runaway backstop — convergence is guaranteed because every pass
|
|
56
|
-
// shrinks the largest value's length while over budget.
|
|
57
|
-
let guard = 0;
|
|
58
|
-
while (guard++ < 1000) {
|
|
59
|
-
const size = byteLen(JSON.stringify({ ...row, SpanAttributes: attrs }));
|
|
60
|
-
if (size <= maxBytes)
|
|
61
|
-
break;
|
|
62
|
-
// Pick the highest-priority (most trimmable) attribute that still has slack;
|
|
63
|
-
// tie-break on larger current length. This trims history/system/tool I/O
|
|
64
|
-
// before the user prompt and model output.
|
|
65
|
-
let key = "";
|
|
66
|
-
let bestWeight = -1;
|
|
67
|
-
let bestLen = 0;
|
|
68
|
-
for (const [k, v] of Object.entries(attrs)) {
|
|
69
|
-
const base = v.endsWith(FIT_MARKER) ? v.slice(0, v.length - FIT_MARKER.length) : v;
|
|
70
|
-
if (base.length <= MIN_KEEP)
|
|
71
|
-
continue; // nothing left to reclaim from this one
|
|
72
|
-
const w = trimWeight(k);
|
|
73
|
-
if (w > bestWeight || (w === bestWeight && base.length > bestLen)) {
|
|
74
|
-
bestWeight = w;
|
|
75
|
-
key = k;
|
|
76
|
-
bestLen = base.length;
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
if (key === "")
|
|
80
|
-
break; // nothing left to reclaim anywhere
|
|
81
|
-
const value = attrs[key];
|
|
82
|
-
const base = value.endsWith(FIT_MARKER)
|
|
83
|
-
? value.slice(0, value.length - FIT_MARKER.length)
|
|
84
|
-
: value;
|
|
85
|
-
const overBy = size - maxBytes;
|
|
86
|
-
const keep = Math.max(MIN_KEEP, base.length - overBy - FIT_MARKER.length);
|
|
87
|
-
attrs[key] = base.slice(0, keep) + FIT_MARKER;
|
|
88
|
-
}
|
|
89
|
-
return { ...row, SpanAttributes: attrs };
|
|
90
|
-
}
|
|
91
|
-
//# sourceMappingURL=fit-row-budget.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"fit-row-budget.js","sourceRoot":"","sources":["../../../../src/tracking/spans/otel/fit-row-budget.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAIH;;;;GAIG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,OAAO,CAAC;AAE5C,MAAM,UAAU,GAAG,kCAAkC,CAAC;AACtD,oFAAoF;AACpF,MAAM,QAAQ,GAAG,EAAE,CAAC;AAEpB;;;;;;;GAOG;AACH,MAAM,WAAW,GAA2B;IAC1C,uBAAuB,EAAE,GAAG;IAC5B,4BAA4B,EAAE,EAAE;IAChC,YAAY,EAAE,EAAE;IAChB,aAAa,EAAE,EAAE;IACjB,YAAY,EAAE,EAAE;IAChB,aAAa,EAAE,EAAE;IACjB,eAAe,EAAE,EAAE;IACnB,mBAAmB,EAAE,EAAE;IACvB,eAAe,EAAE,CAAC;CACnB,CAAC;AACF,MAAM,mBAAmB,GAAG,EAAE,CAAC;AAE/B,SAAS,UAAU,CAAC,GAAW;IAC7B,OAAO,GAAG,IAAI,WAAW,CAAC,CAAC,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,mBAAmB,CAAC;AACrE,CAAC;AAED,SAAS,OAAO,CAAC,CAAS;I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AAU,IAAI,CAAC,CAAC,KAAK,UAAU,IAAI,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,EAAE,CAAC;gBAClE,UAAU,GAAG,CAAC,CAAC;gBACf,GAAG,GAAG,CAAC,CAAC;gBACR,OAAO,GAAG,IAAI,CAAC,MAAM,CAAC;YACxB,CAAC;QACH,CAAC;QACD,IAAI,GAAG,KAAK,EAAE;YAAE,MAAM,CAAC,mCAAmC;QAE1D,MAAM,KAAK,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC;QACzB,MAAM,IAAI,GAAG,KAAK,CAAC,QAAQ,CAAC,UAAU,CAAC;YACrC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,MAAM,GAAG,UAAU,CAAC,MAAM,CAAC;YAClD,CAAC,CAAC,KAAK,CAAC;QACV,MAAM,MAAM,GAAG,IAAI,GAAG,QAAQ,CAAC;QAC/B,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,QAAQ,EAAE,IAAI,CAAC,MAAM,GAAG,MAAM,GAAG,UAAU,CAAC,MAAM,CAAC,CAAC;QAC1E,KAAK,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,UAAU,CAAC;IAChD,CAAC;IAED,OAAO,EAAE,GAAG,GAAG,EAAE,cAAc,EAAE,KAAK,EAAE,CAAC;AAC3C,CAAC"}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Pure `TrackingSpan → TraceRow` mapper.
|
|
3
|
-
*
|
|
4
|
-
* Maps the agent-span envelope onto the OTEL v2 HyperDX-row shape so agent spans
|
|
5
|
-
* land in `otel_traces` alongside scanner/runtime traces. The caller is expected
|
|
6
|
-
* to have already redacted + truncated `span.data` (see RecordingSpanTransport);
|
|
7
|
-
* this function performs no redaction and no I/O.
|
|
8
|
-
*
|
|
9
|
-
* Bounding: per-field size is the caller's responsibility (truncateSpanData,
|
|
10
|
-
* 2 MB/field) and the batcher's 8 MB body cap — so this does NOT impose the
|
|
11
|
-
* small AttrBuilder caps (4 KB/value), which would gut large LLM payloads.
|
|
12
|
-
*/
|
|
13
|
-
import type { TraceRow } from "../../../recording/transport/rows.js";
|
|
14
|
-
import type { TrackingSpan } from "../types.js";
|
|
15
|
-
export declare function trackingSpanToTraceRow(span: TrackingSpan): TraceRow;
|
|
16
|
-
//# sourceMappingURL=map-span-to-trace-row.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"map-span-to-trace-row.d.ts","sourceRoot":"","sources":["../../../../src/tracking/spans/otel/map-span-to-trace-row.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAwB,MAAM,sCAAsC,CAAC;AAE3F,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AA0GhD,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,YAAY,GAAG,QAAQ,CA2HnE"}
|
|
@@ -1,227 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Pure `TrackingSpan → TraceRow` mapper.
|
|
3
|
-
*
|
|
4
|
-
* Maps the agent-span envelope onto the OTEL v2 HyperDX-row shape so agent spans
|
|
5
|
-
* land in `otel_traces` alongside scanner/runtime traces. The caller is expected
|
|
6
|
-
* to have already redacted + truncated `span.data` (see RecordingSpanTransport);
|
|
7
|
-
* this function performs no redaction and no I/O.
|
|
8
|
-
*
|
|
9
|
-
* Bounding: per-field size is the caller's responsibility (truncateSpanData,
|
|
10
|
-
* 2 MB/field) and the batcher's 8 MB body cap — so this does NOT impose the
|
|
11
|
-
* small AttrBuilder caps (4 KB/value), which would gut large LLM payloads.
|
|
12
|
-
*/
|
|
13
|
-
import { msToNs, durationNs } from "../../../recording/otel/attributes.js";
|
|
14
|
-
import { deriveTraceId, deriveSpanId, deriveParentSpanId } from "./span-ids.js";
|
|
15
|
-
const SERVICE_NAME = "senpi-trading-runtime";
|
|
16
|
-
const SCOPE_NAME = "senpi.otel";
|
|
17
|
-
const SCOPE_VERSION = "2.0.0";
|
|
18
|
-
// `data.input` / `data.output` keys given an explicit gen_ai.* attribute above.
|
|
19
|
-
// Anything outside these is surfaced under gen_ai.input.* / gen_ai.output.* so
|
|
20
|
-
// no payload field is ever silently dropped by the split.
|
|
21
|
-
const MAPPED_LLM_INPUT_KEYS = new Set([
|
|
22
|
-
"system",
|
|
23
|
-
"prompt",
|
|
24
|
-
"messages",
|
|
25
|
-
"provider",
|
|
26
|
-
"temperature",
|
|
27
|
-
"maxTokens",
|
|
28
|
-
"imagesCount",
|
|
29
|
-
"tools",
|
|
30
|
-
"model",
|
|
31
|
-
]);
|
|
32
|
-
const MAPPED_LLM_OUTPUT_KEYS = new Set([
|
|
33
|
-
"content",
|
|
34
|
-
"lastAssistant",
|
|
35
|
-
"assistantTexts",
|
|
36
|
-
"finishReason",
|
|
37
|
-
]);
|
|
38
|
-
function asRecord(v) {
|
|
39
|
-
return v && typeof v === "object" && !Array.isArray(v)
|
|
40
|
-
? v
|
|
41
|
-
: undefined;
|
|
42
|
-
}
|
|
43
|
-
function nonEmpty(v) {
|
|
44
|
-
return typeof v === "string" && v.length > 0 ? v : undefined;
|
|
45
|
-
}
|
|
46
|
-
function hasAny(obj, keys) {
|
|
47
|
-
return keys.some((k) => obj[k] !== undefined);
|
|
48
|
-
}
|
|
49
|
-
/** Set a string attribute, omitting null/undefined/empty. `0` survives (meaningful). */
|
|
50
|
-
function putStr(map, key, value) {
|
|
51
|
-
if (value === null || value === undefined || value === "")
|
|
52
|
-
return;
|
|
53
|
-
map[key] = String(value);
|
|
54
|
-
}
|
|
55
|
-
/** Set one attribute per top-level `data` key: scalars as String, objects/arrays as JSON. */
|
|
56
|
-
function putDataValue(map, key, value) {
|
|
57
|
-
if (value === undefined)
|
|
58
|
-
return;
|
|
59
|
-
if (value === null)
|
|
60
|
-
return;
|
|
61
|
-
if (typeof value === "object") {
|
|
62
|
-
try {
|
|
63
|
-
const s = JSON.stringify(value);
|
|
64
|
-
if (s !== undefined)
|
|
65
|
-
map[key] = s;
|
|
66
|
-
}
|
|
67
|
-
catch {
|
|
68
|
-
/* unserializable — drop the one key, not the row */
|
|
69
|
-
}
|
|
70
|
-
return;
|
|
71
|
-
}
|
|
72
|
-
map[key] = String(value);
|
|
73
|
-
}
|
|
74
|
-
function spanName(span) {
|
|
75
|
-
const data = asRecord(span.data);
|
|
76
|
-
switch (span.spanType) {
|
|
77
|
-
case "llm":
|
|
78
|
-
return nonEmpty(span.model) ? `llm ${span.model}` : "llm";
|
|
79
|
-
case "tool": {
|
|
80
|
-
const name = nonEmpty(data?.tool_name) ?? nonEmpty(data?.toolName);
|
|
81
|
-
return name ? `tool ${name}` : "tool";
|
|
82
|
-
}
|
|
83
|
-
case "subagent": {
|
|
84
|
-
const agentId = nonEmpty(asRecord(data?.input)?.agentId) ?? nonEmpty(data?.agentId);
|
|
85
|
-
return agentId ? `subagent ${agentId}` : "subagent";
|
|
86
|
-
}
|
|
87
|
-
case "agent_end":
|
|
88
|
-
return "agent.end";
|
|
89
|
-
default:
|
|
90
|
-
return span.spanType;
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
function spanKind(spanType) {
|
|
94
|
-
return spanType === "llm" || spanType === "tool" ? "Client" : "Internal";
|
|
95
|
-
}
|
|
96
|
-
/**
|
|
97
|
-
* Child run id — ONLY from the delivery patch (subagent_delivery_target's
|
|
98
|
-
* `evObj.childRunId`), which is explicitly the child's run.
|
|
99
|
-
*
|
|
100
|
-
* Deliberately no fallback to `data.runId`: the subagent_spawned merge sets
|
|
101
|
-
* `data.runId = event.runId ?? ctx.runId`, and the ctx fallback is the *host*
|
|
102
|
-
* run — using it would advertise the host run as the child run and break
|
|
103
|
-
* cross-trace stitching. Absent a delivery patch, omit the breadcrumb (honest)
|
|
104
|
-
* rather than stamp the wrong run.
|
|
105
|
-
*/
|
|
106
|
-
function childRunId(data) {
|
|
107
|
-
return nonEmpty(asRecord(data?.delivery)?.childRunId);
|
|
108
|
-
}
|
|
109
|
-
export function trackingSpanToTraceRow(span) {
|
|
110
|
-
const data = asRecord(span.data);
|
|
111
|
-
const error = nonEmpty(data?.error);
|
|
112
|
-
const address = span.address.toLowerCase();
|
|
113
|
-
const status = error !== undefined ? "Error" : "Ok";
|
|
114
|
-
const resourceAttributes = { "service.name": SERVICE_NAME };
|
|
115
|
-
putStr(resourceAttributes, "strategy.address", address);
|
|
116
|
-
putStr(resourceAttributes, "recipe.name", span.recipeName);
|
|
117
|
-
putStr(resourceAttributes, "runtime.id", span.runtimeId);
|
|
118
|
-
putStr(resourceAttributes, "runtime.version", span.runtimeVersion);
|
|
119
|
-
// user.id is intentionally NOT set — the /v1/traces route server-stamps it.
|
|
120
|
-
const spanAttributes = {};
|
|
121
|
-
putStr(spanAttributes, "span.type", span.spanType);
|
|
122
|
-
putStr(spanAttributes, "emission.source", span.emissionSource);
|
|
123
|
-
putStr(spanAttributes, "session.key", span.sessionKey);
|
|
124
|
-
putStr(spanAttributes, "run.id", span.runId);
|
|
125
|
-
putStr(spanAttributes, "correlation.id", span.correlationId);
|
|
126
|
-
putStr(spanAttributes, "child.session.key", span.childSessionKey);
|
|
127
|
-
putStr(spanAttributes, "tool.call_id", span.toolCallId);
|
|
128
|
-
putStr(spanAttributes, "tool.name", nonEmpty(data?.tool_name) ?? nonEmpty(data?.toolName));
|
|
129
|
-
putStr(spanAttributes, "gen_ai.request.model", span.model);
|
|
130
|
-
putStr(spanAttributes, "gen_ai.usage.input_tokens", span.tokensIn);
|
|
131
|
-
putStr(spanAttributes, "gen_ai.usage.output_tokens", span.tokensOut);
|
|
132
|
-
putStr(spanAttributes, "cost.usd", span.costUsd);
|
|
133
|
-
// Mega-trace breadcrumb: lets a downstream view stitch the subagent's own
|
|
134
|
-
// (separate) trace back onto the host. child.session.key is always present;
|
|
135
|
-
// child.run_id depends on the spawned/delivery hooks having fired.
|
|
136
|
-
if (span.spanType === "subagent") {
|
|
137
|
-
putStr(spanAttributes, "subagent.child_session_key", span.childSessionKey);
|
|
138
|
-
putStr(spanAttributes, "subagent.child_run_id", childRunId(data));
|
|
139
|
-
}
|
|
140
|
-
// Split known LLM/tool payloads into granular attributes so the size-pressured
|
|
141
|
-
// fitter can drop bulk (system prompt, history, tool I/O) while preserving the
|
|
142
|
-
// user prompt + model output. gen_ai.* aligns with the OTEL GenAI semantic
|
|
143
|
-
// convention (matching the gen_ai.request.model / gen_ai.usage.* keys above).
|
|
144
|
-
// Anything not consumed here falls through to a generic data.{k} flatten, so
|
|
145
|
-
// subagent/agent_end payloads and unrecognized shapes are never dropped.
|
|
146
|
-
const consumed = new Set();
|
|
147
|
-
if (data) {
|
|
148
|
-
if (span.spanType === "llm") {
|
|
149
|
-
const input = asRecord(data.input);
|
|
150
|
-
if (input && hasAny(input, ["system", "prompt", "messages"])) {
|
|
151
|
-
putDataValue(spanAttributes, "gen_ai.system_instructions", input.system);
|
|
152
|
-
putDataValue(spanAttributes, "gen_ai.prompt", input.prompt);
|
|
153
|
-
putDataValue(spanAttributes, "gen_ai.input.messages", input.messages);
|
|
154
|
-
putDataValue(spanAttributes, "gen_ai.request.provider", input.provider);
|
|
155
|
-
putDataValue(spanAttributes, "gen_ai.request.temperature", input.temperature);
|
|
156
|
-
putDataValue(spanAttributes, "gen_ai.request.max_tokens", input.maxTokens);
|
|
157
|
-
putDataValue(spanAttributes, "gen_ai.request.images_count", input.imagesCount);
|
|
158
|
-
putDataValue(spanAttributes, "gen_ai.request.tools", input.tools);
|
|
159
|
-
// The envelope's gen_ai.request.model (from span.model) wins; fall back to
|
|
160
|
-
// the requested input.model only when the envelope didn't set it.
|
|
161
|
-
if (nonEmpty(span.model) === undefined) {
|
|
162
|
-
putDataValue(spanAttributes, "gen_ai.request.model", input.model);
|
|
163
|
-
}
|
|
164
|
-
// Never silently drop input fields — surface anything not explicitly
|
|
165
|
-
// mapped (incl. future additions to extractLlmInput) under gen_ai.input.*.
|
|
166
|
-
for (const [k, v] of Object.entries(input)) {
|
|
167
|
-
if (!MAPPED_LLM_INPUT_KEYS.has(k))
|
|
168
|
-
putDataValue(spanAttributes, `gen_ai.input.${k}`, v);
|
|
169
|
-
}
|
|
170
|
-
consumed.add("input");
|
|
171
|
-
}
|
|
172
|
-
const output = asRecord(data.output);
|
|
173
|
-
if (output && hasAny(output, ["content", "lastAssistant", "assistantTexts", "finishReason"])) {
|
|
174
|
-
putDataValue(spanAttributes, "gen_ai.completion", output.content ?? output.lastAssistant ?? output.assistantTexts);
|
|
175
|
-
putDataValue(spanAttributes, "gen_ai.completion.finish_reason", output.finishReason);
|
|
176
|
-
// Same no-drop guard for any unmapped output fields.
|
|
177
|
-
for (const [k, v] of Object.entries(output)) {
|
|
178
|
-
if (!MAPPED_LLM_OUTPUT_KEYS.has(k))
|
|
179
|
-
putDataValue(spanAttributes, `gen_ai.output.${k}`, v);
|
|
180
|
-
}
|
|
181
|
-
consumed.add("output");
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
else if (span.spanType === "tool") {
|
|
185
|
-
if (data.input !== undefined) {
|
|
186
|
-
putDataValue(spanAttributes, "tool.input", data.input);
|
|
187
|
-
consumed.add("input");
|
|
188
|
-
}
|
|
189
|
-
if (data.output !== undefined) {
|
|
190
|
-
putDataValue(spanAttributes, "tool.output", data.output);
|
|
191
|
-
consumed.add("output");
|
|
192
|
-
}
|
|
193
|
-
if (nonEmpty(data.error) !== undefined) {
|
|
194
|
-
putDataValue(spanAttributes, "tool.error", data.error);
|
|
195
|
-
consumed.add("error");
|
|
196
|
-
}
|
|
197
|
-
consumed.add("tool_name"); // already surfaced as tool.name
|
|
198
|
-
consumed.add("toolName");
|
|
199
|
-
}
|
|
200
|
-
// Generic one-level flatten for everything not split above.
|
|
201
|
-
for (const [k, v] of Object.entries(data)) {
|
|
202
|
-
if (!consumed.has(k))
|
|
203
|
-
putDataValue(spanAttributes, `data.${k}`, v);
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
return {
|
|
207
|
-
Timestamp: msToNs(span.startedAt),
|
|
208
|
-
TraceId: deriveTraceId(span.runId),
|
|
209
|
-
SpanId: deriveSpanId(span.id),
|
|
210
|
-
ParentSpanId: deriveParentSpanId(span.parentSpanId),
|
|
211
|
-
TraceState: "",
|
|
212
|
-
SpanName: spanName(span),
|
|
213
|
-
SpanKind: spanKind(span.spanType),
|
|
214
|
-
ServiceName: SERVICE_NAME,
|
|
215
|
-
Duration: durationNs(span.startedAt, span.endedAt),
|
|
216
|
-
StatusCode: status,
|
|
217
|
-
StatusMessage: error ?? "",
|
|
218
|
-
SpanAttributes: spanAttributes,
|
|
219
|
-
ResourceAttributes: resourceAttributes,
|
|
220
|
-
Events: [],
|
|
221
|
-
ScopeName: SCOPE_NAME,
|
|
222
|
-
ScopeVersion: SCOPE_VERSION,
|
|
223
|
-
TraceFlags: 1,
|
|
224
|
-
address,
|
|
225
|
-
};
|
|
226
|
-
}
|
|
227
|
-
//# sourceMappingURL=map-span-to-trace-row.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"map-span-to-trace-row.js","sourceRoot":"","sources":["../../../../src/tracking/spans/otel/map-span-to-trace-row.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAGH,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,uCAAuC,CAAC;AAE3E,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAEhF,MAAM,YAAY,GAAG,uBAAuB,CAAC;AAC7C,MAAM,UAAU,GAAG,YAAY,CAAC;AAChC,MAAM,aAAa,GAAG,OAAO,CAAC;AAE9B,gFAAgF;AAChF,+EAA+E;AAC/E,0DAA0D;AAC1D,MAAM,qBAAqB,GAAG,IAAI,GAAG,CAAC;IACpC,QAAQ;IACR,QAAQ;IACR,UAAU;IACV,UAAU;IACV,aAAa;IACb,WAAW;IACX,aAAa;IACb,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AAE,CAAC;QACb,OAAO;KACR,CAAC;AACJ,CAAC"}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* RecordingSpanTransport — ships agent spans to the OTEL v2 `/v1/traces` path.
|
|
3
|
-
*
|
|
4
|
-
* Implements the same `SpanTransport` seam as `BatchingSpanTransport`, but maps
|
|
5
|
-
* each `TrackingSpan` to a HyperDX `TraceRow` and enqueues it on a dedicated
|
|
6
|
-
* recording `TelemetryBatcher` (one per gateway — built at plugin register(),
|
|
7
|
-
* not borrowed from a per-runtime batcher).
|
|
8
|
-
*
|
|
9
|
-
* Pipeline per span (fire-and-forget, never throws into the SpanTracker):
|
|
10
|
-
* truncate oversized data fields → redact PII → map to TraceRow → enqueueTrace
|
|
11
|
-
*
|
|
12
|
-
* Truncation + redaction mirror BatchingSpanTransport so the new path never
|
|
13
|
-
* ships unredacted or oversized payloads. The recording batcher serializes at
|
|
14
|
-
* enqueue, so (unlike the legacy transport) both run BEFORE the row is built.
|
|
15
|
-
*
|
|
16
|
-
* `flush`/`shutdown` first await any in-flight per-span processing, then the
|
|
17
|
-
* batcher — so a flush is deterministic (no row stranded mid-pipeline).
|
|
18
|
-
*/
|
|
19
|
-
import type { SpanTransport, TrackingSpan } from "../types.js";
|
|
20
|
-
import type { TelemetryBatcher } from "../../../recording/transport/index.js";
|
|
21
|
-
import { type PiiRedactor } from "../redact-pii.js";
|
|
22
|
-
export interface RecordingSpanTransportOptions {
|
|
23
|
-
batcher: TelemetryBatcher;
|
|
24
|
-
/**
|
|
25
|
-
* PII redactor. Omit (`undefined`) to look up the process-wide default at use
|
|
26
|
-
* time (handles async redactor init); pass `null` to disable redaction
|
|
27
|
-
* explicitly (tests/local dev).
|
|
28
|
-
*/
|
|
29
|
-
redactor?: PiiRedactor | null;
|
|
30
|
-
}
|
|
31
|
-
export declare class RecordingSpanTransport implements SpanTransport {
|
|
32
|
-
private readonly batcher;
|
|
33
|
-
private readonly redactorOverride;
|
|
34
|
-
private readonly pending;
|
|
35
|
-
constructor(options: RecordingSpanTransportOptions);
|
|
36
|
-
enqueue(span: TrackingSpan): void;
|
|
37
|
-
flush(): Promise<void>;
|
|
38
|
-
shutdown(): Promise<void>;
|
|
39
|
-
/** Truncate → redact → map → enqueue. Self-contained; never throws. */
|
|
40
|
-
private process;
|
|
41
|
-
private drainPending;
|
|
42
|
-
}
|
|
43
|
-
//# sourceMappingURL=recording-span-transport.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"recording-span-transport.d.ts","sourceRoot":"","sources":["../../../../src/tracking/spans/otel/recording-span-transport.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC/D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uCAAuC,CAAC;AAE9E,OAAO,EACL,KAAK,WAAW,EAGjB,MAAM,kBAAkB,CAAC;AAO1B,MAAM,WAAW,6BAA6B;IAC5C,OAAO,EAAE,gBAAgB,CAAC;IAC1B;;;;OAIG;IACH,QAAQ,CAAC,EAAE,WAAW,GAAG,IAAI,CAAC;CAC/B;AAED,qBAAa,sBAAuB,YAAW,aAAa;IAC1D,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAmB;IAC3C,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAiC;IAClE,OAAO,CAAC,QAAQ,CAAC,OAAO,CAA4B;gBAExC,OAAO,EAAE,6BAA6B;IAKlD,OAAO,CAAC,IAAI,EAAE,YAAY,GAAG,IAAI;IAK3B,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAKtB,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;IAK/B,uEAAuE;YACzD,OAAO;YAkBP,YAAY;CAG3B"}
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* RecordingSpanTransport — ships agent spans to the OTEL v2 `/v1/traces` path.
|
|
3
|
-
*
|
|
4
|
-
* Implements the same `SpanTransport` seam as `BatchingSpanTransport`, but maps
|
|
5
|
-
* each `TrackingSpan` to a HyperDX `TraceRow` and enqueues it on a dedicated
|
|
6
|
-
* recording `TelemetryBatcher` (one per gateway — built at plugin register(),
|
|
7
|
-
* not borrowed from a per-runtime batcher).
|
|
8
|
-
*
|
|
9
|
-
* Pipeline per span (fire-and-forget, never throws into the SpanTracker):
|
|
10
|
-
* truncate oversized data fields → redact PII → map to TraceRow → enqueueTrace
|
|
11
|
-
*
|
|
12
|
-
* Truncation + redaction mirror BatchingSpanTransport so the new path never
|
|
13
|
-
* ships unredacted or oversized payloads. The recording batcher serializes at
|
|
14
|
-
* enqueue, so (unlike the legacy transport) both run BEFORE the row is built.
|
|
15
|
-
*
|
|
16
|
-
* `flush`/`shutdown` first await any in-flight per-span processing, then the
|
|
17
|
-
* batcher — so a flush is deterministic (no row stranded mid-pipeline).
|
|
18
|
-
*/
|
|
19
|
-
import { truncateSpanData } from "../span-transport.js";
|
|
20
|
-
import { getDefaultPiiRedactor, redactSpanData, } from "../redact-pii.js";
|
|
21
|
-
import { trackingSpanToTraceRow } from "./map-span-to-trace-row.js";
|
|
22
|
-
import { fitTraceRowToBudget } from "./fit-row-budget.js";
|
|
23
|
-
import { createLogger } from "../../../utils/logger.js";
|
|
24
|
-
const logger = createLogger("[senpi-core][recording-span-transport]");
|
|
25
|
-
export class RecordingSpanTransport {
|
|
26
|
-
batcher;
|
|
27
|
-
redactorOverride;
|
|
28
|
-
pending = new Set();
|
|
29
|
-
constructor(options) {
|
|
30
|
-
this.batcher = options.batcher;
|
|
31
|
-
this.redactorOverride = options.redactor;
|
|
32
|
-
}
|
|
33
|
-
enqueue(span) {
|
|
34
|
-
const p = this.process(span).finally(() => this.pending.delete(p));
|
|
35
|
-
this.pending.add(p);
|
|
36
|
-
}
|
|
37
|
-
async flush() {
|
|
38
|
-
await this.drainPending();
|
|
39
|
-
await this.batcher.flush();
|
|
40
|
-
}
|
|
41
|
-
async shutdown() {
|
|
42
|
-
await this.drainPending();
|
|
43
|
-
await this.batcher.shutdown();
|
|
44
|
-
}
|
|
45
|
-
/** Truncate → redact → map → enqueue. Self-contained; never throws. */
|
|
46
|
-
async process(span) {
|
|
47
|
-
try {
|
|
48
|
-
const truncated = truncateSpanData(span);
|
|
49
|
-
const redactor = this.redactorOverride === undefined
|
|
50
|
-
? getDefaultPiiRedactor()
|
|
51
|
-
: this.redactorOverride;
|
|
52
|
-
const cleaned = redactor ? await redactSpanData(truncated, redactor) : truncated;
|
|
53
|
-
// Fit to the OTEL per-row byte cap (256 KB server-side) — the legacy
|
|
54
|
-
// 2 MB/field truncation above doesn't bound the assembled row.
|
|
55
|
-
this.batcher.enqueueTrace(fitTraceRowToBudget(trackingSpanToTraceRow(cleaned)));
|
|
56
|
-
}
|
|
57
|
-
catch (err) {
|
|
58
|
-
logger.warn("span → trace-row pipeline failed; dropped", {
|
|
59
|
-
err: err instanceof Error ? err.message : String(err),
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
async drainPending() {
|
|
64
|
-
await Promise.allSettled([...this.pending]);
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
//# sourceMappingURL=recording-span-transport.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"recording-span-transport.js","sourceRoot":"","sources":["../../../../src/tracking/spans/otel/recording-span-transport.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAIH,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAEL,qBAAqB,EACrB,cAAc,GACf,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AACpE,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAExD,MAA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,+DAA+D;YAC/D,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,mBAAmB,CAAC,sBAAsB,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;QAClF,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,MAAM,CAAC,IAAI,CAAC,2CAA2C,EAAE;gBACvD,GAAG,EAAE,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC;aACtD,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IAEO,KAAK,CAAC,YAAY;QACxB,MAAM,OAAO,CAAC,UAAU,CAAC,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;IAC9C,CAAC;CACF"}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Deterministic OTEL id derivation for agent spans.
|
|
3
|
-
*
|
|
4
|
-
* Unlike scanner spans (each its own trace, random ids via `cryptoIdGenerator`),
|
|
5
|
-
* agent spans must group by run and preserve their parent/child tree. So ids are
|
|
6
|
-
* *derived* — a hash of the stable source key — rather than random:
|
|
7
|
-
*
|
|
8
|
-
* - `TraceId` = hash(runId) → every span in one agent run shares it
|
|
9
|
-
* - `SpanId` = hash(span.id)
|
|
10
|
-
* - `ParentSpanId` = hash(span.parentSpanId) ("" stays "" for roots)
|
|
11
|
-
*
|
|
12
|
-
* A child's `parentSpanId` holds the parent span's raw id, so
|
|
13
|
-
* `deriveParentSpanId(child.parentSpanId)` equals `deriveSpanId(parent.id)` —
|
|
14
|
-
* the link reconstructs in HyperDX.
|
|
15
|
-
*/
|
|
16
|
-
/** 32 lowercase-hex chars (16 bytes) derived from the agent run id. */
|
|
17
|
-
export declare function deriveTraceId(runId: string): string;
|
|
18
|
-
/** 16 lowercase-hex chars (8 bytes) derived from the span's raw id. */
|
|
19
|
-
export declare function deriveSpanId(id: string): string;
|
|
20
|
-
/** Derived parent SpanId; empty string (root) passes through unchanged. */
|
|
21
|
-
export declare function deriveParentSpanId(parentSpanId: string): string;
|
|
22
|
-
//# sourceMappingURL=span-ids.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"span-ids.d.ts","sourceRoot":"","sources":["../../../../src/tracking/spans/otel/span-ids.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAQH,uEAAuE;AACvE,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAEnD;AAED,uEAAuE;AACvE,wBAAgB,YAAY,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,CAE/C;AAED,2EAA2E;AAC3E,wBAAgB,kBAAkB,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,CAE/D"}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Deterministic OTEL id derivation for agent spans.
|
|
3
|
-
*
|
|
4
|
-
* Unlike scanner spans (each its own trace, random ids via `cryptoIdGenerator`),
|
|
5
|
-
* agent spans must group by run and preserve their parent/child tree. So ids are
|
|
6
|
-
* *derived* — a hash of the stable source key — rather than random:
|
|
7
|
-
*
|
|
8
|
-
* - `TraceId` = hash(runId) → every span in one agent run shares it
|
|
9
|
-
* - `SpanId` = hash(span.id)
|
|
10
|
-
* - `ParentSpanId` = hash(span.parentSpanId) ("" stays "" for roots)
|
|
11
|
-
*
|
|
12
|
-
* A child's `parentSpanId` holds the parent span's raw id, so
|
|
13
|
-
* `deriveParentSpanId(child.parentSpanId)` equals `deriveSpanId(parent.id)` —
|
|
14
|
-
* the link reconstructs in HyperDX.
|
|
15
|
-
*/
|
|
16
|
-
import { createHash } from "node:crypto";
|
|
17
|
-
function hashHex(input, bytes) {
|
|
18
|
-
return createHash("sha256").update(input).digest("hex").slice(0, bytes * 2);
|
|
19
|
-
}
|
|
20
|
-
/** 32 lowercase-hex chars (16 bytes) derived from the agent run id. */
|
|
21
|
-
export function deriveTraceId(runId) {
|
|
22
|
-
return hashHex(runId, 16);
|
|
23
|
-
}
|
|
24
|
-
/** 16 lowercase-hex chars (8 bytes) derived from the span's raw id. */
|
|
25
|
-
export function deriveSpanId(id) {
|
|
26
|
-
return hashHex(id, 8);
|
|
27
|
-
}
|
|
28
|
-
/** Derived parent SpanId; empty string (root) passes through unchanged. */
|
|
29
|
-
export function deriveParentSpanId(parentSpanId) {
|
|
30
|
-
return parentSpanId === "" ? "" : deriveSpanId(parentSpanId);
|
|
31
|
-
}
|
|
32
|
-
//# sourceMappingURL=span-ids.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"span-ids.js","sourceRoot":"","sources":["../../../../src/tracking/spans/otel/span-ids.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,SAAS,OAAO,CAAC,KAAa,EAAE,KAAa;IAC3C,OAAO,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,GAAG,CAAC,CAAC,CAAC;AAC9E,CAAC;AAED,uEAAuE;AACvE,MAAM,UAAU,aAAa,CAAC,KAAa;IACzC,OAAO,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;AAC5B,CAAC;AAED,uEAAuE;AACvE,MAAM,UAAU,YAAY,CAAC,EAAU;IACrC,OAAO,OAAO,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC;AACxB,CAAC;AAED,2EAA2E;AAC3E,MAAM,UAAU,kBAAkB,CAAC,YAAoB;IACrD,OAAO,YAAY,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,YAAY,CAAC,YAAY,CAAC,CAAC;AAC/D,CAAC"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { SpanTracker } from "./span-tracker.js";
|
|
2
|
-
import type { SpanTransport } from "./types.js";
|
|
3
|
-
export type SpanSinkMode = "legacy" | "dual" | "otel";
|
|
4
|
-
/** Parse `SENPI_SPANS_SINK`; unknown/unset → `dual` (the validation default). */
|
|
5
|
-
export declare function resolveSpanSinkMode(value: string | undefined): SpanSinkMode;
|
|
6
|
-
/** Compose the active transport from the two children per the sink mode. */
|
|
7
|
-
export declare function composeSpanTransport(mode: SpanSinkMode, legacy: SpanTransport, recording: SpanTransport): SpanTransport;
|
|
8
|
-
export declare function createPluginSpanTracker(apiKey: string | undefined): SpanTracker;
|
|
9
|
-
//# sourceMappingURL=plugin-span-tracker.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"plugin-span-tracker.d.ts","sourceRoot":"","sources":["../../../src/tracking/spans/plugin-span-tracker.ts"],"names":[],"mappings":"AA2BA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAShD,MAAM,MAAM,YAAY,GAAG,QAAQ,GAAG,MAAM,GAAG,MAAM,CAAC;AAEtD,iFAAiF;AACjF,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,YAAY,CAI3E;AAED,4EAA4E;AAC5E,wBAAgB,oBAAoB,CAClC,IAAI,EAAE,YAAY,EAClB,MAAM,EAAE,aAAa,EACrB,SAAS,EAAE,aAAa,GACvB,aAAa,CASf;AAgCD,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,MAAM,GAAG,SAAS,GACzB,WAAW,CAsDb"}
|