toobit-trade-cli 1.0.3 → 1.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,6 +1,4 @@
1
- #!/usr/bin/env node
2
-
3
- // ../core/dist/index.js
1
+ // packages/core/dist/index.js
4
2
  import { createHmac } from "crypto";
5
3
  import * as fs from "fs";
6
4
  import * as path from "path";
@@ -8,7 +6,6 @@ import * as os from "os";
8
6
  import { readFileSync as readFileSync2, writeFileSync, mkdirSync, existsSync as existsSync2 } from "fs";
9
7
  import { join as join2, dirname } from "path";
10
8
  import { homedir as homedir2 } from "os";
11
- import { parse, stringify } from "smol-toml";
12
9
  function getTimestamp() {
13
10
  return Date.now();
14
11
  }
@@ -21,12 +18,12 @@ var ToobitMcpError = class extends Error {
21
18
  suggestion;
22
19
  endpoint;
23
20
  constructor(type, message, options) {
24
- super(message, options?.cause ? { cause: options.cause } : void 0);
21
+ super(message, (options == null ? void 0 : options.cause) ? { cause: options.cause } : void 0);
25
22
  this.name = type;
26
23
  this.type = type;
27
- this.code = options?.code;
28
- this.suggestion = options?.suggestion;
29
- this.endpoint = options?.endpoint;
24
+ this.code = options == null ? void 0 : options.code;
25
+ this.suggestion = options == null ? void 0 : options.suggestion;
26
+ this.endpoint = options == null ? void 0 : options.endpoint;
30
27
  }
31
28
  };
32
29
  var ConfigError = class extends ToobitMcpError {
@@ -298,7 +295,7 @@ var ToobitRestClient = class {
298
295
  if (codeStr === "-1002" || codeStr === "-1022" || codeStr === "-1107" || codeStr === "-2014" || codeStr === "-2015" || codeStr === "-2017") {
299
296
  throw new AuthenticationError(
300
297
  message,
301
- behavior?.suggestion ?? "Check API key, secret key and permissions.",
298
+ (behavior == null ? void 0 : behavior.suggestion) ?? "Check API key, secret key and permissions.",
302
299
  endpoint
303
300
  );
304
301
  }
@@ -308,13 +305,13 @@ var ToobitRestClient = class {
308
305
  throw new ToobitApiError(message, {
309
306
  code: codeStr,
310
307
  endpoint,
311
- suggestion: behavior?.suggestion
308
+ suggestion: behavior == null ? void 0 : behavior.suggestion
312
309
  });
313
310
  }
314
311
  if (!response.ok) {
315
312
  const rawMsg = responseMsg ?? "Unknown error";
316
313
  let suggestion;
317
- if (/symbol|paramter|parameter/i.test(rawMsg)) {
314
+ if (/symbol.*not valid|invalid.*symbol|paramter.*symbol|parameter.*symbol|symbol.*format/i.test(rawMsg)) {
318
315
  const isFuturesPath = /futures|fundingRate|openInterest|markPrice|contract|longShort|insurance|riskLimit/i.test(config.path);
319
316
  suggestion = isFuturesPath ? "Futures endpoints require contract symbol format, e.g. BTC-SWAP-USDT instead of BTCUSDT." : "Spot endpoints require symbol format like BTCUSDT.";
320
317
  }
@@ -677,7 +674,7 @@ function registerFuturesTools() {
677
674
  {
678
675
  name: "futures_place_order",
679
676
  module: "futures",
680
- description: "Place a USDT-M futures order. For market orders, set orderType to MARKET \u2014 the handler automatically converts to type=LIMIT + priceType=MARKET as required by Toobit API. [CAUTION] Executes real trades. Private endpoint. Rate limit: 20 req/s.",
677
+ description: "Place a USDT-M futures order. For market orders, set orderType to MARKET \u2014 the handler automatically converts to type=LIMIT + priceType=MARKET as required by Toobit API. Leverage must be set separately via futures_set_leverage before placing orders. [CAUTION] Executes real trades. Private endpoint. Rate limit: 20 req/s.",
681
678
  isWrite: true,
682
679
  inputSchema: {
683
680
  type: "object",
@@ -687,7 +684,7 @@ function registerFuturesTools() {
687
684
  orderType: { type: "string", enum: ["LIMIT", "MARKET", "STOP"], description: "LIMIT=limit order, MARKET=market order (auto-converted), STOP=conditional order" },
688
685
  quantity: { type: "string", description: "Order quantity (contracts)" },
689
686
  price: { type: "string", description: "Required for LIMIT orders with priceType=INPUT" },
690
- leverage: { type: "string", description: "Leverage, e.g. 10" },
687
+ leverage: { type: "string", description: "IGNORED by place-order API. Use futures_set_leverage to set leverage before placing orders." },
691
688
  newClientOrderId: { type: "string", description: "Unique client order ID. Auto-generated if omitted." },
692
689
  priceType: { type: "string", enum: ["INPUT", "OPPONENT", "QUEUE", "OVER", "MARKET"], description: "Price type. INPUT=specified price, MARKET=market price" },
693
690
  stopPrice: { type: "string", description: "Trigger price for STOP orders" },
@@ -703,7 +700,8 @@ function registerFuturesTools() {
703
700
  orderType = "LIMIT";
704
701
  priceType = "MARKET";
705
702
  }
706
- const clientId = readString(args, "newClientOrderId") ?? `mcp_${Date.now()}_${Math.random().toString(36).slice(2, 8)}`;
703
+ const rawClientId = readString(args, "newClientOrderId");
704
+ const clientId = rawClientId ? rawClientId.replace(/[<>"'&]/g, "") : `mcp_${Date.now()}_${Math.random().toString(36).slice(2, 8)}`;
707
705
  const response = await context.client.privatePost(
708
706
  "/api/v1/futures/order",
709
707
  compactObject({
@@ -712,7 +710,6 @@ function registerFuturesTools() {
712
710
  type: orderType,
713
711
  quantity: requireString(args, "quantity"),
714
712
  price: readString(args, "price"),
715
- leverage: readString(args, "leverage"),
716
713
  newClientOrderId: clientId,
717
714
  priceType,
718
715
  stopPrice: readString(args, "stopPrice"),
@@ -786,7 +783,7 @@ function registerFuturesTools() {
786
783
  inputSchema: {
787
784
  type: "object",
788
785
  properties: {
789
- symbol: { type: "string", description: "e.g. BTCUSDT" }
786
+ symbol: { type: "string", description: "Futures contract symbol, e.g. BTC-SWAP-USDT" }
790
787
  },
791
788
  required: ["symbol"]
792
789
  },
@@ -825,16 +822,17 @@ function registerFuturesTools() {
825
822
  {
826
823
  name: "futures_amend_order",
827
824
  module: "futures",
828
- description: "Modify a futures order (price/quantity). Private endpoint. Rate limit: 20 req/s.",
825
+ description: "Modify a futures order (price/quantity). Requires the order type. Private endpoint. Rate limit: 20 req/s.",
829
826
  isWrite: true,
830
827
  inputSchema: {
831
828
  type: "object",
832
829
  properties: {
833
830
  orderId: { type: "string" },
831
+ type: { type: "string", enum: ["LIMIT", "STOP", "STOP_PROFIT_LOSS"], description: "Order type (required by API)" },
834
832
  quantity: { type: "string" },
835
833
  price: { type: "string" }
836
834
  },
837
- required: ["orderId"]
835
+ required: ["orderId", "type"]
838
836
  },
839
837
  handler: async (rawArgs, context) => {
840
838
  const args = asRecord(rawArgs);
@@ -842,6 +840,7 @@ function registerFuturesTools() {
842
840
  "/api/v1/futures/order/update",
843
841
  compactObject({
844
842
  orderId: requireString(args, "orderId"),
843
+ type: requireString(args, "type"),
845
844
  quantity: readString(args, "quantity"),
846
845
  price: readString(args, "price")
847
846
  }),
@@ -997,7 +996,7 @@ function registerFuturesTools() {
997
996
  inputSchema: {
998
997
  type: "object",
999
998
  properties: {
1000
- symbol: { type: "string", description: "e.g. BTCUSDT" },
999
+ symbol: { type: "string", description: "Futures contract symbol, e.g. BTC-SWAP-USDT" },
1001
1000
  leverage: { type: "number", description: "Leverage value, e.g. 10" }
1002
1001
  },
1003
1002
  required: ["symbol", "leverage"]
@@ -1023,7 +1022,7 @@ function registerFuturesTools() {
1023
1022
  inputSchema: {
1024
1023
  type: "object",
1025
1024
  properties: {
1026
- symbol: { type: "string", description: "e.g. BTCUSDT" }
1025
+ symbol: { type: "string", description: "Futures contract symbol, e.g. BTC-SWAP-USDT" }
1027
1026
  },
1028
1027
  required: ["symbol"]
1029
1028
  },
@@ -1045,7 +1044,7 @@ function registerFuturesTools() {
1045
1044
  inputSchema: {
1046
1045
  type: "object",
1047
1046
  properties: {
1048
- symbol: { type: "string", description: "e.g. BTCUSDT" },
1047
+ symbol: { type: "string", description: "Futures contract symbol, e.g. BTC-SWAP-USDT" },
1049
1048
  marginType: { type: "string", enum: ["CROSS", "ISOLATED"], description: "CROSS=cross margin, ISOLATED=isolated margin" }
1050
1049
  },
1051
1050
  required: ["symbol", "marginType"]
@@ -1071,10 +1070,10 @@ function registerFuturesTools() {
1071
1070
  inputSchema: {
1072
1071
  type: "object",
1073
1072
  properties: {
1074
- symbol: { type: "string" },
1073
+ symbol: { type: "string", description: "Futures contract symbol, e.g. BTC-SWAP-USDT" },
1075
1074
  side: { type: "string", enum: ["LONG", "SHORT"] },
1076
- stopLossPrice: { type: "string" },
1077
- takeProfitPrice: { type: "string" }
1075
+ takeProfit: { type: "string", description: "Take-profit price" },
1076
+ stopLoss: { type: "string", description: "Stop-loss price" }
1078
1077
  },
1079
1078
  required: ["symbol", "side"]
1080
1079
  },
@@ -1085,8 +1084,8 @@ function registerFuturesTools() {
1085
1084
  compactObject({
1086
1085
  symbol: requireString(args, "symbol"),
1087
1086
  side: requireString(args, "side"),
1088
- stopLossPrice: readString(args, "stopLossPrice"),
1089
- takeProfitPrice: readString(args, "takeProfitPrice")
1087
+ takeProfit: readString(args, "takeProfit"),
1088
+ stopLoss: readString(args, "stopLoss")
1090
1089
  }),
1091
1090
  privateRateLimit("futures_set_trading_stop", 10)
1092
1091
  );
@@ -1227,7 +1226,7 @@ function registerFuturesTools() {
1227
1226
  inputSchema: {
1228
1227
  type: "object",
1229
1228
  properties: {
1230
- symbol: { type: "string", description: "e.g. BTCUSDT" }
1229
+ symbol: { type: "string", description: "Futures contract symbol, e.g. BTC-SWAP-USDT" }
1231
1230
  },
1232
1231
  required: ["symbol"]
1233
1232
  },
@@ -1295,11 +1294,11 @@ function registerFuturesTools() {
1295
1294
  inputSchema: {
1296
1295
  type: "object",
1297
1296
  properties: {
1298
- symbol: { type: "string" },
1297
+ symbol: { type: "string", description: "Futures contract symbol, e.g. BTC-SWAP-USDT" },
1299
1298
  side: { type: "string", enum: ["LONG", "SHORT"] },
1300
- autoAddMargin: { type: "string", enum: ["true", "false"] }
1299
+ enable: { type: "string", enum: ["ON", "OFF"], description: "ON=enable, OFF=disable" }
1301
1300
  },
1302
- required: ["symbol", "side", "autoAddMargin"]
1301
+ required: ["symbol", "side", "enable"]
1303
1302
  },
1304
1303
  handler: async (rawArgs, context) => {
1305
1304
  const args = asRecord(rawArgs);
@@ -1308,7 +1307,7 @@ function registerFuturesTools() {
1308
1307
  compactObject({
1309
1308
  symbol: requireString(args, "symbol"),
1310
1309
  side: requireString(args, "side"),
1311
- autoAddMargin: requireString(args, "autoAddMargin")
1310
+ enable: requireString(args, "enable")
1312
1311
  }),
1313
1312
  privateRateLimit("futures_auto_add_margin", 10)
1314
1313
  );
@@ -1830,7 +1829,7 @@ function registerSpotTradeTools() {
1830
1829
  symbol: { type: "string", description: "e.g. BTCUSDT" },
1831
1830
  side: { type: "string", enum: ["BUY", "SELL"] },
1832
1831
  type: { type: "string", enum: ["LIMIT", "MARKET", "LIMIT_MAKER"], description: "Order type" },
1833
- quantity: { type: "string", description: "Order quantity" },
1832
+ quantity: { type: "string", description: "Order quantity in base asset (e.g. BTC amount). For MARKET BUY, this is the base asset quantity to purchase." },
1834
1833
  price: { type: "string", description: "Order price (required for LIMIT)" },
1835
1834
  newClientOrderId: { type: "string", description: "Client order ID" },
1836
1835
  timeInForce: { type: "string", enum: ["GTC", "IOC", "FOK"], description: "Default GTC" }
@@ -1838,6 +1837,7 @@ function registerSpotTradeTools() {
1838
1837
  required: ["symbol", "side", "type", "quantity"]
1839
1838
  },
1840
1839
  handler: async (rawArgs, context) => {
1840
+ var _a;
1841
1841
  const args = asRecord(rawArgs);
1842
1842
  const response = await context.client.privatePost(
1843
1843
  "/api/v1/spot/order",
@@ -1847,7 +1847,7 @@ function registerSpotTradeTools() {
1847
1847
  type: requireString(args, "type"),
1848
1848
  quantity: requireString(args, "quantity"),
1849
1849
  price: readString(args, "price"),
1850
- newClientOrderId: readString(args, "newClientOrderId"),
1850
+ newClientOrderId: (_a = readString(args, "newClientOrderId")) == null ? void 0 : _a.replace(/[<>"'&]/g, ""),
1851
1851
  timeInForce: readString(args, "timeInForce")
1852
1852
  }),
1853
1853
  privateRateLimit("spot_place_order", 50)
@@ -2117,6 +2117,817 @@ function createToolRunner(client, config) {
2117
2117
  return result;
2118
2118
  };
2119
2119
  }
2120
+ function getLineColFromPtr(string, ptr) {
2121
+ let lines = string.slice(0, ptr).split(/\r\n|\n|\r/g);
2122
+ return [lines.length, lines.pop().length + 1];
2123
+ }
2124
+ function makeCodeBlock(string, line, column) {
2125
+ let lines = string.split(/\r\n|\n|\r/g);
2126
+ let codeblock = "";
2127
+ let numberLen = (Math.log10(line + 1) | 0) + 1;
2128
+ for (let i = line - 1; i <= line + 1; i++) {
2129
+ let l = lines[i - 1];
2130
+ if (!l)
2131
+ continue;
2132
+ codeblock += i.toString().padEnd(numberLen, " ");
2133
+ codeblock += ": ";
2134
+ codeblock += l;
2135
+ codeblock += "\n";
2136
+ if (i === line) {
2137
+ codeblock += " ".repeat(numberLen + column + 2);
2138
+ codeblock += "^\n";
2139
+ }
2140
+ }
2141
+ return codeblock;
2142
+ }
2143
+ var TomlError = class extends Error {
2144
+ line;
2145
+ column;
2146
+ codeblock;
2147
+ constructor(message, options) {
2148
+ const [line, column] = getLineColFromPtr(options.toml, options.ptr);
2149
+ const codeblock = makeCodeBlock(options.toml, line, column);
2150
+ super(`Invalid TOML document: ${message}
2151
+
2152
+ ${codeblock}`, options);
2153
+ this.line = line;
2154
+ this.column = column;
2155
+ this.codeblock = codeblock;
2156
+ }
2157
+ };
2158
+ function isEscaped(str, ptr) {
2159
+ let i = 0;
2160
+ while (str[ptr - ++i] === "\\")
2161
+ ;
2162
+ return --i && i % 2;
2163
+ }
2164
+ function indexOfNewline(str, start = 0, end = str.length) {
2165
+ let idx = str.indexOf("\n", start);
2166
+ if (str[idx - 1] === "\r")
2167
+ idx--;
2168
+ return idx <= end ? idx : -1;
2169
+ }
2170
+ function skipComment(str, ptr) {
2171
+ for (let i = ptr; i < str.length; i++) {
2172
+ let c = str[i];
2173
+ if (c === "\n")
2174
+ return i;
2175
+ if (c === "\r" && str[i + 1] === "\n")
2176
+ return i + 1;
2177
+ if (c < " " && c !== " " || c === "\x7F") {
2178
+ throw new TomlError("control characters are not allowed in comments", {
2179
+ toml: str,
2180
+ ptr
2181
+ });
2182
+ }
2183
+ }
2184
+ return str.length;
2185
+ }
2186
+ function skipVoid(str, ptr, banNewLines, banComments) {
2187
+ let c;
2188
+ while ((c = str[ptr]) === " " || c === " " || !banNewLines && (c === "\n" || c === "\r" && str[ptr + 1] === "\n"))
2189
+ ptr++;
2190
+ return banComments || c !== "#" ? ptr : skipVoid(str, skipComment(str, ptr), banNewLines);
2191
+ }
2192
+ function skipUntil(str, ptr, sep, end, banNewLines = false) {
2193
+ if (!end) {
2194
+ ptr = indexOfNewline(str, ptr);
2195
+ return ptr < 0 ? str.length : ptr;
2196
+ }
2197
+ for (let i = ptr; i < str.length; i++) {
2198
+ let c = str[i];
2199
+ if (c === "#") {
2200
+ i = indexOfNewline(str, i);
2201
+ } else if (c === sep) {
2202
+ return i + 1;
2203
+ } else if (c === end || banNewLines && (c === "\n" || c === "\r" && str[i + 1] === "\n")) {
2204
+ return i;
2205
+ }
2206
+ }
2207
+ throw new TomlError("cannot find end of structure", {
2208
+ toml: str,
2209
+ ptr
2210
+ });
2211
+ }
2212
+ function getStringEnd(str, seek) {
2213
+ let first = str[seek];
2214
+ let target = first === str[seek + 1] && str[seek + 1] === str[seek + 2] ? str.slice(seek, seek + 3) : first;
2215
+ seek += target.length - 1;
2216
+ do
2217
+ seek = str.indexOf(target, ++seek);
2218
+ while (seek > -1 && first !== "'" && isEscaped(str, seek));
2219
+ if (seek > -1) {
2220
+ seek += target.length;
2221
+ if (target.length > 1) {
2222
+ if (str[seek] === first)
2223
+ seek++;
2224
+ if (str[seek] === first)
2225
+ seek++;
2226
+ }
2227
+ }
2228
+ return seek;
2229
+ }
2230
+ var DATE_TIME_RE = /^(\d{4}-\d{2}-\d{2})?[T ]?(?:(\d{2}):\d{2}(?::\d{2}(?:\.\d+)?)?)?(Z|[-+]\d{2}:\d{2})?$/i;
2231
+ var TomlDate = class _TomlDate extends Date {
2232
+ #hasDate = false;
2233
+ #hasTime = false;
2234
+ #offset = null;
2235
+ constructor(date) {
2236
+ let hasDate = true;
2237
+ let hasTime = true;
2238
+ let offset = "Z";
2239
+ if (typeof date === "string") {
2240
+ let match = date.match(DATE_TIME_RE);
2241
+ if (match) {
2242
+ if (!match[1]) {
2243
+ hasDate = false;
2244
+ date = `0000-01-01T${date}`;
2245
+ }
2246
+ hasTime = !!match[2];
2247
+ hasTime && date[10] === " " && (date = date.replace(" ", "T"));
2248
+ if (match[2] && +match[2] > 23) {
2249
+ date = "";
2250
+ } else {
2251
+ offset = match[3] || null;
2252
+ date = date.toUpperCase();
2253
+ if (!offset && hasTime)
2254
+ date += "Z";
2255
+ }
2256
+ } else {
2257
+ date = "";
2258
+ }
2259
+ }
2260
+ super(date);
2261
+ if (!isNaN(this.getTime())) {
2262
+ this.#hasDate = hasDate;
2263
+ this.#hasTime = hasTime;
2264
+ this.#offset = offset;
2265
+ }
2266
+ }
2267
+ isDateTime() {
2268
+ return this.#hasDate && this.#hasTime;
2269
+ }
2270
+ isLocal() {
2271
+ return !this.#hasDate || !this.#hasTime || !this.#offset;
2272
+ }
2273
+ isDate() {
2274
+ return this.#hasDate && !this.#hasTime;
2275
+ }
2276
+ isTime() {
2277
+ return this.#hasTime && !this.#hasDate;
2278
+ }
2279
+ isValid() {
2280
+ return this.#hasDate || this.#hasTime;
2281
+ }
2282
+ toISOString() {
2283
+ let iso = super.toISOString();
2284
+ if (this.isDate())
2285
+ return iso.slice(0, 10);
2286
+ if (this.isTime())
2287
+ return iso.slice(11, 23);
2288
+ if (this.#offset === null)
2289
+ return iso.slice(0, -1);
2290
+ if (this.#offset === "Z")
2291
+ return iso;
2292
+ let offset = +this.#offset.slice(1, 3) * 60 + +this.#offset.slice(4, 6);
2293
+ offset = this.#offset[0] === "-" ? offset : -offset;
2294
+ let offsetDate = new Date(this.getTime() - offset * 6e4);
2295
+ return offsetDate.toISOString().slice(0, -1) + this.#offset;
2296
+ }
2297
+ static wrapAsOffsetDateTime(jsDate, offset = "Z") {
2298
+ let date = new _TomlDate(jsDate);
2299
+ date.#offset = offset;
2300
+ return date;
2301
+ }
2302
+ static wrapAsLocalDateTime(jsDate) {
2303
+ let date = new _TomlDate(jsDate);
2304
+ date.#offset = null;
2305
+ return date;
2306
+ }
2307
+ static wrapAsLocalDate(jsDate) {
2308
+ let date = new _TomlDate(jsDate);
2309
+ date.#hasTime = false;
2310
+ date.#offset = null;
2311
+ return date;
2312
+ }
2313
+ static wrapAsLocalTime(jsDate) {
2314
+ let date = new _TomlDate(jsDate);
2315
+ date.#hasDate = false;
2316
+ date.#offset = null;
2317
+ return date;
2318
+ }
2319
+ };
2320
+ var INT_REGEX = /^((0x[0-9a-fA-F](_?[0-9a-fA-F])*)|(([+-]|0[ob])?\d(_?\d)*))$/;
2321
+ var FLOAT_REGEX = /^[+-]?\d(_?\d)*(\.\d(_?\d)*)?([eE][+-]?\d(_?\d)*)?$/;
2322
+ var LEADING_ZERO = /^[+-]?0[0-9_]/;
2323
+ var ESCAPE_REGEX = /^[0-9a-f]{2,8}$/i;
2324
+ var ESC_MAP = {
2325
+ b: "\b",
2326
+ t: " ",
2327
+ n: "\n",
2328
+ f: "\f",
2329
+ r: "\r",
2330
+ e: "\x1B",
2331
+ '"': '"',
2332
+ "\\": "\\"
2333
+ };
2334
+ function parseString(str, ptr = 0, endPtr = str.length) {
2335
+ let isLiteral = str[ptr] === "'";
2336
+ let isMultiline = str[ptr++] === str[ptr] && str[ptr] === str[ptr + 1];
2337
+ if (isMultiline) {
2338
+ endPtr -= 2;
2339
+ if (str[ptr += 2] === "\r")
2340
+ ptr++;
2341
+ if (str[ptr] === "\n")
2342
+ ptr++;
2343
+ }
2344
+ let tmp = 0;
2345
+ let isEscape;
2346
+ let parsed = "";
2347
+ let sliceStart = ptr;
2348
+ while (ptr < endPtr - 1) {
2349
+ let c = str[ptr++];
2350
+ if (c === "\n" || c === "\r" && str[ptr] === "\n") {
2351
+ if (!isMultiline) {
2352
+ throw new TomlError("newlines are not allowed in strings", {
2353
+ toml: str,
2354
+ ptr: ptr - 1
2355
+ });
2356
+ }
2357
+ } else if (c < " " && c !== " " || c === "\x7F") {
2358
+ throw new TomlError("control characters are not allowed in strings", {
2359
+ toml: str,
2360
+ ptr: ptr - 1
2361
+ });
2362
+ }
2363
+ if (isEscape) {
2364
+ isEscape = false;
2365
+ if (c === "x" || c === "u" || c === "U") {
2366
+ let code = str.slice(ptr, ptr += c === "x" ? 2 : c === "u" ? 4 : 8);
2367
+ if (!ESCAPE_REGEX.test(code)) {
2368
+ throw new TomlError("invalid unicode escape", {
2369
+ toml: str,
2370
+ ptr: tmp
2371
+ });
2372
+ }
2373
+ try {
2374
+ parsed += String.fromCodePoint(parseInt(code, 16));
2375
+ } catch {
2376
+ throw new TomlError("invalid unicode escape", {
2377
+ toml: str,
2378
+ ptr: tmp
2379
+ });
2380
+ }
2381
+ } else if (isMultiline && (c === "\n" || c === " " || c === " " || c === "\r")) {
2382
+ ptr = skipVoid(str, ptr - 1, true);
2383
+ if (str[ptr] !== "\n" && str[ptr] !== "\r") {
2384
+ throw new TomlError("invalid escape: only line-ending whitespace may be escaped", {
2385
+ toml: str,
2386
+ ptr: tmp
2387
+ });
2388
+ }
2389
+ ptr = skipVoid(str, ptr);
2390
+ } else if (c in ESC_MAP) {
2391
+ parsed += ESC_MAP[c];
2392
+ } else {
2393
+ throw new TomlError("unrecognized escape sequence", {
2394
+ toml: str,
2395
+ ptr: tmp
2396
+ });
2397
+ }
2398
+ sliceStart = ptr;
2399
+ } else if (!isLiteral && c === "\\") {
2400
+ tmp = ptr - 1;
2401
+ isEscape = true;
2402
+ parsed += str.slice(sliceStart, tmp);
2403
+ }
2404
+ }
2405
+ return parsed + str.slice(sliceStart, endPtr - 1);
2406
+ }
2407
+ function parseValue(value, toml, ptr, integersAsBigInt) {
2408
+ if (value === "true")
2409
+ return true;
2410
+ if (value === "false")
2411
+ return false;
2412
+ if (value === "-inf")
2413
+ return -Infinity;
2414
+ if (value === "inf" || value === "+inf")
2415
+ return Infinity;
2416
+ if (value === "nan" || value === "+nan" || value === "-nan")
2417
+ return NaN;
2418
+ if (value === "-0")
2419
+ return integersAsBigInt ? 0n : 0;
2420
+ let isInt = INT_REGEX.test(value);
2421
+ if (isInt || FLOAT_REGEX.test(value)) {
2422
+ if (LEADING_ZERO.test(value)) {
2423
+ throw new TomlError("leading zeroes are not allowed", {
2424
+ toml,
2425
+ ptr
2426
+ });
2427
+ }
2428
+ value = value.replace(/_/g, "");
2429
+ let numeric = +value;
2430
+ if (isNaN(numeric)) {
2431
+ throw new TomlError("invalid number", {
2432
+ toml,
2433
+ ptr
2434
+ });
2435
+ }
2436
+ if (isInt) {
2437
+ if ((isInt = !Number.isSafeInteger(numeric)) && !integersAsBigInt) {
2438
+ throw new TomlError("integer value cannot be represented losslessly", {
2439
+ toml,
2440
+ ptr
2441
+ });
2442
+ }
2443
+ if (isInt || integersAsBigInt === true)
2444
+ numeric = BigInt(value);
2445
+ }
2446
+ return numeric;
2447
+ }
2448
+ const date = new TomlDate(value);
2449
+ if (!date.isValid()) {
2450
+ throw new TomlError("invalid value", {
2451
+ toml,
2452
+ ptr
2453
+ });
2454
+ }
2455
+ return date;
2456
+ }
2457
+ function sliceAndTrimEndOf(str, startPtr, endPtr) {
2458
+ let value = str.slice(startPtr, endPtr);
2459
+ let commentIdx = value.indexOf("#");
2460
+ if (commentIdx > -1) {
2461
+ skipComment(str, commentIdx);
2462
+ value = value.slice(0, commentIdx);
2463
+ }
2464
+ return [value.trimEnd(), commentIdx];
2465
+ }
2466
+ function extractValue(str, ptr, end, depth, integersAsBigInt) {
2467
+ if (depth === 0) {
2468
+ throw new TomlError("document contains excessively nested structures. aborting.", {
2469
+ toml: str,
2470
+ ptr
2471
+ });
2472
+ }
2473
+ let c = str[ptr];
2474
+ if (c === "[" || c === "{") {
2475
+ let [value, endPtr2] = c === "[" ? parseArray(str, ptr, depth, integersAsBigInt) : parseInlineTable(str, ptr, depth, integersAsBigInt);
2476
+ if (end) {
2477
+ endPtr2 = skipVoid(str, endPtr2);
2478
+ if (str[endPtr2] === ",")
2479
+ endPtr2++;
2480
+ else if (str[endPtr2] !== end) {
2481
+ throw new TomlError("expected comma or end of structure", {
2482
+ toml: str,
2483
+ ptr: endPtr2
2484
+ });
2485
+ }
2486
+ }
2487
+ return [value, endPtr2];
2488
+ }
2489
+ let endPtr;
2490
+ if (c === '"' || c === "'") {
2491
+ endPtr = getStringEnd(str, ptr);
2492
+ let parsed = parseString(str, ptr, endPtr);
2493
+ if (end) {
2494
+ endPtr = skipVoid(str, endPtr);
2495
+ if (str[endPtr] && str[endPtr] !== "," && str[endPtr] !== end && str[endPtr] !== "\n" && str[endPtr] !== "\r") {
2496
+ throw new TomlError("unexpected character encountered", {
2497
+ toml: str,
2498
+ ptr: endPtr
2499
+ });
2500
+ }
2501
+ endPtr += +(str[endPtr] === ",");
2502
+ }
2503
+ return [parsed, endPtr];
2504
+ }
2505
+ endPtr = skipUntil(str, ptr, ",", end);
2506
+ let slice = sliceAndTrimEndOf(str, ptr, endPtr - +(str[endPtr - 1] === ","));
2507
+ if (!slice[0]) {
2508
+ throw new TomlError("incomplete key-value declaration: no value specified", {
2509
+ toml: str,
2510
+ ptr
2511
+ });
2512
+ }
2513
+ if (end && slice[1] > -1) {
2514
+ endPtr = skipVoid(str, ptr + slice[1]);
2515
+ endPtr += +(str[endPtr] === ",");
2516
+ }
2517
+ return [
2518
+ parseValue(slice[0], str, ptr, integersAsBigInt),
2519
+ endPtr
2520
+ ];
2521
+ }
2522
+ var KEY_PART_RE = /^[a-zA-Z0-9-_]+[ \t]*$/;
2523
+ function parseKey(str, ptr, end = "=") {
2524
+ let dot = ptr - 1;
2525
+ let parsed = [];
2526
+ let endPtr = str.indexOf(end, ptr);
2527
+ if (endPtr < 0) {
2528
+ throw new TomlError("incomplete key-value: cannot find end of key", {
2529
+ toml: str,
2530
+ ptr
2531
+ });
2532
+ }
2533
+ do {
2534
+ let c = str[ptr = ++dot];
2535
+ if (c !== " " && c !== " ") {
2536
+ if (c === '"' || c === "'") {
2537
+ if (c === str[ptr + 1] && c === str[ptr + 2]) {
2538
+ throw new TomlError("multiline strings are not allowed in keys", {
2539
+ toml: str,
2540
+ ptr
2541
+ });
2542
+ }
2543
+ let eos = getStringEnd(str, ptr);
2544
+ if (eos < 0) {
2545
+ throw new TomlError("unfinished string encountered", {
2546
+ toml: str,
2547
+ ptr
2548
+ });
2549
+ }
2550
+ dot = str.indexOf(".", eos);
2551
+ let strEnd = str.slice(eos, dot < 0 || dot > endPtr ? endPtr : dot);
2552
+ let newLine = indexOfNewline(strEnd);
2553
+ if (newLine > -1) {
2554
+ throw new TomlError("newlines are not allowed in keys", {
2555
+ toml: str,
2556
+ ptr: ptr + dot + newLine
2557
+ });
2558
+ }
2559
+ if (strEnd.trimStart()) {
2560
+ throw new TomlError("found extra tokens after the string part", {
2561
+ toml: str,
2562
+ ptr: eos
2563
+ });
2564
+ }
2565
+ if (endPtr < eos) {
2566
+ endPtr = str.indexOf(end, eos);
2567
+ if (endPtr < 0) {
2568
+ throw new TomlError("incomplete key-value: cannot find end of key", {
2569
+ toml: str,
2570
+ ptr
2571
+ });
2572
+ }
2573
+ }
2574
+ parsed.push(parseString(str, ptr, eos));
2575
+ } else {
2576
+ dot = str.indexOf(".", ptr);
2577
+ let part = str.slice(ptr, dot < 0 || dot > endPtr ? endPtr : dot);
2578
+ if (!KEY_PART_RE.test(part)) {
2579
+ throw new TomlError("only letter, numbers, dashes and underscores are allowed in keys", {
2580
+ toml: str,
2581
+ ptr
2582
+ });
2583
+ }
2584
+ parsed.push(part.trimEnd());
2585
+ }
2586
+ }
2587
+ } while (dot + 1 && dot < endPtr);
2588
+ return [parsed, skipVoid(str, endPtr + 1, true, true)];
2589
+ }
2590
+ function parseInlineTable(str, ptr, depth, integersAsBigInt) {
2591
+ let res = {};
2592
+ let seen = /* @__PURE__ */ new Set();
2593
+ let c;
2594
+ ptr++;
2595
+ while ((c = str[ptr++]) !== "}" && c) {
2596
+ if (c === ",") {
2597
+ throw new TomlError("expected value, found comma", {
2598
+ toml: str,
2599
+ ptr: ptr - 1
2600
+ });
2601
+ } else if (c === "#")
2602
+ ptr = skipComment(str, ptr);
2603
+ else if (c !== " " && c !== " " && c !== "\n" && c !== "\r") {
2604
+ let k;
2605
+ let t = res;
2606
+ let hasOwn = false;
2607
+ let [key, keyEndPtr] = parseKey(str, ptr - 1);
2608
+ for (let i = 0; i < key.length; i++) {
2609
+ if (i)
2610
+ t = hasOwn ? t[k] : t[k] = {};
2611
+ k = key[i];
2612
+ if ((hasOwn = Object.hasOwn(t, k)) && (typeof t[k] !== "object" || seen.has(t[k]))) {
2613
+ throw new TomlError("trying to redefine an already defined value", {
2614
+ toml: str,
2615
+ ptr
2616
+ });
2617
+ }
2618
+ if (!hasOwn && k === "__proto__") {
2619
+ Object.defineProperty(t, k, { enumerable: true, configurable: true, writable: true });
2620
+ }
2621
+ }
2622
+ if (hasOwn) {
2623
+ throw new TomlError("trying to redefine an already defined value", {
2624
+ toml: str,
2625
+ ptr
2626
+ });
2627
+ }
2628
+ let [value, valueEndPtr] = extractValue(str, keyEndPtr, "}", depth - 1, integersAsBigInt);
2629
+ seen.add(value);
2630
+ t[k] = value;
2631
+ ptr = valueEndPtr;
2632
+ }
2633
+ }
2634
+ if (!c) {
2635
+ throw new TomlError("unfinished table encountered", {
2636
+ toml: str,
2637
+ ptr
2638
+ });
2639
+ }
2640
+ return [res, ptr];
2641
+ }
2642
+ function parseArray(str, ptr, depth, integersAsBigInt) {
2643
+ let res = [];
2644
+ let c;
2645
+ ptr++;
2646
+ while ((c = str[ptr++]) !== "]" && c) {
2647
+ if (c === ",") {
2648
+ throw new TomlError("expected value, found comma", {
2649
+ toml: str,
2650
+ ptr: ptr - 1
2651
+ });
2652
+ } else if (c === "#")
2653
+ ptr = skipComment(str, ptr);
2654
+ else if (c !== " " && c !== " " && c !== "\n" && c !== "\r") {
2655
+ let e = extractValue(str, ptr - 1, "]", depth - 1, integersAsBigInt);
2656
+ res.push(e[0]);
2657
+ ptr = e[1];
2658
+ }
2659
+ }
2660
+ if (!c) {
2661
+ throw new TomlError("unfinished array encountered", {
2662
+ toml: str,
2663
+ ptr
2664
+ });
2665
+ }
2666
+ return [res, ptr];
2667
+ }
2668
+ function peekTable(key, table, meta, type) {
2669
+ var _a, _b;
2670
+ let t = table;
2671
+ let m = meta;
2672
+ let k;
2673
+ let hasOwn = false;
2674
+ let state;
2675
+ for (let i = 0; i < key.length; i++) {
2676
+ if (i) {
2677
+ t = hasOwn ? t[k] : t[k] = {};
2678
+ m = (state = m[k]).c;
2679
+ if (type === 0 && (state.t === 1 || state.t === 2)) {
2680
+ return null;
2681
+ }
2682
+ if (state.t === 2) {
2683
+ let l = t.length - 1;
2684
+ t = t[l];
2685
+ m = m[l].c;
2686
+ }
2687
+ }
2688
+ k = key[i];
2689
+ if ((hasOwn = Object.hasOwn(t, k)) && ((_a = m[k]) == null ? void 0 : _a.t) === 0 && ((_b = m[k]) == null ? void 0 : _b.d)) {
2690
+ return null;
2691
+ }
2692
+ if (!hasOwn) {
2693
+ if (k === "__proto__") {
2694
+ Object.defineProperty(t, k, { enumerable: true, configurable: true, writable: true });
2695
+ Object.defineProperty(m, k, { enumerable: true, configurable: true, writable: true });
2696
+ }
2697
+ m[k] = {
2698
+ t: i < key.length - 1 && type === 2 ? 3 : type,
2699
+ d: false,
2700
+ i: 0,
2701
+ c: {}
2702
+ };
2703
+ }
2704
+ }
2705
+ state = m[k];
2706
+ if (state.t !== type && !(type === 1 && state.t === 3)) {
2707
+ return null;
2708
+ }
2709
+ if (type === 2) {
2710
+ if (!state.d) {
2711
+ state.d = true;
2712
+ t[k] = [];
2713
+ }
2714
+ t[k].push(t = {});
2715
+ state.c[state.i++] = state = { t: 1, d: false, i: 0, c: {} };
2716
+ }
2717
+ if (state.d) {
2718
+ return null;
2719
+ }
2720
+ state.d = true;
2721
+ if (type === 1) {
2722
+ t = hasOwn ? t[k] : t[k] = {};
2723
+ } else if (type === 0 && hasOwn) {
2724
+ return null;
2725
+ }
2726
+ return [k, t, state.c];
2727
+ }
2728
+ function parse(toml, { maxDepth = 1e3, integersAsBigInt } = {}) {
2729
+ let res = {};
2730
+ let meta = {};
2731
+ let tbl = res;
2732
+ let m = meta;
2733
+ for (let ptr = skipVoid(toml, 0); ptr < toml.length; ) {
2734
+ if (toml[ptr] === "[") {
2735
+ let isTableArray = toml[++ptr] === "[";
2736
+ let k = parseKey(toml, ptr += +isTableArray, "]");
2737
+ if (isTableArray) {
2738
+ if (toml[k[1] - 1] !== "]") {
2739
+ throw new TomlError("expected end of table declaration", {
2740
+ toml,
2741
+ ptr: k[1] - 1
2742
+ });
2743
+ }
2744
+ k[1]++;
2745
+ }
2746
+ let p = peekTable(
2747
+ k[0],
2748
+ res,
2749
+ meta,
2750
+ isTableArray ? 2 : 1
2751
+ /* Type.EXPLICIT */
2752
+ );
2753
+ if (!p) {
2754
+ throw new TomlError("trying to redefine an already defined table or value", {
2755
+ toml,
2756
+ ptr
2757
+ });
2758
+ }
2759
+ m = p[2];
2760
+ tbl = p[1];
2761
+ ptr = k[1];
2762
+ } else {
2763
+ let k = parseKey(toml, ptr);
2764
+ let p = peekTable(
2765
+ k[0],
2766
+ tbl,
2767
+ m,
2768
+ 0
2769
+ /* Type.DOTTED */
2770
+ );
2771
+ if (!p) {
2772
+ throw new TomlError("trying to redefine an already defined table or value", {
2773
+ toml,
2774
+ ptr
2775
+ });
2776
+ }
2777
+ let v = extractValue(toml, k[1], void 0, maxDepth, integersAsBigInt);
2778
+ p[1][p[0]] = v[0];
2779
+ ptr = v[1];
2780
+ }
2781
+ ptr = skipVoid(toml, ptr, true);
2782
+ if (toml[ptr] && toml[ptr] !== "\n" && toml[ptr] !== "\r") {
2783
+ throw new TomlError("each key-value declaration must be followed by an end-of-line", {
2784
+ toml,
2785
+ ptr
2786
+ });
2787
+ }
2788
+ ptr = skipVoid(toml, ptr);
2789
+ }
2790
+ return res;
2791
+ }
2792
+ var BARE_KEY = /^[a-z0-9-_]+$/i;
2793
+ function extendedTypeOf(obj) {
2794
+ let type = typeof obj;
2795
+ if (type === "object") {
2796
+ if (Array.isArray(obj))
2797
+ return "array";
2798
+ if (obj instanceof Date)
2799
+ return "date";
2800
+ }
2801
+ return type;
2802
+ }
2803
+ function isArrayOfTables(obj) {
2804
+ for (let i = 0; i < obj.length; i++) {
2805
+ if (extendedTypeOf(obj[i]) !== "object")
2806
+ return false;
2807
+ }
2808
+ return obj.length != 0;
2809
+ }
2810
+ function formatString(s) {
2811
+ return JSON.stringify(s).replace(/\x7f/g, "\\u007f");
2812
+ }
2813
+ function stringifyValue(val, type, depth, numberAsFloat) {
2814
+ if (depth === 0) {
2815
+ throw new Error("Could not stringify the object: maximum object depth exceeded");
2816
+ }
2817
+ if (type === "number") {
2818
+ if (isNaN(val))
2819
+ return "nan";
2820
+ if (val === Infinity)
2821
+ return "inf";
2822
+ if (val === -Infinity)
2823
+ return "-inf";
2824
+ if (numberAsFloat && Number.isInteger(val))
2825
+ return val.toFixed(1);
2826
+ return val.toString();
2827
+ }
2828
+ if (type === "bigint" || type === "boolean") {
2829
+ return val.toString();
2830
+ }
2831
+ if (type === "string") {
2832
+ return formatString(val);
2833
+ }
2834
+ if (type === "date") {
2835
+ if (isNaN(val.getTime())) {
2836
+ throw new TypeError("cannot serialize invalid date");
2837
+ }
2838
+ return val.toISOString();
2839
+ }
2840
+ if (type === "object") {
2841
+ return stringifyInlineTable(val, depth, numberAsFloat);
2842
+ }
2843
+ if (type === "array") {
2844
+ return stringifyArray(val, depth, numberAsFloat);
2845
+ }
2846
+ }
2847
+ function stringifyInlineTable(obj, depth, numberAsFloat) {
2848
+ let keys = Object.keys(obj);
2849
+ if (keys.length === 0)
2850
+ return "{}";
2851
+ let res = "{ ";
2852
+ for (let i = 0; i < keys.length; i++) {
2853
+ let k = keys[i];
2854
+ if (i)
2855
+ res += ", ";
2856
+ res += BARE_KEY.test(k) ? k : formatString(k);
2857
+ res += " = ";
2858
+ res += stringifyValue(obj[k], extendedTypeOf(obj[k]), depth - 1, numberAsFloat);
2859
+ }
2860
+ return res + " }";
2861
+ }
2862
+ function stringifyArray(array, depth, numberAsFloat) {
2863
+ if (array.length === 0)
2864
+ return "[]";
2865
+ let res = "[ ";
2866
+ for (let i = 0; i < array.length; i++) {
2867
+ if (i)
2868
+ res += ", ";
2869
+ if (array[i] === null || array[i] === void 0) {
2870
+ throw new TypeError("arrays cannot contain null or undefined values");
2871
+ }
2872
+ res += stringifyValue(array[i], extendedTypeOf(array[i]), depth - 1, numberAsFloat);
2873
+ }
2874
+ return res + " ]";
2875
+ }
2876
+ function stringifyArrayTable(array, key, depth, numberAsFloat) {
2877
+ if (depth === 0) {
2878
+ throw new Error("Could not stringify the object: maximum object depth exceeded");
2879
+ }
2880
+ let res = "";
2881
+ for (let i = 0; i < array.length; i++) {
2882
+ res += `${res && "\n"}[[${key}]]
2883
+ `;
2884
+ res += stringifyTable(0, array[i], key, depth, numberAsFloat);
2885
+ }
2886
+ return res;
2887
+ }
2888
+ function stringifyTable(tableKey, obj, prefix, depth, numberAsFloat) {
2889
+ if (depth === 0) {
2890
+ throw new Error("Could not stringify the object: maximum object depth exceeded");
2891
+ }
2892
+ let preamble = "";
2893
+ let tables = "";
2894
+ let keys = Object.keys(obj);
2895
+ for (let i = 0; i < keys.length; i++) {
2896
+ let k = keys[i];
2897
+ if (obj[k] !== null && obj[k] !== void 0) {
2898
+ let type = extendedTypeOf(obj[k]);
2899
+ if (type === "symbol" || type === "function") {
2900
+ throw new TypeError(`cannot serialize values of type '${type}'`);
2901
+ }
2902
+ let key = BARE_KEY.test(k) ? k : formatString(k);
2903
+ if (type === "array" && isArrayOfTables(obj[k])) {
2904
+ tables += (tables && "\n") + stringifyArrayTable(obj[k], prefix ? `${prefix}.${key}` : key, depth - 1, numberAsFloat);
2905
+ } else if (type === "object") {
2906
+ let tblKey = prefix ? `${prefix}.${key}` : key;
2907
+ tables += (tables && "\n") + stringifyTable(tblKey, obj[k], tblKey, depth - 1, numberAsFloat);
2908
+ } else {
2909
+ preamble += key;
2910
+ preamble += " = ";
2911
+ preamble += stringifyValue(obj[k], type, depth, numberAsFloat);
2912
+ preamble += "\n";
2913
+ }
2914
+ }
2915
+ }
2916
+ if (tableKey && (preamble || !tables))
2917
+ preamble = preamble ? `[${tableKey}]
2918
+ ${preamble}` : `[${tableKey}]`;
2919
+ return preamble && tables ? `${preamble}
2920
+ ${tables}` : preamble || tables;
2921
+ }
2922
+ function stringify(obj, { maxDepth = 1e3, numbersAsFloat = false } = {}) {
2923
+ if (extendedTypeOf(obj) !== "object") {
2924
+ throw new TypeError("stringify can only be called with an object");
2925
+ }
2926
+ let str = stringifyTable(0, obj, "", maxDepth, numbersAsFloat);
2927
+ if (str[str.length - 1] !== "\n")
2928
+ return str + "\n";
2929
+ return str;
2930
+ }
2120
2931
  function configFilePath() {
2121
2932
  return join2(homedir2(), ".toobit", "config.toml");
2122
2933
  }
@@ -2127,9 +2938,10 @@ function readFullConfig() {
2127
2938
  return parse(raw);
2128
2939
  }
2129
2940
  function readTomlProfile(profileName) {
2941
+ var _a;
2130
2942
  const config = readFullConfig();
2131
2943
  const name = profileName ?? config.default_profile ?? "default";
2132
- return config.profiles?.[name] ?? {};
2944
+ return ((_a = config.profiles) == null ? void 0 : _a[name]) ?? {};
2133
2945
  }
2134
2946
  function writeFullConfig(config) {
2135
2947
  const path4 = configFilePath();
@@ -2164,9 +2976,10 @@ function parseModuleList(rawModules) {
2164
2976
  return Array.from(deduped);
2165
2977
  }
2166
2978
  function loadConfig(cli) {
2979
+ var _a, _b, _c;
2167
2980
  const toml = readTomlProfile(cli.profile);
2168
- const apiKey = process.env.TOOBIT_API_KEY?.trim() ?? toml.api_key;
2169
- const secretKey = process.env.TOOBIT_SECRET_KEY?.trim() ?? toml.secret_key;
2981
+ const apiKey = ((_a = process.env.TOOBIT_API_KEY) == null ? void 0 : _a.trim()) ?? toml.api_key;
2982
+ const secretKey = ((_b = process.env.TOOBIT_SECRET_KEY) == null ? void 0 : _b.trim()) ?? toml.secret_key;
2170
2983
  const hasAuth = Boolean(apiKey && secretKey);
2171
2984
  const partialAuth = Boolean(apiKey) || Boolean(secretKey);
2172
2985
  if (partialAuth && !hasAuth) {
@@ -2175,7 +2988,7 @@ function loadConfig(cli) {
2175
2988
  "Set TOOBIT_API_KEY and TOOBIT_SECRET_KEY together (env vars or config.toml profile)."
2176
2989
  );
2177
2990
  }
2178
- const rawBaseUrl = process.env.TOOBIT_API_BASE_URL?.trim() ?? toml.base_url ?? TOOBIT_API_BASE_URL;
2991
+ const rawBaseUrl = ((_c = process.env.TOOBIT_API_BASE_URL) == null ? void 0 : _c.trim()) ?? toml.base_url ?? TOOBIT_API_BASE_URL;
2179
2992
  if (!rawBaseUrl.startsWith("http://") && !rawBaseUrl.startsWith("https://")) {
2180
2993
  throw new ConfigError(
2181
2994
  `Invalid base URL "${rawBaseUrl}".`,
@@ -2211,7 +3024,7 @@ var CLIENT_NAMES = {
2211
3024
  };
2212
3025
  var SUPPORTED_CLIENTS = Object.keys(CLIENT_NAMES);
2213
3026
 
2214
- // src/parser.ts
3027
+ // packages/cli/src/parser.ts
2215
3028
  import { parseArgs } from "util";
2216
3029
  function parseCli(argv = process.argv.slice(2)) {
2217
3030
  const STRING_OPTIONS = /* @__PURE__ */ new Set([
@@ -2292,7 +3105,7 @@ function parseCli(argv = process.argv.slice(2)) {
2292
3105
  };
2293
3106
  }
2294
3107
 
2295
- // src/formatter.ts
3108
+ // packages/cli/src/formatter.ts
2296
3109
  function extractRows(value) {
2297
3110
  if (Array.isArray(value)) return value;
2298
3111
  if (typeof value === "object" && value !== null) {
@@ -2347,7 +3160,7 @@ ${separator}
2347
3160
  ${body}`;
2348
3161
  }
2349
3162
 
2350
- // src/commands/market.ts
3163
+ // packages/cli/src/commands/market.ts
2351
3164
  async function handleMarketCommand(cli, run) {
2352
3165
  const f = cli.flags;
2353
3166
  let result;
@@ -2425,7 +3238,7 @@ Available: time, info, ticker, ticker-24hr, depth, trades, klines, candles, book
2425
3238
  process.stdout.write(formatJson(result, cli.json) + "\n");
2426
3239
  }
2427
3240
 
2428
- // src/commands/spot.ts
3241
+ // packages/cli/src/commands/spot.ts
2429
3242
  async function handleSpotCommand(cli, run) {
2430
3243
  const f = cli.flags;
2431
3244
  let result;
@@ -2475,7 +3288,7 @@ Available: place, cancel, cancel-all, get, orders, open-orders, history, fills
2475
3288
  process.stdout.write(formatJson(result, cli.json) + "\n");
2476
3289
  }
2477
3290
 
2478
- // src/commands/futures.ts
3291
+ // packages/cli/src/commands/futures.ts
2479
3292
  async function handleFuturesCommand(cli, run) {
2480
3293
  const f = cli.flags;
2481
3294
  let result;
@@ -2486,8 +3299,7 @@ async function handleFuturesCommand(cli, run) {
2486
3299
  side: f.side,
2487
3300
  orderType: f.orderType ?? f.type ?? "MARKET",
2488
3301
  quantity: f.quantity,
2489
- price: f.price,
2490
- leverage: f.leverage
3302
+ price: f.price
2491
3303
  });
2492
3304
  break;
2493
3305
  case "cancel":
@@ -2552,7 +3364,7 @@ Available: place, cancel, cancel-all, amend, get, orders, history, positions, hi
2552
3364
  process.stdout.write(formatJson(result, cli.json) + "\n");
2553
3365
  }
2554
3366
 
2555
- // src/commands/account.ts
3367
+ // packages/cli/src/commands/account.ts
2556
3368
  async function handleAccountCommand(cli, run) {
2557
3369
  const f = cli.flags;
2558
3370
  let result;
@@ -2601,7 +3413,7 @@ Available: balance, info, balance-flow, sub-accounts, check-api-key, deposit-add
2601
3413
  process.stdout.write(formatJson(result, cli.json) + "\n");
2602
3414
  }
2603
3415
 
2604
- // src/commands/config.ts
3416
+ // packages/cli/src/commands/config.ts
2605
3417
  import * as readline from "readline";
2606
3418
  function prompt(question) {
2607
3419
  const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
@@ -2667,7 +3479,7 @@ Available: init, show, list
2667
3479
  }
2668
3480
  }
2669
3481
 
2670
- // src/index.ts
3482
+ // packages/cli/src/index.ts
2671
3483
  function printHelp() {
2672
3484
  const help = `
2673
3485
  Toobit Trade CLI \u2014 Trade from your terminal
@@ -2742,3 +3554,42 @@ main().catch((error) => {
2742
3554
  `);
2743
3555
  process.exitCode = 1;
2744
3556
  });
3557
+ /*! Bundled license information:
3558
+
3559
+ smol-toml/dist/error.js:
3560
+ smol-toml/dist/util.js:
3561
+ smol-toml/dist/date.js:
3562
+ smol-toml/dist/primitive.js:
3563
+ smol-toml/dist/extract.js:
3564
+ smol-toml/dist/struct.js:
3565
+ smol-toml/dist/parse.js:
3566
+ smol-toml/dist/stringify.js:
3567
+ smol-toml/dist/index.js:
3568
+ (*!
3569
+ * Copyright (c) Squirrel Chat et al., All rights reserved.
3570
+ * SPDX-License-Identifier: BSD-3-Clause
3571
+ *
3572
+ * Redistribution and use in source and binary forms, with or without
3573
+ * modification, are permitted provided that the following conditions are met:
3574
+ *
3575
+ * 1. Redistributions of source code must retain the above copyright notice, this
3576
+ * list of conditions and the following disclaimer.
3577
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
3578
+ * this list of conditions and the following disclaimer in the
3579
+ * documentation and/or other materials provided with the distribution.
3580
+ * 3. Neither the name of the copyright holder nor the names of its contributors
3581
+ * may be used to endorse or promote products derived from this software without
3582
+ * specific prior written permission.
3583
+ *
3584
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
3585
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
3586
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
3587
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
3588
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
3589
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
3590
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
3591
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
3592
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
3593
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3594
+ *)
3595
+ */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "toobit-trade-cli",
3
- "version": "1.0.3",
3
+ "version": "1.0.5",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "toobit": "dist/index.js"
@@ -14,7 +14,6 @@ export async function handleFuturesCommand(cli: CliParsed, run: ToolRunner): Pro
14
14
  orderType: f.orderType ?? f.type ?? "MARKET",
15
15
  quantity: f.quantity,
16
16
  price: f.price,
17
- leverage: f.leverage,
18
17
  });
19
18
  break;
20
19
  case "cancel":