@senpi/runtime 1.0.95-dev.runtime-phase-2-api.20260507130312 → 1.0.95-dev.runtime-phase-2-api.20260507134852

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,38 +1,110 @@
1
1
  /**
2
- * Plugin entry — thin wrapper that initializes dd-trace before loading the
3
- * real plugin module.
2
+ * Senpi core trading plugin — single plugin exposing all core features:
3
+ * actions, scanners, dsl, risk, health.
4
+ * Default export: OpenClaw plugin entry (register(api)).
5
+ * Named export run(): programmatic/standalone entry.
4
6
  *
5
- * Why this file exists:
6
- * ESM hoists static `import` statements above any module-body code. If
7
- * dd-trace.init() lived inside `plugin.ts`, the `import { ... } from "fastify"`
8
- * line at the top of that file would already have loaded Fastify (with
9
- * un-patched prototypes) before init() ran. dd-trace can't patch modules
10
- * retroactively, so the in-file gate would yield zero coverage.
11
- *
12
- * This wrapper sidesteps the problem. ESM resolves the static imports below
13
- * in source order: `dd-trace/initialize.mjs` runs first (registering the
14
- * ESM loader hook + CJS require interceptors), then `./plugin.js` loads.
15
- * Anything `plugin.ts` imports — Fastify, our HTTP server, the Senpi MCP
16
- * client — flows through dd-trace's hooks and gets patched.
17
- *
18
- * We can't rely on `NODE_OPTIONS="--require dd-trace/init"` because the
19
- * openclaw container's env is owned by upstream and out of our control.
20
- *
21
- * Caveat — partial coverage:
22
- * Modules that the OpenClaw harness already loaded before importing this
23
- * plugin (e.g. its own `http` usage) are NOT patched. dd-trace can only
24
- * patch modules that are loaded *after* its hooks are installed. Within
25
- * our plugin's own object graph, that's everything; outside it, nothing.
26
- *
27
- * Gating:
28
- * `dd-trace/initialize.mjs` reads `DD_TRACE_ENABLED` and other `DD_*` env
29
- * vars internally. With no agent configured, it stays a near-no-op — no
30
- * spans are emitted and the connection-failure noise is silent. Tests do
31
- * not need to opt out.
32
- *
33
- * Operator docs: see `docs/runtime-docs/runtime-api.md` § "Tracing (Datadog APM)".
7
+ * Why this file is monolithic (vs. a thin wrapper that imports ./plugin.js):
8
+ * openclaw 2026.2.22's plugin loader follows relative imports from the
9
+ * entry through a CJS-fallback path that rejects `import.meta` syntax.
10
+ * The wrapper-style entry introduced in d919805 broke loadability for
11
+ * that reason. Keeping every export in a single file (this one) avoids
12
+ * the loader's relative-import path entirely.
13
+ */
14
+ import type { SenpiEventBus } from "./dsl/events/index.js";
15
+ /** Initialize all core features (DSL, risk, health) on the given event bus. */
16
+ export declare function initCore(bus: SenpiEventBus): void;
17
+ export { initDsl, DslPlugin, dslLogger, setDslLogLevel, parseDslPluginConfig, DslConfigValidationError, dslValidationIssue, EVENTS as DslEvents, DSL_EVENTS, } from "./dsl/index.js";
18
+ export type { DslArchivedClose, DslPluginConfig, DslPositionSummary, DslState, DslTickResult, ExitBlockConfig, DslValidationIssue, DslValidationIssueCode, } from "./dsl/index.js";
19
+ export { initRisk } from "./risk/index.js";
20
+ export { createHealthStateModule, initHealth } from "./health/index.js";
21
+ export type { ComponentHealth, ComponentHealthStatus, ComponentSystemState, DslComponentHealthStatus, DslSystemState, RuntimeHealthStatus, RuntimeLogLevel, RuntimeSystemState, ScannerComponentHealthStatus, ScannerRegistrationSystemState, ScannerSystemState, StateStatusProvider, } from "./health/index.js";
22
+ export { HOOK_EVENT } from './types/index.js';
23
+ export type { HookEventType, HookEvent, HookSystem, StrategyConfig, StateManager, GateCheckResult, RiskGuard, NotificationService, Signal, ScanResult, } from './types/index.js';
24
+ export { ScanStatus } from './types/index.js';
25
+ export type { ActionType, DecisionMode, ActionConfig, ActionContext, ActionDecision, ActionResult, Action, ActionFactory, ActionManifest, ActionScanPayload, LlmDecisionRequest, LlmDecisionResponse, LlmDecision, } from './actions/types.js';
26
+ export type { ContextBuilder } from './context/types.js';
27
+ export { DecisionEngine, LlmDecisionStrategy, NoDecisionStrategy, } from './actions/decision-engine.js';
28
+ export { OpenClawLlmDecision, AnthropicLlmDecision, createLlmDecision } from './actions/llm-decision/index.js';
29
+ /** @deprecated Use OpenClawLlmDecision instead */
30
+ export { OpenClawLlmDecision as LlmDecisionClient } from './actions/llm-decision/index.js';
31
+ export type { DecisionStrategy, DecisionRequest } from './actions/decision-engine.js';
32
+ export { OpenPositionAction, openPositionFactory, openPositionManifest, } from './actions/open-position/open-position.action.js';
33
+ export { ClosePositionAction, closePositionFactory, closePositionManifest, } from './actions/close-position/close-position.action.js';
34
+ export { SenpiClient } from './senpi/index.js';
35
+ export type { McpTransport, SenpiClientConfig, CreatePositionRequest, CreatePositionOrder, CreatePositionResult, CreatePositionOrderResult, OrderDirection, OrderType, LeverageType, TimeInForce, ExitOrderType, StopLoss, TakeProfit, ListStrategiesFilters, StrategySummary, } from './senpi/index.js';
36
+ export { createScannerRuntimeModule, createSenpiScannerProviders, emergingMoversScanner, momentumScanner, oiTrackerScanner, providerInput, prescreenerScanner, PersistencePolicy, RetentionPolicy, ScanStatus as ScannerScanStatus, SkipScan, } from './scanners/index.js';
37
+ export type { ScannerId, StrategyId, InstrumentContext, Instrument, Candle, CandleResult, ParsedCandles, OiSnapshot, SmMarket, Candidate, ReadSignalsFilter as ScannerReadSignalsFilter, ProviderLogLevel, ProviderLogger, ProviderToolClient, SenpiProviderCacheTtlMs, SenpiProviderTimeouts, SenpiProviderToolNames, SenpiScannerProviderFactoryOptions, SenpiToolClient, Scanner as RuntimeScanner, ScannerDataProviders, ScannerDefinition, ScannerHooks, ProviderInputDescriptor, InstrumentsInputDescriptor, CandlesInputDescriptor, SmDataInputDescriptor, ActivePositionsInputDescriptor, ScannerInputDescriptor, ScannerInput, ExternalScannerIngestRequest, ExternalScannerIngestResult, ExternalScannerIngestSignalItem, ScannerRegistrationSummary, ScannerRuntimeEventMap, ScannerRuntimeEventName, ScannerRuntimeModule, ScannerRuntimeModuleOptions, StrategyRegistration as ScannerStrategyRegistration, } from './scanners/index.js';
38
+ export { run } from "./runtime/run.js";
39
+ export type { RunOptions, RuntimeHandle } from "./runtime/run.js";
40
+ export { loadRuntimeConfig } from "./runtime/load-runtime-config.js";
41
+ export type { LoadRuntimeConfigOptions } from "./runtime/load-runtime-config.js";
42
+ export { Runtime } from "./runtime/runtime.js";
43
+ export type { RuntimeOptions } from "./runtime/runtime.js";
44
+ /** Plugin config shape (aligned with openclaw.plugin.json configSchema). Source of truth for strategies is the registry, not config. */
45
+ export interface SenpiRuntimePluginConfig {
46
+ stateDir?: string;
47
+ apiKey?: string;
48
+ logLevel?: string;
49
+ autoUpdate?: Record<string, unknown>;
50
+ }
51
+ interface PluginLogger {
52
+ info(...args: unknown[]): void;
53
+ warn(...args: unknown[]): void;
54
+ error(message: unknown, meta?: unknown): void;
55
+ }
56
+ interface PluginApi {
57
+ id: string;
58
+ name: string;
59
+ pluginConfig?: Record<string, unknown>;
60
+ logger: PluginLogger;
61
+ config?: Record<string, unknown>;
62
+ runtime: {
63
+ state: {
64
+ resolveStateDir(): string;
65
+ };
66
+ config?: {
67
+ loadConfig(): Promise<unknown>;
68
+ writeConfigFile(config: unknown): Promise<void>;
69
+ };
70
+ };
71
+ registerService(service: {
72
+ id: string;
73
+ start: (ctx: {
74
+ stateDir: string;
75
+ }) => void | Promise<void>;
76
+ stop?: (ctx: {
77
+ stateDir: string;
78
+ }) => void | Promise<void>;
79
+ }): void;
80
+ registerCli(fn: (ctx: {
81
+ program: {
82
+ command: (name: string, desc?: string) => unknown;
83
+ };
84
+ }) => void, opts?: {
85
+ commands: string[];
86
+ }): void;
87
+ registerGatewayMethod(name: string, handler: (ctx: {
88
+ respond: (ok: boolean, value: unknown) => void;
89
+ params?: Record<string, unknown>;
90
+ }) => void | Promise<void>): void;
91
+ on(hookName: string, handler: (...args: unknown[]) => void | Promise<void>, opts?: {
92
+ priority?: number;
93
+ }): void;
94
+ }
95
+ /**
96
+ * OpenClaw plugin entry.
97
+ * Boots from internal registry (installed_runtimes.json) in stateDir; does not read runtime list from config.
34
98
  */
35
- import "dd-trace/initialize.mjs";
36
- export { default } from "./plugin.js";
37
- export * from "./plugin.js";
99
+ declare const senpiRuntimePlugin: {
100
+ id: string;
101
+ name: string;
102
+ version: string;
103
+ description: string;
104
+ configSchema: {
105
+ parse(value: unknown): Record<string, unknown>;
106
+ };
107
+ register(api: PluginApi): void;
108
+ };
109
+ export default senpiRuntimePlugin;
38
110
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAEH,OAAO,yBAAyB,CAAC;AAEjC,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACtC,cAAc,aAAa,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAwCH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAuB3D,+EAA+E;AAC/E,wBAAgB,QAAQ,CAAC,GAAG,EAAE,aAAa,GAAG,IAAI,CAIjD;AAGD,OAAO,EACL,OAAO,EACP,SAAS,EACT,SAAS,EACT,cAAc,EACd,oBAAoB,EACpB,wBAAwB,EACxB,kBAAkB,EAClB,MAAM,IAAI,SAAS,EACnB,UAAU,GACX,MAAM,gBAAgB,CAAC;AACxB,YAAY,EACV,gBAAgB,EAChB,eAAe,EACf,kBAAkB,EAClB,QAAQ,EACR,aAAa,EACb,eAAe,EACf,kBAAkB,EAClB,sBAAsB,GACvB,MAAM,gBAAgB,CAAC;AAGxB,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAG3C,OAAO,EAAE,uBAAuB,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AACxE,YAAY,EACV,eAAe,EACf,qBAAqB,EACrB,oBAAoB,EACpB,wBAAwB,EACxB,cAAc,EACd,mBAAmB,EACnB,eAAe,EACf,kBAAkB,EAClB,4BAA4B,EAC5B,8BAA8B,EAC9B,kBA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