@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 +1 @@
1
- {"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../src/types/runtime.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,KAAK,EAAE,cAAc,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,EAAE,cAAc,CAAC;IAC/B,SAAS,EAAE,SAAS,CAAC;IACrB,aAAa,EAAE,mBAAmB,CAAC;IACnC,aAAa,EAAE,aAAa,CAAC;IAC7B,aAAa,CAAC,EAAE,oBAAoB,CAAC;IACrC,gBAAgB,EAAE,gBAAgB,CAAC;CACpC"}
@@ -1,4 +1,4 @@
1
- import type { CloseOrderType, ClosePositionResult, CreatePositionRequest, CreatePositionResult, EditPositionResult, FeeOptimizedLimitOptions, RatchetStopEvent, RatchetStopPosition } from "../senpi/types.js";
1
+ import type { CloseOrderType, CreatePositionRequest, CreatePositionResult, EditPositionResult, FeeOptimizedLimitOptions, RatchetStopEvent, RatchetStopPosition } from "../senpi/types.js";
2
2
  export type TradingRisk = 'conservative' | 'moderate' | 'aggressive';
3
3
  /** Strategy configuration. Address is the strategy identifier (platform id). */
4
4
  export interface StrategyConfig {
@@ -98,7 +98,7 @@ export interface StrategyState {
98
98
  closePosition(coin: string, reason: string, dex?: string, orderOptions?: {
99
99
  orderType?: CloseOrderType;
100
100
  feeOptimizedLimitOptions?: FeeOptimizedLimitOptions;
101
- }): Promise<ClosePositionResult>;
101
+ }): Promise<unknown>;
102
102
  createPosition(params: CreatePositionRequest): Promise<CreatePositionResult>;
103
103
  editPosition(payload: {
104
104
  coin: string;
@@ -1 +1 @@
1
- {"version":3,"file":"strategy.d.ts","sourceRoot":"","sources":["../../src/types/strategy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EACd,mBAAmB,EACnB,qBAAqB,EACrB,oBAAoB,EACpB,kBAAkB,EAClB,wBAAwB,EACxB,gBAAgB,EAChB,mBAAmB,EACpB,MAAM,mBAAmB,CAAC;AAI3B,MAAM,MAAM,WAAW,GAAG,cAAc,GAAG,UAAU,GAAG,YAAY,CAAC;AAErE,gFAAgF;AAChF,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,MAAM,CAAC;IAChB,iGAAiG;IACjG,MAAM,CAAC,EAAE,MAAM,CAAC;IA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M,CAAC;QAAC,MAAM,CAAC,EAAE,QAAQ,GAAG,QAAQ,GAAG,SAAS,GAAG,KAAK,CAAA;KAAE,GAAG,OAAO,CAAC,mBAAmB,EAAE,CAAC,CAAC;IAC/I,sBAAsB,CAAC,MAAM,CAAC,EAAE;QAC9B,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,SAAS,CAAC,EAAE,KAAK,GAAG,MAAM,CAAC;KAC5B,GAAG,OAAO,CAAC,gBAAgB,EAAE,CAAC,CAAC;CACjC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@senpi/runtime",
3
- "version": "1.1.0-dev.runtime-phase-2.20260609132603",
3
+ "version": "1.1.0-dev.runtime-phase-2.20260610125851",
4
4
  "description": "Senpi runtime plugin for OpenClaw",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -1,65 +0,0 @@
1
- /**
2
- * Per-signal `signal.evaluated` span helpers shared by open / close actions.
3
- *
4
- * Both action files build a per-signal funnel span and stamp `signal.outcome`
5
- * at every early-exit branch. The helpers collapse the batch-reject path and
6
- * the per-iteration funnel-attr shape to one definition.
7
- */
8
- import type { ActionDecision, ActionType, DecisionMode, ScanResult, Signal } from "./types.js";
9
- import { flatten, setPositionId, type OtelEmitter, type OtelSpanHandle, type OtelStatusCode } from "../otel/index.js";
10
- export { flatten, setPositionId };
11
- export type ActionIntent = "OPEN" | "CLOSE";
12
- /**
13
- * Build the `decision.*` attrs the action stamps on `signal.evaluated` after
14
- * the decision strategy returns. Merged with per-signal attrs at span-open
15
- * time. `intended_direction` is intentionally absent — redundant with the
16
- * per-signal `signal.direction` attr (plan B4).
17
- */
18
- export declare function decisionAttrs(opts: {
19
- mode: DecisionMode;
20
- decision: ActionDecision;
21
- minConfidence: number | undefined;
22
- actionType: ActionType;
23
- model: string | undefined;
24
- contextKeys: string[];
25
- }): Record<string, unknown>;
26
- /**
27
- * Variant of `decisionAttrs` for the decision-error catch path. Sets
28
- * `execute=false`, confidence=0, skipped_reason=`decision_error`, with the
29
- * surrounding decision-mode/threshold context intact.
30
- */
31
- export declare function decisionErrorAttrs(opts: {
32
- mode: DecisionMode;
33
- message: string;
34
- minConfidence: number | undefined;
35
- actionType: ActionType;
36
- model: string | undefined;
37
- contextKeys: string[];
38
- }): Record<string, unknown>;
39
- /**
40
- * Per-signal `signal.evaluated` attrs shared by open and close actions. The
41
- * originating signal's `signal.factors.*` and `signal.meta.*` are flattened
42
- * (C3) so HyperDX queries can group by individual factor flags.
43
- */
44
- export declare function buildSignalAttrs(scannerId: string | undefined, sig: Partial<Pick<Signal, "asset" | "direction" | "score" | "signalType" | "factors" | "meta">>, intent: ActionIntent): Record<string, unknown>;
45
- /**
46
- * Batch-reject path: one `signal.evaluated` row per signal in the scan
47
- * result. Used by both open and close actions when an early gate (decision
48
- * error / no-execute / below-confidence / invalid-payload) rejects the
49
- * whole batch.
50
- */
51
- export declare function emitBatchRejected(otel: OtelEmitter, scanResult: ScanResult | undefined, outcome: string, intent: ActionIntent, decAttrs?: Record<string, unknown>, error?: unknown): void;
52
- /**
53
- * Scope helper for the accepted-signal path: open a span, install it on the
54
- * OTEL ALS as `currentSpan` (so descendant `startSpan`/`emitLog` calls inherit
55
- * parent automatically), run the callback, and rely on the callback to call
56
- * its provided `endSignal` for terminal outcome. If the callback throws, the
57
- * span is exception-tagged and ended with `"exception"` before re-throwing —
58
- * the caller need not duplicate that handling.
59
- *
60
- * Position-id leak across signals (H1/H2/B06) is fixed by `otelContext.run`'s
61
- * fresh ALS frame per call.
62
- */
63
- export declare function withSignalSpanScope(otel: OtelEmitter, attrs: Record<string, unknown>, fn: (span: OtelSpanHandle) => Promise<void>): Promise<void>;
64
- export type { OtelStatusCode };
65
- //# sourceMappingURL=otel-helpers.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"otel-helpers.d.ts","sourceRoot":"","sources":["../../src/actions/otel-helpers.ts"],"names":[],"mappings":"AA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,MAAM,EAAE,OAAO,CAAC,CAWzB;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,WAAW,EACjB,UAAU,EAAE,UAAU,GAAG,SAAS,EAClC,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,YAAY,EACpB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAClC,KAAK,CAAC,EAAE,OAAO,GACd,IAAI,CAgBN;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,mBAAmB,CACvC,IAAI,EAAE,WAAW,EACjB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC9B,EAAE,EAAE,CAAC,IAAI,EAAE,cAAc,KAAK,OAAO,CAAC,IAAI,CAAC,GAC1C,OAAO,CAAC,IAAI,CAAC,CAcf;AAGD,YAAY,EAAE,cAAc,EAAE,CAAC"}
@@ -1,122 +0,0 @@
1
- /**
2
- * Per-signal `signal.evaluated` span helpers shared by open / close actions.
3
- *
4
- * Both action files build a per-signal funnel span and stamp `signal.outcome`
5
- * at every early-exit branch. The helpers collapse the batch-reject path and
6
- * the per-iteration funnel-attr shape to one definition.
7
- */
8
- import { flatten, otelContext, setPositionId, } from "../otel/index.js";
9
- // Re-export so action files import otel surface from a single module.
10
- export { flatten, setPositionId };
11
- /**
12
- * Build the `decision.*` attrs the action stamps on `signal.evaluated` after
13
- * the decision strategy returns. Merged with per-signal attrs at span-open
14
- * time. `intended_direction` is intentionally absent — redundant with the
15
- * per-signal `signal.direction` attr (plan B4).
16
- */
17
- export function decisionAttrs(opts) {
18
- const { mode, decision, minConfidence, actionType, model, contextKeys } = opts;
19
- return {
20
- "decision.mode": mode,
21
- "decision.execute": decision.execute,
22
- "decision.confidence": decision.confidence,
23
- "decision.reasoning": decision.reasoning,
24
- "decision.confidence_threshold": minConfidence,
25
- // B18 — `no_execute` only; the `below_confidence` outcome is set by the
26
- // action layer's secondary gate, never by the decision strategy itself.
27
- "decision.skipped_reason": decision.execute ? null : "no_execute",
28
- "decision.action_name": actionType,
29
- "decision.action_type": actionType,
30
- "decision.model": model,
31
- "decision.context_keys": contextKeys,
32
- };
33
- }
34
- /**
35
- * Variant of `decisionAttrs` for the decision-error catch path. Sets
36
- * `execute=false`, confidence=0, skipped_reason=`decision_error`, with the
37
- * surrounding decision-mode/threshold context intact.
38
- */
39
- export function decisionErrorAttrs(opts) {
40
- const { mode, message, minConfidence, actionType, model, contextKeys } = opts;
41
- return {
42
- "decision.mode": mode,
43
- "decision.execute": false,
44
- "decision.confidence": 0,
45
- "decision.reasoning": `Decision error: ${message}`,
46
- "decision.confidence_threshold": minConfidence,
47
- "decision.skipped_reason": "decision_error",
48
- "decision.action_name": actionType,
49
- "decision.action_type": actionType,
50
- "decision.model": model,
51
- "decision.context_keys": contextKeys,
52
- };
53
- }
54
- /**
55
- * Per-signal `signal.evaluated` attrs shared by open and close actions. The
56
- * originating signal's `signal.factors.*` and `signal.meta.*` are flattened
57
- * (C3) so HyperDX queries can group by individual factor flags.
58
- */
59
- export function buildSignalAttrs(scannerId, sig, intent) {
60
- return {
61
- "scanner.id": scannerId,
62
- "signal.asset": sig.asset,
63
- "signal.direction": sig.direction,
64
- "signal.score": sig.score,
65
- "signal.type": sig.signalType,
66
- "signal.action_intent": intent,
67
- ...flatten("signal.factors", sig.factors),
68
- ...flatten("signal.meta", sig.meta),
69
- };
70
- }
71
- /**
72
- * Batch-reject path: one `signal.evaluated` row per signal in the scan
73
- * result. Used by both open and close actions when an early gate (decision
74
- * error / no-execute / below-confidence / invalid-payload) rejects the
75
- * whole batch.
76
- */
77
- export function emitBatchRejected(otel, scanResult, outcome, intent, decAttrs, error) {
78
- const scannerId = scanResult?.scannerId;
79
- for (const sig of scanResult?.signals ?? []) {
80
- const span = otel.startSpan("signal.evaluated", {
81
- attrs: { ...buildSignalAttrs(scannerId, sig, intent), ...(decAttrs ?? {}) },
82
- });
83
- span.setAttr("signal.outcome", outcome);
84
- if (error !== undefined) {
85
- span.recordException(error);
86
- const e = error;
87
- span.setAttr("exception.type", e?.name ?? "Error");
88
- span.end({ statusCode: "Error" });
89
- }
90
- else {
91
- span.end();
92
- }
93
- }
94
- }
95
- /**
96
- * Scope helper for the accepted-signal path: open a span, install it on the
97
- * OTEL ALS as `currentSpan` (so descendant `startSpan`/`emitLog` calls inherit
98
- * parent automatically), run the callback, and rely on the callback to call
99
- * its provided `endSignal` for terminal outcome. If the callback throws, the
100
- * span is exception-tagged and ended with `"exception"` before re-throwing —
101
- * the caller need not duplicate that handling.
102
- *
103
- * Position-id leak across signals (H1/H2/B06) is fixed by `otelContext.run`'s
104
- * fresh ALS frame per call.
105
- */
106
- export async function withSignalSpanScope(otel, attrs, fn) {
107
- const span = otel.startSpan("signal.evaluated", { attrs });
108
- await otelContext.run({ currentSpan: span }, async () => {
109
- try {
110
- await fn(span);
111
- }
112
- catch (err) {
113
- span.recordException(err);
114
- const e = err;
115
- span.setAttr("exception.type", e?.name ?? "Error");
116
- span.setAttr("signal.outcome", "exception");
117
- span.end({ statusCode: "Error" });
118
- throw err;
119
- }
120
- });
121
- }
122
- //# sourceMappingURL=otel-helpers.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"otel-helpers.js","sourceRoot":"","sources":["../../src/actions/otel-helpers.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,EACL,OAAO,EACP,WAAW,EACX,aAAa,GAId,MAAM,kBAAkB,CAAC;AAE1B,sEAAsE;AACtE,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,CAAC;AAIlC;;;;;GAKG;AACH,MAAM,UAAU,aAAa,CAAC,IAO7B;IACC,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,aAAa,EAAE,UAAU,EAAE,KAAK,EAAE,WAAW,EAAE,GAAG,IAAI,CAAC;IAC/E,OAAO;QACL,eAAe,EAAE,IAAI;QACrB,kBAAkB,EAAE,QAAQ,CAAC,OAAO;QACpC,qBAAqB,EAAE,QAAQ,CA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C,IAAI,CAAC,CAAC;QACjB,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC;YAC1B,MAAM,CAAC,GAAG,GAAwB,CAAC;YACnC,IAAI,CAAC,OAAO,CAAC,gBAAgB,EAAE,CAAC,EAAE,IAAI,IAAI,OAAO,CAAC,CAAC;YACnD,IAAI,CAAC,OAAO,CAAC,gBAAgB,EAAE,WAAW,CAAC,CAAC;YAC5C,IAAI,CAAC,GAAG,CAAC,EAAE,UAAU,EAAE,OAAO,EAAE,CAAC,CAAC;YAClC,MAAM,GAAG,CAAC;QACZ,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -1,24 +0,0 @@
1
- /**
2
- * Dedicated OTEL AsyncLocalStorage carrying per-signal context.
3
- *
4
- * Independent of src/tracking/context.ts — the tracking layer is on track for
5
- * deprecation; reusing its ALS instance would couple OTEL to that lifecycle.
6
- */
7
- import { AsyncLocalStorage } from "node:async_hooks";
8
- import type { OtelSpanHandle } from "./emitter.js";
9
- export interface OtelContext {
10
- /** Mint-at-intent position id. Stamped downstream onto every span/log. */
11
- positionId?: string;
12
- /** The currently-active span — read by `startSpan` when no explicit parent. */
13
- currentSpan?: OtelSpanHandle;
14
- }
15
- export declare const otelContext: AsyncLocalStorage<OtelContext>;
16
- export declare function getPositionId(): string | undefined;
17
- /**
18
- * Mutate the current ALS frame in place. Safe because the runtime's signal
19
- * consumer is strictly serial — no concurrent writes to the same frame.
20
- */
21
- export declare function setPositionId(id: string): void;
22
- export declare function getCurrentSpan(): OtelSpanHandle | undefined;
23
- export declare function setCurrentSpan(handle: OtelSpanHandle | undefined): void;
24
- //# sourceMappingURL=context.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/otel/context.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAEnD,MAAM,WAAW,WAAW;IAC1B,0EAA0E;IAC1E,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,+EAA+E;IAC/E,WAAW,CAAC,EAAE,cAAc,CAAC;CAC9B;AAED,eAAO,MAAM,WAAW,gCAAuC,CAAC;AAEhE,wBAAgB,aAAa,IAAI,MAAM,GAAG,SAAS,CAElD;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,CAG9C;AAED,wBAAgB,cAAc,IAAI,cAAc,GAAG,SAAS,CAE3D;AAED,wBAAgB,cAAc,CAAC,MAAM,EAAE,cAAc,GAAG,SAAS,GAAG,IAAI,CAGvE"}
@@ -1,29 +0,0 @@
1
- /**
2
- * Dedicated OTEL AsyncLocalStorage carrying per-signal context.
3
- *
4
- * Independent of src/tracking/context.ts — the tracking layer is on track for
5
- * deprecation; reusing its ALS instance would couple OTEL to that lifecycle.
6
- */
7
- import { AsyncLocalStorage } from "node:async_hooks";
8
- export const otelContext = new AsyncLocalStorage();
9
- export function getPositionId() {
10
- return otelContext.getStore()?.positionId;
11
- }
12
- /**
13
- * Mutate the current ALS frame in place. Safe because the runtime's signal
14
- * consumer is strictly serial — no concurrent writes to the same frame.
15
- */
16
- export function setPositionId(id) {
17
- const ctx = otelContext.getStore();
18
- if (ctx)
19
- ctx.positionId = id;
20
- }
21
- export function getCurrentSpan() {
22
- return otelContext.getStore()?.currentSpan;
23
- }
24
- export function setCurrentSpan(handle) {
25
- const ctx = otelContext.getStore();
26
- if (ctx)
27
- ctx.currentSpan = handle;
28
- }
29
- //# sourceMappingURL=context.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"context.js","sourceRoot":"","sources":["../../src/otel/context.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAUrD,MAAM,CAAC,MAAM,WAAW,GAAG,IAAI,iBAAiB,EAAe,CAAC;AAEhE,MAAM,UAAU,aAAa;IAC3B,OAAO,WAAW,CAAC,QAAQ,EAAE,EAAE,UAAU,CAAC;AAC5C,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,aAAa,CAAC,EAAU;IACtC,MAAM,GAAG,GAAG,WAAW,CAAC,QAAQ,EAAE,CAAC;IACnC,IAAI,GAAG;QAAE,GAAG,CAAC,UAAU,GAAG,EAAE,CAAC;AAC/B,CAAC;AAED,MAAM,UAAU,cAAc;IAC5B,OAAO,WAAW,CAAC,QAAQ,EAAE,EAAE,WAAW,CAAC;AAC7C,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,MAAkC;IAC/D,MAAM,GAAG,GAAG,WAAW,CAAC,QAAQ,EAAE,CAAC;IACnC,IAAI,GAAG;QAAE,GAAG,CAAC,WAAW,GAAG,MAAM,CAAC;AACpC,CAAC"}
@@ -1,73 +0,0 @@
1
- /**
2
- * Per-Runtime OTEL emitter. Constructed once with the identity envelope baked
3
- * in; stamps `position.id` from the OTEL ALS frame onto every span/log at emit
4
- * time. Independent of the deprecating `src/tracking/` layer.
5
- *
6
- * Base host is shared with the legacy tracking layer via SENPI_TRACKING_URL
7
- * (defaulting to the prod tracking host); the OTEL route paths are appended.
8
- * When SENPI_OTEL_API_KEY is unset the emitter is `disabled` and all methods
9
- * are cheap no-ops (the ingest rejects unauthenticated batches).
10
- */
11
- import type { OtelSeverity, OtelSpanKind, OtelStatusCode } from "./types.js";
12
- export interface OtelIdentity {
13
- serviceName: string;
14
- strategyAddress?: string;
15
- recipeName?: string;
16
- /** Recipe author's `version:` from the recipe YAML; absent when omitted. */
17
- recipeVersion?: string;
18
- /** Build version of this runtime (the npm package `version`). */
19
- runtimeVersion?: string;
20
- runtimeBootId: string;
21
- }
22
- export interface OtelEmitterOptions {
23
- identity: OtelIdentity;
24
- endpoint?: string;
25
- apiKey?: string;
26
- disabled?: boolean;
27
- }
28
- export interface SpanStartOpts {
29
- parent?: OtelSpanHandle;
30
- kind?: OtelSpanKind;
31
- attrs?: Record<string, unknown>;
32
- }
33
- export interface SpanEndOpts {
34
- statusCode?: OtelStatusCode;
35
- message?: string;
36
- }
37
- export interface OtelSpanHandle {
38
- readonly traceId: string;
39
- readonly spanId: string;
40
- readonly name: string;
41
- setAttr(key: string, value: unknown): void;
42
- setAttrs(record: Record<string, unknown>): void;
43
- addEvent(name: string, attrs?: Record<string, unknown>): void;
44
- recordException(err: unknown): void;
45
- end(opts?: SpanEndOpts): void;
46
- }
47
- export interface LogEmitOpts {
48
- eventName: string;
49
- severity?: OtelSeverity;
50
- attrs?: Record<string, unknown>;
51
- body?: unknown;
52
- parent?: OtelSpanHandle;
53
- }
54
- export declare class OtelEmitter {
55
- private readonly resource;
56
- private readonly serviceName;
57
- private readonly spans;
58
- private readonly logs;
59
- readonly disabled: boolean;
60
- constructor(options: OtelEmitterOptions);
61
- startSpan(name: string, opts?: SpanStartOpts): OtelSpanHandle;
62
- emitLog(opts: LogEmitOpts): void;
63
- /** Drain both transports' buffers and await in-flight POSTs. */
64
- shutdown(): Promise<void>;
65
- /**
66
- * No-op emitter satisfying the `OtelEmitter` shape. Useful as a fallback in
67
- * paths (e.g. tests or callers that build a runtime context without a real
68
- * runtime) where stamping `{ disabled: true }` plus an identity envelope is
69
- * boilerplate.
70
- */
71
- static disabled(): OtelEmitter;
72
- }
73
- //# sourceMappingURL=emitter.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"emitter.d.ts","sourceRoot":"","sources":["../../src/otel/emitter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AASH,OAAO,KAAK,EAEV,YAAY,EACZ,YAAY,EACZ,cAAc,EAGf,MAAM,YAAY,CAAC;AAkBpB,MAAM,WAAW,YAAY;IAC3B,WAAW,EAAE,MAAM,CAAC;IACpB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,4EAA4E;IA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,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAChC,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,MAAM,CAAC,EAAE,cAAc,CAAC;CACzB;AAED,qBAAa,WAAW;IACtB,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAyB;IAClD,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAS;IACrC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAoC;IAC1D,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAmC;IACxD,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;gBAEf,OAAO,EAAE,kBAAkB;IAyDvC,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,GAAE,aAAkB,GAAG,cAAc;IAqGjE,OAAO,CAAC,IAAI,EAAE,WAAW,GAAG,IAAI;IAiChC,gEAAgE;IAC1D,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;IAO/B;;;;;OAKG;IACH,MAAM,CAAC,QAAQ,IAAI,WAAW;CAM/B"}
@@ -1,248 +0,0 @@
1
- /**
2
- * Per-Runtime OTEL emitter. Constructed once with the identity envelope baked
3
- * in; stamps `position.id` from the OTEL ALS frame onto every span/log at emit
4
- * time. Independent of the deprecating `src/tracking/` layer.
5
- *
6
- * Base host is shared with the legacy tracking layer via SENPI_TRACKING_URL
7
- * (defaulting to the prod tracking host); the OTEL route paths are appended.
8
- * When SENPI_OTEL_API_KEY is unset the emitter is `disabled` and all methods
9
- * are cheap no-ops (the ingest rejects unauthenticated batches).
10
- */
11
- import os from "node:os";
12
- import { createLogger } from "../utils/logger.js";
13
- import { ensureDefaultPiiRedactor } from "../tracking/spans/redact-pii.js";
14
- import { VERSION } from "../version.js";
15
- import { getCurrentSpan, getPositionId } from "./context.js";
16
- import { newSpanId, newTraceId, nowNs, nowNsBigInt, toStringMap, toStringValue } from "./encode.js";
17
- import { OtelHttpTransport } from "./transport.js";
18
- const logger = createLogger("[senpi-core][otel-emitter]");
19
- // Same base host as the legacy tracking layer (events/spans). Local constant so
20
- // the OTEL path stays self-contained while still honoring SENPI_TRACKING_URL.
21
- const DEFAULT_TRACKING_BASE_URL = "https://agent-telemetry.prod.senpi.ai";
22
- /** Severity → OTEL semconv 1-24 number. Lowercase is the canonical wire form. */
23
- const SEVERITY_NUMBER = {
24
- trace: 1,
25
- debug: 5,
26
- info: 9,
27
- warn: 13,
28
- error: 17,
29
- fatal: 21,
30
- };
31
- export class OtelEmitter {
32
- resource;
33
- serviceName;
34
- spans;
35
- logs;
36
- disabled;
37
- constructor(options) {
38
- const endpoint = options.endpoint ??
39
- process.env.SENPI_TRACKING_URL ??
40
- DEFAULT_TRACKING_BASE_URL;
41
- // Intentionally NO fallback to SENPI_API_KEY. The master Senpi API key
42
- // grants broad access; posting it as a Bearer would expose it beyond its
43
- // intended scope. Require SENPI_OTEL_API_KEY explicitly — without it the
44
- // emitter disables rather than posting unauth (the ingest rejects
45
- // unauthenticated batches with 401).
46
- const apiKey = options.apiKey ?? process.env.SENPI_OTEL_API_KEY;
47
- // Resource map produced once at construction (no per-call rebuild).
48
- const id = options.identity;
49
- const resource = {
50
- "service.name": id.serviceName,
51
- "service.version": VERSION,
52
- "host.name": os.hostname(),
53
- "runtime.boot_id": id.runtimeBootId,
54
- "runtime.version": id.runtimeVersion ?? VERSION,
55
- };
56
- // `user.id` is intentionally NOT stamped here. The ingest service
57
- // overwrites it from the verified bearer token (`stampUser` in
58
- // agent_telemetry's otel route), so a producer-side stamp is bytes on
59
- // the wire and a small attack-surface: a compromised producer credential
60
- // could otherwise lie about identity for empty-`strategy.address` rows
61
- // that bypass the ownership gate. Server-stamp is the authoritative path.
62
- if (id.strategyAddress)
63
- resource["strategy.address"] = id.strategyAddress;
64
- if (id.recipeName)
65
- resource["recipe.name"] = id.recipeName;
66
- if (id.recipeVersion)
67
- resource["recipe.version"] = id.recipeVersion;
68
- this.resource = resource;
69
- this.serviceName = id.serviceName;
70
- this.disabled = options.disabled === true || !apiKey;
71
- if (this.disabled) {
72
- if (!apiKey && options.disabled !== true) {
73
- logger.info("OTEL emitter disabled: SENPI_OTEL_API_KEY unset");
74
- }
75
- this.spans = null;
76
- this.logs = null;
77
- return;
78
- }
79
- this.spans = new OtelHttpTransport({
80
- url: joinUrl(endpoint, "/api/v1/tracking/traces"),
81
- apiKey,
82
- kind: "spans",
83
- });
84
- this.logs = new OtelHttpTransport({
85
- url: joinUrl(endpoint, "/api/v1/tracking/logs"),
86
- apiKey,
87
- kind: "logs",
88
- });
89
- // Kick off PII redactor init on the V2 path too (the legacy span tracker
90
- // also calls this; the helper is idempotent). Without this, an OTel-only
91
- // deployment with `SENPI_API_KEY` unset would never construct the legacy
92
- // span tracker and emit un-redacted.
93
- void ensureDefaultPiiRedactor();
94
- }
95
- startSpan(name, opts = {}) {
96
- // B1 — when no explicit parent, fall back to ALS-`currentSpan`.
97
- const parent = opts.parent ?? getCurrentSpan();
98
- const traceId = parent?.traceId ?? newTraceId();
99
- const spanId = newSpanId();
100
- const parentSpanId = parent?.spanId ?? "";
101
- const startTimeNs = nowNsBigInt();
102
- const kind = opts.kind ?? "Internal";
103
- const attrMap = {};
104
- if (opts.attrs) {
105
- for (const [k, v] of Object.entries(opts.attrs)) {
106
- // Skip undefined; emit empty-string for null per CH convention.
107
- if (v === undefined)
108
- continue;
109
- attrMap[k] = toStringValue(v);
110
- }
111
- }
112
- const events = [];
113
- let ended = false;
114
- let exceptionRecorded = false;
115
- const emit = (row) => {
116
- this.spans?.emit(row);
117
- };
118
- const cachedResource = this.resource;
119
- const cachedServiceName = this.serviceName;
120
- const handle = {
121
- traceId,
122
- spanId,
123
- name,
124
- setAttr(key, value) {
125
- // C6 — only skip `undefined`; null, false, 0, '' are all valid values.
126
- if (value === undefined)
127
- return;
128
- attrMap[key] = toStringValue(value);
129
- },
130
- setAttrs(record) {
131
- for (const [k, v] of Object.entries(record)) {
132
- if (v === undefined)
133
- continue;
134
- attrMap[k] = toStringValue(v);
135
- }
136
- },
137
- addEvent(eventName, eventAttrs) {
138
- events.push({
139
- Timestamp: nowNs(),
140
- Name: eventName,
141
- Attributes: eventAttrs ? toStringMap(eventAttrs) : {},
142
- });
143
- },
144
- recordException(err) {
145
- const e = err;
146
- events.push({
147
- Timestamp: nowNs(),
148
- Name: "exception",
149
- Attributes: {
150
- "exception.type": e?.name ?? "Error",
151
- "exception.message": e?.message ?? String(err),
152
- "exception.stacktrace": e?.stack ?? "",
153
- },
154
- });
155
- exceptionRecorded = true;
156
- },
157
- end(endOpts) {
158
- if (ended)
159
- return;
160
- ended = true;
161
- const positionId = getPositionId();
162
- if (positionId && attrMap["position.id"] === undefined) {
163
- attrMap["position.id"] = positionId;
164
- }
165
- // C2 — default StatusCode: explicit > exception-implied 'Error' > 'Ok'.
166
- const statusCode = endOpts?.statusCode ?? (exceptionRecorded ? "Error" : "Ok");
167
- const endTimeNs = nowNsBigInt();
168
- const startTimestamp = startTimeNs.toString();
169
- const duration = (endTimeNs - startTimeNs).toString();
170
- const row = {
171
- Timestamp: startTimestamp,
172
- TraceId: traceId,
173
- SpanId: spanId,
174
- ParentSpanId: parentSpanId,
175
- SpanName: name,
176
- SpanKind: kind,
177
- Duration: duration,
178
- ServiceName: cachedServiceName,
179
- StatusCode: statusCode,
180
- StatusMessage: endOpts?.message ?? "",
181
- SpanAttributes: attrMap,
182
- ResourceAttributes: cachedResource,
183
- Events: events,
184
- ScopeName: "",
185
- ScopeVersion: "",
186
- TraceFlags: 0,
187
- TraceState: "",
188
- };
189
- emit(row);
190
- },
191
- };
192
- return handle;
193
- }
194
- emitLog(opts) {
195
- if (!this.logs)
196
- return;
197
- const severity = opts.severity ?? "info";
198
- const parent = opts.parent ?? getCurrentSpan();
199
- const baseAttrs = {
200
- "event.name": opts.eventName,
201
- ...(opts.attrs ?? {}),
202
- };
203
- const positionId = getPositionId();
204
- if (positionId && baseAttrs["position.id"] === undefined) {
205
- baseAttrs["position.id"] = positionId;
206
- }
207
- let body = "";
208
- if (opts.body !== undefined && opts.body !== null) {
209
- body = typeof opts.body === "string" ? opts.body : toStringValue(opts.body);
210
- }
211
- const row = {
212
- Timestamp: nowNs(),
213
- TraceId: parent?.traceId ?? "",
214
- SpanId: parent?.spanId ?? "",
215
- ServiceName: this.serviceName,
216
- SeverityText: severity,
217
- SeverityNumber: SEVERITY_NUMBER[severity],
218
- Body: body,
219
- LogAttributes: toStringMap(baseAttrs),
220
- ResourceAttributes: this.resource,
221
- EventName: opts.eventName,
222
- };
223
- this.logs.emit(row);
224
- }
225
- /** Drain both transports' buffers and await in-flight POSTs. */
226
- async shutdown() {
227
- await Promise.allSettled([
228
- this.spans?.shutdown() ?? Promise.resolve(),
229
- this.logs?.shutdown() ?? Promise.resolve(),
230
- ]);
231
- }
232
- /**
233
- * No-op emitter satisfying the `OtelEmitter` shape. Useful as a fallback in
234
- * paths (e.g. tests or callers that build a runtime context without a real
235
- * runtime) where stamping `{ disabled: true }` plus an identity envelope is
236
- * boilerplate.
237
- */
238
- static disabled() {
239
- return new OtelEmitter({
240
- identity: { serviceName: "senpi-trading-runtime", runtimeBootId: "disabled" },
241
- disabled: true,
242
- });
243
- }
244
- }
245
- function joinUrl(base, path) {
246
- return base.replace(/\/+$/, "") + path;
247
- }
248
- //# sourceMappingURL=emitter.js.map