@senpi/runtime 1.0.95-dev.runtime-phase-2.20260506193916 → 1.0.95-dev.runtime-phase-2-api.20260507130312
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/README.md +13 -0
- package/dist/index.d.ts +35 -100
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +33 -930
- package/dist/index.js.map +1 -1
- package/dist/plugin.d.ts +110 -0
- package/dist/plugin.d.ts.map +1 -0
- package/dist/plugin.js +1055 -0
- package/dist/plugin.js.map +1 -0
- package/dist/runtime/__tests__/helpers/runtime-gateway-harness.d.ts +3 -3
- package/dist/runtime/audit-query.types.d.ts +113 -0
- package/dist/runtime/audit-query.types.d.ts.map +1 -0
- package/dist/runtime/audit-query.types.js +35 -0
- package/dist/runtime/audit-query.types.js.map +1 -0
- package/dist/runtime/auto-update/coordinator.d.ts +12 -8
- package/dist/runtime/auto-update/coordinator.d.ts.map +1 -1
- package/dist/runtime/auto-update/coordinator.js +18 -17
- package/dist/runtime/auto-update/coordinator.js.map +1 -1
- package/dist/runtime/auto-update/gateway-restart.d.ts +9 -2
- package/dist/runtime/auto-update/gateway-restart.d.ts.map +1 -1
- package/dist/runtime/auto-update/gateway-restart.js +23 -13
- package/dist/runtime/auto-update/gateway-restart.js.map +1 -1
- package/dist/runtime/create-actions.d.ts.map +1 -1
- package/dist/runtime/create-actions.js +13 -2
- package/dist/runtime/create-actions.js.map +1 -1
- package/dist/runtime/run.d.ts +52 -1
- package/dist/runtime/run.d.ts.map +1 -1
- package/dist/runtime/run.js +9 -0
- package/dist/runtime/run.js.map +1 -1
- package/dist/runtime/runtime.d.ts +56 -0
- package/dist/runtime/runtime.d.ts.map +1 -1
- package/dist/runtime/runtime.js +169 -1
- package/dist/runtime/runtime.js.map +1 -1
- package/dist/runtime-api/config.d.ts +47 -0
- package/dist/runtime-api/config.d.ts.map +1 -0
- package/dist/runtime-api/config.js +74 -0
- package/dist/runtime-api/config.js.map +1 -0
- package/dist/runtime-api/handlers/audit.d.ts +78 -0
- package/dist/runtime-api/handlers/audit.d.ts.map +1 -0
- package/dist/runtime-api/handlers/audit.js +65 -0
- package/dist/runtime-api/handlers/audit.js.map +1 -0
- package/dist/runtime-api/handlers/group-by-scanner.d.ts +43 -0
- package/dist/runtime-api/handlers/group-by-scanner.d.ts.map +1 -0
- package/dist/runtime-api/handlers/group-by-scanner.js +43 -0
- package/dist/runtime-api/handlers/group-by-scanner.js.map +1 -0
- package/dist/runtime-api/handlers/ingest-signals.d.ts +54 -0
- package/dist/runtime-api/handlers/ingest-signals.d.ts.map +1 -0
- package/dist/runtime-api/handlers/ingest-signals.js +141 -0
- package/dist/runtime-api/handlers/ingest-signals.js.map +1 -0
- package/dist/runtime-api/handlers/lookup.d.ts +36 -0
- package/dist/runtime-api/handlers/lookup.d.ts.map +1 -0
- package/dist/runtime-api/handlers/lookup.js +31 -0
- package/dist/runtime-api/handlers/lookup.js.map +1 -0
- package/dist/runtime-api/handlers/types.d.ts +85 -0
- package/dist/runtime-api/handlers/types.d.ts.map +1 -0
- package/dist/runtime-api/handlers/types.js +8 -0
- package/dist/runtime-api/handlers/types.js.map +1 -0
- package/dist/runtime-api/lifecycle.d.ts +98 -0
- package/dist/runtime-api/lifecycle.d.ts.map +1 -0
- package/dist/runtime-api/lifecycle.js +137 -0
- package/dist/runtime-api/lifecycle.js.map +1 -0
- package/dist/runtime-api/readiness.d.ts +37 -0
- package/dist/runtime-api/readiness.d.ts.map +1 -0
- package/dist/runtime-api/readiness.js +35 -0
- package/dist/runtime-api/readiness.js.map +1 -0
- package/dist/runtime-api/routes/audit.d.ts +40 -0
- package/dist/runtime-api/routes/audit.d.ts.map +1 -0
- package/dist/runtime-api/routes/audit.js +90 -0
- package/dist/runtime-api/routes/audit.js.map +1 -0
- package/dist/runtime-api/routes/audit.schema.d.ts +75 -0
- package/dist/runtime-api/routes/audit.schema.d.ts.map +1 -0
- package/dist/runtime-api/routes/audit.schema.js +78 -0
- package/dist/runtime-api/routes/audit.schema.js.map +1 -0
- package/dist/runtime-api/routes/health.d.ts +53 -0
- package/dist/runtime-api/routes/health.d.ts.map +1 -0
- package/dist/runtime-api/routes/health.js +48 -0
- package/dist/runtime-api/routes/health.js.map +1 -0
- package/dist/runtime-api/routes/signals.d.ts +50 -0
- package/dist/runtime-api/routes/signals.d.ts.map +1 -0
- package/dist/runtime-api/routes/signals.js +90 -0
- package/dist/runtime-api/routes/signals.js.map +1 -0
- package/dist/runtime-api/routes/signals.schema.d.ts +94 -0
- package/dist/runtime-api/routes/signals.schema.d.ts.map +1 -0
- package/dist/runtime-api/routes/signals.schema.js +58 -0
- package/dist/runtime-api/routes/signals.schema.js.map +1 -0
- package/dist/runtime-api/server.d.ts +79 -0
- package/dist/runtime-api/server.d.ts.map +1 -0
- package/dist/runtime-api/server.js +109 -0
- package/dist/runtime-api/server.js.map +1 -0
- package/dist/senpi/client.d.ts +92 -2
- package/dist/senpi/client.d.ts.map +1 -1
- package/dist/senpi/client.js +181 -8
- package/dist/senpi/client.js.map +1 -1
- package/openclaw.plugin.json +24 -0
- package/package.json +6 -2
package/README.md
CHANGED
|
@@ -176,6 +176,19 @@ Templates live under `examples/strategies/` in the package. See [examples/strate
|
|
|
176
176
|
- `openclaw senpi guide schema` — full YAML schema
|
|
177
177
|
- `openclaw senpi guide version` — plugin version and changelog URL
|
|
178
178
|
|
|
179
|
+
## HTTP API
|
|
180
|
+
|
|
181
|
+
The runtime exposes an HTTP API on `127.0.0.1:8787` (default; configurable via plugin config). Use it to ingest signals from external sources, query audit history, and check liveness.
|
|
182
|
+
|
|
183
|
+
**Three endpoints:**
|
|
184
|
+
- `POST /signals` — ingest external scanner signals; body is a JSON array of signal items
|
|
185
|
+
- `GET /audit?address=<wallet>` — query strategy audit history via MCP
|
|
186
|
+
- `GET /health` — liveness probe with per-runtime signal queue depth
|
|
187
|
+
|
|
188
|
+
**Default binding:** `127.0.0.1:8787` (localhost-only). For Postman testing on the same host, flip `api.host` to `0.0.0.0` in `openclaw.json` and add a Docker port mapping `127.0.0.1:8787:8787` (the `127.0.0.1:` prefix is mandatory to avoid LAN exposure). See [docs/runtime-docs/runtime-api.md](docs/runtime-docs/runtime-api.md) for full details and the Postman testing recipe.
|
|
189
|
+
|
|
190
|
+
**Latency benchmark:** `npm run bench` runs `benchmarks/ingest-latency.ts` — compares the in-process gateway-shim path against HTTP `POST /signals` across three scenarios and prints p50/p95/p99 with a PASS/FAIL gate.
|
|
191
|
+
|
|
179
192
|
## External scanners
|
|
180
193
|
|
|
181
194
|
Use `type: external_scanner` when the signal or context source lives outside the
|
package/dist/index.d.ts
CHANGED
|
@@ -1,103 +1,38 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
2
|
+
* Plugin entry — thin wrapper that initializes dd-trace before loading the
|
|
3
|
+
* real plugin module.
|
|
4
|
+
*
|
|
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)".
|
|
6
34
|
*/
|
|
7
|
-
import
|
|
8
|
-
|
|
9
|
-
export
|
|
10
|
-
export { initDsl, DslPlugin, dslLogger, setDslLogLevel, parseDslPluginConfig, DslConfigValidationError, dslValidationIssue, EVENTS as DslEvents, DSL_EVENTS, } from "./dsl/index.js";
|
|
11
|
-
export type { DslArchivedClose, DslPluginConfig, DslPositionSummary, DslState, DslTickResult, ExitBlockConfig, DslValidationIssue, DslValidationIssueCode, } from "./dsl/index.js";
|
|
12
|
-
export { initRisk } from "./risk/index.js";
|
|
13
|
-
export { createHealthStateModule, initHealth } from "./health/index.js";
|
|
14
|
-
export type { ComponentHealth, ComponentHealthStatus, ComponentSystemState, DslComponentHealthStatus, DslSystemState, RuntimeHealthStatus, RuntimeLogLevel, RuntimeSystemState, ScannerComponentHealthStatus, ScannerRegistrationSystemState, ScannerSystemState, StateStatusProvider, } from "./health/index.js";
|
|
15
|
-
export { HOOK_EVENT } from './types/index.js';
|
|
16
|
-
export type { HookEventType, HookEvent, HookSystem, StrategyConfig, StateManager, GateCheckResult, RiskGuard, NotificationService, Signal, ScanResult, } from './types/index.js';
|
|
17
|
-
export { ScanStatus } from './types/index.js';
|
|
18
|
-
export type { ActionType, DecisionMode, ActionConfig, ActionContext, ActionDecision, ActionResult, Action, ActionFactory, ActionManifest, ActionScanPayload, LlmDecisionRequest, LlmDecisionResponse, LlmDecision, } from './actions/types.js';
|
|
19
|
-
export type { ContextBuilder } from './context/types.js';
|
|
20
|
-
export { DecisionEngine, LlmDecisionStrategy, NoDecisionStrategy, } from './actions/decision-engine.js';
|
|
21
|
-
export { OpenClawLlmDecision, AnthropicLlmDecision, createLlmDecision } from './actions/llm-decision/index.js';
|
|
22
|
-
/** @deprecated Use OpenClawLlmDecision instead */
|
|
23
|
-
export { OpenClawLlmDecision as LlmDecisionClient } from './actions/llm-decision/index.js';
|
|
24
|
-
export type { DecisionStrategy, DecisionRequest } from './actions/decision-engine.js';
|
|
25
|
-
export { OpenPositionAction, openPositionFactory, openPositionManifest, } from './actions/open-position/open-position.action.js';
|
|
26
|
-
export { ClosePositionAction, closePositionFactory, closePositionManifest, } from './actions/close-position/close-position.action.js';
|
|
27
|
-
export { SenpiClient } from './senpi/index.js';
|
|
28
|
-
export type { McpTransport, SenpiClientConfig, CreatePositionRequest, CreatePositionOrder, CreatePositionResult, CreatePositionOrderResult, OrderDirection, OrderType, LeverageType, TimeInForce, ExitOrderType, StopLoss, TakeProfit, ListStrategiesFilters, StrategySummary, } from './senpi/index.js';
|
|
29
|
-
export { createScannerRuntimeModule, createSenpiScannerProviders, emergingMoversScanner, momentumScanner, oiTrackerScanner, providerInput, prescreenerScanner, PersistencePolicy, RetentionPolicy, ScanStatus as ScannerScanStatus, SkipScan, } from './scanners/index.js';
|
|
30
|
-
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';
|
|
31
|
-
export { run } from "./runtime/run.js";
|
|
32
|
-
export type { RunOptions, RuntimeHandle } from "./runtime/run.js";
|
|
33
|
-
export { loadRuntimeConfig } from "./runtime/load-runtime-config.js";
|
|
34
|
-
export type { LoadRuntimeConfigOptions } from "./runtime/load-runtime-config.js";
|
|
35
|
-
export { Runtime } from "./runtime/runtime.js";
|
|
36
|
-
export type { RuntimeOptions } from "./runtime/runtime.js";
|
|
37
|
-
/** Plugin config shape (aligned with openclaw.plugin.json configSchema). Source of truth for strategies is the registry, not config. */
|
|
38
|
-
export interface SenpiRuntimePluginConfig {
|
|
39
|
-
stateDir?: string;
|
|
40
|
-
apiKey?: string;
|
|
41
|
-
logLevel?: string;
|
|
42
|
-
autoUpdate?: Record<string, unknown>;
|
|
43
|
-
}
|
|
44
|
-
interface PluginLogger {
|
|
45
|
-
info(...args: unknown[]): void;
|
|
46
|
-
warn(...args: unknown[]): void;
|
|
47
|
-
error(message: unknown, meta?: unknown): void;
|
|
48
|
-
}
|
|
49
|
-
interface PluginApi {
|
|
50
|
-
id: string;
|
|
51
|
-
name: string;
|
|
52
|
-
pluginConfig?: Record<string, unknown>;
|
|
53
|
-
logger: PluginLogger;
|
|
54
|
-
config?: Record<string, unknown>;
|
|
55
|
-
runtime: {
|
|
56
|
-
state: {
|
|
57
|
-
resolveStateDir(): string;
|
|
58
|
-
};
|
|
59
|
-
config?: {
|
|
60
|
-
loadConfig(): Promise<unknown>;
|
|
61
|
-
writeConfigFile(config: unknown): Promise<void>;
|
|
62
|
-
};
|
|
63
|
-
};
|
|
64
|
-
registerService(service: {
|
|
65
|
-
id: string;
|
|
66
|
-
start: (ctx: {
|
|
67
|
-
stateDir: string;
|
|
68
|
-
}) => void | Promise<void>;
|
|
69
|
-
stop?: (ctx: {
|
|
70
|
-
stateDir: string;
|
|
71
|
-
}) => void | Promise<void>;
|
|
72
|
-
}): void;
|
|
73
|
-
registerCli(fn: (ctx: {
|
|
74
|
-
program: {
|
|
75
|
-
command: (name: string, desc?: string) => unknown;
|
|
76
|
-
};
|
|
77
|
-
}) => void, opts?: {
|
|
78
|
-
commands: string[];
|
|
79
|
-
}): void;
|
|
80
|
-
registerGatewayMethod(name: string, handler: (ctx: {
|
|
81
|
-
respond: (ok: boolean, value: unknown) => void;
|
|
82
|
-
params?: Record<string, unknown>;
|
|
83
|
-
}) => void | Promise<void>): void;
|
|
84
|
-
on(hookName: string, handler: (...args: unknown[]) => void | Promise<void>, opts?: {
|
|
85
|
-
priority?: number;
|
|
86
|
-
}): void;
|
|
87
|
-
}
|
|
88
|
-
/**
|
|
89
|
-
* OpenClaw plugin entry.
|
|
90
|
-
* Boots from internal registry (installed_runtimes.json) in stateDir; does not read runtime list from config.
|
|
91
|
-
*/
|
|
92
|
-
declare const senpiRuntimePlugin: {
|
|
93
|
-
id: string;
|
|
94
|
-
name: string;
|
|
95
|
-
version: string;
|
|
96
|
-
description: string;
|
|
97
|
-
configSchema: {
|
|
98
|
-
parse(value: unknown): Record<string, unknown>;
|
|
99
|
-
};
|
|
100
|
-
register(api: PluginApi): void;
|
|
101
|
-
};
|
|
102
|
-
export default senpiRuntimePlugin;
|
|
35
|
+
import "dd-trace/initialize.mjs";
|
|
36
|
+
export { default } from "./plugin.js";
|
|
37
|
+
export * from "./plugin.js";
|
|
103
38
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA
|
|
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"}
|