@bithumb-official/bithumb-cli 0.1.16 → 0.1.17
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/{chunk-AUQ7MB6O.js → chunk-3VWN4HON.js} +35 -8
- package/dist/chunk-3VWN4HON.js.map +1 -0
- package/dist/{chunk-YXIFBNEQ.js → chunk-HT2P7KTV.js} +67 -994
- package/dist/chunk-HT2P7KTV.js.map +1 -0
- package/dist/{deposit-HNUSMKX5.js → deposit-KAUQEY7H.js} +6 -6
- package/dist/deposit-KAUQEY7H.js.map +1 -0
- package/dist/{deposit-TCMLJ7MI.js → deposit-L3BBLG4X.js} +21 -13
- package/dist/deposit-L3BBLG4X.js.map +1 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +99 -60
- package/dist/index.js.map +1 -1
- package/dist/{market-GLU62BWO.js → market-4IEKEJ4N.js} +8 -7
- package/dist/market-4IEKEJ4N.js.map +1 -0
- package/dist/{market-EEF3KI4T.js → market-C5ESTU3F.js} +6 -6
- package/dist/market-C5ESTU3F.js.map +1 -0
- package/dist/{setup-LAAVO63H.js → setup-NC3QC63P.js} +2 -3
- package/dist/setup-NC3QC63P.js.map +1 -0
- package/dist/{system-XRZ2KHXL.js → system-RVBNM3IX.js} +2 -2
- package/dist/{system-BRZY7PTZ.js → system-XK2EF5SQ.js} +3 -7
- package/dist/system-XK2EF5SQ.js.map +1 -0
- package/dist/{trade-H4G5P2W2.js → trade-RKL7RNME.js} +18 -8
- package/dist/trade-RKL7RNME.js.map +1 -0
- package/dist/{trade-FERR47DJ.js → trade-X5VBEQJE.js} +21 -10
- package/dist/trade-X5VBEQJE.js.map +1 -0
- package/dist/{twap-44UCVSIR.js → twap-FQJVPUWH.js} +12 -4
- package/dist/twap-FQJVPUWH.js.map +1 -0
- package/dist/{twap-4LRBUMTG.js → twap-MZ7ALPBC.js} +3 -3
- package/dist/twap-MZ7ALPBC.js.map +1 -0
- package/dist/{withdraw-TLGVRUBS.js → withdraw-65X3DXR5.js} +17 -9
- package/dist/withdraw-65X3DXR5.js.map +1 -0
- package/dist/{withdraw-IRMICBD2.js → withdraw-LDERU7T7.js} +6 -6
- package/dist/withdraw-LDERU7T7.js.map +1 -0
- package/package.json +1 -1
- package/dist/chunk-AUQ7MB6O.js.map +0 -1
- package/dist/chunk-YXIFBNEQ.js.map +0 -1
- package/dist/config-2P3Y3TQH.js +0 -182
- package/dist/config-2P3Y3TQH.js.map +0 -1
- package/dist/config-6BIS2PLC.js +0 -154
- package/dist/config-6BIS2PLC.js.map +0 -1
- package/dist/deposit-HNUSMKX5.js.map +0 -1
- package/dist/deposit-TCMLJ7MI.js.map +0 -1
- package/dist/market-EEF3KI4T.js.map +0 -1
- package/dist/market-GLU62BWO.js.map +0 -1
- package/dist/setup-LAAVO63H.js.map +0 -1
- package/dist/system-BRZY7PTZ.js.map +0 -1
- package/dist/trade-FERR47DJ.js.map +0 -1
- package/dist/trade-H4G5P2W2.js.map +0 -1
- package/dist/twap-44UCVSIR.js.map +0 -1
- package/dist/twap-4LRBUMTG.js.map +0 -1
- package/dist/withdraw-IRMICBD2.js.map +0 -1
- package/dist/withdraw-TLGVRUBS.js.map +0 -1
- /package/dist/{system-XRZ2KHXL.js.map → system-RVBNM3IX.js.map} +0 -0
|
@@ -5,851 +5,12 @@ import { createHash, createHmac, randomUUID } from "crypto";
|
|
|
5
5
|
import fs from "fs";
|
|
6
6
|
import path from "path";
|
|
7
7
|
import os from "os";
|
|
8
|
-
import {
|
|
9
|
-
import { join } from "path";
|
|
8
|
+
import { mkdirSync, appendFileSync } from "fs";
|
|
10
9
|
import { homedir } from "os";
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
10
|
+
import { join } from "path";
|
|
11
|
+
import { existsSync, mkdirSync as mkdirSync2, readFileSync, writeFileSync } from "fs";
|
|
13
12
|
import { homedir as homedir2 } from "os";
|
|
14
|
-
|
|
15
|
-
// ../../node_modules/.pnpm/smol-toml@1.6.1/node_modules/smol-toml/dist/error.js
|
|
16
|
-
function getLineColFromPtr(string, ptr) {
|
|
17
|
-
let lines = string.slice(0, ptr).split(/\r\n|\n|\r/g);
|
|
18
|
-
return [lines.length, lines.pop().length + 1];
|
|
19
|
-
}
|
|
20
|
-
function makeCodeBlock(string, line, column) {
|
|
21
|
-
let lines = string.split(/\r\n|\n|\r/g);
|
|
22
|
-
let codeblock = "";
|
|
23
|
-
let numberLen = (Math.log10(line + 1) | 0) + 1;
|
|
24
|
-
for (let i = line - 1; i <= line + 1; i++) {
|
|
25
|
-
let l = lines[i - 1];
|
|
26
|
-
if (!l)
|
|
27
|
-
continue;
|
|
28
|
-
codeblock += i.toString().padEnd(numberLen, " ");
|
|
29
|
-
codeblock += ": ";
|
|
30
|
-
codeblock += l;
|
|
31
|
-
codeblock += "\n";
|
|
32
|
-
if (i === line) {
|
|
33
|
-
codeblock += " ".repeat(numberLen + column + 2);
|
|
34
|
-
codeblock += "^\n";
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
return codeblock;
|
|
38
|
-
}
|
|
39
|
-
var TomlError = class extends Error {
|
|
40
|
-
line;
|
|
41
|
-
column;
|
|
42
|
-
codeblock;
|
|
43
|
-
constructor(message, options) {
|
|
44
|
-
const [line, column] = getLineColFromPtr(options.toml, options.ptr);
|
|
45
|
-
const codeblock = makeCodeBlock(options.toml, line, column);
|
|
46
|
-
super(`Invalid TOML document: ${message}
|
|
47
|
-
|
|
48
|
-
${codeblock}`, options);
|
|
49
|
-
this.line = line;
|
|
50
|
-
this.column = column;
|
|
51
|
-
this.codeblock = codeblock;
|
|
52
|
-
}
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
// ../../node_modules/.pnpm/smol-toml@1.6.1/node_modules/smol-toml/dist/util.js
|
|
56
|
-
function isEscaped(str, ptr) {
|
|
57
|
-
let i = 0;
|
|
58
|
-
while (str[ptr - ++i] === "\\")
|
|
59
|
-
;
|
|
60
|
-
return --i && i % 2;
|
|
61
|
-
}
|
|
62
|
-
function indexOfNewline(str, start = 0, end = str.length) {
|
|
63
|
-
let idx = str.indexOf("\n", start);
|
|
64
|
-
if (str[idx - 1] === "\r")
|
|
65
|
-
idx--;
|
|
66
|
-
return idx <= end ? idx : -1;
|
|
67
|
-
}
|
|
68
|
-
function skipComment(str, ptr) {
|
|
69
|
-
for (let i = ptr; i < str.length; i++) {
|
|
70
|
-
let c = str[i];
|
|
71
|
-
if (c === "\n")
|
|
72
|
-
return i;
|
|
73
|
-
if (c === "\r" && str[i + 1] === "\n")
|
|
74
|
-
return i + 1;
|
|
75
|
-
if (c < " " && c !== " " || c === "\x7F") {
|
|
76
|
-
throw new TomlError("control characters are not allowed in comments", {
|
|
77
|
-
toml: str,
|
|
78
|
-
ptr
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
return str.length;
|
|
83
|
-
}
|
|
84
|
-
function skipVoid(str, ptr, banNewLines, banComments) {
|
|
85
|
-
let c;
|
|
86
|
-
while (1) {
|
|
87
|
-
while ((c = str[ptr]) === " " || c === " " || !banNewLines && (c === "\n" || c === "\r" && str[ptr + 1] === "\n"))
|
|
88
|
-
ptr++;
|
|
89
|
-
if (banComments || c !== "#")
|
|
90
|
-
break;
|
|
91
|
-
ptr = skipComment(str, ptr);
|
|
92
|
-
}
|
|
93
|
-
return ptr;
|
|
94
|
-
}
|
|
95
|
-
function skipUntil(str, ptr, sep, end, banNewLines = false) {
|
|
96
|
-
if (!end) {
|
|
97
|
-
ptr = indexOfNewline(str, ptr);
|
|
98
|
-
return ptr < 0 ? str.length : ptr;
|
|
99
|
-
}
|
|
100
|
-
for (let i = ptr; i < str.length; i++) {
|
|
101
|
-
let c = str[i];
|
|
102
|
-
if (c === "#") {
|
|
103
|
-
i = indexOfNewline(str, i);
|
|
104
|
-
} else if (c === sep) {
|
|
105
|
-
return i + 1;
|
|
106
|
-
} else if (c === end || banNewLines && (c === "\n" || c === "\r" && str[i + 1] === "\n")) {
|
|
107
|
-
return i;
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
throw new TomlError("cannot find end of structure", {
|
|
111
|
-
toml: str,
|
|
112
|
-
ptr
|
|
113
|
-
});
|
|
114
|
-
}
|
|
115
|
-
function getStringEnd(str, seek) {
|
|
116
|
-
let first = str[seek];
|
|
117
|
-
let target = first === str[seek + 1] && str[seek + 1] === str[seek + 2] ? str.slice(seek, seek + 3) : first;
|
|
118
|
-
seek += target.length - 1;
|
|
119
|
-
do
|
|
120
|
-
seek = str.indexOf(target, ++seek);
|
|
121
|
-
while (seek > -1 && first !== "'" && isEscaped(str, seek));
|
|
122
|
-
if (seek > -1) {
|
|
123
|
-
seek += target.length;
|
|
124
|
-
if (target.length > 1) {
|
|
125
|
-
if (str[seek] === first)
|
|
126
|
-
seek++;
|
|
127
|
-
if (str[seek] === first)
|
|
128
|
-
seek++;
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
return seek;
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
// ../../node_modules/.pnpm/smol-toml@1.6.1/node_modules/smol-toml/dist/date.js
|
|
135
|
-
var DATE_TIME_RE = /^(\d{4}-\d{2}-\d{2})?[T ]?(?:(\d{2}):\d{2}(?::\d{2}(?:\.\d+)?)?)?(Z|[-+]\d{2}:\d{2})?$/i;
|
|
136
|
-
var TomlDate = class _TomlDate extends Date {
|
|
137
|
-
#hasDate = false;
|
|
138
|
-
#hasTime = false;
|
|
139
|
-
#offset = null;
|
|
140
|
-
constructor(date) {
|
|
141
|
-
let hasDate = true;
|
|
142
|
-
let hasTime = true;
|
|
143
|
-
let offset = "Z";
|
|
144
|
-
if (typeof date === "string") {
|
|
145
|
-
let match = date.match(DATE_TIME_RE);
|
|
146
|
-
if (match) {
|
|
147
|
-
if (!match[1]) {
|
|
148
|
-
hasDate = false;
|
|
149
|
-
date = `0000-01-01T${date}`;
|
|
150
|
-
}
|
|
151
|
-
hasTime = !!match[2];
|
|
152
|
-
hasTime && date[10] === " " && (date = date.replace(" ", "T"));
|
|
153
|
-
if (match[2] && +match[2] > 23) {
|
|
154
|
-
date = "";
|
|
155
|
-
} else {
|
|
156
|
-
offset = match[3] || null;
|
|
157
|
-
date = date.toUpperCase();
|
|
158
|
-
if (!offset && hasTime)
|
|
159
|
-
date += "Z";
|
|
160
|
-
}
|
|
161
|
-
} else {
|
|
162
|
-
date = "";
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
super(date);
|
|
166
|
-
if (!isNaN(this.getTime())) {
|
|
167
|
-
this.#hasDate = hasDate;
|
|
168
|
-
this.#hasTime = hasTime;
|
|
169
|
-
this.#offset = offset;
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
isDateTime() {
|
|
173
|
-
return this.#hasDate && this.#hasTime;
|
|
174
|
-
}
|
|
175
|
-
isLocal() {
|
|
176
|
-
return !this.#hasDate || !this.#hasTime || !this.#offset;
|
|
177
|
-
}
|
|
178
|
-
isDate() {
|
|
179
|
-
return this.#hasDate && !this.#hasTime;
|
|
180
|
-
}
|
|
181
|
-
isTime() {
|
|
182
|
-
return this.#hasTime && !this.#hasDate;
|
|
183
|
-
}
|
|
184
|
-
isValid() {
|
|
185
|
-
return this.#hasDate || this.#hasTime;
|
|
186
|
-
}
|
|
187
|
-
toISOString() {
|
|
188
|
-
let iso = super.toISOString();
|
|
189
|
-
if (this.isDate())
|
|
190
|
-
return iso.slice(0, 10);
|
|
191
|
-
if (this.isTime())
|
|
192
|
-
return iso.slice(11, 23);
|
|
193
|
-
if (this.#offset === null)
|
|
194
|
-
return iso.slice(0, -1);
|
|
195
|
-
if (this.#offset === "Z")
|
|
196
|
-
return iso;
|
|
197
|
-
let offset = +this.#offset.slice(1, 3) * 60 + +this.#offset.slice(4, 6);
|
|
198
|
-
offset = this.#offset[0] === "-" ? offset : -offset;
|
|
199
|
-
let offsetDate = new Date(this.getTime() - offset * 6e4);
|
|
200
|
-
return offsetDate.toISOString().slice(0, -1) + this.#offset;
|
|
201
|
-
}
|
|
202
|
-
static wrapAsOffsetDateTime(jsDate, offset = "Z") {
|
|
203
|
-
let date = new _TomlDate(jsDate);
|
|
204
|
-
date.#offset = offset;
|
|
205
|
-
return date;
|
|
206
|
-
}
|
|
207
|
-
static wrapAsLocalDateTime(jsDate) {
|
|
208
|
-
let date = new _TomlDate(jsDate);
|
|
209
|
-
date.#offset = null;
|
|
210
|
-
return date;
|
|
211
|
-
}
|
|
212
|
-
static wrapAsLocalDate(jsDate) {
|
|
213
|
-
let date = new _TomlDate(jsDate);
|
|
214
|
-
date.#hasTime = false;
|
|
215
|
-
date.#offset = null;
|
|
216
|
-
return date;
|
|
217
|
-
}
|
|
218
|
-
static wrapAsLocalTime(jsDate) {
|
|
219
|
-
let date = new _TomlDate(jsDate);
|
|
220
|
-
date.#hasDate = false;
|
|
221
|
-
date.#offset = null;
|
|
222
|
-
return date;
|
|
223
|
-
}
|
|
224
|
-
};
|
|
225
|
-
|
|
226
|
-
// ../../node_modules/.pnpm/smol-toml@1.6.1/node_modules/smol-toml/dist/primitive.js
|
|
227
|
-
var INT_REGEX = /^((0x[0-9a-fA-F](_?[0-9a-fA-F])*)|(([+-]|0[ob])?\d(_?\d)*))$/;
|
|
228
|
-
var FLOAT_REGEX = /^[+-]?\d(_?\d)*(\.\d(_?\d)*)?([eE][+-]?\d(_?\d)*)?$/;
|
|
229
|
-
var LEADING_ZERO = /^[+-]?0[0-9_]/;
|
|
230
|
-
var ESCAPE_REGEX = /^[0-9a-f]{2,8}$/i;
|
|
231
|
-
var ESC_MAP = {
|
|
232
|
-
b: "\b",
|
|
233
|
-
t: " ",
|
|
234
|
-
n: "\n",
|
|
235
|
-
f: "\f",
|
|
236
|
-
r: "\r",
|
|
237
|
-
e: "\x1B",
|
|
238
|
-
'"': '"',
|
|
239
|
-
"\\": "\\"
|
|
240
|
-
};
|
|
241
|
-
function parseString(str, ptr = 0, endPtr = str.length) {
|
|
242
|
-
let isLiteral = str[ptr] === "'";
|
|
243
|
-
let isMultiline = str[ptr++] === str[ptr] && str[ptr] === str[ptr + 1];
|
|
244
|
-
if (isMultiline) {
|
|
245
|
-
endPtr -= 2;
|
|
246
|
-
if (str[ptr += 2] === "\r")
|
|
247
|
-
ptr++;
|
|
248
|
-
if (str[ptr] === "\n")
|
|
249
|
-
ptr++;
|
|
250
|
-
}
|
|
251
|
-
let tmp = 0;
|
|
252
|
-
let isEscape;
|
|
253
|
-
let parsed = "";
|
|
254
|
-
let sliceStart = ptr;
|
|
255
|
-
while (ptr < endPtr - 1) {
|
|
256
|
-
let c = str[ptr++];
|
|
257
|
-
if (c === "\n" || c === "\r" && str[ptr] === "\n") {
|
|
258
|
-
if (!isMultiline) {
|
|
259
|
-
throw new TomlError("newlines are not allowed in strings", {
|
|
260
|
-
toml: str,
|
|
261
|
-
ptr: ptr - 1
|
|
262
|
-
});
|
|
263
|
-
}
|
|
264
|
-
} else if (c < " " && c !== " " || c === "\x7F") {
|
|
265
|
-
throw new TomlError("control characters are not allowed in strings", {
|
|
266
|
-
toml: str,
|
|
267
|
-
ptr: ptr - 1
|
|
268
|
-
});
|
|
269
|
-
}
|
|
270
|
-
if (isEscape) {
|
|
271
|
-
isEscape = false;
|
|
272
|
-
if (c === "x" || c === "u" || c === "U") {
|
|
273
|
-
let code = str.slice(ptr, ptr += c === "x" ? 2 : c === "u" ? 4 : 8);
|
|
274
|
-
if (!ESCAPE_REGEX.test(code)) {
|
|
275
|
-
throw new TomlError("invalid unicode escape", {
|
|
276
|
-
toml: str,
|
|
277
|
-
ptr: tmp
|
|
278
|
-
});
|
|
279
|
-
}
|
|
280
|
-
try {
|
|
281
|
-
parsed += String.fromCodePoint(parseInt(code, 16));
|
|
282
|
-
} catch {
|
|
283
|
-
throw new TomlError("invalid unicode escape", {
|
|
284
|
-
toml: str,
|
|
285
|
-
ptr: tmp
|
|
286
|
-
});
|
|
287
|
-
}
|
|
288
|
-
} else if (isMultiline && (c === "\n" || c === " " || c === " " || c === "\r")) {
|
|
289
|
-
ptr = skipVoid(str, ptr - 1, true);
|
|
290
|
-
if (str[ptr] !== "\n" && str[ptr] !== "\r") {
|
|
291
|
-
throw new TomlError("invalid escape: only line-ending whitespace may be escaped", {
|
|
292
|
-
toml: str,
|
|
293
|
-
ptr: tmp
|
|
294
|
-
});
|
|
295
|
-
}
|
|
296
|
-
ptr = skipVoid(str, ptr);
|
|
297
|
-
} else if (c in ESC_MAP) {
|
|
298
|
-
parsed += ESC_MAP[c];
|
|
299
|
-
} else {
|
|
300
|
-
throw new TomlError("unrecognized escape sequence", {
|
|
301
|
-
toml: str,
|
|
302
|
-
ptr: tmp
|
|
303
|
-
});
|
|
304
|
-
}
|
|
305
|
-
sliceStart = ptr;
|
|
306
|
-
} else if (!isLiteral && c === "\\") {
|
|
307
|
-
tmp = ptr - 1;
|
|
308
|
-
isEscape = true;
|
|
309
|
-
parsed += str.slice(sliceStart, tmp);
|
|
310
|
-
}
|
|
311
|
-
}
|
|
312
|
-
return parsed + str.slice(sliceStart, endPtr - 1);
|
|
313
|
-
}
|
|
314
|
-
function parseValue(value, toml, ptr, integersAsBigInt) {
|
|
315
|
-
if (value === "true")
|
|
316
|
-
return true;
|
|
317
|
-
if (value === "false")
|
|
318
|
-
return false;
|
|
319
|
-
if (value === "-inf")
|
|
320
|
-
return -Infinity;
|
|
321
|
-
if (value === "inf" || value === "+inf")
|
|
322
|
-
return Infinity;
|
|
323
|
-
if (value === "nan" || value === "+nan" || value === "-nan")
|
|
324
|
-
return NaN;
|
|
325
|
-
if (value === "-0")
|
|
326
|
-
return integersAsBigInt ? 0n : 0;
|
|
327
|
-
let isInt = INT_REGEX.test(value);
|
|
328
|
-
if (isInt || FLOAT_REGEX.test(value)) {
|
|
329
|
-
if (LEADING_ZERO.test(value)) {
|
|
330
|
-
throw new TomlError("leading zeroes are not allowed", {
|
|
331
|
-
toml,
|
|
332
|
-
ptr
|
|
333
|
-
});
|
|
334
|
-
}
|
|
335
|
-
value = value.replace(/_/g, "");
|
|
336
|
-
let numeric = +value;
|
|
337
|
-
if (isNaN(numeric)) {
|
|
338
|
-
throw new TomlError("invalid number", {
|
|
339
|
-
toml,
|
|
340
|
-
ptr
|
|
341
|
-
});
|
|
342
|
-
}
|
|
343
|
-
if (isInt) {
|
|
344
|
-
if ((isInt = !Number.isSafeInteger(numeric)) && !integersAsBigInt) {
|
|
345
|
-
throw new TomlError("integer value cannot be represented losslessly", {
|
|
346
|
-
toml,
|
|
347
|
-
ptr
|
|
348
|
-
});
|
|
349
|
-
}
|
|
350
|
-
if (isInt || integersAsBigInt === true)
|
|
351
|
-
numeric = BigInt(value);
|
|
352
|
-
}
|
|
353
|
-
return numeric;
|
|
354
|
-
}
|
|
355
|
-
const date = new TomlDate(value);
|
|
356
|
-
if (!date.isValid()) {
|
|
357
|
-
throw new TomlError("invalid value", {
|
|
358
|
-
toml,
|
|
359
|
-
ptr
|
|
360
|
-
});
|
|
361
|
-
}
|
|
362
|
-
return date;
|
|
363
|
-
}
|
|
364
|
-
|
|
365
|
-
// ../../node_modules/.pnpm/smol-toml@1.6.1/node_modules/smol-toml/dist/extract.js
|
|
366
|
-
function sliceAndTrimEndOf(str, startPtr, endPtr) {
|
|
367
|
-
let value = str.slice(startPtr, endPtr);
|
|
368
|
-
let commentIdx = value.indexOf("#");
|
|
369
|
-
if (commentIdx > -1) {
|
|
370
|
-
skipComment(str, commentIdx);
|
|
371
|
-
value = value.slice(0, commentIdx);
|
|
372
|
-
}
|
|
373
|
-
return [value.trimEnd(), commentIdx];
|
|
374
|
-
}
|
|
375
|
-
function extractValue(str, ptr, end, depth, integersAsBigInt) {
|
|
376
|
-
if (depth === 0) {
|
|
377
|
-
throw new TomlError("document contains excessively nested structures. aborting.", {
|
|
378
|
-
toml: str,
|
|
379
|
-
ptr
|
|
380
|
-
});
|
|
381
|
-
}
|
|
382
|
-
let c = str[ptr];
|
|
383
|
-
if (c === "[" || c === "{") {
|
|
384
|
-
let [value, endPtr2] = c === "[" ? parseArray(str, ptr, depth, integersAsBigInt) : parseInlineTable(str, ptr, depth, integersAsBigInt);
|
|
385
|
-
if (end) {
|
|
386
|
-
endPtr2 = skipVoid(str, endPtr2);
|
|
387
|
-
if (str[endPtr2] === ",")
|
|
388
|
-
endPtr2++;
|
|
389
|
-
else if (str[endPtr2] !== end) {
|
|
390
|
-
throw new TomlError("expected comma or end of structure", {
|
|
391
|
-
toml: str,
|
|
392
|
-
ptr: endPtr2
|
|
393
|
-
});
|
|
394
|
-
}
|
|
395
|
-
}
|
|
396
|
-
return [value, endPtr2];
|
|
397
|
-
}
|
|
398
|
-
let endPtr;
|
|
399
|
-
if (c === '"' || c === "'") {
|
|
400
|
-
endPtr = getStringEnd(str, ptr);
|
|
401
|
-
let parsed = parseString(str, ptr, endPtr);
|
|
402
|
-
if (end) {
|
|
403
|
-
endPtr = skipVoid(str, endPtr);
|
|
404
|
-
if (str[endPtr] && str[endPtr] !== "," && str[endPtr] !== end && str[endPtr] !== "\n" && str[endPtr] !== "\r") {
|
|
405
|
-
throw new TomlError("unexpected character encountered", {
|
|
406
|
-
toml: str,
|
|
407
|
-
ptr: endPtr
|
|
408
|
-
});
|
|
409
|
-
}
|
|
410
|
-
endPtr += +(str[endPtr] === ",");
|
|
411
|
-
}
|
|
412
|
-
return [parsed, endPtr];
|
|
413
|
-
}
|
|
414
|
-
endPtr = skipUntil(str, ptr, ",", end);
|
|
415
|
-
let slice = sliceAndTrimEndOf(str, ptr, endPtr - +(str[endPtr - 1] === ","));
|
|
416
|
-
if (!slice[0]) {
|
|
417
|
-
throw new TomlError("incomplete key-value declaration: no value specified", {
|
|
418
|
-
toml: str,
|
|
419
|
-
ptr
|
|
420
|
-
});
|
|
421
|
-
}
|
|
422
|
-
if (end && slice[1] > -1) {
|
|
423
|
-
endPtr = skipVoid(str, ptr + slice[1]);
|
|
424
|
-
endPtr += +(str[endPtr] === ",");
|
|
425
|
-
}
|
|
426
|
-
return [
|
|
427
|
-
parseValue(slice[0], str, ptr, integersAsBigInt),
|
|
428
|
-
endPtr
|
|
429
|
-
];
|
|
430
|
-
}
|
|
431
|
-
|
|
432
|
-
// ../../node_modules/.pnpm/smol-toml@1.6.1/node_modules/smol-toml/dist/struct.js
|
|
433
|
-
var KEY_PART_RE = /^[a-zA-Z0-9-_]+[ \t]*$/;
|
|
434
|
-
function parseKey(str, ptr, end = "=") {
|
|
435
|
-
let dot = ptr - 1;
|
|
436
|
-
let parsed = [];
|
|
437
|
-
let endPtr = str.indexOf(end, ptr);
|
|
438
|
-
if (endPtr < 0) {
|
|
439
|
-
throw new TomlError("incomplete key-value: cannot find end of key", {
|
|
440
|
-
toml: str,
|
|
441
|
-
ptr
|
|
442
|
-
});
|
|
443
|
-
}
|
|
444
|
-
do {
|
|
445
|
-
let c = str[ptr = ++dot];
|
|
446
|
-
if (c !== " " && c !== " ") {
|
|
447
|
-
if (c === '"' || c === "'") {
|
|
448
|
-
if (c === str[ptr + 1] && c === str[ptr + 2]) {
|
|
449
|
-
throw new TomlError("multiline strings are not allowed in keys", {
|
|
450
|
-
toml: str,
|
|
451
|
-
ptr
|
|
452
|
-
});
|
|
453
|
-
}
|
|
454
|
-
let eos = getStringEnd(str, ptr);
|
|
455
|
-
if (eos < 0) {
|
|
456
|
-
throw new TomlError("unfinished string encountered", {
|
|
457
|
-
toml: str,
|
|
458
|
-
ptr
|
|
459
|
-
});
|
|
460
|
-
}
|
|
461
|
-
dot = str.indexOf(".", eos);
|
|
462
|
-
let strEnd = str.slice(eos, dot < 0 || dot > endPtr ? endPtr : dot);
|
|
463
|
-
let newLine = indexOfNewline(strEnd);
|
|
464
|
-
if (newLine > -1) {
|
|
465
|
-
throw new TomlError("newlines are not allowed in keys", {
|
|
466
|
-
toml: str,
|
|
467
|
-
ptr: ptr + dot + newLine
|
|
468
|
-
});
|
|
469
|
-
}
|
|
470
|
-
if (strEnd.trimStart()) {
|
|
471
|
-
throw new TomlError("found extra tokens after the string part", {
|
|
472
|
-
toml: str,
|
|
473
|
-
ptr: eos
|
|
474
|
-
});
|
|
475
|
-
}
|
|
476
|
-
if (endPtr < eos) {
|
|
477
|
-
endPtr = str.indexOf(end, eos);
|
|
478
|
-
if (endPtr < 0) {
|
|
479
|
-
throw new TomlError("incomplete key-value: cannot find end of key", {
|
|
480
|
-
toml: str,
|
|
481
|
-
ptr
|
|
482
|
-
});
|
|
483
|
-
}
|
|
484
|
-
}
|
|
485
|
-
parsed.push(parseString(str, ptr, eos));
|
|
486
|
-
} else {
|
|
487
|
-
dot = str.indexOf(".", ptr);
|
|
488
|
-
let part = str.slice(ptr, dot < 0 || dot > endPtr ? endPtr : dot);
|
|
489
|
-
if (!KEY_PART_RE.test(part)) {
|
|
490
|
-
throw new TomlError("only letter, numbers, dashes and underscores are allowed in keys", {
|
|
491
|
-
toml: str,
|
|
492
|
-
ptr
|
|
493
|
-
});
|
|
494
|
-
}
|
|
495
|
-
parsed.push(part.trimEnd());
|
|
496
|
-
}
|
|
497
|
-
}
|
|
498
|
-
} while (dot + 1 && dot < endPtr);
|
|
499
|
-
return [parsed, skipVoid(str, endPtr + 1, true, true)];
|
|
500
|
-
}
|
|
501
|
-
function parseInlineTable(str, ptr, depth, integersAsBigInt) {
|
|
502
|
-
let res = {};
|
|
503
|
-
let seen = /* @__PURE__ */ new Set();
|
|
504
|
-
let c;
|
|
505
|
-
ptr++;
|
|
506
|
-
while ((c = str[ptr++]) !== "}" && c) {
|
|
507
|
-
if (c === ",") {
|
|
508
|
-
throw new TomlError("expected value, found comma", {
|
|
509
|
-
toml: str,
|
|
510
|
-
ptr: ptr - 1
|
|
511
|
-
});
|
|
512
|
-
} else if (c === "#")
|
|
513
|
-
ptr = skipComment(str, ptr);
|
|
514
|
-
else if (c !== " " && c !== " " && c !== "\n" && c !== "\r") {
|
|
515
|
-
let k;
|
|
516
|
-
let t = res;
|
|
517
|
-
let hasOwn = false;
|
|
518
|
-
let [key, keyEndPtr] = parseKey(str, ptr - 1);
|
|
519
|
-
for (let i = 0; i < key.length; i++) {
|
|
520
|
-
if (i)
|
|
521
|
-
t = hasOwn ? t[k] : t[k] = {};
|
|
522
|
-
k = key[i];
|
|
523
|
-
if ((hasOwn = Object.hasOwn(t, k)) && (typeof t[k] !== "object" || seen.has(t[k]))) {
|
|
524
|
-
throw new TomlError("trying to redefine an already defined value", {
|
|
525
|
-
toml: str,
|
|
526
|
-
ptr
|
|
527
|
-
});
|
|
528
|
-
}
|
|
529
|
-
if (!hasOwn && k === "__proto__") {
|
|
530
|
-
Object.defineProperty(t, k, { enumerable: true, configurable: true, writable: true });
|
|
531
|
-
}
|
|
532
|
-
}
|
|
533
|
-
if (hasOwn) {
|
|
534
|
-
throw new TomlError("trying to redefine an already defined value", {
|
|
535
|
-
toml: str,
|
|
536
|
-
ptr
|
|
537
|
-
});
|
|
538
|
-
}
|
|
539
|
-
let [value, valueEndPtr] = extractValue(str, keyEndPtr, "}", depth - 1, integersAsBigInt);
|
|
540
|
-
seen.add(value);
|
|
541
|
-
t[k] = value;
|
|
542
|
-
ptr = valueEndPtr;
|
|
543
|
-
}
|
|
544
|
-
}
|
|
545
|
-
if (!c) {
|
|
546
|
-
throw new TomlError("unfinished table encountered", {
|
|
547
|
-
toml: str,
|
|
548
|
-
ptr
|
|
549
|
-
});
|
|
550
|
-
}
|
|
551
|
-
return [res, ptr];
|
|
552
|
-
}
|
|
553
|
-
function parseArray(str, ptr, depth, integersAsBigInt) {
|
|
554
|
-
let res = [];
|
|
555
|
-
let c;
|
|
556
|
-
ptr++;
|
|
557
|
-
while ((c = str[ptr++]) !== "]" && c) {
|
|
558
|
-
if (c === ",") {
|
|
559
|
-
throw new TomlError("expected value, found comma", {
|
|
560
|
-
toml: str,
|
|
561
|
-
ptr: ptr - 1
|
|
562
|
-
});
|
|
563
|
-
} else if (c === "#")
|
|
564
|
-
ptr = skipComment(str, ptr);
|
|
565
|
-
else if (c !== " " && c !== " " && c !== "\n" && c !== "\r") {
|
|
566
|
-
let e = extractValue(str, ptr - 1, "]", depth - 1, integersAsBigInt);
|
|
567
|
-
res.push(e[0]);
|
|
568
|
-
ptr = e[1];
|
|
569
|
-
}
|
|
570
|
-
}
|
|
571
|
-
if (!c) {
|
|
572
|
-
throw new TomlError("unfinished array encountered", {
|
|
573
|
-
toml: str,
|
|
574
|
-
ptr
|
|
575
|
-
});
|
|
576
|
-
}
|
|
577
|
-
return [res, ptr];
|
|
578
|
-
}
|
|
579
|
-
|
|
580
|
-
// ../../node_modules/.pnpm/smol-toml@1.6.1/node_modules/smol-toml/dist/parse.js
|
|
581
|
-
function peekTable(key, table, meta, type) {
|
|
582
|
-
let t = table;
|
|
583
|
-
let m = meta;
|
|
584
|
-
let k;
|
|
585
|
-
let hasOwn = false;
|
|
586
|
-
let state;
|
|
587
|
-
for (let i = 0; i < key.length; i++) {
|
|
588
|
-
if (i) {
|
|
589
|
-
t = hasOwn ? t[k] : t[k] = {};
|
|
590
|
-
m = (state = m[k]).c;
|
|
591
|
-
if (type === 0 && (state.t === 1 || state.t === 2)) {
|
|
592
|
-
return null;
|
|
593
|
-
}
|
|
594
|
-
if (state.t === 2) {
|
|
595
|
-
let l = t.length - 1;
|
|
596
|
-
t = t[l];
|
|
597
|
-
m = m[l].c;
|
|
598
|
-
}
|
|
599
|
-
}
|
|
600
|
-
k = key[i];
|
|
601
|
-
if ((hasOwn = Object.hasOwn(t, k)) && m[k]?.t === 0 && m[k]?.d) {
|
|
602
|
-
return null;
|
|
603
|
-
}
|
|
604
|
-
if (!hasOwn) {
|
|
605
|
-
if (k === "__proto__") {
|
|
606
|
-
Object.defineProperty(t, k, { enumerable: true, configurable: true, writable: true });
|
|
607
|
-
Object.defineProperty(m, k, { enumerable: true, configurable: true, writable: true });
|
|
608
|
-
}
|
|
609
|
-
m[k] = {
|
|
610
|
-
t: i < key.length - 1 && type === 2 ? 3 : type,
|
|
611
|
-
d: false,
|
|
612
|
-
i: 0,
|
|
613
|
-
c: {}
|
|
614
|
-
};
|
|
615
|
-
}
|
|
616
|
-
}
|
|
617
|
-
state = m[k];
|
|
618
|
-
if (state.t !== type && !(type === 1 && state.t === 3)) {
|
|
619
|
-
return null;
|
|
620
|
-
}
|
|
621
|
-
if (type === 2) {
|
|
622
|
-
if (!state.d) {
|
|
623
|
-
state.d = true;
|
|
624
|
-
t[k] = [];
|
|
625
|
-
}
|
|
626
|
-
t[k].push(t = {});
|
|
627
|
-
state.c[state.i++] = state = { t: 1, d: false, i: 0, c: {} };
|
|
628
|
-
}
|
|
629
|
-
if (state.d) {
|
|
630
|
-
return null;
|
|
631
|
-
}
|
|
632
|
-
state.d = true;
|
|
633
|
-
if (type === 1) {
|
|
634
|
-
t = hasOwn ? t[k] : t[k] = {};
|
|
635
|
-
} else if (type === 0 && hasOwn) {
|
|
636
|
-
return null;
|
|
637
|
-
}
|
|
638
|
-
return [k, t, state.c];
|
|
639
|
-
}
|
|
640
|
-
function parse(toml, { maxDepth = 1e3, integersAsBigInt } = {}) {
|
|
641
|
-
let res = {};
|
|
642
|
-
let meta = {};
|
|
643
|
-
let tbl = res;
|
|
644
|
-
let m = meta;
|
|
645
|
-
for (let ptr = skipVoid(toml, 0); ptr < toml.length; ) {
|
|
646
|
-
if (toml[ptr] === "[") {
|
|
647
|
-
let isTableArray = toml[++ptr] === "[";
|
|
648
|
-
let k = parseKey(toml, ptr += +isTableArray, "]");
|
|
649
|
-
if (isTableArray) {
|
|
650
|
-
if (toml[k[1] - 1] !== "]") {
|
|
651
|
-
throw new TomlError("expected end of table declaration", {
|
|
652
|
-
toml,
|
|
653
|
-
ptr: k[1] - 1
|
|
654
|
-
});
|
|
655
|
-
}
|
|
656
|
-
k[1]++;
|
|
657
|
-
}
|
|
658
|
-
let p = peekTable(
|
|
659
|
-
k[0],
|
|
660
|
-
res,
|
|
661
|
-
meta,
|
|
662
|
-
isTableArray ? 2 : 1
|
|
663
|
-
/* Type.EXPLICIT */
|
|
664
|
-
);
|
|
665
|
-
if (!p) {
|
|
666
|
-
throw new TomlError("trying to redefine an already defined table or value", {
|
|
667
|
-
toml,
|
|
668
|
-
ptr
|
|
669
|
-
});
|
|
670
|
-
}
|
|
671
|
-
m = p[2];
|
|
672
|
-
tbl = p[1];
|
|
673
|
-
ptr = k[1];
|
|
674
|
-
} else {
|
|
675
|
-
let k = parseKey(toml, ptr);
|
|
676
|
-
let p = peekTable(
|
|
677
|
-
k[0],
|
|
678
|
-
tbl,
|
|
679
|
-
m,
|
|
680
|
-
0
|
|
681
|
-
/* Type.DOTTED */
|
|
682
|
-
);
|
|
683
|
-
if (!p) {
|
|
684
|
-
throw new TomlError("trying to redefine an already defined table or value", {
|
|
685
|
-
toml,
|
|
686
|
-
ptr
|
|
687
|
-
});
|
|
688
|
-
}
|
|
689
|
-
let v = extractValue(toml, k[1], void 0, maxDepth, integersAsBigInt);
|
|
690
|
-
p[1][p[0]] = v[0];
|
|
691
|
-
ptr = v[1];
|
|
692
|
-
}
|
|
693
|
-
ptr = skipVoid(toml, ptr, true);
|
|
694
|
-
if (toml[ptr] && toml[ptr] !== "\n" && toml[ptr] !== "\r") {
|
|
695
|
-
throw new TomlError("each key-value declaration must be followed by an end-of-line", {
|
|
696
|
-
toml,
|
|
697
|
-
ptr
|
|
698
|
-
});
|
|
699
|
-
}
|
|
700
|
-
ptr = skipVoid(toml, ptr);
|
|
701
|
-
}
|
|
702
|
-
return res;
|
|
703
|
-
}
|
|
704
|
-
|
|
705
|
-
// ../../node_modules/.pnpm/smol-toml@1.6.1/node_modules/smol-toml/dist/stringify.js
|
|
706
|
-
var BARE_KEY = /^[a-z0-9-_]+$/i;
|
|
707
|
-
function extendedTypeOf(obj) {
|
|
708
|
-
let type = typeof obj;
|
|
709
|
-
if (type === "object") {
|
|
710
|
-
if (Array.isArray(obj))
|
|
711
|
-
return "array";
|
|
712
|
-
if (obj instanceof Date)
|
|
713
|
-
return "date";
|
|
714
|
-
}
|
|
715
|
-
return type;
|
|
716
|
-
}
|
|
717
|
-
function isArrayOfTables(obj) {
|
|
718
|
-
for (let i = 0; i < obj.length; i++) {
|
|
719
|
-
if (extendedTypeOf(obj[i]) !== "object")
|
|
720
|
-
return false;
|
|
721
|
-
}
|
|
722
|
-
return obj.length != 0;
|
|
723
|
-
}
|
|
724
|
-
function formatString(s) {
|
|
725
|
-
return JSON.stringify(s).replace(/\x7f/g, "\\u007f");
|
|
726
|
-
}
|
|
727
|
-
function stringifyValue(val, type, depth, numberAsFloat) {
|
|
728
|
-
if (depth === 0) {
|
|
729
|
-
throw new Error("Could not stringify the object: maximum object depth exceeded");
|
|
730
|
-
}
|
|
731
|
-
if (type === "number") {
|
|
732
|
-
if (isNaN(val))
|
|
733
|
-
return "nan";
|
|
734
|
-
if (val === Infinity)
|
|
735
|
-
return "inf";
|
|
736
|
-
if (val === -Infinity)
|
|
737
|
-
return "-inf";
|
|
738
|
-
if (numberAsFloat && Number.isInteger(val))
|
|
739
|
-
return val.toFixed(1);
|
|
740
|
-
return val.toString();
|
|
741
|
-
}
|
|
742
|
-
if (type === "bigint" || type === "boolean") {
|
|
743
|
-
return val.toString();
|
|
744
|
-
}
|
|
745
|
-
if (type === "string") {
|
|
746
|
-
return formatString(val);
|
|
747
|
-
}
|
|
748
|
-
if (type === "date") {
|
|
749
|
-
if (isNaN(val.getTime())) {
|
|
750
|
-
throw new TypeError("cannot serialize invalid date");
|
|
751
|
-
}
|
|
752
|
-
return val.toISOString();
|
|
753
|
-
}
|
|
754
|
-
if (type === "object") {
|
|
755
|
-
return stringifyInlineTable(val, depth, numberAsFloat);
|
|
756
|
-
}
|
|
757
|
-
if (type === "array") {
|
|
758
|
-
return stringifyArray(val, depth, numberAsFloat);
|
|
759
|
-
}
|
|
760
|
-
}
|
|
761
|
-
function stringifyInlineTable(obj, depth, numberAsFloat) {
|
|
762
|
-
let keys = Object.keys(obj);
|
|
763
|
-
if (keys.length === 0)
|
|
764
|
-
return "{}";
|
|
765
|
-
let res = "{ ";
|
|
766
|
-
for (let i = 0; i < keys.length; i++) {
|
|
767
|
-
let k = keys[i];
|
|
768
|
-
if (i)
|
|
769
|
-
res += ", ";
|
|
770
|
-
res += BARE_KEY.test(k) ? k : formatString(k);
|
|
771
|
-
res += " = ";
|
|
772
|
-
res += stringifyValue(obj[k], extendedTypeOf(obj[k]), depth - 1, numberAsFloat);
|
|
773
|
-
}
|
|
774
|
-
return res + " }";
|
|
775
|
-
}
|
|
776
|
-
function stringifyArray(array, depth, numberAsFloat) {
|
|
777
|
-
if (array.length === 0)
|
|
778
|
-
return "[]";
|
|
779
|
-
let res = "[ ";
|
|
780
|
-
for (let i = 0; i < array.length; i++) {
|
|
781
|
-
if (i)
|
|
782
|
-
res += ", ";
|
|
783
|
-
if (array[i] === null || array[i] === void 0) {
|
|
784
|
-
throw new TypeError("arrays cannot contain null or undefined values");
|
|
785
|
-
}
|
|
786
|
-
res += stringifyValue(array[i], extendedTypeOf(array[i]), depth - 1, numberAsFloat);
|
|
787
|
-
}
|
|
788
|
-
return res + " ]";
|
|
789
|
-
}
|
|
790
|
-
function stringifyArrayTable(array, key, depth, numberAsFloat) {
|
|
791
|
-
if (depth === 0) {
|
|
792
|
-
throw new Error("Could not stringify the object: maximum object depth exceeded");
|
|
793
|
-
}
|
|
794
|
-
let res = "";
|
|
795
|
-
for (let i = 0; i < array.length; i++) {
|
|
796
|
-
res += `${res && "\n"}[[${key}]]
|
|
797
|
-
`;
|
|
798
|
-
res += stringifyTable(0, array[i], key, depth, numberAsFloat);
|
|
799
|
-
}
|
|
800
|
-
return res;
|
|
801
|
-
}
|
|
802
|
-
function stringifyTable(tableKey, obj, prefix, depth, numberAsFloat) {
|
|
803
|
-
if (depth === 0) {
|
|
804
|
-
throw new Error("Could not stringify the object: maximum object depth exceeded");
|
|
805
|
-
}
|
|
806
|
-
let preamble = "";
|
|
807
|
-
let tables = "";
|
|
808
|
-
let keys = Object.keys(obj);
|
|
809
|
-
for (let i = 0; i < keys.length; i++) {
|
|
810
|
-
let k = keys[i];
|
|
811
|
-
if (obj[k] !== null && obj[k] !== void 0) {
|
|
812
|
-
let type = extendedTypeOf(obj[k]);
|
|
813
|
-
if (type === "symbol" || type === "function") {
|
|
814
|
-
throw new TypeError(`cannot serialize values of type '${type}'`);
|
|
815
|
-
}
|
|
816
|
-
let key = BARE_KEY.test(k) ? k : formatString(k);
|
|
817
|
-
if (type === "array" && isArrayOfTables(obj[k])) {
|
|
818
|
-
tables += (tables && "\n") + stringifyArrayTable(obj[k], prefix ? `${prefix}.${key}` : key, depth - 1, numberAsFloat);
|
|
819
|
-
} else if (type === "object") {
|
|
820
|
-
let tblKey = prefix ? `${prefix}.${key}` : key;
|
|
821
|
-
tables += (tables && "\n") + stringifyTable(tblKey, obj[k], tblKey, depth - 1, numberAsFloat);
|
|
822
|
-
} else {
|
|
823
|
-
preamble += key;
|
|
824
|
-
preamble += " = ";
|
|
825
|
-
preamble += stringifyValue(obj[k], type, depth, numberAsFloat);
|
|
826
|
-
preamble += "\n";
|
|
827
|
-
}
|
|
828
|
-
}
|
|
829
|
-
}
|
|
830
|
-
if (tableKey && (preamble || !tables))
|
|
831
|
-
preamble = preamble ? `[${tableKey}]
|
|
832
|
-
${preamble}` : `[${tableKey}]`;
|
|
833
|
-
return preamble && tables ? `${preamble}
|
|
834
|
-
${tables}` : preamble || tables;
|
|
835
|
-
}
|
|
836
|
-
function stringify(obj, { maxDepth = 1e3, numbersAsFloat = false } = {}) {
|
|
837
|
-
if (extendedTypeOf(obj) !== "object") {
|
|
838
|
-
throw new TypeError("stringify can only be called with an object");
|
|
839
|
-
}
|
|
840
|
-
let str = stringifyTable(0, obj, "", maxDepth, numbersAsFloat);
|
|
841
|
-
if (str[str.length - 1] !== "\n")
|
|
842
|
-
return str + "\n";
|
|
843
|
-
return str;
|
|
844
|
-
}
|
|
845
|
-
|
|
846
|
-
// ../core/dist/index.js
|
|
847
|
-
import { mkdirSync as mkdirSync2, appendFileSync } from "fs";
|
|
848
|
-
import { homedir as homedir3 } from "os";
|
|
849
|
-
import { join as join3 } from "path";
|
|
850
|
-
import { existsSync as existsSync3, mkdirSync as mkdirSync3, readFileSync as readFileSync2, writeFileSync as writeFileSync2 } from "fs";
|
|
851
|
-
import { homedir as homedir4 } from "os";
|
|
852
|
-
import { join as join4 } from "path";
|
|
13
|
+
import { join as join2 } from "path";
|
|
853
14
|
import * as fs2 from "fs";
|
|
854
15
|
import * as path2 from "path";
|
|
855
16
|
import * as os2 from "os";
|
|
@@ -1745,14 +906,14 @@ function registerTradeTools() {
|
|
|
1745
906
|
{
|
|
1746
907
|
name: "trade_get_order",
|
|
1747
908
|
module: "trade",
|
|
1748
|
-
description:
|
|
909
|
+
description: '\uAC1C\uBCC4(\uB2E8\uAC74) \uC8FC\uBB38\uC744 \uC870\uD68C\uD569\uB2C8\uB2E4. Get a SINGLE order by order_id or client_order_id. Use when: you have exactly one order identifier. Do NOT use: for multiple orders at once \u2014 do NOT call this repeatedly. Pass all identifiers to trade_get_orders (order_ids/client_order_ids arrays) in a single call instead. Example call: {"order_id":"C0101..."}',
|
|
1749
910
|
isWrite: false,
|
|
1750
911
|
inputSchema: {
|
|
1751
912
|
type: "object",
|
|
1752
913
|
properties: {
|
|
1753
|
-
|
|
914
|
+
order_id: {
|
|
1754
915
|
type: "string",
|
|
1755
|
-
description: "Order
|
|
916
|
+
description: "Order ID"
|
|
1756
917
|
},
|
|
1757
918
|
client_order_id: {
|
|
1758
919
|
type: "string",
|
|
@@ -1766,7 +927,7 @@ function registerTradeTools() {
|
|
|
1766
927
|
const response = await context.client.privateGet(
|
|
1767
928
|
"/v1/order",
|
|
1768
929
|
compactObject({
|
|
1769
|
-
uuid: readString(args, "
|
|
930
|
+
uuid: readString(args, "order_id"),
|
|
1770
931
|
client_order_id: readString(args, "client_order_id")
|
|
1771
932
|
}),
|
|
1772
933
|
privateRateLimit("trade_get_order")
|
|
@@ -1778,7 +939,7 @@ function registerTradeTools() {
|
|
|
1778
939
|
{
|
|
1779
940
|
name: "trade_get_orders",
|
|
1780
941
|
module: "trade",
|
|
1781
|
-
description:
|
|
942
|
+
description: '\uC8FC\uBB38 \uB9AC\uC2A4\uD2B8/\uBCF5\uC218 \uC8FC\uBB38\uC744 \uC870\uD68C\uD569\uB2C8\uB2E4. Get orders \u2014 fetch MULTIPLE specific orders in one call via order_ids/client_order_ids (arrays), or list by market/state filters. Use when: the user gives two or more order numbers, or wants a filtered list. Do NOT use trade_get_order repeatedly for multiple ids \u2014 pass them all here in one call. Note: the server defaults to state=wait when omitted, so to fetch done/cancel orders (e.g. by order_ids) set states explicitly, e.g. states=["wait","done","cancel"]. The auto-order state (watch) CANNOT be mixed with general states (wait/done/cancel); query it separately with state=watch. state and states cannot be used together. Example call: {"order_ids":["C0101...","C0102..."],"states":["wait","done","cancel"]}',
|
|
1782
943
|
isWrite: false,
|
|
1783
944
|
inputSchema: {
|
|
1784
945
|
type: "object",
|
|
@@ -1795,12 +956,12 @@ function registerTradeTools() {
|
|
|
1795
956
|
states: {
|
|
1796
957
|
type: "array",
|
|
1797
958
|
items: { type: "string" },
|
|
1798
|
-
description:
|
|
959
|
+
description: 'Multiple order state filters. Constraints: general states (wait/done/cancel) and the auto-order state (watch) CANNOT be mixed in one query; state and states cannot be used together. If omitted, the server defaults to state=wait \u2014 pass states=["wait","done","cancel"] to include done/cancel orders.'
|
|
1799
960
|
},
|
|
1800
|
-
|
|
961
|
+
order_ids: {
|
|
1801
962
|
type: "array",
|
|
1802
963
|
items: { type: "string" },
|
|
1803
|
-
description: "
|
|
964
|
+
description: "Fetch multiple specific orders by order ID in one call (batch lookup). Pass all order IDs here instead of calling trade_get_order repeatedly."
|
|
1804
965
|
},
|
|
1805
966
|
client_order_ids: {
|
|
1806
967
|
type: "array",
|
|
@@ -1830,7 +991,7 @@ function registerTradeTools() {
|
|
|
1830
991
|
market: readString(args, "market"),
|
|
1831
992
|
state: readString(args, "state"),
|
|
1832
993
|
states: readStringArray(args, "states"),
|
|
1833
|
-
uuids: readStringArray(args, "
|
|
994
|
+
uuids: readStringArray(args, "order_ids"),
|
|
1834
995
|
client_order_ids: readStringArray(args, "client_order_ids"),
|
|
1835
996
|
page: readNumber(args, "page"),
|
|
1836
997
|
limit: readNumber(args, "limit"),
|
|
@@ -2142,27 +1303,11 @@ async function checkApiReachability(baseUrl) {
|
|
|
2142
1303
|
};
|
|
2143
1304
|
}
|
|
2144
1305
|
}
|
|
2145
|
-
function checkAuthentication() {
|
|
2146
|
-
|
|
2147
|
-
|
|
2148
|
-
if (accessKey && secretKey) {
|
|
2149
|
-
return { name: "Authentication", status: "pass", message: "API keys configured via environment variables" };
|
|
2150
|
-
}
|
|
2151
|
-
const tomlPath = join(homedir(), ".bithumb", "config.toml");
|
|
2152
|
-
if (existsSync(tomlPath)) {
|
|
2153
|
-
return { name: "Authentication", status: "pass", message: "config.toml found (credentials may be in profile)" };
|
|
2154
|
-
}
|
|
2155
|
-
if (accessKey || secretKey) {
|
|
2156
|
-
return { name: "Authentication", status: "fail", message: "Partial credentials: set both BITHUMB_ACCESS_KEY and BITHUMB_SECRET_KEY" };
|
|
2157
|
-
}
|
|
2158
|
-
return { name: "Authentication", status: "fail", message: "No credentials found (set env vars or create ~/.bithumb/config.toml)" };
|
|
2159
|
-
}
|
|
2160
|
-
function checkTomlConfig() {
|
|
2161
|
-
const tomlPath = join(homedir(), ".bithumb", "config.toml");
|
|
2162
|
-
if (existsSync(tomlPath)) {
|
|
2163
|
-
return { name: "TOML Config", status: "pass", message: `Found ${tomlPath}` };
|
|
1306
|
+
function checkAuthentication(hasAuth) {
|
|
1307
|
+
if (hasAuth) {
|
|
1308
|
+
return { name: "Authentication", status: "pass", message: "API keys configured (--access-key/--secret-key flags or BITHUMB_ACCESS_KEY/BITHUMB_SECRET_KEY env vars)" };
|
|
2164
1309
|
}
|
|
2165
|
-
return { name: "
|
|
1310
|
+
return { name: "Authentication", status: "fail", message: "No credentials found. Set --access-key/--secret-key flags or BITHUMB_ACCESS_KEY/BITHUMB_SECRET_KEY env vars." };
|
|
2166
1311
|
}
|
|
2167
1312
|
function checkModules(enabledModules) {
|
|
2168
1313
|
return {
|
|
@@ -2209,7 +1354,7 @@ function registerDiagnoseTools() {
|
|
|
2209
1354
|
{
|
|
2210
1355
|
name: "system_diagnose",
|
|
2211
1356
|
module: "system",
|
|
2212
|
-
description: "Run diagnostic checks on the Bithumb Trade Kit configuration. Checks API reachability, authentication,
|
|
1357
|
+
description: "Run diagnostic checks on the Bithumb Trade Kit configuration. Checks API reachability, authentication, and module status.",
|
|
2213
1358
|
isWrite: false,
|
|
2214
1359
|
inputSchema: {
|
|
2215
1360
|
type: "object",
|
|
@@ -2218,10 +1363,10 @@ function registerDiagnoseTools() {
|
|
|
2218
1363
|
handler: async (_args, context) => {
|
|
2219
1364
|
const baseUrl = context?.config?.baseUrl ?? BITHUMB_API_BASE_URL;
|
|
2220
1365
|
const modules = context?.config?.modules ?? [];
|
|
1366
|
+
const hasAuth = context?.config?.hasAuth ?? false;
|
|
2221
1367
|
const checks = [];
|
|
2222
1368
|
checks.push(await checkApiReachability(baseUrl));
|
|
2223
|
-
checks.push(checkAuthentication());
|
|
2224
|
-
checks.push(checkTomlConfig());
|
|
1369
|
+
checks.push(checkAuthentication(hasAuth));
|
|
2225
1370
|
checks.push(checkModules(modules));
|
|
2226
1371
|
const passed = checks.filter((c) => c.status === "pass").length;
|
|
2227
1372
|
const total = checks.length;
|
|
@@ -2263,7 +1408,7 @@ function registerTwapTools() {
|
|
|
2263
1408
|
},
|
|
2264
1409
|
frequency: {
|
|
2265
1410
|
type: "string",
|
|
2266
|
-
enum: ["
|
|
1411
|
+
enum: ["15", "20", "30", "60", "120"],
|
|
2267
1412
|
description: "\uC8FC\uBB38 \uAC04\uACA9(\uCD08)"
|
|
2268
1413
|
},
|
|
2269
1414
|
volume: {
|
|
@@ -2307,7 +1452,7 @@ function registerTwapTools() {
|
|
|
2307
1452
|
type: "string",
|
|
2308
1453
|
description: "\uAC70\uB798 \uB300\uC0C1 \uD398\uC5B4\uC758 \uACE0\uC720 \uC2EC\uBCFC (\uC608\uC2DC: KRW-BTC)"
|
|
2309
1454
|
},
|
|
2310
|
-
|
|
1455
|
+
order_ids: {
|
|
2311
1456
|
type: "array",
|
|
2312
1457
|
items: { type: "string" },
|
|
2313
1458
|
description: "TWAP \uC8FC\uBB38 ID \uBAA9\uB85D"
|
|
@@ -2339,7 +1484,7 @@ function registerTwapTools() {
|
|
|
2339
1484
|
"/v1/twap",
|
|
2340
1485
|
compactObject({
|
|
2341
1486
|
market: readString(args, "market"),
|
|
2342
|
-
uuids: readStringArray(args, "
|
|
1487
|
+
uuids: readStringArray(args, "order_ids"),
|
|
2343
1488
|
state: readString(args, "state"),
|
|
2344
1489
|
next_key: readString(args, "next_key"),
|
|
2345
1490
|
limit: readNumber(args, "limit"),
|
|
@@ -2427,7 +1572,7 @@ function registerWithdrawTools() {
|
|
|
2427
1572
|
type: "string",
|
|
2428
1573
|
description: "Currency symbol, e.g. BTC"
|
|
2429
1574
|
},
|
|
2430
|
-
|
|
1575
|
+
withdrawal_id: {
|
|
2431
1576
|
type: "string",
|
|
2432
1577
|
description: "Withdrawal unique ID"
|
|
2433
1578
|
},
|
|
@@ -2444,7 +1589,7 @@ function registerWithdrawTools() {
|
|
|
2444
1589
|
"/v1/withdraw",
|
|
2445
1590
|
compactObject({
|
|
2446
1591
|
currency: requireString(args, "currency"),
|
|
2447
|
-
uuid: readString(args, "
|
|
1592
|
+
uuid: readString(args, "withdrawal_id"),
|
|
2448
1593
|
txid: readString(args, "txid")
|
|
2449
1594
|
}),
|
|
2450
1595
|
privateRateLimit("withdraw_get")
|
|
@@ -2470,10 +1615,10 @@ function registerWithdrawTools() {
|
|
|
2470
1615
|
enum: ["PROCESSING", "DONE", "CANCELED"],
|
|
2471
1616
|
description: "Withdrawal state filter"
|
|
2472
1617
|
},
|
|
2473
|
-
|
|
1618
|
+
withdrawal_ids: {
|
|
2474
1619
|
type: "array",
|
|
2475
1620
|
items: { type: "string" },
|
|
2476
|
-
description: "Filter by withdrawal
|
|
1621
|
+
description: "Filter by withdrawal IDs"
|
|
2477
1622
|
},
|
|
2478
1623
|
txids: {
|
|
2479
1624
|
type: "array",
|
|
@@ -2503,7 +1648,7 @@ function registerWithdrawTools() {
|
|
|
2503
1648
|
compactObject({
|
|
2504
1649
|
currency: readString(args, "currency"),
|
|
2505
1650
|
state: readString(args, "state"),
|
|
2506
|
-
uuids: readStringArray(args, "
|
|
1651
|
+
uuids: readStringArray(args, "withdrawal_ids"),
|
|
2507
1652
|
txids: readStringArray(args, "txids"),
|
|
2508
1653
|
limit: readNumber(args, "limit"),
|
|
2509
1654
|
page: readNumber(args, "page"),
|
|
@@ -2528,10 +1673,10 @@ function registerWithdrawTools() {
|
|
|
2528
1673
|
enum: ["PROCESSING", "DONE", "CANCELED"],
|
|
2529
1674
|
description: "Withdrawal state filter"
|
|
2530
1675
|
},
|
|
2531
|
-
|
|
1676
|
+
withdrawal_ids: {
|
|
2532
1677
|
type: "array",
|
|
2533
1678
|
items: { type: "string" },
|
|
2534
|
-
description: "Filter by withdrawal
|
|
1679
|
+
description: "Filter by withdrawal IDs"
|
|
2535
1680
|
},
|
|
2536
1681
|
txids: {
|
|
2537
1682
|
type: "array",
|
|
@@ -2560,7 +1705,7 @@ function registerWithdrawTools() {
|
|
|
2560
1705
|
"/v1/withdraws/krw",
|
|
2561
1706
|
compactObject({
|
|
2562
1707
|
state: readString(args, "state"),
|
|
2563
|
-
uuids: readStringArray(args, "
|
|
1708
|
+
uuids: readStringArray(args, "withdrawal_ids"),
|
|
2564
1709
|
txids: readStringArray(args, "txids"),
|
|
2565
1710
|
limit: readNumber(args, "limit"),
|
|
2566
1711
|
page: readNumber(args, "page"),
|
|
@@ -2739,7 +1884,7 @@ function registerDepositTools() {
|
|
|
2739
1884
|
{
|
|
2740
1885
|
name: "deposit_get",
|
|
2741
1886
|
module: "deposit",
|
|
2742
|
-
description: '\uAC1C\uBCC4 \uC785\uAE08\uC744 \uC870\uD68C\uD569\uB2C8\uB2E4. Get a single deposit by currency +
|
|
1887
|
+
description: '\uAC1C\uBCC4 \uC785\uAE08\uC744 \uC870\uD68C\uD569\uB2C8\uB2E4. Get a single deposit by currency + deposit_id (or single txid). Use when: you have a specific deposit_id and want the full record. Do NOT use: to search by txid list \u2014 use deposit_get_list with txids (array) instead. Example call: {"currency":"BTC","deposit_id":"12345678-...."}',
|
|
2743
1888
|
isWrite: false,
|
|
2744
1889
|
inputSchema: {
|
|
2745
1890
|
type: "object",
|
|
@@ -2748,9 +1893,9 @@ function registerDepositTools() {
|
|
|
2748
1893
|
type: "string",
|
|
2749
1894
|
description: "Currency symbol, e.g. BTC"
|
|
2750
1895
|
},
|
|
2751
|
-
|
|
1896
|
+
deposit_id: {
|
|
2752
1897
|
type: "string",
|
|
2753
|
-
description: "Deposit
|
|
1898
|
+
description: "Deposit ID"
|
|
2754
1899
|
},
|
|
2755
1900
|
txid: {
|
|
2756
1901
|
type: "string",
|
|
@@ -2765,7 +1910,7 @@ function registerDepositTools() {
|
|
|
2765
1910
|
"/v1/deposit",
|
|
2766
1911
|
compactObject({
|
|
2767
1912
|
currency: requireString(args, "currency"),
|
|
2768
|
-
uuid: readString(args, "
|
|
1913
|
+
uuid: readString(args, "deposit_id"),
|
|
2769
1914
|
txid: readString(args, "txid")
|
|
2770
1915
|
}),
|
|
2771
1916
|
privateRateLimit("deposit_get")
|
|
@@ -2790,10 +1935,10 @@ function registerDepositTools() {
|
|
|
2790
1935
|
type: "string",
|
|
2791
1936
|
description: "Deposit state filter"
|
|
2792
1937
|
},
|
|
2793
|
-
|
|
1938
|
+
deposit_ids: {
|
|
2794
1939
|
type: "array",
|
|
2795
1940
|
items: { type: "string" },
|
|
2796
|
-
description: "Filter by deposit
|
|
1941
|
+
description: "Filter by deposit IDs"
|
|
2797
1942
|
},
|
|
2798
1943
|
txids: {
|
|
2799
1944
|
type: "array",
|
|
@@ -2822,7 +1967,7 @@ function registerDepositTools() {
|
|
|
2822
1967
|
compactObject({
|
|
2823
1968
|
currency: readString(args, "currency"),
|
|
2824
1969
|
state: readString(args, "state"),
|
|
2825
|
-
uuids: readStringArray(args, "
|
|
1970
|
+
uuids: readStringArray(args, "deposit_ids"),
|
|
2826
1971
|
txids: readStringArray(args, "txids"),
|
|
2827
1972
|
limit: readNumber(args, "limit"),
|
|
2828
1973
|
page: readNumber(args, "page"),
|
|
@@ -2846,10 +1991,10 @@ function registerDepositTools() {
|
|
|
2846
1991
|
type: "string",
|
|
2847
1992
|
description: "Deposit state: PROCESSING, ACCEPTED, CANCELED"
|
|
2848
1993
|
},
|
|
2849
|
-
|
|
1994
|
+
deposit_ids: {
|
|
2850
1995
|
type: "array",
|
|
2851
1996
|
items: { type: "string" },
|
|
2852
|
-
description: "Filter by deposit
|
|
1997
|
+
description: "Filter by deposit IDs"
|
|
2853
1998
|
},
|
|
2854
1999
|
txids: {
|
|
2855
2000
|
type: "array",
|
|
@@ -2877,7 +2022,7 @@ function registerDepositTools() {
|
|
|
2877
2022
|
"/v1/deposits/krw",
|
|
2878
2023
|
compactObject({
|
|
2879
2024
|
state: readString(args, "state"),
|
|
2880
|
-
uuids: readStringArray(args, "
|
|
2025
|
+
uuids: readStringArray(args, "deposit_ids"),
|
|
2881
2026
|
txids: readStringArray(args, "txids"),
|
|
2882
2027
|
limit: readNumber(args, "limit"),
|
|
2883
2028
|
page: readNumber(args, "page"),
|
|
@@ -3032,50 +2177,19 @@ function createToolRunner(client, config) {
|
|
|
3032
2177
|
return await tool.handler(args, { config, client });
|
|
3033
2178
|
};
|
|
3034
2179
|
}
|
|
3035
|
-
function configFilePath() {
|
|
3036
|
-
return join2(homedir2(), ".bithumb", "config.toml");
|
|
3037
|
-
}
|
|
3038
|
-
function readFullConfig() {
|
|
3039
|
-
const path3 = configFilePath();
|
|
3040
|
-
if (!existsSync2(path3)) return { profiles: {} };
|
|
3041
|
-
const raw = readFileSync(path3, "utf-8");
|
|
3042
|
-
try {
|
|
3043
|
-
return parse(raw);
|
|
3044
|
-
} catch (err) {
|
|
3045
|
-
throw new ConfigError(
|
|
3046
|
-
`Failed to parse ${path3}: ${err instanceof Error ? err.message : String(err)}`,
|
|
3047
|
-
"Check TOML syntax in your config file, or delete and re-create it."
|
|
3048
|
-
);
|
|
3049
|
-
}
|
|
3050
|
-
}
|
|
3051
|
-
function readTomlProfile(profileName) {
|
|
3052
|
-
const config = readFullConfig();
|
|
3053
|
-
const name = profileName ?? config.default_profile ?? "default";
|
|
3054
|
-
return config.profiles?.[name] ?? {};
|
|
3055
|
-
}
|
|
3056
|
-
var CONFIG_HEADER = "# Bithumb Trade Kit Configuration\n# Wrap values containing special chars in quotes\n\n";
|
|
3057
|
-
function writeFullConfig(config) {
|
|
3058
|
-
const path3 = configFilePath();
|
|
3059
|
-
const dir = dirname(path3);
|
|
3060
|
-
if (!existsSync2(dir)) {
|
|
3061
|
-
mkdirSync(dir, { recursive: true });
|
|
3062
|
-
}
|
|
3063
|
-
writeFileSync(path3, CONFIG_HEADER + stringify(config), "utf-8");
|
|
3064
|
-
}
|
|
3065
2180
|
function loadConfig(options) {
|
|
3066
|
-
const
|
|
3067
|
-
const
|
|
3068
|
-
const secretKey = process.env.BITHUMB_SECRET_KEY?.trim() ?? toml.secret_key;
|
|
2181
|
+
const accessKey = options?.accessKey?.trim() || process.env.BITHUMB_ACCESS_KEY?.trim();
|
|
2182
|
+
const secretKey = options?.secretKey?.trim() || process.env.BITHUMB_SECRET_KEY?.trim();
|
|
3069
2183
|
const hasAuth = Boolean(accessKey && secretKey);
|
|
3070
2184
|
const partialAuth = Boolean(accessKey) || Boolean(secretKey);
|
|
3071
2185
|
if (partialAuth && !hasAuth) {
|
|
3072
2186
|
throw new ConfigError(
|
|
3073
2187
|
"Partial API credentials.",
|
|
3074
|
-
"Set both
|
|
2188
|
+
"Set both access and secret keys via --access-key/--secret-key flags or BITHUMB_ACCESS_KEY/BITHUMB_SECRET_KEY env vars."
|
|
3075
2189
|
);
|
|
3076
2190
|
}
|
|
3077
|
-
const baseUrl = (process.env.BITHUMB_API_BASE_URL?.trim() ??
|
|
3078
|
-
const rawTimeout = process.env.BITHUMB_TIMEOUT_MS ? Number(process.env.BITHUMB_TIMEOUT_MS) :
|
|
2191
|
+
const baseUrl = (process.env.BITHUMB_API_BASE_URL?.trim() ?? BITHUMB_API_BASE_URL).replace(/\/+$/, "");
|
|
2192
|
+
const rawTimeout = process.env.BITHUMB_TIMEOUT_MS ? Number(process.env.BITHUMB_TIMEOUT_MS) : 15e3;
|
|
3079
2193
|
if (!Number.isFinite(rawTimeout) || rawTimeout <= 0) {
|
|
3080
2194
|
throw new ConfigError(
|
|
3081
2195
|
"Invalid timeout.",
|
|
@@ -3146,18 +2260,21 @@ var TradeLogger = class {
|
|
|
3146
2260
|
logDir;
|
|
3147
2261
|
minLevel;
|
|
3148
2262
|
verbose;
|
|
2263
|
+
emitToStderr;
|
|
3149
2264
|
constructor(minLevelOrOptions) {
|
|
3150
2265
|
if (typeof minLevelOrOptions === "string") {
|
|
3151
|
-
this.logDir =
|
|
2266
|
+
this.logDir = join(homedir(), ".bithumb", "logs");
|
|
3152
2267
|
this.minLevel = minLevelOrOptions;
|
|
3153
2268
|
this.verbose = false;
|
|
2269
|
+
this.emitToStderr = true;
|
|
3154
2270
|
} else {
|
|
3155
|
-
this.logDir = minLevelOrOptions?.logDir ??
|
|
2271
|
+
this.logDir = minLevelOrOptions?.logDir ?? join(homedir(), ".bithumb", "logs");
|
|
3156
2272
|
this.minLevel = minLevelOrOptions?.minLevel ?? "info";
|
|
3157
2273
|
this.verbose = minLevelOrOptions?.verbose ?? false;
|
|
2274
|
+
this.emitToStderr = minLevelOrOptions?.emitToStderr ?? true;
|
|
3158
2275
|
}
|
|
3159
2276
|
try {
|
|
3160
|
-
|
|
2277
|
+
mkdirSync(this.logDir, { recursive: true });
|
|
3161
2278
|
} catch {
|
|
3162
2279
|
}
|
|
3163
2280
|
}
|
|
@@ -3190,24 +2307,24 @@ var TradeLogger = class {
|
|
|
3190
2307
|
...meta ? redactSensitive(meta) : {}
|
|
3191
2308
|
};
|
|
3192
2309
|
const line = JSON.stringify(entry);
|
|
3193
|
-
if (this.verbose || level === "error") {
|
|
2310
|
+
if (this.emitToStderr && (this.verbose || level === "error")) {
|
|
3194
2311
|
process.stderr.write(`[${level}] ${message}
|
|
3195
2312
|
`);
|
|
3196
2313
|
}
|
|
3197
2314
|
try {
|
|
3198
|
-
const filePath =
|
|
2315
|
+
const filePath = join(this.logDir, `trade-${todayDateString()}.log`);
|
|
3199
2316
|
appendFileSync(filePath, line + "\n", "utf8");
|
|
3200
2317
|
} catch {
|
|
3201
2318
|
}
|
|
3202
2319
|
}
|
|
3203
2320
|
};
|
|
3204
|
-
var CACHE_DIR =
|
|
3205
|
-
var CACHE_FILE =
|
|
2321
|
+
var CACHE_DIR = join2(homedir2(), ".bithumb");
|
|
2322
|
+
var CACHE_FILE = join2(CACHE_DIR, "update-check.json");
|
|
3206
2323
|
var CACHE_TTL_MS = 24 * 60 * 60 * 1e3;
|
|
3207
2324
|
function isNewerVersion(current, latest) {
|
|
3208
|
-
const
|
|
3209
|
-
const cur =
|
|
3210
|
-
const lat =
|
|
2325
|
+
const parse = (v) => v.replace(/^v/, "").split(".").map((n) => parseInt(n, 10) || 0);
|
|
2326
|
+
const cur = parse(current);
|
|
2327
|
+
const lat = parse(latest);
|
|
3211
2328
|
for (let i = 0; i < Math.max(cur.length, lat.length); i++) {
|
|
3212
2329
|
const c = cur[i] ?? 0;
|
|
3213
2330
|
const l = lat[i] ?? 0;
|
|
@@ -3232,8 +2349,8 @@ async function fetchLatestVersion(packageName) {
|
|
|
3232
2349
|
}
|
|
3233
2350
|
function readCache() {
|
|
3234
2351
|
try {
|
|
3235
|
-
if (!
|
|
3236
|
-
const raw =
|
|
2352
|
+
if (!existsSync(CACHE_FILE)) return null;
|
|
2353
|
+
const raw = readFileSync(CACHE_FILE, "utf8");
|
|
3237
2354
|
return JSON.parse(raw);
|
|
3238
2355
|
} catch {
|
|
3239
2356
|
return null;
|
|
@@ -3241,10 +2358,10 @@ function readCache() {
|
|
|
3241
2358
|
}
|
|
3242
2359
|
function writeCache(data) {
|
|
3243
2360
|
try {
|
|
3244
|
-
if (!
|
|
3245
|
-
|
|
2361
|
+
if (!existsSync(CACHE_DIR)) {
|
|
2362
|
+
mkdirSync2(CACHE_DIR, { recursive: true });
|
|
3246
2363
|
}
|
|
3247
|
-
|
|
2364
|
+
writeFileSync(CACHE_FILE, JSON.stringify(data), "utf8");
|
|
3248
2365
|
} catch {
|
|
3249
2366
|
}
|
|
3250
2367
|
}
|
|
@@ -3352,7 +2469,6 @@ function buildEntry(client, args) {
|
|
|
3352
2469
|
}
|
|
3353
2470
|
function buildArgs(options) {
|
|
3354
2471
|
const args = [];
|
|
3355
|
-
if (options.profile) args.push("--profile", options.profile);
|
|
3356
2472
|
args.push("--modules", options.modules ?? "all");
|
|
3357
2473
|
return args;
|
|
3358
2474
|
}
|
|
@@ -3380,13 +2496,12 @@ function mergeJsonConfig(configPath, serverName, entry) {
|
|
|
3380
2496
|
}
|
|
3381
2497
|
function printSetupUsage() {
|
|
3382
2498
|
process.stdout.write(
|
|
3383
|
-
`Usage: bithumb setup --client <client> [--
|
|
2499
|
+
`Usage: bithumb setup --client <client> [--modules <list>]
|
|
3384
2500
|
|
|
3385
2501
|
Clients:
|
|
3386
2502
|
` + SUPPORTED_CLIENTS.map((id) => ` ${id.padEnd(16)} ${CLIENT_NAMES[id]}`).join("\n") + `
|
|
3387
2503
|
|
|
3388
2504
|
Options:
|
|
3389
|
-
--profile <name> Profile from ${configFilePath()} (default: uses default_profile)
|
|
3390
2505
|
--modules <list> Comma-separated modules or "all" (default: all)
|
|
3391
2506
|
`
|
|
3392
2507
|
);
|
|
@@ -3395,7 +2510,7 @@ function runSetup(options) {
|
|
|
3395
2510
|
const { client } = options;
|
|
3396
2511
|
const name = CLIENT_NAMES[client];
|
|
3397
2512
|
const args = buildArgs(options);
|
|
3398
|
-
const serverName =
|
|
2513
|
+
const serverName = "bithumb-mcp";
|
|
3399
2514
|
if (client === "claude-code") {
|
|
3400
2515
|
const claudeArgs = [
|
|
3401
2516
|
"mcp",
|
|
@@ -3436,9 +2551,6 @@ export {
|
|
|
3436
2551
|
BithumbApiError,
|
|
3437
2552
|
BithumbRestClient,
|
|
3438
2553
|
createToolRunner,
|
|
3439
|
-
configFilePath,
|
|
3440
|
-
readFullConfig,
|
|
3441
|
-
writeFullConfig,
|
|
3442
2554
|
loadConfig,
|
|
3443
2555
|
TradeLogger,
|
|
3444
2556
|
checkForUpdates,
|
|
@@ -3446,43 +2558,4 @@ export {
|
|
|
3446
2558
|
printSetupUsage,
|
|
3447
2559
|
runSetup
|
|
3448
2560
|
};
|
|
3449
|
-
|
|
3450
|
-
|
|
3451
|
-
smol-toml/dist/error.js:
|
|
3452
|
-
smol-toml/dist/util.js:
|
|
3453
|
-
smol-toml/dist/date.js:
|
|
3454
|
-
smol-toml/dist/primitive.js:
|
|
3455
|
-
smol-toml/dist/extract.js:
|
|
3456
|
-
smol-toml/dist/struct.js:
|
|
3457
|
-
smol-toml/dist/parse.js:
|
|
3458
|
-
smol-toml/dist/stringify.js:
|
|
3459
|
-
smol-toml/dist/index.js:
|
|
3460
|
-
(*!
|
|
3461
|
-
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
3462
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
3463
|
-
*
|
|
3464
|
-
* Redistribution and use in source and binary forms, with or without
|
|
3465
|
-
* modification, are permitted provided that the following conditions are met:
|
|
3466
|
-
*
|
|
3467
|
-
* 1. Redistributions of source code must retain the above copyright notice, this
|
|
3468
|
-
* list of conditions and the following disclaimer.
|
|
3469
|
-
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
3470
|
-
* this list of conditions and the following disclaimer in the
|
|
3471
|
-
* documentation and/or other materials provided with the distribution.
|
|
3472
|
-
* 3. Neither the name of the copyright holder nor the names of its contributors
|
|
3473
|
-
* may be used to endorse or promote products derived from this software without
|
|
3474
|
-
* specific prior written permission.
|
|
3475
|
-
*
|
|
3476
|
-
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
3477
|
-
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
3478
|
-
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
3479
|
-
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
3480
|
-
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
3481
|
-
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
3482
|
-
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
3483
|
-
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
3484
|
-
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
3485
|
-
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
3486
|
-
*)
|
|
3487
|
-
*/
|
|
3488
|
-
//# sourceMappingURL=chunk-YXIFBNEQ.js.map
|
|
2561
|
+
//# sourceMappingURL=chunk-HT2P7KTV.js.map
|