@senpi/runtime 1.1.0-dev.runtime-phase-2.20260609132603 → 1.1.0-dev.runtime-phase-2.20260610125851

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.
Files changed (100) hide show
  1. package/dist/actions/close-position/close-position.action.d.ts +0 -16
  2. package/dist/actions/close-position/close-position.action.d.ts.map +1 -1
  3. package/dist/actions/close-position/close-position.action.js +38 -299
  4. package/dist/actions/close-position/close-position.action.js.map +1 -1
  5. package/dist/actions/decision-engine.d.ts +0 -2
  6. package/dist/actions/decision-engine.d.ts.map +1 -1
  7. package/dist/actions/decision-engine.js.map +1 -1
  8. package/dist/actions/llm-decision/factory.d.ts +0 -3
  9. package/dist/actions/llm-decision/factory.d.ts.map +1 -1
  10. package/dist/actions/llm-decision/factory.js +0 -1
  11. package/dist/actions/llm-decision/factory.js.map +1 -1
  12. package/dist/actions/llm-decision/openclaw-llm-decision.d.ts +0 -13
  13. package/dist/actions/llm-decision/openclaw-llm-decision.d.ts.map +1 -1
  14. package/dist/actions/llm-decision/openclaw-llm-decision.js +68 -195
  15. package/dist/actions/llm-decision/openclaw-llm-decision.js.map +1 -1
  16. package/dist/actions/open-position/open-position.action.d.ts +0 -12
  17. package/dist/actions/open-position/open-position.action.d.ts.map +1 -1
  18. package/dist/actions/open-position/open-position.action.js +123 -346
  19. package/dist/actions/open-position/open-position.action.js.map +1 -1
  20. package/dist/actions/position-tracker/position-tracker.action.d.ts +0 -6
  21. package/dist/actions/position-tracker/position-tracker.action.d.ts.map +1 -1
  22. package/dist/actions/position-tracker/position-tracker.action.js +0 -48
  23. package/dist/actions/position-tracker/position-tracker.action.js.map +1 -1
  24. package/dist/runtime/create-actions.d.ts.map +1 -1
  25. package/dist/runtime/create-actions.js +0 -2
  26. package/dist/runtime/create-actions.js.map +1 -1
  27. package/dist/runtime/create-runtime-context.d.ts +0 -2
  28. package/dist/runtime/create-runtime-context.d.ts.map +1 -1
  29. package/dist/runtime/create-runtime-context.js +0 -1
  30. package/dist/runtime/create-runtime-context.js.map +1 -1
  31. package/dist/runtime/create-scanner-module.d.ts +1 -1
  32. package/dist/runtime/create-scanner-module.d.ts.map +1 -1
  33. package/dist/runtime/create-scanner-module.js +1 -2
  34. package/dist/runtime/create-scanner-module.js.map +1 -1
  35. package/dist/runtime/runtime-schema.d.ts +0 -24
  36. package/dist/runtime/runtime-schema.d.ts.map +1 -1
  37. package/dist/runtime/runtime-schema.js +0 -1
  38. package/dist/runtime/runtime-schema.js.map +1 -1
  39. package/dist/runtime/runtime.d.ts +0 -5
  40. package/dist/runtime/runtime.d.ts.map +1 -1
  41. package/dist/runtime/runtime.js +4 -127
  42. package/dist/runtime/runtime.js.map +1 -1
  43. package/dist/scanners/engine/data-providers.d.ts +0 -2
  44. package/dist/scanners/engine/data-providers.d.ts.map +1 -1
  45. package/dist/scanners/engine/data-providers.js.map +1 -1
  46. package/dist/scanners/engine/engine.d.ts.map +1 -1
  47. package/dist/scanners/engine/engine.js +9 -68
  48. package/dist/scanners/engine/engine.js.map +1 -1
  49. package/dist/scanners/runtime-module.d.ts +0 -2
  50. package/dist/scanners/runtime-module.d.ts.map +1 -1
  51. package/dist/scanners/runtime-module.js +0 -1
  52. package/dist/scanners/runtime-module.js.map +1 -1
  53. package/dist/senpi/client.d.ts +2 -2
  54. package/dist/senpi/client.d.ts.map +1 -1
  55. package/dist/senpi/client.js +20 -120
  56. package/dist/senpi/client.js.map +1 -1
  57. package/dist/senpi/types.d.ts +1 -68
  58. package/dist/senpi/types.d.ts.map +1 -1
  59. package/dist/strategy/strategy-state.d.ts +1 -1
  60. package/dist/strategy/strategy-state.d.ts.map +1 -1
  61. package/dist/tracking/spans/plugin-span-tracker.d.ts.map +1 -1
  62. package/dist/tracking/spans/plugin-span-tracker.js +24 -4
  63. package/dist/tracking/spans/plugin-span-tracker.js.map +1 -1
  64. package/dist/tracking/spans/redact-pii.d.ts +0 -10
  65. package/dist/tracking/spans/redact-pii.d.ts.map +1 -1
  66. package/dist/tracking/spans/redact-pii.js +2 -80
  67. package/dist/tracking/spans/redact-pii.js.map +1 -1
  68. package/dist/types/runtime.d.ts +0 -3
  69. package/dist/types/runtime.d.ts.map +1 -1
  70. package/dist/types/strategy.d.ts +2 -2
  71. package/dist/types/strategy.d.ts.map +1 -1
  72. package/package.json +1 -1
  73. package/dist/actions/otel-helpers.d.ts +0 -65
  74. package/dist/actions/otel-helpers.d.ts.map +0 -1
  75. package/dist/actions/otel-helpers.js +0 -122
  76. package/dist/actions/otel-helpers.js.map +0 -1
  77. package/dist/otel/context.d.ts +0 -24
  78. package/dist/otel/context.d.ts.map +0 -1
  79. package/dist/otel/context.js +0 -29
  80. package/dist/otel/context.js.map +0 -1
  81. package/dist/otel/emitter.d.ts +0 -73
  82. package/dist/otel/emitter.d.ts.map +0 -1
  83. package/dist/otel/emitter.js +0 -248
  84. package/dist/otel/emitter.js.map +0 -1
  85. package/dist/otel/encode.d.ts +0 -48
  86. package/dist/otel/encode.d.ts.map +0 -1
  87. package/dist/otel/encode.js +0 -100
  88. package/dist/otel/encode.js.map +0 -1
  89. package/dist/otel/index.d.ts +0 -13
  90. package/dist/otel/index.d.ts.map +0 -1
  91. package/dist/otel/index.js +0 -10
  92. package/dist/otel/index.js.map +0 -1
  93. package/dist/otel/transport.d.ts +0 -57
  94. package/dist/otel/transport.d.ts.map +0 -1
  95. package/dist/otel/transport.js +0 -208
  96. package/dist/otel/transport.js.map +0 -1
  97. package/dist/otel/types.d.ts +0 -62
  98. package/dist/otel/types.d.ts.map +0 -1
  99. package/dist/otel/types.js +0 -2
  100. package/dist/otel/types.js.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"file":"emitter.js","sourceRoot":"","sources":["../../src/otel/emitter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,wBAA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QAAQ,EAAE,IAAI,OAAO,CAAC,OAAO,EAAE;YAC3C,IAAI,CAAC,IAAI,EAAE,QAAQ,EAAE,IAAI,OAAO,CAAC,OAAO,EAAE;SAC3C,CAAC,CAAC;IACL,CAAC;IAED;;;;;OAKG;IACH,MAAM,CAAC,QAAQ;QACb,OAAO,IAAI,WAAW,CAAC;YACrB,QAAQ,EAAE,EAAE,WAAW,EAAE,uBAAuB,EAAE,aAAa,EAAE,UAAU,EAAE;YAC7E,QAAQ,EAAE,IAAI;SACf,CAAC,CAAC;IACL,CAAC;CACF;AAED,SAAS,OAAO,CAAC,IAAY,EAAE,IAAY;IACzC,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,GAAG,IAAI,CAAC;AACzC,CAAC"}
@@ -1,48 +0,0 @@
1
- /**
2
- * ID generation, ns timestamps, and string-attribute encoding.
3
- *
4
- * Wire-format requirements (see remediation plan "Wire format"):
5
- * - traceId = 32-hex lowercase from 16 random bytes
6
- * - spanId = 16-hex lowercase from 8 random bytes
7
- * - timestamps = epoch nanoseconds as UInt64-string
8
- * - attribute values = flat strings (`Map(LC(String), String)` in HyperDX)
9
- *
10
- * Callers pre-flatten nested objects via the separate `flatten()` helper —
11
- * `toStringValue` JSON-stringifies arrays and plain objects as a fallback.
12
- */
13
- export declare function newTraceId(): string;
14
- export declare function newSpanId(): string;
15
- /**
16
- * High-precision ns timestamp combining `performance.timeOrigin` (epoch ms
17
- * resolved at process start) with `performance.now()` (sub-ms monotonic).
18
- * Returned as a UInt64-string for direct insertion into DateTime64(9) columns.
19
- *
20
- * Arithmetic note: a naive `(timeOrigin + now()) * 1e6` overflows Number
21
- * precision (timeOrigin*1e6 ≈ 1.7e18, well past 2^53 ≈ 9e15) and would zero
22
- * the sub-µs bits. We keep the large epoch component in BigInt and only
23
- * multiply the small `performance.now()` value inside a Number — that
24
- * preserves `performance.now()`'s native µs precision end-to-end.
25
- */
26
- export declare function nowNs(): string;
27
- /** BigInt variant for callers that need to subtract (span duration). */
28
- export declare function nowNsBigInt(): bigint;
29
- /**
30
- * Stringify any JS value into the canonical CH-row attribute encoding.
31
- * Strings pass through; primitives map to their natural string form;
32
- * objects/arrays are JSON-stringified. Returns `''` for null/undefined so
33
- * callers can decide whether to emit the entry or skip it.
34
- */
35
- export declare function toStringValue(v: unknown): string;
36
- /**
37
- * Convert a record of mixed values to a flat string-only attribute map.
38
- * Entries whose value is `null` or `undefined` are skipped — CH schema
39
- * defaults handle absence (per CH convention, empty-string > null > undefined).
40
- */
41
- export declare function toStringMap(record: Record<string, unknown> | undefined): Record<string, string>;
42
- /**
43
- * Flatten a `Record<string, primitive>` into dot-namespaced string attrs.
44
- * Primitives map to their natural string form; arrays and nested objects
45
- * are JSON-stringified via `toStringValue` so nothing gets silently dropped.
46
- */
47
- export declare function flatten(prefix: string, obj: Record<string, unknown> | undefined): Record<string, string>;
48
- //# sourceMappingURL=encode.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"encode.d.ts","sourceRoot":"","sources":["../../src/otel/encode.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAKH,wBAAgB,UAAU,IAAI,MAAM,CAEnC;AAED,wBAAgB,SAAS,IAAI,MAAM,CAElC;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,KAAK,IAAI,MAAM,CAE9B;AAED,wEAAwE;AACxE,wBAAgB,WAAW,IAAI,MAAM,CAOpC;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,CAAC,EAAE,OAAO,GAAG,MAAM,CAWhD;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAQ/F;AAED;;;;GAIG;AACH,wBAAgB,OAAO,CACrB,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,GACvC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAQxB"}
@@ -1,100 +0,0 @@
1
- /**
2
- * ID generation, ns timestamps, and string-attribute encoding.
3
- *
4
- * Wire-format requirements (see remediation plan "Wire format"):
5
- * - traceId = 32-hex lowercase from 16 random bytes
6
- * - spanId = 16-hex lowercase from 8 random bytes
7
- * - timestamps = epoch nanoseconds as UInt64-string
8
- * - attribute values = flat strings (`Map(LC(String), String)` in HyperDX)
9
- *
10
- * Callers pre-flatten nested objects via the separate `flatten()` helper —
11
- * `toStringValue` JSON-stringifies arrays and plain objects as a fallback.
12
- */
13
- import { randomBytes } from "node:crypto";
14
- import { performance } from "node:perf_hooks";
15
- export function newTraceId() {
16
- return randomBytes(16).toString("hex");
17
- }
18
- export function newSpanId() {
19
- return randomBytes(8).toString("hex");
20
- }
21
- /**
22
- * High-precision ns timestamp combining `performance.timeOrigin` (epoch ms
23
- * resolved at process start) with `performance.now()` (sub-ms monotonic).
24
- * Returned as a UInt64-string for direct insertion into DateTime64(9) columns.
25
- *
26
- * Arithmetic note: a naive `(timeOrigin + now()) * 1e6` overflows Number
27
- * precision (timeOrigin*1e6 ≈ 1.7e18, well past 2^53 ≈ 9e15) and would zero
28
- * the sub-µs bits. We keep the large epoch component in BigInt and only
29
- * multiply the small `performance.now()` value inside a Number — that
30
- * preserves `performance.now()`'s native µs precision end-to-end.
31
- */
32
- export function nowNs() {
33
- return nowNsBigInt().toString();
34
- }
35
- /** BigInt variant for callers that need to subtract (span duration). */
36
- export function nowNsBigInt() {
37
- const originMs = performance.timeOrigin;
38
- const originWholeMs = Math.floor(originMs);
39
- const originFracNs = Math.round((originMs - originWholeMs) * 1_000_000);
40
- const originNs = BigInt(originWholeMs) * 1000000n + BigInt(originFracNs);
41
- const offsetNs = BigInt(Math.round(performance.now() * 1_000_000));
42
- return originNs + offsetNs;
43
- }
44
- /**
45
- * Stringify any JS value into the canonical CH-row attribute encoding.
46
- * Strings pass through; primitives map to their natural string form;
47
- * objects/arrays are JSON-stringified. Returns `''` for null/undefined so
48
- * callers can decide whether to emit the entry or skip it.
49
- */
50
- export function toStringValue(v) {
51
- if (v === null || v === undefined)
52
- return "";
53
- if (typeof v === "string")
54
- return v;
55
- if (typeof v === "boolean")
56
- return v ? "true" : "false";
57
- if (typeof v === "bigint")
58
- return v.toString();
59
- if (typeof v === "number")
60
- return String(v);
61
- try {
62
- return JSON.stringify(v);
63
- }
64
- catch {
65
- return String(v);
66
- }
67
- }
68
- /**
69
- * Convert a record of mixed values to a flat string-only attribute map.
70
- * Entries whose value is `null` or `undefined` are skipped — CH schema
71
- * defaults handle absence (per CH convention, empty-string > null > undefined).
72
- */
73
- export function toStringMap(record) {
74
- if (!record)
75
- return {};
76
- const out = {};
77
- for (const [key, v] of Object.entries(record)) {
78
- if (v === null || v === undefined)
79
- continue;
80
- out[key] = toStringValue(v);
81
- }
82
- return out;
83
- }
84
- /**
85
- * Flatten a `Record<string, primitive>` into dot-namespaced string attrs.
86
- * Primitives map to their natural string form; arrays and nested objects
87
- * are JSON-stringified via `toStringValue` so nothing gets silently dropped.
88
- */
89
- export function flatten(prefix, obj) {
90
- if (!obj)
91
- return {};
92
- const out = {};
93
- for (const [k, v] of Object.entries(obj)) {
94
- if (v === null || v === undefined)
95
- continue;
96
- out[`${prefix}.${k}`] = toStringValue(v);
97
- }
98
- return out;
99
- }
100
- //# sourceMappingURL=encode.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"encode.js","sourceRoot":"","sources":["../../src/otel/encode.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAE9C,MAAM,UAAU,UAAU;IACxB,OAAO,WAAW,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;AACzC,CAAC;AAED,MAAM,UAAU,SAAS;IACvB,OAAO,WA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C;IAC3B,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,MAAM,CAAC,CAAC,CAAC,CAAC;IACnB,CAAC;AACH,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,WAAW,CAAC,MAA2C;IACrE,IAAI,CAAC,MAAM;QAAE,OAAO,EAAE,CAAC;IACvB,MAAM,GAAG,GAA2B,EAAE,CAAC;IACvC,KAAK,MAAM,CAAC,GAAG,EAAE,CAAC,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;QAC9C,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,SAAS;YAAE,SAAS;QAC5C,GAAG,CAAC,GAAG,CAAC,GAAG,aAAa,CAAC,CAAC,CAAC,CAAC;IAC9B,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,OAAO,CACrB,MAAc,EACd,GAAwC;IAExC,IAAI,CAAC,GAAG;QAAE,OAAO,EAAE,CAAC;IACpB,MAAM,GAAG,GAA2B,EAAE,CAAC;IACvC,KAAK,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;QACzC,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,SAAS;YAAE,SAAS;QAC5C,GAAG,CAAC,GAAG,MAAM,IAAI,CAAC,EAAE,CAAC,GAAG,aAAa,CAAC,CAAC,CAAC,CAAC;IAC3C,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC"}
@@ -1,13 +0,0 @@
1
- /**
2
- * Public surface of the OTEL V2 recording module.
3
- *
4
- * Exports are limited to symbols consumed outside `src/otel/`. Transport,
5
- * encode helpers, and registry stubs are intentionally not re-exported.
6
- */
7
- export type { LogRow, OtelSeverity, OtelSpanKind, OtelStatusCode, SpanEvent, SpanRow, } from "./types.js";
8
- export { getCurrentSpan, getPositionId, otelContext, setCurrentSpan, setPositionId, } from "./context.js";
9
- export type { OtelContext } from "./context.js";
10
- export { flatten } from "./encode.js";
11
- export { OtelEmitter } from "./emitter.js";
12
- export type { LogEmitOpts, OtelEmitterOptions, OtelIdentity, OtelSpanHandle, SpanEndOpts, SpanStartOpts, } from "./emitter.js";
13
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/otel/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,YAAY,EACV,MAAM,EACN,YAAY,EACZ,YAAY,EACZ,cAAc,EACd,SAAS,EACT,OAAO,GACR,MAAM,YAAY,CAAC;AAEpB,OAAO,EACL,cAAc,EACd,aAAa,EACb,WAAW,EACX,cAAc,EACd,aAAa,GACd,MAAM,cAAc,CAAC;AACtB,YAAY,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAEhD,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAEtC,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,YAAY,EACV,WAAW,EACX,kBAAkB,EAClB,YAAY,EACZ,cAAc,EACd,WAAW,EACX,aAAa,GACd,MAAM,cAAc,CAAC"}
@@ -1,10 +0,0 @@
1
- /**
2
- * Public surface of the OTEL V2 recording module.
3
- *
4
- * Exports are limited to symbols consumed outside `src/otel/`. Transport,
5
- * encode helpers, and registry stubs are intentionally not re-exported.
6
- */
7
- export { getCurrentSpan, getPositionId, otelContext, setCurrentSpan, setPositionId, } from "./context.js";
8
- export { flatten } from "./encode.js";
9
- export { OtelEmitter } from "./emitter.js";
10
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/otel/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAWH,OAAO,EACL,cAAc,EACd,aAAa,EACb,WAAW,EACX,cAAc,EACd,aAAa,GACd,MAAM,cAAc,CAAC;AAGtB,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAEtC,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC"}
@@ -1,57 +0,0 @@
1
- /**
2
- * Fire-and-forget HTTP transport with micro-batching.
3
- *
4
- * Records are buffered in memory and flushed to the consumer when either:
5
- * - the buffer reaches `maxBatch` records, OR
6
- * - `maxAgeMs` elapse since the first record landed (timer-driven).
7
- *
8
- * Each flush issues one POST containing `{ spans: [...] }` / `{ logs: [...] }`.
9
- * The consumer already accepts an array; single-record posts (the prior
10
- * behavior) were just N=1 batches. Trade-off: per-record latency up to
11
- * `maxAgeMs` (default 250ms); SIGKILL loses the in-flight buffer. Graceful
12
- * shutdown via `shutdown()` drains.
13
- *
14
- * Oversize guard: if the serialized batch exceeds `MAX_RECORD_BYTES`, splits
15
- * the batch in halves and re-flushes recursively until each fragment fits.
16
- * For singletons that still overflow, the blob-strip fallback kicks in
17
- * (`gen_ai.message.body`, `senpi.order_response.body`, `decision.reasoning`,
18
- * and log Body get cleared; row tagged `senpi.degraded=true`).
19
- *
20
- * Failure modes are fail-open: redactor throws → warn + emit un-redacted;
21
- * fetch fails → warn + drop the batch; oversize singleton → warn + drop.
22
- * Nothing in this layer blocks the trade path.
23
- */
24
- import type { LogRow, SpanRow } from "./types.js";
25
- export type OtelTransportKind = "spans" | "logs";
26
- export interface OtelHttpTransportOptions {
27
- url: string;
28
- apiKey?: string;
29
- kind: OtelTransportKind;
30
- /** Records buffered before forcing a flush. Default 100. */
31
- maxBatch?: number;
32
- /** Max age in ms of the oldest buffered record before flushing. Default 250. */
33
- maxAgeMs?: number;
34
- }
35
- export declare class OtelHttpTransport<T extends SpanRow | LogRow> {
36
- private readonly url;
37
- private readonly apiKey?;
38
- private readonly kind;
39
- private readonly maxBatch;
40
- private readonly maxAgeMs;
41
- private buf;
42
- private flushTimer;
43
- private inFlight;
44
- constructor(opts: OtelHttpTransportOptions);
45
- /**
46
- * Enqueue a record for the next flush. Synchronous, never throws, never
47
- * blocks. Triggers an immediate flush when the buffer reaches `maxBatch`.
48
- */
49
- emit(record: T): void;
50
- /** Drain the buffer and await all in-flight POSTs. Idempotent. */
51
- shutdown(): Promise<void>;
52
- private flush;
53
- private dispatch;
54
- private dispatchSerialized;
55
- private buildEnvelope;
56
- }
57
- //# sourceMappingURL=transport.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"transport.d.ts","sourceRoot":"","sources":["../../src/otel/transport.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAIH,OAAO,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAQlD,MAAM,MAAM,iBAAiB,GAAG,OAAO,GAAG,MAAM,CAAC;AAEjD,MAAM,WAAW,wBAAwB;IACvC,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,iBAAiB,CAAC;IACxB,4DAA4D;IAC5D,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,gFAAgF;IAChF,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,qBAAa,iBAAiB,CAAC,CAAC,SAAS,OAAO,GAAG,MAAM;IACvD,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAS;IAC7B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAS;IACjC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAoB;IACzC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAS;IAClC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAS;IAElC,OAAO,CAAC,GAAG,CAAW;IACtB,OAAO,CAAC,UAAU,CAA+B;IACjD,OAAO,CAAC,QAAQ,CAA4B;gBAEhC,IAAI,EAAE,wBAAwB;IAQ1C;;;OAGG;IACH,IAAI,CAAC,MAAM,EAAE,CAAC,GAAG,IAAI;IAarB,kEAAkE;IAC5D,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;IAO/B,OAAO,CAAC,KAAK;YAaC,QAAQ;YA0BR,kBAAkB;IA2DhC,OAAO,CAAC,aAAa;CAMtB"}
@@ -1,208 +0,0 @@
1
- /**
2
- * Fire-and-forget HTTP transport with micro-batching.
3
- *
4
- * Records are buffered in memory and flushed to the consumer when either:
5
- * - the buffer reaches `maxBatch` records, OR
6
- * - `maxAgeMs` elapse since the first record landed (timer-driven).
7
- *
8
- * Each flush issues one POST containing `{ spans: [...] }` / `{ logs: [...] }`.
9
- * The consumer already accepts an array; single-record posts (the prior
10
- * behavior) were just N=1 batches. Trade-off: per-record latency up to
11
- * `maxAgeMs` (default 250ms); SIGKILL loses the in-flight buffer. Graceful
12
- * shutdown via `shutdown()` drains.
13
- *
14
- * Oversize guard: if the serialized batch exceeds `MAX_RECORD_BYTES`, splits
15
- * the batch in halves and re-flushes recursively until each fragment fits.
16
- * For singletons that still overflow, the blob-strip fallback kicks in
17
- * (`gen_ai.message.body`, `senpi.order_response.body`, `decision.reasoning`,
18
- * and log Body get cleared; row tagged `senpi.degraded=true`).
19
- *
20
- * Failure modes are fail-open: redactor throws → warn + emit un-redacted;
21
- * fetch fails → warn + drop the batch; oversize singleton → warn + drop.
22
- * Nothing in this layer blocks the trade path.
23
- */
24
- import { createLogger } from "../utils/logger.js";
25
- import { redactSensitiveFields } from "../tracking/spans/redact-pii.js";
26
- const logger = createLogger("[senpi-core][otel-transport]");
27
- const MAX_RECORD_BYTES = 8_000_000;
28
- const DEFAULT_MAX_BATCH = 100;
29
- const DEFAULT_MAX_AGE_MS = 250;
30
- export class OtelHttpTransport {
31
- url;
32
- apiKey;
33
- kind;
34
- maxBatch;
35
- maxAgeMs;
36
- buf = [];
37
- flushTimer = null;
38
- inFlight = new Set();
39
- constructor(opts) {
40
- this.url = opts.url;
41
- this.apiKey = opts.apiKey;
42
- this.kind = opts.kind;
43
- this.maxBatch = opts.maxBatch ?? DEFAULT_MAX_BATCH;
44
- this.maxAgeMs = opts.maxAgeMs ?? DEFAULT_MAX_AGE_MS;
45
- }
46
- /**
47
- * Enqueue a record for the next flush. Synchronous, never throws, never
48
- * blocks. Triggers an immediate flush when the buffer reaches `maxBatch`.
49
- */
50
- emit(record) {
51
- this.buf.push(record);
52
- if (this.buf.length >= this.maxBatch) {
53
- this.flush();
54
- return;
55
- }
56
- if (this.flushTimer === null) {
57
- this.flushTimer = setTimeout(() => this.flush(), this.maxAgeMs);
58
- // Don't keep the event loop alive solely for a buffered batch.
59
- this.flushTimer.unref?.();
60
- }
61
- }
62
- /** Drain the buffer and await all in-flight POSTs. Idempotent. */
63
- async shutdown() {
64
- this.flush();
65
- if (this.inFlight.size > 0) {
66
- await Promise.allSettled([...this.inFlight]);
67
- }
68
- }
69
- flush() {
70
- if (this.flushTimer !== null) {
71
- clearTimeout(this.flushTimer);
72
- this.flushTimer = null;
73
- }
74
- if (this.buf.length === 0)
75
- return;
76
- const batch = this.buf;
77
- this.buf = [];
78
- const promise = this.dispatch(batch);
79
- this.inFlight.add(promise);
80
- void promise.finally(() => this.inFlight.delete(promise));
81
- }
82
- async dispatch(batch) {
83
- try {
84
- // Redaction per record — independent failures shouldn't poison the
85
- // whole batch.
86
- await Promise.all(batch.map(async (r) => {
87
- try {
88
- await redactSensitiveFields(r);
89
- }
90
- catch (err) {
91
- logger.warn("otel redact threw; emitting un-redacted", {
92
- kind: this.kind,
93
- err: err instanceof Error ? err.message : String(err),
94
- });
95
- }
96
- }));
97
- await this.dispatchSerialized(batch);
98
- }
99
- catch (err) {
100
- logger.warn("otel emit error", {
101
- kind: this.kind,
102
- err: err instanceof Error ? err.message : String(err),
103
- });
104
- }
105
- }
106
- async dispatchSerialized(batch) {
107
- let body = this.buildEnvelope(batch);
108
- if (body.length > MAX_RECORD_BYTES) {
109
- // Try to split first — cheaper than blob-stripping when the batch as
110
- // a whole is large but individual records are reasonable.
111
- if (batch.length > 1) {
112
- const mid = batch.length >> 1;
113
- await this.dispatchSerialized(batch.slice(0, mid));
114
- await this.dispatchSerialized(batch.slice(mid));
115
- return;
116
- }
117
- // Singleton oversize → strip known blob fields and retry once.
118
- const stripped = stripBlobFields(batch[0]);
119
- if (stripped.changed) {
120
- body = this.buildEnvelope([stripped.record]);
121
- if (body.length > MAX_RECORD_BYTES) {
122
- logger.warn("otel record oversized after blob strip; dropping", {
123
- kind: this.kind,
124
- bytes: body.length,
125
- });
126
- return;
127
- }
128
- }
129
- else {
130
- logger.warn("otel record oversized; dropping", {
131
- kind: this.kind,
132
- bytes: body.length,
133
- });
134
- return;
135
- }
136
- }
137
- const headers = { "Content-Type": "application/json" };
138
- if (this.apiKey)
139
- headers.Authorization = `Bearer ${this.apiKey}`;
140
- try {
141
- const response = await fetch(this.url, {
142
- method: "POST",
143
- headers,
144
- body,
145
- signal: AbortSignal.timeout(15_000),
146
- });
147
- if (!response.ok) {
148
- const text = await response.text().catch(() => "<unreadable>");
149
- logger.warn("otel emit failed", {
150
- kind: this.kind,
151
- status: response.status,
152
- batchSize: batch.length,
153
- body: text.slice(0, 500),
154
- });
155
- }
156
- }
157
- catch (err) {
158
- logger.warn("otel emit error", {
159
- kind: this.kind,
160
- batchSize: batch.length,
161
- err: err instanceof Error ? err.message : String(err),
162
- });
163
- }
164
- }
165
- buildEnvelope(batch) {
166
- if (this.kind === "spans") {
167
- return JSON.stringify({ spans: batch });
168
- }
169
- return JSON.stringify({ logs: batch });
170
- }
171
- }
172
- // Attribute keys that may carry large blob payloads. `gen_ai.message.*` and
173
- // `senpi.order_response.*` content lives in `LogRow.Body`, not in attrs — Body
174
- // is stripped separately below — so only `decision.reasoning` belongs here.
175
- const BLOB_KEYS = ["decision.reasoning"];
176
- /**
177
- * Build a stripped copy of the record with blob attributes and (for logs)
178
- * `Body` cleared, tagged with `senpi.degraded=true` and the list of dropped
179
- * field names. Pure — the caller's input is not mutated.
180
- */
181
- function stripBlobFields(record) {
182
- const dropped = [];
183
- const isSpan = "SpanAttributes" in record;
184
- const attrSource = isSpan
185
- ? record.SpanAttributes
186
- : record.LogAttributes;
187
- const nextAttrs = { ...attrSource };
188
- for (const key of BLOB_KEYS) {
189
- if (nextAttrs[key] !== undefined) {
190
- delete nextAttrs[key];
191
- dropped.push(key);
192
- }
193
- }
194
- let bodyStripped = false;
195
- if (!isSpan && record.Body && record.Body.length > 0) {
196
- bodyStripped = true;
197
- dropped.push("Body");
198
- }
199
- if (dropped.length === 0)
200
- return { record, changed: false };
201
- nextAttrs["senpi.degraded"] = "true";
202
- nextAttrs["senpi.dropped_fields"] = JSON.stringify(dropped);
203
- const next = isSpan
204
- ? { ...record, SpanAttributes: nextAttrs }
205
- : { ...record, LogAttributes: nextAttrs, ...(bodyStripped ? { Body: "" } : {}) };
206
- return { record: next, changed: true };
207
- }
208
- //# sourceMappingURL=transport.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"transport.js","sourceRoot":"","sources":["../../src/otel/transport.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,qBAAqB,EAAE,MAAM,iCAAiC,CAAC;AAGxE,MAAM,MAAM,GAAG,YAAY,CAAC,8BAA8B,CAAC,CAAC;AAE5D,MAAM,gBAAgB,GAAG,SAAS,CAAC;AACnC,MAAM,iBAAiB,GAAG,GAAG,CAAC;AAC9B,MAAM,kBAAkB,GAAG,GAAG,CAAC;AAc/B,MAAM,OAAO,iBAAiB;IACX,GAAG,CAAS;IACZ,MAAM,CAAU;IAChB,IAAI,CAAoB;IACxB,QAAQ,CAAS;IACjB,QAAQ,CAAS;IAE1B,GAAG,GAAQ,EAAE,CAAC;IACd,UAAU,GAA0B,IAAI,CAAC;IACzC,QAAQ,GAAG,IAAI,GAAG,EAAiB,CAAC;IAE5C,YAAY,IAA8B;QACxC,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC;QACpB,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;QAC1B,IAAI,CAAC,IAAI,GAAG,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AE,GAAG,CAAC,YAAY,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC;IAC/F,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;AACzC,CAAC"}
@@ -1,62 +0,0 @@
1
- /**
2
- * ClickHouse-row record types for the V2 recording emitter.
3
- *
4
- * We POST records shaped exactly like the destination CH table rows so the
5
- * neighbour service can batch-INSERT without normalization. No OTLP envelope,
6
- * no typed `AnyValue` — all attribute values are strings (HyperDX's column
7
- * type is `Map(LowCardinality(String), String)` and never parses values as
8
- * numbers).
9
- */
10
- export type OtelSpanKind = "Internal" | "Client" | "Server" | "Producer" | "Consumer";
11
- export type OtelStatusCode = "Ok" | "Error" | "Unset";
12
- export type OtelSeverity = "trace" | "debug" | "info" | "warn" | "error" | "fatal";
13
- export interface SpanEvent {
14
- Timestamp: string;
15
- Name: string;
16
- Attributes: Record<string, string>;
17
- }
18
- export interface SpanRow {
19
- /** ns-precision DateTime64(9); start time of the span. */
20
- Timestamp: string;
21
- /** 32-hex lowercase. */
22
- TraceId: string;
23
- /** 16-hex lowercase. */
24
- SpanId: string;
25
- /** 16-hex lowercase or empty string for trace roots. */
26
- ParentSpanId: string;
27
- SpanName: string;
28
- SpanKind: OtelSpanKind;
29
- /** UInt64 ns, `endTime - startTime`. Required — HyperDX does not derive. */
30
- Duration: string;
31
- /** Duplicated from resource for the dedicated CH column. */
32
- ServiceName: string;
33
- StatusCode: OtelStatusCode;
34
- /** Empty string when unset. */
35
- StatusMessage: string;
36
- SpanAttributes: Record<string, string>;
37
- ResourceAttributes: Record<string, string>;
38
- Events: SpanEvent[];
39
- ScopeName: string;
40
- ScopeVersion: string;
41
- TraceFlags: number;
42
- TraceState: string;
43
- }
44
- export interface LogRow {
45
- Timestamp: string;
46
- /** Empty string when log is not parented to a span. */
47
- TraceId: string;
48
- /** Empty string when log is not parented to a span. */
49
- SpanId: string;
50
- ServiceName: string;
51
- SeverityText: OtelSeverity;
52
- /** OTEL semconv 1–24. HyperDX doesn't query it but include for correctness. */
53
- SeverityNumber: number;
54
- /** Stringified JSON for structured bodies; empty string when absent. */
55
- Body: string;
56
- LogAttributes: Record<string, string>;
57
- ResourceAttributes: Record<string, string>;
58
- /** Dedicated CH column — the log-type discriminator. Duplicated in
59
- * LogAttributes['event.name'] for OTel-semconv consumers. */
60
- EventName: string;
61
- }
62
- //# sourceMappingURL=types.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/otel/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,MAAM,MAAM,YAAY,GAAG,UAAU,GAAG,QAAQ,GAAG,QAAQ,GAAG,UAAU,GAAG,UAAU,CAAC;AAEtF,MAAM,MAAM,cAAc,GAAG,IAAI,GAAG,OAAO,GAAG,OAAO,CAAC;AAEtD,MAAM,MAAM,YAAY,GAAG,OAAO,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,OAAO,CAAC;AAEnF,MAAM,WAAW,SAAS;IACxB,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACpC;AAED,MAAM,WAAW,OAAO;IACtB,0DAA0D;IAC1D,SAAS,EAAE,MAAM,CAAC;IAClB,wBAAwB;IACxB,OAAO,EAAE,MAAM,CAAC;IAChB,wBAAwB;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,wDAAwD;IACxD,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,YAAY,CAAC;IACvB,4EAA4E;IAC5E,QAAQ,EAAE,MAAM,CAAC;IACjB,4DAA4D;IAC5D,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,cAAc,CAAC;IAC3B,+BAA+B;IAC/B,aAAa,EAAE,MAAM,CAAC;IACtB,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACvC,kBAAkB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC3C,MAAM,EAAE,SAAS,EAAE,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,MAAM;IACrB,SAAS,EAAE,MAAM,CAAC;IAClB,uDAAuD;IACvD,OAAO,EAAE,MAAM,CAAC;IAChB,uDAAuD;IACvD,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,YAAY,CAAC;IAC3B,+EAA+E;IAC/E,cAAc,EAAE,MAAM,CAAC;IACvB,wEAAwE;IACxE,IAAI,EAAE,MAAM,CAAC;IACb,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACtC,kBAAkB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC3C;iEAC6D;IAC7D,SAAS,EAAE,MAAM,CAAC;CACnB"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=types.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/otel/types.ts"],"names":[],"mappings":""}