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.
- package/CHANGELOG.md +54 -0
- package/README.md +6 -2
- package/analysis/README.md +14 -7
- package/analysis/ama_fitting/package.json +1 -1
- package/analysis/analyze_derivatives.ts +1 -1
- package/analysis/bot_key_utils.ts +272 -3
- package/analysis/bot_usage/discover_bot_accounts.ts +64 -9
- package/analysis/bot_usage/kibana_bot_queries.ts +40 -1
- package/analysis/chart_utils.ts +6 -3
- package/analysis/grid_correction_check.ts +56 -20
- package/analysis/resolve_bot_accounts.ts +199 -0
- package/analysis/trade_profitability.ts +36 -8
- package/analysis/tradingview/README.md +25 -0
- package/analysis/tradingview/analyze_tradingview.ts +2 -2
- package/analysis/trend_detection/package.json +1 -1
- package/claw/modules/claw_launcher.ts +5 -4
- package/claw/modules/credit_runtime_adapter.ts +2 -1
- package/claw/modules/dexbot_profiles.ts +4 -3
- package/claw/package.json +1 -1
- package/claw/runtimes/openclaw-plugin/openclaw.plugin.json +1 -1
- package/claw/runtimes/openclaw-plugin/package.json +1 -1
- package/claw/tests/test_claw_mcp_transport.ts +2 -2
- package/dist/analysis/analyze_derivatives.js +1 -1
- package/dist/analysis/bot_key_utils.d.ts +28 -1
- package/dist/analysis/bot_key_utils.d.ts.map +1 -1
- package/dist/analysis/bot_key_utils.js +385 -3
- package/dist/analysis/bot_key_utils.js.map +1 -1
- package/dist/analysis/bot_usage/discover_bot_accounts.js +60 -10
- package/dist/analysis/bot_usage/discover_bot_accounts.js.map +1 -1
- package/dist/analysis/bot_usage/kibana_bot_queries.d.ts +45 -1
- package/dist/analysis/bot_usage/kibana_bot_queries.d.ts.map +1 -1
- package/dist/analysis/bot_usage/kibana_bot_queries.js +39 -1
- package/dist/analysis/bot_usage/kibana_bot_queries.js.map +1 -1
- package/dist/analysis/chart_utils.d.ts +2 -1
- package/dist/analysis/chart_utils.d.ts.map +1 -1
- package/dist/analysis/chart_utils.js +4 -1
- package/dist/analysis/chart_utils.js.map +1 -1
- package/dist/analysis/grid_correction_check.d.ts.map +1 -1
- package/dist/analysis/grid_correction_check.js +60 -20
- package/dist/analysis/grid_correction_check.js.map +1 -1
- package/dist/analysis/resolve_bot_accounts.d.ts +3 -0
- package/dist/analysis/resolve_bot_accounts.d.ts.map +1 -0
- package/dist/analysis/resolve_bot_accounts.js +216 -0
- package/dist/analysis/resolve_bot_accounts.js.map +1 -0
- package/dist/analysis/trade_profitability.d.ts.map +1 -1
- package/dist/analysis/trade_profitability.js +40 -8
- package/dist/analysis/trade_profitability.js.map +1 -1
- package/dist/analysis/tradingview/analyze_tradingview.js +2 -2
- package/dist/analysis/tradingview/analyze_tradingview.js.map +1 -1
- package/dist/bot.d.ts.map +1 -1
- package/dist/bot.js +2 -1
- package/dist/bot.js.map +1 -1
- package/dist/dexbot.d.ts.map +1 -1
- package/dist/dexbot.js +73 -17
- package/dist/dexbot.js.map +1 -1
- package/dist/market_adapter/ama_signal_runner.js +2 -2
- package/dist/market_adapter/inputs/fetch_cex_synthetic_data.js +2 -1
- package/dist/market_adapter/inputs/fetch_cex_synthetic_data.js.map +1 -1
- package/dist/market_adapter/inputs/fetch_lp_data.d.ts +4 -1
- package/dist/market_adapter/inputs/fetch_lp_data.d.ts.map +1 -1
- package/dist/market_adapter/inputs/fetch_lp_data.js +3 -2
- package/dist/market_adapter/inputs/fetch_lp_data.js.map +1 -1
- package/dist/modules/account_bots.d.ts +42 -1
- package/dist/modules/account_bots.d.ts.map +1 -1
- package/dist/modules/account_bots.js +168 -17
- package/dist/modules/account_bots.js.map +1 -1
- package/dist/modules/account_orders.d.ts +7 -1
- package/dist/modules/account_orders.d.ts.map +1 -1
- package/dist/modules/account_orders.js +34 -1
- package/dist/modules/account_orders.js.map +1 -1
- package/dist/modules/bitshares_client.d.ts +4 -1
- package/dist/modules/bitshares_client.d.ts.map +1 -1
- package/dist/modules/bitshares_client.js +12 -4
- package/dist/modules/bitshares_client.js.map +1 -1
- package/dist/modules/bot_settings.d.ts.map +1 -1
- package/dist/modules/bot_settings.js +2 -1
- package/dist/modules/bot_settings.js.map +1 -1
- package/dist/modules/cli_colors.d.ts +39 -0
- package/dist/modules/cli_colors.d.ts.map +1 -0
- package/dist/modules/cli_colors.js +42 -0
- package/dist/modules/cli_colors.js.map +1 -0
- package/dist/modules/constants.d.ts +2 -0
- package/dist/modules/constants.d.ts.map +1 -1
- package/dist/modules/constants.js +27 -11
- package/dist/modules/constants.js.map +1 -1
- package/dist/modules/credit_pricing.d.ts +61 -0
- package/dist/modules/credit_pricing.d.ts.map +1 -0
- package/dist/modules/credit_pricing.js +237 -0
- package/dist/modules/credit_pricing.js.map +1 -0
- package/dist/modules/credit_runtime.d.ts +1 -0
- package/dist/modules/credit_runtime.d.ts.map +1 -1
- package/dist/modules/credit_runtime.js +49 -107
- package/dist/modules/credit_runtime.js.map +1 -1
- package/dist/modules/dexbot_class.d.ts +3 -1
- package/dist/modules/dexbot_class.d.ts.map +1 -1
- package/dist/modules/dexbot_class.js +22 -6
- package/dist/modules/dexbot_class.js.map +1 -1
- package/dist/modules/dexbot_cow_runtime.d.ts +36 -2
- package/dist/modules/dexbot_cow_runtime.d.ts.map +1 -1
- package/dist/modules/dexbot_cow_runtime.js +434 -20
- package/dist/modules/dexbot_cow_runtime.js.map +1 -1
- package/dist/modules/dexbot_maintenance_runtime.d.ts +15 -16
- package/dist/modules/dexbot_maintenance_runtime.d.ts.map +1 -1
- package/dist/modules/dexbot_maintenance_runtime.js +69 -42
- package/dist/modules/dexbot_maintenance_runtime.js.map +1 -1
- package/dist/modules/dexbot_startup_runtime.d.ts +1 -0
- package/dist/modules/dexbot_startup_runtime.d.ts.map +1 -1
- package/dist/modules/dexbot_startup_runtime.js +12 -1
- package/dist/modules/dexbot_startup_runtime.js.map +1 -1
- package/dist/modules/dexbot_state_recovery.d.ts.map +1 -1
- package/dist/modules/dexbot_state_recovery.js +7 -0
- package/dist/modules/dexbot_state_recovery.js.map +1 -1
- package/dist/modules/fund_registry.d.ts +1 -1
- package/dist/modules/fund_registry.js +1 -1
- package/dist/modules/launcher/adapter_requirement.d.ts +38 -0
- package/dist/modules/launcher/adapter_requirement.d.ts.map +1 -0
- package/dist/modules/launcher/adapter_requirement.js +141 -0
- package/dist/modules/launcher/adapter_requirement.js.map +1 -0
- package/dist/modules/launcher/bot_supervisor.d.ts +2 -2
- package/dist/modules/launcher/bot_supervisor.d.ts.map +1 -1
- package/dist/modules/launcher/bot_supervisor.js +32 -3
- package/dist/modules/launcher/bot_supervisor.js.map +1 -1
- package/dist/modules/launcher/launch_modes.d.ts.map +1 -1
- package/dist/modules/launcher/launch_modes.js +5 -4
- package/dist/modules/launcher/launch_modes.js.map +1 -1
- package/dist/modules/launcher/monolithic_runtime.d.ts +1 -1
- package/dist/modules/launcher/monolithic_runtime.d.ts.map +1 -1
- package/dist/modules/launcher/monolithic_runtime.js +12 -8
- package/dist/modules/launcher/monolithic_runtime.js.map +1 -1
- package/dist/modules/launcher/status_reporting.d.ts +6 -6
- package/dist/modules/launcher/status_reporting.d.ts.map +1 -1
- package/dist/modules/launcher/status_reporting.js +9 -6
- package/dist/modules/launcher/status_reporting.js.map +1 -1
- package/dist/modules/order/accounting.d.ts +34 -0
- package/dist/modules/order/accounting.d.ts.map +1 -1
- package/dist/modules/order/accounting.js +182 -5
- package/dist/modules/order/accounting.js.map +1 -1
- package/dist/modules/order/export.d.ts +1 -1
- package/dist/modules/order/export.js +1 -1
- package/dist/modules/order/grid.d.ts.map +1 -1
- package/dist/modules/order/grid.js +68 -28
- package/dist/modules/order/grid.js.map +1 -1
- package/dist/modules/order/grid_reconcile_internal.d.ts.map +1 -1
- package/dist/modules/order/grid_reconcile_internal.js +72 -0
- package/dist/modules/order/grid_reconcile_internal.js.map +1 -1
- package/dist/modules/order/logger.d.ts +23 -1
- package/dist/modules/order/logger.d.ts.map +1 -1
- package/dist/modules/order/logger.js +60 -17
- package/dist/modules/order/logger.js.map +1 -1
- package/dist/modules/order/manager.d.ts +41 -1
- package/dist/modules/order/manager.d.ts.map +1 -1
- package/dist/modules/order/manager.js +186 -17
- package/dist/modules/order/manager.js.map +1 -1
- package/dist/modules/order/strategy.d.ts.map +1 -1
- package/dist/modules/order/strategy.js +17 -2
- package/dist/modules/order/strategy.js.map +1 -1
- package/dist/modules/order/sync_engine.d.ts.map +1 -1
- package/dist/modules/order/sync_engine.js +59 -9
- package/dist/modules/order/sync_engine.js.map +1 -1
- package/dist/modules/order/utils/math.d.ts +42 -1
- package/dist/modules/order/utils/math.d.ts.map +1 -1
- package/dist/modules/order/utils/math.js +91 -1
- package/dist/modules/order/utils/math.js.map +1 -1
- package/dist/modules/order/utils/order.d.ts +52 -1
- package/dist/modules/order/utils/order.d.ts.map +1 -1
- package/dist/modules/order/utils/order.js +137 -7
- package/dist/modules/order/utils/order.js.map +1 -1
- package/dist/modules/order/utils/system.d.ts +66 -4
- package/dist/modules/order/utils/system.d.ts.map +1 -1
- package/dist/modules/order/utils/system.js +156 -16
- package/dist/modules/order/utils/system.js.map +1 -1
- package/dist/modules/order/utils/validate.d.ts +30 -3
- package/dist/modules/order/utils/validate.d.ts.map +1 -1
- package/dist/modules/order/utils/validate.js +206 -11
- package/dist/modules/order/utils/validate.js.map +1 -1
- package/dist/modules/utils/chain_logs.d.ts +11 -0
- package/dist/modules/utils/chain_logs.d.ts.map +1 -0
- package/dist/modules/utils/chain_logs.js +23 -0
- package/dist/modules/utils/chain_logs.js.map +1 -0
- package/dist/modules/utils/sanitize_key.d.ts +7 -0
- package/dist/modules/utils/sanitize_key.d.ts.map +1 -1
- package/dist/modules/utils/sanitize_key.js +15 -0
- package/dist/modules/utils/sanitize_key.js.map +1 -1
- package/dist/pm2.d.ts +11 -1
- package/dist/pm2.d.ts.map +1 -1
- package/dist/pm2.js +66 -15
- package/dist/pm2.js.map +1 -1
- package/dist/scripts/analyze-credit.d.ts +4 -0
- package/dist/scripts/analyze-credit.d.ts.map +1 -0
- package/dist/scripts/analyze-credit.js +760 -0
- package/dist/scripts/analyze-credit.js.map +1 -0
- package/dist/scripts/analyze-orders.d.ts +1 -10
- package/dist/scripts/analyze-orders.d.ts.map +1 -1
- package/dist/scripts/analyze-orders.js +11 -34
- package/dist/scripts/analyze-orders.js.map +1 -1
- package/dist/scripts/test-credit-renewal.d.ts.map +1 -1
- package/dist/scripts/test-credit-renewal.js +37 -5
- package/dist/scripts/test-credit-renewal.js.map +1 -1
- package/dist/scripts/tv.d.ts +11 -0
- package/dist/scripts/tv.d.ts.map +1 -0
- package/dist/scripts/tv.js +357 -0
- package/dist/scripts/tv.js.map +1 -0
- package/dist/scripts/update.js +77 -10
- package/dist/scripts/update.js.map +1 -1
- package/dist/unlock.d.ts.map +1 -1
- package/dist/unlock.js +20 -8
- package/dist/unlock.js.map +1 -1
- package/docs/DEXBOT_COMPARISON.md +3 -3
- package/docs/EVOLUTION.md +8 -6
- package/docs/FUND_MOVEMENT_AND_ACCOUNTING.md +3 -1
- package/docs/GRID_RECONCILE.md +1 -0
- package/docs/LOGGING.md +3 -0
- package/docs/MPA_CREDIT_USAGE.md +3 -1
- package/docs/README.md +2 -2
- package/docs/WORKFLOW.md +3 -1
- package/package.json +2 -1
- 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 (
|
|
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
|
|
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 (
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
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(
|
|
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);
|
|
@@ -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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
@@ -30,7 +30,7 @@ async function testParserAcceptsJsonlAcrossChunksAndSingleBuffer() {
|
|
|
30
30
|
capabilities: {},
|
|
31
31
|
clientInfo: {
|
|
32
32
|
name: 'claw-mcp-transport-test',
|
|
33
|
-
version: '1.
|
|
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.
|
|
190
|
+
version: '1.5.1'
|
|
191
191
|
},
|
|
192
192
|
protocolVersion: '2024-11-05'
|
|
193
193
|
}
|
|
@@ -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":"
|
|
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"}
|