@senpi/runtime 3.0.6-dev.runtime-phase-2.20260630134327 → 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.
Files changed (102) hide show
  1. package/dist/actions/llm-decision/anthropic-llm-decision.d.ts +5 -9
  2. package/dist/actions/llm-decision/anthropic-llm-decision.d.ts.map +1 -1
  3. package/dist/actions/llm-decision/anthropic-llm-decision.js +6 -86
  4. package/dist/actions/llm-decision/anthropic-llm-decision.js.map +1 -1
  5. package/dist/actions/llm-decision/factory.d.ts +0 -6
  6. package/dist/actions/llm-decision/factory.d.ts.map +1 -1
  7. package/dist/actions/llm-decision/factory.js +0 -2
  8. package/dist/actions/llm-decision/factory.js.map +1 -1
  9. package/dist/actions/llm-decision/openclaw-llm-decision.d.ts.map +1 -1
  10. package/dist/actions/llm-decision/openclaw-llm-decision.js +20 -0
  11. package/dist/actions/llm-decision/openclaw-llm-decision.js.map +1 -1
  12. package/dist/index.d.ts.map +1 -1
  13. package/dist/index.js +23 -11
  14. package/dist/index.js.map +1 -1
  15. package/dist/recording/wiring/emitter-factory.d.ts +0 -5
  16. package/dist/recording/wiring/emitter-factory.d.ts.map +1 -1
  17. package/dist/recording/wiring/emitter-factory.js +0 -18
  18. package/dist/recording/wiring/emitter-factory.js.map +1 -1
  19. package/dist/recording/wiring/index.d.ts +1 -1
  20. package/dist/recording/wiring/index.d.ts.map +1 -1
  21. package/dist/recording/wiring/index.js +1 -1
  22. package/dist/recording/wiring/index.js.map +1 -1
  23. package/dist/runtime/runtime-schema.d.ts +4 -53
  24. package/dist/runtime/runtime-schema.d.ts.map +1 -1
  25. package/dist/runtime/runtime-schema.js +4 -4
  26. package/dist/runtime/runtime-schema.js.map +1 -1
  27. package/dist/runtime/runtime.d.ts.map +1 -1
  28. package/dist/runtime/runtime.js +9 -15
  29. package/dist/runtime/runtime.js.map +1 -1
  30. package/dist/senpi/client.d.ts +10 -0
  31. package/dist/senpi/client.d.ts.map +1 -1
  32. package/dist/senpi/client.js +69 -49
  33. package/dist/senpi/client.js.map +1 -1
  34. package/dist/telemetry/metrics.d.ts +47 -0
  35. package/dist/telemetry/metrics.d.ts.map +1 -0
  36. package/dist/telemetry/metrics.js +154 -0
  37. package/dist/telemetry/metrics.js.map +1 -0
  38. package/dist/telemetry/otel-sdk.d.ts +21 -33
  39. package/dist/telemetry/otel-sdk.d.ts.map +1 -1
  40. package/dist/telemetry/otel-sdk.js +77 -50
  41. package/dist/telemetry/otel-sdk.js.map +1 -1
  42. package/dist/telemetry/tracing.d.ts +2 -1
  43. package/dist/telemetry/tracing.d.ts.map +1 -1
  44. package/dist/telemetry/tracing.js +1 -1
  45. package/dist/telemetry/tracing.js.map +1 -1
  46. package/dist/tracking/spans/constants.d.ts +4 -11
  47. package/dist/tracking/spans/constants.d.ts.map +1 -1
  48. package/dist/tracking/spans/constants.js +4 -23
  49. package/dist/tracking/spans/constants.js.map +1 -1
  50. package/dist/tracking/spans/gen-ai.d.ts +70 -0
  51. package/dist/tracking/spans/gen-ai.d.ts.map +1 -0
  52. package/dist/tracking/spans/gen-ai.js +330 -0
  53. package/dist/tracking/spans/gen-ai.js.map +1 -0
  54. package/dist/tracking/spans/index.d.ts +6 -8
  55. package/dist/tracking/spans/index.d.ts.map +1 -1
  56. package/dist/tracking/spans/index.js +6 -11
  57. package/dist/tracking/spans/index.js.map +1 -1
  58. package/dist/tracking/spans/redact-pii.d.ts +18 -20
  59. package/dist/tracking/spans/redact-pii.d.ts.map +1 -1
  60. package/dist/tracking/spans/redact-pii.js +30 -29
  61. package/dist/tracking/spans/redact-pii.js.map +1 -1
  62. package/dist/tracking/spans/span-hooks.d.ts +0 -17
  63. package/dist/tracking/spans/span-hooks.d.ts.map +1 -1
  64. package/dist/tracking/spans/span-hooks.js +407 -207
  65. package/dist/tracking/spans/span-hooks.js.map +1 -1
  66. package/package.json +1 -1
  67. package/dist/tracking/spans/fan-out-span-transport.d.ts +0 -22
  68. package/dist/tracking/spans/fan-out-span-transport.d.ts.map +0 -1
  69. package/dist/tracking/spans/fan-out-span-transport.js +0 -49
  70. package/dist/tracking/spans/fan-out-span-transport.js.map +0 -1
  71. package/dist/tracking/spans/otel/fit-row-budget.d.ts +0 -22
  72. package/dist/tracking/spans/otel/fit-row-budget.d.ts.map +0 -1
  73. package/dist/tracking/spans/otel/fit-row-budget.js +0 -91
  74. package/dist/tracking/spans/otel/fit-row-budget.js.map +0 -1
  75. package/dist/tracking/spans/otel/map-span-to-trace-row.d.ts +0 -16
  76. package/dist/tracking/spans/otel/map-span-to-trace-row.d.ts.map +0 -1
  77. package/dist/tracking/spans/otel/map-span-to-trace-row.js +0 -227
  78. package/dist/tracking/spans/otel/map-span-to-trace-row.js.map +0 -1
  79. package/dist/tracking/spans/otel/recording-span-transport.d.ts +0 -43
  80. package/dist/tracking/spans/otel/recording-span-transport.d.ts.map +0 -1
  81. package/dist/tracking/spans/otel/recording-span-transport.js +0 -67
  82. package/dist/tracking/spans/otel/recording-span-transport.js.map +0 -1
  83. package/dist/tracking/spans/otel/span-ids.d.ts +0 -22
  84. package/dist/tracking/spans/otel/span-ids.d.ts.map +0 -1
  85. package/dist/tracking/spans/otel/span-ids.js +0 -32
  86. package/dist/tracking/spans/otel/span-ids.js.map +0 -1
  87. package/dist/tracking/spans/plugin-span-tracker.d.ts +0 -9
  88. package/dist/tracking/spans/plugin-span-tracker.d.ts.map +0 -1
  89. package/dist/tracking/spans/plugin-span-tracker.js +0 -115
  90. package/dist/tracking/spans/plugin-span-tracker.js.map +0 -1
  91. package/dist/tracking/spans/span-tracker.d.ts +0 -133
  92. package/dist/tracking/spans/span-tracker.d.ts.map +0 -1
  93. package/dist/tracking/spans/span-tracker.js +0 -721
  94. package/dist/tracking/spans/span-tracker.js.map +0 -1
  95. package/dist/tracking/spans/span-transport.d.ts +0 -71
  96. package/dist/tracking/spans/span-transport.d.ts.map +0 -1
  97. package/dist/tracking/spans/span-transport.js +0 -240
  98. package/dist/tracking/spans/span-transport.js.map +0 -1
  99. package/dist/tracking/spans/types.d.ts +0 -101
  100. package/dist/tracking/spans/types.d.ts.map +0 -1
  101. package/dist/tracking/spans/types.js +0 -6
  102. package/dist/tracking/spans/types.js.map +0 -1
@@ -0,0 +1,47 @@
1
+ /**
2
+ * GenAI client metrics, mirroring `tracing.ts`: instruments are obtained through the
3
+ * `@opentelemetry/api` proxy meter, so they no-op before the SDK initialises and resolve
4
+ * the real meter afterwards. Histograms are created lazily and cached on first use so they
5
+ * bind after SDK init (not at module load). Every record helper is fully guarded — metrics
6
+ * must never throw into a caller path.
7
+ *
8
+ * Names/units/attributes follow the GenAI semantic conventions:
9
+ * - gen_ai.client.token.usage Histogram {token}
10
+ * - gen_ai.client.operation.duration Histogram s
11
+ * - gen_ai.execute_tool.duration Histogram s
12
+ * - gen_ai.invoke_agent.duration Histogram s
13
+ */
14
+ import { type Meter } from "@opentelemetry/api";
15
+ /** The single meter for our manual instruments. Resolves the no-op meter pre-init. */
16
+ export declare function getMeter(): Meter;
17
+ /** Reset cached instruments (tests only). */
18
+ export declare function __resetMetricsForTest(): void;
19
+ /** Elapsed seconds from a `Date.now()` start, clamped to non-negative. */
20
+ export declare function elapsedSeconds(startMs: number | undefined): number | undefined;
21
+ export interface GenAiOperationDims {
22
+ provider?: string;
23
+ model?: string;
24
+ }
25
+ /**
26
+ * Record token usage at chat finalize: one data point per token type present.
27
+ * Skips a dimension when its count is undefined.
28
+ */
29
+ export declare function recordTokenUsage(dims: GenAiOperationDims, tokens: {
30
+ input?: number;
31
+ output?: number;
32
+ }): void;
33
+ /** Record the chat operation duration (seconds); stamps `error.type` when set. */
34
+ export declare function recordOperationDuration(seconds: number | undefined, dims: GenAiOperationDims & {
35
+ errorType?: string;
36
+ }): void;
37
+ /** Record the tool execution duration (seconds); stamps `error.type` when set. */
38
+ export declare function recordExecuteToolDuration(seconds: number | undefined, dims: {
39
+ toolName?: string;
40
+ errorType?: string;
41
+ }): void;
42
+ /** Record the sub-agent invocation duration (seconds); stamps `error.type` when set. */
43
+ export declare function recordInvokeAgentDuration(seconds: number | undefined, dims: {
44
+ agentName?: string;
45
+ errorType?: string;
46
+ }): void;
47
+ //# sourceMappingURL=metrics.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"metrics.d.ts","sourceRoot":"","sources":["../../src/telemetry/metrics.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAA2B,KAAK,KAAK,EAAmB,MAAM,oBAAoB,CAAC;AAK1F,sFAAsF;AACtF,wBAAgB,QAAQ,IAAI,KAAK,CAEhC;AASD,6CAA6C;AAC7C,wBAAgB,qBAAqB,IAAI,IAAI,CAK5C;AAmDD,0EAA0E;AAC1E,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAG9E;AAED,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAC9B,IAAI,EAAE,kBAAkB,EACxB,MAAM,EAAE;IAAE,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,GAC1C,IAAI,CAiBN;AAED,kFAAkF;AAClF,wBAAgB,uBAAuB,CACrC,OAAO,EAAE,MAAM,GAAG,SAAS,EAC3B,IAAI,EAAE,kBAAkB,GAAG;IAAE,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,GAChD,IAAI,CAeN;AAED,kFAAkF;AAClF,wBAAgB,yBAAyB,CACvC,OAAO,EAAE,MAAM,GAAG,SAAS,EAC3B,IAAI,EAAE;IAAE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,GAC9C,IAAI,CAcN;AAED,wFAAwF;AACxF,wBAAgB,yBAAyB,CACvC,OAAO,EAAE,MAAM,GAAG,SAAS,EAC3B,IAAI,EAAE;IAAE,SAAS,CAAC,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,GAC/C,IAAI,CAcN"}
@@ -0,0 +1,154 @@
1
+ /**
2
+ * GenAI client metrics, mirroring `tracing.ts`: instruments are obtained through the
3
+ * `@opentelemetry/api` proxy meter, so they no-op before the SDK initialises and resolve
4
+ * the real meter afterwards. Histograms are created lazily and cached on first use so they
5
+ * bind after SDK init (not at module load). Every record helper is fully guarded — metrics
6
+ * must never throw into a caller path.
7
+ *
8
+ * Names/units/attributes follow the GenAI semantic conventions:
9
+ * - gen_ai.client.token.usage Histogram {token}
10
+ * - gen_ai.client.operation.duration Histogram s
11
+ * - gen_ai.execute_tool.duration Histogram s
12
+ * - gen_ai.invoke_agent.duration Histogram s
13
+ */
14
+ import { metrics } from "@opentelemetry/api";
15
+ /** Instrumentation scope; matches the tracer/logger scope. */
16
+ const METER_NAME = "senpi-trading-runtime";
17
+ /** The single meter for our manual instruments. Resolves the no-op meter pre-init. */
18
+ export function getMeter() {
19
+ return metrics.getMeter(METER_NAME);
20
+ }
21
+ // Lazily created + cached histograms — built on first record so they bind to the real
22
+ // meter after SDK init rather than to the no-op meter at module load.
23
+ let tokenUsage;
24
+ let operationDuration;
25
+ let executeToolDuration;
26
+ let invokeAgentDuration;
27
+ /** Reset cached instruments (tests only). */
28
+ export function __resetMetricsForTest() {
29
+ tokenUsage = undefined;
30
+ operationDuration = undefined;
31
+ executeToolDuration = undefined;
32
+ invokeAgentDuration = undefined;
33
+ }
34
+ function tokenUsageInstrument() {
35
+ if (!tokenUsage) {
36
+ tokenUsage = getMeter().createHistogram("gen_ai.client.token.usage", {
37
+ description: "Number of input/output tokens used by a GenAI request",
38
+ unit: "{token}",
39
+ });
40
+ }
41
+ return tokenUsage;
42
+ }
43
+ function operationDurationInstrument() {
44
+ if (!operationDuration) {
45
+ operationDuration = getMeter().createHistogram("gen_ai.client.operation.duration", {
46
+ description: "Duration of a GenAI client operation",
47
+ unit: "s",
48
+ });
49
+ }
50
+ return operationDuration;
51
+ }
52
+ function executeToolDurationInstrument() {
53
+ if (!executeToolDuration) {
54
+ executeToolDuration = getMeter().createHistogram("gen_ai.execute_tool.duration", {
55
+ description: "Duration of a GenAI tool execution",
56
+ unit: "s",
57
+ });
58
+ }
59
+ return executeToolDuration;
60
+ }
61
+ function invokeAgentDurationInstrument() {
62
+ if (!invokeAgentDuration) {
63
+ invokeAgentDuration = getMeter().createHistogram("gen_ai.invoke_agent.duration", {
64
+ description: "Duration of a GenAI sub-agent invocation",
65
+ unit: "s",
66
+ });
67
+ }
68
+ return invokeAgentDuration;
69
+ }
70
+ /** Drop undefined/null attributes so we never stamp hollow dimensions. */
71
+ function defined(attrs) {
72
+ const out = {};
73
+ for (const [k, v] of Object.entries(attrs)) {
74
+ if (v !== undefined && v !== null)
75
+ out[k] = v;
76
+ }
77
+ return out;
78
+ }
79
+ /** Elapsed seconds from a `Date.now()` start, clamped to non-negative. */
80
+ export function elapsedSeconds(startMs) {
81
+ if (typeof startMs !== "number" || !Number.isFinite(startMs))
82
+ return undefined;
83
+ return Math.max(0, (Date.now() - startMs) / 1000);
84
+ }
85
+ /**
86
+ * Record token usage at chat finalize: one data point per token type present.
87
+ * Skips a dimension when its count is undefined.
88
+ */
89
+ export function recordTokenUsage(dims, tokens) {
90
+ try {
91
+ const base = {
92
+ "gen_ai.operation.name": "chat",
93
+ "gen_ai.provider.name": dims.provider,
94
+ "gen_ai.request.model": dims.model,
95
+ };
96
+ const inst = tokenUsageInstrument();
97
+ if (typeof tokens.input === "number" && Number.isFinite(tokens.input)) {
98
+ inst.record(tokens.input, defined({ ...base, "gen_ai.token.type": "input" }));
99
+ }
100
+ if (typeof tokens.output === "number" && Number.isFinite(tokens.output)) {
101
+ inst.record(tokens.output, defined({ ...base, "gen_ai.token.type": "output" }));
102
+ }
103
+ }
104
+ catch {
105
+ // Metrics must never break the caller.
106
+ }
107
+ }
108
+ /** Record the chat operation duration (seconds); stamps `error.type` when set. */
109
+ export function recordOperationDuration(seconds, dims) {
110
+ if (seconds === undefined)
111
+ return;
112
+ try {
113
+ operationDurationInstrument().record(seconds, defined({
114
+ "gen_ai.operation.name": "chat",
115
+ "gen_ai.provider.name": dims.provider,
116
+ "gen_ai.request.model": dims.model,
117
+ "error.type": dims.errorType,
118
+ }));
119
+ }
120
+ catch {
121
+ // Metrics must never break the caller.
122
+ }
123
+ }
124
+ /** Record the tool execution duration (seconds); stamps `error.type` when set. */
125
+ export function recordExecuteToolDuration(seconds, dims) {
126
+ if (seconds === undefined)
127
+ return;
128
+ try {
129
+ executeToolDurationInstrument().record(seconds, defined({
130
+ "gen_ai.operation.name": "execute_tool",
131
+ "gen_ai.tool.name": dims.toolName,
132
+ "error.type": dims.errorType,
133
+ }));
134
+ }
135
+ catch {
136
+ // Metrics must never break the caller.
137
+ }
138
+ }
139
+ /** Record the sub-agent invocation duration (seconds); stamps `error.type` when set. */
140
+ export function recordInvokeAgentDuration(seconds, dims) {
141
+ if (seconds === undefined)
142
+ return;
143
+ try {
144
+ invokeAgentDurationInstrument().record(seconds, defined({
145
+ "gen_ai.operation.name": "invoke_agent",
146
+ "gen_ai.agent.name": dims.agentName,
147
+ "error.type": dims.errorType,
148
+ }));
149
+ }
150
+ catch {
151
+ // Metrics must never break the caller.
152
+ }
153
+ }
154
+ //# sourceMappingURL=metrics.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"metrics.js","sourceRoot":"","sources":["../../src/telemetry/metrics.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,OAAO,EAA+C,MAAM,oBAAoB,CAAC;AAE1F,8DAA8D;AAC9D,MAAM,UAAU,GAAG,uBAAuB,CAAC;AAE3C,sFAAsF;AACtF,MAAM,UAAU,QAAQ;IACtB,OAAO,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;AACtC,CAAC;AA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QACH,6BAA6B,EAAE,CAAC,MAAM,CACpC,OAAO,EACP,OAAO,CAAC;YACN,uBAAuB,EAAE,cAAc;YACvC,mBAAmB,EAAE,IAAI,CAAC,SAAS;YACnC,YAAY,EAAE,IAAI,CAAC,SAAS;SAC7B,CAAC,CACH,CAAC;IACJ,CAAC;IAAC,MAAM,CAAC;QACP,uCAAuC;IACzC,CAAC;AACH,CAAC"}
@@ -1,32 +1,25 @@
1
1
  /**
2
- * OpenTelemetry SDK stand-up: initialises HyperDX's OTel distribution
3
- * (`@hyperdx/node-opentelemetry`) — auto-instrumentation, console-capture logs,
4
- * uncaught-exception capture — against a self-hosted OTLP collector, with a
5
- * standardised resource-attribute set.
2
+ * OpenTelemetry SDK stand-up: HyperDX's OTel distribution (`@hyperdx/node-opentelemetry`)
3
+ * — auto-instrumentation + uncaught-exception capture — against a self-hosted OTLP collector,
4
+ * with a process-stable resource-attribute set.
6
5
  *
7
- * Init runs from `Runtime.start()`, not at process entry: resource attributes
8
- * are immutable after `init()` and are built from the recipe/strategy identity
9
- * and the `telemetry.enabled` gate, none of which exist before a runtime starts.
10
- * On Node >= 22 the diagnostics_channel HTTP instrumentation hooks lazily, so
11
- * deferring init still instruments outbound HTTP.
6
+ * Init runs from plugin `register()` (process scope): the agent hooks register there, before
7
+ * any runtime, and emit through this SDK's tracer. Only process-stable values ride the resource
8
+ * (`service.*`, `deployment.environment`, `user.id`), so init need not wait for a runtime.
12
9
  *
13
- * The package is imported dynamically (not at top level) because it captures the
14
- * OTLP transport config from the `OTEL_EXPORTER_OTLP_*` env vars at module-load time
15
- * and exposes no endpoint/header option on `init()` — so those vars must be set before
16
- * it loads.
10
+ * Gated by OTLP-config presence: inits iff an OTLP endpoint env is set (no enable flag, no
11
+ * localhost default). No endpoint ⇒ no SDK and the global tracer/logger no-op. If a non-noop
12
+ * global `TracerProvider` already exists (the gateway's `diagnostics-otel` owns it), we stand
13
+ * down and emit through the global API — one SDK per process, first writer wins.
17
14
  *
18
- * Under openclaw the operator must set ALL of these in the container env (the SDK does
19
- * not derive them; this module only defaults the base endpoint below, for standalone runs):
20
- * OTEL_EXPORTER_OTLP_ENDPOINT (base, e.g. http://host.docker.internal:4318)
21
- * OTEL_EXPORTER_OTLP_TRACES_ENDPOINT (.../v1/traces)
22
- * OTEL_EXPORTER_OTLP_LOGS_ENDPOINT (.../v1/logs)
23
- * OTEL_EXPORTER_OTLP_METRICS_ENDPOINT (.../v1/metrics)
24
- * OTEL_EXPORTER_OTLP_HEADERS (e.g. Authorization=<collector-token>)
25
- * See docs/runtime-docs/runtime-api.md (Tracing) for why each is required.
15
+ * The package is imported dynamically: it reads `OTEL_EXPORTER_OTLP_*` at module-load and
16
+ * exposes no init() option for them, so the env must be set first. Under openclaw the operator
17
+ * sets all of these (the SDK derives none):
18
+ * OTEL_EXPORTER_OTLP_ENDPOINT / _TRACES_ENDPOINT / _LOGS_ENDPOINT / _METRICS_ENDPOINT / _HEADERS
19
+ * See docs/runtime-docs/runtime-api.md (Tracing).
26
20
  */
27
- import type { IdentityEnvelope } from "../recording/identity.js";
28
- /** Base OTLP endpoint defaulted for standalone Node runs only; ignored under openclaw (see module header). */
29
- export declare const DEFAULT_OTLP_ENDPOINT = "http://localhost:4318";
21
+ /** True when any OTLP endpoint env is set — the gate for standing up the plugin's SDK. */
22
+ export declare function isOtlpEndpointConfigured(): boolean;
30
23
  /**
31
24
  * Whether {@link initOtelSdk} has completed. Code that loads `@hyperdx/node-opentelemetry`
32
25
  * lazily (e.g. per-trace attribute stamping) gates on this so the package — which captures
@@ -72,22 +65,17 @@ export interface OtelResourceExtras {
72
65
  * emit-time identity stamp (both reading the same per-runtime identity context).
73
66
  */
74
67
  export declare function buildOtelResourceAttributes(serviceName: string, extras: OtelResourceExtras): string;
75
- /**
76
- * Resolve the OTLP endpoint: `OTEL_EXPORTER_OTLP_ENDPOINT` env >
77
- * {@link DEFAULT_OTLP_ENDPOINT}.
78
- */
79
- export declare function resolveOtlpEndpoint(): string;
80
68
  export interface InitOtelSdkParams {
81
- readonly enabled: boolean;
82
- /** Built only on the live path to preserve laziness. */
83
- readonly identity: () => IdentityEnvelope;
84
69
  /** SENPI_API_KEY JWT (the MCP bearer) — decoded locally for `user.id`. */
85
70
  readonly userToken?: string;
71
+ /** Plugin version → `service.version`. */
86
72
  readonly serviceVersion: string;
87
73
  }
88
74
  /**
89
75
  * Initialise the OTel SDK. Idempotent, side-effecting, and never crashes boot:
90
- * no-ops when disabled, already initialised, or under test.
76
+ * no-ops when no OTLP endpoint is configured, when a real global TracerProvider
77
+ * already exists (the gateway owns it — we emit through the global API instead),
78
+ * when already initialised, or under test.
91
79
  */
92
80
  export declare function initOtelSdk(params: InitOtelSdkParams): Promise<void>;
93
81
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"otel-sdk.d.ts","sourceRoot":"","sources":["../../src/telemetry/otel-sdk.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAGH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAKjE,8GAA8G;AAC9G,eAAO,MAAM,qBAAqB,0BAA0B,CAAC;AA0E7D;;;;GAIG;AACH,wBAAgB,iBAAiB,IAAI,OAAO,CAE3C;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAkB/E;AAED,qEAAqE;AACrE,MAAM,WAAW,kBAAkB;IACjC,uFAAuF;IACvF,QAAQ,CAAC,iBAAiB,CAAC,EAAE,MAAM,CAAC;IACpC,2BAA2B;IAC3B,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,CAAC;IACjC,kCAAkC;IAClC,QAAQ,CAAC,qBAAqB,CAAC,EAAE,MAAM,CAAC;IACxC,2CAA2C;IAC3C,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB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;;;;;;;;GAkBG;AACH,wBAAgB,2BAA2B,CACzC,WAAW,EAAE,MAAM,EACnB,MAAM,EAAE,kBAAkB,GACzB,MAAM,CAaR;AAED,MAAM,WAAW,iBAAiB;IAChC,0EAA0E;IAC1E,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,0CAA0C;IAC1C,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;CACjC;AAKD;;;;;GAKG;AACH,wBAAsB,WAAW,CAAC,MAAM,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC,CAuF1E;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,eAAe,IAAI,OAAO,CAAC,IAAI,CAAC,CAcrD"}
@@ -1,34 +1,66 @@
1
1
  /**
2
- * OpenTelemetry SDK stand-up: initialises HyperDX's OTel distribution
3
- * (`@hyperdx/node-opentelemetry`) — auto-instrumentation, console-capture logs,
4
- * uncaught-exception capture — against a self-hosted OTLP collector, with a
5
- * standardised resource-attribute set.
2
+ * OpenTelemetry SDK stand-up: HyperDX's OTel distribution (`@hyperdx/node-opentelemetry`)
3
+ * — auto-instrumentation + uncaught-exception capture — against a self-hosted OTLP collector,
4
+ * with a process-stable resource-attribute set.
6
5
  *
7
- * Init runs from `Runtime.start()`, not at process entry: resource attributes
8
- * are immutable after `init()` and are built from the recipe/strategy identity
9
- * and the `telemetry.enabled` gate, none of which exist before a runtime starts.
10
- * On Node >= 22 the diagnostics_channel HTTP instrumentation hooks lazily, so
11
- * deferring init still instruments outbound HTTP.
6
+ * Init runs from plugin `register()` (process scope): the agent hooks register there, before
7
+ * any runtime, and emit through this SDK's tracer. Only process-stable values ride the resource
8
+ * (`service.*`, `deployment.environment`, `user.id`), so init need not wait for a runtime.
12
9
  *
13
- * The package is imported dynamically (not at top level) because it captures the
14
- * OTLP transport config from the `OTEL_EXPORTER_OTLP_*` env vars at module-load time
15
- * and exposes no endpoint/header option on `init()` — so those vars must be set before
16
- * it loads.
10
+ * Gated by OTLP-config presence: inits iff an OTLP endpoint env is set (no enable flag, no
11
+ * localhost default). No endpoint ⇒ no SDK and the global tracer/logger no-op. If a non-noop
12
+ * global `TracerProvider` already exists (the gateway's `diagnostics-otel` owns it), we stand
13
+ * down and emit through the global API — one SDK per process, first writer wins.
17
14
  *
18
- * Under openclaw the operator must set ALL of these in the container env (the SDK does
19
- * not derive them; this module only defaults the base endpoint below, for standalone runs):
20
- * OTEL_EXPORTER_OTLP_ENDPOINT (base, e.g. http://host.docker.internal:4318)
21
- * OTEL_EXPORTER_OTLP_TRACES_ENDPOINT (.../v1/traces)
22
- * OTEL_EXPORTER_OTLP_LOGS_ENDPOINT (.../v1/logs)
23
- * OTEL_EXPORTER_OTLP_METRICS_ENDPOINT (.../v1/metrics)
24
- * OTEL_EXPORTER_OTLP_HEADERS (e.g. Authorization=<collector-token>)
25
- * See docs/runtime-docs/runtime-api.md (Tracing) for why each is required.
15
+ * The package is imported dynamically: it reads `OTEL_EXPORTER_OTLP_*` at module-load and
16
+ * exposes no init() option for them, so the env must be set first. Under openclaw the operator
17
+ * sets all of these (the SDK derives none):
18
+ * OTEL_EXPORTER_OTLP_ENDPOINT / _TRACES_ENDPOINT / _LOGS_ENDPOINT / _METRICS_ENDPOINT / _HEADERS
19
+ * See docs/runtime-docs/runtime-api.md (Tracing).
26
20
  */
27
21
  import { randomUUID } from "node:crypto";
22
+ import { trace } from "@opentelemetry/api";
28
23
  import { createLogger } from "../utils/logger.js";
29
24
  const logger = createLogger("telemetry/otel-sdk");
30
- /** Base OTLP endpoint defaulted for standalone Node runs only; ignored under openclaw (see module header). */
31
- export const DEFAULT_OTLP_ENDPOINT = "http://localhost:4318";
25
+ /** Per-signal OTLP endpoint env vars; presence of any (or the base) is the on-switch. */
26
+ const OTLP_ENDPOINT_ENV_VARS = [
27
+ "OTEL_EXPORTER_OTLP_ENDPOINT",
28
+ "OTEL_EXPORTER_OTLP_TRACES_ENDPOINT",
29
+ "OTEL_EXPORTER_OTLP_LOGS_ENDPOINT",
30
+ "OTEL_EXPORTER_OTLP_METRICS_ENDPOINT",
31
+ ];
32
+ /** True when any OTLP endpoint env is set — the gate for standing up the plugin's SDK. */
33
+ export function isOtlpEndpointConfigured() {
34
+ return OTLP_ENDPOINT_ENV_VARS.some((name) => {
35
+ const value = process.env[name];
36
+ return typeof value === "string" && value.trim().length > 0;
37
+ });
38
+ }
39
+ /**
40
+ * True when a real (non-noop) global `TracerProvider` is already registered — i.e.
41
+ * another SDK (the gateway's `diagnostics-otel`) owns the slot. The global API hands
42
+ * back a `ProxyTracerProvider` until `setGlobalTracerProvider` runs; before that its
43
+ * delegate is the no-op provider. We detect "real" by checking whether a delegate
44
+ * provider has been set: `getDelegate()` exists on the proxy and differs from the
45
+ * no-op. Best-effort — on any uncertainty we treat it as "not owned" and init our own.
46
+ */
47
+ function globalTracerProviderIsReal() {
48
+ try {
49
+ const provider = trace.getTracerProvider();
50
+ if (typeof provider?.getDelegate !== "function") {
51
+ // Not a ProxyTracerProvider — a concrete provider is registered directly.
52
+ return true;
53
+ }
54
+ const delegate = provider.getDelegate();
55
+ if (delegate == null)
56
+ return false;
57
+ // The proxy's default delegate is the NoopTracerProvider; anything else is real.
58
+ return delegate.constructor?.name !== "NoopTracerProvider";
59
+ }
60
+ catch {
61
+ return false;
62
+ }
63
+ }
32
64
  /**
33
65
  * Process-level instance id for `service.instance.id`. Distinct from the
34
66
  * per-runtime `IdentityEnvelope.bootId`: resource attributes are process-global,
@@ -50,7 +82,7 @@ const PROCESS_INSTANCE_ID = randomUUID();
50
82
  * Fix: enable our own `UndiciInstrumentation`; with no provider set it resolves the
51
83
  * global one `init()` registered, and HyperDX's instance stays disabled (no double
52
84
  * instrumentation). Best-effort — a failure must not fail boot. Also a prerequisite
53
- * for the manual `mcp.*`/`dsl.*` spans (Task 9b), which assume outbound `fetch` calls
85
+ * for the manual `mcp.*`/`dsl.*` spans, which assume outbound `fetch` calls
54
86
  * auto-nest as HTTP children.
55
87
  *
56
88
  * Seen with `@hyperdx/node-opentelemetry` 0.11 / `instrumentation-undici` 0.28, Node 24
@@ -147,38 +179,37 @@ export function buildOtelResourceAttributes(serviceName, extras) {
147
179
  .map(([key, value]) => `${key}=${encodeURIComponent(String(value))}`)
148
180
  .join(",");
149
181
  }
150
- /**
151
- * Resolve the OTLP endpoint: `OTEL_EXPORTER_OTLP_ENDPOINT` env >
152
- * {@link DEFAULT_OTLP_ENDPOINT}.
153
- */
154
- export function resolveOtlpEndpoint() {
155
- const envOverride = process.env.OTEL_EXPORTER_OTLP_ENDPOINT?.trim();
156
- if (envOverride)
157
- return envOverride;
158
- return DEFAULT_OTLP_ENDPOINT;
159
- }
182
+ /** `service.name` for the plugin-owned resource; matches the tracer/logger scope. */
183
+ const SERVICE_NAME = "senpi-trading-runtime";
160
184
  /**
161
185
  * Initialise the OTel SDK. Idempotent, side-effecting, and never crashes boot:
162
- * no-ops when disabled, already initialised, or under test.
186
+ * no-ops when no OTLP endpoint is configured, when a real global TracerProvider
187
+ * already exists (the gateway owns it — we emit through the global API instead),
188
+ * when already initialised, or under test.
163
189
  */
164
190
  export async function initOtelSdk(params) {
165
191
  if (initialized)
166
192
  return;
167
- if (!params.enabled) {
168
- logger.debug("OTel SDK init skipped: telemetry disabled");
193
+ // Presence of OTLP config is the on-switch — no endpoint means telemetry off.
194
+ if (!isOtlpEndpointConfigured()) {
195
+ logger.debug("OTel SDK init skipped: no OTLP endpoint configured");
169
196
  return;
170
197
  }
171
- // Skip under test: the enable gate defaults to true, so without this the SDK
172
- // would init (start exporters, patch core modules) during the vitest run.
198
+ // Stand down if another SDK (the gateway's diagnostics-otel) already owns the
199
+ // global provider — a second registration drops spans and splits resource identity.
200
+ if (globalTracerProviderIsReal()) {
201
+ logger.info("OTel SDK init skipped: a global TracerProvider already exists; emitting through the global API");
202
+ initialized = true;
203
+ return;
204
+ }
205
+ // Skip under test: the SDK would start exporters and patch core modules during vitest.
173
206
  if (process.env.VITEST || process.env.NODE_ENV === "test") {
174
207
  logger.debug("OTel SDK init skipped: running under test");
175
208
  return;
176
209
  }
177
210
  try {
178
- const identity = params.identity();
179
211
  // Commit the guard before any fallible work: a failed init must not let a
180
- // later Runtime.start() re-enter and double-append OTEL_RESOURCE_ATTRIBUTES.
181
- // identity() above threw before this, so env is still untouched on that path.
212
+ // later caller re-enter and double-append OTEL_RESOURCE_ATTRIBUTES.
182
213
  initialized = true;
183
214
  // Source the environment label from NODE_ENV (Node-standard). Pass the value
184
215
  // through verbatim (so `staging`/custom envs are faithful), defaulting to
@@ -188,7 +219,7 @@ export async function initOtelSdk(params) {
188
219
  const deploymentEnvironment = nodeEnv && nodeEnv.length > 0 ? nodeEnv : "development";
189
220
  const userId = decodeSenpiUserId(params.userToken);
190
221
  // Append to any host-set value rather than clobber operator attrs.
191
- const ourAttrs = buildOtelResourceAttributes(identity.service, {
222
+ const ourAttrs = buildOtelResourceAttributes(SERVICE_NAME, {
192
223
  serviceInstanceId: PROCESS_INSTANCE_ID,
193
224
  serviceVersion: params.serviceVersion,
194
225
  deploymentEnvironment,
@@ -198,18 +229,14 @@ export async function initOtelSdk(params) {
198
229
  process.env.OTEL_RESOURCE_ATTRIBUTES = existingAttrs
199
230
  ? `${existingAttrs},${ourAttrs}`
200
231
  : ourAttrs;
201
- // Must be set before the import below — HyperDX reads it at module-load.
202
- if (!process.env.OTEL_EXPORTER_OTLP_ENDPOINT) {
203
- process.env.OTEL_EXPORTER_OTLP_ENDPOINT = resolveOtlpEndpoint();
204
- }
205
- // Dynamic import: loads only now, after the env var above is set.
232
+ // Dynamic import: loads only now, after the endpoint env is confirmed set.
206
233
  const hyperdx = (await import("@hyperdx/node-opentelemetry"));
207
234
  hyperdxModule = hyperdx;
208
235
  hyperdx.init({
209
236
  // No apiKey on init(): the exporter authenticates to the collector via the
210
237
  // Authorization header in OTEL_EXPORTER_OTLP_HEADERS (read from env at
211
238
  // module-load), not through the SDK's HyperDX apiKey field.
212
- service: identity.service,
239
+ service: SERVICE_NAME,
213
240
  // Off: createLogger() emits structured LogRecords through the OTel Logs API directly,
214
241
  // so capturing console.* would duplicate every log (flattened, lossy) into the collector.
215
242
  // stdout is untouched — the local human line still prints.
@@ -228,7 +255,7 @@ export async function initOtelSdk(params) {
228
255
  });
229
256
  await reinstrumentUndici();
230
257
  logger.info("OTel SDK initialised", {
231
- service: identity.service,
258
+ service: SERVICE_NAME,
232
259
  endpoint: process.env.OTEL_EXPORTER_OTLP_ENDPOINT,
233
260
  deploymentEnvironment,
234
261
  });
@@ -1 +1 @@
1
- {"version":3,"file":"otel-sdk.js","sourceRoot":"","sources":["../../src/telemetry/otel-sdk.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD,MAAM,MAAM,GAAG,YAAY,CAAC,oBAAoB,CAAC,CAAC;AAElD,8GAA8G;AAC9G,MAAM,CAAC,MAAM,qBAAqB,GAAG,uBAAuB,CAAC;AAE7D;;;;;GAKG;AACH,MAAM,mBAAmB,GAAG,UAAU,EAAE,CAAC;AAuBzC;;;;;;;;;;;;;;;;;;;GAmBG;AACH,KAAK,UAAU,kBAAkB;IAC/B,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,CAAC,MAAM,MAAM,CAAC,uCAAuC,CAAC,CAEjE,CAAC;QACF,IAAI,GAAG,CAAC,qBAAqB,EAAE,CAAC,MAAM,EAAE,CAAC;QACzC,MAAM,CAAC,KAAK,CAAC,qDAAqD,CAAC,CAAC;IACtE,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,MAAM,CAAC,IAAI,CAAC,gFAAgF,EAAE;YAC5F,GAAG,EAAE,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC;SACtD,CAAC,CAAC;IACL,CAAC;AACH,CA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YAC1E,GAAG,EAAE,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC;SACtD,CAAC,CAAC;IACL,CAAC;AACH,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe;IACnC,IAAI,CAAC,WAAW,IAAI,CAAC,aAAa;QAAE,OAAO;IAC3C,iFAAiF;IACjF,WAAW,GAAG,KAAK,CAAC;IACpB,MAAM,GAAG,GAAG,aAAa,CAAC;IAC1B,aAAa,GAAG,SAAS,CAAC;IAC1B,IAAI,CAAC;QACH,MAAM,GAAG,CAAC,QAAQ,EAAE,CAAC;QACrB,MAAM,CAAC,KAAK,CAAC,2CAA2C,CAAC,CAAC;IAC5D,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,MAAM,CAAC,IAAI,CAAC,2DAA2D,EAAE;YACvE,GAAG,EAAE,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC;SACtD,CAAC,CAAC;IACL,CAAC;AACH,CAAC"}
@@ -5,7 +5,7 @@
5
5
  * is not initialised (telemetry off, or under test) the API resolves a no-op tracer,
6
6
  * so `withSpan` runs the callback with near-zero overhead — no `enabled` gate needed.
7
7
  */
8
- import { type Span, type Attributes, type Tracer } from "@opentelemetry/api";
8
+ import { type Span, type SpanKind, type Attributes, type Tracer } from "@opentelemetry/api";
9
9
  /** The single tracer for our manual spans. Resolves the no-op tracer pre-init. */
10
10
  export declare function getTracer(): Tracer;
11
11
  /**
@@ -28,5 +28,6 @@ export declare function getTracer(): Tracer;
28
28
  */
29
29
  export declare function withSpan<T>(name: string, attributes: Attributes, fn: (span: Span) => Promise<T>, options?: {
30
30
  expected?: (err: unknown) => boolean;
31
+ kind?: SpanKind;
31
32
  }): Promise<T>;
32
33
  //# sourceMappingURL=tracing.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"tracing.d.ts","sourceRoot":"","sources":["../../src/telemetry/tracing.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAGL,KAAK,IAAI,EACT,KAAK,UAAU,EACf,KAAK,MAAM,EACZ,MAAM,oBAAoB,CAAC;AAK5B,kFAAkF;AAClF,wBAAgB,SAAS,IAAI,MAAM,CAElC;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,QAAQ,CAAC,CAAC,EACxB,IAAI,EAAE,MAAM,EACZ,UAAU,EAAE,UAAU,EACtB,EAAE,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,OAAO,CAAC,CAAC,CAAC,EAC9B,OAAO,CAAC,EAAE;IAAE,QAAQ,CAAC,EAAE,CAAC,GAAG,EAAE,OAAO,KAAK,OAAO,CAAA;CAAE,GACjD,OAAO,CAAC,CAAC,CAAC,CA8BZ"}
1
+ {"version":3,"file":"tracing.d.ts","sourceRoot":"","sources":["../../src/telemetry/tracing.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAGL,KAAK,IAAI,EACT,KAAK,QAAQ,EACb,KAAK,UAAU,EACf,KAAK,MAAM,EACZ,MAAM,oBAAoB,CAAC;AAK5B,kFAAkF;AAClF,wBAAgB,SAAS,IAAI,MAAM,CAElC;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,QAAQ,CAAC,CAAC,EACxB,IAAI,EAAE,MAAM,EACZ,UAAU,EAAE,UAAU,EACtB,EAAE,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,OAAO,CAAC,CAAC,CAAC,EAC9B,OAAO,CAAC,EAAE;IAAE,QAAQ,CAAC,EAAE,CAAC,GAAG,EAAE,OAAO,KAAK,OAAO,CAAC;IAAC,IAAI,CAAC,EAAE,QAAQ,CAAA;CAAE,GAClE,OAAO,CAAC,CAAC,CAAC,CA8BZ"}
@@ -31,7 +31,7 @@ export function getTracer() {
31
31
  * error nor corrupt its result.
32
32
  */
33
33
  export function withSpan(name, attributes, fn, options) {
34
- return getTracer().startActiveSpan(name, { attributes }, async (span) => {
34
+ return getTracer().startActiveSpan(name, { attributes, kind: options?.kind }, async (span) => {
35
35
  try {
36
36
  return await fn(span);
37
37
  }
@@ -1 +1 @@
1
- {"version":3,"file":"tracing.js","sourceRoot":"","sources":["../../src/telemetry/tracing.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EACL,KAAK,EACL,cAAc,GAIf,MAAM,oBAAoB,CAAC;AAE5B,iEAAiE;AACjE,MAAM,WAAW,GAAG,uBAAuB,CAAC;AAE5C,kFAAkF;AAClF,MAAM,UAAU,SAAS;IACvB,OAAO,KAAK,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;AACtC,CAAC;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,QAAQ,CACtB,IAAY,EACZ,UAAsB,EACtB,EAA8B,EAC9B,OAAkD;IAElD,OAAO,SAAS,EAAE,CAAC,eAAe,CAAC,IAAI,EAAE,EAAE,UAAU,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE;QACtE,IAAI,CAAC;YACH,OAAO,MAAM,EAAE,CAAC,IAAI,CAAC,CAAC;QACxB,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,IAAI,QAAQ,GAAG,KAAK,CAAC;YACrB,IAAI,CAAC;gBACH,QAAQ,GAAG,OAAO,EAAE,QAAQ,EAAE,CAAC,GAAG,CAAC,IAAI,KAAK,CAAC;YAC/C,CAAC;YAAC,MAAM,CAAC;gBACP,4EAA4E;YAC9E,CAAC;YACD,IAAI,QAAQ;gBAAE,MAAM,GAAG,CAAC;YACxB,IAAI,CAAC;gBACH,IAAI,CAAC,eAAe,CAAC,GAAY,CAAC,CAAC;gBACnC,IAAI,CAAC,SAAS,CAAC;oBACb,IAAI,EAAE,cAAc,CAAC,KAAK;oBAC1B,OAAO,EAAE,GAAG,YAAY,KAAK,CAAC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QAAQ;gBAAE,MAAM,GAAG,CAAC;YACxB,IAAI,CAAC;gBACH,IAAI,CAAC,eAAe,CAAC,GAAY,CAAC,CAAC;gBACnC,IAAI,CAAC,SAAS,CAAC;oBACb,IAAI,EAAE,cAAc,CAAC,KAAK;oBAC1B,OAAO,EAAE,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC;iBAC1D,CAAC,CAAC;YACL,CAAC;YAAC,MAAM,CAAC;gBACP,wEAAwE;YAC1E,CAAC;YACD,MAAM,GAAG,CAAC;QACZ,CAAC;gBAAS,CAAC;YACT,IAAI,CAAC;gBACH,IAAI,CAAC,GAAG,EAAE,CAAC;YACb,CAAC;YAAC,MAAM,CAAC;gBACP,+DAA+D;YACjE,CAAC;QACH,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -1,16 +1,9 @@
1
1
  /**
2
- * Span telemetry constants: API path, batching thresholds, orphan-sweep timings.
2
+ * Span telemetry constants.
3
+ *
4
+ * Header names used to cross the runtime → OpenClaw HTTP boundary so the
5
+ * gateway-side hooks can stamp senpi identity onto the gen_ai spans.
3
6
  */
4
- export declare const SPANS_API_PATH = "/api/v1/tracking/spans";
5
- export declare const FLUSH_INTERVAL_MS = 10000;
6
- export declare const FLUSH_THRESHOLD = 50;
7
- export declare const MAX_BUFFER_SIZE = 500;
8
- export declare const STALE_TIMEOUT_MS: number;
9
- export declare const SWEEP_INTERVAL_MS = 60000;
10
- export declare const MAX_BATCH_BYTES = 8000000;
11
- export declare const MAX_SPAN_FIELD_BYTES = 2000000;
12
- /** First N chars of each truncated value retained for debugging context. */
13
- export declare const TRUNCATED_PREVIEW_BYTES = 2000;
14
7
  export declare const HEADER_CORRELATION_ID = "x-senpi-correlation-id";
15
8
  export declare const HEADER_ADDRESS = "x-senpi-address";
16
9
  export declare const HEADER_RECIPE_NAME = "x-senpi-recipe-name";
@@ -1 +1 @@
1
- {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../src/tracking/spans/constants.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,eAAO,MAAM,cAAc,2BAA2B,CAAC;AAGvD,eAAO,MAAM,iBAAiB,QAAS,CAAC;AACxC,eAAO,MAAM,eAAe,KAAK,CAAC;AAClC,eAAO,MAAM,eAAe,MAAM,CAAC;AAGnC,eAAO,MAAM,gBAAgB,QAAa,CAAC;AAC3C,eAAO,MAAM,iBAAiB,QAAS,CAAC;AAKxC,eAAO,MAAM,eAAe,UAAY,CAAC;AAQzC,eAAO,MAAM,oBAAoB,UAAY,CAAC;AAC9C,4EAA4E;AAC5E,eAAO,MAAM,uBAAuB,OAAQ,CAAC;AAG7C,eAAO,MAAM,qBAAqB,2BAA2B,CAAC;AAC9D,eAAO,MAAM,cAAc,oBAAoB,CAAC;AAChD,eAAO,MAAM,kBAAkB,wBAAwB,CAAC;AACxD,eAAO,MAAM,iBAAiB,uBAAuB,CAAC;AACtD,eAAO,MAAM,sBAAsB,4BAA4B,CAAC"}
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../src/tracking/spans/constants.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,eAAO,MAAM,qBAAqB,2BAA2B,CAAC;AAC9D,eAAO,MAAM,cAAc,oBAAoB,CAAC;AAChD,eAAO,MAAM,kBAAkB,wBAAwB,CAAC;AACxD,eAAO,MAAM,iBAAiB,uBAAuB,CAAC;AACtD,eAAO,MAAM,sBAAsB,4BAA4B,CAAC"}