toobit-trade-cli 1.0.2 → 1.0.4

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 (2) hide show
  1. package/dist/index.js +915 -57
  2. package/package.json +1 -1
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 {
@@ -290,7 +287,7 @@ var ToobitRestClient = class {
290
287
  const responseCode = parsed.code;
291
288
  const responseMsg = parsed.msg || void 0;
292
289
  const endpoint = `${config.method} ${config.path}`;
293
- const hasBusinessCode = responseCode !== void 0 && responseCode !== 0;
290
+ const hasBusinessCode = responseCode !== void 0 && responseCode !== 0 && responseCode !== 200;
294
291
  if (hasBusinessCode) {
295
292
  const codeStr = String(responseCode);
296
293
  const message = responseMsg || "Toobit API request failed.";
@@ -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,7 +305,7 @@ 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) {
@@ -469,24 +466,26 @@ function registerAccountTools() {
469
466
  inputSchema: {
470
467
  type: "object",
471
468
  properties: {
472
- fromAccountType: { type: "number", description: "1=coin, 2=contract" },
473
- toAccountType: { type: "number", description: "1=coin, 2=contract" },
474
- tokenId: { type: "string", description: "e.g. USDT" },
475
- amount: { type: "string" },
476
- subAccountId: { type: "string" }
469
+ fromUid: { type: "number", description: "From user ID" },
470
+ toUid: { type: "number", description: "To user ID" },
471
+ fromAccountType: { type: "string", enum: ["MAIN", "FUTURES", "COPY_TRADING"], description: "MAIN=spot, FUTURES=contract, COPY_TRADING=copy trading" },
472
+ toAccountType: { type: "string", enum: ["MAIN", "FUTURES", "COPY_TRADING"], description: "MAIN=spot, FUTURES=contract, COPY_TRADING=copy trading" },
473
+ asset: { type: "string", description: "Asset name, e.g. USDT" },
474
+ quantity: { type: "string", description: "Transfer quantity" }
477
475
  },
478
- required: ["tokenId", "amount"]
476
+ required: ["fromUid", "toUid", "fromAccountType", "toAccountType", "asset", "quantity"]
479
477
  },
480
478
  handler: async (rawArgs, context) => {
481
479
  const args = asRecord(rawArgs);
482
480
  const response = await context.client.privatePost(
483
481
  "/api/v1/subAccount/transfer",
484
482
  compactObject({
485
- fromAccountType: readNumber(args, "fromAccountType"),
486
- toAccountType: readNumber(args, "toAccountType"),
487
- tokenId: requireString(args, "tokenId"),
488
- amount: requireString(args, "amount"),
489
- subAccountId: readString(args, "subAccountId")
483
+ fromUid: readNumber(args, "fromUid"),
484
+ toUid: readNumber(args, "toUid"),
485
+ fromAccountType: requireString(args, "fromAccountType"),
486
+ toAccountType: requireString(args, "toAccountType"),
487
+ asset: requireString(args, "asset"),
488
+ quantity: requireString(args, "quantity")
490
489
  }),
491
490
  privateRateLimit("account_sub_transfer", 5)
492
491
  );
@@ -581,18 +580,18 @@ function registerAccountTools() {
581
580
  inputSchema: {
582
581
  type: "object",
583
582
  properties: {
584
- tokenId: { type: "string", description: "e.g. USDT" },
585
- chainType: { type: "string" }
583
+ coin: { type: "string", description: "Asset name, e.g. USDT" },
584
+ chainType: { type: "string", description: "Chain type, e.g. ERC20, TRC20, OMNI" }
586
585
  },
587
- required: ["tokenId"]
586
+ required: ["coin", "chainType"]
588
587
  },
589
588
  handler: async (rawArgs, context) => {
590
589
  const args = asRecord(rawArgs);
591
590
  const response = await context.client.privateGet(
592
591
  "/api/v1/account/deposit/address",
593
592
  compactObject({
594
- tokenId: requireString(args, "tokenId"),
595
- chainType: readString(args, "chainType")
593
+ coin: requireString(args, "coin"),
594
+ chainType: requireString(args, "chainType")
596
595
  }),
597
596
  privateRateLimit("account_get_deposit_address", 20)
598
597
  );
@@ -675,38 +674,45 @@ function registerFuturesTools() {
675
674
  {
676
675
  name: "futures_place_order",
677
676
  module: "futures",
678
- description: "Place a USDT-M futures order. [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. [CAUTION] Executes real trades. Private endpoint. Rate limit: 20 req/s.",
679
678
  isWrite: true,
680
679
  inputSchema: {
681
680
  type: "object",
682
681
  properties: {
683
- symbol: { type: "string", description: "e.g. BTCUSDT" },
682
+ symbol: { type: "string", description: "Futures contract symbol, e.g. BTC-SWAP-USDT" },
684
683
  side: { type: "string", enum: ["BUY_OPEN", "SELL_OPEN", "BUY_CLOSE", "SELL_CLOSE"] },
685
- orderType: { type: "string", enum: ["LIMIT", "MARKET"], description: "Order type" },
684
+ orderType: { type: "string", enum: ["LIMIT", "MARKET", "STOP"], description: "LIMIT=limit order, MARKET=market order (auto-converted), STOP=conditional order" },
686
685
  quantity: { type: "string", description: "Order quantity (contracts)" },
687
- price: { type: "string", description: "Required for LIMIT" },
686
+ price: { type: "string", description: "Required for LIMIT orders with priceType=INPUT" },
688
687
  leverage: { type: "string", description: "Leverage, e.g. 10" },
689
- clientOrderId: { type: "string" },
690
- priceType: { type: "string", enum: ["INPUT", "OPPONENT", "QUEUE", "OVER", "MARKET"], description: "Price type for trigger orders" },
691
- triggerPrice: { type: "string", description: "Trigger price for conditional orders" },
692
- timeInForce: { type: "string", enum: ["GTC", "IOC", "FOK", "LIMIT_MAKER"] }
688
+ newClientOrderId: { type: "string", description: "Unique client order ID. Auto-generated if omitted." },
689
+ priceType: { type: "string", enum: ["INPUT", "OPPONENT", "QUEUE", "OVER", "MARKET"], description: "Price type. INPUT=specified price, MARKET=market price" },
690
+ stopPrice: { type: "string", description: "Trigger price for STOP orders" },
691
+ timeInForce: { type: "string", enum: ["GTC", "IOC", "FOK"] }
693
692
  },
694
693
  required: ["symbol", "side", "orderType", "quantity"]
695
694
  },
696
695
  handler: async (rawArgs, context) => {
697
696
  const args = asRecord(rawArgs);
697
+ let orderType = requireString(args, "orderType");
698
+ let priceType = readString(args, "priceType");
699
+ if (orderType === "MARKET") {
700
+ orderType = "LIMIT";
701
+ priceType = "MARKET";
702
+ }
703
+ const clientId = readString(args, "newClientOrderId") ?? `mcp_${Date.now()}_${Math.random().toString(36).slice(2, 8)}`;
698
704
  const response = await context.client.privatePost(
699
705
  "/api/v1/futures/order",
700
706
  compactObject({
701
707
  symbol: requireString(args, "symbol"),
702
708
  side: requireString(args, "side"),
703
- orderType: requireString(args, "orderType"),
709
+ type: orderType,
704
710
  quantity: requireString(args, "quantity"),
705
711
  price: readString(args, "price"),
706
712
  leverage: readString(args, "leverage"),
707
- clientOrderId: readString(args, "clientOrderId"),
708
- priceType: readString(args, "priceType"),
709
- triggerPrice: readString(args, "triggerPrice"),
713
+ newClientOrderId: clientId,
714
+ priceType,
715
+ stopPrice: readString(args, "stopPrice"),
710
716
  timeInForce: readString(args, "timeInForce")
711
717
  }),
712
718
  privateRateLimit("futures_place_order", 20)
@@ -777,7 +783,7 @@ function registerFuturesTools() {
777
783
  inputSchema: {
778
784
  type: "object",
779
785
  properties: {
780
- symbol: { type: "string", description: "e.g. BTCUSDT" }
786
+ symbol: { type: "string", description: "Futures contract symbol, e.g. BTC-SWAP-USDT" }
781
787
  },
782
788
  required: ["symbol"]
783
789
  },
@@ -988,7 +994,7 @@ function registerFuturesTools() {
988
994
  inputSchema: {
989
995
  type: "object",
990
996
  properties: {
991
- symbol: { type: "string", description: "e.g. BTCUSDT" },
997
+ symbol: { type: "string", description: "Futures contract symbol, e.g. BTC-SWAP-USDT" },
992
998
  leverage: { type: "number", description: "Leverage value, e.g. 10" }
993
999
  },
994
1000
  required: ["symbol", "leverage"]
@@ -1014,7 +1020,7 @@ function registerFuturesTools() {
1014
1020
  inputSchema: {
1015
1021
  type: "object",
1016
1022
  properties: {
1017
- symbol: { type: "string", description: "e.g. BTCUSDT" }
1023
+ symbol: { type: "string", description: "Futures contract symbol, e.g. BTC-SWAP-USDT" }
1018
1024
  },
1019
1025
  required: ["symbol"]
1020
1026
  },
@@ -1036,8 +1042,8 @@ function registerFuturesTools() {
1036
1042
  inputSchema: {
1037
1043
  type: "object",
1038
1044
  properties: {
1039
- symbol: { type: "string", description: "e.g. BTCUSDT" },
1040
- marginType: { type: "string", enum: ["1", "2"], description: "1=cross, 2=isolated" }
1045
+ symbol: { type: "string", description: "Futures contract symbol, e.g. BTC-SWAP-USDT" },
1046
+ marginType: { type: "string", enum: ["CROSS", "ISOLATED"], description: "CROSS=cross margin, ISOLATED=isolated margin" }
1041
1047
  },
1042
1048
  required: ["symbol", "marginType"]
1043
1049
  },
@@ -1218,7 +1224,7 @@ function registerFuturesTools() {
1218
1224
  inputSchema: {
1219
1225
  type: "object",
1220
1226
  properties: {
1221
- symbol: { type: "string", description: "e.g. BTCUSDT" }
1227
+ symbol: { type: "string", description: "Futures contract symbol, e.g. BTC-SWAP-USDT" }
1222
1228
  },
1223
1229
  required: ["symbol"]
1224
1230
  },
@@ -2108,6 +2114,817 @@ function createToolRunner(client, config) {
2108
2114
  return result;
2109
2115
  };
2110
2116
  }
2117
+ function getLineColFromPtr(string, ptr) {
2118
+ let lines = string.slice(0, ptr).split(/\r\n|\n|\r/g);
2119
+ return [lines.length, lines.pop().length + 1];
2120
+ }
2121
+ function makeCodeBlock(string, line, column) {
2122
+ let lines = string.split(/\r\n|\n|\r/g);
2123
+ let codeblock = "";
2124
+ let numberLen = (Math.log10(line + 1) | 0) + 1;
2125
+ for (let i = line - 1; i <= line + 1; i++) {
2126
+ let l = lines[i - 1];
2127
+ if (!l)
2128
+ continue;
2129
+ codeblock += i.toString().padEnd(numberLen, " ");
2130
+ codeblock += ": ";
2131
+ codeblock += l;
2132
+ codeblock += "\n";
2133
+ if (i === line) {
2134
+ codeblock += " ".repeat(numberLen + column + 2);
2135
+ codeblock += "^\n";
2136
+ }
2137
+ }
2138
+ return codeblock;
2139
+ }
2140
+ var TomlError = class extends Error {
2141
+ line;
2142
+ column;
2143
+ codeblock;
2144
+ constructor(message, options) {
2145
+ const [line, column] = getLineColFromPtr(options.toml, options.ptr);
2146
+ const codeblock = makeCodeBlock(options.toml, line, column);
2147
+ super(`Invalid TOML document: ${message}
2148
+
2149
+ ${codeblock}`, options);
2150
+ this.line = line;
2151
+ this.column = column;
2152
+ this.codeblock = codeblock;
2153
+ }
2154
+ };
2155
+ function isEscaped(str, ptr) {
2156
+ let i = 0;
2157
+ while (str[ptr - ++i] === "\\")
2158
+ ;
2159
+ return --i && i % 2;
2160
+ }
2161
+ function indexOfNewline(str, start = 0, end = str.length) {
2162
+ let idx = str.indexOf("\n", start);
2163
+ if (str[idx - 1] === "\r")
2164
+ idx--;
2165
+ return idx <= end ? idx : -1;
2166
+ }
2167
+ function skipComment(str, ptr) {
2168
+ for (let i = ptr; i < str.length; i++) {
2169
+ let c = str[i];
2170
+ if (c === "\n")
2171
+ return i;
2172
+ if (c === "\r" && str[i + 1] === "\n")
2173
+ return i + 1;
2174
+ if (c < " " && c !== " " || c === "\x7F") {
2175
+ throw new TomlError("control characters are not allowed in comments", {
2176
+ toml: str,
2177
+ ptr
2178
+ });
2179
+ }
2180
+ }
2181
+ return str.length;
2182
+ }
2183
+ function skipVoid(str, ptr, banNewLines, banComments) {
2184
+ let c;
2185
+ while ((c = str[ptr]) === " " || c === " " || !banNewLines && (c === "\n" || c === "\r" && str[ptr + 1] === "\n"))
2186
+ ptr++;
2187
+ return banComments || c !== "#" ? ptr : skipVoid(str, skipComment(str, ptr), banNewLines);
2188
+ }
2189
+ function skipUntil(str, ptr, sep, end, banNewLines = false) {
2190
+ if (!end) {
2191
+ ptr = indexOfNewline(str, ptr);
2192
+ return ptr < 0 ? str.length : ptr;
2193
+ }
2194
+ for (let i = ptr; i < str.length; i++) {
2195
+ let c = str[i];
2196
+ if (c === "#") {
2197
+ i = indexOfNewline(str, i);
2198
+ } else if (c === sep) {
2199
+ return i + 1;
2200
+ } else if (c === end || banNewLines && (c === "\n" || c === "\r" && str[i + 1] === "\n")) {
2201
+ return i;
2202
+ }
2203
+ }
2204
+ throw new TomlError("cannot find end of structure", {
2205
+ toml: str,
2206
+ ptr
2207
+ });
2208
+ }
2209
+ function getStringEnd(str, seek) {
2210
+ let first = str[seek];
2211
+ let target = first === str[seek + 1] && str[seek + 1] === str[seek + 2] ? str.slice(seek, seek + 3) : first;
2212
+ seek += target.length - 1;
2213
+ do
2214
+ seek = str.indexOf(target, ++seek);
2215
+ while (seek > -1 && first !== "'" && isEscaped(str, seek));
2216
+ if (seek > -1) {
2217
+ seek += target.length;
2218
+ if (target.length > 1) {
2219
+ if (str[seek] === first)
2220
+ seek++;
2221
+ if (str[seek] === first)
2222
+ seek++;
2223
+ }
2224
+ }
2225
+ return seek;
2226
+ }
2227
+ var DATE_TIME_RE = /^(\d{4}-\d{2}-\d{2})?[T ]?(?:(\d{2}):\d{2}(?::\d{2}(?:\.\d+)?)?)?(Z|[-+]\d{2}:\d{2})?$/i;
2228
+ var TomlDate = class _TomlDate extends Date {
2229
+ #hasDate = false;
2230
+ #hasTime = false;
2231
+ #offset = null;
2232
+ constructor(date) {
2233
+ let hasDate = true;
2234
+ let hasTime = true;
2235
+ let offset = "Z";
2236
+ if (typeof date === "string") {
2237
+ let match = date.match(DATE_TIME_RE);
2238
+ if (match) {
2239
+ if (!match[1]) {
2240
+ hasDate = false;
2241
+ date = `0000-01-01T${date}`;
2242
+ }
2243
+ hasTime = !!match[2];
2244
+ hasTime && date[10] === " " && (date = date.replace(" ", "T"));
2245
+ if (match[2] && +match[2] > 23) {
2246
+ date = "";
2247
+ } else {
2248
+ offset = match[3] || null;
2249
+ date = date.toUpperCase();
2250
+ if (!offset && hasTime)
2251
+ date += "Z";
2252
+ }
2253
+ } else {
2254
+ date = "";
2255
+ }
2256
+ }
2257
+ super(date);
2258
+ if (!isNaN(this.getTime())) {
2259
+ this.#hasDate = hasDate;
2260
+ this.#hasTime = hasTime;
2261
+ this.#offset = offset;
2262
+ }
2263
+ }
2264
+ isDateTime() {
2265
+ return this.#hasDate && this.#hasTime;
2266
+ }
2267
+ isLocal() {
2268
+ return !this.#hasDate || !this.#hasTime || !this.#offset;
2269
+ }
2270
+ isDate() {
2271
+ return this.#hasDate && !this.#hasTime;
2272
+ }
2273
+ isTime() {
2274
+ return this.#hasTime && !this.#hasDate;
2275
+ }
2276
+ isValid() {
2277
+ return this.#hasDate || this.#hasTime;
2278
+ }
2279
+ toISOString() {
2280
+ let iso = super.toISOString();
2281
+ if (this.isDate())
2282
+ return iso.slice(0, 10);
2283
+ if (this.isTime())
2284
+ return iso.slice(11, 23);
2285
+ if (this.#offset === null)
2286
+ return iso.slice(0, -1);
2287
+ if (this.#offset === "Z")
2288
+ return iso;
2289
+ let offset = +this.#offset.slice(1, 3) * 60 + +this.#offset.slice(4, 6);
2290
+ offset = this.#offset[0] === "-" ? offset : -offset;
2291
+ let offsetDate = new Date(this.getTime() - offset * 6e4);
2292
+ return offsetDate.toISOString().slice(0, -1) + this.#offset;
2293
+ }
2294
+ static wrapAsOffsetDateTime(jsDate, offset = "Z") {
2295
+ let date = new _TomlDate(jsDate);
2296
+ date.#offset = offset;
2297
+ return date;
2298
+ }
2299
+ static wrapAsLocalDateTime(jsDate) {
2300
+ let date = new _TomlDate(jsDate);
2301
+ date.#offset = null;
2302
+ return date;
2303
+ }
2304
+ static wrapAsLocalDate(jsDate) {
2305
+ let date = new _TomlDate(jsDate);
2306
+ date.#hasTime = false;
2307
+ date.#offset = null;
2308
+ return date;
2309
+ }
2310
+ static wrapAsLocalTime(jsDate) {
2311
+ let date = new _TomlDate(jsDate);
2312
+ date.#hasDate = false;
2313
+ date.#offset = null;
2314
+ return date;
2315
+ }
2316
+ };
2317
+ var INT_REGEX = /^((0x[0-9a-fA-F](_?[0-9a-fA-F])*)|(([+-]|0[ob])?\d(_?\d)*))$/;
2318
+ var FLOAT_REGEX = /^[+-]?\d(_?\d)*(\.\d(_?\d)*)?([eE][+-]?\d(_?\d)*)?$/;
2319
+ var LEADING_ZERO = /^[+-]?0[0-9_]/;
2320
+ var ESCAPE_REGEX = /^[0-9a-f]{2,8}$/i;
2321
+ var ESC_MAP = {
2322
+ b: "\b",
2323
+ t: " ",
2324
+ n: "\n",
2325
+ f: "\f",
2326
+ r: "\r",
2327
+ e: "\x1B",
2328
+ '"': '"',
2329
+ "\\": "\\"
2330
+ };
2331
+ function parseString(str, ptr = 0, endPtr = str.length) {
2332
+ let isLiteral = str[ptr] === "'";
2333
+ let isMultiline = str[ptr++] === str[ptr] && str[ptr] === str[ptr + 1];
2334
+ if (isMultiline) {
2335
+ endPtr -= 2;
2336
+ if (str[ptr += 2] === "\r")
2337
+ ptr++;
2338
+ if (str[ptr] === "\n")
2339
+ ptr++;
2340
+ }
2341
+ let tmp = 0;
2342
+ let isEscape;
2343
+ let parsed = "";
2344
+ let sliceStart = ptr;
2345
+ while (ptr < endPtr - 1) {
2346
+ let c = str[ptr++];
2347
+ if (c === "\n" || c === "\r" && str[ptr] === "\n") {
2348
+ if (!isMultiline) {
2349
+ throw new TomlError("newlines are not allowed in strings", {
2350
+ toml: str,
2351
+ ptr: ptr - 1
2352
+ });
2353
+ }
2354
+ } else if (c < " " && c !== " " || c === "\x7F") {
2355
+ throw new TomlError("control characters are not allowed in strings", {
2356
+ toml: str,
2357
+ ptr: ptr - 1
2358
+ });
2359
+ }
2360
+ if (isEscape) {
2361
+ isEscape = false;
2362
+ if (c === "x" || c === "u" || c === "U") {
2363
+ let code = str.slice(ptr, ptr += c === "x" ? 2 : c === "u" ? 4 : 8);
2364
+ if (!ESCAPE_REGEX.test(code)) {
2365
+ throw new TomlError("invalid unicode escape", {
2366
+ toml: str,
2367
+ ptr: tmp
2368
+ });
2369
+ }
2370
+ try {
2371
+ parsed += String.fromCodePoint(parseInt(code, 16));
2372
+ } catch {
2373
+ throw new TomlError("invalid unicode escape", {
2374
+ toml: str,
2375
+ ptr: tmp
2376
+ });
2377
+ }
2378
+ } else if (isMultiline && (c === "\n" || c === " " || c === " " || c === "\r")) {
2379
+ ptr = skipVoid(str, ptr - 1, true);
2380
+ if (str[ptr] !== "\n" && str[ptr] !== "\r") {
2381
+ throw new TomlError("invalid escape: only line-ending whitespace may be escaped", {
2382
+ toml: str,
2383
+ ptr: tmp
2384
+ });
2385
+ }
2386
+ ptr = skipVoid(str, ptr);
2387
+ } else if (c in ESC_MAP) {
2388
+ parsed += ESC_MAP[c];
2389
+ } else {
2390
+ throw new TomlError("unrecognized escape sequence", {
2391
+ toml: str,
2392
+ ptr: tmp
2393
+ });
2394
+ }
2395
+ sliceStart = ptr;
2396
+ } else if (!isLiteral && c === "\\") {
2397
+ tmp = ptr - 1;
2398
+ isEscape = true;
2399
+ parsed += str.slice(sliceStart, tmp);
2400
+ }
2401
+ }
2402
+ return parsed + str.slice(sliceStart, endPtr - 1);
2403
+ }
2404
+ function parseValue(value, toml, ptr, integersAsBigInt) {
2405
+ if (value === "true")
2406
+ return true;
2407
+ if (value === "false")
2408
+ return false;
2409
+ if (value === "-inf")
2410
+ return -Infinity;
2411
+ if (value === "inf" || value === "+inf")
2412
+ return Infinity;
2413
+ if (value === "nan" || value === "+nan" || value === "-nan")
2414
+ return NaN;
2415
+ if (value === "-0")
2416
+ return integersAsBigInt ? 0n : 0;
2417
+ let isInt = INT_REGEX.test(value);
2418
+ if (isInt || FLOAT_REGEX.test(value)) {
2419
+ if (LEADING_ZERO.test(value)) {
2420
+ throw new TomlError("leading zeroes are not allowed", {
2421
+ toml,
2422
+ ptr
2423
+ });
2424
+ }
2425
+ value = value.replace(/_/g, "");
2426
+ let numeric = +value;
2427
+ if (isNaN(numeric)) {
2428
+ throw new TomlError("invalid number", {
2429
+ toml,
2430
+ ptr
2431
+ });
2432
+ }
2433
+ if (isInt) {
2434
+ if ((isInt = !Number.isSafeInteger(numeric)) && !integersAsBigInt) {
2435
+ throw new TomlError("integer value cannot be represented losslessly", {
2436
+ toml,
2437
+ ptr
2438
+ });
2439
+ }
2440
+ if (isInt || integersAsBigInt === true)
2441
+ numeric = BigInt(value);
2442
+ }
2443
+ return numeric;
2444
+ }
2445
+ const date = new TomlDate(value);
2446
+ if (!date.isValid()) {
2447
+ throw new TomlError("invalid value", {
2448
+ toml,
2449
+ ptr
2450
+ });
2451
+ }
2452
+ return date;
2453
+ }
2454
+ function sliceAndTrimEndOf(str, startPtr, endPtr) {
2455
+ let value = str.slice(startPtr, endPtr);
2456
+ let commentIdx = value.indexOf("#");
2457
+ if (commentIdx > -1) {
2458
+ skipComment(str, commentIdx);
2459
+ value = value.slice(0, commentIdx);
2460
+ }
2461
+ return [value.trimEnd(), commentIdx];
2462
+ }
2463
+ function extractValue(str, ptr, end, depth, integersAsBigInt) {
2464
+ if (depth === 0) {
2465
+ throw new TomlError("document contains excessively nested structures. aborting.", {
2466
+ toml: str,
2467
+ ptr
2468
+ });
2469
+ }
2470
+ let c = str[ptr];
2471
+ if (c === "[" || c === "{") {
2472
+ let [value, endPtr2] = c === "[" ? parseArray(str, ptr, depth, integersAsBigInt) : parseInlineTable(str, ptr, depth, integersAsBigInt);
2473
+ if (end) {
2474
+ endPtr2 = skipVoid(str, endPtr2);
2475
+ if (str[endPtr2] === ",")
2476
+ endPtr2++;
2477
+ else if (str[endPtr2] !== end) {
2478
+ throw new TomlError("expected comma or end of structure", {
2479
+ toml: str,
2480
+ ptr: endPtr2
2481
+ });
2482
+ }
2483
+ }
2484
+ return [value, endPtr2];
2485
+ }
2486
+ let endPtr;
2487
+ if (c === '"' || c === "'") {
2488
+ endPtr = getStringEnd(str, ptr);
2489
+ let parsed = parseString(str, ptr, endPtr);
2490
+ if (end) {
2491
+ endPtr = skipVoid(str, endPtr);
2492
+ if (str[endPtr] && str[endPtr] !== "," && str[endPtr] !== end && str[endPtr] !== "\n" && str[endPtr] !== "\r") {
2493
+ throw new TomlError("unexpected character encountered", {
2494
+ toml: str,
2495
+ ptr: endPtr
2496
+ });
2497
+ }
2498
+ endPtr += +(str[endPtr] === ",");
2499
+ }
2500
+ return [parsed, endPtr];
2501
+ }
2502
+ endPtr = skipUntil(str, ptr, ",", end);
2503
+ let slice = sliceAndTrimEndOf(str, ptr, endPtr - +(str[endPtr - 1] === ","));
2504
+ if (!slice[0]) {
2505
+ throw new TomlError("incomplete key-value declaration: no value specified", {
2506
+ toml: str,
2507
+ ptr
2508
+ });
2509
+ }
2510
+ if (end && slice[1] > -1) {
2511
+ endPtr = skipVoid(str, ptr + slice[1]);
2512
+ endPtr += +(str[endPtr] === ",");
2513
+ }
2514
+ return [
2515
+ parseValue(slice[0], str, ptr, integersAsBigInt),
2516
+ endPtr
2517
+ ];
2518
+ }
2519
+ var KEY_PART_RE = /^[a-zA-Z0-9-_]+[ \t]*$/;
2520
+ function parseKey(str, ptr, end = "=") {
2521
+ let dot = ptr - 1;
2522
+ let parsed = [];
2523
+ let endPtr = str.indexOf(end, ptr);
2524
+ if (endPtr < 0) {
2525
+ throw new TomlError("incomplete key-value: cannot find end of key", {
2526
+ toml: str,
2527
+ ptr
2528
+ });
2529
+ }
2530
+ do {
2531
+ let c = str[ptr = ++dot];
2532
+ if (c !== " " && c !== " ") {
2533
+ if (c === '"' || c === "'") {
2534
+ if (c === str[ptr + 1] && c === str[ptr + 2]) {
2535
+ throw new TomlError("multiline strings are not allowed in keys", {
2536
+ toml: str,
2537
+ ptr
2538
+ });
2539
+ }
2540
+ let eos = getStringEnd(str, ptr);
2541
+ if (eos < 0) {
2542
+ throw new TomlError("unfinished string encountered", {
2543
+ toml: str,
2544
+ ptr
2545
+ });
2546
+ }
2547
+ dot = str.indexOf(".", eos);
2548
+ let strEnd = str.slice(eos, dot < 0 || dot > endPtr ? endPtr : dot);
2549
+ let newLine = indexOfNewline(strEnd);
2550
+ if (newLine > -1) {
2551
+ throw new TomlError("newlines are not allowed in keys", {
2552
+ toml: str,
2553
+ ptr: ptr + dot + newLine
2554
+ });
2555
+ }
2556
+ if (strEnd.trimStart()) {
2557
+ throw new TomlError("found extra tokens after the string part", {
2558
+ toml: str,
2559
+ ptr: eos
2560
+ });
2561
+ }
2562
+ if (endPtr < eos) {
2563
+ endPtr = str.indexOf(end, eos);
2564
+ if (endPtr < 0) {
2565
+ throw new TomlError("incomplete key-value: cannot find end of key", {
2566
+ toml: str,
2567
+ ptr
2568
+ });
2569
+ }
2570
+ }
2571
+ parsed.push(parseString(str, ptr, eos));
2572
+ } else {
2573
+ dot = str.indexOf(".", ptr);
2574
+ let part = str.slice(ptr, dot < 0 || dot > endPtr ? endPtr : dot);
2575
+ if (!KEY_PART_RE.test(part)) {
2576
+ throw new TomlError("only letter, numbers, dashes and underscores are allowed in keys", {
2577
+ toml: str,
2578
+ ptr
2579
+ });
2580
+ }
2581
+ parsed.push(part.trimEnd());
2582
+ }
2583
+ }
2584
+ } while (dot + 1 && dot < endPtr);
2585
+ return [parsed, skipVoid(str, endPtr + 1, true, true)];
2586
+ }
2587
+ function parseInlineTable(str, ptr, depth, integersAsBigInt) {
2588
+ let res = {};
2589
+ let seen = /* @__PURE__ */ new Set();
2590
+ let c;
2591
+ ptr++;
2592
+ while ((c = str[ptr++]) !== "}" && c) {
2593
+ if (c === ",") {
2594
+ throw new TomlError("expected value, found comma", {
2595
+ toml: str,
2596
+ ptr: ptr - 1
2597
+ });
2598
+ } else if (c === "#")
2599
+ ptr = skipComment(str, ptr);
2600
+ else if (c !== " " && c !== " " && c !== "\n" && c !== "\r") {
2601
+ let k;
2602
+ let t = res;
2603
+ let hasOwn = false;
2604
+ let [key, keyEndPtr] = parseKey(str, ptr - 1);
2605
+ for (let i = 0; i < key.length; i++) {
2606
+ if (i)
2607
+ t = hasOwn ? t[k] : t[k] = {};
2608
+ k = key[i];
2609
+ if ((hasOwn = Object.hasOwn(t, k)) && (typeof t[k] !== "object" || seen.has(t[k]))) {
2610
+ throw new TomlError("trying to redefine an already defined value", {
2611
+ toml: str,
2612
+ ptr
2613
+ });
2614
+ }
2615
+ if (!hasOwn && k === "__proto__") {
2616
+ Object.defineProperty(t, k, { enumerable: true, configurable: true, writable: true });
2617
+ }
2618
+ }
2619
+ if (hasOwn) {
2620
+ throw new TomlError("trying to redefine an already defined value", {
2621
+ toml: str,
2622
+ ptr
2623
+ });
2624
+ }
2625
+ let [value, valueEndPtr] = extractValue(str, keyEndPtr, "}", depth - 1, integersAsBigInt);
2626
+ seen.add(value);
2627
+ t[k] = value;
2628
+ ptr = valueEndPtr;
2629
+ }
2630
+ }
2631
+ if (!c) {
2632
+ throw new TomlError("unfinished table encountered", {
2633
+ toml: str,
2634
+ ptr
2635
+ });
2636
+ }
2637
+ return [res, ptr];
2638
+ }
2639
+ function parseArray(str, ptr, depth, integersAsBigInt) {
2640
+ let res = [];
2641
+ let c;
2642
+ ptr++;
2643
+ while ((c = str[ptr++]) !== "]" && c) {
2644
+ if (c === ",") {
2645
+ throw new TomlError("expected value, found comma", {
2646
+ toml: str,
2647
+ ptr: ptr - 1
2648
+ });
2649
+ } else if (c === "#")
2650
+ ptr = skipComment(str, ptr);
2651
+ else if (c !== " " && c !== " " && c !== "\n" && c !== "\r") {
2652
+ let e = extractValue(str, ptr - 1, "]", depth - 1, integersAsBigInt);
2653
+ res.push(e[0]);
2654
+ ptr = e[1];
2655
+ }
2656
+ }
2657
+ if (!c) {
2658
+ throw new TomlError("unfinished array encountered", {
2659
+ toml: str,
2660
+ ptr
2661
+ });
2662
+ }
2663
+ return [res, ptr];
2664
+ }
2665
+ function peekTable(key, table, meta, type) {
2666
+ var _a, _b;
2667
+ let t = table;
2668
+ let m = meta;
2669
+ let k;
2670
+ let hasOwn = false;
2671
+ let state;
2672
+ for (let i = 0; i < key.length; i++) {
2673
+ if (i) {
2674
+ t = hasOwn ? t[k] : t[k] = {};
2675
+ m = (state = m[k]).c;
2676
+ if (type === 0 && (state.t === 1 || state.t === 2)) {
2677
+ return null;
2678
+ }
2679
+ if (state.t === 2) {
2680
+ let l = t.length - 1;
2681
+ t = t[l];
2682
+ m = m[l].c;
2683
+ }
2684
+ }
2685
+ k = key[i];
2686
+ if ((hasOwn = Object.hasOwn(t, k)) && ((_a = m[k]) == null ? void 0 : _a.t) === 0 && ((_b = m[k]) == null ? void 0 : _b.d)) {
2687
+ return null;
2688
+ }
2689
+ if (!hasOwn) {
2690
+ if (k === "__proto__") {
2691
+ Object.defineProperty(t, k, { enumerable: true, configurable: true, writable: true });
2692
+ Object.defineProperty(m, k, { enumerable: true, configurable: true, writable: true });
2693
+ }
2694
+ m[k] = {
2695
+ t: i < key.length - 1 && type === 2 ? 3 : type,
2696
+ d: false,
2697
+ i: 0,
2698
+ c: {}
2699
+ };
2700
+ }
2701
+ }
2702
+ state = m[k];
2703
+ if (state.t !== type && !(type === 1 && state.t === 3)) {
2704
+ return null;
2705
+ }
2706
+ if (type === 2) {
2707
+ if (!state.d) {
2708
+ state.d = true;
2709
+ t[k] = [];
2710
+ }
2711
+ t[k].push(t = {});
2712
+ state.c[state.i++] = state = { t: 1, d: false, i: 0, c: {} };
2713
+ }
2714
+ if (state.d) {
2715
+ return null;
2716
+ }
2717
+ state.d = true;
2718
+ if (type === 1) {
2719
+ t = hasOwn ? t[k] : t[k] = {};
2720
+ } else if (type === 0 && hasOwn) {
2721
+ return null;
2722
+ }
2723
+ return [k, t, state.c];
2724
+ }
2725
+ function parse(toml, { maxDepth = 1e3, integersAsBigInt } = {}) {
2726
+ let res = {};
2727
+ let meta = {};
2728
+ let tbl = res;
2729
+ let m = meta;
2730
+ for (let ptr = skipVoid(toml, 0); ptr < toml.length; ) {
2731
+ if (toml[ptr] === "[") {
2732
+ let isTableArray = toml[++ptr] === "[";
2733
+ let k = parseKey(toml, ptr += +isTableArray, "]");
2734
+ if (isTableArray) {
2735
+ if (toml[k[1] - 1] !== "]") {
2736
+ throw new TomlError("expected end of table declaration", {
2737
+ toml,
2738
+ ptr: k[1] - 1
2739
+ });
2740
+ }
2741
+ k[1]++;
2742
+ }
2743
+ let p = peekTable(
2744
+ k[0],
2745
+ res,
2746
+ meta,
2747
+ isTableArray ? 2 : 1
2748
+ /* Type.EXPLICIT */
2749
+ );
2750
+ if (!p) {
2751
+ throw new TomlError("trying to redefine an already defined table or value", {
2752
+ toml,
2753
+ ptr
2754
+ });
2755
+ }
2756
+ m = p[2];
2757
+ tbl = p[1];
2758
+ ptr = k[1];
2759
+ } else {
2760
+ let k = parseKey(toml, ptr);
2761
+ let p = peekTable(
2762
+ k[0],
2763
+ tbl,
2764
+ m,
2765
+ 0
2766
+ /* Type.DOTTED */
2767
+ );
2768
+ if (!p) {
2769
+ throw new TomlError("trying to redefine an already defined table or value", {
2770
+ toml,
2771
+ ptr
2772
+ });
2773
+ }
2774
+ let v = extractValue(toml, k[1], void 0, maxDepth, integersAsBigInt);
2775
+ p[1][p[0]] = v[0];
2776
+ ptr = v[1];
2777
+ }
2778
+ ptr = skipVoid(toml, ptr, true);
2779
+ if (toml[ptr] && toml[ptr] !== "\n" && toml[ptr] !== "\r") {
2780
+ throw new TomlError("each key-value declaration must be followed by an end-of-line", {
2781
+ toml,
2782
+ ptr
2783
+ });
2784
+ }
2785
+ ptr = skipVoid(toml, ptr);
2786
+ }
2787
+ return res;
2788
+ }
2789
+ var BARE_KEY = /^[a-z0-9-_]+$/i;
2790
+ function extendedTypeOf(obj) {
2791
+ let type = typeof obj;
2792
+ if (type === "object") {
2793
+ if (Array.isArray(obj))
2794
+ return "array";
2795
+ if (obj instanceof Date)
2796
+ return "date";
2797
+ }
2798
+ return type;
2799
+ }
2800
+ function isArrayOfTables(obj) {
2801
+ for (let i = 0; i < obj.length; i++) {
2802
+ if (extendedTypeOf(obj[i]) !== "object")
2803
+ return false;
2804
+ }
2805
+ return obj.length != 0;
2806
+ }
2807
+ function formatString(s) {
2808
+ return JSON.stringify(s).replace(/\x7f/g, "\\u007f");
2809
+ }
2810
+ function stringifyValue(val, type, depth, numberAsFloat) {
2811
+ if (depth === 0) {
2812
+ throw new Error("Could not stringify the object: maximum object depth exceeded");
2813
+ }
2814
+ if (type === "number") {
2815
+ if (isNaN(val))
2816
+ return "nan";
2817
+ if (val === Infinity)
2818
+ return "inf";
2819
+ if (val === -Infinity)
2820
+ return "-inf";
2821
+ if (numberAsFloat && Number.isInteger(val))
2822
+ return val.toFixed(1);
2823
+ return val.toString();
2824
+ }
2825
+ if (type === "bigint" || type === "boolean") {
2826
+ return val.toString();
2827
+ }
2828
+ if (type === "string") {
2829
+ return formatString(val);
2830
+ }
2831
+ if (type === "date") {
2832
+ if (isNaN(val.getTime())) {
2833
+ throw new TypeError("cannot serialize invalid date");
2834
+ }
2835
+ return val.toISOString();
2836
+ }
2837
+ if (type === "object") {
2838
+ return stringifyInlineTable(val, depth, numberAsFloat);
2839
+ }
2840
+ if (type === "array") {
2841
+ return stringifyArray(val, depth, numberAsFloat);
2842
+ }
2843
+ }
2844
+ function stringifyInlineTable(obj, depth, numberAsFloat) {
2845
+ let keys = Object.keys(obj);
2846
+ if (keys.length === 0)
2847
+ return "{}";
2848
+ let res = "{ ";
2849
+ for (let i = 0; i < keys.length; i++) {
2850
+ let k = keys[i];
2851
+ if (i)
2852
+ res += ", ";
2853
+ res += BARE_KEY.test(k) ? k : formatString(k);
2854
+ res += " = ";
2855
+ res += stringifyValue(obj[k], extendedTypeOf(obj[k]), depth - 1, numberAsFloat);
2856
+ }
2857
+ return res + " }";
2858
+ }
2859
+ function stringifyArray(array, depth, numberAsFloat) {
2860
+ if (array.length === 0)
2861
+ return "[]";
2862
+ let res = "[ ";
2863
+ for (let i = 0; i < array.length; i++) {
2864
+ if (i)
2865
+ res += ", ";
2866
+ if (array[i] === null || array[i] === void 0) {
2867
+ throw new TypeError("arrays cannot contain null or undefined values");
2868
+ }
2869
+ res += stringifyValue(array[i], extendedTypeOf(array[i]), depth - 1, numberAsFloat);
2870
+ }
2871
+ return res + " ]";
2872
+ }
2873
+ function stringifyArrayTable(array, key, depth, numberAsFloat) {
2874
+ if (depth === 0) {
2875
+ throw new Error("Could not stringify the object: maximum object depth exceeded");
2876
+ }
2877
+ let res = "";
2878
+ for (let i = 0; i < array.length; i++) {
2879
+ res += `${res && "\n"}[[${key}]]
2880
+ `;
2881
+ res += stringifyTable(0, array[i], key, depth, numberAsFloat);
2882
+ }
2883
+ return res;
2884
+ }
2885
+ function stringifyTable(tableKey, obj, prefix, depth, numberAsFloat) {
2886
+ if (depth === 0) {
2887
+ throw new Error("Could not stringify the object: maximum object depth exceeded");
2888
+ }
2889
+ let preamble = "";
2890
+ let tables = "";
2891
+ let keys = Object.keys(obj);
2892
+ for (let i = 0; i < keys.length; i++) {
2893
+ let k = keys[i];
2894
+ if (obj[k] !== null && obj[k] !== void 0) {
2895
+ let type = extendedTypeOf(obj[k]);
2896
+ if (type === "symbol" || type === "function") {
2897
+ throw new TypeError(`cannot serialize values of type '${type}'`);
2898
+ }
2899
+ let key = BARE_KEY.test(k) ? k : formatString(k);
2900
+ if (type === "array" && isArrayOfTables(obj[k])) {
2901
+ tables += (tables && "\n") + stringifyArrayTable(obj[k], prefix ? `${prefix}.${key}` : key, depth - 1, numberAsFloat);
2902
+ } else if (type === "object") {
2903
+ let tblKey = prefix ? `${prefix}.${key}` : key;
2904
+ tables += (tables && "\n") + stringifyTable(tblKey, obj[k], tblKey, depth - 1, numberAsFloat);
2905
+ } else {
2906
+ preamble += key;
2907
+ preamble += " = ";
2908
+ preamble += stringifyValue(obj[k], type, depth, numberAsFloat);
2909
+ preamble += "\n";
2910
+ }
2911
+ }
2912
+ }
2913
+ if (tableKey && (preamble || !tables))
2914
+ preamble = preamble ? `[${tableKey}]
2915
+ ${preamble}` : `[${tableKey}]`;
2916
+ return preamble && tables ? `${preamble}
2917
+ ${tables}` : preamble || tables;
2918
+ }
2919
+ function stringify(obj, { maxDepth = 1e3, numbersAsFloat = false } = {}) {
2920
+ if (extendedTypeOf(obj) !== "object") {
2921
+ throw new TypeError("stringify can only be called with an object");
2922
+ }
2923
+ let str = stringifyTable(0, obj, "", maxDepth, numbersAsFloat);
2924
+ if (str[str.length - 1] !== "\n")
2925
+ return str + "\n";
2926
+ return str;
2927
+ }
2111
2928
  function configFilePath() {
2112
2929
  return join2(homedir2(), ".toobit", "config.toml");
2113
2930
  }
@@ -2118,9 +2935,10 @@ function readFullConfig() {
2118
2935
  return parse(raw);
2119
2936
  }
2120
2937
  function readTomlProfile(profileName) {
2938
+ var _a;
2121
2939
  const config = readFullConfig();
2122
2940
  const name = profileName ?? config.default_profile ?? "default";
2123
- return config.profiles?.[name] ?? {};
2941
+ return ((_a = config.profiles) == null ? void 0 : _a[name]) ?? {};
2124
2942
  }
2125
2943
  function writeFullConfig(config) {
2126
2944
  const path4 = configFilePath();
@@ -2155,9 +2973,10 @@ function parseModuleList(rawModules) {
2155
2973
  return Array.from(deduped);
2156
2974
  }
2157
2975
  function loadConfig(cli) {
2976
+ var _a, _b, _c;
2158
2977
  const toml = readTomlProfile(cli.profile);
2159
- const apiKey = process.env.TOOBIT_API_KEY?.trim() ?? toml.api_key;
2160
- const secretKey = process.env.TOOBIT_SECRET_KEY?.trim() ?? toml.secret_key;
2978
+ const apiKey = ((_a = process.env.TOOBIT_API_KEY) == null ? void 0 : _a.trim()) ?? toml.api_key;
2979
+ const secretKey = ((_b = process.env.TOOBIT_SECRET_KEY) == null ? void 0 : _b.trim()) ?? toml.secret_key;
2161
2980
  const hasAuth = Boolean(apiKey && secretKey);
2162
2981
  const partialAuth = Boolean(apiKey) || Boolean(secretKey);
2163
2982
  if (partialAuth && !hasAuth) {
@@ -2166,7 +2985,7 @@ function loadConfig(cli) {
2166
2985
  "Set TOOBIT_API_KEY and TOOBIT_SECRET_KEY together (env vars or config.toml profile)."
2167
2986
  );
2168
2987
  }
2169
- const rawBaseUrl = process.env.TOOBIT_API_BASE_URL?.trim() ?? toml.base_url ?? TOOBIT_API_BASE_URL;
2988
+ const rawBaseUrl = ((_c = process.env.TOOBIT_API_BASE_URL) == null ? void 0 : _c.trim()) ?? toml.base_url ?? TOOBIT_API_BASE_URL;
2170
2989
  if (!rawBaseUrl.startsWith("http://") && !rawBaseUrl.startsWith("https://")) {
2171
2990
  throw new ConfigError(
2172
2991
  `Invalid base URL "${rawBaseUrl}".`,
@@ -2202,7 +3021,7 @@ var CLIENT_NAMES = {
2202
3021
  };
2203
3022
  var SUPPORTED_CLIENTS = Object.keys(CLIENT_NAMES);
2204
3023
 
2205
- // src/parser.ts
3024
+ // packages/cli/src/parser.ts
2206
3025
  import { parseArgs } from "util";
2207
3026
  function parseCli(argv = process.argv.slice(2)) {
2208
3027
  const STRING_OPTIONS = /* @__PURE__ */ new Set([
@@ -2283,7 +3102,7 @@ function parseCli(argv = process.argv.slice(2)) {
2283
3102
  };
2284
3103
  }
2285
3104
 
2286
- // src/formatter.ts
3105
+ // packages/cli/src/formatter.ts
2287
3106
  function extractRows(value) {
2288
3107
  if (Array.isArray(value)) return value;
2289
3108
  if (typeof value === "object" && value !== null) {
@@ -2338,7 +3157,7 @@ ${separator}
2338
3157
  ${body}`;
2339
3158
  }
2340
3159
 
2341
- // src/commands/market.ts
3160
+ // packages/cli/src/commands/market.ts
2342
3161
  async function handleMarketCommand(cli, run) {
2343
3162
  const f = cli.flags;
2344
3163
  let result;
@@ -2416,7 +3235,7 @@ Available: time, info, ticker, ticker-24hr, depth, trades, klines, candles, book
2416
3235
  process.stdout.write(formatJson(result, cli.json) + "\n");
2417
3236
  }
2418
3237
 
2419
- // src/commands/spot.ts
3238
+ // packages/cli/src/commands/spot.ts
2420
3239
  async function handleSpotCommand(cli, run) {
2421
3240
  const f = cli.flags;
2422
3241
  let result;
@@ -2466,7 +3285,7 @@ Available: place, cancel, cancel-all, get, orders, open-orders, history, fills
2466
3285
  process.stdout.write(formatJson(result, cli.json) + "\n");
2467
3286
  }
2468
3287
 
2469
- // src/commands/futures.ts
3288
+ // packages/cli/src/commands/futures.ts
2470
3289
  async function handleFuturesCommand(cli, run) {
2471
3290
  const f = cli.flags;
2472
3291
  let result;
@@ -2543,7 +3362,7 @@ Available: place, cancel, cancel-all, amend, get, orders, history, positions, hi
2543
3362
  process.stdout.write(formatJson(result, cli.json) + "\n");
2544
3363
  }
2545
3364
 
2546
- // src/commands/account.ts
3365
+ // packages/cli/src/commands/account.ts
2547
3366
  async function handleAccountCommand(cli, run) {
2548
3367
  const f = cli.flags;
2549
3368
  let result;
@@ -2592,7 +3411,7 @@ Available: balance, info, balance-flow, sub-accounts, check-api-key, deposit-add
2592
3411
  process.stdout.write(formatJson(result, cli.json) + "\n");
2593
3412
  }
2594
3413
 
2595
- // src/commands/config.ts
3414
+ // packages/cli/src/commands/config.ts
2596
3415
  import * as readline from "readline";
2597
3416
  function prompt(question) {
2598
3417
  const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
@@ -2658,7 +3477,7 @@ Available: init, show, list
2658
3477
  }
2659
3478
  }
2660
3479
 
2661
- // src/index.ts
3480
+ // packages/cli/src/index.ts
2662
3481
  function printHelp() {
2663
3482
  const help = `
2664
3483
  Toobit Trade CLI \u2014 Trade from your terminal
@@ -2733,3 +3552,42 @@ main().catch((error) => {
2733
3552
  `);
2734
3553
  process.exitCode = 1;
2735
3554
  });
3555
+ /*! Bundled license information:
3556
+
3557
+ smol-toml/dist/error.js:
3558
+ smol-toml/dist/util.js:
3559
+ smol-toml/dist/date.js:
3560
+ smol-toml/dist/primitive.js:
3561
+ smol-toml/dist/extract.js:
3562
+ smol-toml/dist/struct.js:
3563
+ smol-toml/dist/parse.js:
3564
+ smol-toml/dist/stringify.js:
3565
+ smol-toml/dist/index.js:
3566
+ (*!
3567
+ * Copyright (c) Squirrel Chat et al., All rights reserved.
3568
+ * SPDX-License-Identifier: BSD-3-Clause
3569
+ *
3570
+ * Redistribution and use in source and binary forms, with or without
3571
+ * modification, are permitted provided that the following conditions are met:
3572
+ *
3573
+ * 1. Redistributions of source code must retain the above copyright notice, this
3574
+ * list of conditions and the following disclaimer.
3575
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
3576
+ * this list of conditions and the following disclaimer in the
3577
+ * documentation and/or other materials provided with the distribution.
3578
+ * 3. Neither the name of the copyright holder nor the names of its contributors
3579
+ * may be used to endorse or promote products derived from this software without
3580
+ * specific prior written permission.
3581
+ *
3582
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
3583
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
3584
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
3585
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
3586
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
3587
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
3588
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
3589
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
3590
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
3591
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3592
+ *)
3593
+ */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "toobit-trade-cli",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "toobit": "dist/index.js"