dexbot 1.4.25 → 1.5.1

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 (217) hide show
  1. package/CHANGELOG.md +54 -0
  2. package/README.md +6 -2
  3. package/analysis/README.md +14 -7
  4. package/analysis/ama_fitting/package.json +1 -1
  5. package/analysis/analyze_derivatives.ts +1 -1
  6. package/analysis/bot_key_utils.ts +272 -3
  7. package/analysis/bot_usage/discover_bot_accounts.ts +64 -9
  8. package/analysis/bot_usage/kibana_bot_queries.ts +40 -1
  9. package/analysis/chart_utils.ts +6 -3
  10. package/analysis/grid_correction_check.ts +56 -20
  11. package/analysis/resolve_bot_accounts.ts +199 -0
  12. package/analysis/trade_profitability.ts +36 -8
  13. package/analysis/tradingview/README.md +25 -0
  14. package/analysis/tradingview/analyze_tradingview.ts +2 -2
  15. package/analysis/trend_detection/package.json +1 -1
  16. package/claw/modules/claw_launcher.ts +5 -4
  17. package/claw/modules/credit_runtime_adapter.ts +2 -1
  18. package/claw/modules/dexbot_profiles.ts +4 -3
  19. package/claw/package.json +1 -1
  20. package/claw/runtimes/openclaw-plugin/openclaw.plugin.json +1 -1
  21. package/claw/runtimes/openclaw-plugin/package.json +1 -1
  22. package/claw/tests/test_claw_mcp_transport.ts +2 -2
  23. package/dist/analysis/analyze_derivatives.js +1 -1
  24. package/dist/analysis/bot_key_utils.d.ts +28 -1
  25. package/dist/analysis/bot_key_utils.d.ts.map +1 -1
  26. package/dist/analysis/bot_key_utils.js +385 -3
  27. package/dist/analysis/bot_key_utils.js.map +1 -1
  28. package/dist/analysis/bot_usage/discover_bot_accounts.js +60 -10
  29. package/dist/analysis/bot_usage/discover_bot_accounts.js.map +1 -1
  30. package/dist/analysis/bot_usage/kibana_bot_queries.d.ts +45 -1
  31. package/dist/analysis/bot_usage/kibana_bot_queries.d.ts.map +1 -1
  32. package/dist/analysis/bot_usage/kibana_bot_queries.js +39 -1
  33. package/dist/analysis/bot_usage/kibana_bot_queries.js.map +1 -1
  34. package/dist/analysis/chart_utils.d.ts +2 -1
  35. package/dist/analysis/chart_utils.d.ts.map +1 -1
  36. package/dist/analysis/chart_utils.js +4 -1
  37. package/dist/analysis/chart_utils.js.map +1 -1
  38. package/dist/analysis/grid_correction_check.d.ts.map +1 -1
  39. package/dist/analysis/grid_correction_check.js +60 -20
  40. package/dist/analysis/grid_correction_check.js.map +1 -1
  41. package/dist/analysis/resolve_bot_accounts.d.ts +3 -0
  42. package/dist/analysis/resolve_bot_accounts.d.ts.map +1 -0
  43. package/dist/analysis/resolve_bot_accounts.js +216 -0
  44. package/dist/analysis/resolve_bot_accounts.js.map +1 -0
  45. package/dist/analysis/trade_profitability.d.ts.map +1 -1
  46. package/dist/analysis/trade_profitability.js +40 -8
  47. package/dist/analysis/trade_profitability.js.map +1 -1
  48. package/dist/analysis/tradingview/analyze_tradingview.js +2 -2
  49. package/dist/analysis/tradingview/analyze_tradingview.js.map +1 -1
  50. package/dist/bot.d.ts.map +1 -1
  51. package/dist/bot.js +2 -1
  52. package/dist/bot.js.map +1 -1
  53. package/dist/dexbot.d.ts.map +1 -1
  54. package/dist/dexbot.js +73 -17
  55. package/dist/dexbot.js.map +1 -1
  56. package/dist/market_adapter/ama_signal_runner.js +2 -2
  57. package/dist/market_adapter/inputs/fetch_cex_synthetic_data.js +2 -1
  58. package/dist/market_adapter/inputs/fetch_cex_synthetic_data.js.map +1 -1
  59. package/dist/market_adapter/inputs/fetch_lp_data.d.ts +4 -1
  60. package/dist/market_adapter/inputs/fetch_lp_data.d.ts.map +1 -1
  61. package/dist/market_adapter/inputs/fetch_lp_data.js +3 -2
  62. package/dist/market_adapter/inputs/fetch_lp_data.js.map +1 -1
  63. package/dist/modules/account_bots.d.ts +42 -1
  64. package/dist/modules/account_bots.d.ts.map +1 -1
  65. package/dist/modules/account_bots.js +168 -17
  66. package/dist/modules/account_bots.js.map +1 -1
  67. package/dist/modules/account_orders.d.ts +7 -1
  68. package/dist/modules/account_orders.d.ts.map +1 -1
  69. package/dist/modules/account_orders.js +34 -1
  70. package/dist/modules/account_orders.js.map +1 -1
  71. package/dist/modules/bitshares_client.d.ts +4 -1
  72. package/dist/modules/bitshares_client.d.ts.map +1 -1
  73. package/dist/modules/bitshares_client.js +12 -4
  74. package/dist/modules/bitshares_client.js.map +1 -1
  75. package/dist/modules/bot_settings.d.ts.map +1 -1
  76. package/dist/modules/bot_settings.js +2 -1
  77. package/dist/modules/bot_settings.js.map +1 -1
  78. package/dist/modules/cli_colors.d.ts +39 -0
  79. package/dist/modules/cli_colors.d.ts.map +1 -0
  80. package/dist/modules/cli_colors.js +42 -0
  81. package/dist/modules/cli_colors.js.map +1 -0
  82. package/dist/modules/constants.d.ts +2 -0
  83. package/dist/modules/constants.d.ts.map +1 -1
  84. package/dist/modules/constants.js +27 -11
  85. package/dist/modules/constants.js.map +1 -1
  86. package/dist/modules/credit_pricing.d.ts +61 -0
  87. package/dist/modules/credit_pricing.d.ts.map +1 -0
  88. package/dist/modules/credit_pricing.js +237 -0
  89. package/dist/modules/credit_pricing.js.map +1 -0
  90. package/dist/modules/credit_runtime.d.ts +1 -0
  91. package/dist/modules/credit_runtime.d.ts.map +1 -1
  92. package/dist/modules/credit_runtime.js +49 -107
  93. package/dist/modules/credit_runtime.js.map +1 -1
  94. package/dist/modules/dexbot_class.d.ts +3 -1
  95. package/dist/modules/dexbot_class.d.ts.map +1 -1
  96. package/dist/modules/dexbot_class.js +22 -6
  97. package/dist/modules/dexbot_class.js.map +1 -1
  98. package/dist/modules/dexbot_cow_runtime.d.ts +36 -2
  99. package/dist/modules/dexbot_cow_runtime.d.ts.map +1 -1
  100. package/dist/modules/dexbot_cow_runtime.js +434 -20
  101. package/dist/modules/dexbot_cow_runtime.js.map +1 -1
  102. package/dist/modules/dexbot_maintenance_runtime.d.ts +15 -16
  103. package/dist/modules/dexbot_maintenance_runtime.d.ts.map +1 -1
  104. package/dist/modules/dexbot_maintenance_runtime.js +69 -42
  105. package/dist/modules/dexbot_maintenance_runtime.js.map +1 -1
  106. package/dist/modules/dexbot_startup_runtime.d.ts +1 -0
  107. package/dist/modules/dexbot_startup_runtime.d.ts.map +1 -1
  108. package/dist/modules/dexbot_startup_runtime.js +12 -1
  109. package/dist/modules/dexbot_startup_runtime.js.map +1 -1
  110. package/dist/modules/dexbot_state_recovery.d.ts.map +1 -1
  111. package/dist/modules/dexbot_state_recovery.js +7 -0
  112. package/dist/modules/dexbot_state_recovery.js.map +1 -1
  113. package/dist/modules/fund_registry.d.ts +1 -1
  114. package/dist/modules/fund_registry.js +1 -1
  115. package/dist/modules/launcher/adapter_requirement.d.ts +38 -0
  116. package/dist/modules/launcher/adapter_requirement.d.ts.map +1 -0
  117. package/dist/modules/launcher/adapter_requirement.js +141 -0
  118. package/dist/modules/launcher/adapter_requirement.js.map +1 -0
  119. package/dist/modules/launcher/bot_supervisor.d.ts +2 -2
  120. package/dist/modules/launcher/bot_supervisor.d.ts.map +1 -1
  121. package/dist/modules/launcher/bot_supervisor.js +32 -3
  122. package/dist/modules/launcher/bot_supervisor.js.map +1 -1
  123. package/dist/modules/launcher/launch_modes.d.ts.map +1 -1
  124. package/dist/modules/launcher/launch_modes.js +5 -4
  125. package/dist/modules/launcher/launch_modes.js.map +1 -1
  126. package/dist/modules/launcher/monolithic_runtime.d.ts +1 -1
  127. package/dist/modules/launcher/monolithic_runtime.d.ts.map +1 -1
  128. package/dist/modules/launcher/monolithic_runtime.js +12 -8
  129. package/dist/modules/launcher/monolithic_runtime.js.map +1 -1
  130. package/dist/modules/launcher/status_reporting.d.ts +6 -6
  131. package/dist/modules/launcher/status_reporting.d.ts.map +1 -1
  132. package/dist/modules/launcher/status_reporting.js +9 -6
  133. package/dist/modules/launcher/status_reporting.js.map +1 -1
  134. package/dist/modules/order/accounting.d.ts +34 -0
  135. package/dist/modules/order/accounting.d.ts.map +1 -1
  136. package/dist/modules/order/accounting.js +182 -5
  137. package/dist/modules/order/accounting.js.map +1 -1
  138. package/dist/modules/order/export.d.ts +1 -1
  139. package/dist/modules/order/export.js +1 -1
  140. package/dist/modules/order/grid.d.ts.map +1 -1
  141. package/dist/modules/order/grid.js +68 -28
  142. package/dist/modules/order/grid.js.map +1 -1
  143. package/dist/modules/order/grid_reconcile_internal.d.ts.map +1 -1
  144. package/dist/modules/order/grid_reconcile_internal.js +72 -0
  145. package/dist/modules/order/grid_reconcile_internal.js.map +1 -1
  146. package/dist/modules/order/logger.d.ts +23 -1
  147. package/dist/modules/order/logger.d.ts.map +1 -1
  148. package/dist/modules/order/logger.js +60 -17
  149. package/dist/modules/order/logger.js.map +1 -1
  150. package/dist/modules/order/manager.d.ts +41 -1
  151. package/dist/modules/order/manager.d.ts.map +1 -1
  152. package/dist/modules/order/manager.js +186 -17
  153. package/dist/modules/order/manager.js.map +1 -1
  154. package/dist/modules/order/strategy.d.ts.map +1 -1
  155. package/dist/modules/order/strategy.js +17 -2
  156. package/dist/modules/order/strategy.js.map +1 -1
  157. package/dist/modules/order/sync_engine.d.ts.map +1 -1
  158. package/dist/modules/order/sync_engine.js +59 -9
  159. package/dist/modules/order/sync_engine.js.map +1 -1
  160. package/dist/modules/order/utils/math.d.ts +42 -1
  161. package/dist/modules/order/utils/math.d.ts.map +1 -1
  162. package/dist/modules/order/utils/math.js +91 -1
  163. package/dist/modules/order/utils/math.js.map +1 -1
  164. package/dist/modules/order/utils/order.d.ts +52 -1
  165. package/dist/modules/order/utils/order.d.ts.map +1 -1
  166. package/dist/modules/order/utils/order.js +137 -7
  167. package/dist/modules/order/utils/order.js.map +1 -1
  168. package/dist/modules/order/utils/system.d.ts +66 -4
  169. package/dist/modules/order/utils/system.d.ts.map +1 -1
  170. package/dist/modules/order/utils/system.js +156 -16
  171. package/dist/modules/order/utils/system.js.map +1 -1
  172. package/dist/modules/order/utils/validate.d.ts +30 -3
  173. package/dist/modules/order/utils/validate.d.ts.map +1 -1
  174. package/dist/modules/order/utils/validate.js +206 -11
  175. package/dist/modules/order/utils/validate.js.map +1 -1
  176. package/dist/modules/utils/chain_logs.d.ts +11 -0
  177. package/dist/modules/utils/chain_logs.d.ts.map +1 -0
  178. package/dist/modules/utils/chain_logs.js +23 -0
  179. package/dist/modules/utils/chain_logs.js.map +1 -0
  180. package/dist/modules/utils/sanitize_key.d.ts +7 -0
  181. package/dist/modules/utils/sanitize_key.d.ts.map +1 -1
  182. package/dist/modules/utils/sanitize_key.js +15 -0
  183. package/dist/modules/utils/sanitize_key.js.map +1 -1
  184. package/dist/pm2.d.ts +11 -1
  185. package/dist/pm2.d.ts.map +1 -1
  186. package/dist/pm2.js +66 -15
  187. package/dist/pm2.js.map +1 -1
  188. package/dist/scripts/analyze-credit.d.ts +4 -0
  189. package/dist/scripts/analyze-credit.d.ts.map +1 -0
  190. package/dist/scripts/analyze-credit.js +760 -0
  191. package/dist/scripts/analyze-credit.js.map +1 -0
  192. package/dist/scripts/analyze-orders.d.ts +1 -10
  193. package/dist/scripts/analyze-orders.d.ts.map +1 -1
  194. package/dist/scripts/analyze-orders.js +11 -34
  195. package/dist/scripts/analyze-orders.js.map +1 -1
  196. package/dist/scripts/test-credit-renewal.d.ts.map +1 -1
  197. package/dist/scripts/test-credit-renewal.js +37 -5
  198. package/dist/scripts/test-credit-renewal.js.map +1 -1
  199. package/dist/scripts/tv.d.ts +11 -0
  200. package/dist/scripts/tv.d.ts.map +1 -0
  201. package/dist/scripts/tv.js +357 -0
  202. package/dist/scripts/tv.js.map +1 -0
  203. package/dist/scripts/update.js +77 -10
  204. package/dist/scripts/update.js.map +1 -1
  205. package/dist/unlock.d.ts.map +1 -1
  206. package/dist/unlock.js +20 -8
  207. package/dist/unlock.js.map +1 -1
  208. package/docs/DEXBOT_COMPARISON.md +3 -3
  209. package/docs/EVOLUTION.md +8 -6
  210. package/docs/FUND_MOVEMENT_AND_ACCOUNTING.md +3 -1
  211. package/docs/GRID_RECONCILE.md +1 -0
  212. package/docs/LOGGING.md +3 -0
  213. package/docs/MPA_CREDIT_USAGE.md +3 -1
  214. package/docs/README.md +2 -2
  215. package/docs/WORKFLOW.md +3 -1
  216. package/package.json +2 -1
  217. package/scripts/README.md +12 -0
@@ -5,6 +5,7 @@ import fs from 'node:fs';
5
5
  import { pathToFileURL } from 'node:url';
6
6
  import * as KC from '../market_adapter/core/kibana_client.js';
7
7
  import * as C from '../modules/constants.js';
8
+ import { findBotKeyByAccountRef, getStoredBotAccountId, persistBotAccountId } from './bot_key_utils.js';
8
9
 
9
10
  const { kibanaSearch, DEFAULT_CONFIG: BASE_CONFIG } = KC;
10
11
 
@@ -194,14 +195,15 @@ Analyzes filled orders for a BitShares account, computing realized PnL
194
195
  via FIFO or sequential (LIFO) inventory tracking.
195
196
 
196
197
  Arguments:
197
- accountId BitShares account ID (1.2.x) or name (with --lookup)
198
+ accountId BitShares account ID (1.2.x) or name (auto-resolved in the background)
198
199
 
199
200
  Options:
200
201
  --start <iso> Start time (ISO 8601, e.g. 2025-01-01 or 2025-01-01T00:00:00Z)
201
202
  --end <iso> End time (ISO 8601)
202
203
  --hours <n> Lookback hours from now (alternative to --start/--end)
203
204
  --asset <assetId> Filter to one base asset (e.g. 1.3.113 for bitUSD)
204
- --lookup Resolve account name to ID via BitShares node
205
+ --lookup Legacy (no-op): account names always resolve automatically
206
+ --refresh-account Force re-resolution and update the stored accountId
205
207
  --node <url> BitShares node URL (default: first healthy from built-in pool)
206
208
  --csv <file> Export trade list as CSV
207
209
  --json <file> Export full analysis as JSON
@@ -233,6 +235,7 @@ function parseArgs() {
233
235
  end: null,
234
236
  asset: null,
235
237
  lookup: false,
238
+ refreshAccount: false,
236
239
  node: C.NODE_MANAGEMENT.DEFAULT_NODES[0],
237
240
  csv: null,
238
241
  json: null,
@@ -249,6 +252,7 @@ function parseArgs() {
249
252
  case '--end': opts.end = args[++i]; break;
250
253
  case '--asset': opts.asset = args[++i]; break;
251
254
  case '--lookup': opts.lookup = true; break;
255
+ case '--refresh-account': opts.refreshAccount = true; break;
252
256
  case '--node': opts.node = args[++i]; break;
253
257
  case '--csv': opts.csv = args[++i]; break;
254
258
  case '--json': opts.json = args[++i]; break;
@@ -1329,13 +1333,37 @@ async function run() {
1329
1333
  const opts = parseArgs();
1330
1334
  let accountId = opts.accountId;
1331
1335
 
1332
- if (opts.lookup) {
1333
- const resolved = await resolveAccountId(accountId, opts.node);
1334
- if (!resolved) {
1335
- console.error(` Could not resolve "${accountId}" to an account ID`);
1336
- process.exit(1);
1336
+ if (!/^1\.2\.\d+$/.test(String(accountId))) {
1337
+ // Background resolution: the Kibana query below filters on the 1.2.x
1338
+ // account_id field, so a name must always resolve first (a raw name
1339
+ // would silently return zero fills).
1340
+ // Stored ID first: when the name belongs to a bot in profiles/bots.json
1341
+ // and its stamped accountId still matches, no chain lookup is needed.
1342
+ let matchedKey: string | null = null;
1343
+ let stored: string | null = null;
1344
+ try {
1345
+ const match = findBotKeyByAccountRef(accountId);
1346
+ if (match) {
1347
+ matchedKey = match.botKey;
1348
+ stored = getStoredBotAccountId(match.botKey, accountId);
1349
+ }
1350
+ } catch (_) {
1351
+ // bots.json issues must never break resolution; fall through to chain.
1352
+ }
1353
+ if (stored && !opts.refreshAccount) {
1354
+ console.log(` Using stored accountId ${stored} from profiles/bots.json (no lookup needed; pass --refresh-account to re-verify)`);
1355
+ accountId = stored;
1356
+ } else {
1357
+ const resolved = await resolveAccountId(accountId, opts.node);
1358
+ if (!resolved) {
1359
+ console.error(` Could not resolve "${accountId}" to an account ID`);
1360
+ process.exit(1);
1361
+ }
1362
+ accountId = resolved;
1363
+ if (matchedKey && persistBotAccountId(matchedKey, resolved)) {
1364
+ console.log(` Stored accountId ${resolved} in profiles/bots.json`);
1365
+ }
1337
1366
  }
1338
- accountId = resolved;
1339
1367
  }
1340
1368
 
1341
1369
  // Build time range
@@ -2,6 +2,31 @@
2
2
 
3
3
  This exporter generates a standalone HTML chart in the `analysis/charts/` folder using the local `uPlot`-based TradingView-style renderer.
4
4
 
5
+ ## Recommended: `dexbot tv` (One Step)
6
+
7
+ `dexbot tv` fetches the candles itself (chunked Kibana scans for pools, order-book fallback for pairs) and then renders through this exporter — no manual fetch/export steps needed:
8
+
9
+ ```bash
10
+ # Bot chart with AMA overlay (bot key from profiles/bots.json, default: 3 months)
11
+ dexbot tv <bot>
12
+
13
+ # Any pool by bare or full ID
14
+ dexbot tv 133
15
+ dexbot tv 1.19.133
16
+
17
+ # Any pair (pool-first, order-book fallback)
18
+ dexbot tv TOKENA/TOKENB
19
+
20
+ # Options
21
+ dexbot tv <bot> --month 6 # months of 1h candles (default: 3)
22
+ dexbot tv <bot> --chart analysis/charts/custom.html
23
+ dexbot tv <bot> --scale linear # log (default) or linear
24
+ ```
25
+
26
+ Output: `analysis/charts/tv_<bot|pool_<id>|<a>_<b>>_1h_<N>m.html`, with a clickable `file://` link printed on completion. Unknown targets fail fast with the list of known bot keys.
27
+
28
+ The sections below cover manual usage (explicit candle files, direct runner flags).
29
+
5
30
  ## What It Produces
6
31
 
7
32
  - Log-scale price chart
@@ -11,7 +11,7 @@ import { getErrorMessage } from '../../modules/utils/errors.js';
11
11
  import { toIntervalLabel } from '../../market_adapter/interval_utils.js';
12
12
  import { loadBotMeta } from '../bot_key_utils.js';
13
13
  import { resolveSource, listAvailableBots } from '../resolve_source.js';
14
- import { writeChartFile } from '../chart_utils.js';
14
+ import { writeChartFile, toFileUrl } from '../chart_utils.js';
15
15
  import { PATHS } from '../../modules/paths.js';
16
16
 
17
17
 
@@ -148,7 +148,7 @@ async function main() {
148
148
 
149
149
  writeChartFile(config.chartFile, html);
150
150
 
151
- if (!config.quiet) console.log(`[TradingView] ✓ Chart saved to ${config.chartFile}`);
151
+ if (!config.quiet) console.log(`\n[TradingView] ✓ Chart saved. Open chart: (${toFileUrl(config.chartFile)})`);
152
152
  } catch (err: any) {
153
153
  console.error(`[TradingView] Error: ${getErrorMessage(err)}`);
154
154
  process.exit(1);
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "trend-detection",
3
- "version": "1.4.25",
3
+ "version": "1.5.1",
4
4
  "description": "Kalman filter trend detection with tactical/modal state tracking",
5
5
  "main": "../../dist/analysis/trend_detection/kalman_trend_analyzer.js",
6
6
  "scripts": {
@@ -9,6 +9,7 @@ import { loadSettingsFile, resolveRawBotEntries, saveSettingsFile, normalizeBotE
9
9
  import { normalizeMode, detectMode, setPreferredMode, describeModeChoice } from './launcher_mode_detector.js';
10
10
  import { normalizeRoot, resolveRuntimeScript, normalizeProfileDir } from './launcher_paths.js';
11
11
  import { getErrorMessage } from '../../modules/utils/errors.js';
12
+ import { isSameBotName } from '../../modules/utils/sanitize_key.js';
12
13
 
13
14
  const storage = getStorage();
14
15
 
@@ -174,7 +175,7 @@ async function launcherReset(botName: string | null, options: Record<string, any
174
175
  const { config } = loadSettingsFile(PROFILES_BOTS_FILE);
175
176
  const entries = normalizeBotEntries(resolveRawBotEntries(config));
176
177
 
177
- const targets = botName ? entries.filter((b: any) => b.name === botName) : entries.filter((b: any) => b.active !== false);
178
+ const targets = botName ? entries.filter((b: any) => isSameBotName(b.name, botName)) : entries.filter((b: any) => b.active !== false);
178
179
 
179
180
  if (botName && targets.length === 0) {
180
181
  throw new Error(`Bot '${botName}' not found in ${PROFILES_BOTS_FILE}`);
@@ -235,7 +236,7 @@ async function launcherDisable(botName: string | null, options: Record<string, a
235
236
  };
236
237
  }
237
238
 
238
- const match = entries.find((b: any) => b.name === botName);
239
+ const match = entries.find((b: any) => isSameBotName(b.name, botName));
239
240
  if (!match) {
240
241
  throw new Error(`Bot '${botName}' not found in ${PROFILES_BOTS_FILE}`);
241
242
  }
@@ -268,7 +269,7 @@ async function launcherPm2Start(botName: string | null, options: Record<string,
268
269
  const { config } = loadSettingsFile(PROFILES_BOTS_FILE);
269
270
  const entries = normalizeBotEntries(resolveRawBotEntries(config));
270
271
 
271
- const targets = botName ? entries.filter((b: any) => b.name === botName) : entries.filter((b: any) => b.active !== false);
272
+ const targets = botName ? entries.filter((b: any) => isSameBotName(b.name, botName)) : entries.filter((b: any) => b.active !== false);
272
273
 
273
274
  if (botName && targets.length === 0) {
274
275
  throw new Error(`Bot '${botName}' not found or not active in ${PROFILES_BOTS_FILE}`);
@@ -287,7 +288,7 @@ async function launcherPm2Start(botName: string | null, options: Record<string,
287
288
  // Filter apps if specific bot requested
288
289
  let appsToStart = apps;
289
290
  if (botName) {
290
- appsToStart = apps.filter((app: any) => app.name === botName);
291
+ appsToStart = apps.filter((app: any) => isSameBotName(app.name, botName));
291
292
  if (appsToStart.length === 0) {
292
293
  throw new Error(`No PM2 app found for bot '${botName}'`);
293
294
  }
@@ -3,6 +3,7 @@
3
3
  import { PATHS } from '../../modules/paths.js';
4
4
  import CreditRuntime from '../../modules/credit_runtime.js';
5
5
  import { getErrorMessage } from '../../modules/utils/errors.js';
6
+ import { isSameBotName } from '../../modules/utils/sanitize_key.js';
6
7
 
7
8
 
8
9
  function createCreditRuntimeAdapter(infra: any, options: Record<string, any> = {}) {
@@ -55,7 +56,7 @@ function createCreditRuntimeAdapter(infra: any, options: Record<string, any> = {
55
56
  try {
56
57
  const bundle = await infra.profiles.loadBundle();
57
58
  const match = bundle.bots.find(
58
- (b: Record<string, any>) => b.botKey === botRef || b.name === botRef,
59
+ (b: Record<string, any>) => isSameBotName(b.botKey, botRef) || isSameBotName(b.name, botRef),
59
60
  );
60
61
  return match || null;
61
62
  } catch {
@@ -10,6 +10,7 @@ import { acquireFileLock } from '../../market_adapter/utils/file_lock.js';
10
10
  import { assertNoDuplicateBotKeys } from '../../modules/bot_settings.js';
11
11
  import { clone } from './utils.js';
12
12
  import { createBotKey, sanitizeKey } from '../../modules/account_orders.js';
13
+ import { isSameBotName } from '../../modules/utils/sanitize_key.js';
13
14
  const storage = getStorage();
14
15
 
15
16
  import type { BotSettings, ProfileOptions, ClawProfileBundle } from './types.js';
@@ -815,10 +816,10 @@ function matchBotIdentifier(bot: any, identifier: any) {
815
816
  }
816
817
 
817
818
  if (typeof identifier === 'object') {
818
- if (identifier.botKey && bot.botKey === identifier.botKey) {
819
+ if (identifier.botKey && (bot.botKey === identifier.botKey || isSameBotName(bot.botKey, identifier.botKey))) {
819
820
  return true;
820
821
  }
821
- if (identifier.name && bot.name === identifier.name) {
822
+ if (identifier.name && isSameBotName(bot.name, identifier.name)) {
822
823
  return true;
823
824
  }
824
825
  if (identifier.assetA && identifier.assetB && bot.assetA === identifier.assetA && bot.assetB === identifier.assetB) {
@@ -839,7 +840,7 @@ function matchBotIdentifier(bot: any, identifier: any) {
839
840
  return false;
840
841
  }
841
842
 
842
- if (bot.botKey === value || bot.name === value) {
843
+ if (bot.botKey === value || isSameBotName(bot.botKey, value) || isSameBotName(bot.name, value)) {
843
844
  return true;
844
845
  }
845
846
 
package/claw/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dexbot2-claw",
3
- "version": "1.4.25",
3
+ "version": "1.5.1",
4
4
  "private": true,
5
5
  "description": "Claw bridge and runtime integration layer for BitShares and DEXBot2.",
6
6
  "type": "module",
@@ -2,7 +2,7 @@
2
2
  "id": "bitshares-claw",
3
3
  "name": "BitShares Claw",
4
4
  "description": "Native BitShares and DEXBot2 tools from the DEXBot2 claw integration",
5
- "version": "1.4.25",
5
+ "version": "1.5.1",
6
6
  "skills": [
7
7
  "skills"
8
8
  ],
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "bitshares-claw-openclaw-plugin",
3
3
  "private": true,
4
- "version": "1.4.25",
4
+ "version": "1.5.1",
5
5
  "type": "module",
6
6
  "main": "index.js"
7
7
  }
@@ -30,7 +30,7 @@ async function testParserAcceptsJsonlAcrossChunksAndSingleBuffer() {
30
30
  capabilities: {},
31
31
  clientInfo: {
32
32
  name: 'claw-mcp-transport-test',
33
- version: '1.4.25'
33
+ version: '1.5.1'
34
34
  },
35
35
  protocolVersion: '2024-11-05'
36
36
  }
@@ -187,7 +187,7 @@ async function testMainEntrypointHandlesRealProcessInitialize() {
187
187
  capabilities: {},
188
188
  clientInfo: {
189
189
  name: 'claw-mcp-transport-test',
190
- version: '1.4.25'
190
+ version: '1.5.1'
191
191
  },
192
192
  protocolVersion: '2024-11-05'
193
193
  }
@@ -13,7 +13,7 @@
13
13
  *
14
14
  * node dist/analysis/analyze_derivatives.js \\
15
15
  * --source market_adapter \
16
- * --bot-key XRP-BTS
16
+ * --bot-key AAA-BBB
17
17
  *
18
18
  * Output:
19
19
  * analysis/charts/derivative_chart.html
@@ -5,7 +5,34 @@ declare function resolveBotKey(botName: any, filePath?: string): string | null;
5
5
  declare function candleFileForBot(botKey: string, intervalLabel: string, dataDir?: string): string;
6
6
  declare function resolveCandleFile(botKey: string, intervalLabel: string, dataDir?: string, botsFile?: string): string | null;
7
7
  declare function loadBotMeta(botKey: any, filePath?: string): any;
8
+ /**
9
+ * Persist a resolved account name → ID mapping onto the bot entry in
10
+ * profiles/bots.json (`accountId` next to `preferredAccount`), so analysis
11
+ * tools can skip the chain lookup on subsequent runs. No-op when the stored
12
+ * value already matches. Prefers a byte-preserving textual patch (comments,
13
+ * key order and formatting survive); falls back to a full rewrite using the
14
+ * same atomic writeJSON serialization the bot editor uses. Returns true when
15
+ * the file was updated.
16
+ */
17
+ declare function persistBotAccountId(botKey: any, accountId: string, filePath?: string): boolean;
18
+ /**
19
+ * Return the stored chain account ID for a bot key, or null when none is
20
+ * stamped yet. When expectedRef is given, the stored ID is only returned if
21
+ * the entry's current preferredAccount still matches it — a rename must
22
+ * never silently reuse a stale ID.
23
+ */
24
+ declare function getStoredBotAccountId(botKey: any, expectedRef?: string | null, filePath?: string): string | null;
25
+ /**
26
+ * Find the bot entry whose preferredAccount matches a raw account reference
27
+ * (case-insensitive). Used by tools that accept a bare account name to locate
28
+ * the stored accountId and the persist target. Returns null for 1.2.x input
29
+ * or when no bot claims the name.
30
+ */
31
+ declare function findBotKeyByAccountRef(ref: any, filePath?: string): {
32
+ botKey: string;
33
+ meta: any;
34
+ } | null;
8
35
  declare function resolveAmaConfig(botKey: any): any;
9
36
  declare function resolveAmaKey(botKey: any): string;
10
- export { loadBotSettings, sanitizeKey, computeBotKey, resolveBotKey, candleFileForBot, resolveCandleFile, loadBotMeta, resolveAmaConfig, resolveAmaKey };
37
+ export { loadBotSettings, sanitizeKey, computeBotKey, resolveBotKey, candleFileForBot, resolveCandleFile, loadBotMeta, getStoredBotAccountId, findBotKeyByAccountRef, persistBotAccountId, resolveAmaConfig, resolveAmaKey };
11
38
  //# sourceMappingURL=bot_key_utils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"bot_key_utils.d.ts","sourceRoot":"","sources":["../../analysis/bot_key_utils.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,WAAW,EAAE,MAAM,kCAAkC,CAAC;AAU/D,iBAAS,eAAe,CAAC,QAAQ,SAA2B,OAO3D;AAED,iBAAS,aAAa,CAAC,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,UAM7C;AAED,iBAAS,aAAa,CAAC,OAAO,EAAE,GAAG,EAAE,QAAQ,SAA2B,iBAQvE;AAED,iBAAS,gBAAgB,CAAC,MAAM,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,EAAE,OAAO,SAAgC,UAEvG;AAED,iBAAS,iBAAiB,CAAC,MAAM,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,EAAE,OAAO,SAAgC,EAAE,QAAQ,SAA2B,iBAS7I;AAED,iBAAS,WAAW,CAAC,MAAM,EAAE,GAAG,EAAE,QAAQ,SAA2B,OASpE;AAED,iBAAS,gBAAgB,CAAC,MAAM,EAAE,GAAG,OAuEpC;AAED,iBAAS,aAAa,CAAC,MAAM,EAAE,GAAG,UAQjC;AAED,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,aAAa,EAAE,aAAa,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,WAAW,EAAE,gBAAgB,EAAE,aAAa,EAAE,CAAA"}
1
+ {"version":3,"file":"bot_key_utils.d.ts","sourceRoot":"","sources":["../../analysis/bot_key_utils.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,WAAW,EAAE,MAAM,kCAAkC,CAAC;AAU/D,iBAAS,eAAe,CAAC,QAAQ,SAA2B,OAa3D;AAED,iBAAS,aAAa,CAAC,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,UAM7C;AAED,iBAAS,aAAa,CAAC,OAAO,EAAE,GAAG,EAAE,QAAQ,SAA2B,iBAQvE;AAED,iBAAS,gBAAgB,CAAC,MAAM,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,EAAE,OAAO,SAAgC,UAEvG;AAED,iBAAS,iBAAiB,CAAC,MAAM,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,EAAE,OAAO,SAAgC,EAAE,QAAQ,SAA2B,iBAS7I;AAED,iBAAS,WAAW,CAAC,MAAM,EAAE,GAAG,EAAE,QAAQ,SAA2B,OASpE;AAwLD;;;;;;;;GAQG;AACH,iBAAS,mBAAmB,CAAC,MAAM,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,SAA2B,GAAG,OAAO,CAwBzG;AAED;;;;;GAKG;AACH,iBAAS,qBAAqB,CAAC,MAAM,EAAE,GAAG,EAAE,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,EAAE,QAAQ,SAA2B,GAAG,MAAM,GAAG,IAAI,CAY3H;AAED;;;;;GAKG;AACH,iBAAS,sBAAsB,CAAC,GAAG,EAAE,GAAG,EAAE,QAAQ,SAA2B,GAAG;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,GAAG,CAAA;CAAE,GAAG,IAAI,CAiBnH;AAED,iBAAS,gBAAgB,CAAC,MAAM,EAAE,GAAG,OAuEpC;AAED,iBAAS,aAAa,CAAC,MAAM,EAAE,GAAG,UAQjC;AAED,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,aAAa,EAAE,aAAa,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,WAAW,EAAE,qBAAqB,EAAE,sBAAsB,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,aAAa,EAAE,CAAA"}