ADAPT-Chase commited on
Commit
d8ff51d
·
verified ·
1 Parent(s): df8451c

Add files using upload-large-folder tool

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. novas/novacore-zephyr/claude-code-router/node_modules/content-disposition/LICENSE +22 -0
  2. novas/novacore-zephyr/claude-code-router/node_modules/content-disposition/index.js +458 -0
  3. novas/novacore-zephyr/claude-code-router/node_modules/esbuild/LICENSE.md +21 -0
  4. novas/novacore-zephyr/claude-code-router/node_modules/esbuild/README.md +3 -0
  5. novas/novacore-zephyr/claude-code-router/node_modules/esbuild/install.js +289 -0
  6. novas/novacore-zephyr/claude-code-router/node_modules/esbuild/package.json +49 -0
  7. novas/novacore-zephyr/claude-code-router/node_modules/execa/index.js +361 -0
  8. novas/novacore-zephyr/claude-code-router/node_modules/execa/license +9 -0
  9. novas/novacore-zephyr/claude-code-router/node_modules/execa/package.json +69 -0
  10. novas/novacore-zephyr/claude-code-router/node_modules/execa/readme.md +327 -0
  11. novas/novacore-zephyr/claude-code-router/node_modules/fastify/.borp.yaml +3 -0
  12. novas/novacore-zephyr/claude-code-router/node_modules/fastify/.markdownlint-cli2.yaml +22 -0
  13. novas/novacore-zephyr/claude-code-router/node_modules/fastify/.prettierignore +1 -0
  14. novas/novacore-zephyr/claude-code-router/node_modules/fastify/GOVERNANCE.md +4 -0
  15. novas/novacore-zephyr/claude-code-router/node_modules/fastify/LICENSE +24 -0
  16. novas/novacore-zephyr/claude-code-router/node_modules/fastify/PROJECT_CHARTER.md +126 -0
  17. novas/novacore-zephyr/claude-code-router/node_modules/fastify/README.md +421 -0
  18. novas/novacore-zephyr/claude-code-router/node_modules/fastify/SECURITY.md +160 -0
  19. novas/novacore-zephyr/claude-code-router/node_modules/fastify/SPONSORS.md +23 -0
  20. novas/novacore-zephyr/claude-code-router/node_modules/fastify/eslint.config.js +19 -0
  21. novas/novacore-zephyr/claude-code-router/node_modules/fastify/fastify.d.ts +240 -0
  22. novas/novacore-zephyr/claude-code-router/node_modules/fastify/fastify.js +963 -0
  23. novas/novacore-zephyr/claude-code-router/node_modules/fastify/package.json +225 -0
  24. novas/novacore-zephyr/claude-code-router/node_modules/json5/LICENSE.md +23 -0
  25. novas/novacore-zephyr/claude-code-router/node_modules/json5/README.md +282 -0
  26. novas/novacore-zephyr/claude-code-router/node_modules/json5/package.json +72 -0
  27. novas/novacore-zephyr/claude-code-router/node_modules/openurl/.npmignore +3 -0
  28. novas/novacore-zephyr/claude-code-router/node_modules/openurl/README.md +29 -0
  29. novas/novacore-zephyr/claude-code-router/node_modules/openurl/openurl.js +68 -0
  30. novas/novacore-zephyr/claude-code-router/node_modules/openurl/package.json +16 -0
  31. novas/novacore-zephyr/claude-code-router/node_modules/pino-rotating-file-stream/LICENSE +21 -0
  32. novas/novacore-zephyr/claude-code-router/node_modules/pino-rotating-file-stream/README.md +57 -0
  33. novas/novacore-zephyr/claude-code-router/node_modules/pino-rotating-file-stream/package.json +53 -0
  34. novas/novacore-zephyr/claude-code-router/node_modules/pino-rotating-file-stream/tsconfig.cjs.json +8 -0
  35. novas/novacore-zephyr/claude-code-router/node_modules/pino-rotating-file-stream/tsconfig.json +32 -0
  36. novas/novacore-zephyr/claude-code-router/node_modules/pino-rotating-file-stream/tsconfig.mjs.json +8 -0
  37. novas/novacore-zephyr/claude-code-router/node_modules/shx/LICENSE +21 -0
  38. novas/novacore-zephyr/claude-code-router/node_modules/shx/README.md +160 -0
  39. novas/novacore-zephyr/claude-code-router/node_modules/shx/package.json +72 -0
  40. novas/novacore-zephyr/claude-code-router/node_modules/string-width-cjs/index.d.ts +29 -0
  41. novas/novacore-zephyr/claude-code-router/node_modules/string-width-cjs/index.js +47 -0
  42. novas/novacore-zephyr/claude-code-router/node_modules/string-width-cjs/license +9 -0
  43. novas/novacore-zephyr/claude-code-router/node_modules/string-width-cjs/package.json +56 -0
  44. novas/novacore-zephyr/claude-code-router/node_modules/string-width-cjs/readme.md +50 -0
  45. novas/novacore-zephyr/claude-code-router/node_modules/tiktoken/README.md +325 -0
  46. novas/novacore-zephyr/claude-code-router/node_modules/tiktoken/init.cjs +42 -0
  47. novas/novacore-zephyr/claude-code-router/node_modules/tiktoken/init.d.ts +2 -0
  48. novas/novacore-zephyr/claude-code-router/node_modules/tiktoken/init.js +20 -0
  49. novas/novacore-zephyr/claude-code-router/node_modules/tiktoken/lite.d.ts +1 -0
  50. novas/novacore-zephyr/claude-code-router/node_modules/tiktoken/load.cjs +170 -0
novas/novacore-zephyr/claude-code-router/node_modules/content-disposition/LICENSE ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ (The MIT License)
2
+
3
+ Copyright (c) 2014-2017 Douglas Christopher Wilson
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ 'Software'), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
novas/novacore-zephyr/claude-code-router/node_modules/content-disposition/index.js ADDED
@@ -0,0 +1,458 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*!
2
+ * content-disposition
3
+ * Copyright(c) 2014-2017 Douglas Christopher Wilson
4
+ * MIT Licensed
5
+ */
6
+
7
+ 'use strict'
8
+
9
+ /**
10
+ * Module exports.
11
+ * @public
12
+ */
13
+
14
+ module.exports = contentDisposition
15
+ module.exports.parse = parse
16
+
17
+ /**
18
+ * Module dependencies.
19
+ * @private
20
+ */
21
+
22
+ var basename = require('path').basename
23
+ var Buffer = require('safe-buffer').Buffer
24
+
25
+ /**
26
+ * RegExp to match non attr-char, *after* encodeURIComponent (i.e. not including "%")
27
+ * @private
28
+ */
29
+
30
+ var ENCODE_URL_ATTR_CHAR_REGEXP = /[\x00-\x20"'()*,/:;<=>?@[\\\]{}\x7f]/g // eslint-disable-line no-control-regex
31
+
32
+ /**
33
+ * RegExp to match percent encoding escape.
34
+ * @private
35
+ */
36
+
37
+ var HEX_ESCAPE_REGEXP = /%[0-9A-Fa-f]{2}/
38
+ var HEX_ESCAPE_REPLACE_REGEXP = /%([0-9A-Fa-f]{2})/g
39
+
40
+ /**
41
+ * RegExp to match non-latin1 characters.
42
+ * @private
43
+ */
44
+
45
+ var NON_LATIN1_REGEXP = /[^\x20-\x7e\xa0-\xff]/g
46
+
47
+ /**
48
+ * RegExp to match quoted-pair in RFC 2616
49
+ *
50
+ * quoted-pair = "\" CHAR
51
+ * CHAR = <any US-ASCII character (octets 0 - 127)>
52
+ * @private
53
+ */
54
+
55
+ var QESC_REGEXP = /\\([\u0000-\u007f])/g // eslint-disable-line no-control-regex
56
+
57
+ /**
58
+ * RegExp to match chars that must be quoted-pair in RFC 2616
59
+ * @private
60
+ */
61
+
62
+ var QUOTE_REGEXP = /([\\"])/g
63
+
64
+ /**
65
+ * RegExp for various RFC 2616 grammar
66
+ *
67
+ * parameter = token "=" ( token | quoted-string )
68
+ * token = 1*<any CHAR except CTLs or separators>
69
+ * separators = "(" | ")" | "<" | ">" | "@"
70
+ * | "," | ";" | ":" | "\" | <">
71
+ * | "/" | "[" | "]" | "?" | "="
72
+ * | "{" | "}" | SP | HT
73
+ * quoted-string = ( <"> *(qdtext | quoted-pair ) <"> )
74
+ * qdtext = <any TEXT except <">>
75
+ * quoted-pair = "\" CHAR
76
+ * CHAR = <any US-ASCII character (octets 0 - 127)>
77
+ * TEXT = <any OCTET except CTLs, but including LWS>
78
+ * LWS = [CRLF] 1*( SP | HT )
79
+ * CRLF = CR LF
80
+ * CR = <US-ASCII CR, carriage return (13)>
81
+ * LF = <US-ASCII LF, linefeed (10)>
82
+ * SP = <US-ASCII SP, space (32)>
83
+ * HT = <US-ASCII HT, horizontal-tab (9)>
84
+ * CTL = <any US-ASCII control character (octets 0 - 31) and DEL (127)>
85
+ * OCTET = <any 8-bit sequence of data>
86
+ * @private
87
+ */
88
+
89
+ var PARAM_REGEXP = /;[\x09\x20]*([!#$%&'*+.0-9A-Z^_`a-z|~-]+)[\x09\x20]*=[\x09\x20]*("(?:[\x20!\x23-\x5b\x5d-\x7e\x80-\xff]|\\[\x20-\x7e])*"|[!#$%&'*+.0-9A-Z^_`a-z|~-]+)[\x09\x20]*/g // eslint-disable-line no-control-regex
90
+ var TEXT_REGEXP = /^[\x20-\x7e\x80-\xff]+$/
91
+ var TOKEN_REGEXP = /^[!#$%&'*+.0-9A-Z^_`a-z|~-]+$/
92
+
93
+ /**
94
+ * RegExp for various RFC 5987 grammar
95
+ *
96
+ * ext-value = charset "'" [ language ] "'" value-chars
97
+ * charset = "UTF-8" / "ISO-8859-1" / mime-charset
98
+ * mime-charset = 1*mime-charsetc
99
+ * mime-charsetc = ALPHA / DIGIT
100
+ * / "!" / "#" / "$" / "%" / "&"
101
+ * / "+" / "-" / "^" / "_" / "`"
102
+ * / "{" / "}" / "~"
103
+ * language = ( 2*3ALPHA [ extlang ] )
104
+ * / 4ALPHA
105
+ * / 5*8ALPHA
106
+ * extlang = *3( "-" 3ALPHA )
107
+ * value-chars = *( pct-encoded / attr-char )
108
+ * pct-encoded = "%" HEXDIG HEXDIG
109
+ * attr-char = ALPHA / DIGIT
110
+ * / "!" / "#" / "$" / "&" / "+" / "-" / "."
111
+ * / "^" / "_" / "`" / "|" / "~"
112
+ * @private
113
+ */
114
+
115
+ var EXT_VALUE_REGEXP = /^([A-Za-z0-9!#$%&+\-^_`{}~]+)'(?:[A-Za-z]{2,3}(?:-[A-Za-z]{3}){0,3}|[A-Za-z]{4,8}|)'((?:%[0-9A-Fa-f]{2}|[A-Za-z0-9!#$&+.^_`|~-])+)$/
116
+
117
+ /**
118
+ * RegExp for various RFC 6266 grammar
119
+ *
120
+ * disposition-type = "inline" | "attachment" | disp-ext-type
121
+ * disp-ext-type = token
122
+ * disposition-parm = filename-parm | disp-ext-parm
123
+ * filename-parm = "filename" "=" value
124
+ * | "filename*" "=" ext-value
125
+ * disp-ext-parm = token "=" value
126
+ * | ext-token "=" ext-value
127
+ * ext-token = <the characters in token, followed by "*">
128
+ * @private
129
+ */
130
+
131
+ var DISPOSITION_TYPE_REGEXP = /^([!#$%&'*+.0-9A-Z^_`a-z|~-]+)[\x09\x20]*(?:$|;)/ // eslint-disable-line no-control-regex
132
+
133
+ /**
134
+ * Create an attachment Content-Disposition header.
135
+ *
136
+ * @param {string} [filename]
137
+ * @param {object} [options]
138
+ * @param {string} [options.type=attachment]
139
+ * @param {string|boolean} [options.fallback=true]
140
+ * @return {string}
141
+ * @public
142
+ */
143
+
144
+ function contentDisposition (filename, options) {
145
+ var opts = options || {}
146
+
147
+ // get type
148
+ var type = opts.type || 'attachment'
149
+
150
+ // get parameters
151
+ var params = createparams(filename, opts.fallback)
152
+
153
+ // format into string
154
+ return format(new ContentDisposition(type, params))
155
+ }
156
+
157
+ /**
158
+ * Create parameters object from filename and fallback.
159
+ *
160
+ * @param {string} [filename]
161
+ * @param {string|boolean} [fallback=true]
162
+ * @return {object}
163
+ * @private
164
+ */
165
+
166
+ function createparams (filename, fallback) {
167
+ if (filename === undefined) {
168
+ return
169
+ }
170
+
171
+ var params = {}
172
+
173
+ if (typeof filename !== 'string') {
174
+ throw new TypeError('filename must be a string')
175
+ }
176
+
177
+ // fallback defaults to true
178
+ if (fallback === undefined) {
179
+ fallback = true
180
+ }
181
+
182
+ if (typeof fallback !== 'string' && typeof fallback !== 'boolean') {
183
+ throw new TypeError('fallback must be a string or boolean')
184
+ }
185
+
186
+ if (typeof fallback === 'string' && NON_LATIN1_REGEXP.test(fallback)) {
187
+ throw new TypeError('fallback must be ISO-8859-1 string')
188
+ }
189
+
190
+ // restrict to file base name
191
+ var name = basename(filename)
192
+
193
+ // determine if name is suitable for quoted string
194
+ var isQuotedString = TEXT_REGEXP.test(name)
195
+
196
+ // generate fallback name
197
+ var fallbackName = typeof fallback !== 'string'
198
+ ? fallback && getlatin1(name)
199
+ : basename(fallback)
200
+ var hasFallback = typeof fallbackName === 'string' && fallbackName !== name
201
+
202
+ // set extended filename parameter
203
+ if (hasFallback || !isQuotedString || HEX_ESCAPE_REGEXP.test(name)) {
204
+ params['filename*'] = name
205
+ }
206
+
207
+ // set filename parameter
208
+ if (isQuotedString || hasFallback) {
209
+ params.filename = hasFallback
210
+ ? fallbackName
211
+ : name
212
+ }
213
+
214
+ return params
215
+ }
216
+
217
+ /**
218
+ * Format object to Content-Disposition header.
219
+ *
220
+ * @param {object} obj
221
+ * @param {string} obj.type
222
+ * @param {object} [obj.parameters]
223
+ * @return {string}
224
+ * @private
225
+ */
226
+
227
+ function format (obj) {
228
+ var parameters = obj.parameters
229
+ var type = obj.type
230
+
231
+ if (!type || typeof type !== 'string' || !TOKEN_REGEXP.test(type)) {
232
+ throw new TypeError('invalid type')
233
+ }
234
+
235
+ // start with normalized type
236
+ var string = String(type).toLowerCase()
237
+
238
+ // append parameters
239
+ if (parameters && typeof parameters === 'object') {
240
+ var param
241
+ var params = Object.keys(parameters).sort()
242
+
243
+ for (var i = 0; i < params.length; i++) {
244
+ param = params[i]
245
+
246
+ var val = param.substr(-1) === '*'
247
+ ? ustring(parameters[param])
248
+ : qstring(parameters[param])
249
+
250
+ string += '; ' + param + '=' + val
251
+ }
252
+ }
253
+
254
+ return string
255
+ }
256
+
257
+ /**
258
+ * Decode a RFC 5987 field value (gracefully).
259
+ *
260
+ * @param {string} str
261
+ * @return {string}
262
+ * @private
263
+ */
264
+
265
+ function decodefield (str) {
266
+ var match = EXT_VALUE_REGEXP.exec(str)
267
+
268
+ if (!match) {
269
+ throw new TypeError('invalid extended field value')
270
+ }
271
+
272
+ var charset = match[1].toLowerCase()
273
+ var encoded = match[2]
274
+ var value
275
+
276
+ // to binary string
277
+ var binary = encoded.replace(HEX_ESCAPE_REPLACE_REGEXP, pdecode)
278
+
279
+ switch (charset) {
280
+ case 'iso-8859-1':
281
+ value = getlatin1(binary)
282
+ break
283
+ case 'utf-8':
284
+ value = Buffer.from(binary, 'binary').toString('utf8')
285
+ break
286
+ default:
287
+ throw new TypeError('unsupported charset in extended field')
288
+ }
289
+
290
+ return value
291
+ }
292
+
293
+ /**
294
+ * Get ISO-8859-1 version of string.
295
+ *
296
+ * @param {string} val
297
+ * @return {string}
298
+ * @private
299
+ */
300
+
301
+ function getlatin1 (val) {
302
+ // simple Unicode -> ISO-8859-1 transformation
303
+ return String(val).replace(NON_LATIN1_REGEXP, '?')
304
+ }
305
+
306
+ /**
307
+ * Parse Content-Disposition header string.
308
+ *
309
+ * @param {string} string
310
+ * @return {object}
311
+ * @public
312
+ */
313
+
314
+ function parse (string) {
315
+ if (!string || typeof string !== 'string') {
316
+ throw new TypeError('argument string is required')
317
+ }
318
+
319
+ var match = DISPOSITION_TYPE_REGEXP.exec(string)
320
+
321
+ if (!match) {
322
+ throw new TypeError('invalid type format')
323
+ }
324
+
325
+ // normalize type
326
+ var index = match[0].length
327
+ var type = match[1].toLowerCase()
328
+
329
+ var key
330
+ var names = []
331
+ var params = {}
332
+ var value
333
+
334
+ // calculate index to start at
335
+ index = PARAM_REGEXP.lastIndex = match[0].substr(-1) === ';'
336
+ ? index - 1
337
+ : index
338
+
339
+ // match parameters
340
+ while ((match = PARAM_REGEXP.exec(string))) {
341
+ if (match.index !== index) {
342
+ throw new TypeError('invalid parameter format')
343
+ }
344
+
345
+ index += match[0].length
346
+ key = match[1].toLowerCase()
347
+ value = match[2]
348
+
349
+ if (names.indexOf(key) !== -1) {
350
+ throw new TypeError('invalid duplicate parameter')
351
+ }
352
+
353
+ names.push(key)
354
+
355
+ if (key.indexOf('*') + 1 === key.length) {
356
+ // decode extended value
357
+ key = key.slice(0, -1)
358
+ value = decodefield(value)
359
+
360
+ // overwrite existing value
361
+ params[key] = value
362
+ continue
363
+ }
364
+
365
+ if (typeof params[key] === 'string') {
366
+ continue
367
+ }
368
+
369
+ if (value[0] === '"') {
370
+ // remove quotes and escapes
371
+ value = value
372
+ .substr(1, value.length - 2)
373
+ .replace(QESC_REGEXP, '$1')
374
+ }
375
+
376
+ params[key] = value
377
+ }
378
+
379
+ if (index !== -1 && index !== string.length) {
380
+ throw new TypeError('invalid parameter format')
381
+ }
382
+
383
+ return new ContentDisposition(type, params)
384
+ }
385
+
386
+ /**
387
+ * Percent decode a single character.
388
+ *
389
+ * @param {string} str
390
+ * @param {string} hex
391
+ * @return {string}
392
+ * @private
393
+ */
394
+
395
+ function pdecode (str, hex) {
396
+ return String.fromCharCode(parseInt(hex, 16))
397
+ }
398
+
399
+ /**
400
+ * Percent encode a single character.
401
+ *
402
+ * @param {string} char
403
+ * @return {string}
404
+ * @private
405
+ */
406
+
407
+ function pencode (char) {
408
+ return '%' + String(char)
409
+ .charCodeAt(0)
410
+ .toString(16)
411
+ .toUpperCase()
412
+ }
413
+
414
+ /**
415
+ * Quote a string for HTTP.
416
+ *
417
+ * @param {string} val
418
+ * @return {string}
419
+ * @private
420
+ */
421
+
422
+ function qstring (val) {
423
+ var str = String(val)
424
+
425
+ return '"' + str.replace(QUOTE_REGEXP, '\\$1') + '"'
426
+ }
427
+
428
+ /**
429
+ * Encode a Unicode string for HTTP (RFC 5987).
430
+ *
431
+ * @param {string} val
432
+ * @return {string}
433
+ * @private
434
+ */
435
+
436
+ function ustring (val) {
437
+ var str = String(val)
438
+
439
+ // percent encode as UTF-8
440
+ var encoded = encodeURIComponent(str)
441
+ .replace(ENCODE_URL_ATTR_CHAR_REGEXP, pencode)
442
+
443
+ return 'UTF-8\'\'' + encoded
444
+ }
445
+
446
+ /**
447
+ * Class for parsed Content-Disposition header for v8 optimization
448
+ *
449
+ * @public
450
+ * @param {string} type
451
+ * @param {object} parameters
452
+ * @constructor
453
+ */
454
+
455
+ function ContentDisposition (type, parameters) {
456
+ this.type = type
457
+ this.parameters = parameters
458
+ }
novas/novacore-zephyr/claude-code-router/node_modules/esbuild/LICENSE.md ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ MIT License
2
+
3
+ Copyright (c) 2020 Evan Wallace
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
novas/novacore-zephyr/claude-code-router/node_modules/esbuild/README.md ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ # esbuild
2
+
3
+ This is a JavaScript bundler and minifier. See https://github.com/evanw/esbuild and the [JavaScript API documentation](https://esbuild.github.io/api/) for details.
novas/novacore-zephyr/claude-code-router/node_modules/esbuild/install.js ADDED
@@ -0,0 +1,289 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __copyProps = (to, from, except, desc) => {
9
+ if (from && typeof from === "object" || typeof from === "function") {
10
+ for (let key of __getOwnPropNames(from))
11
+ if (!__hasOwnProp.call(to, key) && key !== except)
12
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
13
+ }
14
+ return to;
15
+ };
16
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
17
+ // If the importer is in node compatibility mode or this is not an ESM
18
+ // file that has been converted to a CommonJS file using a Babel-
19
+ // compatible transform (i.e. "__esModule" has not been set), then set
20
+ // "default" to the CommonJS "module.exports" for node compatibility.
21
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
22
+ mod
23
+ ));
24
+
25
+ // lib/npm/node-platform.ts
26
+ var fs = require("fs");
27
+ var os = require("os");
28
+ var path = require("path");
29
+ var ESBUILD_BINARY_PATH = process.env.ESBUILD_BINARY_PATH || ESBUILD_BINARY_PATH;
30
+ var isValidBinaryPath = (x) => !!x && x !== "/usr/bin/esbuild";
31
+ var knownWindowsPackages = {
32
+ "win32 arm64 LE": "@esbuild/win32-arm64",
33
+ "win32 ia32 LE": "@esbuild/win32-ia32",
34
+ "win32 x64 LE": "@esbuild/win32-x64"
35
+ };
36
+ var knownUnixlikePackages = {
37
+ "aix ppc64 BE": "@esbuild/aix-ppc64",
38
+ "android arm64 LE": "@esbuild/android-arm64",
39
+ "darwin arm64 LE": "@esbuild/darwin-arm64",
40
+ "darwin x64 LE": "@esbuild/darwin-x64",
41
+ "freebsd arm64 LE": "@esbuild/freebsd-arm64",
42
+ "freebsd x64 LE": "@esbuild/freebsd-x64",
43
+ "linux arm LE": "@esbuild/linux-arm",
44
+ "linux arm64 LE": "@esbuild/linux-arm64",
45
+ "linux ia32 LE": "@esbuild/linux-ia32",
46
+ "linux mips64el LE": "@esbuild/linux-mips64el",
47
+ "linux ppc64 LE": "@esbuild/linux-ppc64",
48
+ "linux riscv64 LE": "@esbuild/linux-riscv64",
49
+ "linux s390x BE": "@esbuild/linux-s390x",
50
+ "linux x64 LE": "@esbuild/linux-x64",
51
+ "linux loong64 LE": "@esbuild/linux-loong64",
52
+ "netbsd arm64 LE": "@esbuild/netbsd-arm64",
53
+ "netbsd x64 LE": "@esbuild/netbsd-x64",
54
+ "openbsd arm64 LE": "@esbuild/openbsd-arm64",
55
+ "openbsd x64 LE": "@esbuild/openbsd-x64",
56
+ "sunos x64 LE": "@esbuild/sunos-x64"
57
+ };
58
+ var knownWebAssemblyFallbackPackages = {
59
+ "android arm LE": "@esbuild/android-arm",
60
+ "android x64 LE": "@esbuild/android-x64",
61
+ "openharmony arm64 LE": "@esbuild/openharmony-arm64"
62
+ };
63
+ function pkgAndSubpathForCurrentPlatform() {
64
+ let pkg;
65
+ let subpath;
66
+ let isWASM = false;
67
+ let platformKey = `${process.platform} ${os.arch()} ${os.endianness()}`;
68
+ if (platformKey in knownWindowsPackages) {
69
+ pkg = knownWindowsPackages[platformKey];
70
+ subpath = "esbuild.exe";
71
+ } else if (platformKey in knownUnixlikePackages) {
72
+ pkg = knownUnixlikePackages[platformKey];
73
+ subpath = "bin/esbuild";
74
+ } else if (platformKey in knownWebAssemblyFallbackPackages) {
75
+ pkg = knownWebAssemblyFallbackPackages[platformKey];
76
+ subpath = "bin/esbuild";
77
+ isWASM = true;
78
+ } else {
79
+ throw new Error(`Unsupported platform: ${platformKey}`);
80
+ }
81
+ return { pkg, subpath, isWASM };
82
+ }
83
+ function downloadedBinPath(pkg, subpath) {
84
+ const esbuildLibDir = path.dirname(require.resolve("esbuild"));
85
+ return path.join(esbuildLibDir, `downloaded-${pkg.replace("/", "-")}-${path.basename(subpath)}`);
86
+ }
87
+
88
+ // lib/npm/node-install.ts
89
+ var fs2 = require("fs");
90
+ var os2 = require("os");
91
+ var path2 = require("path");
92
+ var zlib = require("zlib");
93
+ var https = require("https");
94
+ var child_process = require("child_process");
95
+ var versionFromPackageJSON = require(path2.join(__dirname, "package.json")).version;
96
+ var toPath = path2.join(__dirname, "bin", "esbuild");
97
+ var isToPathJS = true;
98
+ function validateBinaryVersion(...command) {
99
+ command.push("--version");
100
+ let stdout;
101
+ try {
102
+ stdout = child_process.execFileSync(command.shift(), command, {
103
+ // Without this, this install script strangely crashes with the error
104
+ // "EACCES: permission denied, write" but only on Ubuntu Linux when node is
105
+ // installed from the Snap Store. This is not a problem when you download
106
+ // the official version of node. The problem appears to be that stderr
107
+ // (i.e. file descriptor 2) isn't writable?
108
+ //
109
+ // More info:
110
+ // - https://snapcraft.io/ (what the Snap Store is)
111
+ // - https://nodejs.org/dist/ (download the official version of node)
112
+ // - https://github.com/evanw/esbuild/issues/1711#issuecomment-1027554035
113
+ //
114
+ stdio: "pipe"
115
+ }).toString().trim();
116
+ } catch (err) {
117
+ if (os2.platform() === "darwin" && /_SecTrustEvaluateWithError/.test(err + "")) {
118
+ let os3 = "this version of macOS";
119
+ try {
120
+ os3 = "macOS " + child_process.execFileSync("sw_vers", ["-productVersion"]).toString().trim();
121
+ } catch {
122
+ }
123
+ throw new Error(`The "esbuild" package cannot be installed because ${os3} is too outdated.
124
+
125
+ The Go compiler (which esbuild relies on) no longer supports ${os3},
126
+ which means the "esbuild" binary executable can't be run. You can either:
127
+
128
+ * Update your version of macOS to one that the Go compiler supports
129
+ * Use the "esbuild-wasm" package instead of the "esbuild" package
130
+ * Build esbuild yourself using an older version of the Go compiler
131
+ `);
132
+ }
133
+ throw err;
134
+ }
135
+ if (stdout !== versionFromPackageJSON) {
136
+ throw new Error(`Expected ${JSON.stringify(versionFromPackageJSON)} but got ${JSON.stringify(stdout)}`);
137
+ }
138
+ }
139
+ function isYarn() {
140
+ const { npm_config_user_agent } = process.env;
141
+ if (npm_config_user_agent) {
142
+ return /\byarn\//.test(npm_config_user_agent);
143
+ }
144
+ return false;
145
+ }
146
+ function fetch(url) {
147
+ return new Promise((resolve, reject) => {
148
+ https.get(url, (res) => {
149
+ if ((res.statusCode === 301 || res.statusCode === 302) && res.headers.location)
150
+ return fetch(res.headers.location).then(resolve, reject);
151
+ if (res.statusCode !== 200)
152
+ return reject(new Error(`Server responded with ${res.statusCode}`));
153
+ let chunks = [];
154
+ res.on("data", (chunk) => chunks.push(chunk));
155
+ res.on("end", () => resolve(Buffer.concat(chunks)));
156
+ }).on("error", reject);
157
+ });
158
+ }
159
+ function extractFileFromTarGzip(buffer, subpath) {
160
+ try {
161
+ buffer = zlib.unzipSync(buffer);
162
+ } catch (err) {
163
+ throw new Error(`Invalid gzip data in archive: ${err && err.message || err}`);
164
+ }
165
+ let str = (i, n) => String.fromCharCode(...buffer.subarray(i, i + n)).replace(/\0.*$/, "");
166
+ let offset = 0;
167
+ subpath = `package/${subpath}`;
168
+ while (offset < buffer.length) {
169
+ let name = str(offset, 100);
170
+ let size = parseInt(str(offset + 124, 12), 8);
171
+ offset += 512;
172
+ if (!isNaN(size)) {
173
+ if (name === subpath) return buffer.subarray(offset, offset + size);
174
+ offset += size + 511 & ~511;
175
+ }
176
+ }
177
+ throw new Error(`Could not find ${JSON.stringify(subpath)} in archive`);
178
+ }
179
+ function installUsingNPM(pkg, subpath, binPath) {
180
+ const env = { ...process.env, npm_config_global: void 0 };
181
+ const esbuildLibDir = path2.dirname(require.resolve("esbuild"));
182
+ const installDir = path2.join(esbuildLibDir, "npm-install");
183
+ fs2.mkdirSync(installDir);
184
+ try {
185
+ fs2.writeFileSync(path2.join(installDir, "package.json"), "{}");
186
+ child_process.execSync(
187
+ `npm install --loglevel=error --prefer-offline --no-audit --progress=false ${pkg}@${versionFromPackageJSON}`,
188
+ { cwd: installDir, stdio: "pipe", env }
189
+ );
190
+ const installedBinPath = path2.join(installDir, "node_modules", pkg, subpath);
191
+ fs2.renameSync(installedBinPath, binPath);
192
+ } finally {
193
+ try {
194
+ removeRecursive(installDir);
195
+ } catch {
196
+ }
197
+ }
198
+ }
199
+ function removeRecursive(dir) {
200
+ for (const entry of fs2.readdirSync(dir)) {
201
+ const entryPath = path2.join(dir, entry);
202
+ let stats;
203
+ try {
204
+ stats = fs2.lstatSync(entryPath);
205
+ } catch {
206
+ continue;
207
+ }
208
+ if (stats.isDirectory()) removeRecursive(entryPath);
209
+ else fs2.unlinkSync(entryPath);
210
+ }
211
+ fs2.rmdirSync(dir);
212
+ }
213
+ function applyManualBinaryPathOverride(overridePath) {
214
+ const pathString = JSON.stringify(overridePath);
215
+ fs2.writeFileSync(toPath, `#!/usr/bin/env node
216
+ require('child_process').execFileSync(${pathString}, process.argv.slice(2), { stdio: 'inherit' });
217
+ `);
218
+ const libMain = path2.join(__dirname, "lib", "main.js");
219
+ const code = fs2.readFileSync(libMain, "utf8");
220
+ fs2.writeFileSync(libMain, `var ESBUILD_BINARY_PATH = ${pathString};
221
+ ${code}`);
222
+ }
223
+ function maybeOptimizePackage(binPath) {
224
+ const { isWASM } = pkgAndSubpathForCurrentPlatform();
225
+ if (os2.platform() !== "win32" && !isYarn() && !isWASM) {
226
+ const tempPath = path2.join(__dirname, "bin-esbuild");
227
+ try {
228
+ fs2.linkSync(binPath, tempPath);
229
+ fs2.renameSync(tempPath, toPath);
230
+ isToPathJS = false;
231
+ fs2.unlinkSync(tempPath);
232
+ } catch {
233
+ }
234
+ }
235
+ }
236
+ async function downloadDirectlyFromNPM(pkg, subpath, binPath) {
237
+ const url = `https://registry.npmjs.org/${pkg}/-/${pkg.replace("@esbuild/", "")}-${versionFromPackageJSON}.tgz`;
238
+ console.error(`[esbuild] Trying to download ${JSON.stringify(url)}`);
239
+ try {
240
+ fs2.writeFileSync(binPath, extractFileFromTarGzip(await fetch(url), subpath));
241
+ fs2.chmodSync(binPath, 493);
242
+ } catch (e) {
243
+ console.error(`[esbuild] Failed to download ${JSON.stringify(url)}: ${e && e.message || e}`);
244
+ throw e;
245
+ }
246
+ }
247
+ async function checkAndPreparePackage() {
248
+ if (isValidBinaryPath(ESBUILD_BINARY_PATH)) {
249
+ if (!fs2.existsSync(ESBUILD_BINARY_PATH)) {
250
+ console.warn(`[esbuild] Ignoring bad configuration: ESBUILD_BINARY_PATH=${ESBUILD_BINARY_PATH}`);
251
+ } else {
252
+ applyManualBinaryPathOverride(ESBUILD_BINARY_PATH);
253
+ return;
254
+ }
255
+ }
256
+ const { pkg, subpath } = pkgAndSubpathForCurrentPlatform();
257
+ let binPath;
258
+ try {
259
+ binPath = require.resolve(`${pkg}/${subpath}`);
260
+ } catch (e) {
261
+ console.error(`[esbuild] Failed to find package "${pkg}" on the file system
262
+
263
+ This can happen if you use the "--no-optional" flag. The "optionalDependencies"
264
+ package.json feature is used by esbuild to install the correct binary executable
265
+ for your current platform. This install script will now attempt to work around
266
+ this. If that fails, you need to remove the "--no-optional" flag to use esbuild.
267
+ `);
268
+ binPath = downloadedBinPath(pkg, subpath);
269
+ try {
270
+ console.error(`[esbuild] Trying to install package "${pkg}" using npm`);
271
+ installUsingNPM(pkg, subpath, binPath);
272
+ } catch (e2) {
273
+ console.error(`[esbuild] Failed to install package "${pkg}" using npm: ${e2 && e2.message || e2}`);
274
+ try {
275
+ await downloadDirectlyFromNPM(pkg, subpath, binPath);
276
+ } catch (e3) {
277
+ throw new Error(`Failed to install package "${pkg}"`);
278
+ }
279
+ }
280
+ }
281
+ maybeOptimizePackage(binPath);
282
+ }
283
+ checkAndPreparePackage().then(() => {
284
+ if (isToPathJS) {
285
+ validateBinaryVersion(process.execPath, toPath);
286
+ } else {
287
+ validateBinaryVersion(toPath);
288
+ }
289
+ });
novas/novacore-zephyr/claude-code-router/node_modules/esbuild/package.json ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "esbuild",
3
+ "version": "0.25.9",
4
+ "description": "An extremely fast JavaScript and CSS bundler and minifier.",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "git+https://github.com/evanw/esbuild.git"
8
+ },
9
+ "scripts": {
10
+ "postinstall": "node install.js"
11
+ },
12
+ "main": "lib/main.js",
13
+ "types": "lib/main.d.ts",
14
+ "engines": {
15
+ "node": ">=18"
16
+ },
17
+ "bin": {
18
+ "esbuild": "bin/esbuild"
19
+ },
20
+ "optionalDependencies": {
21
+ "@esbuild/aix-ppc64": "0.25.9",
22
+ "@esbuild/android-arm": "0.25.9",
23
+ "@esbuild/android-arm64": "0.25.9",
24
+ "@esbuild/android-x64": "0.25.9",
25
+ "@esbuild/darwin-arm64": "0.25.9",
26
+ "@esbuild/darwin-x64": "0.25.9",
27
+ "@esbuild/freebsd-arm64": "0.25.9",
28
+ "@esbuild/freebsd-x64": "0.25.9",
29
+ "@esbuild/linux-arm": "0.25.9",
30
+ "@esbuild/linux-arm64": "0.25.9",
31
+ "@esbuild/linux-ia32": "0.25.9",
32
+ "@esbuild/linux-loong64": "0.25.9",
33
+ "@esbuild/linux-mips64el": "0.25.9",
34
+ "@esbuild/linux-ppc64": "0.25.9",
35
+ "@esbuild/linux-riscv64": "0.25.9",
36
+ "@esbuild/linux-s390x": "0.25.9",
37
+ "@esbuild/linux-x64": "0.25.9",
38
+ "@esbuild/netbsd-arm64": "0.25.9",
39
+ "@esbuild/netbsd-x64": "0.25.9",
40
+ "@esbuild/openbsd-arm64": "0.25.9",
41
+ "@esbuild/openbsd-x64": "0.25.9",
42
+ "@esbuild/openharmony-arm64": "0.25.9",
43
+ "@esbuild/sunos-x64": "0.25.9",
44
+ "@esbuild/win32-arm64": "0.25.9",
45
+ "@esbuild/win32-ia32": "0.25.9",
46
+ "@esbuild/win32-x64": "0.25.9"
47
+ },
48
+ "license": "MIT"
49
+ }
novas/novacore-zephyr/claude-code-router/node_modules/execa/index.js ADDED
@@ -0,0 +1,361 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 'use strict';
2
+ const path = require('path');
3
+ const childProcess = require('child_process');
4
+ const crossSpawn = require('cross-spawn');
5
+ const stripEof = require('strip-eof');
6
+ const npmRunPath = require('npm-run-path');
7
+ const isStream = require('is-stream');
8
+ const _getStream = require('get-stream');
9
+ const pFinally = require('p-finally');
10
+ const onExit = require('signal-exit');
11
+ const errname = require('./lib/errname');
12
+ const stdio = require('./lib/stdio');
13
+
14
+ const TEN_MEGABYTES = 1000 * 1000 * 10;
15
+
16
+ function handleArgs(cmd, args, opts) {
17
+ let parsed;
18
+
19
+ opts = Object.assign({
20
+ extendEnv: true,
21
+ env: {}
22
+ }, opts);
23
+
24
+ if (opts.extendEnv) {
25
+ opts.env = Object.assign({}, process.env, opts.env);
26
+ }
27
+
28
+ if (opts.__winShell === true) {
29
+ delete opts.__winShell;
30
+ parsed = {
31
+ command: cmd,
32
+ args,
33
+ options: opts,
34
+ file: cmd,
35
+ original: {
36
+ cmd,
37
+ args
38
+ }
39
+ };
40
+ } else {
41
+ parsed = crossSpawn._parse(cmd, args, opts);
42
+ }
43
+
44
+ opts = Object.assign({
45
+ maxBuffer: TEN_MEGABYTES,
46
+ buffer: true,
47
+ stripEof: true,
48
+ preferLocal: true,
49
+ localDir: parsed.options.cwd || process.cwd(),
50
+ encoding: 'utf8',
51
+ reject: true,
52
+ cleanup: true
53
+ }, parsed.options);
54
+
55
+ opts.stdio = stdio(opts);
56
+
57
+ if (opts.preferLocal) {
58
+ opts.env = npmRunPath.env(Object.assign({}, opts, {cwd: opts.localDir}));
59
+ }
60
+
61
+ if (opts.detached) {
62
+ // #115
63
+ opts.cleanup = false;
64
+ }
65
+
66
+ if (process.platform === 'win32' && path.basename(parsed.command) === 'cmd.exe') {
67
+ // #116
68
+ parsed.args.unshift('/q');
69
+ }
70
+
71
+ return {
72
+ cmd: parsed.command,
73
+ args: parsed.args,
74
+ opts,
75
+ parsed
76
+ };
77
+ }
78
+
79
+ function handleInput(spawned, input) {
80
+ if (input === null || input === undefined) {
81
+ return;
82
+ }
83
+
84
+ if (isStream(input)) {
85
+ input.pipe(spawned.stdin);
86
+ } else {
87
+ spawned.stdin.end(input);
88
+ }
89
+ }
90
+
91
+ function handleOutput(opts, val) {
92
+ if (val && opts.stripEof) {
93
+ val = stripEof(val);
94
+ }
95
+
96
+ return val;
97
+ }
98
+
99
+ function handleShell(fn, cmd, opts) {
100
+ let file = '/bin/sh';
101
+ let args = ['-c', cmd];
102
+
103
+ opts = Object.assign({}, opts);
104
+
105
+ if (process.platform === 'win32') {
106
+ opts.__winShell = true;
107
+ file = process.env.comspec || 'cmd.exe';
108
+ args = ['/s', '/c', `"${cmd}"`];
109
+ opts.windowsVerbatimArguments = true;
110
+ }
111
+
112
+ if (opts.shell) {
113
+ file = opts.shell;
114
+ delete opts.shell;
115
+ }
116
+
117
+ return fn(file, args, opts);
118
+ }
119
+
120
+ function getStream(process, stream, {encoding, buffer, maxBuffer}) {
121
+ if (!process[stream]) {
122
+ return null;
123
+ }
124
+
125
+ let ret;
126
+
127
+ if (!buffer) {
128
+ // TODO: Use `ret = util.promisify(stream.finished)(process[stream]);` when targeting Node.js 10
129
+ ret = new Promise((resolve, reject) => {
130
+ process[stream]
131
+ .once('end', resolve)
132
+ .once('error', reject);
133
+ });
134
+ } else if (encoding) {
135
+ ret = _getStream(process[stream], {
136
+ encoding,
137
+ maxBuffer
138
+ });
139
+ } else {
140
+ ret = _getStream.buffer(process[stream], {maxBuffer});
141
+ }
142
+
143
+ return ret.catch(err => {
144
+ err.stream = stream;
145
+ err.message = `${stream} ${err.message}`;
146
+ throw err;
147
+ });
148
+ }
149
+
150
+ function makeError(result, options) {
151
+ const {stdout, stderr} = result;
152
+
153
+ let err = result.error;
154
+ const {code, signal} = result;
155
+
156
+ const {parsed, joinedCmd} = options;
157
+ const timedOut = options.timedOut || false;
158
+
159
+ if (!err) {
160
+ let output = '';
161
+
162
+ if (Array.isArray(parsed.opts.stdio)) {
163
+ if (parsed.opts.stdio[2] !== 'inherit') {
164
+ output += output.length > 0 ? stderr : `\n${stderr}`;
165
+ }
166
+
167
+ if (parsed.opts.stdio[1] !== 'inherit') {
168
+ output += `\n${stdout}`;
169
+ }
170
+ } else if (parsed.opts.stdio !== 'inherit') {
171
+ output = `\n${stderr}${stdout}`;
172
+ }
173
+
174
+ err = new Error(`Command failed: ${joinedCmd}${output}`);
175
+ err.code = code < 0 ? errname(code) : code;
176
+ }
177
+
178
+ err.stdout = stdout;
179
+ err.stderr = stderr;
180
+ err.failed = true;
181
+ err.signal = signal || null;
182
+ err.cmd = joinedCmd;
183
+ err.timedOut = timedOut;
184
+
185
+ return err;
186
+ }
187
+
188
+ function joinCmd(cmd, args) {
189
+ let joinedCmd = cmd;
190
+
191
+ if (Array.isArray(args) && args.length > 0) {
192
+ joinedCmd += ' ' + args.join(' ');
193
+ }
194
+
195
+ return joinedCmd;
196
+ }
197
+
198
+ module.exports = (cmd, args, opts) => {
199
+ const parsed = handleArgs(cmd, args, opts);
200
+ const {encoding, buffer, maxBuffer} = parsed.opts;
201
+ const joinedCmd = joinCmd(cmd, args);
202
+
203
+ let spawned;
204
+ try {
205
+ spawned = childProcess.spawn(parsed.cmd, parsed.args, parsed.opts);
206
+ } catch (err) {
207
+ return Promise.reject(err);
208
+ }
209
+
210
+ let removeExitHandler;
211
+ if (parsed.opts.cleanup) {
212
+ removeExitHandler = onExit(() => {
213
+ spawned.kill();
214
+ });
215
+ }
216
+
217
+ let timeoutId = null;
218
+ let timedOut = false;
219
+
220
+ const cleanup = () => {
221
+ if (timeoutId) {
222
+ clearTimeout(timeoutId);
223
+ timeoutId = null;
224
+ }
225
+
226
+ if (removeExitHandler) {
227
+ removeExitHandler();
228
+ }
229
+ };
230
+
231
+ if (parsed.opts.timeout > 0) {
232
+ timeoutId = setTimeout(() => {
233
+ timeoutId = null;
234
+ timedOut = true;
235
+ spawned.kill(parsed.opts.killSignal);
236
+ }, parsed.opts.timeout);
237
+ }
238
+
239
+ const processDone = new Promise(resolve => {
240
+ spawned.on('exit', (code, signal) => {
241
+ cleanup();
242
+ resolve({code, signal});
243
+ });
244
+
245
+ spawned.on('error', err => {
246
+ cleanup();
247
+ resolve({error: err});
248
+ });
249
+
250
+ if (spawned.stdin) {
251
+ spawned.stdin.on('error', err => {
252
+ cleanup();
253
+ resolve({error: err});
254
+ });
255
+ }
256
+ });
257
+
258
+ function destroy() {
259
+ if (spawned.stdout) {
260
+ spawned.stdout.destroy();
261
+ }
262
+
263
+ if (spawned.stderr) {
264
+ spawned.stderr.destroy();
265
+ }
266
+ }
267
+
268
+ const handlePromise = () => pFinally(Promise.all([
269
+ processDone,
270
+ getStream(spawned, 'stdout', {encoding, buffer, maxBuffer}),
271
+ getStream(spawned, 'stderr', {encoding, buffer, maxBuffer})
272
+ ]).then(arr => {
273
+ const result = arr[0];
274
+ result.stdout = arr[1];
275
+ result.stderr = arr[2];
276
+
277
+ if (result.error || result.code !== 0 || result.signal !== null) {
278
+ const err = makeError(result, {
279
+ joinedCmd,
280
+ parsed,
281
+ timedOut
282
+ });
283
+
284
+ // TODO: missing some timeout logic for killed
285
+ // https://github.com/nodejs/node/blob/master/lib/child_process.js#L203
286
+ // err.killed = spawned.killed || killed;
287
+ err.killed = err.killed || spawned.killed;
288
+
289
+ if (!parsed.opts.reject) {
290
+ return err;
291
+ }
292
+
293
+ throw err;
294
+ }
295
+
296
+ return {
297
+ stdout: handleOutput(parsed.opts, result.stdout),
298
+ stderr: handleOutput(parsed.opts, result.stderr),
299
+ code: 0,
300
+ failed: false,
301
+ killed: false,
302
+ signal: null,
303
+ cmd: joinedCmd,
304
+ timedOut: false
305
+ };
306
+ }), destroy);
307
+
308
+ crossSpawn._enoent.hookChildProcess(spawned, parsed.parsed);
309
+
310
+ handleInput(spawned, parsed.opts.input);
311
+
312
+ spawned.then = (onfulfilled, onrejected) => handlePromise().then(onfulfilled, onrejected);
313
+ spawned.catch = onrejected => handlePromise().catch(onrejected);
314
+
315
+ return spawned;
316
+ };
317
+
318
+ // TODO: set `stderr: 'ignore'` when that option is implemented
319
+ module.exports.stdout = (...args) => module.exports(...args).then(x => x.stdout);
320
+
321
+ // TODO: set `stdout: 'ignore'` when that option is implemented
322
+ module.exports.stderr = (...args) => module.exports(...args).then(x => x.stderr);
323
+
324
+ module.exports.shell = (cmd, opts) => handleShell(module.exports, cmd, opts);
325
+
326
+ module.exports.sync = (cmd, args, opts) => {
327
+ const parsed = handleArgs(cmd, args, opts);
328
+ const joinedCmd = joinCmd(cmd, args);
329
+
330
+ if (isStream(parsed.opts.input)) {
331
+ throw new TypeError('The `input` option cannot be a stream in sync mode');
332
+ }
333
+
334
+ const result = childProcess.spawnSync(parsed.cmd, parsed.args, parsed.opts);
335
+ result.code = result.status;
336
+
337
+ if (result.error || result.status !== 0 || result.signal !== null) {
338
+ const err = makeError(result, {
339
+ joinedCmd,
340
+ parsed
341
+ });
342
+
343
+ if (!parsed.opts.reject) {
344
+ return err;
345
+ }
346
+
347
+ throw err;
348
+ }
349
+
350
+ return {
351
+ stdout: handleOutput(parsed.opts, result.stdout),
352
+ stderr: handleOutput(parsed.opts, result.stderr),
353
+ code: 0,
354
+ failed: false,
355
+ signal: null,
356
+ cmd: joinedCmd,
357
+ timedOut: false
358
+ };
359
+ };
360
+
361
+ module.exports.shellSync = (cmd, opts) => handleShell(module.exports.sync, cmd, opts);
novas/novacore-zephyr/claude-code-router/node_modules/execa/license ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ MIT License
2
+
3
+ Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
+
7
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
novas/novacore-zephyr/claude-code-router/node_modules/execa/package.json ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "execa",
3
+ "version": "1.0.0",
4
+ "description": "A better `child_process`",
5
+ "license": "MIT",
6
+ "repository": "sindresorhus/execa",
7
+ "author": {
8
+ "name": "Sindre Sorhus",
9
+ "email": "sindresorhus@gmail.com",
10
+ "url": "sindresorhus.com"
11
+ },
12
+ "engines": {
13
+ "node": ">=6"
14
+ },
15
+ "scripts": {
16
+ "test": "xo && nyc ava"
17
+ },
18
+ "files": [
19
+ "index.js",
20
+ "lib"
21
+ ],
22
+ "keywords": [
23
+ "exec",
24
+ "child",
25
+ "process",
26
+ "execute",
27
+ "fork",
28
+ "execfile",
29
+ "spawn",
30
+ "file",
31
+ "shell",
32
+ "bin",
33
+ "binary",
34
+ "binaries",
35
+ "npm",
36
+ "path",
37
+ "local"
38
+ ],
39
+ "dependencies": {
40
+ "cross-spawn": "^6.0.0",
41
+ "get-stream": "^4.0.0",
42
+ "is-stream": "^1.1.0",
43
+ "npm-run-path": "^2.0.0",
44
+ "p-finally": "^1.0.0",
45
+ "signal-exit": "^3.0.0",
46
+ "strip-eof": "^1.0.0"
47
+ },
48
+ "devDependencies": {
49
+ "ava": "*",
50
+ "cat-names": "^1.0.2",
51
+ "coveralls": "^3.0.1",
52
+ "delay": "^3.0.0",
53
+ "is-running": "^2.0.0",
54
+ "nyc": "^13.0.1",
55
+ "tempfile": "^2.0.0",
56
+ "xo": "*"
57
+ },
58
+ "nyc": {
59
+ "reporter": [
60
+ "text",
61
+ "lcov"
62
+ ],
63
+ "exclude": [
64
+ "**/fixtures/**",
65
+ "**/test.js",
66
+ "**/test/**"
67
+ ]
68
+ }
69
+ }
novas/novacore-zephyr/claude-code-router/node_modules/execa/readme.md ADDED
@@ -0,0 +1,327 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # execa [![Build Status: Linux](https://travis-ci.org/sindresorhus/execa.svg?branch=master)](https://travis-ci.org/sindresorhus/execa) [![Build status: Windows](https://ci.appveyor.com/api/projects/status/x5ajamxtjtt93cqv/branch/master?svg=true)](https://ci.appveyor.com/project/sindresorhus/execa/branch/master) [![Coverage Status](https://coveralls.io/repos/github/sindresorhus/execa/badge.svg?branch=master)](https://coveralls.io/github/sindresorhus/execa?branch=master)
2
+
3
+ > A better [`child_process`](https://nodejs.org/api/child_process.html)
4
+
5
+
6
+ ## Why
7
+
8
+ - Promise interface.
9
+ - [Strips EOF](https://github.com/sindresorhus/strip-eof) from the output so you don't have to `stdout.trim()`.
10
+ - Supports [shebang](https://en.wikipedia.org/wiki/Shebang_(Unix)) binaries cross-platform.
11
+ - [Improved Windows support.](https://github.com/IndigoUnited/node-cross-spawn#why)
12
+ - Higher max buffer. 10 MB instead of 200 KB.
13
+ - [Executes locally installed binaries by name.](#preferlocal)
14
+ - [Cleans up spawned processes when the parent process dies.](#cleanup)
15
+
16
+
17
+ ## Install
18
+
19
+ ```
20
+ $ npm install execa
21
+ ```
22
+
23
+ <a href="https://www.patreon.com/sindresorhus">
24
+ <img src="https://c5.patreon.com/external/logo/become_a_patron_button@2x.png" width="160">
25
+ </a>
26
+
27
+
28
+ ## Usage
29
+
30
+ ```js
31
+ const execa = require('execa');
32
+
33
+ (async () => {
34
+ const {stdout} = await execa('echo', ['unicorns']);
35
+ console.log(stdout);
36
+ //=> 'unicorns'
37
+ })();
38
+ ```
39
+
40
+ Additional examples:
41
+
42
+ ```js
43
+ const execa = require('execa');
44
+
45
+ (async () => {
46
+ // Pipe the child process stdout to the current stdout
47
+ execa('echo', ['unicorns']).stdout.pipe(process.stdout);
48
+
49
+
50
+ // Run a shell command
51
+ const {stdout} = await execa.shell('echo unicorns');
52
+ //=> 'unicorns'
53
+
54
+
55
+ // Catching an error
56
+ try {
57
+ await execa.shell('exit 3');
58
+ } catch (error) {
59
+ console.log(error);
60
+ /*
61
+ {
62
+ message: 'Command failed: /bin/sh -c exit 3'
63
+ killed: false,
64
+ code: 3,
65
+ signal: null,
66
+ cmd: '/bin/sh -c exit 3',
67
+ stdout: '',
68
+ stderr: '',
69
+ timedOut: false
70
+ }
71
+ */
72
+ }
73
+ })();
74
+
75
+ // Catching an error with a sync method
76
+ try {
77
+ execa.shellSync('exit 3');
78
+ } catch (error) {
79
+ console.log(error);
80
+ /*
81
+ {
82
+ message: 'Command failed: /bin/sh -c exit 3'
83
+ code: 3,
84
+ signal: null,
85
+ cmd: '/bin/sh -c exit 3',
86
+ stdout: '',
87
+ stderr: '',
88
+ timedOut: false
89
+ }
90
+ */
91
+ }
92
+ ```
93
+
94
+
95
+ ## API
96
+
97
+ ### execa(file, [arguments], [options])
98
+
99
+ Execute a file.
100
+
101
+ Think of this as a mix of `child_process.execFile` and `child_process.spawn`.
102
+
103
+ Returns a [`child_process` instance](https://nodejs.org/api/child_process.html#child_process_class_childprocess), which is enhanced to also be a `Promise` for a result `Object` with `stdout` and `stderr` properties.
104
+
105
+ ### execa.stdout(file, [arguments], [options])
106
+
107
+ Same as `execa()`, but returns only `stdout`.
108
+
109
+ ### execa.stderr(file, [arguments], [options])
110
+
111
+ Same as `execa()`, but returns only `stderr`.
112
+
113
+ ### execa.shell(command, [options])
114
+
115
+ Execute a command through the system shell. Prefer `execa()` whenever possible, as it's both faster and safer.
116
+
117
+ Returns a [`child_process` instance](https://nodejs.org/api/child_process.html#child_process_class_childprocess).
118
+
119
+ The `child_process` instance is enhanced to also be promise for a result object with `stdout` and `stderr` properties.
120
+
121
+ ### execa.sync(file, [arguments], [options])
122
+
123
+ Execute a file synchronously.
124
+
125
+ Returns the same result object as [`child_process.spawnSync`](https://nodejs.org/api/child_process.html#child_process_child_process_spawnsync_command_args_options).
126
+
127
+ This method throws an `Error` if the command fails.
128
+
129
+ ### execa.shellSync(file, [options])
130
+
131
+ Execute a command synchronously through the system shell.
132
+
133
+ Returns the same result object as [`child_process.spawnSync`](https://nodejs.org/api/child_process.html#child_process_child_process_spawnsync_command_args_options).
134
+
135
+ ### options
136
+
137
+ Type: `Object`
138
+
139
+ #### cwd
140
+
141
+ Type: `string`<br>
142
+ Default: `process.cwd()`
143
+
144
+ Current working directory of the child process.
145
+
146
+ #### env
147
+
148
+ Type: `Object`<br>
149
+ Default: `process.env`
150
+
151
+ Environment key-value pairs. Extends automatically from `process.env`. Set `extendEnv` to `false` if you don't want this.
152
+
153
+ #### extendEnv
154
+
155
+ Type: `boolean`<br>
156
+ Default: `true`
157
+
158
+ Set to `false` if you don't want to extend the environment variables when providing the `env` property.
159
+
160
+ #### argv0
161
+
162
+ Type: `string`
163
+
164
+ Explicitly set the value of `argv[0]` sent to the child process. This will be set to `command` or `file` if not specified.
165
+
166
+ #### stdio
167
+
168
+ Type: `string[]` `string`<br>
169
+ Default: `pipe`
170
+
171
+ Child's [stdio](https://nodejs.org/api/child_process.html#child_process_options_stdio) configuration.
172
+
173
+ #### detached
174
+
175
+ Type: `boolean`
176
+
177
+ Prepare child to run independently of its parent process. Specific behavior [depends on the platform](https://nodejs.org/api/child_process.html#child_process_options_detached).
178
+
179
+ #### uid
180
+
181
+ Type: `number`
182
+
183
+ Sets the user identity of the process.
184
+
185
+ #### gid
186
+
187
+ Type: `number`
188
+
189
+ Sets the group identity of the process.
190
+
191
+ #### shell
192
+
193
+ Type: `boolean` `string`<br>
194
+ Default: `false`
195
+
196
+ If `true`, runs `command` inside of a shell. Uses `/bin/sh` on UNIX and `cmd.exe` on Windows. A different shell can be specified as a string. The shell should understand the `-c` switch on UNIX or `/d /s /c` on Windows.
197
+
198
+ #### stripEof
199
+
200
+ Type: `boolean`<br>
201
+ Default: `true`
202
+
203
+ [Strip EOF](https://github.com/sindresorhus/strip-eof) (last newline) from the output.
204
+
205
+ #### preferLocal
206
+
207
+ Type: `boolean`<br>
208
+ Default: `true`
209
+
210
+ Prefer locally installed binaries when looking for a binary to execute.<br>
211
+ If you `$ npm install foo`, you can then `execa('foo')`.
212
+
213
+ #### localDir
214
+
215
+ Type: `string`<br>
216
+ Default: `process.cwd()`
217
+
218
+ Preferred path to find locally installed binaries in (use with `preferLocal`).
219
+
220
+ #### input
221
+
222
+ Type: `string` `Buffer` `stream.Readable`
223
+
224
+ Write some input to the `stdin` of your binary.<br>
225
+ Streams are not allowed when using the synchronous methods.
226
+
227
+ #### reject
228
+
229
+ Type: `boolean`<br>
230
+ Default: `true`
231
+
232
+ Setting this to `false` resolves the promise with the error instead of rejecting it.
233
+
234
+ #### cleanup
235
+
236
+ Type: `boolean`<br>
237
+ Default: `true`
238
+
239
+ Keep track of the spawned process and `kill` it when the parent process exits.
240
+
241
+ #### encoding
242
+
243
+ Type: `string`<br>
244
+ Default: `utf8`
245
+
246
+ Specify the character encoding used to decode the `stdout` and `stderr` output.
247
+
248
+ #### timeout
249
+
250
+ Type: `number`<br>
251
+ Default: `0`
252
+
253
+ If timeout is greater than `0`, the parent will send the signal identified by the `killSignal` property (the default is `SIGTERM`) if the child runs longer than timeout milliseconds.
254
+
255
+ #### buffer
256
+
257
+ Type: `boolean`<br>
258
+ Default: `true`
259
+
260
+ Buffer the output from the spawned process. When buffering is disabled you must consume the output of the `stdout` and `stderr` streams because the promise will not be resolved/rejected until they have completed.
261
+
262
+ #### maxBuffer
263
+
264
+ Type: `number`<br>
265
+ Default: `10000000` (10MB)
266
+
267
+ Largest amount of data in bytes allowed on `stdout` or `stderr`.
268
+
269
+ #### killSignal
270
+
271
+ Type: `string` `number`<br>
272
+ Default: `SIGTERM`
273
+
274
+ Signal value to be used when the spawned process will be killed.
275
+
276
+ #### stdin
277
+
278
+ Type: `string` `number` `Stream` `undefined` `null`<br>
279
+ Default: `pipe`
280
+
281
+ Same options as [`stdio`](https://nodejs.org/dist/latest-v6.x/docs/api/child_process.html#child_process_options_stdio).
282
+
283
+ #### stdout
284
+
285
+ Type: `string` `number` `Stream` `undefined` `null`<br>
286
+ Default: `pipe`
287
+
288
+ Same options as [`stdio`](https://nodejs.org/dist/latest-v6.x/docs/api/child_process.html#child_process_options_stdio).
289
+
290
+ #### stderr
291
+
292
+ Type: `string` `number` `Stream` `undefined` `null`<br>
293
+ Default: `pipe`
294
+
295
+ Same options as [`stdio`](https://nodejs.org/dist/latest-v6.x/docs/api/child_process.html#child_process_options_stdio).
296
+
297
+ #### windowsVerbatimArguments
298
+
299
+ Type: `boolean`<br>
300
+ Default: `false`
301
+
302
+ If `true`, no quoting or escaping of arguments is done on Windows. Ignored on other platforms. This is set to `true` automatically when the `shell` option is `true`.
303
+
304
+
305
+ ## Tips
306
+
307
+ ### Save and pipe output from a child process
308
+
309
+ Let's say you want to show the output of a child process in real-time while also saving it to a variable.
310
+
311
+ ```js
312
+ const execa = require('execa');
313
+ const getStream = require('get-stream');
314
+
315
+ const stream = execa('echo', ['foo']).stdout;
316
+
317
+ stream.pipe(process.stdout);
318
+
319
+ getStream(stream).then(value => {
320
+ console.log('child output:', value);
321
+ });
322
+ ```
323
+
324
+
325
+ ## License
326
+
327
+ MIT © [Sindre Sorhus](https://sindresorhus.com)
novas/novacore-zephyr/claude-code-router/node_modules/fastify/.borp.yaml ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ files:
2
+ - 'test/**/*.test.js'
3
+ - 'test/**/*.test.mjs'
novas/novacore-zephyr/claude-code-router/node_modules/fastify/.markdownlint-cli2.yaml ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # See https://github.com/DavidAnson/markdownlint-cli2
2
+ config:
3
+ # Disable all rules by default.
4
+ default: false
5
+
6
+ # Enforce line length.
7
+ MD013:
8
+ line_length: 80
9
+ code_block_line_length: 120
10
+ headings: false
11
+ tables: false
12
+ strict: false
13
+ stern: false
14
+
15
+ globs:
16
+ - '**/*.md'
17
+
18
+ ignores:
19
+ - 'node_modules/**'
20
+ - 'test/**/*.md'
21
+
22
+ noProgress: true
novas/novacore-zephyr/claude-code-router/node_modules/fastify/.prettierignore ADDED
@@ -0,0 +1 @@
 
 
1
+ *
novas/novacore-zephyr/claude-code-router/node_modules/fastify/GOVERNANCE.md ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ # Fastify Project Governance
2
+
3
+ Please see Fastify's [organization-wide governance
4
+ ](https://github.com/fastify/.github/blob/main/GOVERNANCE.md) document.
novas/novacore-zephyr/claude-code-router/node_modules/fastify/LICENSE ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ MIT License
2
+
3
+ Copyright (c) 2016-present The Fastify Team
4
+
5
+ The Fastify team members are listed at https://github.com/fastify/fastify#team
6
+ and in the README file.
7
+
8
+ Permission is hereby granted, free of charge, to any person obtaining a copy
9
+ of this software and associated documentation files (the "Software"), to deal
10
+ in the Software without restriction, including without limitation the rights
11
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12
+ copies of the Software, and to permit persons to whom the Software is
13
+ furnished to do so, subject to the following conditions:
14
+
15
+ The above copyright notice and this permission notice shall be included in all
16
+ copies or substantial portions of the Software.
17
+
18
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24
+ SOFTWARE.
novas/novacore-zephyr/claude-code-router/node_modules/fastify/PROJECT_CHARTER.md ADDED
@@ -0,0 +1,126 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Fastify Charter
2
+
3
+ The Fastify project aims to build a fast and low-overhead web framework for
4
+ Node.js.
5
+
6
+
7
+ ## Section 0: Guiding Principles
8
+
9
+ The Fastify project is part of the [OpenJS Foundation][openjs foundation]. It
10
+ operates transparently, openly, collaboratively, and ethically. Project
11
+ proposals, timelines, and status must not merely be open, but also easily
12
+ visible to outsiders.
13
+
14
+
15
+ ## Section 1: Scope
16
+
17
+ Fastify is a web framework highly focused on providing the best developer
18
+ experience with the least overhead and a plugin architecture.
19
+
20
+ ### 1.1: In-scope
21
+
22
+ + Develop a web framework for Node.js with a focus on developer experience,
23
+ performance, and extensibility.
24
+ + Plugin Architecture
25
+ + Support web protocols
26
+ + Official plugins for common user requirements
27
+ + Documentation:
28
+ + Project (policies, processes, and releases)
29
+ + Guides and Tutorials
30
+ + Framework API
31
+ + Website
32
+ + Write easier APIs for developers
33
+ + Tools:
34
+ + CI services
35
+ + Bots to improve overall efficiency
36
+ + Releases
37
+ + Support:
38
+ + Community
39
+ + Users's issues and questions
40
+ + Contributors's pull request review
41
+
42
+ ### 1.2: Out-of-Scope
43
+
44
+ + Support versions of Node.js at EOL (end of life) stage
45
+ + Support serverless architecture
46
+ + Contributions that violate the [Code of Conduct](CODE_OF_CONDUCT.md)
47
+
48
+
49
+ ## Section 2: Relationship with OpenJS Foundation CPC.
50
+
51
+ Technical leadership for the projects within the [OpenJS Foundation][openjs
52
+ foundation] is delegated to the projects through their project charters by the
53
+ [OpenJS Foundation Cross-Project Council](https://openjsf.org/about/governance/)
54
+ (CPC). In the case of the Fastify project, it is delegated to the [Fastify
55
+ Collaborators](README.md#team). The OpenJS Foundation's business leadership is
56
+ the Board of Directors (the "Board").
57
+
58
+ This Fastify Charter reflects a carefully constructed balanced role for the
59
+ Collaborators and the CPC in the governance of the OpenJS Foundation. The
60
+ charter amendment process is for the Fastify Collaborators to propose change
61
+ using a majority of the full Fastify Organization, the proposed changes
62
+ being subject to review and approval by the CPC. The CPC may additionally make
63
+ amendments to the Collaborators charter at any time, though the CPC will not
64
+ interfere with day-to-day discussions, votes, or meetings of the Fastify
65
+ Organization.
66
+
67
+
68
+ ### 2.1 Other Formal Project Relationships
69
+
70
+ Section Intentionally Left Blank
71
+
72
+
73
+ ## Section 3: Fastify Governing Body
74
+
75
+ Fastify is governed by its [maintainers](README.md#team). See [how it is
76
+ structured](GOVERNANCE.md) for more information.
77
+
78
+
79
+ ## Section 4: Roles & Responsibilities
80
+
81
+ The roles and responsibilities of Fastify's maintainers are described in [the
82
+ project organization](GOVERNANCE.md).
83
+
84
+ ### Section 4.1 Project Operations & Management
85
+
86
+ Section Intentionally Left Blank
87
+
88
+ ### Section 4.2: Decision-making, Voting, and/or Elections
89
+
90
+ **Decision-making**
91
+
92
+ Fastify's features can be discussed in GitHub issues and/or projects. Consensus
93
+ on a discussion is reached when there is no objection by any collaborators.
94
+
95
+ When there is no consensus, Lead Maintainers will have the final say on the
96
+ topic.
97
+
98
+ **Voting, and/or Elections**
99
+
100
+ These processes are described in the [GOVERNANCE](GOVERNANCE.md) document.
101
+
102
+ ### Section 4.3: Other Project Roles
103
+
104
+ Section Intentionally Left Blank
105
+
106
+ ## Section 5: Definitions
107
+
108
+ + *Contributors*: contribute code or other artifacts, but do not have the right
109
+ to commit to the code base. Contributors work with the project’s Collaborators
110
+ to have code committed to the code base. Contributors should rarely be
111
+ encumbered by the Fastify Collaborators and never by the CPC or OpenJS
112
+ Foundation Board.
113
+
114
+ + *Collaborators*: contribute code and other artifacts, have the right to commit
115
+ to the code base, and release plugin projects. Collaborators follow the
116
+ [CONTRIBUTING](CONTRIBUTING.md) guidelines to manage the project. A
117
+ Collaborator could be encumbered by other Fastify Collaborators and never by
118
+ the CPC or OpenJS Foundation Board.
119
+
120
+ + *Lead Maintainers*: founders of the project, contribute code and other
121
+ artifacts, have the right to commit to the code base and release the project.
122
+ Lead Maintainers follow the [CONTRIBUTING](CONTRIBUTING.md) guidelines to
123
+ manage the project. A Lead Maintainer will be encumbered by the Fastify
124
+ Collaborators and by the CPC or OpenJS Foundation Board.
125
+
126
+ [openjs foundation]: https://openjsf.org
novas/novacore-zephyr/claude-code-router/node_modules/fastify/README.md ADDED
@@ -0,0 +1,421 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <div align="center"> <a href="https://fastify.dev/">
2
+ <img
3
+ src="https://github.com/fastify/graphics/raw/HEAD/fastify-landscape-outlined.svg"
4
+ width="650"
5
+ height="auto"
6
+ />
7
+ </a>
8
+ </div>
9
+
10
+ <div align="center">
11
+
12
+ [![CI](https://github.com/fastify/fastify/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/fastify/fastify/actions/workflows/ci.yml)
13
+ [![Package Manager
14
+ CI](https://github.com/fastify/fastify/actions/workflows/package-manager-ci.yml/badge.svg?branch=main)](https://github.com/fastify/fastify/actions/workflows/package-manager-ci.yml)
15
+ [![Web
16
+ site](https://github.com/fastify/fastify/actions/workflows/website.yml/badge.svg?branch=main)](https://github.com/fastify/fastify/actions/workflows/website.yml)
17
+ [![neostandard javascript style](https://img.shields.io/badge/code_style-neostandard-brightgreen?style=flat)](https://github.com/neostandard/neostandard)
18
+ [![CII Best Practices](https://bestpractices.coreinfrastructure.org/projects/7585/badge)](https://bestpractices.coreinfrastructure.org/projects/7585)
19
+
20
+ </div>
21
+
22
+ <div align="center">
23
+
24
+ [![NPM
25
+ version](https://img.shields.io/npm/v/fastify.svg?style=flat)](https://www.npmjs.com/package/fastify)
26
+ [![NPM
27
+ downloads](https://img.shields.io/npm/dm/fastify.svg?style=flat)](https://www.npmjs.com/package/fastify)
28
+ [![Security Responsible
29
+ Disclosure](https://img.shields.io/badge/Security-Responsible%20Disclosure-yellow.svg)](https://github.com/fastify/fastify/blob/main/SECURITY.md)
30
+ [![Discord](https://img.shields.io/discord/725613461949906985)](https://discord.gg/fastify)
31
+ [![Contribute with Gitpod](https://img.shields.io/badge/Contribute%20with-Gitpod-908a85?logo=gitpod&color=blue)](https://gitpod.io/#https://github.com/fastify/fastify)
32
+ [![Open Collective backers and sponsors](https://img.shields.io/opencollective/all/fastify)](https://github.com/sponsors/fastify#sponsors)
33
+
34
+ </div>
35
+
36
+ <br />
37
+
38
+ An efficient server implies a lower cost of the infrastructure, better
39
+ responsiveness under load, and happy users. How can you efficiently handle the
40
+ resources of your server, knowing that you are serving the highest number of
41
+ requests possible, without sacrificing security validations and handy
42
+ development?
43
+
44
+ Enter Fastify. Fastify is a web framework highly focused on providing the best
45
+ developer experience with the least overhead and a powerful plugin architecture.
46
+ It is inspired by Hapi and Express and as far as we know, it is one of the
47
+ fastest web frameworks in town.
48
+
49
+ The `main` branch refers to the Fastify `v5` release.
50
+ Check out the [`4.x` branch](https://github.com/fastify/fastify/tree/4.x) for `v4`.
51
+
52
+ ### Table of Contents
53
+
54
+ - [Quick start](#quick-start)
55
+ - [Install](#install)
56
+ - [Example](#example)
57
+ - [Core features](#core-features)
58
+ - [Benchmarks](#benchmarks)
59
+ - [Documentation](#documentation)
60
+ - [Ecosystem](#ecosystem)
61
+ - [Support](#support)
62
+ - [Team](#team)
63
+ - [Hosted by](#hosted-by)
64
+ - [License](#license)
65
+
66
+
67
+ ### Quick start
68
+
69
+ Create a folder and make it your current working directory:
70
+
71
+ ```sh
72
+ mkdir my-app
73
+ cd my-app
74
+ ```
75
+
76
+ Generate a fastify project with `npm init`:
77
+
78
+ ```sh
79
+ npm init fastify
80
+ ```
81
+
82
+ Install dependencies:
83
+
84
+ ```sh
85
+ npm i
86
+ ```
87
+
88
+ To start the app in dev mode:
89
+
90
+ ```sh
91
+ npm run dev
92
+ ```
93
+
94
+ For production mode:
95
+
96
+ ```sh
97
+ npm start
98
+ ```
99
+
100
+ Under the hood `npm init` downloads and runs [Fastify
101
+ Create](https://github.com/fastify/create-fastify), which in turn uses the
102
+ generate functionality of [Fastify CLI](https://github.com/fastify/fastify-cli).
103
+
104
+
105
+ ### Install
106
+
107
+ To install Fastify in an existing project as a dependency:
108
+
109
+ ```sh
110
+ npm i fastify
111
+ ```
112
+
113
+ ### Example
114
+
115
+ ```js
116
+ // Require the framework and instantiate it
117
+
118
+ // ESM
119
+ import Fastify from 'fastify'
120
+
121
+ const fastify = Fastify({
122
+ logger: true
123
+ })
124
+ // CommonJs
125
+ const fastify = require('fastify')({
126
+ logger: true
127
+ })
128
+
129
+ // Declare a route
130
+ fastify.get('/', (request, reply) => {
131
+ reply.send({ hello: 'world' })
132
+ })
133
+
134
+ // Run the server!
135
+ fastify.listen({ port: 3000 }, (err, address) => {
136
+ if (err) throw err
137
+ // Server is now listening on ${address}
138
+ })
139
+ ```
140
+
141
+ With async-await:
142
+
143
+ ```js
144
+ // ESM
145
+ import Fastify from 'fastify'
146
+
147
+ const fastify = Fastify({
148
+ logger: true
149
+ })
150
+ // CommonJs
151
+ const fastify = require('fastify')({
152
+ logger: true
153
+ })
154
+
155
+ fastify.get('/', async (request, reply) => {
156
+ reply.type('application/json').code(200)
157
+ return { hello: 'world' }
158
+ })
159
+
160
+ fastify.listen({ port: 3000 }, (err, address) => {
161
+ if (err) throw err
162
+ // Server is now listening on ${address}
163
+ })
164
+ ```
165
+
166
+ Do you want to know more? Head to the <a
167
+ href="./docs/Guides/Getting-Started.md"><code><b>Getting Started</b></code></a>.
168
+ If you learn best by reading code, explore the official [demo](https://github.com/fastify/demo).
169
+
170
+ > ## Note
171
+ > `.listen` binds to the local host, `localhost`, interface by default
172
+ > (`127.0.0.1` or `::1`, depending on the operating system configuration). If
173
+ > you are running Fastify in a container (Docker,
174
+ > [GCP](https://cloud.google.com/), etc.), you may need to bind to `0.0.0.0`. Be
175
+ > careful when listening on all interfaces; it comes with inherent
176
+ > [security
177
+ > risks](https://web.archive.org/web/20170711105010/https://snyk.io/blog/mongodb-hack-and-secure-defaults/).
178
+ > See [the documentation](./docs/Reference/Server.md#listen) for more
179
+ > information.
180
+
181
+ ### Core features
182
+
183
+ - **Highly performant:** as far as we know, Fastify is one of the fastest web
184
+ frameworks in town, depending on the code complexity we can serve up to 76+
185
+ thousand requests per second.
186
+ - **Extensible:** Fastify is fully extensible via its hooks, plugins, and
187
+ decorators.
188
+ - **Schema-based:** even if it is not mandatory we recommend using [JSON
189
+ Schema](https://json-schema.org/) to validate your routes and serialize your
190
+ outputs. Internally Fastify compiles the schema in a highly performant
191
+ function.
192
+ - **Logging:** logs are extremely important but are costly; we chose the best
193
+ logger to almost remove this cost, [Pino](https://github.com/pinojs/pino)!
194
+ - **Developer friendly:** the framework is built to be very expressive and help
195
+ developers in their daily use without sacrificing performance and
196
+ security.
197
+
198
+ ### Benchmarks
199
+
200
+ __Machine:__ EX41S-SSD, Intel Core i7, 4Ghz, 64GB RAM, 4C/8T, SSD.
201
+
202
+ __Method:__: `autocannon -c 100 -d 40 -p 10 localhost:3000` * 2, taking the
203
+ second average
204
+
205
+ | Framework | Version | Router? | Requests/sec |
206
+ | :----------------- | :------------------------- | :----------: | ------------: |
207
+ | Express | 4.17.3 | &#10003; | 14,200 |
208
+ | hapi | 20.2.1 | &#10003; | 42,284 |
209
+ | Restify | 8.6.1 | &#10003; | 50,363 |
210
+ | Koa | 2.13.0 | &#10007; | 54,272 |
211
+ | **Fastify** | **4.0.0** | **&#10003;** | **77,193** |
212
+ | - | | | |
213
+ | `http.Server` | 16.14.2 | &#10007; | 74,513 |
214
+
215
+ These benchmarks taken using https://github.com/fastify/benchmarks. This is a
216
+ synthetic "hello world" benchmark that aims to evaluate the framework overhead.
217
+ The overhead that each framework has on your application depends on your
218
+ application. You should __always__ benchmark if performance matters to you.
219
+
220
+ ## Documentation
221
+ * [__`Getting Started`__](./docs/Guides/Getting-Started.md)
222
+ * [__`Guides`__](./docs/Guides/Index.md)
223
+ * [__`Server`__](./docs/Reference/Server.md)
224
+ * [__`Routes`__](./docs/Reference/Routes.md)
225
+ * [__`Encapsulation`__](./docs/Reference/Encapsulation.md)
226
+ * [__`Logging`__](./docs/Reference/Logging.md)
227
+ * [__`Middleware`__](./docs/Reference/Middleware.md)
228
+ * [__`Hooks`__](./docs/Reference/Hooks.md)
229
+ * [__`Decorators`__](./docs/Reference/Decorators.md)
230
+ * [__`Validation and Serialization`__](./docs/Reference/Validation-and-Serialization.md)
231
+ * [__`Fluent Schema`__](./docs/Guides/Fluent-Schema.md)
232
+ * [__`Lifecycle`__](./docs/Reference/Lifecycle.md)
233
+ * [__`Reply`__](./docs/Reference/Reply.md)
234
+ * [__`Request`__](./docs/Reference/Request.md)
235
+ * [__`Errors`__](./docs/Reference/Errors.md)
236
+ * [__`Content Type Parser`__](./docs/Reference/ContentTypeParser.md)
237
+ * [__`Plugins`__](./docs/Reference/Plugins.md)
238
+ * [__`Testing`__](./docs/Guides/Testing.md)
239
+ * [__`Benchmarking`__](./docs/Guides/Benchmarking.md)
240
+ * [__`How to write a good plugin`__](./docs/Guides/Write-Plugin.md)
241
+ * [__`Plugins Guide`__](./docs/Guides/Plugins-Guide.md)
242
+ * [__`HTTP2`__](./docs/Reference/HTTP2.md)
243
+ * [__`Long Term Support`__](./docs/Reference/LTS.md)
244
+ * [__`TypeScript and types support`__](./docs/Reference/TypeScript.md)
245
+ * [__`Serverless`__](./docs/Guides/Serverless.md)
246
+ * [__`Recommendations`__](./docs/Guides/Recommendations.md)
247
+
248
+ ## Ecosystem
249
+
250
+ - [Core](./docs/Guides/Ecosystem.md#core) - Core plugins maintained by the
251
+ _Fastify_ [team](#team).
252
+ - [Community](./docs/Guides/Ecosystem.md#community) - Community-supported
253
+ plugins.
254
+ - [Live Examples](https://github.com/fastify/example) - Multirepo with a broad
255
+ set of real working examples.
256
+ - [Discord](https://discord.gg/D3FZYPy) - Join our discord server and chat with
257
+ the maintainers.
258
+
259
+ ## Support
260
+ Please visit [Fastify help](https://github.com/fastify/help) to view prior
261
+ support issues and to ask new support questions.
262
+
263
+ Version 3 of Fastify and lower are EOL and will not receive any security or bug fixes.
264
+
265
+ Fastify's partner, HeroDevs, provides commercial security fixes for all
266
+ unsupported versions at [https://herodevs.com/support/fastify-nes][hd-link].
267
+ Fastify's supported version matrix is available in the
268
+ [Long Term Support][lts-link] documentation.
269
+
270
+ ## Contributing
271
+
272
+ Whether reporting bugs, discussing improvements and new ideas, or writing code,
273
+ we welcome contributions from anyone and everyone. Please read the [CONTRIBUTING](./CONTRIBUTING.md)
274
+ guidelines before submitting pull requests.
275
+
276
+ ## Team
277
+
278
+ _Fastify_ is the result of the work of a great community. Team members are
279
+ listed in alphabetical order.
280
+
281
+ **Lead Maintainers:**
282
+ * [__Matteo Collina__](https://github.com/mcollina),
283
+ <https://twitter.com/matteocollina>, <https://www.npmjs.com/~matteo.collina>
284
+ * [__Tomas Della Vedova__](https://github.com/delvedor),
285
+ <https://twitter.com/delvedor>, <https://www.npmjs.com/~delvedor>
286
+ * [__KaKa Ng__](https://github.com/climba03003),
287
+ <https://www.npmjs.com/~climba03003>
288
+ * [__Manuel Spigolon__](https://github.com/eomm),
289
+ <https://twitter.com/manueomm>, <https://www.npmjs.com/~eomm>
290
+ * [__James Sumners__](https://github.com/jsumners),
291
+ <https://twitter.com/jsumners79>, <https://www.npmjs.com/~jsumners>
292
+
293
+ ### Fastify Core team
294
+ * [__Aras Abbasi__](https://github.com/uzlopak),
295
+ <https://www.npmjs.com/~uzlopak>
296
+ * [__Harry Brundage__](https://github.com/airhorns/),
297
+ <https://twitter.com/harrybrundage>, <https://www.npmjs.com/~airhorns>
298
+ * [__Matteo Collina__](https://github.com/mcollina),
299
+ <https://twitter.com/matteocollina>, <https://www.npmjs.com/~matteo.collina>
300
+ * [__Gürgün Dayıoğlu__](https://github.com/gurgunday),
301
+ <https://www.npmjs.com/~gurgunday>
302
+ * [__Tomas Della Vedova__](https://github.com/delvedor),
303
+ <https://twitter.com/delvedor>, <https://www.npmjs.com/~delvedor>
304
+ * [__Carlos Fuentes__](https://github.com/metcoder95),
305
+ <https://twitter.com/metcoder95>, <https://www.npmjs.com/~metcoder95>
306
+ * [__Vincent Le Goff__](https://github.com/zekth)
307
+ * [__Luciano Mammino__](https://github.com/lmammino),
308
+ <https://twitter.com/loige>, <https://www.npmjs.com/~lmammino>
309
+ * [__Jean Michelet__](https://github.com/jean-michelet),
310
+ <https://www.npmjs.com/~jean-michelet>
311
+ * [__KaKa Ng__](https://github.com/climba03003),
312
+ <https://www.npmjs.com/~climba03003>
313
+ * [__Luis Orbaiceta__](https://github.com/luisorbaiceta),
314
+ <https://twitter.com/luisorbai>, <https://www.npmjs.com/~luisorbaiceta>
315
+ * [__Maksim Sinik__](https://github.com/fox1t),
316
+ <https://twitter.com/maksimsinik>, <https://www.npmjs.com/~fox1t>
317
+ * [__Manuel Spigolon__](https://github.com/eomm),
318
+ <https://twitter.com/manueomm>, <https://www.npmjs.com/~eomm>
319
+ * [__James Sumners__](https://github.com/jsumners),
320
+ <https://twitter.com/jsumners79>, <https://www.npmjs.com/~jsumners>
321
+
322
+ ### Fastify Plugins team
323
+ * [__Harry Brundage__](https://github.com/airhorns/),
324
+ <https://twitter.com/harrybrundage>, <https://www.npmjs.com/~airhorns>
325
+ * [__Simone Busoli__](https://github.com/simoneb),
326
+ <https://twitter.com/simonebu>, <https://www.npmjs.com/~simoneb>
327
+ * [__Dan Castillo__](https://github.com/dancastillo),
328
+ <https://www.npmjs.com/~dancastillo>
329
+ * [__Matteo Collina__](https://github.com/mcollina),
330
+ <https://twitter.com/matteocollina>, <https://www.npmjs.com/~matteo.collina>
331
+ * [__Gürgün Dayıoğlu__](https://github.com/gurgunday),
332
+ <https://www.npmjs.com/~gurgunday>
333
+ * [__Tomas Della Vedova__](https://github.com/delvedor),
334
+ <https://twitter.com/delvedor>, <https://www.npmjs.com/~delvedor>
335
+ * [__Carlos Fuentes__](https://github.com/metcoder95),
336
+ <https://twitter.com/metcoder95>, <https://www.npmjs.com/~metcoder95>
337
+ * [__Vincent Le Goff__](https://github.com/zekth)
338
+ * [__Jean Michelet__](https://github.com/jean-michelet),
339
+ <https://www.npmjs.com/~jean-michelet>
340
+ * [__KaKa Ng__](https://github.com/climba03003),
341
+ <https://www.npmjs.com/~climba03003>
342
+ * [__Maksim Sinik__](https://github.com/fox1t),
343
+ <https://twitter.com/maksimsinik>, <https://www.npmjs.com/~fox1t>
344
+ * [__Frazer Smith__](https://github.com/Fdawgs), <https://www.npmjs.com/~fdawgs>
345
+ * [__Manuel Spigolon__](https://github.com/eomm),
346
+ <https://twitter.com/manueomm>, <https://www.npmjs.com/~eomm>
347
+
348
+ ### Emeritus Contributors
349
+ Great contributors to a specific area of the Fastify ecosystem will be invited
350
+ to join this group by Lead Maintainers when they decide to step down from the
351
+ active contributor's group.
352
+
353
+ * [__Tommaso Allevi__](https://github.com/allevo),
354
+ <https://twitter.com/allevitommaso>, <https://www.npmjs.com/~allevo>
355
+ * [__Ethan Arrowood__](https://github.com/Ethan-Arrowood/),
356
+ <https://twitter.com/arrowoodtech>, <https://www.npmjs.com/~ethan_arrowood>
357
+ * [__Çağatay Çalı__](https://github.com/cagataycali),
358
+ <https://twitter.com/cagataycali>, <https://www.npmjs.com/~cagataycali>
359
+ * [__David Mark Clements__](https://github.com/davidmarkclements),
360
+ <https://twitter.com/davidmarkclem>,
361
+ <https://www.npmjs.com/~davidmarkclements>
362
+ * [__dalisoft__](https://github.com/dalisoft), <https://twitter.com/dalisoft>,
363
+ <https://www.npmjs.com/~dalisoft>
364
+ * [__Dustin Deus__](https://github.com/StarpTech),
365
+ <https://twitter.com/dustindeus>, <https://www.npmjs.com/~starptech>
366
+ * [__Denis Fäcke__](https://github.com/SerayaEryn),
367
+ <https://twitter.com/serayaeryn>, <https://www.npmjs.com/~serayaeryn>
368
+ * [__Rafael Gonzaga__](https://github.com/rafaelgss),
369
+ <https://twitter.com/_rafaelgss>, <https://www.npmjs.com/~rafaelgss>
370
+ * [__Trivikram Kamat__](https://github.com/trivikr),
371
+ <https://twitter.com/trivikram>, <https://www.npmjs.com/~trivikr>
372
+ * [__Ayoub El Khattabi__](https://github.com/AyoubElk),
373
+ <https://twitter.com/ayoubelkh>, <https://www.npmjs.com/~ayoubelk>
374
+ * [__Cemre Mengu__](https://github.com/cemremengu),
375
+ <https://twitter.com/cemremengu>, <https://www.npmjs.com/~cemremengu>
376
+ * [__Salman Mitha__](https://github.com/salmanm),
377
+ <https://www.npmjs.com/~salmanm>
378
+ * [__Nathan Woltman__](https://github.com/nwoltman),
379
+ <https://twitter.com/NathanWoltman>, <https://www.npmjs.com/~nwoltman>
380
+
381
+ ## Hosted by
382
+
383
+ [<img
384
+ src="https://github.com/openjs-foundation/artwork/blob/main/openjs_foundation/openjs_foundation-logo-horizontal-color.png?raw=true"
385
+ width="250px;"/>](https://openjsf.org/projects)
386
+
387
+ We are an [At-Large
388
+ Project](https://github.com/openjs-foundation/cross-project-council/blob/HEAD/PROJECT_PROGRESSION.md#at-large-projects)
389
+ in the [OpenJS Foundation](https://openjsf.org/).
390
+
391
+ ## Sponsors
392
+
393
+ Support this project by becoming a [SPONSOR](./SPONSORS.md)!
394
+ Fastify has an [Open Collective](https://opencollective.com/fastify)
395
+ page where we accept and manage financial contributions.
396
+
397
+ ## Acknowledgments
398
+
399
+ This project is kindly sponsored by:
400
+ - [NearForm](https://nearform.com)
401
+ - [Platformatic](https://platformatic.dev)
402
+
403
+ Past Sponsors:
404
+ - [LetzDoIt](https://www.letzdoitapp.com/)
405
+
406
+ This list includes all companies that support one or more team members
407
+ in maintaining this project.
408
+
409
+ ## License
410
+
411
+ Licensed under [MIT](./LICENSE).
412
+
413
+ For your convenience, here is a list of all the licenses of our production
414
+ dependencies:
415
+ - MIT
416
+ - ISC
417
+ - BSD-3-Clause
418
+ - BSD-2-Clause
419
+
420
+ [hd-link]: https://www.herodevs.com/support/fastify-nes?utm_source=fastify&utm_medium=link&utm_campaign=github_readme
421
+ [lts-link]: https://fastify.dev/docs/latest/Reference/LTS/
novas/novacore-zephyr/claude-code-router/node_modules/fastify/SECURITY.md ADDED
@@ -0,0 +1,160 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Security Policy
2
+
3
+ This document describes the management of vulnerabilities for the Fastify
4
+ project and its official plugins.
5
+
6
+ ## Reporting vulnerabilities
7
+
8
+ Individuals who find potential vulnerabilities in Fastify are invited to
9
+ complete a vulnerability report via the dedicated pages:
10
+
11
+ 1. [HackerOne](https://hackerone.com/fastify)
12
+ 2. [GitHub Security Advisory](https://github.com/fastify/fastify/security/advisories/new)
13
+
14
+ ### Strict measures when reporting vulnerabilities
15
+
16
+ It is of the utmost importance that you read carefully and follow these
17
+ guidelines to ensure the ecosystem as a whole isn't disrupted due to improperly
18
+ reported vulnerabilities:
19
+
20
+ * Avoid creating new "informative" reports. Only create new
21
+ reports on a vulnerability if you are absolutely sure this should be
22
+ tagged as an actual vulnerability. Third-party vendors and individuals are
23
+ tracking any new vulnerabilities reported in HackerOne or GitHub and will flag
24
+ them as such for their customers (think about snyk, npm audit, ...).
25
+ * Security reports should never be created and triaged by the same person. If
26
+ you are creating a report for a vulnerability that you found, or on
27
+ behalf of someone else, there should always be a 2nd Security Team member who
28
+ triages it. If in doubt, invite more Fastify Collaborators to help triage the
29
+ validity of the report. In any case, the report should follow the same process
30
+ as outlined below of inviting the maintainers to review and accept the
31
+ vulnerability.
32
+ * ***Do not*** attempt to show CI/CD vulnerabilities by creating new pull
33
+ requests to any of the Fastify organization's repositories. Doing so will
34
+ result in a [content report][cr] to GitHub as an unsolicited exploit.
35
+ The proper way to provide such reports is by creating a new repository,
36
+ configured in the same manner as the repository you would like to submit
37
+ a report about, and with a pull request to your own repository showing
38
+ the proof of concept.
39
+
40
+ [cr]: https://docs.github.com/en/communities/maintaining-your-safety-on-github/reporting-abuse-or-spam#reporting-an-issue-or-pull-request
41
+
42
+ ### Vulnerabilities found outside this process
43
+
44
+ ⚠ The Fastify project does not support any reporting outside the process mentioned
45
+ in this document.
46
+
47
+ ## Handling vulnerability reports
48
+
49
+ When a potential vulnerability is reported, the following actions are taken:
50
+
51
+ ### Triage
52
+
53
+ **Delay:** 4 business days
54
+
55
+ Within 4 business days, a member of the security team provides a first answer to
56
+ the individual who submitted the potential vulnerability. The possible responses
57
+ can be:
58
+
59
+ * **Acceptance**: what was reported is considered as a new vulnerability
60
+ * **Rejection**: what was reported is not considered as a new vulnerability
61
+ * **Need more information**: the security team needs more information in order to
62
+ evaluate what was reported.
63
+
64
+ Triaging should include updating issue fields:
65
+ * Asset - set/create the module affected by the report
66
+ * Severity - TBD, currently left empty
67
+
68
+ Reference: [HackerOne: Submitting
69
+ Reports](https://docs.hackerone.com/hackers/submitting-reports.html)
70
+
71
+ ### Correction follow-up
72
+
73
+ **Delay:** 90 days
74
+
75
+ When a vulnerability is confirmed, a member of the security team volunteers to
76
+ follow up on this report.
77
+
78
+ With the help of the individual who reported the vulnerability, they contact the
79
+ maintainers of the vulnerable package to make them aware of the vulnerability.
80
+ The maintainers can be invited as participants to the reported issue.
81
+
82
+ With the package maintainer, they define a release date for the publication of
83
+ the vulnerability. Ideally, this release date should not happen before the
84
+ package has been patched.
85
+
86
+ The report's vulnerable versions upper limit should be set to:
87
+ * `*` if there is no fixed version available by the time of publishing the
88
+ report.
89
+ * the last vulnerable version. For example: `<=1.2.3` if a fix exists in `1.2.4`
90
+
91
+ ### Publication
92
+
93
+ **Delay:** 90 days
94
+
95
+ Within 90 days after the triage date, the vulnerability must be made public.
96
+
97
+ **Severity**: Vulnerability severity is assessed using [CVSS
98
+ v.3](https://www.first.org/cvss/user-guide). More information can be found on
99
+ [HackerOne documentation](https://docs.hackerone.com/hackers/severity.html)
100
+
101
+ If the package maintainer is actively developing a patch, an additional delay
102
+ can be added with the approval of the security team and the individual who
103
+ reported the vulnerability.
104
+
105
+ At this point, a CVE should be requested through the selected platform through
106
+ the UI, which should include the Report ID and a summary.
107
+
108
+ Within HackerOne, this is handled through a "public disclosure request".
109
+
110
+ Reference: [HackerOne:
111
+ Disclosure](https://docs.hackerone.com/hackers/disclosure.html)
112
+
113
+ ## The Fastify Security team
114
+
115
+ The core team is responsible for the management of the security program and
116
+ this policy and process.
117
+
118
+ Members of this team are expected to keep all information that they have
119
+ privileged access to by being on the team completely private to the team. This
120
+ includes agreeing to not notify anyone outside the team of issues that have not
121
+ yet been disclosed publicly, including the existence of issues, expectations of
122
+ upcoming releases, and patching of any issues other than in the process of their
123
+ work as a member of the Fastify Core team.
124
+
125
+ ### Members
126
+
127
+ * [__Matteo Collina__](https://github.com/mcollina),
128
+ <https://twitter.com/matteocollina>, <https://www.npmjs.com/~matteo.collina>
129
+ * [__Tomas Della Vedova__](https://github.com/delvedor),
130
+ <https://twitter.com/delvedor>, <https://www.npmjs.com/~delvedor>
131
+ * [__Vincent Le Goff__](https://github.com/zekth)
132
+ * [__KaKa Ng__](https://github.com/climba03003)
133
+ * [__James Sumners__](https://github.com/jsumners),
134
+ <https://twitter.com/jsumners79>, <https://www.npmjs.com/~jsumners>
135
+
136
+ ## OpenSSF CII Best Practices
137
+
138
+ [![CII Best Practices](https://bestpractices.coreinfrastructure.org/projects/7585/badge)](https://bestpractices.coreinfrastructure.org/projects/7585)
139
+
140
+ There are three “tiers”: passing, silver, and gold.
141
+
142
+ ### Passing
143
+ We meet 100% of the “passing” criteria.
144
+
145
+ ### Silver
146
+ We meet 87% of the “silver” criteria. The gaps are as follows:
147
+ - we do not have a DCO or a CLA process for contributions.
148
+ - we do not currently document
149
+ “what the user can and cannot expect in terms of security” for our project.
150
+ - we do not currently document ”the architecture (aka high-level design)”
151
+ for our project.
152
+
153
+ ### Gold
154
+ We meet 70% of the “gold” criteria. The gaps are as follows:
155
+ - we do not yet have the “silver” badge; see all the gaps above.
156
+ - We do not include a copyright or license statement in each source file.
157
+ Efforts are underway to change this archaic practice into a
158
+ suggestion instead of a hard requirement.
159
+ - There are a few unanswered questions around cryptography that are
160
+ waiting for clarification.
novas/novacore-zephyr/claude-code-router/node_modules/fastify/SPONSORS.md ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Sponsors
2
+
3
+ All active sponsors of Fastify are listed here, in order of contribution!
4
+ Our sponsors are the reason why we can work on some issues or features
5
+ that otherwise would be impossible to do.
6
+
7
+ If you want to become a sponsor, please check out our [Open Collective page](https://opencollective.com/fastify)
8
+ or [GitHub Sponsors](https://github.com/sponsors/fastify)!
9
+
10
+ ## Tier 4
11
+
12
+ _Be the first!_
13
+
14
+ ## Tier 3
15
+
16
+ - [Mercedes-Benz Group](https://github.com/mercedes-benz)
17
+ - [Val Town, Inc.](https://opencollective.com/valtown)
18
+ - [Handsontable - JavaScript Data Grid](https://handsontable.com/docs/react-data-grid/?utm_source=Fastify_GH&utm_medium=sponsorship&utm_campaign=library_sponsorship_2024)
19
+ - [Lokalise - A Localization and Translation Software Tool](https://lokalise.com/?utm_source=Fastify_GH&utm_medium=sponsorship)
20
+
21
+ ## Tier 2
22
+
23
+ _Be the first!_
novas/novacore-zephyr/claude-code-router/node_modules/fastify/eslint.config.js ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 'use strict'
2
+ const neostandard = require('neostandard')
3
+
4
+ module.exports = [
5
+ ...neostandard({
6
+ ignores: [
7
+ 'lib/configValidator.js',
8
+ 'lib/error-serializer.js',
9
+ 'test/same-shape.test.js',
10
+ 'test/types/import.js'
11
+ ],
12
+ ts: true
13
+ }),
14
+ {
15
+ rules: {
16
+ 'comma-dangle': ['error', 'never']
17
+ }
18
+ }
19
+ ]
novas/novacore-zephyr/claude-code-router/node_modules/fastify/fastify.d.ts ADDED
@@ -0,0 +1,240 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import * as http from 'node:http'
2
+ import * as http2 from 'node:http2'
3
+ import * as https from 'node:https'
4
+ import { Socket } from 'node:net'
5
+
6
+ import { Options as AjvOptions, ValidatorFactory } from '@fastify/ajv-compiler'
7
+ import { FastifyError } from '@fastify/error'
8
+ import { Options as FJSOptions, SerializerFactory } from '@fastify/fast-json-stringify-compiler'
9
+ import { ConstraintStrategy, HTTPVersion } from 'find-my-way'
10
+ import { InjectOptions, CallbackFunc as LightMyRequestCallback, Chain as LightMyRequestChain, Response as LightMyRequestResponse } from 'light-my-request'
11
+
12
+ import { AddContentTypeParser, ConstructorAction, FastifyBodyParser, FastifyContentTypeParser, getDefaultJsonParser, hasContentTypeParser, ProtoAction } from './types/content-type-parser'
13
+ import { FastifyContextConfig, FastifyReplyContext, FastifyRequestContext } from './types/context'
14
+ import { FastifyErrorCodes } from './types/errors'
15
+ import { DoneFuncWithErrOrRes, HookHandlerDoneFunction, onCloseAsyncHookHandler, onCloseHookHandler, onErrorAsyncHookHandler, onErrorHookHandler, onListenAsyncHookHandler, onListenHookHandler, onReadyAsyncHookHandler, onReadyHookHandler, onRegisterHookHandler, onRequestAbortAsyncHookHandler, onRequestAbortHookHandler, onRequestAsyncHookHandler, onRequestHookHandler, onResponseAsyncHookHandler, onResponseHookHandler, onRouteHookHandler, onSendAsyncHookHandler, onSendHookHandler, onTimeoutAsyncHookHandler, onTimeoutHookHandler, preCloseAsyncHookHandler, preCloseHookHandler, preHandlerAsyncHookHandler, preHandlerHookHandler, preParsingAsyncHookHandler, preParsingHookHandler, preSerializationAsyncHookHandler, preSerializationHookHandler, preValidationAsyncHookHandler, preValidationHookHandler, RequestPayload } from './types/hooks'
16
+ import { FastifyInstance, FastifyListenOptions, PrintRoutesOptions } from './types/instance'
17
+ import {
18
+ FastifyBaseLogger,
19
+ FastifyChildLoggerFactory,
20
+ FastifyLogFn,
21
+ FastifyLoggerInstance,
22
+ FastifyLoggerOptions,
23
+ LogLevel,
24
+ PinoLoggerOptions
25
+ } from './types/logger'
26
+ import { FastifyPlugin, FastifyPluginAsync, FastifyPluginCallback, FastifyPluginOptions } from './types/plugin'
27
+ import { FastifyRegister, FastifyRegisterOptions, RegisterOptions } from './types/register'
28
+ import { FastifyReply } from './types/reply'
29
+ import { FastifyRequest, RequestGenericInterface } from './types/request'
30
+ import { RouteGenericInterface, RouteHandler, RouteHandlerMethod, RouteOptions, RouteShorthandMethod, RouteShorthandOptions, RouteShorthandOptionsWithHandler } from './types/route'
31
+ import { FastifySchema, FastifySchemaValidationError, FastifySchemaCompiler, FastifySerializerCompiler, SchemaErrorDataVar, SchemaErrorFormatter } from './types/schema'
32
+ import { FastifyServerFactory, FastifyServerFactoryHandler } from './types/serverFactory'
33
+ import { FastifyTypeProvider, FastifyTypeProviderDefault, SafePromiseLike } from './types/type-provider'
34
+ import { ContextConfigDefault, HTTPMethods, RawReplyDefaultExpression, RawRequestDefaultExpression, RawServerBase, RawServerDefault, RequestBodyDefault, RequestHeadersDefault, RequestParamsDefault, RequestQuerystringDefault } from './types/utils'
35
+
36
+ declare module '@fastify/error' {
37
+ interface FastifyError {
38
+ validationContext?: SchemaErrorDataVar;
39
+ validation?: FastifySchemaValidationError[];
40
+ }
41
+ }
42
+
43
+ type Fastify = typeof fastify
44
+
45
+ declare namespace fastify {
46
+ export const errorCodes: FastifyErrorCodes
47
+
48
+ export type FastifyHttp2SecureOptions<
49
+ Server extends http2.Http2SecureServer,
50
+ Logger extends FastifyBaseLogger = FastifyBaseLogger
51
+ > = FastifyServerOptions<Server, Logger> & {
52
+ http2: true,
53
+ https: http2.SecureServerOptions,
54
+ http2SessionTimeout?: number
55
+ }
56
+
57
+ export type FastifyHttp2Options<
58
+ Server extends http2.Http2Server,
59
+ Logger extends FastifyBaseLogger = FastifyBaseLogger
60
+ > = FastifyServerOptions<Server, Logger> & {
61
+ http2: true,
62
+ http2SessionTimeout?: number
63
+ }
64
+
65
+ export type FastifyHttpsOptions<
66
+ Server extends https.Server,
67
+ Logger extends FastifyBaseLogger = FastifyBaseLogger
68
+ > = FastifyServerOptions<Server, Logger> & {
69
+ https: https.ServerOptions | null
70
+ }
71
+
72
+ export type FastifyHttpOptions<
73
+ Server extends http.Server,
74
+ Logger extends FastifyBaseLogger = FastifyBaseLogger
75
+ > = FastifyServerOptions<Server, Logger> & {
76
+ http?: http.ServerOptions | null
77
+ }
78
+
79
+ type FindMyWayVersion<RawServer extends RawServerBase> = RawServer extends http.Server ? HTTPVersion.V1 : HTTPVersion.V2
80
+
81
+ export interface ConnectionError extends Error {
82
+ code: string,
83
+ bytesParsed: number,
84
+ rawPacket: {
85
+ type: string,
86
+ data: number[]
87
+ }
88
+ }
89
+
90
+ type TrustProxyFunction = (address: string, hop: number) => boolean
91
+
92
+ /**
93
+ * Options for a fastify server instance. Utilizes conditional logic on the generic server parameter to enforce certain https and http2
94
+ */
95
+ export type FastifyServerOptions<
96
+ RawServer extends RawServerBase = RawServerDefault,
97
+ Logger extends FastifyBaseLogger = FastifyBaseLogger
98
+ > = {
99
+ ignoreTrailingSlash?: boolean,
100
+ ignoreDuplicateSlashes?: boolean,
101
+ connectionTimeout?: number,
102
+ keepAliveTimeout?: number,
103
+ maxRequestsPerSocket?: number,
104
+ forceCloseConnections?: boolean | 'idle',
105
+ requestTimeout?: number,
106
+ pluginTimeout?: number,
107
+ bodyLimit?: number,
108
+ maxParamLength?: number,
109
+ disableRequestLogging?: boolean,
110
+ exposeHeadRoutes?: boolean,
111
+ onProtoPoisoning?: ProtoAction,
112
+ onConstructorPoisoning?: ConstructorAction,
113
+ logger?: boolean | FastifyLoggerOptions<RawServer> & PinoLoggerOptions,
114
+ loggerInstance?: Logger
115
+ serializerOpts?: FJSOptions | Record<string, unknown>,
116
+ serverFactory?: FastifyServerFactory<RawServer>,
117
+ caseSensitive?: boolean,
118
+ allowUnsafeRegex?: boolean,
119
+ requestIdHeader?: string | false,
120
+ requestIdLogLabel?: string;
121
+ useSemicolonDelimiter?: boolean,
122
+ genReqId?: (req: RawRequestDefaultExpression<RawServer>) => string,
123
+ trustProxy?: boolean | string | string[] | number | TrustProxyFunction,
124
+ querystringParser?: (str: string) => { [key: string]: unknown },
125
+ constraints?: {
126
+ [name: string]: ConstraintStrategy<FindMyWayVersion<RawServer>, unknown>,
127
+ },
128
+ schemaController?: {
129
+ bucket?: (parentSchemas?: unknown) => {
130
+ add(schema: unknown): FastifyInstance;
131
+ getSchema(schemaId: string): unknown;
132
+ getSchemas(): Record<string, unknown>;
133
+ };
134
+ compilersFactory?: {
135
+ buildValidator?: ValidatorFactory;
136
+ buildSerializer?: SerializerFactory;
137
+ };
138
+ };
139
+ return503OnClosing?: boolean,
140
+ ajv?: {
141
+ customOptions?: AjvOptions,
142
+ plugins?: (Function | [Function, unknown])[]
143
+ },
144
+ frameworkErrors?: <RequestGeneric extends RequestGenericInterface = RequestGenericInterface, TypeProvider extends FastifyTypeProvider = FastifyTypeProviderDefault, SchemaCompiler extends FastifySchema = FastifySchema>(
145
+ error: FastifyError,
146
+ req: FastifyRequest<RequestGeneric, RawServer, RawRequestDefaultExpression<RawServer>, FastifySchema, TypeProvider>,
147
+ res: FastifyReply<RequestGeneric, RawServer, RawRequestDefaultExpression<RawServer>, RawReplyDefaultExpression<RawServer>, FastifyContextConfig, SchemaCompiler, TypeProvider>
148
+ ) => void,
149
+ rewriteUrl?: (
150
+ // The RawRequestDefaultExpression, RawReplyDefaultExpression, and FastifyTypeProviderDefault parameters
151
+ // should be narrowed further but those generic parameters are not passed to this FastifyServerOptions type
152
+ this: FastifyInstance<RawServer, RawRequestDefaultExpression<RawServer>, RawReplyDefaultExpression<RawServer>, Logger, FastifyTypeProviderDefault>,
153
+ req: RawRequestDefaultExpression<RawServer>
154
+ ) => string,
155
+ schemaErrorFormatter?: SchemaErrorFormatter,
156
+ /**
157
+ * listener to error events emitted by client connections
158
+ */
159
+ clientErrorHandler?: (error: ConnectionError, socket: Socket) => void,
160
+ childLoggerFactory?: FastifyChildLoggerFactory,
161
+ allowErrorHandlerOverride?: boolean
162
+ }
163
+
164
+ /**
165
+ * @deprecated use {@link FastifySchemaValidationError}
166
+ */
167
+ export type ValidationResult = FastifySchemaValidationError
168
+
169
+ /* Export additional types */
170
+ export type {
171
+ LightMyRequestChain, InjectOptions, LightMyRequestResponse, LightMyRequestCallback, // 'light-my-request'
172
+ FastifyRequest, RequestGenericInterface, // './types/request'
173
+ FastifyReply, // './types/reply'
174
+ FastifyPluginCallback, FastifyPluginAsync, FastifyPluginOptions, FastifyPlugin, // './types/plugin'
175
+ FastifyListenOptions, FastifyInstance, PrintRoutesOptions, // './types/instance'
176
+ FastifyLoggerOptions, FastifyBaseLogger, FastifyLoggerInstance, FastifyLogFn, LogLevel, // './types/logger'
177
+ FastifyRequestContext, FastifyContextConfig, FastifyReplyContext, // './types/context'
178
+ RouteHandler, RouteHandlerMethod, RouteOptions, RouteShorthandMethod, RouteShorthandOptions, RouteShorthandOptionsWithHandler, RouteGenericInterface, // './types/route'
179
+ FastifyRegister, FastifyRegisterOptions, RegisterOptions, // './types/register'
180
+ FastifyBodyParser, FastifyContentTypeParser, AddContentTypeParser, hasContentTypeParser, getDefaultJsonParser, ProtoAction, ConstructorAction, // './types/content-type-parser'
181
+ FastifyError, // '@fastify/error'
182
+ FastifySchema, FastifySchemaValidationError, FastifySchemaCompiler, FastifySerializerCompiler, // './types/schema'
183
+ HTTPMethods, RawServerBase, RawRequestDefaultExpression, RawReplyDefaultExpression, RawServerDefault, ContextConfigDefault, RequestBodyDefault, RequestQuerystringDefault, RequestParamsDefault, RequestHeadersDefault, // './types/utils'
184
+ DoneFuncWithErrOrRes, HookHandlerDoneFunction, RequestPayload, onCloseAsyncHookHandler, onCloseHookHandler, onErrorAsyncHookHandler, onErrorHookHandler, onReadyAsyncHookHandler, onReadyHookHandler, onListenAsyncHookHandler, onListenHookHandler, onRegisterHookHandler, onRequestAsyncHookHandler, onRequestHookHandler, onResponseAsyncHookHandler, onResponseHookHandler, onRouteHookHandler, onSendAsyncHookHandler, onSendHookHandler, onTimeoutAsyncHookHandler, onTimeoutHookHandler, preHandlerAsyncHookHandler, preHandlerHookHandler, preParsingAsyncHookHandler, preParsingHookHandler, preSerializationAsyncHookHandler, preSerializationHookHandler, preValidationAsyncHookHandler, preValidationHookHandler, onRequestAbortHookHandler, onRequestAbortAsyncHookHandler, preCloseAsyncHookHandler, preCloseHookHandler, // './types/hooks'
185
+ FastifyServerFactory, FastifyServerFactoryHandler, // './types/serverFactory'
186
+ FastifyTypeProvider, FastifyTypeProviderDefault, SafePromiseLike, // './types/type-provider'
187
+ FastifyErrorCodes // './types/errors'
188
+ }
189
+ // named export
190
+ // import { plugin } from 'plugin'
191
+ // const { plugin } = require('plugin')
192
+ export const fastify: Fastify
193
+ // default export
194
+ // import plugin from 'plugin'
195
+ export { fastify as default }
196
+ }
197
+
198
+ /**
199
+ * Fastify factory function for the standard fastify http, https, or http2 server instance.
200
+ *
201
+ * The default function utilizes http
202
+ *
203
+ * @param opts Fastify server options
204
+ * @returns Fastify server instance
205
+ */
206
+ declare function fastify<
207
+ Server extends http2.Http2SecureServer,
208
+ Request extends RawRequestDefaultExpression<Server> = RawRequestDefaultExpression<Server>,
209
+ Reply extends RawReplyDefaultExpression<Server> = RawReplyDefaultExpression<Server>,
210
+ Logger extends FastifyBaseLogger = FastifyBaseLogger,
211
+ TypeProvider extends FastifyTypeProvider = FastifyTypeProviderDefault
212
+ > (opts: fastify.FastifyHttp2SecureOptions<Server, Logger>): FastifyInstance<Server, Request, Reply, Logger, TypeProvider> & SafePromiseLike<FastifyInstance<Server, Request, Reply, Logger, TypeProvider>>
213
+
214
+ declare function fastify<
215
+ Server extends http2.Http2Server,
216
+ Request extends RawRequestDefaultExpression<Server> = RawRequestDefaultExpression<Server>,
217
+ Reply extends RawReplyDefaultExpression<Server> = RawReplyDefaultExpression<Server>,
218
+ Logger extends FastifyBaseLogger = FastifyBaseLogger,
219
+ TypeProvider extends FastifyTypeProvider = FastifyTypeProviderDefault
220
+ > (opts: fastify.FastifyHttp2Options<Server, Logger>): FastifyInstance<Server, Request, Reply, Logger, TypeProvider> & SafePromiseLike<FastifyInstance<Server, Request, Reply, Logger, TypeProvider>>
221
+
222
+ declare function fastify<
223
+ Server extends https.Server,
224
+ Request extends RawRequestDefaultExpression<Server> = RawRequestDefaultExpression<Server>,
225
+ Reply extends RawReplyDefaultExpression<Server> = RawReplyDefaultExpression<Server>,
226
+ Logger extends FastifyBaseLogger = FastifyBaseLogger,
227
+ TypeProvider extends FastifyTypeProvider = FastifyTypeProviderDefault
228
+ > (opts: fastify.FastifyHttpsOptions<Server, Logger>): FastifyInstance<Server, Request, Reply, Logger, TypeProvider> & SafePromiseLike<FastifyInstance<Server, Request, Reply, Logger, TypeProvider>>
229
+
230
+ declare function fastify<
231
+ Server extends http.Server,
232
+ Request extends RawRequestDefaultExpression<Server> = RawRequestDefaultExpression<Server>,
233
+ Reply extends RawReplyDefaultExpression<Server> = RawReplyDefaultExpression<Server>,
234
+ Logger extends FastifyBaseLogger = FastifyBaseLogger,
235
+ TypeProvider extends FastifyTypeProvider = FastifyTypeProviderDefault
236
+ > (opts?: fastify.FastifyHttpOptions<Server, Logger>): FastifyInstance<Server, Request, Reply, Logger, TypeProvider> & SafePromiseLike<FastifyInstance<Server, Request, Reply, Logger, TypeProvider>>
237
+
238
+ // CJS export
239
+ // const fastify = require('fastify')
240
+ export = fastify
novas/novacore-zephyr/claude-code-router/node_modules/fastify/fastify.js ADDED
@@ -0,0 +1,963 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 'use strict'
2
+
3
+ const VERSION = '5.5.0'
4
+
5
+ const Avvio = require('avvio')
6
+ const http = require('node:http')
7
+ const diagnostics = require('node:diagnostics_channel')
8
+ let lightMyRequest
9
+
10
+ const {
11
+ kAvvioBoot,
12
+ kChildren,
13
+ kServerBindings,
14
+ kBodyLimit,
15
+ kSupportedHTTPMethods,
16
+ kRoutePrefix,
17
+ kLogLevel,
18
+ kLogSerializers,
19
+ kHooks,
20
+ kSchemaController,
21
+ kRequestAcceptVersion,
22
+ kReplySerializerDefault,
23
+ kContentTypeParser,
24
+ kReply,
25
+ kRequest,
26
+ kFourOhFour,
27
+ kState,
28
+ kOptions,
29
+ kPluginNameChain,
30
+ kSchemaErrorFormatter,
31
+ kErrorHandler,
32
+ kKeepAliveConnections,
33
+ kChildLoggerFactory,
34
+ kGenReqId,
35
+ kErrorHandlerAlreadySet
36
+ } = require('./lib/symbols.js')
37
+
38
+ const { createServer } = require('./lib/server')
39
+ const Reply = require('./lib/reply')
40
+ const Request = require('./lib/request')
41
+ const Context = require('./lib/context.js')
42
+ const decorator = require('./lib/decorate')
43
+ const ContentTypeParser = require('./lib/contentTypeParser')
44
+ const SchemaController = require('./lib/schema-controller')
45
+ const { Hooks, hookRunnerApplication, supportedHooks } = require('./lib/hooks')
46
+ const { createChildLogger, defaultChildLoggerFactory, createLogger } = require('./lib/logger-factory')
47
+ const pluginUtils = require('./lib/pluginUtils')
48
+ const { getGenReqId, reqIdGenFactory } = require('./lib/reqIdGenFactory')
49
+ const { buildRouting, validateBodyLimitOption, buildRouterOptions } = require('./lib/route')
50
+ const build404 = require('./lib/fourOhFour')
51
+ const getSecuredInitialConfig = require('./lib/initialConfigValidation')
52
+ const override = require('./lib/pluginOverride')
53
+ const noopSet = require('./lib/noop-set')
54
+ const {
55
+ appendStackTrace,
56
+ AVVIO_ERRORS_MAP,
57
+ ...errorCodes
58
+ } = require('./lib/errors')
59
+ const PonyPromise = require('./lib/promise')
60
+
61
+ const { defaultInitOptions } = getSecuredInitialConfig
62
+
63
+ const {
64
+ FST_ERR_ASYNC_CONSTRAINT,
65
+ FST_ERR_BAD_URL,
66
+ FST_ERR_FORCE_CLOSE_CONNECTIONS_IDLE_NOT_AVAILABLE,
67
+ FST_ERR_OPTIONS_NOT_OBJ,
68
+ FST_ERR_QSP_NOT_FN,
69
+ FST_ERR_SCHEMA_CONTROLLER_BUCKET_OPT_NOT_FN,
70
+ FST_ERR_AJV_CUSTOM_OPTIONS_OPT_NOT_OBJ,
71
+ FST_ERR_AJV_CUSTOM_OPTIONS_OPT_NOT_ARR,
72
+ FST_ERR_INSTANCE_ALREADY_LISTENING,
73
+ FST_ERR_REOPENED_CLOSE_SERVER,
74
+ FST_ERR_ROUTE_REWRITE_NOT_STR,
75
+ FST_ERR_SCHEMA_ERROR_FORMATTER_NOT_FN,
76
+ FST_ERR_ERROR_HANDLER_NOT_FN,
77
+ FST_ERR_ERROR_HANDLER_ALREADY_SET,
78
+ FST_ERR_ROUTE_METHOD_INVALID
79
+ } = errorCodes
80
+
81
+ const { buildErrorHandler } = require('./lib/error-handler.js')
82
+ const { FSTWRN004 } = require('./lib/warnings.js')
83
+
84
+ const initChannel = diagnostics.channel('fastify.initialization')
85
+
86
+ function defaultBuildPrettyMeta (route) {
87
+ // return a shallow copy of route's sanitized context
88
+
89
+ const cleanKeys = {}
90
+ const allowedProps = ['errorHandler', 'logLevel', 'logSerializers']
91
+
92
+ allowedProps.concat(supportedHooks).forEach(k => {
93
+ cleanKeys[k] = route.store[k]
94
+ })
95
+
96
+ return Object.assign({}, cleanKeys)
97
+ }
98
+
99
+ /**
100
+ * @param {import('./fastify.js').FastifyServerOptions} options
101
+ */
102
+ function fastify (options) {
103
+ // Options validations
104
+ if (options && typeof options !== 'object') {
105
+ throw new FST_ERR_OPTIONS_NOT_OBJ()
106
+ } else {
107
+ // Shallow copy options object to prevent mutations outside of this function
108
+ options = Object.assign({}, options)
109
+ }
110
+
111
+ if (
112
+ (options.querystringParser && typeof options.querystringParser !== 'function') ||
113
+ (
114
+ options.routerOptions?.querystringParser &&
115
+ typeof options.routerOptions.querystringParser !== 'function'
116
+ )
117
+ ) {
118
+ throw new FST_ERR_QSP_NOT_FN(typeof (options.querystringParser ?? options.routerOptions.querystringParser))
119
+ }
120
+
121
+ if (options.schemaController && options.schemaController.bucket && typeof options.schemaController.bucket !== 'function') {
122
+ throw new FST_ERR_SCHEMA_CONTROLLER_BUCKET_OPT_NOT_FN(typeof options.schemaController.bucket)
123
+ }
124
+
125
+ validateBodyLimitOption(options.bodyLimit)
126
+
127
+ const requestIdHeader = typeof options.requestIdHeader === 'string' && options.requestIdHeader.length !== 0 ? options.requestIdHeader.toLowerCase() : (options.requestIdHeader === true && 'request-id')
128
+ const genReqId = reqIdGenFactory(requestIdHeader, options.genReqId)
129
+ const requestIdLogLabel = options.requestIdLogLabel || 'reqId'
130
+ const bodyLimit = options.bodyLimit || defaultInitOptions.bodyLimit
131
+ const disableRequestLogging = options.disableRequestLogging || false
132
+
133
+ const ajvOptions = Object.assign({
134
+ customOptions: {},
135
+ plugins: []
136
+ }, options.ajv)
137
+ const frameworkErrors = options.frameworkErrors
138
+
139
+ // Ajv options
140
+ if (!ajvOptions.customOptions || Object.prototype.toString.call(ajvOptions.customOptions) !== '[object Object]') {
141
+ throw new FST_ERR_AJV_CUSTOM_OPTIONS_OPT_NOT_OBJ(typeof ajvOptions.customOptions)
142
+ }
143
+ if (!ajvOptions.plugins || !Array.isArray(ajvOptions.plugins)) {
144
+ throw new FST_ERR_AJV_CUSTOM_OPTIONS_OPT_NOT_ARR(typeof ajvOptions.plugins)
145
+ }
146
+
147
+ // Instance Fastify components
148
+
149
+ const { logger, hasLogger } = createLogger(options)
150
+
151
+ // Update the options with the fixed values
152
+ options.connectionTimeout = options.connectionTimeout || defaultInitOptions.connectionTimeout
153
+ options.keepAliveTimeout = options.keepAliveTimeout || defaultInitOptions.keepAliveTimeout
154
+ options.maxRequestsPerSocket = options.maxRequestsPerSocket || defaultInitOptions.maxRequestsPerSocket
155
+ options.requestTimeout = options.requestTimeout || defaultInitOptions.requestTimeout
156
+ options.logger = logger
157
+ options.requestIdHeader = requestIdHeader
158
+ options.requestIdLogLabel = requestIdLogLabel
159
+ options.disableRequestLogging = disableRequestLogging
160
+ options.ajv = ajvOptions
161
+ options.clientErrorHandler = options.clientErrorHandler || defaultClientErrorHandler
162
+ options.allowErrorHandlerOverride = options.allowErrorHandlerOverride ?? defaultInitOptions.allowErrorHandlerOverride
163
+
164
+ const initialConfig = getSecuredInitialConfig(options)
165
+
166
+ // exposeHeadRoutes have its default set from the validator
167
+ options.exposeHeadRoutes = initialConfig.exposeHeadRoutes
168
+
169
+ options.routerOptions = buildRouterOptions(options, {
170
+ defaultRoute,
171
+ onBadUrl,
172
+ ignoreTrailingSlash: defaultInitOptions.ignoreTrailingSlash,
173
+ ignoreDuplicateSlashes: defaultInitOptions.ignoreDuplicateSlashes,
174
+ maxParamLength: defaultInitOptions.maxParamLength,
175
+ allowUnsafeRegex: defaultInitOptions.allowUnsafeRegex,
176
+ buildPrettyMeta: defaultBuildPrettyMeta,
177
+ useSemicolonDelimiter: defaultInitOptions.useSemicolonDelimiter
178
+ })
179
+
180
+ // Default router
181
+ const router = buildRouting({
182
+ config: options.routerOptions
183
+ })
184
+
185
+ // 404 router, used for handling encapsulated 404 handlers
186
+ const fourOhFour = build404(options)
187
+
188
+ // HTTP server and its handler
189
+ const httpHandler = wrapRouting(router, options)
190
+
191
+ // we need to set this before calling createServer
192
+ options.http2SessionTimeout = initialConfig.http2SessionTimeout
193
+ const { server, listen } = createServer(options, httpHandler)
194
+
195
+ const serverHasCloseAllConnections = typeof server.closeAllConnections === 'function'
196
+ const serverHasCloseIdleConnections = typeof server.closeIdleConnections === 'function'
197
+
198
+ let forceCloseConnections = options.forceCloseConnections
199
+ if (forceCloseConnections === 'idle' && !serverHasCloseIdleConnections) {
200
+ throw new FST_ERR_FORCE_CLOSE_CONNECTIONS_IDLE_NOT_AVAILABLE()
201
+ } else if (typeof forceCloseConnections !== 'boolean') {
202
+ /* istanbul ignore next: only one branch can be valid in a given Node.js version */
203
+ forceCloseConnections = serverHasCloseIdleConnections ? 'idle' : false
204
+ }
205
+
206
+ const keepAliveConnections = !serverHasCloseAllConnections && forceCloseConnections === true ? new Set() : noopSet()
207
+
208
+ const setupResponseListeners = Reply.setupResponseListeners
209
+ const schemaController = SchemaController.buildSchemaController(null, options.schemaController)
210
+
211
+ // Public API
212
+ const fastify = {
213
+ // Fastify internals
214
+ [kState]: {
215
+ listening: false,
216
+ closing: false,
217
+ started: false,
218
+ ready: false,
219
+ booting: false,
220
+ aborted: false,
221
+ readyResolver: null
222
+ },
223
+ [kKeepAliveConnections]: keepAliveConnections,
224
+ [kSupportedHTTPMethods]: {
225
+ bodyless: new Set([
226
+ // Standard
227
+ 'GET',
228
+ 'HEAD',
229
+ 'TRACE'
230
+ ]),
231
+ bodywith: new Set([
232
+ // Standard
233
+ 'DELETE',
234
+ 'OPTIONS',
235
+ 'PATCH',
236
+ 'PUT',
237
+ 'POST'
238
+ ])
239
+ },
240
+ [kOptions]: options,
241
+ [kChildren]: [],
242
+ [kServerBindings]: [],
243
+ [kBodyLimit]: bodyLimit,
244
+ [kRoutePrefix]: '',
245
+ [kLogLevel]: '',
246
+ [kLogSerializers]: null,
247
+ [kHooks]: new Hooks(),
248
+ [kSchemaController]: schemaController,
249
+ [kSchemaErrorFormatter]: null,
250
+ [kErrorHandler]: buildErrorHandler(),
251
+ [kErrorHandlerAlreadySet]: false,
252
+ [kChildLoggerFactory]: defaultChildLoggerFactory,
253
+ [kReplySerializerDefault]: null,
254
+ [kContentTypeParser]: new ContentTypeParser(
255
+ bodyLimit,
256
+ (options.onProtoPoisoning || defaultInitOptions.onProtoPoisoning),
257
+ (options.onConstructorPoisoning || defaultInitOptions.onConstructorPoisoning)
258
+ ),
259
+ [kReply]: Reply.buildReply(Reply),
260
+ [kRequest]: Request.buildRequest(Request, options.trustProxy),
261
+ [kFourOhFour]: fourOhFour,
262
+ [pluginUtils.kRegisteredPlugins]: [],
263
+ [kPluginNameChain]: ['fastify'],
264
+ [kAvvioBoot]: null,
265
+ [kGenReqId]: genReqId,
266
+ // routing method
267
+ routing: httpHandler,
268
+ // routes shorthand methods
269
+ delete: function _delete (url, options, handler) {
270
+ return router.prepareRoute.call(this, { method: 'DELETE', url, options, handler })
271
+ },
272
+ get: function _get (url, options, handler) {
273
+ return router.prepareRoute.call(this, { method: 'GET', url, options, handler })
274
+ },
275
+ head: function _head (url, options, handler) {
276
+ return router.prepareRoute.call(this, { method: 'HEAD', url, options, handler })
277
+ },
278
+ trace: function _trace (url, options, handler) {
279
+ return router.prepareRoute.call(this, { method: 'TRACE', url, options, handler })
280
+ },
281
+ patch: function _patch (url, options, handler) {
282
+ return router.prepareRoute.call(this, { method: 'PATCH', url, options, handler })
283
+ },
284
+ post: function _post (url, options, handler) {
285
+ return router.prepareRoute.call(this, { method: 'POST', url, options, handler })
286
+ },
287
+ put: function _put (url, options, handler) {
288
+ return router.prepareRoute.call(this, { method: 'PUT', url, options, handler })
289
+ },
290
+ options: function _options (url, options, handler) {
291
+ return router.prepareRoute.call(this, { method: 'OPTIONS', url, options, handler })
292
+ },
293
+ all: function _all (url, options, handler) {
294
+ return router.prepareRoute.call(this, { method: this.supportedMethods, url, options, handler })
295
+ },
296
+ // extended route
297
+ route: function _route (options) {
298
+ // we need the fastify object that we are producing so we apply a lazy loading of the function,
299
+ // otherwise we should bind it after the declaration
300
+ return router.route.call(this, { options })
301
+ },
302
+ hasRoute: function _route (options) {
303
+ return router.hasRoute.call(this, { options })
304
+ },
305
+ findRoute: function _findRoute (options) {
306
+ return router.findRoute(options)
307
+ },
308
+ // expose logger instance
309
+ log: logger,
310
+ // type provider
311
+ withTypeProvider,
312
+ // hooks
313
+ addHook,
314
+ // schemas
315
+ addSchema,
316
+ getSchema: schemaController.getSchema.bind(schemaController),
317
+ getSchemas: schemaController.getSchemas.bind(schemaController),
318
+ setValidatorCompiler,
319
+ setSerializerCompiler,
320
+ setSchemaController,
321
+ setReplySerializer,
322
+ setSchemaErrorFormatter,
323
+ // set generated request id
324
+ setGenReqId,
325
+ // custom parsers
326
+ addContentTypeParser: ContentTypeParser.helpers.addContentTypeParser,
327
+ hasContentTypeParser: ContentTypeParser.helpers.hasContentTypeParser,
328
+ getDefaultJsonParser: ContentTypeParser.defaultParsers.getDefaultJsonParser,
329
+ defaultTextParser: ContentTypeParser.defaultParsers.defaultTextParser,
330
+ removeContentTypeParser: ContentTypeParser.helpers.removeContentTypeParser,
331
+ removeAllContentTypeParsers: ContentTypeParser.helpers.removeAllContentTypeParsers,
332
+ // Fastify architecture methods (initialized by Avvio)
333
+ register: null,
334
+ after: null,
335
+ ready: null,
336
+ onClose: null,
337
+ close: null,
338
+ printPlugins: null,
339
+ hasPlugin: function (name) {
340
+ return this[pluginUtils.kRegisteredPlugins].includes(name) || this[kPluginNameChain].includes(name)
341
+ },
342
+ // http server
343
+ listen,
344
+ server,
345
+ addresses: function () {
346
+ /* istanbul ignore next */
347
+ const binded = this[kServerBindings].map(b => b.address())
348
+ binded.push(this.server.address())
349
+ return binded.filter(adr => adr)
350
+ },
351
+ // extend fastify objects
352
+ decorate: decorator.add,
353
+ hasDecorator: decorator.exist,
354
+ decorateReply: decorator.decorateReply,
355
+ decorateRequest: decorator.decorateRequest,
356
+ hasRequestDecorator: decorator.existRequest,
357
+ hasReplyDecorator: decorator.existReply,
358
+ getDecorator: decorator.getInstanceDecorator,
359
+ addHttpMethod,
360
+ // fake http injection
361
+ inject,
362
+ // pretty print of the registered routes
363
+ printRoutes,
364
+ // custom error handling
365
+ setNotFoundHandler,
366
+ setErrorHandler,
367
+ // child logger
368
+ setChildLoggerFactory,
369
+ // Set fastify initial configuration options read-only object
370
+ initialConfig,
371
+ // constraint strategies
372
+ addConstraintStrategy: router.addConstraintStrategy.bind(router),
373
+ hasConstraintStrategy: router.hasConstraintStrategy.bind(router)
374
+ }
375
+
376
+ Object.defineProperties(fastify, {
377
+ listeningOrigin: {
378
+ get () {
379
+ const address = this.addresses().slice(-1).pop()
380
+ /* ignore if windows: unix socket is not testable on Windows platform */
381
+ /* c8 ignore next 3 */
382
+ if (typeof address === 'string') {
383
+ return address
384
+ }
385
+ const host = address.family === 'IPv6' ? `[${address.address}]` : address.address
386
+ return `${this[kOptions].https ? 'https' : 'http'}://${host}:${address.port}`
387
+ }
388
+ },
389
+ pluginName: {
390
+ configurable: true,
391
+ get () {
392
+ if (this[kPluginNameChain].length > 1) {
393
+ return this[kPluginNameChain].join(' -> ')
394
+ }
395
+ return this[kPluginNameChain][0]
396
+ }
397
+ },
398
+ prefix: {
399
+ configurable: true,
400
+ get () { return this[kRoutePrefix] }
401
+ },
402
+ validatorCompiler: {
403
+ configurable: true,
404
+ get () { return this[kSchemaController].getValidatorCompiler() }
405
+ },
406
+ serializerCompiler: {
407
+ configurable: true,
408
+ get () { return this[kSchemaController].getSerializerCompiler() }
409
+ },
410
+ childLoggerFactory: {
411
+ configurable: true,
412
+ get () { return this[kChildLoggerFactory] }
413
+ },
414
+ version: {
415
+ configurable: true,
416
+ get () { return VERSION }
417
+ },
418
+ errorHandler: {
419
+ configurable: true,
420
+ get () {
421
+ return this[kErrorHandler].func
422
+ }
423
+ },
424
+ genReqId: {
425
+ configurable: true,
426
+ get () { return this[kGenReqId] }
427
+ },
428
+ supportedMethods: {
429
+ configurable: false,
430
+ get () {
431
+ return [
432
+ ...this[kSupportedHTTPMethods].bodyless,
433
+ ...this[kSupportedHTTPMethods].bodywith
434
+ ]
435
+ }
436
+ }
437
+ })
438
+
439
+ if (options.schemaErrorFormatter) {
440
+ validateSchemaErrorFormatter(options.schemaErrorFormatter)
441
+ fastify[kSchemaErrorFormatter] = options.schemaErrorFormatter.bind(fastify)
442
+ }
443
+
444
+ // Install and configure Avvio
445
+ // Avvio will update the following Fastify methods:
446
+ // - register
447
+ // - after
448
+ // - ready
449
+ // - onClose
450
+ // - close
451
+
452
+ const avvioPluginTimeout = Number(options.pluginTimeout)
453
+ const avvio = Avvio(fastify, {
454
+ autostart: false,
455
+ timeout: isNaN(avvioPluginTimeout) === false ? avvioPluginTimeout : defaultInitOptions.pluginTimeout,
456
+ expose: {
457
+ use: 'register'
458
+ }
459
+ })
460
+ // Override to allow the plugin encapsulation
461
+ avvio.override = override
462
+ avvio.on('start', () => (fastify[kState].started = true))
463
+ fastify[kAvvioBoot] = fastify.ready // the avvio ready function
464
+ fastify.ready = ready // overwrite the avvio ready function
465
+ fastify.printPlugins = avvio.prettyPrint.bind(avvio)
466
+
467
+ // cache the closing value, since we are checking it in an hot path
468
+ avvio.once('preReady', () => {
469
+ fastify.onClose((instance, done) => {
470
+ fastify[kState].closing = true
471
+ router.closeRoutes()
472
+
473
+ hookRunnerApplication('preClose', fastify[kAvvioBoot], fastify, function () {
474
+ if (fastify[kState].listening) {
475
+ /* istanbul ignore next: Cannot test this without Node.js core support */
476
+ if (forceCloseConnections === 'idle') {
477
+ // Not needed in Node 19
478
+ instance.server.closeIdleConnections()
479
+ /* istanbul ignore next: Cannot test this without Node.js core support */
480
+ } else if (serverHasCloseAllConnections && forceCloseConnections) {
481
+ instance.server.closeAllConnections()
482
+ } else if (forceCloseConnections === true) {
483
+ for (const conn of fastify[kKeepAliveConnections]) {
484
+ // We must invoke the destroy method instead of merely unreffing
485
+ // the sockets. If we only unref, then the callback passed to
486
+ // `fastify.close` will never be invoked; nor will any of the
487
+ // registered `onClose` hooks.
488
+ conn.destroy()
489
+ fastify[kKeepAliveConnections].delete(conn)
490
+ }
491
+ }
492
+ }
493
+
494
+ // No new TCP connections are accepted.
495
+ // We must call close on the server even if we are not listening
496
+ // otherwise memory will be leaked.
497
+ // https://github.com/nodejs/node/issues/48604
498
+ if (!options.serverFactory || fastify[kState].listening) {
499
+ instance.server.close(function (err) {
500
+ /* c8 ignore next 6 */
501
+ if (err && err.code !== 'ERR_SERVER_NOT_RUNNING') {
502
+ done(null)
503
+ } else {
504
+ done()
505
+ }
506
+ })
507
+ } else {
508
+ process.nextTick(done, null)
509
+ }
510
+ })
511
+ })
512
+ })
513
+
514
+ // Create bad URL context
515
+ const onBadUrlContext = new Context({
516
+ server: fastify,
517
+ config: {}
518
+ })
519
+
520
+ // Set the default 404 handler
521
+ fastify.setNotFoundHandler()
522
+ fourOhFour.arrange404(fastify)
523
+
524
+ router.setup(options, {
525
+ avvio,
526
+ fourOhFour,
527
+ logger,
528
+ hasLogger,
529
+ setupResponseListeners,
530
+ throwIfAlreadyStarted,
531
+ keepAliveConnections
532
+ })
533
+
534
+ // Delay configuring clientError handler so that it can access fastify state.
535
+ server.on('clientError', options.clientErrorHandler.bind(fastify))
536
+
537
+ if (initChannel.hasSubscribers) {
538
+ initChannel.publish({ fastify })
539
+ }
540
+
541
+ // Older nodejs versions may not have asyncDispose
542
+ if ('asyncDispose' in Symbol) {
543
+ fastify[Symbol.asyncDispose] = function dispose () {
544
+ return fastify.close()
545
+ }
546
+ }
547
+
548
+ return fastify
549
+
550
+ function throwIfAlreadyStarted (msg) {
551
+ if (fastify[kState].started) throw new FST_ERR_INSTANCE_ALREADY_LISTENING(msg)
552
+ }
553
+
554
+ // HTTP injection handling
555
+ // If the server is not ready yet, this
556
+ // utility will automatically force it.
557
+ function inject (opts, cb) {
558
+ // lightMyRequest is dynamically loaded as it seems very expensive
559
+ // because of Ajv
560
+ if (lightMyRequest === undefined) {
561
+ lightMyRequest = require('light-my-request')
562
+ }
563
+
564
+ if (fastify[kState].started) {
565
+ if (fastify[kState].closing) {
566
+ // Force to return an error
567
+ const error = new FST_ERR_REOPENED_CLOSE_SERVER()
568
+ if (cb) {
569
+ cb(error)
570
+ return
571
+ } else {
572
+ return Promise.reject(error)
573
+ }
574
+ }
575
+ return lightMyRequest(httpHandler, opts, cb)
576
+ }
577
+
578
+ if (cb) {
579
+ this.ready(err => {
580
+ if (err) cb(err, null)
581
+ else lightMyRequest(httpHandler, opts, cb)
582
+ })
583
+ } else {
584
+ return lightMyRequest((req, res) => {
585
+ this.ready(function (err) {
586
+ if (err) {
587
+ res.emit('error', err)
588
+ return
589
+ }
590
+ httpHandler(req, res)
591
+ })
592
+ }, opts)
593
+ }
594
+ }
595
+
596
+ function ready (cb) {
597
+ if (this[kState].readyResolver !== null) {
598
+ if (cb != null) {
599
+ this[kState].readyResolver.promise.then(() => cb(null, fastify), cb)
600
+ return
601
+ }
602
+
603
+ return this[kState].readyResolver.promise
604
+ }
605
+
606
+ // run the hooks after returning the promise
607
+ process.nextTick(runHooks)
608
+
609
+ // Create a promise no matter what
610
+ // It will work as a barrier for all the .ready() calls (ensuring single hook execution)
611
+ // as well as a flow control mechanism to chain cbs and further
612
+ // promises
613
+ this[kState].readyResolver = PonyPromise.withResolvers()
614
+
615
+ if (!cb) {
616
+ return this[kState].readyResolver.promise
617
+ } else {
618
+ this[kState].readyResolver.promise.then(() => cb(null, fastify), cb)
619
+ }
620
+
621
+ function runHooks () {
622
+ // start loading
623
+ fastify[kAvvioBoot]((err, done) => {
624
+ if (err || fastify[kState].started || fastify[kState].ready || fastify[kState].booting) {
625
+ manageErr(err)
626
+ } else {
627
+ fastify[kState].booting = true
628
+ hookRunnerApplication('onReady', fastify[kAvvioBoot], fastify, manageErr)
629
+ }
630
+ done()
631
+ })
632
+ }
633
+
634
+ function manageErr (err) {
635
+ // If the error comes out of Avvio's Error codes
636
+ // We create a make and preserve the previous error
637
+ // as cause
638
+ err = err != null && AVVIO_ERRORS_MAP[err.code] != null
639
+ ? appendStackTrace(err, new AVVIO_ERRORS_MAP[err.code](err.message))
640
+ : err
641
+
642
+ if (err) {
643
+ return fastify[kState].readyResolver.reject(err)
644
+ }
645
+
646
+ fastify[kState].readyResolver.resolve(fastify)
647
+ fastify[kState].booting = false
648
+ fastify[kState].ready = true
649
+ fastify[kState].readyResolver = null
650
+ }
651
+ }
652
+
653
+ // Used exclusively in TypeScript contexts to enable auto type inference from JSON schema.
654
+ function withTypeProvider () {
655
+ return this
656
+ }
657
+
658
+ // wrapper that we expose to the user for hooks handling
659
+ function addHook (name, fn) {
660
+ throwIfAlreadyStarted('Cannot call "addHook"!')
661
+
662
+ if (fn == null) {
663
+ throw new errorCodes.FST_ERR_HOOK_INVALID_HANDLER(name, fn)
664
+ }
665
+
666
+ if (name === 'onSend' || name === 'preSerialization' || name === 'onError' || name === 'preParsing') {
667
+ if (fn.constructor.name === 'AsyncFunction' && fn.length === 4) {
668
+ throw new errorCodes.FST_ERR_HOOK_INVALID_ASYNC_HANDLER()
669
+ }
670
+ } else if (name === 'onReady' || name === 'onListen') {
671
+ if (fn.constructor.name === 'AsyncFunction' && fn.length !== 0) {
672
+ throw new errorCodes.FST_ERR_HOOK_INVALID_ASYNC_HANDLER()
673
+ }
674
+ } else if (name === 'onRequestAbort') {
675
+ if (fn.constructor.name === 'AsyncFunction' && fn.length !== 1) {
676
+ throw new errorCodes.FST_ERR_HOOK_INVALID_ASYNC_HANDLER()
677
+ }
678
+ } else {
679
+ if (fn.constructor.name === 'AsyncFunction' && fn.length === 3) {
680
+ throw new errorCodes.FST_ERR_HOOK_INVALID_ASYNC_HANDLER()
681
+ }
682
+ }
683
+
684
+ if (name === 'onClose') {
685
+ this.onClose(fn.bind(this))
686
+ } else if (name === 'onReady' || name === 'onListen' || name === 'onRoute') {
687
+ this[kHooks].add(name, fn)
688
+ } else {
689
+ this.after((err, done) => {
690
+ try {
691
+ _addHook.call(this, name, fn)
692
+ done(err)
693
+ } catch (err) {
694
+ done(err)
695
+ }
696
+ })
697
+ }
698
+ return this
699
+
700
+ function _addHook (name, fn) {
701
+ this[kHooks].add(name, fn)
702
+ this[kChildren].forEach(child => _addHook.call(child, name, fn))
703
+ }
704
+ }
705
+
706
+ // wrapper that we expose to the user for schemas handling
707
+ function addSchema (schema) {
708
+ throwIfAlreadyStarted('Cannot call "addSchema"!')
709
+ this[kSchemaController].add(schema)
710
+ this[kChildren].forEach(child => child.addSchema(schema))
711
+ return this
712
+ }
713
+
714
+ function defaultClientErrorHandler (err, socket) {
715
+ // In case of a connection reset, the socket has been destroyed and there is nothing that needs to be done.
716
+ // https://nodejs.org/api/http.html#http_event_clienterror
717
+ if (err.code === 'ECONNRESET' || socket.destroyed) {
718
+ return
719
+ }
720
+
721
+ let body, errorCode, errorStatus, errorLabel
722
+
723
+ if (err.code === 'ERR_HTTP_REQUEST_TIMEOUT') {
724
+ errorCode = '408'
725
+ errorStatus = http.STATUS_CODES[errorCode]
726
+ body = `{"error":"${errorStatus}","message":"Client Timeout","statusCode":408}`
727
+ errorLabel = 'timeout'
728
+ } else if (err.code === 'HPE_HEADER_OVERFLOW') {
729
+ errorCode = '431'
730
+ errorStatus = http.STATUS_CODES[errorCode]
731
+ body = `{"error":"${errorStatus}","message":"Exceeded maximum allowed HTTP header size","statusCode":431}`
732
+ errorLabel = 'header_overflow'
733
+ } else {
734
+ errorCode = '400'
735
+ errorStatus = http.STATUS_CODES[errorCode]
736
+ body = `{"error":"${errorStatus}","message":"Client Error","statusCode":400}`
737
+ errorLabel = 'error'
738
+ }
739
+
740
+ // Most devs do not know what to do with this error.
741
+ // In the vast majority of cases, it's a network error and/or some
742
+ // config issue on the load balancer side.
743
+ this.log.trace({ err }, `client ${errorLabel}`)
744
+ // Copying standard node behavior
745
+ // https://github.com/nodejs/node/blob/6ca23d7846cb47e84fd344543e394e50938540be/lib/_http_server.js#L666
746
+
747
+ // If the socket is not writable, there is no reason to try to send data.
748
+ if (socket.writable) {
749
+ socket.write(`HTTP/1.1 ${errorCode} ${errorStatus}\r\nContent-Length: ${body.length}\r\nContent-Type: application/json\r\n\r\n${body}`)
750
+ }
751
+ socket.destroy(err)
752
+ }
753
+
754
+ // If the router does not match any route, every request will land here
755
+ // req and res are Node.js core objects
756
+ function defaultRoute (req, res) {
757
+ if (req.headers['accept-version'] !== undefined) {
758
+ // we remove the accept-version header for performance result
759
+ // because we do not want to go through the constraint checking
760
+ // the usage of symbol here to prevent any collision on custom header name
761
+ req.headers[kRequestAcceptVersion] = req.headers['accept-version']
762
+ req.headers['accept-version'] = undefined
763
+ }
764
+ fourOhFour.router.lookup(req, res)
765
+ }
766
+
767
+ function onBadUrl (path, req, res) {
768
+ if (frameworkErrors) {
769
+ const id = getGenReqId(onBadUrlContext.server, req)
770
+ const childLogger = createChildLogger(onBadUrlContext, logger, req, id)
771
+
772
+ const request = new Request(id, null, req, null, childLogger, onBadUrlContext)
773
+ const reply = new Reply(res, request, childLogger)
774
+
775
+ if (disableRequestLogging === false) {
776
+ childLogger.info({ req: request }, 'incoming request')
777
+ }
778
+
779
+ return frameworkErrors(new FST_ERR_BAD_URL(path), request, reply)
780
+ }
781
+ const body = `{"error":"Bad Request","code":"FST_ERR_BAD_URL","message":"'${path}' is not a valid url component","statusCode":400}`
782
+ res.writeHead(400, {
783
+ 'Content-Type': 'application/json',
784
+ 'Content-Length': body.length
785
+ })
786
+ res.end(body)
787
+ }
788
+
789
+ function buildAsyncConstraintCallback (isAsync, req, res) {
790
+ if (isAsync === false) return undefined
791
+ return function onAsyncConstraintError (err) {
792
+ if (err) {
793
+ if (frameworkErrors) {
794
+ const id = getGenReqId(onBadUrlContext.server, req)
795
+ const childLogger = createChildLogger(onBadUrlContext, logger, req, id)
796
+
797
+ const request = new Request(id, null, req, null, childLogger, onBadUrlContext)
798
+ const reply = new Reply(res, request, childLogger)
799
+
800
+ if (disableRequestLogging === false) {
801
+ childLogger.info({ req: request }, 'incoming request')
802
+ }
803
+
804
+ return frameworkErrors(new FST_ERR_ASYNC_CONSTRAINT(), request, reply)
805
+ }
806
+ const body = '{"error":"Internal Server Error","message":"Unexpected error from async constraint","statusCode":500}'
807
+ res.writeHead(500, {
808
+ 'Content-Type': 'application/json',
809
+ 'Content-Length': body.length
810
+ })
811
+ res.end(body)
812
+ }
813
+ }
814
+ }
815
+
816
+ function setNotFoundHandler (opts, handler) {
817
+ throwIfAlreadyStarted('Cannot call "setNotFoundHandler"!')
818
+
819
+ fourOhFour.setNotFoundHandler.call(this, opts, handler, avvio, router.routeHandler)
820
+ return this
821
+ }
822
+
823
+ function setValidatorCompiler (validatorCompiler) {
824
+ throwIfAlreadyStarted('Cannot call "setValidatorCompiler"!')
825
+ this[kSchemaController].setValidatorCompiler(validatorCompiler)
826
+ return this
827
+ }
828
+
829
+ function setSchemaErrorFormatter (errorFormatter) {
830
+ throwIfAlreadyStarted('Cannot call "setSchemaErrorFormatter"!')
831
+ validateSchemaErrorFormatter(errorFormatter)
832
+ this[kSchemaErrorFormatter] = errorFormatter.bind(this)
833
+ return this
834
+ }
835
+
836
+ function setSerializerCompiler (serializerCompiler) {
837
+ throwIfAlreadyStarted('Cannot call "setSerializerCompiler"!')
838
+ this[kSchemaController].setSerializerCompiler(serializerCompiler)
839
+ return this
840
+ }
841
+
842
+ function setSchemaController (schemaControllerOpts) {
843
+ throwIfAlreadyStarted('Cannot call "setSchemaController"!')
844
+ const old = this[kSchemaController]
845
+ const schemaController = SchemaController.buildSchemaController(old, Object.assign({}, old.opts, schemaControllerOpts))
846
+ this[kSchemaController] = schemaController
847
+ this.getSchema = schemaController.getSchema.bind(schemaController)
848
+ this.getSchemas = schemaController.getSchemas.bind(schemaController)
849
+ return this
850
+ }
851
+
852
+ function setReplySerializer (replySerializer) {
853
+ throwIfAlreadyStarted('Cannot call "setReplySerializer"!')
854
+
855
+ this[kReplySerializerDefault] = replySerializer
856
+ return this
857
+ }
858
+
859
+ // wrapper that we expose to the user for configure the custom error handler
860
+ function setErrorHandler (func) {
861
+ throwIfAlreadyStarted('Cannot call "setErrorHandler"!')
862
+
863
+ if (typeof func !== 'function') {
864
+ throw new FST_ERR_ERROR_HANDLER_NOT_FN()
865
+ }
866
+
867
+ if (!options.allowErrorHandlerOverride && this[kErrorHandlerAlreadySet]) {
868
+ throw new FST_ERR_ERROR_HANDLER_ALREADY_SET()
869
+ } else if (this[kErrorHandlerAlreadySet]) {
870
+ FSTWRN004("To disable this behavior, set 'allowErrorHandlerOverride' to false or ignore this message. For more information, visit: https://fastify.dev/docs/latest/Reference/Server/#allowerrorhandleroverride")
871
+ }
872
+
873
+ this[kErrorHandlerAlreadySet] = true
874
+ this[kErrorHandler] = buildErrorHandler(this[kErrorHandler], func.bind(this))
875
+ return this
876
+ }
877
+
878
+ function setChildLoggerFactory (factory) {
879
+ throwIfAlreadyStarted('Cannot call "setChildLoggerFactory"!')
880
+
881
+ this[kChildLoggerFactory] = factory
882
+ return this
883
+ }
884
+
885
+ function printRoutes (opts = {}) {
886
+ // includeHooks:true - shortcut to include all supported hooks exported by fastify.Hooks
887
+ opts.includeMeta = opts.includeHooks ? opts.includeMeta ? supportedHooks.concat(opts.includeMeta) : supportedHooks : opts.includeMeta
888
+ return router.printRoutes(opts)
889
+ }
890
+
891
+ function wrapRouting (router, { rewriteUrl, logger }) {
892
+ let isAsync
893
+ return function preRouting (req, res) {
894
+ // only call isAsyncConstraint once
895
+ if (isAsync === undefined) isAsync = router.isAsyncConstraint()
896
+ if (rewriteUrl) {
897
+ req.originalUrl = req.url
898
+ const url = rewriteUrl.call(fastify, req)
899
+ if (typeof url === 'string') {
900
+ req.url = url
901
+ } else {
902
+ const err = new FST_ERR_ROUTE_REWRITE_NOT_STR(req.url, typeof url)
903
+ req.destroy(err)
904
+ }
905
+ }
906
+ router.routing(req, res, buildAsyncConstraintCallback(isAsync, req, res))
907
+ }
908
+ }
909
+
910
+ function setGenReqId (func) {
911
+ throwIfAlreadyStarted('Cannot call "setGenReqId"!')
912
+
913
+ this[kGenReqId] = reqIdGenFactory(this[kOptions].requestIdHeader, func)
914
+ return this
915
+ }
916
+
917
+ function addHttpMethod (method, { hasBody = false } = {}) {
918
+ if (typeof method !== 'string' || http.METHODS.indexOf(method) === -1) {
919
+ throw new FST_ERR_ROUTE_METHOD_INVALID()
920
+ }
921
+
922
+ if (hasBody === true) {
923
+ this[kSupportedHTTPMethods].bodywith.add(method)
924
+ this[kSupportedHTTPMethods].bodyless.delete(method)
925
+ } else {
926
+ this[kSupportedHTTPMethods].bodywith.delete(method)
927
+ this[kSupportedHTTPMethods].bodyless.add(method)
928
+ }
929
+
930
+ const _method = method.toLowerCase()
931
+ if (!this.hasDecorator(_method)) {
932
+ this.decorate(_method, function (url, options, handler) {
933
+ return router.prepareRoute.call(this, { method, url, options, handler })
934
+ })
935
+ }
936
+
937
+ return this
938
+ }
939
+ }
940
+
941
+ function validateSchemaErrorFormatter (schemaErrorFormatter) {
942
+ if (typeof schemaErrorFormatter !== 'function') {
943
+ throw new FST_ERR_SCHEMA_ERROR_FORMATTER_NOT_FN(typeof schemaErrorFormatter)
944
+ } else if (schemaErrorFormatter.constructor.name === 'AsyncFunction') {
945
+ throw new FST_ERR_SCHEMA_ERROR_FORMATTER_NOT_FN('AsyncFunction')
946
+ }
947
+ }
948
+
949
+ /**
950
+ * These export configurations enable JS and TS developers
951
+ * to consume fastify in whatever way best suits their needs.
952
+ * Some examples of supported import syntax includes:
953
+ * - `const fastify = require('fastify')`
954
+ * - `const { fastify } = require('fastify')`
955
+ * - `import * as Fastify from 'fastify'`
956
+ * - `import { fastify, TSC_definition } from 'fastify'`
957
+ * - `import fastify from 'fastify'`
958
+ * - `import fastify, { TSC_definition } from 'fastify'`
959
+ */
960
+ module.exports = fastify
961
+ module.exports.errorCodes = errorCodes
962
+ module.exports.fastify = fastify
963
+ module.exports.default = fastify
novas/novacore-zephyr/claude-code-router/node_modules/fastify/package.json ADDED
@@ -0,0 +1,225 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "fastify",
3
+ "version": "5.5.0",
4
+ "description": "Fast and low overhead web framework, for Node.js",
5
+ "main": "fastify.js",
6
+ "type": "commonjs",
7
+ "types": "fastify.d.ts",
8
+ "scripts": {
9
+ "bench": "branchcmp -r 2 -g -s \"npm run benchmark\"",
10
+ "benchmark": "concurrently -k -s first \"node ./examples/benchmark/simple.js\" \"autocannon -c 100 -d 30 -p 10 localhost:3000/\"",
11
+ "benchmark:parser": "concurrently -k -s first \"node ./examples/benchmark/parser.js\" \"autocannon -c 100 -d 30 -p 10 -i ./examples/benchmark/body.json -H \"content-type:application/jsoff\" -m POST localhost:3000/\"",
12
+ "benchmark:parser:error": "concurrently -k -s first \"node ./examples/benchmark/parser.js\" \"autocannon -c 100 -d 30 -p 10 -i ./examples/benchmark/body.json -H \"content-type:application/jsoff\" -H \"content-length:123\" -m POST localhost:3000/\"",
13
+ "build:validation": "node build/build-error-serializer.js && node build/build-validation.js",
14
+ "coverage": "c8 --reporter html borp --reporter=@jsumners/line-reporter --coverage --check-coverage --lines 100 ",
15
+ "coverage:ci-check-coverage": "borp --reporter=@jsumners/line-reporter --coverage --check-coverage --lines 100",
16
+ "lint": "npm run lint:eslint",
17
+ "lint:fix": "eslint --fix",
18
+ "lint:markdown": "markdownlint-cli2",
19
+ "lint:eslint": "eslint",
20
+ "prepublishOnly": "cross-env PREPUBLISH=true borp --reporter=@jsumners/line-reporter && npm run test:validator:integrity",
21
+ "test": "npm run lint && npm run unit && npm run test:typescript",
22
+ "test:ci": "npm run unit && npm run test:typescript",
23
+ "test:report": "npm run lint && npm run unit:report && npm run test:typescript",
24
+ "test:validator:integrity": "npm run build:validation && git diff --quiet --ignore-all-space --ignore-blank-lines --ignore-cr-at-eol lib/error-serializer.js && git diff --quiet --ignore-all-space --ignore-blank-lines --ignore-cr-at-eol lib/configValidator.js",
25
+ "test:typescript": "tsc test/types/import.ts --target es2022 --moduleResolution node16 --module node16 --noEmit && tsd",
26
+ "test:watch": "npm run unit -- --watch --coverage-report=none --reporter=terse",
27
+ "unit": "borp",
28
+ "unit:report": "c8 --reporter html borp --reporter=@jsumners/line-reporter",
29
+ "citgm": "borp --reporter=@jsumners/line-reporter --coverage --check-coverage --concurrency=1"
30
+ },
31
+ "repository": {
32
+ "type": "git",
33
+ "url": "git+https://github.com/fastify/fastify.git"
34
+ },
35
+ "keywords": [
36
+ "web",
37
+ "framework",
38
+ "json",
39
+ "schema",
40
+ "open",
41
+ "api"
42
+ ],
43
+ "author": "Matteo Collina <hello@matteocollina.com>",
44
+ "contributors": [
45
+ {
46
+ "name": "Tomas Della Vedova",
47
+ "url": "http://delved.org",
48
+ "author": true
49
+ },
50
+ {
51
+ "name": "Tommaso Allevi",
52
+ "email": "tomallevi@gmail.com"
53
+ },
54
+ {
55
+ "name": "Ethan Arrowood",
56
+ "url": "https://github.com/Ethan-Arrowood",
57
+ "email": "ethan.arrowood@gmail.com"
58
+ },
59
+ {
60
+ "name": "Dustin Deus",
61
+ "url": "http://starptech.de",
62
+ "email": "deusdustin@gmail.com"
63
+ },
64
+ {
65
+ "name": "Ayoub El Khattabi",
66
+ "url": "https://github.com/AyoubElk",
67
+ "email": "elkhattabi.ayoub@gmail.com"
68
+ },
69
+ {
70
+ "name": "Rafael Gonzaga",
71
+ "email": "rafael.nunu@hotmail.com",
72
+ "url": "https://github.com/rafaelgss"
73
+ },
74
+ {
75
+ "name": "Trivikram Kamat",
76
+ "url": "http://trivikr.github.io",
77
+ "email": "trivikr.dev@gmail.com"
78
+ },
79
+ {
80
+ "name": "Luciano Mammino",
81
+ "url": "https://loige.co"
82
+ },
83
+ {
84
+ "name": "Cemre Mengu",
85
+ "email": "cemremengu@gmail.com"
86
+ },
87
+ {
88
+ "name": "Evan Shortiss",
89
+ "email": "evanshortiss@gmail.com"
90
+ },
91
+ {
92
+ "name": "Maksim Sinik",
93
+ "url": "https://maksim.dev"
94
+ },
95
+ {
96
+ "name": "Manuel Spigolon",
97
+ "email": "behemoth89@gmail.com"
98
+ },
99
+ {
100
+ "name": "James Sumners",
101
+ "url": "https://james.sumners.info"
102
+ },
103
+ {
104
+ "name": "Denis Fäcke",
105
+ "url": "https://github.com/SerayaEryn"
106
+ },
107
+ {
108
+ "name": "Igor Savin",
109
+ "email": "kibertoad@gmail.com",
110
+ "url": "https://github.com/kibertoad"
111
+ },
112
+ {
113
+ "name": "Vincent Le Goff",
114
+ "email": "vince.legoff@gmail.com",
115
+ "url": "https://github.com/zekth"
116
+ },
117
+ {
118
+ "name": "Luis Orbaiceta",
119
+ "email": "luisorbaiceta@gmail.com",
120
+ "url": "https://luisorbaiceta.com"
121
+ },
122
+ {
123
+ "name": "Carlos Fuentes",
124
+ "email": "me@metcoder.dev",
125
+ "url": "https://metcoder.dev"
126
+ },
127
+ {
128
+ "name": "Gürgün Dayıoğlu",
129
+ "email": "hey@gurgun.day",
130
+ "url": "https://heyhey.to/G"
131
+ },
132
+ {
133
+ "name": "Aras Abbasi",
134
+ "email": "aras.abbasi@gmail.com"
135
+ },
136
+ {
137
+ "name": "Frazer Smith",
138
+ "email": "frazer.dev@icloud.com",
139
+ "url": "https://github.com/fdawgs"
140
+ },
141
+ {
142
+ "name": "KaKa Ng",
143
+ "email": "kaka@kakang.dev",
144
+ "url": "https://github.com/climba03003"
145
+ },
146
+ {
147
+ "name": "Jean Michelet",
148
+ "email": "jean.antoine.michelet@gmail.com",
149
+ "url": "https://github.com/jean-michelet"
150
+ }
151
+ ],
152
+ "license": "MIT",
153
+ "bugs": {
154
+ "url": "https://github.com/fastify/fastify/issues"
155
+ },
156
+ "homepage": "https://fastify.dev/",
157
+ "funding": [
158
+ {
159
+ "type": "github",
160
+ "url": "https://github.com/sponsors/fastify"
161
+ },
162
+ {
163
+ "type": "opencollective",
164
+ "url": "https://opencollective.com/fastify"
165
+ }
166
+ ],
167
+ "devDependencies": {
168
+ "@fastify/pre-commit": "^2.1.0",
169
+ "@jsumners/line-reporter": "^1.0.1",
170
+ "@sinclair/typebox": "^0.34.13",
171
+ "@sinonjs/fake-timers": "^11.2.2",
172
+ "@stylistic/eslint-plugin": "^5.1.0",
173
+ "@stylistic/eslint-plugin-js": "^4.1.0",
174
+ "@types/node": "^24.0.12",
175
+ "ajv": "^8.12.0",
176
+ "ajv-errors": "^3.0.0",
177
+ "ajv-formats": "^3.0.1",
178
+ "ajv-i18n": "^4.2.0",
179
+ "ajv-merge-patch": "^5.0.1",
180
+ "autocannon": "^8.0.0",
181
+ "borp": "^0.20.0",
182
+ "branch-comparer": "^1.1.0",
183
+ "concurrently": "^9.1.2",
184
+ "cross-env": "^10.0.0",
185
+ "eslint": "^9.0.0",
186
+ "fast-json-body": "^1.1.0",
187
+ "fastify-plugin": "^5.0.0",
188
+ "fluent-json-schema": "^6.0.0",
189
+ "h2url": "^0.2.0",
190
+ "http-errors": "^2.0.0",
191
+ "joi": "^17.12.3",
192
+ "json-schema-to-ts": "^3.0.1",
193
+ "JSONStream": "^1.3.5",
194
+ "markdownlint-cli2": "^0.18.1",
195
+ "neostandard": "^0.12.0",
196
+ "node-forge": "^1.3.1",
197
+ "proxyquire": "^2.1.3",
198
+ "split2": "^4.2.0",
199
+ "tsd": "^0.32.0",
200
+ "typescript": "~5.9.2",
201
+ "undici": "^7.11.0",
202
+ "vary": "^1.1.2",
203
+ "yup": "^1.4.0"
204
+ },
205
+ "dependencies": {
206
+ "@fastify/ajv-compiler": "^4.0.0",
207
+ "@fastify/error": "^4.0.0",
208
+ "@fastify/fast-json-stringify-compiler": "^5.0.0",
209
+ "@fastify/proxy-addr": "^5.0.0",
210
+ "abstract-logging": "^2.0.1",
211
+ "avvio": "^9.0.0",
212
+ "fast-json-stringify": "^6.0.0",
213
+ "find-my-way": "^9.0.0",
214
+ "light-my-request": "^6.0.0",
215
+ "pino": "^9.0.0",
216
+ "process-warning": "^5.0.0",
217
+ "rfdc": "^1.3.1",
218
+ "secure-json-parse": "^4.0.0",
219
+ "semver": "^7.6.0",
220
+ "toad-cache": "^3.7.0"
221
+ },
222
+ "tsd": {
223
+ "directory": "test/types"
224
+ }
225
+ }
novas/novacore-zephyr/claude-code-router/node_modules/json5/LICENSE.md ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ MIT License
2
+
3
+ Copyright (c) 2012-2018 Aseem Kishore, and [others].
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+
23
+ [others]: https://github.com/json5/json5/contributors
novas/novacore-zephyr/claude-code-router/node_modules/json5/README.md ADDED
@@ -0,0 +1,282 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # JSON5 – JSON for Humans
2
+
3
+ [![Build Status](https://app.travis-ci.com/json5/json5.svg?branch=main)][Build
4
+ Status] [![Coverage
5
+ Status](https://coveralls.io/repos/github/json5/json5/badge.svg)][Coverage
6
+ Status]
7
+
8
+ JSON5 is an extension to the popular [JSON] file format that aims to be
9
+ easier to **write and maintain _by hand_ (e.g. for config files)**.
10
+ It is _not intended_ to be used for machine-to-machine communication.
11
+ (Keep using JSON or other file formats for that. 🙂)
12
+
13
+ JSON5 was started in 2012, and as of 2022, now gets **[>65M downloads/week](https://www.npmjs.com/package/json5)**,
14
+ ranks in the **[top 0.1%](https://gist.github.com/anvaka/8e8fa57c7ee1350e3491)** of the most depended-upon packages on npm,
15
+ and has been adopted by major projects like
16
+ **[Chromium](https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/renderer/platform/runtime_enabled_features.json5;drc=5de823b36e68fd99009a29281b17bc3a1d6b329c),
17
+ [Next.js](https://github.com/vercel/next.js/blob/b88f20c90bf4659b8ad5cb2a27956005eac2c7e8/packages/next/lib/find-config.ts#L43-L46),
18
+ [Babel](https://babeljs.io/docs/en/config-files#supported-file-extensions),
19
+ [Retool](https://community.retool.com/t/i-am-attempting-to-append-several-text-fields-to-a-google-sheet-but-receiving-a-json5-invalid-character-error/7626),
20
+ [WebStorm](https://www.jetbrains.com/help/webstorm/json.html),
21
+ and [more](https://github.com/json5/json5/wiki/In-the-Wild)**.
22
+ It's also natively supported on **[Apple platforms](https://developer.apple.com/documentation/foundation/jsondecoder/3766916-allowsjson5)**
23
+ like **MacOS** and **iOS**.
24
+
25
+ Formally, the **[JSON5 Data Interchange Format](https://spec.json5.org/)** is a superset of JSON
26
+ (so valid JSON files will always be valid JSON5 files)
27
+ that expands its syntax to include some productions from [ECMAScript 5.1] (ES5).
28
+ It's also a strict _subset_ of ES5, so valid JSON5 files will always be valid ES5.
29
+
30
+ This JavaScript library is a reference implementation for JSON5 parsing and serialization,
31
+ and is directly used in many of the popular projects mentioned above
32
+ (where e.g. extreme performance isn't necessary),
33
+ but others have created [many other libraries](https://github.com/json5/json5/wiki/In-the-Wild)
34
+ across many other platforms.
35
+
36
+ [Build Status]: https://app.travis-ci.com/json5/json5
37
+
38
+ [Coverage Status]: https://coveralls.io/github/json5/json5
39
+
40
+ [JSON]: https://tools.ietf.org/html/rfc7159
41
+
42
+ [ECMAScript 5.1]: https://www.ecma-international.org/ecma-262/5.1/
43
+
44
+ ## Summary of Features
45
+ The following ECMAScript 5.1 features, which are not supported in JSON, have
46
+ been extended to JSON5.
47
+
48
+ ### Objects
49
+ - Object keys may be an ECMAScript 5.1 _[IdentifierName]_.
50
+ - Objects may have a single trailing comma.
51
+
52
+ ### Arrays
53
+ - Arrays may have a single trailing comma.
54
+
55
+ ### Strings
56
+ - Strings may be single quoted.
57
+ - Strings may span multiple lines by escaping new line characters.
58
+ - Strings may include character escapes.
59
+
60
+ ### Numbers
61
+ - Numbers may be hexadecimal.
62
+ - Numbers may have a leading or trailing decimal point.
63
+ - Numbers may be [IEEE 754] positive infinity, negative infinity, and NaN.
64
+ - Numbers may begin with an explicit plus sign.
65
+
66
+ ### Comments
67
+ - Single and multi-line comments are allowed.
68
+
69
+ ### White Space
70
+ - Additional white space characters are allowed.
71
+
72
+ [IdentifierName]: https://www.ecma-international.org/ecma-262/5.1/#sec-7.6
73
+
74
+ [IEEE 754]: http://ieeexplore.ieee.org/servlet/opac?punumber=4610933
75
+
76
+ ## Example
77
+ Kitchen-sink example:
78
+
79
+ ```js
80
+ {
81
+ // comments
82
+ unquoted: 'and you can quote me on that',
83
+ singleQuotes: 'I can use "double quotes" here',
84
+ lineBreaks: "Look, Mom! \
85
+ No \\n's!",
86
+ hexadecimal: 0xdecaf,
87
+ leadingDecimalPoint: .8675309, andTrailing: 8675309.,
88
+ positiveSign: +1,
89
+ trailingComma: 'in objects', andIn: ['arrays',],
90
+ "backwardsCompatible": "with JSON",
91
+ }
92
+ ```
93
+
94
+ A more real-world example is [this config file](https://github.com/chromium/chromium/blob/feb3c9f670515edf9a88f185301cbd7794ee3e52/third_party/blink/renderer/platform/runtime_enabled_features.json5)
95
+ from the Chromium/Blink project.
96
+
97
+ ## Specification
98
+ For a detailed explanation of the JSON5 format, please read the [official
99
+ specification](https://json5.github.io/json5-spec/).
100
+
101
+ ## Installation and Usage
102
+ ### Node.js
103
+ ```sh
104
+ npm install json5
105
+ ```
106
+
107
+ #### CommonJS
108
+ ```js
109
+ const JSON5 = require('json5')
110
+ ```
111
+
112
+ #### Modules
113
+ ```js
114
+ import JSON5 from 'json5'
115
+ ```
116
+
117
+ ### Browsers
118
+ #### UMD
119
+ ```html
120
+ <!-- This will create a global `JSON5` variable. -->
121
+ <script src="https://unpkg.com/json5@2/dist/index.min.js"></script>
122
+ ```
123
+
124
+ #### Modules
125
+ ```html
126
+ <script type="module">
127
+ import JSON5 from 'https://unpkg.com/json5@2/dist/index.min.mjs'
128
+ </script>
129
+ ```
130
+
131
+ ## API
132
+ The JSON5 API is compatible with the [JSON API].
133
+
134
+ [JSON API]:
135
+ https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON
136
+
137
+ ### JSON5.parse()
138
+ Parses a JSON5 string, constructing the JavaScript value or object described by
139
+ the string. An optional reviver function can be provided to perform a
140
+ transformation on the resulting object before it is returned.
141
+
142
+ #### Syntax
143
+ JSON5.parse(text[, reviver])
144
+
145
+ #### Parameters
146
+ - `text`: The string to parse as JSON5.
147
+ - `reviver`: If a function, this prescribes how the value originally produced by
148
+ parsing is transformed, before being returned.
149
+
150
+ #### Return value
151
+ The object corresponding to the given JSON5 text.
152
+
153
+ ### JSON5.stringify()
154
+ Converts a JavaScript value to a JSON5 string, optionally replacing values if a
155
+ replacer function is specified, or optionally including only the specified
156
+ properties if a replacer array is specified.
157
+
158
+ #### Syntax
159
+ JSON5.stringify(value[, replacer[, space]])
160
+ JSON5.stringify(value[, options])
161
+
162
+ #### Parameters
163
+ - `value`: The value to convert to a JSON5 string.
164
+ - `replacer`: A function that alters the behavior of the stringification
165
+ process, or an array of String and Number objects that serve as a whitelist
166
+ for selecting/filtering the properties of the value object to be included in
167
+ the JSON5 string. If this value is null or not provided, all properties of the
168
+ object are included in the resulting JSON5 string.
169
+ - `space`: A String or Number object that's used to insert white space into the
170
+ output JSON5 string for readability purposes. If this is a Number, it
171
+ indicates the number of space characters to use as white space; this number is
172
+ capped at 10 (if it is greater, the value is just 10). Values less than 1
173
+ indicate that no space should be used. If this is a String, the string (or the
174
+ first 10 characters of the string, if it's longer than that) is used as white
175
+ space. If this parameter is not provided (or is null), no white space is used.
176
+ If white space is used, trailing commas will be used in objects and arrays.
177
+ - `options`: An object with the following properties:
178
+ - `replacer`: Same as the `replacer` parameter.
179
+ - `space`: Same as the `space` parameter.
180
+ - `quote`: A String representing the quote character to use when serializing
181
+ strings.
182
+
183
+ #### Return value
184
+ A JSON5 string representing the value.
185
+
186
+ ### Node.js `require()` JSON5 files
187
+ When using Node.js, you can `require()` JSON5 files by adding the following
188
+ statement.
189
+
190
+ ```js
191
+ require('json5/lib/register')
192
+ ```
193
+
194
+ Then you can load a JSON5 file with a Node.js `require()` statement. For
195
+ example:
196
+
197
+ ```js
198
+ const config = require('./config.json5')
199
+ ```
200
+
201
+ ## CLI
202
+ Since JSON is more widely used than JSON5, this package includes a CLI for
203
+ converting JSON5 to JSON and for validating the syntax of JSON5 documents.
204
+
205
+ ### Installation
206
+ ```sh
207
+ npm install --global json5
208
+ ```
209
+
210
+ ### Usage
211
+ ```sh
212
+ json5 [options] <file>
213
+ ```
214
+
215
+ If `<file>` is not provided, then STDIN is used.
216
+
217
+ #### Options:
218
+ - `-s`, `--space`: The number of spaces to indent or `t` for tabs
219
+ - `-o`, `--out-file [file]`: Output to the specified file, otherwise STDOUT
220
+ - `-v`, `--validate`: Validate JSON5 but do not output JSON
221
+ - `-V`, `--version`: Output the version number
222
+ - `-h`, `--help`: Output usage information
223
+
224
+ ## Contributing
225
+ ### Development
226
+ ```sh
227
+ git clone https://github.com/json5/json5
228
+ cd json5
229
+ npm install
230
+ ```
231
+
232
+ When contributing code, please write relevant tests and run `npm test` and `npm
233
+ run lint` before submitting pull requests. Please use an editor that supports
234
+ [EditorConfig](http://editorconfig.org/).
235
+
236
+ ### Issues
237
+ To report bugs or request features regarding the JSON5 **data format**,
238
+ please submit an issue to the official
239
+ **[_specification_ repository](https://github.com/json5/json5-spec)**.
240
+
241
+ Note that we will never add any features that make JSON5 incompatible with ES5;
242
+ that compatibility is a fundamental premise of JSON5.
243
+
244
+ To report bugs or request features regarding this **JavaScript implementation**
245
+ of JSON5, please submit an issue to **_this_ repository**.
246
+
247
+ ### Security Vulnerabilities and Disclosures
248
+ To report a security vulnerability, please follow the follow the guidelines
249
+ described in our [security policy](./SECURITY.md).
250
+
251
+ ## License
252
+ MIT. See [LICENSE.md](./LICENSE.md) for details.
253
+
254
+ ## Credits
255
+ [Aseem Kishore](https://github.com/aseemk) founded this project.
256
+ He wrote a [blog post](https://aseemk.substack.com/p/ignore-the-f-ing-haters-json5)
257
+ about the journey and lessons learned 10 years in.
258
+
259
+ [Michael Bolin](http://bolinfest.com/) independently arrived at and published
260
+ some of these same ideas with awesome explanations and detail. Recommended
261
+ reading: [Suggested Improvements to JSON](http://bolinfest.com/essays/json.html)
262
+
263
+ [Douglas Crockford](http://www.crockford.com/) of course designed and built
264
+ JSON, but his state machine diagrams on the [JSON website](http://json.org/), as
265
+ cheesy as it may sound, gave us motivation and confidence that building a new
266
+ parser to implement these ideas was within reach! The original
267
+ implementation of JSON5 was also modeled directly off of Doug’s open-source
268
+ [json_parse.js] parser. We’re grateful for that clean and well-documented
269
+ code.
270
+
271
+ [json_parse.js]:
272
+ https://github.com/douglascrockford/JSON-js/blob/03157639c7a7cddd2e9f032537f346f1a87c0f6d/json_parse.js
273
+
274
+ [Max Nanasy](https://github.com/MaxNanasy) has been an early and prolific
275
+ supporter, contributing multiple patches and ideas.
276
+
277
+ [Andrew Eisenberg](https://github.com/aeisenberg) contributed the original
278
+ `stringify` method.
279
+
280
+ [Jordan Tucker](https://github.com/jordanbtucker) has aligned JSON5 more closely
281
+ with ES5, wrote the official JSON5 specification, completely rewrote the
282
+ codebase from the ground up, and is actively maintaining this project.
novas/novacore-zephyr/claude-code-router/node_modules/json5/package.json ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "json5",
3
+ "version": "2.2.3",
4
+ "description": "JSON for Humans",
5
+ "main": "lib/index.js",
6
+ "module": "dist/index.mjs",
7
+ "bin": "lib/cli.js",
8
+ "browser": "dist/index.js",
9
+ "types": "lib/index.d.ts",
10
+ "files": [
11
+ "lib/",
12
+ "dist/"
13
+ ],
14
+ "engines": {
15
+ "node": ">=6"
16
+ },
17
+ "scripts": {
18
+ "build": "rollup -c",
19
+ "build-package": "node build/package.js",
20
+ "build-unicode": "node build/unicode.js",
21
+ "coverage": "tap --coverage-report html test",
22
+ "lint": "eslint --fix .",
23
+ "lint-report": "eslint .",
24
+ "prepublishOnly": "npm run production",
25
+ "preversion": "npm run production",
26
+ "production": "run-s test build",
27
+ "tap": "tap -Rspec --100 test",
28
+ "test": "run-s lint-report tap",
29
+ "version": "npm run build-package && git add package.json5"
30
+ },
31
+ "repository": {
32
+ "type": "git",
33
+ "url": "git+https://github.com/json5/json5.git"
34
+ },
35
+ "keywords": [
36
+ "json",
37
+ "json5",
38
+ "es5",
39
+ "es2015",
40
+ "ecmascript"
41
+ ],
42
+ "author": "Aseem Kishore <aseem.kishore@gmail.com>",
43
+ "contributors": [
44
+ "Max Nanasy <max.nanasy@gmail.com>",
45
+ "Andrew Eisenberg <andrew@eisenberg.as>",
46
+ "Jordan Tucker <jordanbtucker@gmail.com>"
47
+ ],
48
+ "license": "MIT",
49
+ "bugs": {
50
+ "url": "https://github.com/json5/json5/issues"
51
+ },
52
+ "homepage": "http://json5.org/",
53
+ "devDependencies": {
54
+ "core-js": "^2.6.5",
55
+ "eslint": "^5.15.3",
56
+ "eslint-config-standard": "^12.0.0",
57
+ "eslint-plugin-import": "^2.16.0",
58
+ "eslint-plugin-node": "^8.0.1",
59
+ "eslint-plugin-promise": "^4.0.1",
60
+ "eslint-plugin-standard": "^4.0.0",
61
+ "npm-run-all": "^4.1.5",
62
+ "regenerate": "^1.4.0",
63
+ "rollup": "^0.64.1",
64
+ "rollup-plugin-buble": "^0.19.6",
65
+ "rollup-plugin-commonjs": "^9.2.1",
66
+ "rollup-plugin-node-resolve": "^3.4.0",
67
+ "rollup-plugin-terser": "^1.0.1",
68
+ "sinon": "^6.3.5",
69
+ "tap": "^12.6.0",
70
+ "unicode-10.0.0": "^0.7.5"
71
+ }
72
+ }
novas/novacore-zephyr/claude-code-router/node_modules/openurl/.npmignore ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ .DS_Store
2
+ .idea
3
+
novas/novacore-zephyr/claude-code-router/node_modules/openurl/README.md ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ openurl – Node.js module for opening URLs
2
+ =========================================
3
+
4
+ openurl is a Node.js module for opening a URL via the operating system. This will usually trigger actions such as:
5
+
6
+ - http URLs: open the default browser
7
+ - mailto URLs: open the default email client
8
+ - file URLs: open a window showing the directory (on OS X)
9
+
10
+ Example interaction on the Node.js REPL:
11
+
12
+ > require("openurl").open("http://rauschma.de")
13
+ > require("openurl").open("mailto:john@example.com")
14
+
15
+ You can generate emails as follows:
16
+
17
+ require("openurl").mailto(["john@example.com", "jane@example.com"],
18
+ { subject: "Hello!", body: "This is\nan automatically sent email!\n" });
19
+
20
+ Install via npm:
21
+
22
+ npm install openurl
23
+
24
+ I’m not yet terribly familiar with implementing npm packages, so any feedback is welcome
25
+ (especially experience reports on Windows and Linux, which I can’t test on).
26
+
27
+ Related reading:
28
+
29
+ - [Write your shell scripts in JavaScript, via Node.js](http://www.2ality.com/2011/12/nodejs-shell-scripting.html)
novas/novacore-zephyr/claude-code-router/node_modules/openurl/openurl.js ADDED
@@ -0,0 +1,68 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ var spawn = require('child_process').spawn;
2
+
3
+ var command;
4
+
5
+ switch(process.platform) {
6
+ case 'darwin':
7
+ command = 'open';
8
+ break;
9
+ case 'win32':
10
+ command = 'explorer.exe';
11
+ break;
12
+ case 'linux':
13
+ command = 'xdg-open';
14
+ break;
15
+ default:
16
+ throw new Error('Unsupported platform: ' + process.platform);
17
+ }
18
+
19
+ /**
20
+ * Error handling is deliberately minimal, as this function is to be easy to use for shell scripting
21
+ *
22
+ * @param url The URL to open
23
+ * @param callback A function with a single error argument. Optional.
24
+ */
25
+
26
+ function open(url, callback) {
27
+ var child = spawn(command, [url]);
28
+ var errorText = "";
29
+ child.stderr.setEncoding('utf8');
30
+ child.stderr.on('data', function (data) {
31
+ errorText += data;
32
+ });
33
+ child.stderr.on('end', function () {
34
+ if (errorText.length > 0) {
35
+ var error = new Error(errorText);
36
+ if (callback) {
37
+ callback(error);
38
+ } else {
39
+ throw error;
40
+ }
41
+ } else if (callback) {
42
+ callback(error);
43
+ }
44
+ });
45
+ }
46
+
47
+ /**
48
+ * @param fields Common fields are: "subject", "body".
49
+ * Some email apps let you specify arbitrary headers here.
50
+ * @param recipientsSeparator Default is ",". Use ";" for Outlook.
51
+ */
52
+ function mailto(recipients, fields, recipientsSeparator, callback) {
53
+ recipientsSeparator = recipientsSeparator || ",";
54
+
55
+ var url = "mailto:"+recipients.join(recipientsSeparator);
56
+ Object.keys(fields).forEach(function (key, index) {
57
+ if (index === 0) {
58
+ url += "?";
59
+ } else {
60
+ url += "&";
61
+ }
62
+ url += key + "=" + encodeURIComponent(fields[key]);
63
+ });
64
+ open(url, callback);
65
+ }
66
+
67
+ exports.open = open;
68
+ exports.mailto = mailto;
novas/novacore-zephyr/claude-code-router/node_modules/openurl/package.json ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "openurl",
3
+ "version": "1.1.1",
4
+ "author": "Axel Rauschmayer <axe@rauschma.de>",
5
+ "description": "Open a URL via the operating system (http: in default browser, mailto: in mail client etc.",
6
+ "main": "./openurl.js",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "https://github.com/rauschma/openurl"
10
+ },
11
+ "keywords": [
12
+ "desktop",
13
+ "browser"
14
+ ],
15
+ "license": "MIT"
16
+ }
novas/novacore-zephyr/claude-code-router/node_modules/pino-rotating-file-stream/LICENSE ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ MIT License
2
+
3
+ Copyright (c) 2023 thelicato
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
novas/novacore-zephyr/claude-code-router/node_modules/pino-rotating-file-stream/README.md ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # pino-rotating-file-stream
2
+
3
+ [![NPM Package Version](https://img.shields.io/npm/v/pino-rotating-file-stream)](https://www.npmjs.com/package/pino-rotating-file-stream)
4
+
5
+ ## Description
6
+
7
+ This module provides a **transport** for *pino* to automatically rotates logs. Under the hood, it uses [rotating-file-stream](https://www.npmjs.com/package/rotating-file-stream) even though some fields have been added to the default *Options*.
8
+
9
+ ## CLI
10
+ The current version of this packages has only support for the module usage as described in the [Programmatic Integration](#programmatic-integration) section. This feature will be added in next versions of the package.
11
+ For now you can rely on [@vrbo/pino-rotating-file](https://www.npmjs.com/package/@vrbo/pino-rotating-file) for CLI integration.
12
+ ## Programmatic Integration
13
+ Install ``pino-rotating-file-stream`` alongside ``pino`` and set the transport to ``pino-rotating-file-stream``:
14
+
15
+ ```js
16
+ const pino = require('pino')
17
+ const logger = pino({
18
+ transport: {
19
+ target: 'pino-rotating-file-stream',
20
+ options: {
21
+ filename: 'app.log', // Required
22
+ path: './logs', // Required
23
+ },
24
+ },
25
+ })
26
+
27
+ logger.info('hi')
28
+ ```
29
+
30
+ See also the example in the ``examples`` folder.
31
+
32
+ ### Options
33
+ The options are essentially the same provided by ``rotating-file-stream`` except form two new entries. The following list shows all the options with the default values:
34
+ ```js
35
+ {
36
+ filename: string; // Specifies the name of the file. Required.
37
+ path: string // Specifies the base path for files. Required.
38
+ size: string // Specifies the file size to rotate the file. Default: '100M'.
39
+ maxSize: string // Specifies the maximum size of rotated files to keep. Default: '1G'.
40
+ interval: string // Specifies the time interval to rotate the file. Default: '7d'.
41
+ compress: boolean | string | Function // Specifies compression method of rotated files. Default: 'gzip'.
42
+ encoding: string // Specifies the default encoding. Default: 'utf8'.
43
+ history: string // Specifies the history filename. Default: null.
44
+ immutable: boolean // Never mutate file names. Default: null.
45
+ initialRotation: boolean // Initial rotation based on not-rotated file timestamp. Default: null.
46
+ intervalBoundary: boolean // Makes rotated file name with lower boundary of rotation period. Default: null.
47
+ maxFiles: number // Specifies the maximum number of rotated files to keep. Default: null.
48
+ mode: number // Proxied to fs.createWriteStream. Default: 0o666.
49
+ omitExtension: // boolean Omits the .gz extension from compressed rotated files. Default: null.
50
+ rotate: number // Enables the classical UNIX logrotate behaviour. Default: null.
51
+ teeToStdout: boolean // Writes file content to stdout as well. Default: null.
52
+ }
53
+ ```
54
+
55
+ ## License
56
+
57
+ [MIT](./LICENSE) License © 2023 [Angelo Delicato](https://github.com/thelicato)
novas/novacore-zephyr/claude-code-router/node_modules/pino-rotating-file-stream/package.json ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "pino-rotating-file-stream",
3
+ "version": "0.0.2",
4
+ "description": "A transport for pino that rotates logs",
5
+ "keywords": [
6
+ "pino",
7
+ "pino-transport",
8
+ "log-rotation",
9
+ "logging"
10
+ ],
11
+ "homepage": "https://github.com/thelicato/pino-rotating-file-stream#readme",
12
+ "bugs": {
13
+ "url": "https://github.com/thelicato/pino-rotating-file-stream/issues"
14
+ },
15
+ "packageManager": "pnpm@8.5.1",
16
+ "license": "MIT",
17
+ "author": "Angelo Delicato <thelicato@duck.com>",
18
+ "repository": {
19
+ "type": "git",
20
+ "url": "git+https://github.com/thelicato/pino-rotating-file-stream.git"
21
+ },
22
+ "exports": {
23
+ ".": {
24
+ "import": "./dist/mjs/index.js",
25
+ "require": "./dist/cjs/index.js"
26
+ },
27
+ "./*.js": "./*.js",
28
+ "./*": {
29
+ "require": "./*.js",
30
+ "import": "./*"
31
+ }
32
+ },
33
+ "main": "./dist/cjs/index.js",
34
+ "module": "./dist/mjs/index.js",
35
+ "typeScriptVersion": "3.7",
36
+ "devDependencies": {
37
+ "@types/node": "^20.1.1",
38
+ "pino": "^8.14.1",
39
+ "pnpm": "^8.5.1",
40
+ "ts-node": "^10.9.1",
41
+ "tsc-alias": "^1.8.5",
42
+ "tsconfig-paths": "^4.2.0",
43
+ "typescript": "^5.0.4"
44
+ },
45
+ "dependencies": {
46
+ "rotating-file-stream": "^3.1.0"
47
+ },
48
+ "scripts": {
49
+ "build-mjs": "tsc -p tsconfig.mjs.json && tsc-alias -p tsconfig.mjs.json",
50
+ "build-cjs": "tsc -p tsconfig.cjs.json && tsc-alias -p tsconfig.cjs.json",
51
+ "build": "pnpm build-mjs && pnpm build-cjs"
52
+ }
53
+ }
novas/novacore-zephyr/claude-code-router/node_modules/pino-rotating-file-stream/tsconfig.cjs.json ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "extends": "./tsconfig.json",
3
+ "compilerOptions": {
4
+ "module": "CommonJS",
5
+ "outDir": "dist/cjs",
6
+ "target": "ES2020"
7
+ }
8
+ }
novas/novacore-zephyr/claude-code-router/node_modules/pino-rotating-file-stream/tsconfig.json ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "include": ["src"],
3
+ "exclude": ["dist"],
4
+ "ts-node": {
5
+ "files": true,
6
+ "require": ["tsconfig-paths/register"]
7
+ },
8
+ "compilerOptions": {
9
+ "lib": ["ES2020"],
10
+ "strict": true,
11
+ "esModuleInterop": true,
12
+ "skipLibCheck": true,
13
+ "sourceMap": true,
14
+ "declaration": true,
15
+ "moduleResolution": "node",
16
+ "useUnknownInCatchVariables": false,
17
+ "noImplicitAny": true,
18
+ "noImplicitThis": true,
19
+ "strictNullChecks": true,
20
+ "noUnusedParameters": true,
21
+ "noUnusedLocals": false,
22
+ "noImplicitReturns": true,
23
+ "noFallthroughCasesInSwitch": false,
24
+ "strictPropertyInitialization": false,
25
+ "alwaysStrict": true,
26
+ "resolveJsonModule": true,
27
+ "baseUrl": ".",
28
+ "paths": {
29
+ "@/*": ["./src/*"]
30
+ }
31
+ }
32
+ }
novas/novacore-zephyr/claude-code-router/node_modules/pino-rotating-file-stream/tsconfig.mjs.json ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "extends": "./tsconfig.json",
3
+ "compilerOptions": {
4
+ "module": "ESNext",
5
+ "outDir": "dist/mjs",
6
+ "target": "ESNext"
7
+ }
8
+ }
novas/novacore-zephyr/claude-code-router/node_modules/shx/LICENSE ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 Nathan Fischer, Ari Porad, Levi Thomason
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
novas/novacore-zephyr/claude-code-router/node_modules/shx/README.md ADDED
@@ -0,0 +1,160 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Shx
2
+
3
+ [![GitHub Actions](https://img.shields.io/github/actions/workflow/status/shelljs/shx/main.yml?style=flat-square&logo=github)](https://github.com/shelljs/shx/actions/workflows/main.yml)
4
+ [![Codecov](https://img.shields.io/codecov/c/github/shelljs/shx/main.svg?style=flat-square&label=coverage)](https://codecov.io/gh/shelljs/shx)
5
+ [![npm version](https://img.shields.io/npm/v/shx.svg?style=flat-square)](https://www.npmjs.com/package/shx)
6
+ [![npm downloads](https://img.shields.io/npm/dm/shx.svg?style=flat-square)](https://www.npmjs.com/package/shx)
7
+
8
+ `shx` is a wrapper around [ShellJS](https://github.com/shelljs/shelljs) Unix
9
+ commands, providing an easy solution for simple Unix-like, cross-platform
10
+ commands in npm package scripts.
11
+
12
+ `shx` is proudly tested on every LTS node release since <!-- start minVersion -->`v18`<!-- stop minVersion -->!
13
+
14
+ ## Difference Between ShellJS and shx
15
+
16
+ - **ShellJS:** Good for writing long scripts, all in JS, running via NodeJS (e.g. `node myScript.js`).
17
+ - **shx:** Good for writing one-off commands in npm package scripts (e.g. `"clean": "shx rm -rf out/"`).
18
+
19
+ ## Install
20
+
21
+ ```shell
22
+ npm install shx --save-dev
23
+ ```
24
+ This will allow using `shx` in your `package.json` scripts.
25
+
26
+ ## Usage
27
+
28
+ ### Command Line
29
+
30
+ If you'd like to use `shx` on the command line, install it globally with the `-g` flag.
31
+ The following code can be run *either a Unix or Windows* command line:
32
+
33
+ ```Bash
34
+ $ shx pwd # ShellJS commands are supported automatically
35
+ /home/username/path/to/dir
36
+
37
+ $ shx ls # files are outputted one per line
38
+ file.txt
39
+ file2.txt
40
+
41
+ $ shx rm *.txt # a cross-platform way to delete files!
42
+
43
+ $ shx ls
44
+
45
+ $ shx echo "Hi there!"
46
+ Hi there!
47
+
48
+ $ shx touch helloworld.txt
49
+
50
+ $ shx cp helloworld.txt foobar.txt
51
+
52
+ $ shx mkdir sub
53
+
54
+ $ shx ls
55
+ foobar.txt
56
+ helloworld.txt
57
+ sub
58
+
59
+ $ shx rm -r sub # options work as well
60
+
61
+ $ shx --silent ls fakeFileName # silence error output
62
+
63
+ $ shx --negate test -d dir # Negate status code output (e.g., failed commands will now have status 0)
64
+ ```
65
+
66
+ All commands internally call the ShellJS corresponding function, guaranteeing
67
+ cross-platform compatibility.
68
+
69
+ ### package.json
70
+
71
+ ShellJS is good for writing long scripts. If you want to write bash-like,
72
+ platform-independent scripts, we recommend you go with that.
73
+
74
+ However, `shx` is ideal for one-liners inside `package.json`:
75
+
76
+ ```json
77
+ {
78
+ "scripts": {
79
+ "clean": "shx rm -rf \"build/**/*.js\" \"build/output\" && shx echo \"Done cleaning\""
80
+ }
81
+ }
82
+ ```
83
+
84
+ It's safe to use `&&` and `||` operators in npm package scripts. These will be
85
+ interpreted by the operating system's shell (`sh` on Unix, `cmd.exe` on
86
+ Windows). If you're using glob operators like `*` or `**`, then we recommend to
87
+ **put these in double quotes**, which ensures that `shx` will expand the glob
88
+ rather than the operating system shell.
89
+
90
+ > [!IMPORTANT]
91
+ > Windows treats single quotes (ex. `'some string'`) differently than double
92
+ > quotes.
93
+ > [We recommend](https://github.com/shelljs/shx/issues/165#issuecomment-563127983)
94
+ > wrapping your arguments in **escaped double quotes** so that your code is
95
+ > compatible cross platform (ex. `"clean": "shx echo \"some string\""`).
96
+
97
+ ## Command reference
98
+
99
+ Shx exposes [most ShellJS
100
+ commands](https://github.com/shelljs/shelljs#command-reference). If a command is
101
+ not listed here, assume it's supported!
102
+
103
+ ### sed
104
+
105
+ Shx provides unix-like syntax on top of `shell.sed()`. So ShellJS code like:
106
+
107
+ ```js
108
+ shell.sed('-i', /original string/g, 'replacement', 'filename.txt');
109
+ ```
110
+
111
+ would turn into the following Shx command:
112
+
113
+ ```sh
114
+ shx sed -i "s/original string/replacement/g" filename.txt
115
+ ```
116
+
117
+ **Note:** like unix `sed`, `shx sed` treats `/` as a special character, and
118
+ [this must be
119
+ escaped](https://github.com/shelljs/shx/issues/169#issuecomment-563013849) (as
120
+ `\/` in the shell, or `\\/` in `package.json`) if you intend to use this
121
+ character in either the regex or replacement string. Do **not** escape `/`
122
+ characters in the file path.
123
+
124
+ ### Unsupported Commands
125
+
126
+ As mentioned above, most ShellJS commands are supported in `shx`. Due to the
127
+ differences in execution environments between ShellJS and `shx` (JS vs CLI) the
128
+ following commands are not supported:
129
+
130
+ | Unsupported command | Recommend workaround |
131
+ | ------------------- | -------------------- |
132
+ | `shx cd` | Just use plain old `cd` (it's the same on windows too) |
133
+ | `shx pushd` | Just use plain old `pushd`. Use forward slashes and double-quote the path. (e.g. `pushd "../docs"`. This would fail on Windows without the quotes) |
134
+ | `shx popd` | Just use plain old `popd` |
135
+ | `shx dirs` | No workaround |
136
+ | `shx set` | See below |
137
+ | `shx exit` | Just use plain old `exit` |
138
+ | `shx exec` | Instead of `shx exec cmd`, just use plain old `cmd` |
139
+ | `shx ShellString` | No workaround (but why would you want this?) |
140
+
141
+ ### Shx options
142
+
143
+ Shx allows you to modify its behavior by passing arguments. Here's a list of
144
+ supported options:
145
+
146
+ | [`set`](https://github.com/shelljs/shelljs#setoptions) flag | [`shell.config`](https://github.com/shelljs/shelljs#configuration) setting | shx command | Effect |
147
+ |:---:| --- | --- | --- |
148
+ | `-e` | `config.fatal = true` | Not supported | Exit upon first error. |
149
+ | `-v` | `config.verbose = true` | `shx --verbose cd foo` | Log the command as it's run. |
150
+ | `-f` | `config.noglob = true` | `shx --noglob cat '*.txt'` | Don't expand wildcards. |
151
+ | N/A | `config.silent = true` | `shx --silent cd noexist` | Don't show error output. |
152
+ | N/A | N/A | `shx --negate test -d dir` | Runs the specified command but negates the exit status. Failed command = status 0, successful command = status 1. |
153
+ | N/A | N/A | `shx --help` | Show help text. |
154
+ | N/A | N/A | `shx --version` | Print the shx version. |
155
+
156
+ ## Team
157
+
158
+ | [![Nate Fischer](https://avatars.githubusercontent.com/u/5801521?s=130)](https://github.com/nfischer) | [![Ari Porad](https://avatars1.githubusercontent.com/u/1817508?v=3&s=130)](http://github.com/ariporad) | [![Levi Thomason](https://avatars1.githubusercontent.com/u/5067638?v=3&s=130)](https://github.com/levithomason) |
159
+ |:---:|:---:|:---:|
160
+ | [Nate Fischer](https://github.com/nfischer) | [Ari Porad](http://github.com/ariporad) | [Levi Thomason](https://github.com/levithomason) |
novas/novacore-zephyr/claude-code-router/node_modules/shx/package.json ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "shx",
3
+ "version": "0.4.0",
4
+ "description": "Portable Shell Commands for Node",
5
+ "bin": {
6
+ "shx": "lib/cli.js"
7
+ },
8
+ "files": [
9
+ "lib"
10
+ ],
11
+ "scripts": {
12
+ "check-node-support": "node scripts/check-node-support",
13
+ "prebuild": "rimraf lib",
14
+ "build": "babel src -d lib",
15
+ "lint": "eslint .",
16
+ "prepublish": "npm run build",
17
+ "posttest": "npm run lint",
18
+ "release:major": "shelljs-release major",
19
+ "release:minor": "shelljs-release minor",
20
+ "release:patch": "shelljs-release patch",
21
+ "changelog": "shelljs-changelog",
22
+ "test": "nyc --reporter=text --reporter=lcov mocha"
23
+ },
24
+ "repository": {
25
+ "type": "git",
26
+ "url": "git+https://github.com/shelljs/shx.git"
27
+ },
28
+ "keywords": [
29
+ "shelljs",
30
+ "shell",
31
+ "unix",
32
+ "bash",
33
+ "sh",
34
+ "exec",
35
+ "cli",
36
+ "zsh"
37
+ ],
38
+ "contributors": [
39
+ "Ari Porad <ari@ariporad.com> (http://ariporad.com/)",
40
+ "Levi Thomason <me@levithomason.com> (https://github.com/levithomason)",
41
+ "Nate Fischer <ntfschr@gmail.com>"
42
+ ],
43
+ "license": "MIT",
44
+ "bugs": {
45
+ "url": "https://github.com/shelljs/shx/issues"
46
+ },
47
+ "homepage": "https://github.com/shelljs/shx#readme",
48
+ "devDependencies": {
49
+ "babel-cli": "^6.6.5",
50
+ "babel-preset-env": "^1.7.0",
51
+ "babel-register": "^6.7.2",
52
+ "eslint": "^8.57.1",
53
+ "eslint-config-airbnb-base": "^15.0.0",
54
+ "eslint-import-resolver-node": "0.3.7",
55
+ "eslint-plugin-import": "^2.31.0",
56
+ "js-yaml": "^4.1.0",
57
+ "mocha": "^11.1.0",
58
+ "nyc": "^17.1.0",
59
+ "rimraf": "^5.0.10",
60
+ "shelljs-changelog": "^0.2.6",
61
+ "shelljs-plugin-open": "^0.3.0",
62
+ "shelljs-release": "^0.5.3",
63
+ "should": "^13.2.3"
64
+ },
65
+ "dependencies": {
66
+ "minimist": "^1.2.8",
67
+ "shelljs": "^0.9.2"
68
+ },
69
+ "engines": {
70
+ "node": ">=18"
71
+ }
72
+ }
novas/novacore-zephyr/claude-code-router/node_modules/string-width-cjs/index.d.ts ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ declare const stringWidth: {
2
+ /**
3
+ Get the visual width of a string - the number of columns required to display it.
4
+
5
+ Some Unicode characters are [fullwidth](https://en.wikipedia.org/wiki/Halfwidth_and_fullwidth_forms) and use double the normal width. [ANSI escape codes](https://en.wikipedia.org/wiki/ANSI_escape_code) are stripped and doesn't affect the width.
6
+
7
+ @example
8
+ ```
9
+ import stringWidth = require('string-width');
10
+
11
+ stringWidth('a');
12
+ //=> 1
13
+
14
+ stringWidth('古');
15
+ //=> 2
16
+
17
+ stringWidth('\u001B[1m古\u001B[22m');
18
+ //=> 2
19
+ ```
20
+ */
21
+ (string: string): number;
22
+
23
+ // TODO: remove this in the next major version, refactor the whole definition to:
24
+ // declare function stringWidth(string: string): number;
25
+ // export = stringWidth;
26
+ default: typeof stringWidth;
27
+ }
28
+
29
+ export = stringWidth;
novas/novacore-zephyr/claude-code-router/node_modules/string-width-cjs/index.js ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 'use strict';
2
+ const stripAnsi = require('strip-ansi');
3
+ const isFullwidthCodePoint = require('is-fullwidth-code-point');
4
+ const emojiRegex = require('emoji-regex');
5
+
6
+ const stringWidth = string => {
7
+ if (typeof string !== 'string' || string.length === 0) {
8
+ return 0;
9
+ }
10
+
11
+ string = stripAnsi(string);
12
+
13
+ if (string.length === 0) {
14
+ return 0;
15
+ }
16
+
17
+ string = string.replace(emojiRegex(), ' ');
18
+
19
+ let width = 0;
20
+
21
+ for (let i = 0; i < string.length; i++) {
22
+ const code = string.codePointAt(i);
23
+
24
+ // Ignore control characters
25
+ if (code <= 0x1F || (code >= 0x7F && code <= 0x9F)) {
26
+ continue;
27
+ }
28
+
29
+ // Ignore combining characters
30
+ if (code >= 0x300 && code <= 0x36F) {
31
+ continue;
32
+ }
33
+
34
+ // Surrogates
35
+ if (code > 0xFFFF) {
36
+ i++;
37
+ }
38
+
39
+ width += isFullwidthCodePoint(code) ? 2 : 1;
40
+ }
41
+
42
+ return width;
43
+ };
44
+
45
+ module.exports = stringWidth;
46
+ // TODO: remove this in the next major version
47
+ module.exports.default = stringWidth;
novas/novacore-zephyr/claude-code-router/node_modules/string-width-cjs/license ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ MIT License
2
+
3
+ Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
+
7
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
novas/novacore-zephyr/claude-code-router/node_modules/string-width-cjs/package.json ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "string-width",
3
+ "version": "4.2.3",
4
+ "description": "Get the visual width of a string - the number of columns required to display it",
5
+ "license": "MIT",
6
+ "repository": "sindresorhus/string-width",
7
+ "author": {
8
+ "name": "Sindre Sorhus",
9
+ "email": "sindresorhus@gmail.com",
10
+ "url": "sindresorhus.com"
11
+ },
12
+ "engines": {
13
+ "node": ">=8"
14
+ },
15
+ "scripts": {
16
+ "test": "xo && ava && tsd"
17
+ },
18
+ "files": [
19
+ "index.js",
20
+ "index.d.ts"
21
+ ],
22
+ "keywords": [
23
+ "string",
24
+ "character",
25
+ "unicode",
26
+ "width",
27
+ "visual",
28
+ "column",
29
+ "columns",
30
+ "fullwidth",
31
+ "full-width",
32
+ "full",
33
+ "ansi",
34
+ "escape",
35
+ "codes",
36
+ "cli",
37
+ "command-line",
38
+ "terminal",
39
+ "console",
40
+ "cjk",
41
+ "chinese",
42
+ "japanese",
43
+ "korean",
44
+ "fixed-width"
45
+ ],
46
+ "dependencies": {
47
+ "emoji-regex": "^8.0.0",
48
+ "is-fullwidth-code-point": "^3.0.0",
49
+ "strip-ansi": "^6.0.1"
50
+ },
51
+ "devDependencies": {
52
+ "ava": "^1.4.1",
53
+ "tsd": "^0.7.1",
54
+ "xo": "^0.24.0"
55
+ }
56
+ }
novas/novacore-zephyr/claude-code-router/node_modules/string-width-cjs/readme.md ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # string-width
2
+
3
+ > Get the visual width of a string - the number of columns required to display it
4
+
5
+ Some Unicode characters are [fullwidth](https://en.wikipedia.org/wiki/Halfwidth_and_fullwidth_forms) and use double the normal width. [ANSI escape codes](https://en.wikipedia.org/wiki/ANSI_escape_code) are stripped and doesn't affect the width.
6
+
7
+ Useful to be able to measure the actual width of command-line output.
8
+
9
+
10
+ ## Install
11
+
12
+ ```
13
+ $ npm install string-width
14
+ ```
15
+
16
+
17
+ ## Usage
18
+
19
+ ```js
20
+ const stringWidth = require('string-width');
21
+
22
+ stringWidth('a');
23
+ //=> 1
24
+
25
+ stringWidth('古');
26
+ //=> 2
27
+
28
+ stringWidth('\u001B[1m古\u001B[22m');
29
+ //=> 2
30
+ ```
31
+
32
+
33
+ ## Related
34
+
35
+ - [string-width-cli](https://github.com/sindresorhus/string-width-cli) - CLI for this module
36
+ - [string-length](https://github.com/sindresorhus/string-length) - Get the real length of a string
37
+ - [widest-line](https://github.com/sindresorhus/widest-line) - Get the visual width of the widest line in a string
38
+
39
+
40
+ ---
41
+
42
+ <div align="center">
43
+ <b>
44
+ <a href="https://tidelift.com/subscription/pkg/npm-string-width?utm_source=npm-string-width&utm_medium=referral&utm_campaign=readme">Get professional support for this package with a Tidelift subscription</a>
45
+ </b>
46
+ <br>
47
+ <sub>
48
+ Tidelift helps make open source sustainable for maintainers while giving companies<br>assurances about security, maintenance, and licensing for their dependencies.
49
+ </sub>
50
+ </div>
novas/novacore-zephyr/claude-code-router/node_modules/tiktoken/README.md ADDED
@@ -0,0 +1,325 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # ⏳ tiktoken
2
+
3
+ tiktoken is a [BPE](https://en.wikipedia.org/wiki/Byte_pair_encoding) tokeniser for use with
4
+ OpenAI's models, forked from the original tiktoken library to provide JS/WASM bindings for NodeJS and other JS runtimes.
5
+
6
+ This repository contains the following packages:
7
+
8
+ - `tiktoken` (formally hosted at `@dqbd/tiktoken`): WASM bindings for the original Python library, providing full 1-to-1 feature parity.
9
+ - `js-tiktoken`: Pure JavaScript port of the original library with the core functionality, suitable for environments where WASM is not well supported or not desired (such as edge runtimes).
10
+
11
+ Documentation for `js-tiktoken` can be found in [here](https://github.com/dqbd/tiktoken/blob/main/js/README.md). Documentation for the `tiktoken` can be found here below.
12
+
13
+ The WASM version of `tiktoken` can be installed from NPM:
14
+
15
+ ```
16
+ npm install tiktoken
17
+ ```
18
+
19
+ ## Usage
20
+
21
+ Basic usage follows, which includes all the OpenAI encoders and ranks:
22
+
23
+ ```typescript
24
+ import assert from "node:assert";
25
+ import { get_encoding, encoding_for_model } from "tiktoken";
26
+
27
+ const enc = get_encoding("gpt2");
28
+ assert(
29
+ new TextDecoder().decode(enc.decode(enc.encode("hello world"))) ===
30
+ "hello world"
31
+ );
32
+
33
+ // To get the tokeniser corresponding to a specific model in the OpenAI API:
34
+ const enc = encoding_for_model("text-davinci-003");
35
+
36
+ // Extend existing encoding with custom special tokens
37
+ const enc = encoding_for_model("gpt2", {
38
+ "<|im_start|>": 100264,
39
+ "<|im_end|>": 100265,
40
+ });
41
+
42
+ // don't forget to free the encoder after it is not used
43
+ enc.free();
44
+ ```
45
+
46
+ In constrained environments (eg. Edge Runtime, Cloudflare Workers), where you don't want to load all the encoders at once, you can use the lightweight WASM binary via `tiktoken/lite`.
47
+
48
+ ```typescript
49
+ const { Tiktoken } = require("tiktoken/lite");
50
+ const cl100k_base = require("tiktoken/encoders/cl100k_base.json");
51
+
52
+ const encoding = new Tiktoken(
53
+ cl100k_base.bpe_ranks,
54
+ cl100k_base.special_tokens,
55
+ cl100k_base.pat_str
56
+ );
57
+ const tokens = encoding.encode("hello world");
58
+ encoding.free();
59
+ ```
60
+
61
+ If you want to fetch the latest ranks, use the `load` function:
62
+
63
+ ```typescript
64
+ const { Tiktoken } = require("tiktoken/lite");
65
+ const { load } = require("tiktoken/load");
66
+ const registry = require("tiktoken/registry.json");
67
+ const models = require("tiktoken/model_to_encoding.json");
68
+
69
+ async function main() {
70
+ const model = await load(registry[models["gpt-3.5-turbo"]]);
71
+ const encoder = new Tiktoken(
72
+ model.bpe_ranks,
73
+ model.special_tokens,
74
+ model.pat_str
75
+ );
76
+ const tokens = encoder.encode("hello world");
77
+ encoder.free();
78
+ }
79
+
80
+ main();
81
+ ```
82
+
83
+ If desired, you can create a Tiktoken instance directly with custom ranks, special tokens and regex pattern:
84
+
85
+ ```typescript
86
+ import { Tiktoken } from "../pkg";
87
+ import { readFileSync } from "fs";
88
+
89
+ const encoder = new Tiktoken(
90
+ readFileSync("./ranks/gpt2.tiktoken").toString("utf-8"),
91
+ { "<|endoftext|>": 50256, "<|im_start|>": 100264, "<|im_end|>": 100265 },
92
+ "'s|'t|'re|'ve|'m|'ll|'d| ?\\p{L}+| ?\\p{N}+| ?[^\\s\\p{L}\\p{N}]+|\\s+(?!\\S)|\\s+"
93
+ );
94
+ ```
95
+
96
+ Finally, you can a custom `init` function to override the WASM initialization logic for non-Node environments. This is useful if you are using a bundler that does not support WASM ESM integration.
97
+
98
+ ```typescript
99
+ import { get_encoding, init } from "tiktoken/init";
100
+
101
+ async function main() {
102
+ const wasm = "..."; // fetch the WASM binary somehow
103
+ await init((imports) => WebAssembly.instantiate(wasm, imports));
104
+
105
+ const encoding = get_encoding("cl100k_base");
106
+ const tokens = encoding.encode("hello world");
107
+ encoding.free();
108
+ }
109
+
110
+ main();
111
+ ```
112
+
113
+ ## Compatibility
114
+
115
+ As this is a WASM library, there might be some issues with specific runtimes. If you encounter any issues, please open an issue.
116
+
117
+ | Runtime | Status | Notes |
118
+ | ---------------------------- | ------ | ------------------------------------------------------------------------------------------ |
119
+ | Node.js | ✅ | |
120
+ | Bun | ✅ | |
121
+ | Vite | ✅ | See [here](#vite) for notes |
122
+ | Next.js | ✅ | See [here](#nextjs) for notes |
123
+ | Create React App (via Craco) | ✅ | See [here](#create-react-app) for notes |
124
+ | Vercel Edge Runtime | ✅ | See [here](#vercel-edge-runtime) for notes |
125
+ | Cloudflare Workers | ✅ | See [here](#cloudflare-workers) for notes |
126
+ | Electron | ✅ | See [here](#electron) for notes |
127
+ | Deno | ❌ | Currently unsupported (see [dqbd/tiktoken#22](https://github.com/dqbd/tiktoken/issues/22)) |
128
+ | Svelte + Cloudflare Workers | ❌ | Currently unsupported (see [dqbd/tiktoken#37](https://github.com/dqbd/tiktoken/issues/37)) |
129
+
130
+ For unsupported runtimes, consider using [`js-tiktoken`](https://www.npmjs.com/package/js-tiktoken), which is a pure JS implementation of the tokeniser.
131
+
132
+ ### [Vite](#vite)
133
+
134
+ If you are using Vite, you will need to add both the `vite-plugin-wasm` and `vite-plugin-top-level-await`. Add the following to your `vite.config.js`:
135
+
136
+ ```js
137
+ import wasm from "vite-plugin-wasm";
138
+ import topLevelAwait from "vite-plugin-top-level-await";
139
+ import { defineConfig } from "vite";
140
+
141
+ export default defineConfig({
142
+ plugins: [wasm(), topLevelAwait()],
143
+ });
144
+ ```
145
+
146
+ ### [Next.js](#nextjs)
147
+
148
+ Both API routes and `/pages` are supported with the following `next.config.js` configuration.
149
+
150
+ ```typescript
151
+ // next.config.json
152
+ const config = {
153
+ webpack(config, { isServer, dev }) {
154
+ config.experiments = {
155
+ asyncWebAssembly: true,
156
+ layers: true,
157
+ };
158
+
159
+ return config;
160
+ },
161
+ };
162
+ ```
163
+
164
+ Usage in pages:
165
+
166
+ ```tsx
167
+ import { get_encoding } from "tiktoken";
168
+ import { useState } from "react";
169
+
170
+ const encoding = get_encoding("cl100k_base");
171
+
172
+ export default function Home() {
173
+ const [input, setInput] = useState("hello world");
174
+ const tokens = encoding.encode(input);
175
+
176
+ return (
177
+ <div>
178
+ <input
179
+ type="text"
180
+ value={input}
181
+ onChange={(e) => setInput(e.target.value)}
182
+ />
183
+ <div>{tokens.toString()}</div>
184
+ </div>
185
+ );
186
+ }
187
+ ```
188
+
189
+ Usage in API routes:
190
+
191
+ ```typescript
192
+ import { get_encoding } from "tiktoken";
193
+ import { NextApiRequest, NextApiResponse } from "next";
194
+
195
+ export default function handler(req: NextApiRequest, res: NextApiResponse) {
196
+ const encoding = get_encoding("cl100k_base");
197
+ const tokens = encoding.encode("hello world");
198
+ encoding.free();
199
+ return res.status(200).json({ tokens });
200
+ }
201
+ ```
202
+
203
+ ### [Create React App](#create-react-app)
204
+
205
+ By default, the Webpack configugration found in Create React App does not support WASM ESM modules. To add support, please do the following:
206
+
207
+ 1. Swap `react-scripts` with `craco`, using the guide found here: https://craco.js.org/docs/getting-started/.
208
+ 2. Add the following to `craco.config.js`:
209
+
210
+ ```js
211
+ module.exports = {
212
+ webpack: {
213
+ configure: (config) => {
214
+ config.experiments = {
215
+ asyncWebAssembly: true,
216
+ layers: true,
217
+ };
218
+
219
+ // turn off static file serving of WASM files
220
+ // we need to let Webpack handle WASM import
221
+ config.module.rules
222
+ .find((i) => "oneOf" in i)
223
+ .oneOf.find((i) => i.type === "asset/resource")
224
+ .exclude.push(/\.wasm$/);
225
+
226
+ return config;
227
+ },
228
+ },
229
+ };
230
+ ```
231
+
232
+ ### [Vercel Edge Runtime](#vercel-edge-runtime)
233
+
234
+ Vercel Edge Runtime does support WASM modules by adding a `?module` suffix. Initialize the encoder with the following snippet:
235
+
236
+ ```typescript
237
+ // @ts-expect-error
238
+ import wasm from "tiktoken/lite/tiktoken_bg.wasm?module";
239
+ import model from "tiktoken/encoders/cl100k_base.json";
240
+ import { init, Tiktoken } from "tiktoken/lite/init";
241
+
242
+ export const config = { runtime: "edge" };
243
+
244
+ export default async function (req: Request) {
245
+ await init((imports) => WebAssembly.instantiate(wasm, imports));
246
+
247
+ const encoding = new Tiktoken(
248
+ model.bpe_ranks,
249
+ model.special_tokens,
250
+ model.pat_str
251
+ );
252
+
253
+ const tokens = encoding.encode("hello world");
254
+ encoding.free();
255
+
256
+ return new Response(`${tokens}`);
257
+ }
258
+ ```
259
+
260
+ ### [Cloudflare Workers](#cloudflare-workers)
261
+
262
+ Similar to Vercel Edge Runtime, Cloudflare Workers must import the WASM binary file manually and use the `tiktoken/lite` version to fit the 1 MB limit. However, users need to point directly at the WASM binary via a relative path (including `./node_modules/`).
263
+
264
+ Add the following rule to the `wrangler.toml` to upload WASM during build:
265
+
266
+ ```toml
267
+ [[rules]]
268
+ globs = ["**/*.wasm"]
269
+ type = "CompiledWasm"
270
+ ```
271
+
272
+ Initialize the encoder with the following snippet:
273
+
274
+ ```javascript
275
+ import { init, Tiktoken } from "tiktoken/lite/init";
276
+ import wasm from "./node_modules/tiktoken/lite/tiktoken_bg.wasm";
277
+ import model from "tiktoken/encoders/cl100k_base.json";
278
+
279
+ export default {
280
+ async fetch() {
281
+ await init((imports) => WebAssembly.instantiate(wasm, imports));
282
+ const encoder = new Tiktoken(
283
+ model.bpe_ranks,
284
+ model.special_tokens,
285
+ model.pat_str
286
+ );
287
+ const tokens = encoder.encode("test");
288
+ encoder.free();
289
+ return new Response(`${tokens}`);
290
+ },
291
+ };
292
+ ```
293
+
294
+ ### [Electron](#electron)
295
+
296
+ To use tiktoken in your Electron main process, you need to make sure the WASM binary gets copied into your application package.
297
+
298
+ Assuming a setup with [Electron Forge](https://www.electronforge.io) and [`@electron-forge/plugin-webpack`](https://www.npmjs.com/package/@electron-forge/plugin-webpack), add the following to your `webpack.main.config.js`:
299
+
300
+ ```javascript
301
+ const CopyPlugin = require("copy-webpack-plugin");
302
+
303
+ module.exports = {
304
+ // ...
305
+ plugins: [
306
+ new CopyPlugin({
307
+ patterns: [
308
+ { from: "./node_modules/tiktoken/tiktoken_bg.wasm" },
309
+ ],
310
+ }),
311
+ ],
312
+ };
313
+ ```
314
+
315
+ ## Development
316
+
317
+ To build the `tiktoken` library, make sure to have:
318
+ - Rust and [`wasm-pack`](https://github.com/rustwasm/wasm-pack) installed.
319
+ - Node.js 18+ is required to build the JS bindings and fetch the latest encoder ranks via `fetch`.
320
+
321
+ Install all the dev-dependencies with `yarn install` and build both WASM binary and JS bindings with `yarn build`.
322
+
323
+ ## Acknowledgements
324
+
325
+ - https://github.com/zurawiki/tiktoken-rs
novas/novacore-zephyr/claude-code-router/node_modules/tiktoken/init.cjs ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.init = void 0;
18
+ // @ts-expect-error
19
+ const imports = require("./tiktoken_bg.cjs");
20
+ let isInitialized = false;
21
+ async function init(callback) {
22
+ if (isInitialized)
23
+ return imports;
24
+ const result = await callback({ "./tiktoken_bg.js": imports });
25
+ const instance = "instance" in result && result.instance instanceof WebAssembly.Instance
26
+ ? result.instance
27
+ : result instanceof WebAssembly.Instance
28
+ ? result
29
+ : null;
30
+ if (instance == null)
31
+ throw new Error("Missing instance");
32
+ imports.__wbg_set_wasm(instance.exports);
33
+ isInitialized = true;
34
+ return imports;
35
+ }
36
+ exports.init = init;
37
+ exports["get_encoding"] = imports["get_encoding"];
38
+ exports["encoding_for_model"] = imports["encoding_for_model"];
39
+ exports["get_encoding_name_for_model"] = imports["get_encoding_name_for_model"];
40
+ exports["Tiktoken"] = imports["Tiktoken"];
41
+ // @ts-expect-error
42
+ __exportStar(require("./tiktoken_bg.cjs"), exports);
novas/novacore-zephyr/claude-code-router/node_modules/tiktoken/init.d.ts ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ export declare function init(callback: (imports: WebAssembly.Imports) => Promise<WebAssembly.Instance | WebAssembly.WebAssemblyInstantiatedSource>): Promise<void>;
2
+ export * from "./tiktoken_bg";
novas/novacore-zephyr/claude-code-router/node_modules/tiktoken/init.js ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // @ts-expect-error
2
+ import * as imports from "./tiktoken_bg";
3
+ let isInitialized = false;
4
+ export async function init(callback) {
5
+ if (isInitialized)
6
+ return imports;
7
+ const result = await callback({ "./tiktoken_bg.js": imports });
8
+ const instance = "instance" in result && result.instance instanceof WebAssembly.Instance
9
+ ? result.instance
10
+ : result instanceof WebAssembly.Instance
11
+ ? result
12
+ : null;
13
+ if (instance == null)
14
+ throw new Error("Missing instance");
15
+ imports.__wbg_set_wasm(instance.exports);
16
+ isInitialized = true;
17
+ return imports;
18
+ }
19
+ // @ts-expect-error
20
+ export * from "./tiktoken_bg";
novas/novacore-zephyr/claude-code-router/node_modules/tiktoken/lite.d.ts ADDED
@@ -0,0 +1 @@
 
 
1
+ export * from "./lite/tiktoken";
novas/novacore-zephyr/claude-code-router/node_modules/tiktoken/load.cjs ADDED
@@ -0,0 +1,170 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.load = void 0;
4
+ /**
5
+ Copyright (c) 2014 Jameson Little
6
+
7
+ Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ of this software and associated documentation files (the "Software"), to deal
9
+ in the Software without restriction, including without limitation the rights
10
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ copies of the Software, and to permit persons to whom the Software is
12
+ furnished to do so, subject to the following conditions:
13
+
14
+ The above copyright notice and this permission notice shall be included in
15
+ all copies or substantial portions of the Software.
16
+
17
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23
+ THE SOFTWARE.
24
+ */
25
+ const lookup = [];
26
+ const revLookup = [];
27
+ const code = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
28
+ for (var i = 0, len = code.length; i < len; ++i) {
29
+ lookup[i] = code[i];
30
+ revLookup[code.charCodeAt(i)] = i;
31
+ }
32
+ // Support decoding URL-safe base64 strings, as Node.js does.
33
+ // See: https://en.wikipedia.org/wiki/Base64#URL_applications
34
+ revLookup["-".charCodeAt(0)] = 62;
35
+ revLookup["_".charCodeAt(0)] = 63;
36
+ function tripletToBase64(num) {
37
+ return (lookup[(num >> 18) & 0x3f] +
38
+ lookup[(num >> 12) & 0x3f] +
39
+ lookup[(num >> 6) & 0x3f] +
40
+ lookup[num & 0x3f]);
41
+ }
42
+ function encodeChunk(uint8, start, end) {
43
+ var tmp;
44
+ var output = [];
45
+ for (var i = start; i < end; i += 3) {
46
+ tmp =
47
+ ((uint8[i] << 16) & 0xff0000) +
48
+ ((uint8[i + 1] << 8) & 0xff00) +
49
+ (uint8[i + 2] & 0xff);
50
+ output.push(tripletToBase64(tmp));
51
+ }
52
+ return output.join("");
53
+ }
54
+ function fromByteArray(uint8) {
55
+ var tmp;
56
+ var len = uint8.length;
57
+ var extraBytes = len % 3; // if we have 1 byte left, pad 2 bytes
58
+ var parts = [];
59
+ var maxChunkLength = 16383; // must be multiple of 3
60
+ // go through the array every three bytes, we'll deal with trailing stuff later
61
+ for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) {
62
+ parts.push(encodeChunk(uint8, i, i + maxChunkLength > len2 ? len2 : i + maxChunkLength));
63
+ }
64
+ // pad the end with zeros, but make sure to not forget the extra bytes
65
+ if (extraBytes === 1) {
66
+ tmp = uint8[len - 1];
67
+ parts.push(lookup[tmp >> 2] + lookup[(tmp << 4) & 0x3f] + "==");
68
+ }
69
+ else if (extraBytes === 2) {
70
+ tmp = (uint8[len - 2] << 8) + uint8[len - 1];
71
+ parts.push(lookup[tmp >> 10] +
72
+ lookup[(tmp >> 4) & 0x3f] +
73
+ lookup[(tmp << 2) & 0x3f] +
74
+ "=");
75
+ }
76
+ return parts.join("");
77
+ }
78
+ function is_printable(u) {
79
+ // printable ascii characters according to python
80
+ return !(u <= 31 || (u >= 127 && u <= 160) || u == 173);
81
+ }
82
+ function data_gym_to_mergeable_bpe_ranks(vocal_bpe_contents, encoder_json_contents) {
83
+ const rank_to_intbyte = Array.from({ length: 2 ** 8 }, (_, i) => i).filter((i) => is_printable(i) && String.fromCharCode(i) !== " ");
84
+ const data_gym_byte_to_byte = rank_to_intbyte.reduce((memo, item) => {
85
+ memo[String.fromCharCode(item)] = item;
86
+ return memo;
87
+ }, {});
88
+ let n = 0;
89
+ for (let b = 0; b < 2 ** 8; b++) {
90
+ if (!rank_to_intbyte.includes(b)) {
91
+ rank_to_intbyte.push(b);
92
+ data_gym_byte_to_byte[String.fromCharCode(2 ** 8 + n)] = b;
93
+ n += 1;
94
+ }
95
+ }
96
+ if (rank_to_intbyte.length !== 2 ** 8) {
97
+ throw new Error("rank_to_intbyte.length must be 2**8");
98
+ }
99
+ // vocab_bpe contains the merges along with associated ranks
100
+ const bpe_merges = vocal_bpe_contents
101
+ .split("\n")
102
+ .slice(1, -1)
103
+ .map((merge_str) => merge_str.split(" "));
104
+ function decode_data_gym(value) {
105
+ return value.split("").map((b) => data_gym_byte_to_byte[b]);
106
+ }
107
+ // add the single byte tokens
108
+ const bpe_ranks = Object.fromEntries(rank_to_intbyte.map((b, i) => [b, i]));
109
+ // add the merged tokens
110
+ n = rank_to_intbyte.length;
111
+ for (const [first, second] of bpe_merges) {
112
+ bpe_ranks[[...decode_data_gym(first), ...decode_data_gym(second)].join(",")] = n;
113
+ n += 1;
114
+ }
115
+ // check that the encoder file matches the merges file
116
+ // this sanity check is important since tiktoken assumes that ranks are ordered the same
117
+ // as merge priority
118
+ const encoder_json = JSON.parse(encoder_json_contents);
119
+ const encoder_json_loaded = Object.fromEntries(Object.entries(encoder_json).map(([k, v]) => [
120
+ decode_data_gym(k).join(","),
121
+ v,
122
+ ]));
123
+ // drop these two special tokens if present, since they're not mergeable bpe tokens
124
+ delete encoder_json_loaded[decode_data_gym("<|endoftext|>").join(",")];
125
+ delete encoder_json_loaded[decode_data_gym("<|startoftext|>").join(",")];
126
+ function normalize_map(items) {
127
+ return JSON.stringify(Object.keys(items)
128
+ .sort()
129
+ .map((key) => [key, items[key]]));
130
+ }
131
+ if (normalize_map(bpe_ranks) !== normalize_map(encoder_json_loaded)) {
132
+ throw new Error("bpe_ranks !== encoder_json_loaded");
133
+ }
134
+ return bpe_ranks;
135
+ }
136
+ function dump_tiktoken_bpe(bpe_ranks) {
137
+ return (Object.entries(bpe_ranks)
138
+ .sort((a, b) => a[1] - b[1])
139
+ .map(([token_str, rank]) => [
140
+ fromByteArray(token_str.split(",").map((i) => Number.parseInt(i, 10))),
141
+ rank,
142
+ ].join(" "))
143
+ .join("\n") + "\n");
144
+ }
145
+ async function load(registry, customFetch) {
146
+ const ofetch = customFetch
147
+ ? customFetch
148
+ : (url) => fetch(url).then((r) => r.text());
149
+ if ("data_gym_to_mergeable_bpe_ranks" in registry) {
150
+ const [vocab_bpe, encoder_json] = await Promise.all([
151
+ ofetch(registry.data_gym_to_mergeable_bpe_ranks.vocab_bpe_file),
152
+ ofetch(registry.data_gym_to_mergeable_bpe_ranks.encoder_json_file),
153
+ ]);
154
+ return {
155
+ explicit_n_vocab: registry.explicit_n_vocab,
156
+ pat_str: registry.pat_str,
157
+ special_tokens: registry.special_tokens,
158
+ bpe_ranks: dump_tiktoken_bpe(data_gym_to_mergeable_bpe_ranks(vocab_bpe, encoder_json)),
159
+ };
160
+ }
161
+ else {
162
+ return {
163
+ explicit_n_vocab: registry.explicit_n_vocab,
164
+ pat_str: registry.pat_str,
165
+ special_tokens: registry.special_tokens,
166
+ bpe_ranks: await ofetch(registry.load_tiktoken_bpe),
167
+ };
168
+ }
169
+ }
170
+ exports.load = load;