agentschat-mcp 0.36.10 → 0.36.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +95 -0
- package/README.md +103 -72
- package/codex/README.md +27 -4
- package/dist/codex-bots.js +512 -419
- package/dist/codex-bridge.js +541 -448
- package/dist/connector.js +5 -5
- package/dist/server.js +60 -15
- package/package.json +7 -3
- package/scripts/ensure-grok-wakes.mjs +138 -7
- package/scripts/example-agy-mcp-wrapper.sh +41 -0
- package/scripts/example-url-wake-ensure.sh +37 -2
- package/scripts/example-url-wake-receiver.mjs +81 -5
- package/skills/grok-wake-keepalive.md +57 -14
- package/skills/hermes-host-keepalive.md +33 -12
- package/skills/onboarding.md +216 -40
- package/skills/url-wake-keepalive.md +68 -6
- package/src/identity-guard.ts +37 -0
- package/src/server.ts +44 -12
package/dist/codex-bots.js
CHANGED
|
@@ -26,126 +26,6 @@ function validateIdentityProfile(profile, file, allowDevToken = false) {
|
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
// node_modules/smol-toml/dist/date.js
|
|
30
|
-
/*!
|
|
31
|
-
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
32
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
33
|
-
*
|
|
34
|
-
* Redistribution and use in source and binary forms, with or without
|
|
35
|
-
* modification, are permitted provided that the following conditions are met:
|
|
36
|
-
*
|
|
37
|
-
* 1. Redistributions of source code must retain the above copyright notice, this
|
|
38
|
-
* list of conditions and the following disclaimer.
|
|
39
|
-
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
40
|
-
* this list of conditions and the following disclaimer in the
|
|
41
|
-
* documentation and/or other materials provided with the distribution.
|
|
42
|
-
* 3. Neither the name of the copyright holder nor the names of its contributors
|
|
43
|
-
* may be used to endorse or promote products derived from this software without
|
|
44
|
-
* specific prior written permission.
|
|
45
|
-
*
|
|
46
|
-
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
47
|
-
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
48
|
-
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
49
|
-
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
50
|
-
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
51
|
-
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
52
|
-
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
53
|
-
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
54
|
-
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
55
|
-
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
56
|
-
*/
|
|
57
|
-
var DATE_TIME_RE = /^(\d{4}-\d{2}-\d{2})?[T ]?(?:(\d{2}):\d{2}(?::\d{2}(?:\.\d+)?)?)?(Z|[-+]\d{2}:\d{2})?$/i;
|
|
58
|
-
|
|
59
|
-
class TomlDate extends Date {
|
|
60
|
-
#hasDate = false;
|
|
61
|
-
#hasTime = false;
|
|
62
|
-
#offset = null;
|
|
63
|
-
constructor(date) {
|
|
64
|
-
let hasDate = true;
|
|
65
|
-
let hasTime = true;
|
|
66
|
-
let offset = "Z";
|
|
67
|
-
if (typeof date === "string") {
|
|
68
|
-
let match = date.match(DATE_TIME_RE);
|
|
69
|
-
if (match) {
|
|
70
|
-
if (!match[1]) {
|
|
71
|
-
hasDate = false;
|
|
72
|
-
date = `0000-01-01T${date}`;
|
|
73
|
-
}
|
|
74
|
-
hasTime = !!match[2];
|
|
75
|
-
hasTime && date[10] === " " && (date = date.replace(" ", "T"));
|
|
76
|
-
if (match[2] && +match[2] > 23) {
|
|
77
|
-
date = "";
|
|
78
|
-
} else {
|
|
79
|
-
offset = match[3] || null;
|
|
80
|
-
date = date.toUpperCase();
|
|
81
|
-
if (!offset && hasTime)
|
|
82
|
-
date += "Z";
|
|
83
|
-
}
|
|
84
|
-
} else {
|
|
85
|
-
date = "";
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
super(date);
|
|
89
|
-
if (!isNaN(this.getTime())) {
|
|
90
|
-
this.#hasDate = hasDate;
|
|
91
|
-
this.#hasTime = hasTime;
|
|
92
|
-
this.#offset = offset;
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
isDateTime() {
|
|
96
|
-
return this.#hasDate && this.#hasTime;
|
|
97
|
-
}
|
|
98
|
-
isLocal() {
|
|
99
|
-
return !this.#hasDate || !this.#hasTime || !this.#offset;
|
|
100
|
-
}
|
|
101
|
-
isDate() {
|
|
102
|
-
return this.#hasDate && !this.#hasTime;
|
|
103
|
-
}
|
|
104
|
-
isTime() {
|
|
105
|
-
return this.#hasTime && !this.#hasDate;
|
|
106
|
-
}
|
|
107
|
-
isValid() {
|
|
108
|
-
return this.#hasDate || this.#hasTime;
|
|
109
|
-
}
|
|
110
|
-
toISOString() {
|
|
111
|
-
let iso = super.toISOString();
|
|
112
|
-
if (this.isDate())
|
|
113
|
-
return iso.slice(0, 10);
|
|
114
|
-
if (this.isTime())
|
|
115
|
-
return iso.slice(11, 23);
|
|
116
|
-
if (this.#offset === null)
|
|
117
|
-
return iso.slice(0, -1);
|
|
118
|
-
if (this.#offset === "Z")
|
|
119
|
-
return iso;
|
|
120
|
-
let offset = +this.#offset.slice(1, 3) * 60 + +this.#offset.slice(4, 6);
|
|
121
|
-
offset = this.#offset[0] === "-" ? offset : -offset;
|
|
122
|
-
let offsetDate = new Date(this.getTime() - offset * 60000);
|
|
123
|
-
return offsetDate.toISOString().slice(0, -1) + this.#offset;
|
|
124
|
-
}
|
|
125
|
-
static wrapAsOffsetDateTime(jsDate, offset = "Z") {
|
|
126
|
-
let date = new TomlDate(jsDate);
|
|
127
|
-
date.#offset = offset;
|
|
128
|
-
return date;
|
|
129
|
-
}
|
|
130
|
-
static wrapAsLocalDateTime(jsDate) {
|
|
131
|
-
let date = new TomlDate(jsDate);
|
|
132
|
-
date.#offset = null;
|
|
133
|
-
return date;
|
|
134
|
-
}
|
|
135
|
-
static wrapAsLocalDate(jsDate) {
|
|
136
|
-
let date = new TomlDate(jsDate);
|
|
137
|
-
date.#hasTime = false;
|
|
138
|
-
date.#offset = null;
|
|
139
|
-
return date;
|
|
140
|
-
}
|
|
141
|
-
static wrapAsLocalTime(jsDate) {
|
|
142
|
-
let date = new TomlDate(jsDate);
|
|
143
|
-
date.#hasDate = false;
|
|
144
|
-
date.#offset = null;
|
|
145
|
-
return date;
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
|
|
149
29
|
// node_modules/smol-toml/dist/error.js
|
|
150
30
|
/*!
|
|
151
31
|
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
@@ -175,11 +55,11 @@ class TomlDate extends Date {
|
|
|
175
55
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
176
56
|
*/
|
|
177
57
|
function getLineColFromPtr(string, ptr) {
|
|
178
|
-
let lines = string.slice(0, ptr).split(/\r
|
|
58
|
+
let lines = string.slice(0, ptr).split(/\r?\n/);
|
|
179
59
|
return [lines.length, lines.pop().length + 1];
|
|
180
60
|
}
|
|
181
61
|
function makeCodeBlock(string, line, column) {
|
|
182
|
-
let lines = string.split(/\r
|
|
62
|
+
let lines = string.split(/\r?\n/);
|
|
183
63
|
let codeblock = "";
|
|
184
64
|
let numberLen = (Math.log10(line + 1) | 0) + 1;
|
|
185
65
|
for (let i = line - 1;i <= line + 1; i++) {
|
|
@@ -214,90 +94,10 @@ ${codeblock}`, options);
|
|
|
214
94
|
this.column = column;
|
|
215
95
|
this.codeblock = codeblock;
|
|
216
96
|
}
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
// node_modules/smol-toml/dist/util.js
|
|
220
|
-
/*!
|
|
221
|
-
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
222
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
223
|
-
*
|
|
224
|
-
* Redistribution and use in source and binary forms, with or without
|
|
225
|
-
* modification, are permitted provided that the following conditions are met:
|
|
226
|
-
*
|
|
227
|
-
* 1. Redistributions of source code must retain the above copyright notice, this
|
|
228
|
-
* list of conditions and the following disclaimer.
|
|
229
|
-
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
230
|
-
* this list of conditions and the following disclaimer in the
|
|
231
|
-
* documentation and/or other materials provided with the distribution.
|
|
232
|
-
* 3. Neither the name of the copyright holder nor the names of its contributors
|
|
233
|
-
* may be used to endorse or promote products derived from this software without
|
|
234
|
-
* specific prior written permission.
|
|
235
|
-
*
|
|
236
|
-
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
237
|
-
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
238
|
-
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
239
|
-
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
240
|
-
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
241
|
-
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
242
|
-
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
243
|
-
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
244
|
-
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
245
|
-
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
246
|
-
*/
|
|
247
|
-
function indexOfNewline(str, start = 0) {
|
|
248
|
-
let idx = str.indexOf(`
|
|
249
|
-
`, start);
|
|
250
|
-
if (str.charCodeAt(idx - 1) === 13)
|
|
251
|
-
idx--;
|
|
252
|
-
return idx;
|
|
253
|
-
}
|
|
254
|
-
function skipComment(ctx) {
|
|
255
|
-
for (;ctx.p < ctx.s.length; ctx.p++) {
|
|
256
|
-
let c = ctx.s.charCodeAt(ctx.p);
|
|
257
|
-
if (c === 10)
|
|
258
|
-
break;
|
|
259
|
-
if (c === 13 && ctx.s.charCodeAt(ctx.p + 1) === 10) {
|
|
260
|
-
ctx.p++;
|
|
261
|
-
break;
|
|
262
|
-
}
|
|
263
|
-
if (c < 32 && c !== 9 || c === 127) {
|
|
264
|
-
throw new TomlError("control characters are not allowed in comments", {
|
|
265
|
-
toml: ctx.s,
|
|
266
|
-
ptr: ctx.p
|
|
267
|
-
});
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
|
-
}
|
|
271
|
-
function skipVoid(ctx, banNewLines, banComments) {
|
|
272
|
-
let c;
|
|
273
|
-
while (true) {
|
|
274
|
-
while ((c = ctx.s.charCodeAt(ctx.p)) === 32 || c === 9 || !banNewLines && (c === 10 || c === 13 && ctx.s.charCodeAt(ctx.p + 1) === 10))
|
|
275
|
-
ctx.p++;
|
|
276
|
-
if (banComments || c !== 35)
|
|
277
|
-
break;
|
|
278
|
-
skipComment(ctx);
|
|
97
|
+
static x(message, ctx, ptr) {
|
|
98
|
+
throw new TomlError(message, { toml: ctx.s, ptr: ptr ?? ctx.p });
|
|
279
99
|
}
|
|
280
100
|
}
|
|
281
|
-
function skipUntil(ctx, sep, end) {
|
|
282
|
-
let ptr = ctx.p;
|
|
283
|
-
if (!end) {
|
|
284
|
-
ptr = indexOfNewline(ctx.s, ptr);
|
|
285
|
-
ctx.p = ptr < 0 ? ctx.s.length : ptr;
|
|
286
|
-
return;
|
|
287
|
-
}
|
|
288
|
-
for (;ctx.p < ctx.s.length; ctx.p++) {
|
|
289
|
-
let c = ctx.s.charCodeAt(ctx.p);
|
|
290
|
-
if (c === 35) {
|
|
291
|
-
skipComment(ctx);
|
|
292
|
-
} else if (c === end || c === sep) {
|
|
293
|
-
return;
|
|
294
|
-
}
|
|
295
|
-
}
|
|
296
|
-
throw new TomlError("cannot find end of structure", {
|
|
297
|
-
toml: ctx.s,
|
|
298
|
-
ptr
|
|
299
|
-
});
|
|
300
|
-
}
|
|
301
101
|
|
|
302
102
|
// node_modules/smol-toml/dist/primitive.js
|
|
303
103
|
/*!
|
|
@@ -327,11 +127,8 @@ function skipUntil(ctx, sep, end) {
|
|
|
327
127
|
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
328
128
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
329
129
|
*/
|
|
330
|
-
var INT_REGEX = /^((0x[0-9a-fA-F](_?[0-9a-fA-F])*)|(([+-]|0[ob])?\d(_?\d)*))$/;
|
|
331
|
-
var FLOAT_REGEX = /^[+-]?\d(_?\d)*(\.\d(_?\d)*)?([eE][+-]?\d(_?\d)*)?$/;
|
|
332
|
-
var LEADING_ZERO = /^[+-]?0[0-9_]/;
|
|
333
130
|
function parseString(ctx) {
|
|
334
|
-
let
|
|
131
|
+
let startPtr = ctx.p;
|
|
335
132
|
let c = ctx.s.charCodeAt(ctx.p++);
|
|
336
133
|
let first = c;
|
|
337
134
|
let isLiteral = c === 39;
|
|
@@ -350,10 +147,7 @@ function parseString(ctx) {
|
|
|
350
147
|
if (isMultiline && (c === 10 || c === 13 && ctx.s.charCodeAt(ctx.p + 1) === 10)) {
|
|
351
148
|
state = state && 3;
|
|
352
149
|
} else if (c < 32 && c !== 9 || c === 127) {
|
|
353
|
-
|
|
354
|
-
toml: ctx.s,
|
|
355
|
-
ptr: ctx.p
|
|
356
|
-
});
|
|
150
|
+
TomlError.x("control characters are not allowed in strings", ctx);
|
|
357
151
|
} else if ((!state || state === 3) && c === first && (!isMultiline || ctx.s.charCodeAt(ctx.p + 1) === first && ctx.s.charCodeAt(ctx.p + 2) === first)) {
|
|
358
152
|
if (isMultiline) {
|
|
359
153
|
if (ctx.s.charCodeAt(ctx.p + 3) === first)
|
|
@@ -361,8 +155,10 @@ function parseString(ctx) {
|
|
|
361
155
|
if (ctx.s.charCodeAt(ctx.p + 3) === first)
|
|
362
156
|
ctx.p++;
|
|
363
157
|
}
|
|
364
|
-
if (!state)
|
|
365
|
-
|
|
158
|
+
if (!state) {
|
|
159
|
+
let s = ctx.s.slice(sliceStart, ctx.p);
|
|
160
|
+
parsed = parsed ? parsed + s : s;
|
|
161
|
+
}
|
|
366
162
|
ctx.p += isMultiline ? 3 : 1;
|
|
367
163
|
return parsed;
|
|
368
164
|
} else if (!state) {
|
|
@@ -372,22 +168,23 @@ function parseString(ctx) {
|
|
|
372
168
|
}
|
|
373
169
|
} else if (state === 1) {
|
|
374
170
|
if (c === 120 || c === 117 || c === 85) {
|
|
171
|
+
let errPtr = ctx.p++ - 1;
|
|
375
172
|
let value = 0;
|
|
376
173
|
let len = c === 120 ? 2 : c === 117 ? 4 : 8;
|
|
377
174
|
for (let j = 0;j < len; j++, ctx.p++) {
|
|
378
|
-
let hex = ctx.s.charCodeAt(ctx.p
|
|
175
|
+
let hex = ctx.s.charCodeAt(ctx.p);
|
|
379
176
|
let digit = hex >= 48 && hex <= 57 ? hex - 48 : hex >= 65 && hex <= 70 ? hex - 65 + 10 : hex >= 97 && hex <= 102 ? hex - 97 + 10 : -1;
|
|
380
177
|
if (digit < 0)
|
|
381
|
-
|
|
178
|
+
TomlError.x("invalid non-hex character in unicode escape", ctx);
|
|
382
179
|
value = value << 4 | digit;
|
|
383
180
|
}
|
|
384
181
|
if (value < 0 || value > 1114111 || value >= 55296 && value <= 57343) {
|
|
385
|
-
|
|
182
|
+
TomlError.x("invalid unicode escape", ctx, errPtr);
|
|
386
183
|
}
|
|
387
184
|
parsed += String.fromCodePoint(value);
|
|
388
|
-
sliceStart = ctx.p
|
|
185
|
+
sliceStart = ctx.p--;
|
|
389
186
|
state = 0;
|
|
390
|
-
} else if (c === 32 || c === 9) {
|
|
187
|
+
} else if (isMultiline && (c === 32 || c === 9)) {
|
|
391
188
|
state = 2;
|
|
392
189
|
} else {
|
|
393
190
|
if (c === 98)
|
|
@@ -408,70 +205,161 @@ function parseString(ctx) {
|
|
|
408
205
|
else if (c === 92)
|
|
409
206
|
parsed += "\\";
|
|
410
207
|
else
|
|
411
|
-
|
|
208
|
+
TomlError.x("unrecognised escape sequence", ctx);
|
|
412
209
|
sliceStart = ctx.p + 1;
|
|
413
210
|
state = 0;
|
|
414
211
|
}
|
|
415
212
|
} else if (c !== 32 && c !== 9) {
|
|
416
|
-
if (state === 2)
|
|
417
|
-
|
|
418
|
-
toml: ctx.s,
|
|
419
|
-
ptr: sliceStart
|
|
420
|
-
});
|
|
421
|
-
}
|
|
213
|
+
if (state === 2)
|
|
214
|
+
TomlError.x("invalid escape: only line-ending whitespace may be escaped", ctx, sliceStart);
|
|
422
215
|
state = !isLiteral && c === 92 ? 1 : 0;
|
|
423
216
|
sliceStart = ctx.p;
|
|
424
217
|
}
|
|
425
218
|
}
|
|
426
|
-
|
|
219
|
+
TomlError.x("unfinished string", ctx, startPtr);
|
|
427
220
|
}
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
221
|
+
|
|
222
|
+
// node_modules/smol-toml/dist/date.js
|
|
223
|
+
/*!
|
|
224
|
+
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
225
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
226
|
+
*
|
|
227
|
+
* Redistribution and use in source and binary forms, with or without
|
|
228
|
+
* modification, are permitted provided that the following conditions are met:
|
|
229
|
+
*
|
|
230
|
+
* 1. Redistributions of source code must retain the above copyright notice, this
|
|
231
|
+
* list of conditions and the following disclaimer.
|
|
232
|
+
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
233
|
+
* this list of conditions and the following disclaimer in the
|
|
234
|
+
* documentation and/or other materials provided with the distribution.
|
|
235
|
+
* 3. Neither the name of the copyright holder nor the names of its contributors
|
|
236
|
+
* may be used to endorse or promote products derived from this software without
|
|
237
|
+
* specific prior written permission.
|
|
238
|
+
*
|
|
239
|
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
240
|
+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
241
|
+
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
242
|
+
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
243
|
+
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
244
|
+
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
245
|
+
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
246
|
+
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
247
|
+
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
248
|
+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
249
|
+
*/
|
|
250
|
+
var DATE_TIME_RE = /^(\d{4}-\d{2}-\d{2})?[Tt ]?(?:(\d{2}):\d{2}(?::\d{2}(?:\.\d+)?)?)?(Z|z|[-+]\d{2}:\d{2})?$/i;
|
|
251
|
+
|
|
252
|
+
class TomlDate extends Date {
|
|
253
|
+
#hasDate = false;
|
|
254
|
+
#hasTime = false;
|
|
255
|
+
#offset = null;
|
|
256
|
+
constructor(date, fasttype, unsafeDelim) {
|
|
257
|
+
let hasDate = true;
|
|
258
|
+
let hasTime = true;
|
|
259
|
+
let offset = "Z";
|
|
260
|
+
let c;
|
|
261
|
+
if (typeof date === "string") {
|
|
262
|
+
if (fasttype)
|
|
263
|
+
prep: {
|
|
264
|
+
if (fasttype < 3) {
|
|
265
|
+
if (+date.slice(11, 13) > 23) {
|
|
266
|
+
date = "";
|
|
267
|
+
break prep;
|
|
268
|
+
}
|
|
269
|
+
if (fasttype === 2) {
|
|
270
|
+
offset = null;
|
|
271
|
+
date += "Z";
|
|
272
|
+
} else if ((c = date.charCodeAt(date.length - 1)) !== 90 && c !== 122) {
|
|
273
|
+
offset = date.slice(date.length - 6);
|
|
274
|
+
}
|
|
275
|
+
if (unsafeDelim)
|
|
276
|
+
date = date.slice(0, 10) + "T" + date.slice(11);
|
|
277
|
+
} else if (fasttype === 4) {
|
|
278
|
+
date = +date.slice(0, 2) > 23 ? "" : `0000-01-01T${date}Z`;
|
|
279
|
+
}
|
|
280
|
+
hasDate = fasttype !== 4;
|
|
281
|
+
hasTime = fasttype !== 3;
|
|
282
|
+
}
|
|
283
|
+
else {
|
|
284
|
+
let match = date.match(DATE_TIME_RE);
|
|
285
|
+
if (match) {
|
|
286
|
+
if (!match[1]) {
|
|
287
|
+
hasDate = false;
|
|
288
|
+
date = `0000-01-01T${date}`;
|
|
289
|
+
}
|
|
290
|
+
hasTime = !!match[2];
|
|
291
|
+
hasTime && date[10] === " " && (date = date.replace(" ", "T"));
|
|
292
|
+
if (match[2] && +match[2] > 23) {
|
|
293
|
+
date = "";
|
|
294
|
+
} else {
|
|
295
|
+
offset = match[3] || null;
|
|
296
|
+
if (!offset && hasTime)
|
|
297
|
+
date += "Z";
|
|
298
|
+
}
|
|
299
|
+
} else {
|
|
300
|
+
date = "";
|
|
301
|
+
}
|
|
465
302
|
}
|
|
466
|
-
if (isInt || integersAsBigInt === true)
|
|
467
|
-
numeric = BigInt(value);
|
|
468
303
|
}
|
|
469
|
-
|
|
304
|
+
super(date);
|
|
305
|
+
if (!isNaN(this.getTime())) {
|
|
306
|
+
this.#hasDate = hasDate;
|
|
307
|
+
this.#hasTime = hasTime;
|
|
308
|
+
this.#offset = offset;
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
isDateTime() {
|
|
312
|
+
return this.#hasDate && this.#hasTime;
|
|
313
|
+
}
|
|
314
|
+
isLocal() {
|
|
315
|
+
return !this.#hasDate || !this.#hasTime || !this.#offset;
|
|
316
|
+
}
|
|
317
|
+
isDate() {
|
|
318
|
+
return this.#hasDate && !this.#hasTime;
|
|
319
|
+
}
|
|
320
|
+
isTime() {
|
|
321
|
+
return this.#hasTime && !this.#hasDate;
|
|
322
|
+
}
|
|
323
|
+
isValid() {
|
|
324
|
+
return this.#hasDate || this.#hasTime;
|
|
325
|
+
}
|
|
326
|
+
toISOString() {
|
|
327
|
+
let iso = super.toISOString();
|
|
328
|
+
if (this.isDate())
|
|
329
|
+
return iso.slice(0, 10);
|
|
330
|
+
if (this.isTime())
|
|
331
|
+
return iso.slice(11, 23);
|
|
332
|
+
if (this.#offset === null)
|
|
333
|
+
return iso.slice(0, -1);
|
|
334
|
+
if (this.#offset === "Z" || this.#offset === "z")
|
|
335
|
+
return iso;
|
|
336
|
+
let offset = +this.#offset.slice(1, 3) * 60 + +this.#offset.slice(4, 6);
|
|
337
|
+
offset = this.#offset[0] === "-" ? offset : -offset;
|
|
338
|
+
let offsetDate = new Date(this.getTime() - offset * 60000);
|
|
339
|
+
return offsetDate.toISOString().slice(0, -1) + this.#offset;
|
|
340
|
+
}
|
|
341
|
+
static wrapAsOffsetDateTime(jsDate, offset = "Z") {
|
|
342
|
+
let date = new TomlDate(jsDate);
|
|
343
|
+
date.#offset = offset;
|
|
344
|
+
return date;
|
|
345
|
+
}
|
|
346
|
+
static wrapAsLocalDateTime(jsDate) {
|
|
347
|
+
let date = new TomlDate(jsDate);
|
|
348
|
+
date.#offset = null;
|
|
349
|
+
return date;
|
|
350
|
+
}
|
|
351
|
+
static wrapAsLocalDate(jsDate) {
|
|
352
|
+
let date = new TomlDate(jsDate);
|
|
353
|
+
date.#hasTime = false;
|
|
354
|
+
date.#offset = null;
|
|
355
|
+
return date;
|
|
356
|
+
}
|
|
357
|
+
static wrapAsLocalTime(jsDate) {
|
|
358
|
+
let date = new TomlDate(jsDate);
|
|
359
|
+
date.#hasDate = false;
|
|
360
|
+
date.#offset = null;
|
|
361
|
+
return date;
|
|
470
362
|
}
|
|
471
|
-
const date = new TomlDate(value);
|
|
472
|
-
if (!date.isValid())
|
|
473
|
-
throw new TomlError("invalid value", err);
|
|
474
|
-
return date;
|
|
475
363
|
}
|
|
476
364
|
|
|
477
365
|
// node_modules/smol-toml/dist/extract.js
|
|
@@ -502,17 +390,18 @@ function parseValue(ctx, integersAsBigInt, end) {
|
|
|
502
390
|
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
503
391
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
504
392
|
*/
|
|
505
|
-
function
|
|
506
|
-
|
|
507
|
-
|
|
393
|
+
function isDigit(char, base = 10) {
|
|
394
|
+
return base === 16 ? char > 47 && char < 58 || char > 64 && char < 71 || char > 96 && char < 103 : char > 47 && char < 48 + base;
|
|
395
|
+
}
|
|
396
|
+
function isEndOfValue(char, delim) {
|
|
397
|
+
return char === 32 || char === 9 || char === 10 || char === 13 || delim && (char === delim || char === 44) || char === 35;
|
|
398
|
+
}
|
|
399
|
+
function extractValue(ctx, end) {
|
|
400
|
+
let errPtr = ctx.p;
|
|
401
|
+
let c = ctx.s.charCodeAt(ctx.p);
|
|
508
402
|
if (c === 91 || c === 123) {
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
toml: ctx.s,
|
|
512
|
-
ptr
|
|
513
|
-
});
|
|
514
|
-
}
|
|
515
|
-
let value = c === 91 ? parseArray(ctx, integersAsBigInt) : parseInlineTable(ctx, integersAsBigInt);
|
|
403
|
+
ctx.d-- || TomlError.x("document contains excessively nested structures. aborting.", ctx);
|
|
404
|
+
let value = c === 91 ? parseArray(ctx) : parseInlineTable(ctx);
|
|
516
405
|
ctx.d++;
|
|
517
406
|
return value;
|
|
518
407
|
}
|
|
@@ -521,17 +410,243 @@ function extractValue(ctx, end, integersAsBigInt) {
|
|
|
521
410
|
}
|
|
522
411
|
if (c === 116) {
|
|
523
412
|
if (ctx.s.charCodeAt(++ctx.p) !== 114 || ctx.s.charCodeAt(++ctx.p) !== 117 || ctx.s.charCodeAt(++ctx.p) !== 101)
|
|
524
|
-
|
|
525
|
-
ctx.p
|
|
526
|
-
return true;
|
|
413
|
+
TomlError.x("invalid value", ctx, errPtr);
|
|
414
|
+
return ctx.p++, true;
|
|
527
415
|
}
|
|
528
416
|
if (c === 102) {
|
|
529
417
|
if (ctx.s.charCodeAt(++ctx.p) !== 97 || ctx.s.charCodeAt(++ctx.p) !== 108 || ctx.s.charCodeAt(++ctx.p) !== 115 || ctx.s.charCodeAt(++ctx.p) !== 101)
|
|
530
|
-
|
|
531
|
-
ctx.p
|
|
532
|
-
|
|
418
|
+
TomlError.x("invalid value", ctx, errPtr);
|
|
419
|
+
return ctx.p++, false;
|
|
420
|
+
}
|
|
421
|
+
if (c === 43 || c === 45) {
|
|
422
|
+
return parseNumber(ctx, ctx.p, ctx.s.charCodeAt(++ctx.p), 44 - c, end);
|
|
423
|
+
}
|
|
424
|
+
if (ctx.s.charCodeAt(ctx.p + 4) === 45 && ctx.s.charCodeAt(ctx.p + 7) === 45) {
|
|
425
|
+
return parseDate(ctx, c, end);
|
|
426
|
+
}
|
|
427
|
+
if (ctx.s.charCodeAt(ctx.p + 2) === 58) {
|
|
428
|
+
return parseTime(ctx, c, end);
|
|
429
|
+
}
|
|
430
|
+
return parseNumber(ctx, ctx.p, c, 0, end);
|
|
431
|
+
}
|
|
432
|
+
function parseNumber(ctx, startPtr, startChr, sign, endChr) {
|
|
433
|
+
let c = startChr;
|
|
434
|
+
let state = 0;
|
|
435
|
+
let hasUnderscores = false;
|
|
436
|
+
if (c === 105) {
|
|
437
|
+
if (ctx.s.charCodeAt(++ctx.p) !== 110 || ctx.s.charCodeAt(++ctx.p) !== 102)
|
|
438
|
+
TomlError.x("invalid value", ctx, startPtr);
|
|
439
|
+
return ctx.p++, (sign || 1) / 0;
|
|
440
|
+
}
|
|
441
|
+
if (c === 110) {
|
|
442
|
+
if (ctx.s.charCodeAt(++ctx.p) !== 97 || ctx.s.charCodeAt(++ctx.p) !== 110)
|
|
443
|
+
TomlError.x("invalid value", ctx, startPtr);
|
|
444
|
+
return ctx.p++, NaN;
|
|
445
|
+
}
|
|
446
|
+
if (c === 48) {
|
|
447
|
+
if (++ctx.p >= ctx.s.length || isEndOfValue(c = ctx.s.charCodeAt(ctx.p), endChr))
|
|
448
|
+
return ctx.bi === true ? 0n : 0;
|
|
449
|
+
if (!sign) {
|
|
450
|
+
if (c === 120)
|
|
451
|
+
return parseIntegerBaseN(ctx, startPtr, 16, endChr);
|
|
452
|
+
else if (c === 98)
|
|
453
|
+
return parseIntegerBaseN(ctx, startPtr, 2, endChr);
|
|
454
|
+
else if (c === 111)
|
|
455
|
+
return parseIntegerBaseN(ctx, startPtr, 8, endChr);
|
|
456
|
+
}
|
|
457
|
+
if (c === 46)
|
|
458
|
+
state = 2;
|
|
459
|
+
else if (c === 101 || c === 69)
|
|
460
|
+
state = 4;
|
|
461
|
+
else
|
|
462
|
+
TomlError.x("illegal leading zero", ctx, startPtr);
|
|
463
|
+
} else if (!isDigit(c))
|
|
464
|
+
TomlError.x("invalid value", ctx, startPtr);
|
|
465
|
+
while (++ctx.p < ctx.s.length && (c = ctx.s.charCodeAt(ctx.p), !isEndOfValue(c, endChr))) {
|
|
466
|
+
if (!state)
|
|
467
|
+
state = 1;
|
|
468
|
+
if (c === 95) {
|
|
469
|
+
if (!(state & 1))
|
|
470
|
+
TomlError.x("illegal underscore", ctx);
|
|
471
|
+
state += 11;
|
|
472
|
+
hasUnderscores = true;
|
|
473
|
+
} else if (state === 1 && c === 46)
|
|
474
|
+
state = 2;
|
|
475
|
+
else if ((state === 1 || state === 3) && (c === 101 || c === 69))
|
|
476
|
+
state = 4;
|
|
477
|
+
else if (state === 4 && (c === 43 || c === 45)) {
|
|
478
|
+
state = 6;
|
|
479
|
+
} else if (!isDigit(c))
|
|
480
|
+
TomlError.x(`illegal character in numeric literal`, ctx);
|
|
481
|
+
else if (state > 9)
|
|
482
|
+
state -= 11;
|
|
483
|
+
else if (!(state & 1))
|
|
484
|
+
state++;
|
|
485
|
+
}
|
|
486
|
+
if (!state) {
|
|
487
|
+
let val = (startChr - 48) * (sign || 1);
|
|
488
|
+
return ctx.bi === true ? BigInt(val) : val;
|
|
489
|
+
}
|
|
490
|
+
if (!(state & 1))
|
|
491
|
+
TomlError.x("unfinished numeric value", ctx, startPtr);
|
|
492
|
+
let str = ctx.s.slice(startPtr, ctx.p);
|
|
493
|
+
if (hasUnderscores)
|
|
494
|
+
str = str.replaceAll("_", "");
|
|
495
|
+
return state > 1 ? parseFloat(str) : parseInteger(ctx, str, 10, startPtr);
|
|
496
|
+
}
|
|
497
|
+
function parseIntegerBaseN(ctx, startPtr, base, endChr) {
|
|
498
|
+
let c, underscore = 1;
|
|
499
|
+
while (++ctx.p < ctx.s.length && (c = ctx.s.charCodeAt(ctx.p), !isEndOfValue(c, endChr))) {
|
|
500
|
+
if (c === 95) {
|
|
501
|
+
if (underscore & 1)
|
|
502
|
+
TomlError.x("illegal underscore", ctx);
|
|
503
|
+
underscore = 3;
|
|
504
|
+
} else if (!isDigit(c, base))
|
|
505
|
+
TomlError.x(`illegal character in numeric literal`, ctx);
|
|
506
|
+
else if (underscore & 1)
|
|
507
|
+
underscore--;
|
|
508
|
+
}
|
|
509
|
+
if (underscore & 1)
|
|
510
|
+
TomlError.x("unfinished numeric value", ctx);
|
|
511
|
+
let str = ctx.s.slice(startPtr + 2, ctx.p);
|
|
512
|
+
if (underscore)
|
|
513
|
+
str = str.replaceAll("_", "");
|
|
514
|
+
return parseInteger(ctx, str, base, startPtr);
|
|
515
|
+
}
|
|
516
|
+
function parseInteger(ctx, str, base, startPtr) {
|
|
517
|
+
if (ctx.bi !== true)
|
|
518
|
+
int: {
|
|
519
|
+
let val = parseInt(str, base);
|
|
520
|
+
if (!Number.isSafeInteger(val)) {
|
|
521
|
+
if (ctx.bi)
|
|
522
|
+
break int;
|
|
523
|
+
TomlError.x("integer value cannot be represented losslessly", ctx, startPtr);
|
|
524
|
+
}
|
|
525
|
+
return val;
|
|
526
|
+
}
|
|
527
|
+
return base === 10 ? BigInt(str) : BigInt((base === 2 ? "0b" : base === 8 ? "0o" : "0x") + str);
|
|
528
|
+
}
|
|
529
|
+
function parseDate(ctx, c, endChr) {
|
|
530
|
+
let startPtr = ctx.p++, unsafeSeparator;
|
|
531
|
+
if (!isDigit(c) || !isDigit(ctx.s.charCodeAt(ctx.p++)) || !isDigit(ctx.s.charCodeAt(ctx.p++)) || !isDigit(ctx.s.charCodeAt(ctx.p++))) {
|
|
532
|
+
return parseNumber(ctx, ctx.p = startPtr, c, 0, endChr);
|
|
533
|
+
}
|
|
534
|
+
ctx.p += 5;
|
|
535
|
+
if (!isDigit(ctx.s.charCodeAt(ctx.p++)))
|
|
536
|
+
TomlError.x("invalid date-time: date part is malformed", ctx, startPtr);
|
|
537
|
+
if (ctx.p >= ctx.s.length || ((c = ctx.s.charCodeAt(ctx.p)) !== 32 || (unsafeSeparator = true, !isDigit(ctx.s.charCodeAt(ctx.p + 1)))) && c !== 84 && c !== 116) {
|
|
538
|
+
let t = ctx.s.slice(startPtr, ctx.p);
|
|
539
|
+
return readDate(ctx, t, 3, false, startPtr);
|
|
540
|
+
}
|
|
541
|
+
if (ctx.s.charCodeAt(ctx.p += 3) !== 58)
|
|
542
|
+
TomlError.x("invalid date-time: time part is malformed", ctx, startPtr);
|
|
543
|
+
if (ctx.s.charCodeAt(ctx.p += 3) === 58)
|
|
544
|
+
ctx.p += 3;
|
|
545
|
+
if (ctx.s.charCodeAt(ctx.p) === 46)
|
|
546
|
+
while (isDigit(ctx.s.charCodeAt(++ctx.p)))
|
|
547
|
+
;
|
|
548
|
+
if (c = ctx.s.charCodeAt(ctx.p)) {
|
|
549
|
+
if (c === 90 || c === 122) {
|
|
550
|
+
let t = ctx.s.slice(startPtr, ++ctx.p);
|
|
551
|
+
return readDate(ctx, t, 1, unsafeSeparator, startPtr, "[+00:00]");
|
|
552
|
+
}
|
|
553
|
+
if (c === 43 || c === 45) {
|
|
554
|
+
let t = ctx.s.slice(startPtr, ctx.p += 6);
|
|
555
|
+
return readDate(ctx, t, 1, unsafeSeparator, startPtr, !ctx.ld && "[" + ctx.s.slice(ctx.p - 6, ctx.p) + "]");
|
|
556
|
+
}
|
|
557
|
+
}
|
|
558
|
+
let t = ctx.s.slice(startPtr, ctx.p);
|
|
559
|
+
return readDate(ctx, t, 2, unsafeSeparator, startPtr);
|
|
560
|
+
}
|
|
561
|
+
function parseTime(ctx, c, endChr) {
|
|
562
|
+
let start = ctx.p;
|
|
563
|
+
if (!isDigit(c) || !isDigit(ctx.s.charCodeAt(++ctx.p))) {
|
|
564
|
+
return parseNumber(ctx, --ctx.p, c, 0, endChr);
|
|
565
|
+
}
|
|
566
|
+
if (ctx.s.charCodeAt(ctx.p += 4) === 58)
|
|
567
|
+
ctx.p += 3;
|
|
568
|
+
if (ctx.s.charCodeAt(ctx.p) === 46)
|
|
569
|
+
while (isDigit(ctx.s.charCodeAt(++ctx.p)))
|
|
570
|
+
;
|
|
571
|
+
let t = ctx.s.slice(start, ctx.p);
|
|
572
|
+
return readDate(ctx, t, 4, false, start);
|
|
573
|
+
}
|
|
574
|
+
function readDate(ctx, str, type, unsafeDelim, errPtr, temporalSuffix) {
|
|
575
|
+
if (ctx.ld) {
|
|
576
|
+
let date = new TomlDate(str, type, unsafeDelim);
|
|
577
|
+
if (!date.isValid())
|
|
578
|
+
TomlError.x("invalid date", ctx, errPtr);
|
|
579
|
+
return date;
|
|
580
|
+
}
|
|
581
|
+
try {
|
|
582
|
+
if (temporalSuffix)
|
|
583
|
+
str += temporalSuffix;
|
|
584
|
+
switch (type) {
|
|
585
|
+
case 1:
|
|
586
|
+
return Temporal.ZonedDateTime.from(str);
|
|
587
|
+
case 2:
|
|
588
|
+
return Temporal.PlainDateTime.from(str);
|
|
589
|
+
case 3:
|
|
590
|
+
return Temporal.PlainDate.from(str);
|
|
591
|
+
case 4:
|
|
592
|
+
return Temporal.PlainTime.from(str);
|
|
593
|
+
}
|
|
594
|
+
} catch (e) {
|
|
595
|
+
TomlError.x(e instanceof Error ? e.message : "" + e, ctx, errPtr);
|
|
596
|
+
}
|
|
597
|
+
}
|
|
598
|
+
|
|
599
|
+
// node_modules/smol-toml/dist/util.js
|
|
600
|
+
/*!
|
|
601
|
+
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
602
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
603
|
+
*
|
|
604
|
+
* Redistribution and use in source and binary forms, with or without
|
|
605
|
+
* modification, are permitted provided that the following conditions are met:
|
|
606
|
+
*
|
|
607
|
+
* 1. Redistributions of source code must retain the above copyright notice, this
|
|
608
|
+
* list of conditions and the following disclaimer.
|
|
609
|
+
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
610
|
+
* this list of conditions and the following disclaimer in the
|
|
611
|
+
* documentation and/or other materials provided with the distribution.
|
|
612
|
+
* 3. Neither the name of the copyright holder nor the names of its contributors
|
|
613
|
+
* may be used to endorse or promote products derived from this software without
|
|
614
|
+
* specific prior written permission.
|
|
615
|
+
*
|
|
616
|
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
617
|
+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
618
|
+
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
619
|
+
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
620
|
+
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
621
|
+
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
622
|
+
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
623
|
+
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
624
|
+
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
625
|
+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
626
|
+
*/
|
|
627
|
+
function skipComment(ctx) {
|
|
628
|
+
for (;ctx.p < ctx.s.length; ctx.p++) {
|
|
629
|
+
let c = ctx.s.charCodeAt(ctx.p);
|
|
630
|
+
if (c === 10)
|
|
631
|
+
break;
|
|
632
|
+
if (c === 13 && ctx.s.charCodeAt(ctx.p + 1) === 10) {
|
|
633
|
+
ctx.p++;
|
|
634
|
+
break;
|
|
635
|
+
}
|
|
636
|
+
if (c < 32 && c !== 9 || c === 127) {
|
|
637
|
+
TomlError.x("control characters are not allowed in comments", ctx);
|
|
638
|
+
}
|
|
639
|
+
}
|
|
640
|
+
}
|
|
641
|
+
function skipVoid(ctx, banNewLines, banComments) {
|
|
642
|
+
let c;
|
|
643
|
+
while (ctx.p < ctx.s.length) {
|
|
644
|
+
while (ctx.p < ctx.s.length && ((c = ctx.s.charCodeAt(ctx.p)) === 32 || c === 9 || !banNewLines && (c === 10 || c === 13 && ctx.s.charCodeAt(ctx.p + 1) === 10)))
|
|
645
|
+
ctx.p++;
|
|
646
|
+
if (banComments || c !== 35)
|
|
647
|
+
break;
|
|
648
|
+
skipComment(ctx);
|
|
533
649
|
}
|
|
534
|
-
return parseValue(ctx, integersAsBigInt, end);
|
|
535
650
|
}
|
|
536
651
|
|
|
537
652
|
// node_modules/smol-toml/dist/struct.js
|
|
@@ -562,76 +677,50 @@ function extractValue(ctx, end, integersAsBigInt) {
|
|
|
562
677
|
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
563
678
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
564
679
|
*/
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
let
|
|
568
|
-
let dot = start - 1;
|
|
680
|
+
function parseKey(ctx, end = 61) {
|
|
681
|
+
let startPtr;
|
|
682
|
+
let state = 0;
|
|
569
683
|
let parsed = [];
|
|
570
|
-
let
|
|
571
|
-
|
|
572
|
-
throw new TomlError("incomplete key-value: cannot find end of key", {
|
|
573
|
-
toml: ctx.s,
|
|
574
|
-
ptr: start
|
|
575
|
-
});
|
|
576
|
-
}
|
|
684
|
+
let sliceStart;
|
|
685
|
+
let c = ctx.s.charCodeAt(startPtr = ctx.p);
|
|
577
686
|
do {
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
ptr: ctx.p
|
|
601
|
-
});
|
|
602
|
-
}
|
|
603
|
-
if (endPtr < ctx.p) {
|
|
604
|
-
endPtr = ctx.s.indexOf(end, ctx.p);
|
|
605
|
-
if (endPtr < 0) {
|
|
606
|
-
throw new TomlError("incomplete key-value: cannot find end of key", {
|
|
607
|
-
toml: ctx.s,
|
|
608
|
-
ptr: start
|
|
609
|
-
});
|
|
610
|
-
}
|
|
611
|
-
}
|
|
612
|
-
parsed.push(part);
|
|
613
|
-
} else {
|
|
614
|
-
dot = ctx.s.indexOf(".", ctx.p);
|
|
615
|
-
let part = ctx.s.slice(ctx.p, dot < 0 || dot > endPtr ? endPtr : dot);
|
|
616
|
-
if (!KEY_PART_RE.test(part)) {
|
|
617
|
-
throw new TomlError("only letter, numbers, dashes and underscores are allowed in keys", {
|
|
618
|
-
toml: ctx.s,
|
|
619
|
-
ptr: ctx.p
|
|
620
|
-
});
|
|
621
|
-
}
|
|
622
|
-
parsed.push(part.trimEnd());
|
|
687
|
+
if (c === end) {
|
|
688
|
+
if (!state)
|
|
689
|
+
TomlError.x("unexpected end of key", ctx);
|
|
690
|
+
if (state === 1)
|
|
691
|
+
parsed.push(ctx.s.slice(sliceStart, ctx.p));
|
|
692
|
+
return ctx.p++, parsed;
|
|
693
|
+
} else if (c === 46) {
|
|
694
|
+
if (!state)
|
|
695
|
+
TomlError.x("illegal empty bare key", ctx);
|
|
696
|
+
if (state === 1)
|
|
697
|
+
parsed.push(ctx.s.slice(sliceStart, ctx.p));
|
|
698
|
+
state = 0;
|
|
699
|
+
} else if (!state && (c === 34 || c === 39)) {
|
|
700
|
+
if (c === ctx.s.charCodeAt(ctx.p + 1) && c === ctx.s.charCodeAt(ctx.p + 2))
|
|
701
|
+
TomlError.x("illegal quoted key: multiline strings are not allowed", ctx);
|
|
702
|
+
parsed.push(parseString(ctx));
|
|
703
|
+
state = 2;
|
|
704
|
+
ctx.p--;
|
|
705
|
+
} else if (c === 32 || c === 9) {
|
|
706
|
+
if (state === 1) {
|
|
707
|
+
parsed.push(ctx.s.slice(sliceStart, ctx.p));
|
|
708
|
+
state = 2;
|
|
623
709
|
}
|
|
710
|
+
} else if (state === 2 || c < 48 && c !== 45 || c > 57 && c < 65 || c > 90 && c < 97 && c !== 95 || c > 122) {
|
|
711
|
+
TomlError.x("illegal character in key", ctx);
|
|
712
|
+
} else if (!state) {
|
|
713
|
+
state = 1;
|
|
714
|
+
sliceStart = ctx.p;
|
|
624
715
|
}
|
|
625
|
-
} while (
|
|
626
|
-
|
|
627
|
-
skipVoid(ctx, true, true);
|
|
628
|
-
return parsed;
|
|
716
|
+
} while (c = ctx.s.charCodeAt(++ctx.p));
|
|
717
|
+
TomlError.x("incomplete key-value: cannot find end of key", ctx, startPtr);
|
|
629
718
|
}
|
|
630
|
-
function parseInlineTable(ctx
|
|
631
|
-
let
|
|
719
|
+
function parseInlineTable(ctx) {
|
|
720
|
+
let startPtr = ctx.p++;
|
|
721
|
+
let res = Object.create(null);
|
|
632
722
|
let seen = new Set;
|
|
633
723
|
let c;
|
|
634
|
-
ctx.p++;
|
|
635
724
|
while (ctx.p < ctx.s.length) {
|
|
636
725
|
skipVoid(ctx);
|
|
637
726
|
if ((c = ctx.s.charCodeAt(ctx.p)) === 125) {
|
|
@@ -641,66 +730,59 @@ function parseInlineTable(ctx, integersAsBigInt) {
|
|
|
641
730
|
let k;
|
|
642
731
|
let t = res;
|
|
643
732
|
let hasOwn = false;
|
|
644
|
-
let
|
|
733
|
+
let errPtr = ctx.p;
|
|
645
734
|
let key = parseKey(ctx);
|
|
646
735
|
for (let i = 0;i < key.length; i++) {
|
|
647
736
|
if (i)
|
|
648
|
-
t = hasOwn ? t[k] : t[k] =
|
|
737
|
+
t = hasOwn ? t[k] : t[k] = Object.create(null);
|
|
649
738
|
k = key[i];
|
|
650
739
|
if ((hasOwn = Object.hasOwn(t, k)) && (typeof t[k] !== "object" || seen.has(t[k]))) {
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
740
|
+
TomlError.x("trying to redefine an already defined value", ctx, errPtr);
|
|
741
|
+
}
|
|
742
|
+
let unsafe = k === "__proto__";
|
|
743
|
+
if (ctx.uk && (unsafe || k === "constructor")) {
|
|
744
|
+
t = ctx.uk !== 1 && TomlError.x("document contains an unsafe property", ctx, errPtr);
|
|
745
|
+
break;
|
|
655
746
|
}
|
|
656
|
-
if (!hasOwn &&
|
|
747
|
+
if (!hasOwn && unsafe) {
|
|
657
748
|
Object.defineProperty(t, k, { enumerable: true, configurable: true, writable: true });
|
|
658
749
|
}
|
|
659
750
|
}
|
|
660
751
|
if (hasOwn) {
|
|
661
|
-
|
|
662
|
-
toml: ctx.s,
|
|
663
|
-
ptr: ctx.p
|
|
664
|
-
});
|
|
752
|
+
TomlError.x("trying to redefine an already defined value", ctx, errPtr);
|
|
665
753
|
}
|
|
666
|
-
|
|
667
|
-
|
|
754
|
+
skipVoid(ctx, true, true);
|
|
755
|
+
let value = extractValue(ctx, 125);
|
|
756
|
+
if (t && typeof (t[k] = value) === "object")
|
|
757
|
+
seen.add(value);
|
|
668
758
|
skipVoid(ctx);
|
|
669
759
|
if ((c = ctx.s.charCodeAt(ctx.p++)) === 125) {
|
|
670
760
|
return res;
|
|
671
761
|
}
|
|
672
|
-
if (c !== 44)
|
|
673
|
-
|
|
674
|
-
}
|
|
762
|
+
if (c !== 44)
|
|
763
|
+
TomlError.x("expected comma or end of structure", ctx, ctx.p - 1);
|
|
675
764
|
}
|
|
676
|
-
|
|
677
|
-
toml: ctx.s,
|
|
678
|
-
ptr: ctx.p
|
|
679
|
-
});
|
|
765
|
+
TomlError.x("unfinished table", ctx, startPtr);
|
|
680
766
|
}
|
|
681
|
-
function parseArray(ctx
|
|
767
|
+
function parseArray(ctx) {
|
|
768
|
+
let startPtr = ctx.p++;
|
|
682
769
|
let res = [];
|
|
683
770
|
let c;
|
|
684
|
-
ctx.p++;
|
|
685
771
|
while (ctx.p < ctx.s.length) {
|
|
686
772
|
skipVoid(ctx);
|
|
687
773
|
if ((c = ctx.s.charCodeAt(ctx.p)) === 93) {
|
|
688
774
|
ctx.p++;
|
|
689
775
|
return res;
|
|
690
776
|
}
|
|
691
|
-
res.push(extractValue(ctx, 93
|
|
777
|
+
res.push(extractValue(ctx, 93));
|
|
692
778
|
skipVoid(ctx);
|
|
693
779
|
if ((c = ctx.s.charCodeAt(ctx.p++)) === 93) {
|
|
694
780
|
return res;
|
|
695
781
|
}
|
|
696
|
-
if (c !== 44)
|
|
697
|
-
|
|
698
|
-
}
|
|
782
|
+
if (c !== 44)
|
|
783
|
+
TomlError.x("expected comma or end of structure", ctx, ctx.p - 1);
|
|
699
784
|
}
|
|
700
|
-
|
|
701
|
-
toml: ctx.s,
|
|
702
|
-
ptr: ctx.p
|
|
703
|
-
});
|
|
785
|
+
TomlError.x("unfinished array", ctx, startPtr);
|
|
704
786
|
}
|
|
705
787
|
|
|
706
788
|
// node_modules/smol-toml/dist/parse.js
|
|
@@ -731,7 +813,7 @@ function parseArray(ctx, integersAsBigInt) {
|
|
|
731
813
|
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
732
814
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
733
815
|
*/
|
|
734
|
-
function peekTable(key, table, meta, type) {
|
|
816
|
+
function peekTable(ctx, key, table, meta, type) {
|
|
735
817
|
let t = table;
|
|
736
818
|
let m = meta;
|
|
737
819
|
let k;
|
|
@@ -739,7 +821,7 @@ function peekTable(key, table, meta, type) {
|
|
|
739
821
|
let state;
|
|
740
822
|
for (let i = 0;i < key.length; i++) {
|
|
741
823
|
if (i) {
|
|
742
|
-
t = hasOwn ? t[k] : t[k] =
|
|
824
|
+
t = hasOwn ? t[k] : t[k] = Object.create(null);
|
|
743
825
|
m = (state = m[k]).c;
|
|
744
826
|
if (type === 0 && (state.t === 1 || state.t === 2)) {
|
|
745
827
|
return null;
|
|
@@ -755,7 +837,10 @@ function peekTable(key, table, meta, type) {
|
|
|
755
837
|
return null;
|
|
756
838
|
}
|
|
757
839
|
if (!hasOwn) {
|
|
758
|
-
|
|
840
|
+
let unsafe = k === "__proto__";
|
|
841
|
+
if (ctx.uk && (unsafe || k === "constructor"))
|
|
842
|
+
return false;
|
|
843
|
+
if (unsafe) {
|
|
759
844
|
Object.defineProperty(t, k, { enumerable: true, configurable: true, writable: true });
|
|
760
845
|
Object.defineProperty(m, k, { enumerable: true, configurable: true, writable: true });
|
|
761
846
|
}
|
|
@@ -763,7 +848,7 @@ function peekTable(key, table, meta, type) {
|
|
|
763
848
|
t: i < key.length - 1 && type === 2 ? 3 : type,
|
|
764
849
|
d: false,
|
|
765
850
|
i: 0,
|
|
766
|
-
c:
|
|
851
|
+
c: Object.create(null)
|
|
767
852
|
};
|
|
768
853
|
}
|
|
769
854
|
}
|
|
@@ -776,69 +861,76 @@ function peekTable(key, table, meta, type) {
|
|
|
776
861
|
state.d = true;
|
|
777
862
|
t[k] = [];
|
|
778
863
|
}
|
|
779
|
-
t[k].push(t =
|
|
780
|
-
state.c[state.i++] = state = { t: 1, d: false, i: 0, c:
|
|
864
|
+
t[k].push(t = Object.create(null));
|
|
865
|
+
state.c[state.i++] = state = { t: 1, d: false, i: 0, c: Object.create(null) };
|
|
781
866
|
}
|
|
782
867
|
if (state.d) {
|
|
783
868
|
return null;
|
|
784
869
|
}
|
|
785
870
|
state.d = true;
|
|
786
871
|
if (type === 1) {
|
|
787
|
-
t = hasOwn ? t[k] : t[k] =
|
|
872
|
+
t = hasOwn ? t[k] : t[k] = Object.create(null);
|
|
788
873
|
} else if (type === 0 && hasOwn) {
|
|
789
874
|
return null;
|
|
790
875
|
}
|
|
791
876
|
return [k, t, state.c];
|
|
792
877
|
}
|
|
793
|
-
function
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
878
|
+
function validateTablePeek(ctx, peek, ptr) {
|
|
879
|
+
if (peek === null || ctx.uk === 2)
|
|
880
|
+
TomlError.x(peek === null ? "trying to redefine an already defined table or value" : "document contains an unsafe property", ctx, ptr);
|
|
881
|
+
}
|
|
882
|
+
function parse(toml, options = {}) {
|
|
883
|
+
let ctx = {
|
|
884
|
+
s: toml,
|
|
885
|
+
p: 0,
|
|
886
|
+
d: options.maxDepth ?? 1000,
|
|
887
|
+
bi: options.integersAsBigInt ?? false,
|
|
888
|
+
ld: options.useLegacyDate ?? true,
|
|
889
|
+
uk: options.unsafeKeyBehaviour === "throw" ? 2 : options.unsafeKeyBehaviour === "drop" ? 1 : 0
|
|
890
|
+
};
|
|
891
|
+
let res = Object.create(null);
|
|
892
|
+
let meta = Object.create(null);
|
|
797
893
|
let tmp;
|
|
894
|
+
let skipping = false;
|
|
798
895
|
let tbl = res;
|
|
799
896
|
let m = meta;
|
|
897
|
+
if (toml.charCodeAt(0) === 65279)
|
|
898
|
+
ctx.p++;
|
|
800
899
|
skipVoid(ctx);
|
|
801
900
|
while (ctx.p < toml.length) {
|
|
802
901
|
if (toml.charCodeAt(ctx.p) === 91) {
|
|
803
902
|
let isTableArray = toml.charCodeAt(++ctx.p) === 91;
|
|
804
903
|
tmp = ctx.p += +isTableArray;
|
|
805
|
-
|
|
904
|
+
skipping = false;
|
|
905
|
+
let k = parseKey(ctx, 93);
|
|
806
906
|
if (isTableArray) {
|
|
807
|
-
if (toml.charCodeAt(ctx.p
|
|
808
|
-
|
|
809
|
-
toml,
|
|
810
|
-
ptr: ctx.p - 1
|
|
811
|
-
});
|
|
907
|
+
if (toml.charCodeAt(ctx.p) !== 93) {
|
|
908
|
+
TomlError.x("expected end of table array declaration", ctx);
|
|
812
909
|
}
|
|
813
910
|
ctx.p++;
|
|
814
911
|
}
|
|
815
|
-
let p = peekTable(k, res, meta, isTableArray ? 2 : 1);
|
|
912
|
+
let p = peekTable(ctx, k, res, meta, isTableArray ? 2 : 1);
|
|
816
913
|
if (!p) {
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
914
|
+
validateTablePeek(ctx, p, tmp);
|
|
915
|
+
skipping = true;
|
|
916
|
+
} else {
|
|
917
|
+
m = p[2];
|
|
918
|
+
tbl = p[1];
|
|
821
919
|
}
|
|
822
|
-
m = p[2];
|
|
823
|
-
tbl = p[1];
|
|
824
920
|
} else {
|
|
825
921
|
tmp = ctx.p;
|
|
826
922
|
let k = parseKey(ctx);
|
|
827
|
-
let p = peekTable(k, tbl, m, 0);
|
|
828
|
-
if (!p)
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
p[1][p[0]] = extractValue(ctx, undefined, integersAsBigInt);
|
|
923
|
+
let p = peekTable(ctx, k, tbl, m, 0);
|
|
924
|
+
if (!p && !skipping)
|
|
925
|
+
validateTablePeek(ctx, p, tmp);
|
|
926
|
+
skipVoid(ctx, true, true);
|
|
927
|
+
let v = extractValue(ctx, undefined);
|
|
928
|
+
if (p && !skipping)
|
|
929
|
+
p[1][p[0]] = v;
|
|
835
930
|
}
|
|
836
931
|
skipVoid(ctx, true);
|
|
837
|
-
if (ctx.p < toml.length && (tmp = toml.charCodeAt(ctx.p)) !== 10 && tmp !== 13) {
|
|
838
|
-
|
|
839
|
-
toml,
|
|
840
|
-
ptr: ctx.p
|
|
841
|
-
});
|
|
932
|
+
if (ctx.p < toml.length && (tmp = toml.charCodeAt(ctx.p)) !== 10 && (tmp !== 13 || toml.charCodeAt(ctx.p + 1) !== 10)) {
|
|
933
|
+
TomlError.x("each key-value declaration must be followed by an end-of-line", ctx);
|
|
842
934
|
}
|
|
843
935
|
skipVoid(ctx);
|
|
844
936
|
}
|
|
@@ -873,6 +965,7 @@ function parse(toml, { maxDepth = 1000, integersAsBigInt } = {}) {
|
|
|
873
965
|
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
874
966
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
875
967
|
*/
|
|
968
|
+
var HAS_WELLFORMED = !!"".isWellFormed;
|
|
876
969
|
|
|
877
970
|
// node_modules/smol-toml/dist/index.js
|
|
878
971
|
/*!
|
|
@@ -1217,7 +1310,7 @@ async function tick() {
|
|
|
1217
1310
|
try {
|
|
1218
1311
|
const configs = loadBots(registry);
|
|
1219
1312
|
for (const [name, worker] of workers) {
|
|
1220
|
-
const c = configs.find((
|
|
1313
|
+
const c = configs.find((c) => c.name === name);
|
|
1221
1314
|
if (!c || createHash2("sha256").update(JSON.stringify(c)).digest("hex") !== worker.fingerprint) {
|
|
1222
1315
|
await stop(worker);
|
|
1223
1316
|
workers.delete(name);
|