@reefclaw/openclaw-plugin 0.1.4 → 0.1.6

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 (124) hide show
  1. package/ccxt/binance-private.d.ts +21 -0
  2. package/ccxt/binance-private.js +132 -22
  3. package/config/plugin-config-io.d.ts +6 -0
  4. package/config/tool-gate.js +3 -0
  5. package/exchange-adapter.d.ts +16 -0
  6. package/index.js +567 -57
  7. package/lifecycle/trading-operation-lock.d.ts +17 -0
  8. package/lifecycle/trading-operation-lock.js +14 -0
  9. package/live/bracket-id.d.ts +2 -3
  10. package/live/bracket-id.js +22 -9
  11. package/live/live-adapter.d.ts +24 -1
  12. package/live/live-adapter.js +114 -2
  13. package/live/local-signal-service.js +11 -6
  14. package/live/local-strategy-evaluator.js +4 -0
  15. package/live/proposal-decision-listener.d.ts +6 -0
  16. package/live/proposal-decision-listener.js +4 -0
  17. package/live/stop-watcher.d.ts +27 -1
  18. package/live/stop-watcher.js +59 -2
  19. package/onboarding/runtime.d.ts +13 -0
  20. package/onboarding/runtime.js +22 -2
  21. package/openclaw.plugin.json +1 -0
  22. package/package.json +1 -1
  23. package/persistence/state-manager.d.ts +24 -0
  24. package/persistence/state-manager.js +62 -4
  25. package/portfolio/wave9-admission.d.ts +67 -0
  26. package/portfolio/wave9-admission.js +262 -0
  27. package/portfolio/wave9-policy.d.ts +36 -0
  28. package/portfolio/wave9-policy.js +183 -0
  29. package/signals/conditions/registry.js +50 -0
  30. package/simulator/exchange-simulator.js +5 -0
  31. package/simulator/fill-engine.js +5 -1
  32. package/simulator/types.d.ts +6 -1
  33. package/strategy/evaluator.d.ts +3 -0
  34. package/strategy/evaluator.js +5 -0
  35. package/tools/assessment-validation.d.ts +2 -0
  36. package/tools/attach-brackets.d.ts +7 -2
  37. package/tools/attach-brackets.js +36 -0
  38. package/tools/cancel-all-orders.d.ts +2 -0
  39. package/tools/cancel-all-orders.js +4 -1
  40. package/tools/cancel-order.d.ts +4 -0
  41. package/tools/cancel-order.js +49 -3
  42. package/tools/close-position.d.ts +23 -0
  43. package/tools/close-position.js +286 -13
  44. package/tools/create-order.d.ts +28 -0
  45. package/tools/create-order.js +1364 -192
  46. package/tools/get-analytics.js +2 -2
  47. package/tools/get-basis.js +2 -2
  48. package/tools/get-cascade-risk.js +2 -2
  49. package/tools/get-crypto-metrics.js +20 -3
  50. package/tools/get-cvd.js +2 -2
  51. package/tools/get-divergences.js +2 -2
  52. package/tools/get-funding-context.js +2 -2
  53. package/tools/get-liquidation-levels.js +2 -2
  54. package/tools/get-liquidation-pulse.js +2 -2
  55. package/tools/get-pattern-scan.js +2 -2
  56. package/tools/get-regime.js +2 -2
  57. package/tools/get-resting-liquidity.js +2 -2
  58. package/tools/get-risk-scenario.js +2 -2
  59. package/tools/get-session-review.js +2 -2
  60. package/tools/get-setup-detail.js +9 -1
  61. package/tools/get-signals.js +2 -2
  62. package/tools/get-sizing.js +2 -2
  63. package/tools/get-trade-feedback.js +2 -2
  64. package/tools/get-trade-flow.js +2 -2
  65. package/tools/get-volume-profile.js +2 -2
  66. package/tools/get-wave9-status.d.ts +127 -0
  67. package/tools/get-wave9-status.js +796 -0
  68. package/tools/intel-api.d.ts +20 -0
  69. package/tools/intel-api.js +67 -0
  70. package/tools/intel-cache.d.ts +1 -1
  71. package/tools/intel-cache.js +20 -5
  72. package/tools/list-strategies.d.ts +11 -1
  73. package/tools/list-strategies.js +17 -0
  74. package/tools/modify-stop.d.ts +4 -0
  75. package/tools/modify-stop.js +63 -24
  76. package/tools/modify-target.d.ts +4 -0
  77. package/tools/modify-target.js +62 -23
  78. package/tools/scan-pairs.js +19 -8
  79. package/tools/toggle-strategy.js +7 -0
  80. package/types.d.ts +5 -0
  81. package/venues/hyperliquid/hl-balance.d.ts +116 -0
  82. package/venues/hyperliquid/hl-balance.js +145 -0
  83. package/venues/hyperliquid/hl-brackets.d.ts +102 -0
  84. package/venues/hyperliquid/hl-brackets.js +172 -0
  85. package/venues/hyperliquid/hl-cloid.d.ts +22 -0
  86. package/venues/hyperliquid/hl-cloid.js +82 -0
  87. package/venues/hyperliquid/hl-info-cache.d.ts +46 -0
  88. package/venues/hyperliquid/hl-info-cache.js +125 -0
  89. package/venues/hyperliquid/hl-live-adapter.d.ts +88 -0
  90. package/venues/hyperliquid/hl-live-adapter.js +353 -0
  91. package/venues/hyperliquid/hl-precision.d.ts +61 -0
  92. package/venues/hyperliquid/hl-precision.js +176 -0
  93. package/venues/hyperliquid/hl-private.d.ts +88 -0
  94. package/venues/hyperliquid/hl-private.js +357 -0
  95. package/venues/hyperliquid/hl-public.d.ts +31 -4
  96. package/venues/hyperliquid/hl-public.js +155 -11
  97. package/venues/hyperliquid/hl-rate-gate.d.ts +57 -0
  98. package/venues/hyperliquid/hl-rate-gate.js +220 -0
  99. package/venues/hyperliquid/hl-user-stream.d.ts +90 -0
  100. package/venues/hyperliquid/hl-user-stream.js +220 -0
  101. package/venues/registry.d.ts +28 -9
  102. package/venues/registry.js +19 -13
  103. package/venues/symbols.d.ts +43 -0
  104. package/venues/symbols.js +107 -0
  105. package/wave9/live-account-capture.d.ts +67 -0
  106. package/wave9/live-account-capture.js +435 -0
  107. package/wave9/live-autonomous-protection.d.ts +39 -0
  108. package/wave9/live-autonomous-protection.js +112 -0
  109. package/wave9/live-durable-reconciliation-scheduler.d.ts +33 -0
  110. package/wave9/live-durable-reconciliation-scheduler.js +115 -0
  111. package/wave9/live-execution-ledger.d.ts +107 -0
  112. package/wave9/live-execution-ledger.js +498 -0
  113. package/wave9/live-position-confirmation.d.ts +18 -0
  114. package/wave9/live-position-confirmation.js +111 -0
  115. package/wave9/live-residual-protection.d.ts +18 -0
  116. package/wave9/live-residual-protection.js +250 -0
  117. package/wave9/live-startup-reconciliation.d.ts +38 -0
  118. package/wave9/live-startup-reconciliation.js +454 -0
  119. package/wave9/live-symbol-ownership.d.ts +20 -0
  120. package/wave9/live-symbol-ownership.js +132 -0
  121. package/wave9/paper-admission-guard.d.ts +199 -0
  122. package/wave9/paper-admission-guard.js +650 -0
  123. package/wave9/usdm-evidence-provider.d.ts +42 -0
  124. package/wave9/usdm-evidence-provider.js +133 -0
@@ -1,7 +1,7 @@
1
1
  // Tool: get_analytics — fetches edge analytics from the Intelligence API.
2
2
  // Returns per-strategy performance metrics (win rate, expectancy, Sharpe),
3
3
  // regime breakdown, equity curve, and degradation alerts.
4
- import { fetchIntelApi, enc } from './intel-api.js';
4
+ import { fetchIntelApi, enc, resolveIntelSymbol } from './intel-api.js';
5
5
  export async function getAnalyticsTool(args, deps) {
6
- return fetchIntelApi(`/api/analytics/${enc(args.symbol)}`, deps);
6
+ return fetchIntelApi(`/api/analytics/${enc(resolveIntelSymbol(deps, args.symbol))}`, deps);
7
7
  }
@@ -1,7 +1,7 @@
1
1
  // Tool: get_basis — fetches spot-futures basis (mark-spot premium) analysis.
2
2
  // Returns current premium/discount, historical basis, funding alignment, and dislocation detection.
3
- import { fetchIntelApi, enc } from './intel-api.js';
3
+ import { fetchIntelApi, enc, resolveIntelSymbol } from './intel-api.js';
4
4
  export async function getBasisTool(args, deps) {
5
5
  const hours = args.hours ?? 24;
6
- return fetchIntelApi(`/api/basis/${enc(args.symbol)}?hours=${hours}`, deps);
6
+ return fetchIntelApi(`/api/basis/${enc(resolveIntelSymbol(deps, args.symbol))}?hours=${hours}`, deps);
7
7
  }
@@ -1,8 +1,8 @@
1
1
  // Tool: get_cascade_risk — fetches liquidation cascade risk assessment.
2
2
  // Returns proximity to liquidation clusters, cascade impact estimates,
3
3
  // recent liquidation activity, and overall risk score.
4
- import { fetchIntelApi, enc } from './intel-api.js';
4
+ import { fetchIntelApi, enc, resolveIntelSymbol } from './intel-api.js';
5
5
  export async function getCascadeRiskTool(args, deps) {
6
6
  const hours = args.hours ?? 24;
7
- return fetchIntelApi(`/api/cascade-risk/${enc(args.symbol)}?hours=${hours}`, deps);
7
+ return fetchIntelApi(`/api/cascade-risk/${enc(resolveIntelSymbol(deps, args.symbol))}?hours=${hours}`, deps);
8
8
  }
@@ -1,11 +1,28 @@
1
1
  // Tool: get_crypto_metrics — funding rate + open interest from Binance perpetual futures
2
2
  // Uses dedicated CCXT methods (fetchFundingRate + fetchOpenInterest) instead of fetchTicker,
3
3
  // because Binance's 24hr ticker endpoint does NOT include funding/OI data.
4
+ import { fromIntelSymbol } from '../venues/symbols.js';
4
5
  export async function getCryptoMetricsTool(args, deps) {
5
6
  try {
6
- // Funding rate & OI only exist on perpetual futures.
7
- // Convert spot symbols (BTC/USDT) to perp format (BTC/USDT:USDT).
8
- const perpSymbol = args.symbol.includes(':') ? args.symbol : `${args.symbol}:USDT`;
7
+ // The agent routinely pastes intel-form ids into this tool ('ETHUSDT',
8
+ // 'HL_BTC' ~100×/day live as of 2026-07-13). Handed to ccxt verbatim, a
9
+ // concatenated id resolves to the SPOT market and funding/OI fail
10
+ // ("supports linear and inverse contracts only"). Map both intel
11
+ // namespaces back to canonical BASE/QUOTE first; anything fromIntelSymbol
12
+ // can't map comes back verbatim (honest passthrough, no invented quote).
13
+ const canonical = args.symbol.includes('/') || args.symbol.includes(':')
14
+ ? args.symbol
15
+ : fromIntelSymbol(args.symbol.trim()).canonical;
16
+ // Funding rate & OI only exist on perpetual futures. Convert a canonical
17
+ // symbol to its linear-perp ccxt form by settling in the QUOTE currency
18
+ // (BTC/USDT → BTC/USDT:USDT on Binance, BTC/USDC → BTC/USDC:USDC on
19
+ // Hyperliquid). A hardcoded :USDT suffix produced the nonsense form
20
+ // BTC/USDC:USDT on the HL venue (seen live, wisekid soak 2026-07-12) —
21
+ // never silently translate quote assets across venues.
22
+ const quote = canonical.split('/')[1];
23
+ const perpSymbol = canonical.includes(':') || !quote
24
+ ? canonical
25
+ : `${canonical}:${quote}`;
9
26
  // Fetch funding rate and open interest in parallel (separate API endpoints)
10
27
  const [fundingData, oiData, tickerData] = await Promise.all([
11
28
  deps.binanceApi.fetchFundingRate(perpSymbol),
package/tools/get-cvd.js CHANGED
@@ -1,6 +1,6 @@
1
1
  // Tool: get_cvd — fetches CVD (Cumulative Volume Delta) analysis from the Intelligence API.
2
2
  // Returns buy/sell pressure, divergence detection, slope, z-score, and interpretation.
3
- import { fetchIntelApi, enc } from './intel-api.js';
3
+ import { fetchIntelApi, enc, resolveIntelSymbol } from './intel-api.js';
4
4
  export async function getCvdTool(args, deps) {
5
- return fetchIntelApi(`/api/cvd/${enc(args.symbol)}`, deps);
5
+ return fetchIntelApi(`/api/cvd/${enc(resolveIntelSymbol(deps, args.symbol))}`, deps);
6
6
  }
@@ -1,6 +1,6 @@
1
1
  // Tool: get_divergences — multi-timeframe RSI/MACD divergence scanner.
2
2
  // Detects price-vs-indicator divergences across 15m, 1h, 4h, 1d timeframes.
3
- import { fetchIntelApi, enc } from './intel-api.js';
3
+ import { fetchIntelApi, enc, resolveIntelSymbol } from './intel-api.js';
4
4
  export async function getDivergencesTool(args, deps) {
5
- return fetchIntelApi(`/api/divergences/${enc(args.symbol)}`, deps);
5
+ return fetchIntelApi(`/api/divergences/${enc(resolveIntelSymbol(deps, args.symbol))}`, deps);
6
6
  }
@@ -10,7 +10,7 @@
10
10
  //
11
11
  // Returns `{ enabled: false, reason }` when the intel-side
12
12
  // FUNDING_OVERLAY flag is off or the symbol has < 100 30d samples.
13
- import { fetchIntelApi, enc } from './intel-api.js';
13
+ import { fetchIntelApi, enc, resolveIntelSymbol } from './intel-api.js';
14
14
  export async function getFundingContextTool(args, deps) {
15
- return fetchIntelApi(`/api/funding/${enc(args.symbol)}`, deps);
15
+ return fetchIntelApi(`/api/funding/${enc(resolveIntelSymbol(deps, args.symbol))}`, deps);
16
16
  }
@@ -1,7 +1,7 @@
1
1
  // Tool: get_liquidation_levels — fetches liquidation levels from the Intelligence API.
2
2
  // Returns historical liquidation clusters and estimated liquidation levels around current price.
3
- import { fetchIntelApi, enc } from './intel-api.js';
3
+ import { fetchIntelApi, enc, resolveIntelSymbol } from './intel-api.js';
4
4
  export async function getLiquidationLevelsTool(args, deps) {
5
5
  const hours = args.hours ?? 24;
6
- return fetchIntelApi(`/api/liquidation-levels/${enc(args.symbol)}?hours=${hours}`, deps);
6
+ return fetchIntelApi(`/api/liquidation-levels/${enc(resolveIntelSymbol(deps, args.symbol))}?hours=${hours}`, deps);
7
7
  }
@@ -6,11 +6,11 @@
6
6
  // When the intel-side `microstructure.liquidationPulse` flag is off,
7
7
  // returns `{ enabled: false, reason }` — operator hasn't enabled the
8
8
  // feature yet.
9
- import { fetchIntelApi } from './intel-api.js';
9
+ import { fetchIntelApi, resolveIntelSymbol } from './intel-api.js';
10
10
  export async function getLiquidationPulseTool(args, deps) {
11
11
  const params = new URLSearchParams();
12
12
  if (args.symbol)
13
- params.set('symbol', args.symbol);
13
+ params.set('symbol', resolveIntelSymbol(deps, args.symbol));
14
14
  const windowSeconds = clamp(args.window_seconds ?? 60, 5, 300);
15
15
  params.set('window_seconds', String(windowSeconds));
16
16
  return fetchIntelApi(`/api/liquidation-pulse?${params.toString()}`, deps);
@@ -1,8 +1,8 @@
1
1
  // Tool: get_pattern_scan — automated chart pattern recognition from OHLCV data.
2
2
  // Calls Intelligence API for swing points, trendlines, and 10 pattern types.
3
- import { fetchIntelApi, enc } from './intel-api.js';
3
+ import { fetchIntelApi, enc, resolveIntelSymbol } from './intel-api.js';
4
4
  export async function getPatternScanTool(args, deps) {
5
- const intelSymbol = args.symbol.replace('/', '');
5
+ const intelSymbol = resolveIntelSymbol(deps, args.symbol);
6
6
  const timeframe = args.timeframe ?? '1h';
7
7
  return fetchIntelApi(`/api/patterns/${enc(intelSymbol)}?timeframe=${enc(timeframe)}&lookback=200`, deps);
8
8
  }
@@ -1,7 +1,7 @@
1
1
  // Tool: get_regime — fetches regime classification from the Intelligence API.
2
2
  // Returns current market regime (trend_up, trend_down, range_tight, etc.)
3
3
  // with confidence, probabilities, and contributing features.
4
- import { fetchIntelApi, enc } from './intel-api.js';
4
+ import { fetchIntelApi, enc, resolveIntelSymbol } from './intel-api.js';
5
5
  export async function getRegimeTool(args, deps) {
6
- return fetchIntelApi(`/api/regime/${enc(args.symbol)}`, deps);
6
+ return fetchIntelApi(`/api/regime/${enc(resolveIntelSymbol(deps, args.symbol))}`, deps);
7
7
  }
@@ -5,7 +5,7 @@
5
5
  //
6
6
  // Returns `{ enabled: false, reason }` when the intel-side
7
7
  // `microstructure.bandedLiquidity` flag is off (= columns are NULL).
8
- import { fetchIntelApi, enc } from './intel-api.js';
8
+ import { fetchIntelApi, enc, resolveIntelSymbol } from './intel-api.js';
9
9
  export async function getRestingLiquidityTool(args, deps) {
10
- return fetchIntelApi(`/api/resting-liquidity/${enc(args.symbol)}`, deps);
10
+ return fetchIntelApi(`/api/resting-liquidity/${enc(resolveIntelSymbol(deps, args.symbol))}`, deps);
11
11
  }
@@ -2,7 +2,7 @@
2
2
  // Fetches positions + balance from simulator state, then calls Intelligence API for scenario analysis.
3
3
  // Returns: per-scenario P&L, heat, drawdown zone, stops triggered, limits breached.
4
4
  import { enc } from './intel-api.js';
5
- import { fetchIntelApi } from './intel-api.js';
5
+ import { fetchIntelApi, resolveIntelSymbol } from './intel-api.js';
6
6
  export async function getRiskScenarioTool(args, deps) {
7
7
  const positions = deps.getPositions();
8
8
  const wallet = deps.getWallet();
@@ -34,7 +34,7 @@ export async function getRiskScenarioTool(args, deps) {
34
34
  })).filter(s => !isNaN(s.movePct));
35
35
  }
36
36
  // Normalize symbol for intelligence API (BTC/USDT → BTCUSDT)
37
- const intelSymbol = args.symbol.replace('/', '');
37
+ const intelSymbol = resolveIntelSymbol(deps.intelApiDeps, args.symbol);
38
38
  const body = {
39
39
  positions: apiPositions,
40
40
  balance,
@@ -1,8 +1,8 @@
1
1
  // Tool: get_session_review — automated end-of-session performance summary.
2
2
  // Calls Intelligence API for trade stats, setup/regime breakdown, lessons, and session-over-session comparison.
3
- import { fetchIntelApi, enc } from './intel-api.js';
3
+ import { fetchIntelApi, enc, resolveIntelSymbol } from './intel-api.js';
4
4
  export async function getSessionReviewTool(args, deps) {
5
- const intelSymbol = args.symbol.replace('/', '');
5
+ const intelSymbol = resolveIntelSymbol(deps, args.symbol);
6
6
  const hours = args.hours ?? 24;
7
7
  return fetchIntelApi(`/api/session-review/${enc(intelSymbol)}?hours=${hours}`, deps);
8
8
  }
@@ -14,10 +14,18 @@
14
14
  // that direction so long and short setups produce ladders that match.
15
15
  // Cache is shared with scan_pairs (intel-cache.ts) so drill-down sees the
16
16
  // same fact snapshot the scan ranked the symbol from.
17
+ import { resolveIntelSymbol } from './intel-api.js';
17
18
  import { evaluateStrategy, } from '../strategy/evaluator.js';
18
19
  import { getFactBySymbolCached, getStrategyRowsCached } from './intel-cache.js';
19
20
  export async function getSetupDetailTool(args, deps) {
20
- const symbol = args.symbol.toUpperCase().replace(/[^A-Z0-9]/g, '');
21
+ // Venue-aware symbol resolution (plan §5.3). Binance keeps the historical
22
+ // sanitizer byte-identically; the hyperliquid arm maps agent-facing forms
23
+ // ('BTC/USDC', 'BTCUSDC') to the HL_ intel namespace and must NOT uppercase
24
+ // or strip '_' — HL coins are case-sensitive ('kPEPE' is real, 'KPEPE' is
25
+ // not) and the legacy sanitizer would mangle 'HL_BTC' into 'HLBTC'.
26
+ const symbol = (deps.venue ?? 'binance') === 'hyperliquid'
27
+ ? resolveIntelSymbol(deps, args.symbol)
28
+ : args.symbol.toUpperCase().replace(/[^A-Z0-9]/g, '');
21
29
  // 1. Fetch fact for this symbol — shared cache with scan_pairs, so a
22
30
  // drill-down after a heartbeat scan hits the same snapshot the scan
23
31
  // ranked the symbol from.
@@ -7,9 +7,9 @@
7
7
  // comparison (zero behaviour change).
8
8
  // enforce — return the locally-evaluated snapshot, falling back to central
9
9
  // when the local service has no fact for the symbol yet.
10
- import { fetchIntelApi, enc } from './intel-api.js';
10
+ import { fetchIntelApi, enc, resolveIntelSymbol } from './intel-api.js';
11
11
  async function central(args, deps) {
12
- const s = enc(args.symbol);
12
+ const s = enc(resolveIntelSymbol(deps, args.symbol));
13
13
  const [snapshot, history] = await Promise.all([
14
14
  fetchIntelApi(`/api/signals/${s}`, deps),
15
15
  fetchIntelApi(`/api/signals/${s}/history?hours=${args.hours ?? 24}`, deps),
@@ -1,6 +1,6 @@
1
1
  // Tool: get_sizing — fetches Half-Kelly position sizing recommendation from Intelligence API.
2
2
  // Returns recommended size as % of account, Kelly fraction, win rate, avg W/L ratio, vol adjustment.
3
- import { fetchIntelApi, enc } from './intel-api.js';
3
+ import { fetchIntelApi, enc, resolveIntelSymbol } from './intel-api.js';
4
4
  export async function getSizingTool(args, deps) {
5
- return fetchIntelApi(`/api/sizing/${enc(args.symbol)}`, deps);
5
+ return fetchIntelApi(`/api/sizing/${enc(resolveIntelSymbol(deps, args.symbol))}`, deps);
6
6
  }
@@ -1,8 +1,8 @@
1
1
  // Tool: get_trade_feedback — fetches structured performance feedback from Intelligence API.
2
2
  // Returns per-setup-type win rates, regime breakdown, recent outcomes, and current streak.
3
3
  // Designed for the agent to review before entering trades.
4
- import { fetchIntelApi, enc } from './intel-api.js';
4
+ import { fetchIntelApi, enc, resolveIntelSymbol } from './intel-api.js';
5
5
  export async function getTradeFeedbackTool(args, deps) {
6
6
  const hours = args.hours ?? 168;
7
- return fetchIntelApi(`/api/analytics/${enc(args.symbol)}/feedback?hours=${hours}`, deps);
7
+ return fetchIntelApi(`/api/analytics/${enc(resolveIntelSymbol(deps, args.symbol))}/feedback?hours=${hours}`, deps);
8
8
  }
@@ -1,7 +1,7 @@
1
1
  // Tool: get_trade_flow — fetches aggregated trade flow / institutional flow data.
2
2
  // Returns buy/sell volume, large trade (whale) activity, net delta, and whale pressure verdict.
3
- import { fetchIntelApi, enc } from './intel-api.js';
3
+ import { fetchIntelApi, enc, resolveIntelSymbol } from './intel-api.js';
4
4
  export async function getTradeFlowTool(args, deps) {
5
5
  const minutes = args.minutes ?? 5;
6
- return fetchIntelApi(`/api/trade-flow/${enc(args.symbol)}?minutes=${minutes}`, deps);
6
+ return fetchIntelApi(`/api/trade-flow/${enc(resolveIntelSymbol(deps, args.symbol))}?minutes=${minutes}`, deps);
7
7
  }
@@ -1,7 +1,7 @@
1
1
  // Tool: get_volume_profile — fetches volume profile from the Intelligence API.
2
2
  // Returns price buckets with buy/sell volume, POC, value area, and current price.
3
- import { fetchIntelApi, enc } from './intel-api.js';
3
+ import { fetchIntelApi, enc, resolveIntelSymbol } from './intel-api.js';
4
4
  export async function getVolumeProfileTool(args, deps) {
5
5
  const period = args.period ?? 24;
6
- return fetchIntelApi(`/api/volume-profile/${enc(args.symbol)}?period=${period}`, deps);
6
+ return fetchIntelApi(`/api/volume-profile/${enc(resolveIntelSymbol(deps, args.symbol))}?period=${period}`, deps);
7
7
  }
@@ -0,0 +1,127 @@
1
+ import { evaluateWave9Daily, type Wave9StrategyName } from '../portfolio/wave9-policy.js';
2
+ import { type Wave9EvidenceProvider } from '../wave9/usdm-evidence-provider.js';
3
+ import type { TradingOperationLock } from '../lifecycle/trading-operation-lock.js';
4
+ import type { Wave9NativeStopObservation } from '../wave9/live-account-capture.js';
5
+ import type { Wave9ExecutionMode } from '../wave9/paper-admission-guard.js';
6
+ import type { IntelApiDeps } from './intel-api.js';
7
+ export declare const WAVE9_BUNDLE_NAME = "wave9_28d_momentum_reversal";
8
+ export declare const WAVE9_EXECUTION_KERNEL = "wave9_shared_v1";
9
+ export declare const WAVE9_PAPER_ENTRY_WINDOW_MS: number;
10
+ export interface Wave9BundleActivation {
11
+ available: boolean;
12
+ name: typeof WAVE9_BUNDLE_NAME;
13
+ executionModel: typeof WAVE9_EXECUTION_KERNEL;
14
+ active: boolean;
15
+ source?: 'tenant_override' | 'global_default';
16
+ error?: string;
17
+ }
18
+ export interface Wave9ActivationClient {
19
+ getActivation(): Promise<Wave9BundleActivation>;
20
+ }
21
+ export declare class IntelWave9ActivationClient implements Wave9ActivationClient {
22
+ private readonly deps;
23
+ constructor(deps: IntelApiDeps);
24
+ getActivation(): Promise<Wave9BundleActivation>;
25
+ }
26
+ export interface Wave9ObservedPosition {
27
+ symbol: string;
28
+ side: 'long' | 'short';
29
+ quantity: number;
30
+ entryPrice: number;
31
+ markPrice: number;
32
+ stopPrice?: number;
33
+ missionId?: string;
34
+ setupType?: string;
35
+ /** Present only after an exact Wave 9 admission has recorded it. */
36
+ candidateId?: string;
37
+ /** Optional future durable geometry for authoritative open-book projection. */
38
+ strategy?: Wave9StrategyName;
39
+ accruedFundingUsd?: number;
40
+ openedAt?: string;
41
+ /** Exchange-native stop identity and liveness bound by LIVE capture. */
42
+ nativeStop?: Wave9NativeStopObservation;
43
+ /** Stable held-position geometry, excluding mark/MFE/wallet volatility. */
44
+ positionFingerprint?: string;
45
+ }
46
+ export interface Wave9AccountSnapshot {
47
+ tradingMode: 'PAPER' | 'SHADOW' | 'MICRO_LIVE' | 'LIVE';
48
+ positionsAvailable: boolean;
49
+ openOrdersAvailable: boolean;
50
+ openOrderCount?: number;
51
+ /** Wallet cash after booked fees/realized PnL, not MTM account equity. */
52
+ cashEquityAvailable: boolean;
53
+ cashEquityUsd?: number;
54
+ positions?: Wave9ObservedPosition[];
55
+ /** Persisted closed Wave 9 identities; survives a gateway restart. */
56
+ executedCandidateIds?: string[];
57
+ source: string;
58
+ /** Exact process-local account geometry bound into short-lived guards. */
59
+ accountFingerprint?: string;
60
+ authoritative: boolean;
61
+ runtimeParity: false;
62
+ provenance: string;
63
+ adapterReadiness?: string;
64
+ nativeStopProtectionAvailable?: boolean;
65
+ reasons?: string[];
66
+ }
67
+ export interface Wave9EntryAuthorizationInput {
68
+ batchId: string;
69
+ candidateId: string;
70
+ missionId: string;
71
+ symbol: string;
72
+ side: 'BUY' | 'SELL';
73
+ quantity: string;
74
+ stopPrice: string;
75
+ sequence: number;
76
+ notBeforeMs: number;
77
+ deadlineMs: number;
78
+ accountFingerprint: string;
79
+ tradingMode: Wave9ExecutionMode;
80
+ }
81
+ export interface Wave9IssuedEntryAuthorization {
82
+ token: string;
83
+ batchId: string;
84
+ candidateId: string;
85
+ missionId: string;
86
+ sequence: number;
87
+ deadlineMs: number;
88
+ accountFingerprint: string;
89
+ tradingMode: Wave9ExecutionMode;
90
+ }
91
+ export interface Wave9ExitAuthorizationInput {
92
+ candidateId: string;
93
+ missionId: string;
94
+ symbol: string;
95
+ positionSide: 'long' | 'short';
96
+ reason: 'signal_reversal';
97
+ notBeforeMs: number;
98
+ deadlineMs: number;
99
+ positionFingerprint: string;
100
+ tradingMode: Wave9ExecutionMode;
101
+ }
102
+ export interface Wave9IssuedExitAuthorization {
103
+ token: string;
104
+ candidateId: string;
105
+ missionId: string;
106
+ deadlineMs: number;
107
+ positionFingerprint?: string;
108
+ tradingMode: Wave9ExecutionMode;
109
+ }
110
+ /** Structural seam implemented by the process-local paper admission guard. */
111
+ export interface Wave9AdmissionAuthorizationIssuer {
112
+ issueBatch(decisions: readonly Wave9EntryAuthorizationInput[]): readonly Wave9IssuedEntryAuthorization[];
113
+ issueExitBatch(decisions: readonly Wave9ExitAuthorizationInput[]): readonly Wave9IssuedExitAuthorization[];
114
+ }
115
+ export interface GetWave9StatusDeps {
116
+ activationClient: Wave9ActivationClient;
117
+ getAccountSnapshot(): Promise<Wave9AccountSnapshot>;
118
+ operationLock: TradingOperationLock;
119
+ /** Wave 9 evidence and execution are pinned to Binance USD-M. */
120
+ executionVenue: string;
121
+ createEvidenceProvider?: () => Wave9EvidenceProvider;
122
+ authorizationIssuer?: Wave9AdmissionAuthorizationIssuer;
123
+ now?: () => Date;
124
+ evaluateDaily?: typeof evaluateWave9Daily;
125
+ }
126
+ export declare function wave9MissionId(candidateId: string): string;
127
+ export declare function getWave9StatusTool(deps: GetWave9StatusDeps): Promise<Record<string, unknown>>;