ADAPT-Chase commited on
Commit
cc2ab9a
·
verified ·
1 Parent(s): f61c173

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/avvio/.github/dependabot.yml +13 -0
  2. novas/novacore-zephyr/claude-code-router/node_modules/avvio/.github/release-drafter.yml +4 -0
  3. novas/novacore-zephyr/claude-code-router/node_modules/avvio/.github/tests_checker.yml +3 -0
  4. novas/novacore-zephyr/claude-code-router/node_modules/avvio/.github/workflows/ci.yml +24 -0
  5. novas/novacore-zephyr/claude-code-router/node_modules/avvio/examples/example.js +72 -0
  6. novas/novacore-zephyr/claude-code-router/node_modules/avvio/lib/create-promise.js +45 -0
  7. novas/novacore-zephyr/claude-code-router/node_modules/avvio/lib/debug.js +19 -0
  8. novas/novacore-zephyr/claude-code-router/node_modules/avvio/lib/errors.js +38 -0
  9. novas/novacore-zephyr/claude-code-router/node_modules/avvio/lib/execute-with-thenable.js +28 -0
  10. novas/novacore-zephyr/claude-code-router/node_modules/avvio/lib/get-plugin-name.js +34 -0
  11. novas/novacore-zephyr/claude-code-router/node_modules/avvio/lib/is-bundled-or-typescript-plugin.js +23 -0
  12. novas/novacore-zephyr/claude-code-router/node_modules/avvio/lib/is-promise-like.js +17 -0
  13. novas/novacore-zephyr/claude-code-router/node_modules/avvio/lib/plugin.js +279 -0
  14. novas/novacore-zephyr/claude-code-router/node_modules/avvio/lib/symbols.js +26 -0
  15. novas/novacore-zephyr/claude-code-router/node_modules/avvio/lib/thenify.js +60 -0
  16. novas/novacore-zephyr/claude-code-router/node_modules/avvio/lib/time-tree.js +200 -0
  17. novas/novacore-zephyr/claude-code-router/node_modules/avvio/lib/validate-plugin.js +26 -0
  18. novas/novacore-zephyr/claude-code-router/node_modules/avvio/test/after-and-ready.test.js +864 -0
  19. novas/novacore-zephyr/claude-code-router/node_modules/avvio/test/after-pass-through.test.js +32 -0
  20. novas/novacore-zephyr/claude-code-router/node_modules/avvio/test/after-self-promise.test.js +20 -0
  21. novas/novacore-zephyr/claude-code-router/node_modules/avvio/test/after-throw.test.js +24 -0
  22. novas/novacore-zephyr/claude-code-router/node_modules/avvio/test/after-use-after.test.js +90 -0
  23. novas/novacore-zephyr/claude-code-router/node_modules/avvio/test/async-await.test.js +325 -0
  24. novas/novacore-zephyr/claude-code-router/node_modules/avvio/test/await-after.test.js +449 -0
  25. novas/novacore-zephyr/claude-code-router/node_modules/avvio/test/await-self.test.js +31 -0
  26. novas/novacore-zephyr/claude-code-router/node_modules/avvio/test/await-use.test.js +294 -0
  27. novas/novacore-zephyr/claude-code-router/node_modules/avvio/test/basic.test.js +439 -0
  28. novas/novacore-zephyr/claude-code-router/node_modules/avvio/test/callbacks.test.js +113 -0
  29. novas/novacore-zephyr/claude-code-router/node_modules/avvio/test/catch-override-exception.test.js +26 -0
  30. novas/novacore-zephyr/claude-code-router/node_modules/avvio/test/chainable.test.js +67 -0
  31. novas/novacore-zephyr/claude-code-router/node_modules/avvio/test/close.test.js +544 -0
  32. novas/novacore-zephyr/claude-code-router/node_modules/avvio/test/errors.test.js +26 -0
  33. novas/novacore-zephyr/claude-code-router/node_modules/avvio/test/esm.mjs +12 -0
  34. novas/novacore-zephyr/claude-code-router/node_modules/avvio/test/esm.test.js +14 -0
  35. novas/novacore-zephyr/claude-code-router/node_modules/avvio/test/events-listeners.test.js +23 -0
  36. novas/novacore-zephyr/claude-code-router/node_modules/avvio/test/expose.test.js +80 -0
  37. novas/novacore-zephyr/claude-code-router/node_modules/avvio/test/fixtures/dummy.txt +1 -0
  38. novas/novacore-zephyr/claude-code-router/node_modules/avvio/test/fixtures/esm.mjs +3 -0
  39. novas/novacore-zephyr/claude-code-router/node_modules/avvio/test/fixtures/plugin-no-next.js +5 -0
  40. novas/novacore-zephyr/claude-code-router/node_modules/avvio/test/gh-issues/bug-205.test.js +16 -0
  41. novas/novacore-zephyr/claude-code-router/node_modules/avvio/test/lib/create-promise.test.js +55 -0
  42. novas/novacore-zephyr/claude-code-router/node_modules/avvio/test/lib/execute-with-thenable.test.js +82 -0
  43. novas/novacore-zephyr/claude-code-router/node_modules/avvio/test/lib/get-plugin-name.test.js +67 -0
  44. novas/novacore-zephyr/claude-code-router/node_modules/avvio/test/lib/is-bundled-or-typescript-plugin.test.js +20 -0
  45. novas/novacore-zephyr/claude-code-router/node_modules/avvio/test/lib/is-promise-like.test.js +20 -0
  46. novas/novacore-zephyr/claude-code-router/node_modules/avvio/test/lib/thenify.test.js +123 -0
  47. novas/novacore-zephyr/claude-code-router/node_modules/avvio/test/lib/time-tree.test.js +391 -0
  48. novas/novacore-zephyr/claude-code-router/node_modules/avvio/test/lib/validate-plugin.test.js +19 -0
  49. novas/novacore-zephyr/claude-code-router/node_modules/avvio/test/load-plugin.test.js +123 -0
  50. novas/novacore-zephyr/claude-code-router/node_modules/avvio/test/no-done.test.js +18 -0
novas/novacore-zephyr/claude-code-router/node_modules/avvio/.github/dependabot.yml ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ version: 2
2
+ updates:
3
+ - package-ecosystem: "github-actions"
4
+ directory: "/"
5
+ schedule:
6
+ interval: "monthly"
7
+ open-pull-requests-limit: 10
8
+
9
+ - package-ecosystem: "npm"
10
+ directory: "/"
11
+ schedule:
12
+ interval: "weekly"
13
+ open-pull-requests-limit: 10
novas/novacore-zephyr/claude-code-router/node_modules/avvio/.github/release-drafter.yml ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ template: |
2
+ ## What’s Changed
3
+
4
+ $CHANGES
novas/novacore-zephyr/claude-code-router/node_modules/avvio/.github/tests_checker.yml ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ comment: 'Could you please add tests to make sure this change works as expected?',
2
+ fileExtensions: ['.php', '.ts', '.js', '.c', '.cs', '.cpp', '.rb', '.java']
3
+ testDir: 'test'
novas/novacore-zephyr/claude-code-router/node_modules/avvio/.github/workflows/ci.yml ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - main
7
+ - master
8
+ - next
9
+ - 'v*'
10
+ paths-ignore:
11
+ - 'docs/**'
12
+ - '*.md'
13
+ pull_request:
14
+ paths-ignore:
15
+ - 'docs/**'
16
+ - '*.md'
17
+
18
+ jobs:
19
+ test:
20
+ uses: fastify/workflows/.github/workflows/plugins-ci.yml@v5.0.0
21
+ with:
22
+ lint: true
23
+ license-check: true
24
+ node-versions: '["20", "22"]'
novas/novacore-zephyr/claude-code-router/node_modules/avvio/examples/example.js ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 'use strict'
2
+
3
+ const avvio = require('..')()
4
+
5
+ function a (instance, opts, cb) {
6
+ (opts.use || []).forEach(_ => { instance.use(_, { use: opts.subUse || [] }) })
7
+ setTimeout(cb, 10)
8
+ }
9
+ const pointer = a
10
+
11
+ function b (instance, opts, cb) {
12
+ (opts.use || []).forEach(_ => { instance.use(_, { use: opts.subUse || [] }) })
13
+ setTimeout(cb, 20)
14
+ }
15
+
16
+ function c (instance, opts, cb) {
17
+ (opts.use || []).forEach(_ => { instance.use(_, { use: opts.subUse || [] }) })
18
+ setTimeout(cb, 30)
19
+ }
20
+
21
+ avvio
22
+ .use(first, { hello: 'world' })
23
+ .use(duplicate, { count: 0 })
24
+ .use(function a (instance, opts, cb) {
25
+ instance.use(pointer, { use: [b], subUse: [c] })
26
+ .use(b)
27
+ setTimeout(cb, 42)
28
+ })
29
+ .after(function (err, cb) {
30
+ if (err) {
31
+ console.log('something bad happened')
32
+ console.log(err)
33
+ }
34
+ console.log('after first and second')
35
+ cb()
36
+ })
37
+ .use(duplicate, { count: 4 })
38
+ .use(third)
39
+ .ready(function (err) {
40
+ if (err) {
41
+ throw err
42
+ }
43
+ console.log('application booted!')
44
+ })
45
+
46
+ avvio.on('preReady', () => {
47
+ console.log(avvio.prettyPrint())
48
+ })
49
+
50
+ function first (instance, opts, cb) {
51
+ console.log('first loaded', opts)
52
+ instance.use(second)
53
+ setTimeout(cb, 42)
54
+ }
55
+
56
+ function second (instance, opts, cb) {
57
+ console.log('second loaded')
58
+ process.nextTick(cb)
59
+ }
60
+
61
+ function third (instance, opts, cb) {
62
+ console.log('third loaded')
63
+ cb()
64
+ }
65
+
66
+ function duplicate (instance, opts, cb) {
67
+ console.log('duplicate loaded', opts.count)
68
+ if (opts.count > 0) {
69
+ instance.use(duplicate, { count: opts.count - 1 })
70
+ }
71
+ setTimeout(cb, 20)
72
+ }
novas/novacore-zephyr/claude-code-router/node_modules/avvio/lib/create-promise.js ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 'use strict'
2
+
3
+ /**
4
+ * @callback PromiseResolve
5
+ * @param {any|PromiseLike<any>} value
6
+ * @returns {void}
7
+ */
8
+
9
+ /**
10
+ * @callback PromiseReject
11
+ * @param {any} reason
12
+ * @returns {void}
13
+ */
14
+
15
+ /**
16
+ * @typedef PromiseObject
17
+ * @property {Promise} promise
18
+ * @property {PromiseResolve} resolve
19
+ * @property {PromiseReject} reject
20
+ */
21
+
22
+ /**
23
+ * @returns {PromiseObject}
24
+ */
25
+ function createPromise () {
26
+ /**
27
+ * @type {PromiseObject}
28
+ */
29
+ const obj = {
30
+ resolve: null,
31
+ reject: null,
32
+ promise: null
33
+ }
34
+
35
+ obj.promise = new Promise((resolve, reject) => {
36
+ obj.resolve = resolve
37
+ obj.reject = reject
38
+ })
39
+
40
+ return obj
41
+ }
42
+
43
+ module.exports = {
44
+ createPromise
45
+ }
novas/novacore-zephyr/claude-code-router/node_modules/avvio/lib/debug.js ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 'use strict'
2
+
3
+ const { debuglog } = require('node:util')
4
+
5
+ /**
6
+ * @callback DebugLogger
7
+ * @param {string} msg
8
+ * @param {...unknown} param
9
+ * @returns {void}
10
+ */
11
+
12
+ /**
13
+ * @type {DebugLogger}
14
+ */
15
+ const debug = debuglog('avvio')
16
+
17
+ module.exports = {
18
+ debug
19
+ }
novas/novacore-zephyr/claude-code-router/node_modules/avvio/lib/errors.js ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 'use strict'
2
+
3
+ const { createError } = require('@fastify/error')
4
+
5
+ module.exports = {
6
+ AVV_ERR_EXPOSE_ALREADY_DEFINED: createError(
7
+ 'AVV_ERR_EXPOSE_ALREADY_DEFINED',
8
+ "'%s' is already defined, specify an expose option for '%s'"
9
+ ),
10
+ AVV_ERR_ATTRIBUTE_ALREADY_DEFINED: createError(
11
+ 'AVV_ERR_ATTRIBUTE_ALREADY_DEFINED',
12
+ "'%s' is already defined"
13
+ ),
14
+ AVV_ERR_CALLBACK_NOT_FN: createError(
15
+ 'AVV_ERR_CALLBACK_NOT_FN',
16
+ "Callback for '%s' hook is not a function. Received: '%s'"
17
+ ),
18
+ AVV_ERR_PLUGIN_NOT_VALID: createError(
19
+ 'AVV_ERR_PLUGIN_NOT_VALID',
20
+ "Plugin must be a function or a promise. Received: '%s'"
21
+ ),
22
+ AVV_ERR_ROOT_PLG_BOOTED: createError(
23
+ 'AVV_ERR_ROOT_PLG_BOOTED',
24
+ 'Root plugin has already booted'
25
+ ),
26
+ AVV_ERR_PARENT_PLG_LOADED: createError(
27
+ 'AVV_ERR_PARENT_PLG_LOADED',
28
+ "Impossible to load '%s' plugin because the parent '%s' was already loaded"
29
+ ),
30
+ AVV_ERR_READY_TIMEOUT: createError(
31
+ 'AVV_ERR_READY_TIMEOUT',
32
+ "Plugin did not start in time: '%s'. You may have forgotten to call 'done' function or to resolve a Promise"
33
+ ),
34
+ AVV_ERR_PLUGIN_EXEC_TIMEOUT: createError(
35
+ 'AVV_ERR_PLUGIN_EXEC_TIMEOUT',
36
+ "Plugin did not start in time: '%s'. You may have forgotten to call 'done' function or to resolve a Promise"
37
+ )
38
+ }
novas/novacore-zephyr/claude-code-router/node_modules/avvio/lib/execute-with-thenable.js ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 'use strict'
2
+ const { isPromiseLike } = require('./is-promise-like')
3
+ const { kAvvio } = require('./symbols')
4
+
5
+ /**
6
+ * @callback ExecuteWithThenableCallback
7
+ * @param {Error} error
8
+ * @returns {void}
9
+ */
10
+
11
+ /**
12
+ * @param {Function} func
13
+ * @param {Array<any>} args
14
+ * @param {ExecuteWithThenableCallback} [callback]
15
+ */
16
+ function executeWithThenable (func, args, callback) {
17
+ const result = func.apply(func, args)
18
+ if (isPromiseLike(result) && !result[kAvvio]) {
19
+ // process promise but not avvio mock thenable
20
+ result.then(() => process.nextTick(callback), (error) => process.nextTick(callback, error))
21
+ } else if (callback) {
22
+ process.nextTick(callback)
23
+ }
24
+ }
25
+
26
+ module.exports = {
27
+ executeWithThenable
28
+ }
novas/novacore-zephyr/claude-code-router/node_modules/avvio/lib/get-plugin-name.js ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 'use strict'
2
+
3
+ // this symbol is assigned by fastify-plugin
4
+ const { kPluginMeta } = require('./symbols')
5
+
6
+ /**
7
+ * @param {function} plugin
8
+ * @param {object} [options]
9
+ * @param {string} [options.name]
10
+ * @returns {string}
11
+ */
12
+ function getPluginName (plugin, options) {
13
+ // use explicit function metadata if set
14
+ if (plugin[kPluginMeta] && plugin[kPluginMeta].name) {
15
+ return plugin[kPluginMeta].name
16
+ }
17
+
18
+ // use explicit name option if set
19
+ if (options && options.name) {
20
+ return options.name
21
+ }
22
+
23
+ // determine from the function
24
+ if (plugin.name) {
25
+ return plugin.name
26
+ } else {
27
+ // takes the first two lines of the function if nothing else works
28
+ return plugin.toString().split('\n').slice(0, 2).map(s => s.trim()).join(' -- ')
29
+ }
30
+ }
31
+
32
+ module.exports = {
33
+ getPluginName
34
+ }
novas/novacore-zephyr/claude-code-router/node_modules/avvio/lib/is-bundled-or-typescript-plugin.js ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 'use strict'
2
+
3
+ /**
4
+ * bundled or typescript plugin
5
+ * @typedef {object} BundledOrTypescriptPlugin
6
+ * @property {function} default
7
+ */
8
+
9
+ /**
10
+ * @param {any} maybeBundledOrTypescriptPlugin
11
+ * @returns {plugin is BundledOrTypescriptPlugin}
12
+ */
13
+ function isBundledOrTypescriptPlugin (maybeBundledOrTypescriptPlugin) {
14
+ return (
15
+ maybeBundledOrTypescriptPlugin !== null &&
16
+ typeof maybeBundledOrTypescriptPlugin === 'object' &&
17
+ typeof maybeBundledOrTypescriptPlugin.default === 'function'
18
+ )
19
+ }
20
+
21
+ module.exports = {
22
+ isBundledOrTypescriptPlugin
23
+ }
novas/novacore-zephyr/claude-code-router/node_modules/avvio/lib/is-promise-like.js ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 'use strict'
2
+
3
+ /**
4
+ * @param {any} maybePromiseLike
5
+ * @returns {maybePromiseLike is PromiseLike}
6
+ */
7
+ function isPromiseLike (maybePromiseLike) {
8
+ return (
9
+ maybePromiseLike !== null &&
10
+ typeof maybePromiseLike === 'object' &&
11
+ typeof maybePromiseLike.then === 'function'
12
+ )
13
+ }
14
+
15
+ module.exports = {
16
+ isPromiseLike
17
+ }
novas/novacore-zephyr/claude-code-router/node_modules/avvio/lib/plugin.js ADDED
@@ -0,0 +1,279 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 'use strict'
2
+
3
+ const { EventEmitter } = require('node:events')
4
+ const { inherits } = require('node:util')
5
+ const { debug } = require('./debug')
6
+ const { createPromise } = require('./create-promise')
7
+ const { AVV_ERR_PLUGIN_EXEC_TIMEOUT } = require('./errors')
8
+ const { getPluginName } = require('./get-plugin-name')
9
+ const { isPromiseLike } = require('./is-promise-like')
10
+
11
+ /**
12
+ * @param {*} queue
13
+ * @param {*} func
14
+ * @param {*} options
15
+ * @param {boolean} isAfter
16
+ * @param {number} [timeout]
17
+ */
18
+ function Plugin (queue, func, options, isAfter, timeout) {
19
+ this.queue = queue
20
+ this.func = func
21
+ this.options = options
22
+
23
+ /**
24
+ * @type {boolean}
25
+ */
26
+ this.isAfter = isAfter
27
+ /**
28
+ * @type {number}
29
+ */
30
+ this.timeout = timeout
31
+
32
+ /**
33
+ * @type {boolean}
34
+ */
35
+ this.started = false
36
+ /**
37
+ * @type {string}
38
+ */
39
+ this.name = getPluginName(func, options)
40
+
41
+ this.queue.pause()
42
+
43
+ /**
44
+ * @type {Error|null}
45
+ */
46
+ this._error = null
47
+ /**
48
+ * @type {boolean}
49
+ */
50
+ this.loaded = false
51
+
52
+ this._promise = null
53
+
54
+ this.startTime = null
55
+ }
56
+
57
+ inherits(Plugin, EventEmitter)
58
+
59
+ /**
60
+ * @callback ExecCallback
61
+ * @param {Error|null} execErr
62
+ * @returns
63
+ */
64
+
65
+ /**
66
+ *
67
+ * @param {*} server
68
+ * @param {ExecCallback} callback
69
+ * @returns
70
+ */
71
+ Plugin.prototype.exec = function (server, callback) {
72
+ debug('exec', this.name)
73
+
74
+ this.server = server
75
+ const func = this.func
76
+ const name = this.name
77
+ let completed = false
78
+
79
+ this.options = typeof this.options === 'function' ? this.options(this.server) : this.options
80
+
81
+ let timer = null
82
+
83
+ /**
84
+ * @param {Error} [execErr]
85
+ */
86
+ const done = (execErr) => {
87
+ if (completed) {
88
+ debug('loading complete', name)
89
+ return
90
+ }
91
+
92
+ this._error = execErr
93
+
94
+ if (execErr) {
95
+ debug('exec errored', name)
96
+ } else {
97
+ debug('exec completed', name)
98
+ }
99
+
100
+ completed = true
101
+
102
+ if (timer) {
103
+ clearTimeout(timer)
104
+ }
105
+
106
+ callback(execErr)
107
+ }
108
+
109
+ if (this.timeout > 0) {
110
+ debug('setting up timeout', name, this.timeout)
111
+ timer = setTimeout(function () {
112
+ debug('timed out', name)
113
+ timer = null
114
+ const readyTimeoutErr = new AVV_ERR_PLUGIN_EXEC_TIMEOUT(name)
115
+ // TODO Remove reference to function
116
+ readyTimeoutErr.fn = func
117
+ done(readyTimeoutErr)
118
+ }, this.timeout)
119
+ }
120
+
121
+ this.started = true
122
+ this.startTime = Date.now()
123
+ this.emit('start', this.server ? this.server.name : null, this.name, Date.now())
124
+
125
+ const maybePromiseLike = func(this.server, this.options, done)
126
+
127
+ if (isPromiseLike(maybePromiseLike)) {
128
+ debug('exec: resolving promise', name)
129
+
130
+ maybePromiseLike.then(
131
+ () => process.nextTick(done),
132
+ (e) => process.nextTick(done, e))
133
+ } else if (func.length < 3) {
134
+ done()
135
+ }
136
+ }
137
+
138
+ /**
139
+ * @returns {Promise}
140
+ */
141
+ Plugin.prototype.loadedSoFar = function () {
142
+ debug('loadedSoFar', this.name)
143
+
144
+ if (this.loaded) {
145
+ return Promise.resolve()
146
+ }
147
+
148
+ const setup = () => {
149
+ this.server.after((afterErr, callback) => {
150
+ this._error = afterErr
151
+ this.queue.pause()
152
+
153
+ if (this._promise) {
154
+ if (afterErr) {
155
+ debug('rejecting promise', this.name, afterErr)
156
+ this._promise.reject(afterErr)
157
+ } else {
158
+ debug('resolving promise', this.name)
159
+ this._promise.resolve()
160
+ }
161
+ this._promise = null
162
+ }
163
+
164
+ process.nextTick(callback, afterErr)
165
+ })
166
+ this.queue.resume()
167
+ }
168
+
169
+ let res
170
+
171
+ if (!this._promise) {
172
+ this._promise = createPromise()
173
+ res = this._promise.promise
174
+
175
+ if (!this.server) {
176
+ this.on('start', setup)
177
+ } else {
178
+ setup()
179
+ }
180
+ } else {
181
+ res = Promise.resolve()
182
+ }
183
+
184
+ return res
185
+ }
186
+
187
+ /**
188
+ * @callback EnqueueCallback
189
+ * @param {Error|null} enqueueErr
190
+ * @param {Plugin} result
191
+ */
192
+
193
+ /**
194
+ *
195
+ * @param {Plugin} plugin
196
+ * @param {EnqueueCallback} callback
197
+ */
198
+ Plugin.prototype.enqueue = function (plugin, callback) {
199
+ debug('enqueue', this.name, plugin.name)
200
+
201
+ this.emit('enqueue', this.server ? this.server.name : null, this.name, Date.now())
202
+ this.queue.push(plugin, callback)
203
+ }
204
+
205
+ /**
206
+ * @callback FinishCallback
207
+ * @param {Error|null} finishErr
208
+ * @returns
209
+ */
210
+ /**
211
+ *
212
+ * @param {Error|null} err
213
+ * @param {FinishCallback} callback
214
+ * @returns
215
+ */
216
+ Plugin.prototype.finish = function (err, callback) {
217
+ debug('finish', this.name, err)
218
+
219
+ const done = () => {
220
+ if (this.loaded) {
221
+ return
222
+ }
223
+
224
+ debug('loaded', this.name)
225
+ this.emit('loaded', this.server ? this.server.name : null, this.name, Date.now())
226
+ this.loaded = true
227
+
228
+ callback(err)
229
+ }
230
+
231
+ if (err) {
232
+ if (this._promise) {
233
+ this._promise.reject(err)
234
+ this._promise = null
235
+ }
236
+ done()
237
+ return
238
+ }
239
+
240
+ const check = () => {
241
+ debug('check', this.name, this.queue.length(), this.queue.running(), this._promise)
242
+ if (this.queue.length() === 0 && this.queue.running() === 0) {
243
+ if (this._promise) {
244
+ const wrap = () => {
245
+ debug('wrap')
246
+ queueMicrotask(check)
247
+ }
248
+ this._promise.resolve()
249
+ this._promise.promise.then(wrap, wrap)
250
+ this._promise = null
251
+ } else {
252
+ done()
253
+ }
254
+ } else {
255
+ debug('delayed', this.name)
256
+ // finish when the queue of nested plugins to load is empty
257
+ this.queue.drain = () => {
258
+ debug('drain', this.name)
259
+ this.queue.drain = noop
260
+
261
+ // we defer the check, as a safety net for things
262
+ // that might be scheduled in the loading callback
263
+ queueMicrotask(check)
264
+ }
265
+ }
266
+ }
267
+
268
+ queueMicrotask(check)
269
+
270
+ // we start loading the dependents plugins only once
271
+ // the current level is finished
272
+ this.queue.resume()
273
+ }
274
+
275
+ function noop () {}
276
+
277
+ module.exports = {
278
+ Plugin
279
+ }
novas/novacore-zephyr/claude-code-router/node_modules/avvio/lib/symbols.js ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 'use strict'
2
+
3
+ // Internal Symbols
4
+ const kAvvio = Symbol('avvio.Boot')
5
+ const kIsOnCloseHandler = Symbol('isOnCloseHandler')
6
+ const kThenifyDoNotWrap = Symbol('avvio.ThenifyDoNotWrap')
7
+ const kUntrackNode = Symbol('avvio.TimeTree.untrackNode')
8
+ const kTrackNode = Symbol('avvio.TimeTree.trackNode')
9
+ const kGetParent = Symbol('avvio.TimeTree.getParent')
10
+ const kGetNode = Symbol('avvio.TimeTree.getNode')
11
+ const kAddNode = Symbol('avvio.TimeTree.addNode')
12
+
13
+ // Public Symbols
14
+ const kPluginMeta = Symbol.for('plugin-meta')
15
+
16
+ module.exports = {
17
+ kAvvio,
18
+ kIsOnCloseHandler,
19
+ kThenifyDoNotWrap,
20
+ kUntrackNode,
21
+ kTrackNode,
22
+ kGetParent,
23
+ kGetNode,
24
+ kAddNode,
25
+ kPluginMeta
26
+ }
novas/novacore-zephyr/claude-code-router/node_modules/avvio/lib/thenify.js ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 'use strict'
2
+
3
+ const { debug } = require('./debug')
4
+ const { kThenifyDoNotWrap } = require('./symbols')
5
+
6
+ /**
7
+ * @callback PromiseConstructorLikeResolve
8
+ * @param {any} value
9
+ * @returns {void}
10
+ */
11
+
12
+ /**
13
+ * @callback PromiseConstructorLikeReject
14
+ * @param {reason} error
15
+ * @returns {void}
16
+ */
17
+
18
+ /**
19
+ * @callback PromiseConstructorLike
20
+ * @param {PromiseConstructorLikeResolve} resolve
21
+ * @param {PromiseConstructorLikeReject} reject
22
+ * @returns {void}
23
+ */
24
+
25
+ /**
26
+ * @returns {PromiseConstructorLike}
27
+ */
28
+ function thenify () {
29
+ // If the instance is ready, then there is
30
+ // nothing to await. This is true during
31
+ // await server.ready() as ready() resolves
32
+ // with the server, end we will end up here
33
+ // because of automatic promise chaining.
34
+ if (this.booted) {
35
+ debug('thenify returning undefined because we are already booted')
36
+ return
37
+ }
38
+
39
+ // Calling resolve(this._server) would fetch the then
40
+ // property on the server, which will lead it here.
41
+ // If we do not break the recursion, we will loop
42
+ // forever.
43
+ if (this[kThenifyDoNotWrap]) {
44
+ this[kThenifyDoNotWrap] = false
45
+ return
46
+ }
47
+
48
+ debug('thenify')
49
+ return (resolve, reject) => {
50
+ const p = this._loadRegistered()
51
+ return p.then(() => {
52
+ this[kThenifyDoNotWrap] = true
53
+ return resolve(this._server)
54
+ }, reject)
55
+ }
56
+ }
57
+
58
+ module.exports = {
59
+ thenify
60
+ }
novas/novacore-zephyr/claude-code-router/node_modules/avvio/lib/time-tree.js ADDED
@@ -0,0 +1,200 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 'use strict'
2
+
3
+ const {
4
+ kUntrackNode,
5
+ kTrackNode,
6
+ kGetParent,
7
+ kGetNode,
8
+ kAddNode
9
+ } = require('./symbols')
10
+
11
+ /**
12
+ * Node of the TimeTree
13
+ * @typedef {object} TimeTreeNode
14
+ * @property {string} id
15
+ * @property {string|null} parent
16
+ * @property {string} label
17
+ * @property {Array<TimeTreeNode>} nodes
18
+ * @property {number} start
19
+ * @property {number|undefined} stop
20
+ * @property {number|undefined} diff
21
+ */
22
+
23
+ class TimeTree {
24
+ constructor () {
25
+ /**
26
+ * @type {TimeTreeNode|null} root
27
+ * @public
28
+ */
29
+ this.root = null
30
+
31
+ /**
32
+ * @type {Map<string, TimeTreeNode>} tableId
33
+ * @public
34
+ */
35
+ this.tableId = new Map()
36
+
37
+ /**
38
+ * @type {Map<string, Array<TimeTreeNode>>} tableLabel
39
+ * @public
40
+ */
41
+ this.tableLabel = new Map()
42
+ }
43
+
44
+ /**
45
+ * @param {TimeTreeNode} node
46
+ */
47
+ [kTrackNode] (node) {
48
+ this.tableId.set(node.id, node)
49
+ if (this.tableLabel.has(node.label)) {
50
+ this.tableLabel.get(node.label).push(node)
51
+ } else {
52
+ this.tableLabel.set(node.label, [node])
53
+ }
54
+ }
55
+
56
+ /**
57
+ * @param {TimeTreeNode} node
58
+ */
59
+ [kUntrackNode] (node) {
60
+ this.tableId.delete(node.id)
61
+
62
+ const labelNode = this.tableLabel.get(node.label)
63
+ labelNode.pop()
64
+
65
+ if (labelNode.length === 0) {
66
+ this.tableLabel.delete(node.label)
67
+ }
68
+ }
69
+
70
+ /**
71
+ * @param {string} parent
72
+ * @returns {TimeTreeNode}
73
+ */
74
+ [kGetParent] (parent) {
75
+ if (parent === null) {
76
+ return null
77
+ } else if (this.tableLabel.has(parent)) {
78
+ const parentNode = this.tableLabel.get(parent)
79
+ return parentNode[parentNode.length - 1]
80
+ } else {
81
+ return null
82
+ }
83
+ }
84
+
85
+ /**
86
+ *
87
+ * @param {string} nodeId
88
+ * @returns {TimeTreeNode}
89
+ */
90
+ [kGetNode] (nodeId) {
91
+ return this.tableId.get(nodeId)
92
+ }
93
+
94
+ /**
95
+ * @param {string} parent
96
+ * @param {string} label
97
+ * @param {number} start
98
+ * @returns {TimeTreeNode["id"]}
99
+ */
100
+ [kAddNode] (parent, label, start) {
101
+ const parentNode = this[kGetParent](parent)
102
+ const isRoot = parentNode === null
103
+
104
+ if (isRoot) {
105
+ this.root = {
106
+ parent: null,
107
+ id: 'root',
108
+ label,
109
+ nodes: [],
110
+ start,
111
+ stop: null,
112
+ diff: -1
113
+ }
114
+ this[kTrackNode](this.root)
115
+ return this.root.id
116
+ }
117
+
118
+ const nodeId = `${label}-${Math.random()}`
119
+ /**
120
+ * @type {TimeTreeNode}
121
+ */
122
+ const childNode = {
123
+ parent,
124
+ id: nodeId,
125
+ label,
126
+ nodes: [],
127
+ start,
128
+ stop: null,
129
+ diff: -1
130
+ }
131
+ parentNode.nodes.push(childNode)
132
+ this[kTrackNode](childNode)
133
+ return nodeId
134
+ }
135
+
136
+ /**
137
+ * @param {string} parent
138
+ * @param {string} label
139
+ * @param {number|undefined} start
140
+ * @returns {TimeTreeNode["id"]}
141
+ */
142
+ start (parent, label, start = Date.now()) {
143
+ return this[kAddNode](parent, label, start)
144
+ }
145
+
146
+ /**
147
+ * @param {string} nodeId
148
+ * @param {number|undefined} stop
149
+ */
150
+ stop (nodeId, stop = Date.now()) {
151
+ const node = this[kGetNode](nodeId)
152
+ if (node) {
153
+ node.stop = stop
154
+ node.diff = (node.stop - node.start) || 0
155
+ this[kUntrackNode](node)
156
+ }
157
+ }
158
+
159
+ /**
160
+ * @returns {TimeTreeNode}
161
+ */
162
+ toJSON () {
163
+ return Object.assign({}, this.root)
164
+ }
165
+
166
+ /**
167
+ * @returns {string}
168
+ */
169
+ prettyPrint () {
170
+ return prettyPrintTimeTree(this.toJSON())
171
+ }
172
+ }
173
+
174
+ /**
175
+ * @param {TimeTreeNode} obj
176
+ * @param {string|undefined} prefix
177
+ * @returns {string}
178
+ */
179
+ function prettyPrintTimeTree (obj, prefix = '') {
180
+ let result = prefix
181
+
182
+ const nodesCount = obj.nodes.length
183
+ const lastIndex = nodesCount - 1
184
+ result += `${obj.label} ${obj.diff} ms\n`
185
+
186
+ for (let i = 0; i < nodesCount; ++i) {
187
+ const node = obj.nodes[i]
188
+ const prefix_ = prefix + (i === lastIndex ? ' ' : '│ ')
189
+
190
+ result += prefix
191
+ result += (i === lastIndex ? '└─' : '├─')
192
+ result += (node.nodes.length === 0 ? '─ ' : '┬ ')
193
+ result += prettyPrintTimeTree(node, prefix_).slice(prefix.length + 2)
194
+ }
195
+ return result
196
+ }
197
+
198
+ module.exports = {
199
+ TimeTree
200
+ }
novas/novacore-zephyr/claude-code-router/node_modules/avvio/lib/validate-plugin.js ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 'use strict'
2
+
3
+ const { AVV_ERR_PLUGIN_NOT_VALID } = require('./errors')
4
+
5
+ /**
6
+ * @param {any} maybePlugin
7
+ * @throws {AVV_ERR_PLUGIN_NOT_VALID}
8
+ *
9
+ * @returns {asserts plugin is Function|PromiseLike}
10
+ */
11
+ function validatePlugin (maybePlugin) {
12
+ // validate if plugin is a function or Promise
13
+ if (!(maybePlugin && (typeof maybePlugin === 'function' || typeof maybePlugin.then === 'function'))) {
14
+ if (Array.isArray(maybePlugin)) {
15
+ throw new AVV_ERR_PLUGIN_NOT_VALID('array')
16
+ } else if (maybePlugin === null) {
17
+ throw new AVV_ERR_PLUGIN_NOT_VALID('null')
18
+ } else {
19
+ throw new AVV_ERR_PLUGIN_NOT_VALID(typeof maybePlugin)
20
+ }
21
+ }
22
+ }
23
+
24
+ module.exports = {
25
+ validatePlugin
26
+ }
novas/novacore-zephyr/claude-code-router/node_modules/avvio/test/after-and-ready.test.js ADDED
@@ -0,0 +1,864 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 'use strict'
2
+
3
+ const { test } = require('tap')
4
+ const boot = require('..')
5
+
6
+ test('boot a plugin and then execute a call after that', (t) => {
7
+ t.plan(5)
8
+
9
+ const app = boot()
10
+ let pluginLoaded = false
11
+ let afterCalled = false
12
+
13
+ app.use(function (s, opts, done) {
14
+ t.notOk(afterCalled, 'after not called')
15
+ pluginLoaded = true
16
+ done()
17
+ })
18
+
19
+ app.after(function (err, cb) {
20
+ t.error(err)
21
+ t.ok(pluginLoaded, 'afterred!')
22
+ afterCalled = true
23
+ cb()
24
+ })
25
+
26
+ app.on('start', () => {
27
+ t.ok(afterCalled, 'after called')
28
+ t.ok(pluginLoaded, 'plugin loaded')
29
+ })
30
+ })
31
+
32
+ test('after without a done callback', (t) => {
33
+ t.plan(5)
34
+
35
+ const app = boot()
36
+ let pluginLoaded = false
37
+ let afterCalled = false
38
+
39
+ app.use(function (s, opts, done) {
40
+ t.notOk(afterCalled, 'after not called')
41
+ pluginLoaded = true
42
+ done()
43
+ })
44
+
45
+ app.after(function (err) {
46
+ t.error(err)
47
+ t.ok(pluginLoaded, 'afterred!')
48
+ afterCalled = true
49
+ })
50
+
51
+ app.on('start', () => {
52
+ t.ok(afterCalled, 'after called')
53
+ t.ok(pluginLoaded, 'plugin loaded')
54
+ })
55
+ })
56
+
57
+ test('verify when a afterred call happens', (t) => {
58
+ t.plan(3)
59
+
60
+ const app = boot()
61
+
62
+ app.use(function (s, opts, done) {
63
+ done()
64
+ })
65
+
66
+ app.after(function (err, cb) {
67
+ t.error(err)
68
+ t.pass('afterred finished')
69
+ cb()
70
+ })
71
+
72
+ app.on('start', () => {
73
+ t.pass('booted')
74
+ })
75
+ })
76
+
77
+ test('internal after', (t) => {
78
+ t.plan(18)
79
+
80
+ const app = boot()
81
+ let firstLoaded = false
82
+ let secondLoaded = false
83
+ let thirdLoaded = false
84
+ let afterCalled = false
85
+
86
+ app.use(first)
87
+ app.use(third)
88
+
89
+ function first (s, opts, done) {
90
+ t.notOk(firstLoaded, 'first is not loaded')
91
+ t.notOk(secondLoaded, 'second is not loaded')
92
+ t.notOk(thirdLoaded, 'third is not loaded')
93
+ firstLoaded = true
94
+ s.use(second)
95
+ s.after(function (err, cb) {
96
+ t.error(err)
97
+ t.notOk(afterCalled, 'after was not called')
98
+ afterCalled = true
99
+ cb()
100
+ })
101
+ done()
102
+ }
103
+
104
+ function second (s, opts, done) {
105
+ t.ok(firstLoaded, 'first is loaded')
106
+ t.notOk(secondLoaded, 'second is not loaded')
107
+ t.notOk(thirdLoaded, 'third is not loaded')
108
+ t.notOk(afterCalled, 'after was not called')
109
+ secondLoaded = true
110
+ done()
111
+ }
112
+
113
+ function third (s, opts, done) {
114
+ t.ok(firstLoaded, 'first is loaded')
115
+ t.ok(secondLoaded, 'second is loaded')
116
+ t.ok(afterCalled, 'after was called')
117
+ t.notOk(thirdLoaded, 'third is not loaded')
118
+ thirdLoaded = true
119
+ done()
120
+ }
121
+
122
+ app.on('start', () => {
123
+ t.ok(firstLoaded, 'first is loaded')
124
+ t.ok(secondLoaded, 'second is loaded')
125
+ t.ok(thirdLoaded, 'third is loaded')
126
+ t.ok(afterCalled, 'after was called')
127
+ t.pass('booted')
128
+ })
129
+ })
130
+
131
+ test('ready adds at the end of the queue', (t) => {
132
+ t.plan(14)
133
+
134
+ const app = boot()
135
+ let pluginLoaded = false
136
+ let afterCalled = false
137
+ let readyCalled = false
138
+
139
+ app.ready(function (err, cb) {
140
+ t.error(err)
141
+ t.ok(pluginLoaded, 'after the plugin')
142
+ t.ok(afterCalled, 'after after')
143
+ readyCalled = true
144
+ process.nextTick(cb)
145
+ })
146
+
147
+ app.use(function (s, opts, done) {
148
+ t.notOk(afterCalled, 'after not called')
149
+ t.notOk(readyCalled, 'ready not called')
150
+ pluginLoaded = true
151
+
152
+ app.ready(function (err) {
153
+ t.error(err)
154
+ t.ok(readyCalled, 'after the first ready')
155
+ t.ok(afterCalled, 'after the after callback')
156
+ })
157
+
158
+ done()
159
+ })
160
+
161
+ app.after(function (err, cb) {
162
+ t.error(err)
163
+ t.ok(pluginLoaded, 'executing after!')
164
+ t.notOk(readyCalled, 'ready not called')
165
+ afterCalled = true
166
+ cb()
167
+ })
168
+
169
+ app.on('start', () => {
170
+ t.ok(afterCalled, 'after called')
171
+ t.ok(pluginLoaded, 'plugin loaded')
172
+ t.ok(readyCalled, 'ready called')
173
+ })
174
+ })
175
+
176
+ test('if the after/ready callback has two parameters, the first one must be the context', (t) => {
177
+ t.plan(4)
178
+
179
+ const server = { my: 'server' }
180
+ const app = boot(server)
181
+
182
+ app.use(function (s, opts, done) {
183
+ done()
184
+ })
185
+
186
+ app.after(function (err, context, cb) {
187
+ t.error(err)
188
+ t.equal(server, context)
189
+ cb()
190
+ })
191
+
192
+ app.ready(function (err, context, cb) {
193
+ t.error(err)
194
+ t.equal(server, context)
195
+ cb()
196
+ })
197
+ })
198
+
199
+ test('if the after/ready async, the returns must be the context generated', (t) => {
200
+ t.plan(3)
201
+
202
+ const server = { my: 'server', index: 0 }
203
+ const app = boot(server)
204
+ app.override = function (old) {
205
+ return { ...old, index: old.index + 1 }
206
+ }
207
+
208
+ app.use(function (s, opts, done) {
209
+ s.use(function (s, opts, done) {
210
+ s.ready().then(itself => t.same(itself, s, 'deep deep'))
211
+ done()
212
+ })
213
+ s.ready().then(itself => t.same(itself, s, 'deep'))
214
+ done()
215
+ })
216
+
217
+ app.ready().then(itself => t.same(itself, server, 'outer'))
218
+ })
219
+
220
+ test('if the after/ready callback, the returns must be the context generated', (t) => {
221
+ t.plan(3)
222
+
223
+ const server = { my: 'server', index: 0 }
224
+ const app = boot(server)
225
+ app.override = function (old) {
226
+ return { ...old, index: old.index + 1 }
227
+ }
228
+
229
+ app.use(function (s, opts, done) {
230
+ s.use(function (s, opts, done) {
231
+ s.ready((_, itself, done) => {
232
+ t.same(itself, s, 'deep deep')
233
+ done()
234
+ })
235
+ done()
236
+ })
237
+ s.ready((_, itself, done) => {
238
+ t.same(itself, s, 'deep')
239
+ done()
240
+ })
241
+ done()
242
+ })
243
+
244
+ app.ready((_, itself, done) => {
245
+ t.same(itself, server, 'outer')
246
+ done()
247
+ })
248
+ })
249
+
250
+ test('error should come in the first after - one parameter', (t) => {
251
+ t.plan(3)
252
+
253
+ const server = { my: 'server' }
254
+ const app = boot(server)
255
+
256
+ app.use(function (s, opts, done) {
257
+ done(new Error('err'))
258
+ })
259
+
260
+ app.after(function (err) {
261
+ t.ok(err instanceof Error)
262
+ t.equal(err.message, 'err')
263
+ })
264
+
265
+ app.ready(function (err) {
266
+ t.error(err)
267
+ })
268
+ })
269
+
270
+ test('error should come in the first after - two parameters', (t) => {
271
+ t.plan(3)
272
+
273
+ const server = { my: 'server' }
274
+ const app = boot(server)
275
+
276
+ app.use(function (s, opts, done) {
277
+ done(new Error('err'))
278
+ })
279
+
280
+ app.after(function (err, cb) {
281
+ t.ok(err instanceof Error)
282
+ t.equal(err.message, 'err')
283
+ cb()
284
+ })
285
+
286
+ app.ready(function (err) {
287
+ t.error(err)
288
+ })
289
+ })
290
+
291
+ test('error should come in the first after - three parameter', (t) => {
292
+ t.plan(4)
293
+
294
+ const server = { my: 'server' }
295
+ const app = boot(server)
296
+
297
+ app.use(function (s, opts, done) {
298
+ done(new Error('err'))
299
+ })
300
+
301
+ app.after(function (err, context, cb) {
302
+ t.ok(err instanceof Error)
303
+ t.equal(err.message, 'err')
304
+ t.equal(context, server)
305
+ cb()
306
+ })
307
+
308
+ app.ready(function (err) {
309
+ t.error(err)
310
+ })
311
+ })
312
+
313
+ test('error should come in the first ready - one parameter', (t) => {
314
+ t.plan(2)
315
+
316
+ const server = { my: 'server' }
317
+ const app = boot(server)
318
+
319
+ app.use(function (s, opts, done) {
320
+ done(new Error('err'))
321
+ })
322
+
323
+ app.ready(function (err) {
324
+ t.ok(err instanceof Error)
325
+ t.equal(err.message, 'err')
326
+ })
327
+ })
328
+
329
+ test('error should come in the first ready - two parameters', (t) => {
330
+ t.plan(2)
331
+
332
+ const server = { my: 'server' }
333
+ const app = boot(server)
334
+
335
+ app.use(function (s, opts, done) {
336
+ done(new Error('err'))
337
+ })
338
+
339
+ app.ready(function (err, cb) {
340
+ t.ok(err instanceof Error)
341
+ t.equal(err.message, 'err')
342
+ cb()
343
+ })
344
+ })
345
+
346
+ test('error should come in the first ready - three parameters', (t) => {
347
+ t.plan(3)
348
+
349
+ const server = { my: 'server' }
350
+ const app = boot(server)
351
+
352
+ app.use(function (s, opts, done) {
353
+ done(new Error('err'))
354
+ })
355
+
356
+ app.ready(function (err, context, cb) {
357
+ t.ok(err instanceof Error)
358
+ t.equal(err.message, 'err')
359
+ t.equal(context, server)
360
+ cb()
361
+ })
362
+ })
363
+
364
+ test('if `use` has a callback with more then one parameter, the error must not reach ready', (t) => {
365
+ t.plan(1)
366
+
367
+ const server = { my: 'server' }
368
+ const app = boot(server)
369
+
370
+ app.use(function (s, opts, done) {
371
+ done(new Error('err'))
372
+ })
373
+
374
+ app.ready(function (err) {
375
+ t.ok(err)
376
+ })
377
+ })
378
+
379
+ test('if `use` has a callback without parameters, the error must reach ready', (t) => {
380
+ t.plan(1)
381
+
382
+ const server = { my: 'server' }
383
+ const app = boot(server)
384
+
385
+ app.use(function (s, opts, done) {
386
+ done(new Error('err'))
387
+ }, () => {})
388
+
389
+ app.ready(function (err) {
390
+ t.ok(err)
391
+ })
392
+ })
393
+
394
+ test('should pass the errors from after to ready', (t) => {
395
+ t.plan(6)
396
+
397
+ const server = {}
398
+ const app = boot(server, {})
399
+
400
+ server.use(function (s, opts, done) {
401
+ t.equal(s, server, 'the first argument is the server')
402
+ t.same(opts, {}, 'no options')
403
+ done()
404
+ }).after((err, done) => {
405
+ t.error(err)
406
+ done(new Error('some error'))
407
+ })
408
+
409
+ server.onClose(() => {
410
+ t.ok('onClose called')
411
+ })
412
+
413
+ server.ready(err => {
414
+ t.equal(err.message, 'some error')
415
+ })
416
+
417
+ app.on('start', () => {
418
+ server.close(() => {
419
+ t.pass('booted')
420
+ })
421
+ })
422
+ })
423
+
424
+ test('after no encapsulation', t => {
425
+ t.plan(4)
426
+
427
+ const app = boot()
428
+ app.override = function (s, fn, opts) {
429
+ s = Object.create(s)
430
+ return s
431
+ }
432
+
433
+ app.use(function (instance, opts, next) {
434
+ instance.test = true
435
+ instance.after(function (err, i, done) {
436
+ t.error(err)
437
+ t.notOk(i.test)
438
+ done()
439
+ })
440
+ next()
441
+ })
442
+
443
+ app.after(function (err, i, done) {
444
+ t.error(err)
445
+ t.notOk(i.test)
446
+ done()
447
+ })
448
+ })
449
+
450
+ test('ready no encapsulation', t => {
451
+ t.plan(4)
452
+
453
+ const app = boot()
454
+ app.override = function (s, fn, opts) {
455
+ s = Object.create(s)
456
+ return s
457
+ }
458
+
459
+ app.use(function (instance, opts, next) {
460
+ instance.test = true
461
+ instance.ready(function (err, i, done) {
462
+ t.error(err)
463
+ t.notOk(i.test)
464
+ done()
465
+ })
466
+ next()
467
+ })
468
+
469
+ app.ready(function (err, i, done) {
470
+ t.error(err)
471
+ t.notOk(i.test)
472
+ done()
473
+ })
474
+ })
475
+
476
+ test('after encapsulation with a server', t => {
477
+ t.plan(4)
478
+
479
+ const server = { my: 'server' }
480
+ const app = boot(server)
481
+ app.override = function (s, fn, opts) {
482
+ s = Object.create(s)
483
+ return s
484
+ }
485
+
486
+ app.use(function (instance, opts, next) {
487
+ instance.test = true
488
+ instance.after(function (err, i, done) {
489
+ t.error(err)
490
+ t.ok(i.test)
491
+ done()
492
+ })
493
+ next()
494
+ })
495
+
496
+ app.after(function (err, i, done) {
497
+ t.error(err)
498
+ t.notOk(i.test)
499
+ done()
500
+ })
501
+ })
502
+
503
+ test('ready encapsulation with a server', t => {
504
+ t.plan(4)
505
+
506
+ const server = { my: 'server' }
507
+ const app = boot(server)
508
+ app.override = function (s, fn, opts) {
509
+ s = Object.create(s)
510
+ return s
511
+ }
512
+
513
+ app.use(function (instance, opts, next) {
514
+ instance.test = true
515
+ instance.ready(function (err, i, done) {
516
+ t.error(err)
517
+ t.ok(i.test)
518
+ done()
519
+ })
520
+ next()
521
+ })
522
+
523
+ app.ready(function (err, i, done) {
524
+ t.error(err)
525
+ t.notOk(i.test)
526
+ done()
527
+ })
528
+ })
529
+
530
+ test('after should passthrough the errors', (t) => {
531
+ t.plan(5)
532
+
533
+ const app = boot()
534
+ let pluginLoaded = false
535
+ let afterCalled = false
536
+
537
+ app.use(function (s, opts, done) {
538
+ t.notOk(afterCalled, 'after not called')
539
+ pluginLoaded = true
540
+ done(new Error('kaboom'))
541
+ })
542
+
543
+ app.after(function () {
544
+ t.ok(pluginLoaded, 'afterred!')
545
+ afterCalled = true
546
+ })
547
+
548
+ app.ready(function (err) {
549
+ t.ok(err)
550
+ t.ok(afterCalled, 'after called')
551
+ t.ok(pluginLoaded, 'plugin loaded')
552
+ })
553
+ })
554
+
555
+ test('stop loading plugins if it errors', (t) => {
556
+ t.plan(2)
557
+
558
+ const app = boot()
559
+
560
+ app.use(function first (server, opts, done) {
561
+ t.pass('first called')
562
+ done(new Error('kaboom'))
563
+ })
564
+
565
+ app.use(function second (server, opts, done) {
566
+ t.fail('this should never be called')
567
+ })
568
+
569
+ app.ready((err) => {
570
+ t.equal(err.message, 'kaboom')
571
+ })
572
+ })
573
+
574
+ test('keep loading if there is an .after', (t) => {
575
+ t.plan(4)
576
+
577
+ const app = boot()
578
+
579
+ app.use(function first (server, opts, done) {
580
+ t.pass('first called')
581
+ done(new Error('kaboom'))
582
+ })
583
+
584
+ app.after(function (err) {
585
+ t.equal(err.message, 'kaboom')
586
+ })
587
+
588
+ app.use(function second (server, opts, done) {
589
+ t.pass('second called')
590
+ done()
591
+ })
592
+
593
+ app.ready((err) => {
594
+ t.error(err)
595
+ })
596
+ })
597
+
598
+ test('do not load nested plugin if parent errors', (t) => {
599
+ t.plan(4)
600
+
601
+ const app = boot()
602
+
603
+ app.use(function first (server, opts, done) {
604
+ t.pass('first called')
605
+
606
+ server.use(function second (_, opts, done) {
607
+ t.fail('this should never be called')
608
+ })
609
+
610
+ done(new Error('kaboom'))
611
+ })
612
+
613
+ app.after(function (err) {
614
+ t.equal(err.message, 'kaboom')
615
+ })
616
+
617
+ app.use(function third (server, opts, done) {
618
+ t.pass('third called')
619
+ done()
620
+ })
621
+
622
+ app.ready((err) => {
623
+ t.error(err)
624
+ })
625
+ })
626
+
627
+ test('.after nested', (t) => {
628
+ t.plan(4)
629
+
630
+ const app = boot()
631
+
632
+ app.use(function outer (app, opts, done) {
633
+ app.use(function first (app, opts, done) {
634
+ t.pass('first called')
635
+ done(new Error('kaboom'))
636
+ })
637
+
638
+ app.after(function (err) {
639
+ t.equal(err.message, 'kaboom')
640
+ })
641
+
642
+ app.use(function second (app, opts, done) {
643
+ t.pass('second called')
644
+ done()
645
+ })
646
+
647
+ done()
648
+ })
649
+
650
+ app.ready((err) => {
651
+ t.error(err)
652
+ })
653
+ })
654
+
655
+ test('nested error', (t) => {
656
+ t.plan(4)
657
+
658
+ const app = boot()
659
+
660
+ app.use(function outer (app, opts, done) {
661
+ app.use(function first (app, opts, done) {
662
+ t.pass('first called')
663
+ done(new Error('kaboom'))
664
+ })
665
+
666
+ app.use(function second (app, opts, done) {
667
+ t.fail('this should never be called')
668
+ })
669
+
670
+ done()
671
+ })
672
+
673
+ app.after(function (err) {
674
+ t.equal(err.message, 'kaboom')
675
+ })
676
+
677
+ app.use(function third (server, opts, done) {
678
+ t.pass('third called')
679
+ done()
680
+ })
681
+
682
+ app.ready((err) => {
683
+ t.error(err)
684
+ })
685
+ })
686
+
687
+ test('preReady event', (t) => {
688
+ t.plan(4)
689
+
690
+ const app = boot()
691
+ const order = [1, 2]
692
+
693
+ app.use(function first (server, opts, done) {
694
+ t.pass('first called')
695
+ done()
696
+ })
697
+
698
+ app.use(function second (server, opts, done) {
699
+ t.pass('second called')
700
+ done()
701
+ })
702
+
703
+ app.on('preReady', () => {
704
+ t.equal(order.shift(), 1)
705
+ })
706
+
707
+ app.ready(() => {
708
+ t.equal(order.shift(), 2)
709
+ })
710
+ })
711
+
712
+ test('preReady event (multiple)', (t) => {
713
+ t.plan(6)
714
+
715
+ const app = boot()
716
+ const order = [1, 2, 3, 4]
717
+
718
+ app.use(function first (server, opts, done) {
719
+ t.pass('first called')
720
+ done()
721
+ })
722
+
723
+ app.use(function second (server, opts, done) {
724
+ t.pass('second called')
725
+ done()
726
+ })
727
+
728
+ app.on('preReady', () => {
729
+ t.equal(order.shift(), 1)
730
+ })
731
+
732
+ app.on('preReady', () => {
733
+ t.equal(order.shift(), 2)
734
+ })
735
+
736
+ app.on('preReady', () => {
737
+ t.equal(order.shift(), 3)
738
+ })
739
+
740
+ app.ready(() => {
741
+ t.equal(order.shift(), 4)
742
+ })
743
+ })
744
+
745
+ test('preReady event (nested)', (t) => {
746
+ t.plan(6)
747
+
748
+ const app = boot()
749
+ const order = [1, 2, 3, 4]
750
+
751
+ app.use(function first (server, opts, done) {
752
+ t.pass('first called')
753
+ done()
754
+ })
755
+
756
+ app.use(function second (server, opts, done) {
757
+ t.pass('second called')
758
+
759
+ server.on('preReady', () => {
760
+ t.equal(order.shift(), 3)
761
+ })
762
+
763
+ done()
764
+ })
765
+
766
+ app.on('preReady', () => {
767
+ t.equal(order.shift(), 1)
768
+ })
769
+
770
+ app.on('preReady', () => {
771
+ t.equal(order.shift(), 2)
772
+ })
773
+
774
+ app.ready(() => {
775
+ t.equal(order.shift(), 4)
776
+ })
777
+ })
778
+
779
+ test('preReady event (errored)', (t) => {
780
+ t.plan(5)
781
+
782
+ const app = boot()
783
+ const order = [1, 2, 3]
784
+
785
+ app.use(function first (server, opts, done) {
786
+ t.pass('first called')
787
+ done(new Error('kaboom'))
788
+ })
789
+
790
+ app.use(function second (server, opts, done) {
791
+ t.fail('We should not be here')
792
+ })
793
+
794
+ app.on('preReady', () => {
795
+ t.equal(order.shift(), 1)
796
+ })
797
+
798
+ app.on('preReady', () => {
799
+ t.equal(order.shift(), 2)
800
+ })
801
+
802
+ app.ready((err) => {
803
+ t.ok(err)
804
+ t.equal(order.shift(), 3)
805
+ })
806
+ })
807
+
808
+ test('after return self', (t) => {
809
+ t.plan(6)
810
+
811
+ const app = boot()
812
+ let pluginLoaded = false
813
+ let afterCalled = false
814
+ let second = false
815
+
816
+ app.use(function (s, opts, done) {
817
+ t.notOk(afterCalled, 'after not called')
818
+ pluginLoaded = true
819
+ done()
820
+ })
821
+
822
+ app.after(function () {
823
+ t.ok(pluginLoaded, 'afterred!')
824
+ afterCalled = true
825
+ // happens with after(() => app.use(..))
826
+ return app
827
+ })
828
+
829
+ app.use(function (s, opts, done) {
830
+ t.ok(afterCalled, 'after called')
831
+ second = true
832
+ done()
833
+ })
834
+
835
+ app.on('start', () => {
836
+ t.ok(afterCalled, 'after called')
837
+ t.ok(pluginLoaded, 'plugin loaded')
838
+ t.ok(second, 'second plugin loaded')
839
+ })
840
+ })
841
+
842
+ test('after 1 param swallows errors with server and timeout', (t) => {
843
+ t.plan(3)
844
+
845
+ const server = {}
846
+ boot(server, { autostart: false, timeout: 1000 })
847
+
848
+ server.use(function first (server, opts, done) {
849
+ t.pass('first called')
850
+ done(new Error('kaboom'))
851
+ })
852
+
853
+ server.use(function second (server, opts, done) {
854
+ t.fail('We should not be here')
855
+ })
856
+
857
+ server.after(function (err) {
858
+ t.ok(err)
859
+ })
860
+
861
+ server.ready(function (err) {
862
+ t.error(err)
863
+ })
864
+ })
novas/novacore-zephyr/claude-code-router/node_modules/avvio/test/after-pass-through.test.js ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 'use strict'
2
+
3
+ const { test } = require('tap')
4
+ const boot = require('..')
5
+
6
+ test('proper support for after with a passed async function in wrapped mode', (t) => {
7
+ const app = {}
8
+ boot(app)
9
+
10
+ t.plan(5)
11
+
12
+ const e = new Error('kaboom')
13
+
14
+ app.use(function (f, opts) {
15
+ return Promise.reject(e)
16
+ }).after(function (err, cb) {
17
+ t.equal(err, e)
18
+ cb(err)
19
+ }).after(function () {
20
+ t.pass('this is just called')
21
+ }).after(function (err, cb) {
22
+ t.equal(err, e)
23
+ cb(err)
24
+ })
25
+
26
+ app.ready().then(() => {
27
+ t.fail('this should not be called')
28
+ }).catch(err => {
29
+ t.ok(err)
30
+ t.equal(err.message, 'kaboom')
31
+ })
32
+ })
novas/novacore-zephyr/claude-code-router/node_modules/avvio/test/after-self-promise.test.js ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 'use strict'
2
+
3
+ const { test } = require('tap')
4
+ const boot = require('..')
5
+
6
+ test('after does not await itself', async (t) => {
7
+ t.plan(3)
8
+
9
+ const app = {}
10
+ boot(app)
11
+
12
+ app.use(async (app) => {
13
+ t.pass('plugin init')
14
+ })
15
+ app.after(() => app)
16
+ t.pass('reachable')
17
+
18
+ await app.ready()
19
+ t.pass('reachable')
20
+ })
novas/novacore-zephyr/claude-code-router/node_modules/avvio/test/after-throw.test.js ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 'use strict'
2
+
3
+ const { test } = require('tap')
4
+ const boot = require('..')
5
+
6
+ test('catched error by Promise.reject', (t) => {
7
+ const app = boot()
8
+ t.plan(2)
9
+
10
+ t.threw = function (err) {
11
+ t.equal(err.message, 'kaboom2')
12
+ }
13
+
14
+ app.use(function (f, opts) {
15
+ return Promise.reject(new Error('kaboom'))
16
+ }).after(function (err) {
17
+ t.equal(err.message, 'kaboom')
18
+ throw new Error('kaboom2')
19
+ })
20
+
21
+ app.ready(function () {
22
+ t.fail('the ready callback should never be called')
23
+ })
24
+ })
novas/novacore-zephyr/claude-code-router/node_modules/avvio/test/after-use-after.test.js ADDED
@@ -0,0 +1,90 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 'use strict'
2
+
3
+ const { test } = require('tap')
4
+ const boot = require('..')
5
+ const app = {}
6
+
7
+ boot(app)
8
+
9
+ test('multi after', (t) => {
10
+ t.plan(6)
11
+
12
+ app.use(function (f, opts, cb) {
13
+ cb()
14
+ }).after(() => {
15
+ t.pass('this is just called')
16
+
17
+ app.use(function (f, opts, cb) {
18
+ t.pass('this is just called')
19
+ cb()
20
+ })
21
+ }).after(function () {
22
+ t.pass('this is just called')
23
+ app.use(function (f, opts, cb) {
24
+ t.pass('this is just called')
25
+ cb()
26
+ })
27
+ }).after(function (err, cb) {
28
+ t.pass('this is just called')
29
+ cb(err)
30
+ })
31
+
32
+ app.ready().then(() => {
33
+ t.pass('ready')
34
+ }).catch(() => {
35
+ t.fail('this should not be called')
36
+ })
37
+ })
38
+
39
+ test('after grouping - use called after after called', (t) => {
40
+ t.plan(9)
41
+ const app = {}
42
+ boot(app)
43
+
44
+ const TEST_VALUE = {}
45
+ const OTHER_TEST_VALUE = {}
46
+ const NEW_TEST_VALUE = {}
47
+
48
+ const sO = (fn) => {
49
+ fn[Symbol.for('skip-override')] = true
50
+ return fn
51
+ }
52
+
53
+ app.use(sO(function (f, options, next) {
54
+ f.test = TEST_VALUE
55
+
56
+ next()
57
+ }))
58
+
59
+ app.after(function (err, f, done) {
60
+ t.error(err)
61
+ t.equal(f.test, TEST_VALUE)
62
+
63
+ f.test2 = OTHER_TEST_VALUE
64
+ done()
65
+ })
66
+
67
+ app.use(sO(function (f, options, next) {
68
+ t.equal(f.test, TEST_VALUE)
69
+ t.equal(f.test2, OTHER_TEST_VALUE)
70
+
71
+ f.test3 = NEW_TEST_VALUE
72
+
73
+ next()
74
+ }))
75
+
76
+ app.after(function (err, f, done) {
77
+ t.error(err)
78
+ t.equal(f.test, TEST_VALUE)
79
+ t.equal(f.test2, OTHER_TEST_VALUE)
80
+ t.equal(f.test3, NEW_TEST_VALUE)
81
+ done()
82
+ })
83
+
84
+ app.ready().then(() => {
85
+ t.pass('ready')
86
+ }).catch((e) => {
87
+ console.log(e)
88
+ t.fail('this should not be called')
89
+ })
90
+ })
novas/novacore-zephyr/claude-code-router/node_modules/avvio/test/async-await.test.js ADDED
@@ -0,0 +1,325 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 'use strict'
2
+
3
+ /* eslint no-prototype-builtins: off */
4
+
5
+ const { test } = require('tap')
6
+ const sleep = function (ms) {
7
+ return new Promise(function (resolve) {
8
+ setTimeout(resolve, ms)
9
+ })
10
+ }
11
+
12
+ const boot = require('..')
13
+
14
+ test('one level', async (t) => {
15
+ t.plan(14)
16
+
17
+ const app = boot()
18
+ let firstLoaded = false
19
+ let secondLoaded = false
20
+ let thirdLoaded = false
21
+
22
+ app.use(first)
23
+ app.use(third)
24
+
25
+ async function first (s, opts) {
26
+ t.notOk(firstLoaded, 'first is not loaded')
27
+ t.notOk(secondLoaded, 'second is not loaded')
28
+ t.notOk(thirdLoaded, 'third is not loaded')
29
+ firstLoaded = true
30
+ s.use(second)
31
+ }
32
+
33
+ async function second (s, opts) {
34
+ t.ok(firstLoaded, 'first is loaded')
35
+ t.notOk(secondLoaded, 'second is not loaded')
36
+ t.notOk(thirdLoaded, 'third is not loaded')
37
+ secondLoaded = true
38
+ }
39
+
40
+ async function third (s, opts) {
41
+ t.ok(firstLoaded, 'first is loaded')
42
+ t.ok(secondLoaded, 'second is loaded')
43
+ t.notOk(thirdLoaded, 'third is not loaded')
44
+ thirdLoaded = true
45
+ }
46
+
47
+ const readyContext = await app.ready()
48
+
49
+ t.equal(app, readyContext)
50
+ t.ok(firstLoaded, 'first is loaded')
51
+ t.ok(secondLoaded, 'second is loaded')
52
+ t.ok(thirdLoaded, 'third is loaded')
53
+ t.pass('booted')
54
+ })
55
+
56
+ test('multiple reentrant plugin loading', async (t) => {
57
+ t.plan(31)
58
+
59
+ const app = boot()
60
+ let firstLoaded = false
61
+ let secondLoaded = false
62
+ let thirdLoaded = false
63
+ let fourthLoaded = false
64
+ let fifthLoaded = false
65
+
66
+ app.use(first)
67
+ app.use(fifth)
68
+
69
+ async function first (s, opts) {
70
+ t.notOk(firstLoaded, 'first is not loaded')
71
+ t.notOk(secondLoaded, 'second is not loaded')
72
+ t.notOk(thirdLoaded, 'third is not loaded')
73
+ t.notOk(fourthLoaded, 'fourth is not loaded')
74
+ t.notOk(fifthLoaded, 'fifth is not loaded')
75
+ firstLoaded = true
76
+ s.use(second)
77
+ }
78
+
79
+ async function second (s, opts) {
80
+ t.ok(firstLoaded, 'first is loaded')
81
+ t.notOk(secondLoaded, 'second is not loaded')
82
+ t.notOk(thirdLoaded, 'third is not loaded')
83
+ t.notOk(fourthLoaded, 'fourth is not loaded')
84
+ t.notOk(fifthLoaded, 'fifth is not loaded')
85
+ secondLoaded = true
86
+ s.use(third)
87
+ await sleep(10)
88
+ s.use(fourth)
89
+ }
90
+
91
+ async function third (s, opts) {
92
+ t.ok(firstLoaded, 'first is loaded')
93
+ t.ok(secondLoaded, 'second is loaded')
94
+ t.notOk(thirdLoaded, 'third is not loaded')
95
+ t.notOk(fourthLoaded, 'fourth is not loaded')
96
+ t.notOk(fifthLoaded, 'fifth is not loaded')
97
+ thirdLoaded = true
98
+ }
99
+
100
+ async function fourth (s, opts) {
101
+ t.ok(firstLoaded, 'first is loaded')
102
+ t.ok(secondLoaded, 'second is loaded')
103
+ t.ok(thirdLoaded, 'third is loaded')
104
+ t.notOk(fourthLoaded, 'fourth is not loaded')
105
+ t.notOk(fifthLoaded, 'fifth is not loaded')
106
+ fourthLoaded = true
107
+ }
108
+
109
+ async function fifth (s, opts) {
110
+ t.ok(firstLoaded, 'first is loaded')
111
+ t.ok(secondLoaded, 'second is loaded')
112
+ t.ok(thirdLoaded, 'third is loaded')
113
+ t.ok(fourthLoaded, 'fourth is loaded')
114
+ t.notOk(fifthLoaded, 'fifth is not loaded')
115
+ fifthLoaded = true
116
+ }
117
+
118
+ await app.ready()
119
+ t.ok(firstLoaded, 'first is loaded')
120
+ t.ok(secondLoaded, 'second is loaded')
121
+ t.ok(thirdLoaded, 'third is loaded')
122
+ t.ok(fourthLoaded, 'fourth is loaded')
123
+ t.ok(fifthLoaded, 'fifth is loaded')
124
+ t.pass('booted')
125
+ })
126
+
127
+ test('async ready plugin registration (errored)', async (t) => {
128
+ t.plan(1)
129
+
130
+ const app = boot()
131
+
132
+ app.use(async (server, opts) => {
133
+ await sleep(10)
134
+ throw new Error('kaboom')
135
+ })
136
+
137
+ try {
138
+ await app.ready()
139
+ t.fail('we should not be here')
140
+ } catch (err) {
141
+ t.equal(err.message, 'kaboom')
142
+ }
143
+ })
144
+
145
+ test('after', async (t) => {
146
+ t.plan(15)
147
+
148
+ const app = boot()
149
+ let firstLoaded = false
150
+ let secondLoaded = false
151
+ let thirdLoaded = false
152
+
153
+ app.use(first)
154
+
155
+ async function first (s, opts) {
156
+ t.notOk(firstLoaded, 'first is not loaded')
157
+ t.notOk(secondLoaded, 'second is not loaded')
158
+ t.notOk(thirdLoaded, 'third is not loaded')
159
+ firstLoaded = true
160
+ s.after(second)
161
+ s.after(third)
162
+ }
163
+
164
+ async function second (err) {
165
+ t.error(err)
166
+ t.ok(firstLoaded, 'first is loaded')
167
+ t.notOk(secondLoaded, 'second is not loaded')
168
+ t.notOk(thirdLoaded, 'third is not loaded')
169
+ await sleep(10)
170
+ secondLoaded = true
171
+ }
172
+
173
+ async function third () {
174
+ t.ok(firstLoaded, 'first is loaded')
175
+ t.ok(secondLoaded, 'second is loaded')
176
+ t.notOk(thirdLoaded, 'third is not loaded')
177
+ await sleep(10)
178
+ thirdLoaded = true
179
+ }
180
+
181
+ const readyContext = await app.ready()
182
+
183
+ t.equal(app, readyContext)
184
+ t.ok(firstLoaded, 'first is loaded')
185
+ t.ok(secondLoaded, 'second is loaded')
186
+ t.ok(thirdLoaded, 'third is loaded')
187
+ t.pass('booted')
188
+ })
189
+
190
+ test('after wrapped', async (t) => {
191
+ t.plan(15)
192
+
193
+ const app = {}
194
+ boot(app)
195
+ let firstLoaded = false
196
+ let secondLoaded = false
197
+ let thirdLoaded = false
198
+
199
+ app.use(first)
200
+
201
+ async function first (s, opts) {
202
+ t.notOk(firstLoaded, 'first is not loaded')
203
+ t.notOk(secondLoaded, 'second is not loaded')
204
+ t.notOk(thirdLoaded, 'third is not loaded')
205
+ firstLoaded = true
206
+ s.after(second)
207
+ s.after(third)
208
+ }
209
+
210
+ async function second (err) {
211
+ t.error(err)
212
+ t.ok(firstLoaded, 'first is loaded')
213
+ t.notOk(secondLoaded, 'second is not loaded')
214
+ t.notOk(thirdLoaded, 'third is not loaded')
215
+ await sleep(10)
216
+ secondLoaded = true
217
+ }
218
+
219
+ async function third () {
220
+ t.ok(firstLoaded, 'first is loaded')
221
+ t.ok(secondLoaded, 'second is loaded')
222
+ t.notOk(thirdLoaded, 'third is not loaded')
223
+ await sleep(10)
224
+ thirdLoaded = true
225
+ }
226
+
227
+ const readyContext = await app.ready()
228
+
229
+ t.equal(app, readyContext)
230
+ t.ok(firstLoaded, 'first is loaded')
231
+ t.ok(secondLoaded, 'second is loaded')
232
+ t.ok(thirdLoaded, 'third is loaded')
233
+ t.pass('booted')
234
+ })
235
+
236
+ test('promise plugins', async (t) => {
237
+ t.plan(14)
238
+
239
+ const app = boot()
240
+ let firstLoaded = false
241
+ let secondLoaded = false
242
+ let thirdLoaded = false
243
+
244
+ app.use(first())
245
+ app.use(third())
246
+
247
+ async function first () {
248
+ return async function (s, opts) {
249
+ t.notOk(firstLoaded, 'first is not loaded')
250
+ t.notOk(secondLoaded, 'second is not loaded')
251
+ t.notOk(thirdLoaded, 'third is not loaded')
252
+ firstLoaded = true
253
+ s.use(second())
254
+ }
255
+ }
256
+
257
+ async function second () {
258
+ return async function (s, opts) {
259
+ t.ok(firstLoaded, 'first is loaded')
260
+ t.notOk(secondLoaded, 'second is not loaded')
261
+ t.notOk(thirdLoaded, 'third is not loaded')
262
+ secondLoaded = true
263
+ }
264
+ }
265
+
266
+ async function third () {
267
+ return async function (s, opts) {
268
+ t.ok(firstLoaded, 'first is loaded')
269
+ t.ok(secondLoaded, 'second is loaded')
270
+ t.notOk(thirdLoaded, 'third is not loaded')
271
+ thirdLoaded = true
272
+ }
273
+ }
274
+
275
+ const readyContext = await app.ready()
276
+
277
+ t.equal(app, readyContext)
278
+ t.ok(firstLoaded, 'first is loaded')
279
+ t.ok(secondLoaded, 'second is loaded')
280
+ t.ok(thirdLoaded, 'third is loaded')
281
+ t.pass('booted')
282
+ })
283
+
284
+ test('skip override with promise', (t) => {
285
+ t.plan(3)
286
+
287
+ const server = { my: 'server' }
288
+ const app = boot(server)
289
+
290
+ app.override = function (s, func) {
291
+ t.pass('override called')
292
+
293
+ if (func[Symbol.for('skip-override')]) {
294
+ return s
295
+ }
296
+ return Object.create(s)
297
+ }
298
+
299
+ app.use(first())
300
+
301
+ async function first () {
302
+ async function fn (s, opts) {
303
+ t.equal(s, server)
304
+ t.notOk(Object.prototype.isPrototypeOf.call(server, s))
305
+ }
306
+
307
+ fn[Symbol.for('skip-override')] = true
308
+
309
+ return fn
310
+ }
311
+ })
312
+
313
+ test('ready queue error', async (t) => {
314
+ const app = boot()
315
+ app.use(first)
316
+
317
+ async function first (s, opts) {}
318
+
319
+ app.ready(function (_, worker, done) {
320
+ const error = new Error('kaboom')
321
+ done(error)
322
+ })
323
+
324
+ await t.rejects(app.ready(), { message: 'kaboom' })
325
+ })
novas/novacore-zephyr/claude-code-router/node_modules/avvio/test/await-after.test.js ADDED
@@ -0,0 +1,449 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 'use strict'
2
+
3
+ const { test } = require('tap')
4
+ const boot = require('..')
5
+ const { promisify } = require('node:util')
6
+ const sleep = promisify(setTimeout)
7
+ const fs = require('node:fs').promises
8
+ const path = require('node:path')
9
+
10
+ test('await after - nested plugins with same tick callbacks', async (t) => {
11
+ const app = {}
12
+ boot(app)
13
+
14
+ let secondLoaded = false
15
+
16
+ app.use(async (app) => {
17
+ t.pass('plugin init')
18
+ app.use(async () => {
19
+ t.pass('plugin2 init')
20
+ await sleep(1)
21
+ secondLoaded = true
22
+ })
23
+ })
24
+ await app.after()
25
+ t.pass('reachable')
26
+ t.equal(secondLoaded, true)
27
+
28
+ await app.ready()
29
+ t.pass('reachable')
30
+ })
31
+
32
+ test('await after without server', async (t) => {
33
+ const app = boot()
34
+
35
+ let secondLoaded = false
36
+
37
+ app.use(async (app) => {
38
+ t.pass('plugin init')
39
+ app.use(async () => {
40
+ t.pass('plugin2 init')
41
+ await sleep(1)
42
+ secondLoaded = true
43
+ })
44
+ })
45
+ await app.after()
46
+ t.pass('reachable')
47
+ t.equal(secondLoaded, true)
48
+
49
+ await app.ready()
50
+ t.pass('reachable')
51
+ })
52
+
53
+ test('await after with cb functions', async (t) => {
54
+ const app = boot()
55
+ let secondLoaded = false
56
+ let record = ''
57
+
58
+ app.use(async (app) => {
59
+ t.pass('plugin init')
60
+ record += 'plugin|'
61
+ app.use(async () => {
62
+ t.pass('plugin2 init')
63
+ record += 'plugin2|'
64
+ await sleep(1)
65
+ secondLoaded = true
66
+ })
67
+ })
68
+ await app.after(() => {
69
+ record += 'after|'
70
+ })
71
+ t.pass('reachable')
72
+ t.equal(secondLoaded, true)
73
+ record += 'ready'
74
+ await app.ready()
75
+ t.pass('reachable')
76
+ t.equal(record, 'plugin|plugin2|after|ready')
77
+ })
78
+
79
+ test('await after - nested plugins with future tick callbacks', async (t) => {
80
+ const app = {}
81
+ boot(app)
82
+
83
+ t.plan(4)
84
+
85
+ app.use((f, opts, cb) => {
86
+ t.pass('plugin init')
87
+ app.use((f, opts, cb) => {
88
+ t.pass('plugin2 init')
89
+ setImmediate(cb)
90
+ })
91
+ setImmediate(cb)
92
+ })
93
+ await app.after()
94
+ t.pass('reachable')
95
+
96
+ await app.ready()
97
+ t.pass('reachable')
98
+ })
99
+
100
+ test('await after - nested async function plugins', async (t) => {
101
+ const app = {}
102
+ boot(app)
103
+
104
+ t.plan(5)
105
+
106
+ app.use(async (f, opts) => {
107
+ t.pass('plugin init')
108
+ await app.use(async (f, opts) => {
109
+ t.pass('plugin2 init')
110
+ })
111
+ t.pass('reachable')
112
+ })
113
+ await app.after()
114
+ t.pass('reachable')
115
+
116
+ await app.ready()
117
+ t.pass('reachable')
118
+ })
119
+
120
+ test('await after - promise resolves to undefined', async (t) => {
121
+ const app = {}
122
+ boot(app)
123
+
124
+ t.plan(4)
125
+
126
+ app.use(async (f, opts, cb) => {
127
+ app.use((f, opts, cb) => {
128
+ t.pass('plugin init')
129
+ cb()
130
+ })
131
+ const instance = await app.after()
132
+ t.equal(instance, undefined)
133
+ })
134
+ t.pass('reachable')
135
+
136
+ await app.ready()
137
+ t.pass('reachable')
138
+ })
139
+
140
+ test('await after - promise returning function plugins + promise chaining', async (t) => {
141
+ const app = {}
142
+ boot(app)
143
+
144
+ t.plan(6)
145
+
146
+ app.use((f, opts) => {
147
+ t.pass('plugin init')
148
+ return app.use((f, opts) => {
149
+ t.pass('plugin2 init')
150
+ return Promise.resolve()
151
+ }).then((f2) => {
152
+ t.equal(f2, f)
153
+ return 'test'
154
+ }).then((val) => {
155
+ t.equal(val, 'test')
156
+ })
157
+ })
158
+ await app.after()
159
+ t.pass('reachable')
160
+
161
+ await app.ready()
162
+ t.pass('reachable')
163
+ })
164
+
165
+ test('await after - error handling, async throw', async (t) => {
166
+ const app = {}
167
+ boot(app)
168
+
169
+ t.plan(2)
170
+
171
+ const e = new Error('kaboom')
172
+
173
+ app.use(async (f, opts) => {
174
+ throw Error('kaboom')
175
+ })
176
+
177
+ await t.rejects(app.after(), e)
178
+
179
+ await t.rejects(() => app.ready(), Error('kaboom'))
180
+ })
181
+
182
+ test('await after - error handling, async throw, nested', async (t) => {
183
+ const app = {}
184
+ boot(app)
185
+
186
+ t.plan(2)
187
+
188
+ const e = new Error('kaboom')
189
+
190
+ app.use(async (f, opts) => {
191
+ app.use(async (f, opts) => {
192
+ throw e
193
+ })
194
+ })
195
+
196
+ await t.rejects(app.after())
197
+ await t.rejects(() => app.ready(), e)
198
+ })
199
+
200
+ test('await after - error handling, same tick cb err', async (t) => {
201
+ const app = {}
202
+ boot(app)
203
+
204
+ t.plan(2)
205
+
206
+ app.use((f, opts, cb) => {
207
+ cb(Error('kaboom'))
208
+ })
209
+ await t.rejects(app.after())
210
+ await t.rejects(app.ready(), Error('kaboom'))
211
+ })
212
+
213
+ test('await after - error handling, same tick cb err, nested', async (t) => {
214
+ const app = {}
215
+ boot(app)
216
+
217
+ t.plan(2)
218
+
219
+ app.use((f, opts, cb) => {
220
+ app.use((f, opts, cb) => {
221
+ cb(Error('kaboom'))
222
+ })
223
+ cb()
224
+ })
225
+
226
+ await t.rejects(app.after())
227
+ await t.rejects(app.ready(), Error('kaboom'))
228
+ })
229
+
230
+ test('await after - error handling, future tick cb err', async (t) => {
231
+ const app = {}
232
+ boot(app)
233
+
234
+ t.plan(2)
235
+
236
+ app.use((f, opts, cb) => {
237
+ setImmediate(() => { cb(Error('kaboom')) })
238
+ })
239
+
240
+ await t.rejects(app.after())
241
+ await t.rejects(app.ready(), Error('kaboom'))
242
+ })
243
+
244
+ test('await after - error handling, future tick cb err, nested', async (t) => {
245
+ const app = {}
246
+ boot(app)
247
+
248
+ t.plan(2)
249
+
250
+ app.use((f, opts, cb) => {
251
+ app.use((f, opts, cb) => {
252
+ setImmediate(() => { cb(Error('kaboom')) })
253
+ })
254
+ cb()
255
+ })
256
+ await t.rejects(app.after(), Error('kaboom'))
257
+ await t.rejects(app.ready(), Error('kaboom'))
258
+ })
259
+
260
+ test('await after complex scenario', async (t) => {
261
+ const app = {}
262
+ boot(app)
263
+ t.plan(16)
264
+
265
+ let firstLoaded = false
266
+ let secondLoaded = false
267
+ let thirdLoaded = false
268
+ let fourthLoaded = false
269
+
270
+ app.use(first)
271
+ await app.after()
272
+ t.ok(firstLoaded, 'first is loaded')
273
+ t.notOk(secondLoaded, 'second is not loaded')
274
+ t.notOk(thirdLoaded, 'third is not loaded')
275
+ t.notOk(fourthLoaded, 'fourth is not loaded')
276
+ app.use(second)
277
+ t.ok(firstLoaded, 'first is loaded')
278
+ t.notOk(secondLoaded, 'second is not loaded')
279
+ t.notOk(thirdLoaded, 'third is not loaded')
280
+ t.notOk(fourthLoaded, 'fourth is not loaded')
281
+ app.use(third)
282
+ await app.after()
283
+ t.ok(firstLoaded, 'first is loaded')
284
+ t.ok(secondLoaded, 'second is loaded')
285
+ t.ok(thirdLoaded, 'third is loaded')
286
+ t.ok(fourthLoaded, 'fourth is loaded')
287
+ await app.ready()
288
+ t.ok(firstLoaded, 'first is loaded')
289
+ t.ok(secondLoaded, 'second is loaded')
290
+ t.ok(thirdLoaded, 'third is loaded')
291
+ t.ok(fourthLoaded, 'fourth is loaded')
292
+
293
+ async function first () {
294
+ firstLoaded = true
295
+ }
296
+
297
+ async function second () {
298
+ secondLoaded = true
299
+ }
300
+
301
+ async function third (app) {
302
+ thirdLoaded = true
303
+ app.use(fourth)
304
+ }
305
+
306
+ async function fourth () {
307
+ fourthLoaded = true
308
+ }
309
+ })
310
+
311
+ test('without autostart and sync/async plugin mix', async (t) => {
312
+ const app = {}
313
+ boot(app, { autostart: false })
314
+ t.plan(21)
315
+
316
+ let firstLoaded = false
317
+ let secondLoaded = false
318
+ let thirdLoaded = false
319
+ let fourthLoaded = false
320
+
321
+ app.use(first)
322
+ await app.after()
323
+ t.ok(firstLoaded, 'first is loaded')
324
+ t.notOk(secondLoaded, 'second is not loaded')
325
+ t.notOk(thirdLoaded, 'third is not loaded')
326
+ t.notOk(fourthLoaded, 'fourth is not loaded')
327
+
328
+ app.use(second)
329
+ await app.after()
330
+ t.ok(firstLoaded, 'first is loaded')
331
+ t.ok(secondLoaded, 'second is loaded')
332
+ t.notOk(thirdLoaded, 'third is not loaded')
333
+ t.notOk(fourthLoaded, 'fourth is not loaded')
334
+
335
+ await sleep(10)
336
+
337
+ app.use(third)
338
+ await app.after()
339
+ t.ok(firstLoaded, 'first is loaded')
340
+ t.ok(secondLoaded, 'second is loaded')
341
+ t.ok(thirdLoaded, 'third is loaded')
342
+ t.notOk(fourthLoaded, 'fourth is not loaded')
343
+
344
+ app.use(fourth)
345
+ t.ok(firstLoaded, 'first is loaded')
346
+ t.ok(secondLoaded, 'second is loaded')
347
+ t.ok(thirdLoaded, 'third is loaded')
348
+ t.notOk(fourthLoaded, 'fourth is not loaded')
349
+
350
+ await app.after()
351
+ t.ok(firstLoaded, 'first is loaded')
352
+ t.ok(secondLoaded, 'second is loaded')
353
+ t.ok(thirdLoaded, 'third is loaded')
354
+ t.ok(fourthLoaded, 'fourth is loaded')
355
+
356
+ await app.ready()
357
+
358
+ async function first () {
359
+ firstLoaded = true
360
+ }
361
+
362
+ async function second () {
363
+ const contents = await fs.readFile(path.join(__dirname, 'fixtures', 'dummy.txt'), 'utf-8')
364
+ t.equal(contents, 'hello, world!')
365
+ secondLoaded = true
366
+ }
367
+
368
+ async function third () {
369
+ await sleep(10)
370
+ thirdLoaded = true
371
+ }
372
+
373
+ function fourth (server, opts, done) {
374
+ fourthLoaded = true
375
+ done()
376
+ }
377
+ })
378
+
379
+ test('without autostart', async (t) => {
380
+ const app = {}
381
+ boot(app, { autostart: false })
382
+ let firstLoaded = false
383
+ let secondLoaded = false
384
+ let thirdLoaded = false
385
+
386
+ app.use(async function first (app) {
387
+ firstLoaded = true
388
+ app.use(async () => {
389
+ await sleep(1)
390
+ secondLoaded = true
391
+ })
392
+ })
393
+
394
+ await app.after()
395
+ t.equal(firstLoaded, true)
396
+ t.equal(secondLoaded, true)
397
+
398
+ await app.use(async () => {
399
+ thirdLoaded = true
400
+ })
401
+
402
+ t.equal(thirdLoaded, true)
403
+
404
+ await app.ready()
405
+ })
406
+
407
+ test('without autostart and with override', async (t) => {
408
+ const app = {}
409
+ const _ = boot(app, { autostart: false })
410
+ let count = 0
411
+
412
+ _.override = function (s) {
413
+ const res = Object.create(s)
414
+ res.count = ++count
415
+
416
+ return res
417
+ }
418
+
419
+ app.use(async function first (app) {
420
+ t.equal(app.count, 1)
421
+ app.use(async (app) => {
422
+ t.equal(app.count, 2)
423
+ await app.after()
424
+ })
425
+ })
426
+
427
+ await app.after()
428
+
429
+ await app.use(async (app) => {
430
+ t.equal(app.count, 3)
431
+ })
432
+
433
+ await app.ready()
434
+ })
435
+
436
+ test('stop processing after errors', async (t) => {
437
+ t.plan(2)
438
+
439
+ const app = boot()
440
+
441
+ try {
442
+ await app.use(async function first (app) {
443
+ t.pass('first should be loaded')
444
+ throw new Error('kaboom')
445
+ })
446
+ } catch (e) {
447
+ t.equal(e.message, 'kaboom')
448
+ }
449
+ })
novas/novacore-zephyr/claude-code-router/node_modules/avvio/test/await-self.test.js ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 'use strict'
2
+
3
+ const { test } = require('tap')
4
+ const boot = require('..')
5
+
6
+ test('await self', async (t) => {
7
+ const app = {}
8
+ boot(app)
9
+
10
+ t.equal(await app, app)
11
+ })
12
+
13
+ test('await self three times', async (t) => {
14
+ const app = {}
15
+ boot(app)
16
+
17
+ t.equal(await app, app)
18
+ t.equal(await app, app)
19
+ t.equal(await app, app)
20
+ })
21
+
22
+ test('await self within plugin', async (t) => {
23
+ const app = {}
24
+ boot(app)
25
+
26
+ app.use(async (f) => {
27
+ t.equal(await f, f)
28
+ })
29
+
30
+ t.equal(await app, app)
31
+ })
novas/novacore-zephyr/claude-code-router/node_modules/avvio/test/await-use.test.js ADDED
@@ -0,0 +1,294 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 'use strict'
2
+
3
+ const { test } = require('tap')
4
+ const { promisify } = require('node:util')
5
+ const sleep = promisify(setTimeout)
6
+ const boot = require('..')
7
+
8
+ test('await use - nested plugins with same tick callbacks', async (t) => {
9
+ const app = {}
10
+ boot(app)
11
+
12
+ t.plan(4)
13
+
14
+ await app.use((f, opts, cb) => {
15
+ t.pass('plugin init')
16
+ app.use((f, opts, cb) => {
17
+ t.pass('plugin2 init')
18
+ cb()
19
+ })
20
+ cb()
21
+ })
22
+ t.pass('reachable')
23
+
24
+ await app.ready()
25
+ t.pass('reachable')
26
+ })
27
+
28
+ test('await use - nested plugins with future tick callbacks', async (t) => {
29
+ const app = {}
30
+ boot(app)
31
+
32
+ t.plan(4)
33
+
34
+ await app.use((f, opts, cb) => {
35
+ t.pass('plugin init')
36
+ app.use((f, opts, cb) => {
37
+ t.pass('plugin2 init')
38
+ setImmediate(cb)
39
+ })
40
+ setImmediate(cb)
41
+ })
42
+ t.pass('reachable')
43
+
44
+ await app.ready()
45
+ t.pass('reachable')
46
+ })
47
+
48
+ test('await use - nested async function plugins', async (t) => {
49
+ const app = {}
50
+ boot(app)
51
+
52
+ t.plan(5)
53
+
54
+ await app.use(async (f, opts) => {
55
+ t.pass('plugin init')
56
+ await app.use(async (f, opts) => {
57
+ t.pass('plugin2 init')
58
+ })
59
+ t.pass('reachable')
60
+ })
61
+ t.pass('reachable')
62
+
63
+ await app.ready()
64
+ t.pass('reachable')
65
+ })
66
+
67
+ test('await use - promise returning function plugins + promise chaining', async (t) => {
68
+ const app = {}
69
+ boot(app)
70
+
71
+ t.plan(6)
72
+
73
+ await app.use((f, opts) => {
74
+ t.pass('plugin init')
75
+ return app.use((f, opts) => {
76
+ t.pass('plugin2 init')
77
+ return Promise.resolve()
78
+ }).then(() => {
79
+ t.pass('reachable')
80
+ return 'test'
81
+ }).then((val) => {
82
+ t.equal(val, 'test')
83
+ })
84
+ })
85
+ t.pass('reachable')
86
+
87
+ await app.ready()
88
+ t.pass('reachable')
89
+ })
90
+
91
+ test('await use - await and use chaining', async (t) => {
92
+ const app = {}
93
+ boot(app)
94
+
95
+ t.plan(3)
96
+
97
+ app.use(async (f, opts, cb) => {
98
+ await app.use(async (f, opts) => {
99
+ t.pass('plugin init')
100
+ }).use(async (f, opts) => {
101
+ t.pass('plugin2 init')
102
+ })
103
+ })
104
+
105
+ await app.ready()
106
+ t.pass('reachable')
107
+ })
108
+
109
+ function thenableRejects (t, thenable, err, msg) {
110
+ return t.rejects(async () => { await thenable }, err, msg)
111
+ }
112
+
113
+ test('await use - error handling, async throw', async (t) => {
114
+ const app = {}
115
+ boot(app)
116
+
117
+ t.plan(2)
118
+
119
+ await thenableRejects(t, app.use(async (f, opts) => {
120
+ throw Error('kaboom')
121
+ }), Error('kaboom'))
122
+
123
+ await t.rejects(app.ready(), Error('kaboom'))
124
+ })
125
+
126
+ test('await use - error handling, async throw, nested', async (t) => {
127
+ const app = {}
128
+ boot(app)
129
+
130
+ t.plan(2)
131
+
132
+ await thenableRejects(t, app.use(async function a (f, opts) {
133
+ await app.use(async function b (f, opts) {
134
+ throw Error('kaboom')
135
+ })
136
+ }, Error('kaboom')), 'b')
137
+
138
+ t.rejects(() => app.ready(), Error('kaboom'))
139
+ })
140
+
141
+ test('await use - error handling, same tick cb err', async (t) => {
142
+ const app = {}
143
+ boot(app)
144
+
145
+ t.plan(2)
146
+
147
+ await thenableRejects(t, app.use((f, opts, cb) => {
148
+ cb(Error('kaboom'))
149
+ }), Error('kaboom'))
150
+
151
+ t.rejects(() => app.ready(), Error('kaboom'))
152
+ })
153
+
154
+ test('await use - error handling, same tick cb err, nested', async (t) => {
155
+ const app = {}
156
+ boot(app)
157
+
158
+ t.plan(2)
159
+
160
+ await thenableRejects(t, app.use((f, opts, cb) => {
161
+ app.use((f, opts, cb) => {
162
+ cb(Error('kaboom'))
163
+ })
164
+ cb()
165
+ }), Error('kaboom'))
166
+
167
+ t.rejects(() => app.ready(), Error('kaboom'))
168
+ })
169
+
170
+ test('await use - error handling, future tick cb err', async (t) => {
171
+ const app = {}
172
+ boot(app)
173
+
174
+ t.plan(2)
175
+
176
+ await thenableRejects(t, app.use((f, opts, cb) => {
177
+ setImmediate(() => { cb(Error('kaboom')) })
178
+ }), Error('kaboom'))
179
+
180
+ t.rejects(() => app.ready(), Error('kaboom'))
181
+ })
182
+
183
+ test('await use - error handling, future tick cb err, nested', async (t) => {
184
+ const app = {}
185
+ boot(app)
186
+
187
+ t.plan(2)
188
+
189
+ await thenableRejects(t, app.use((f, opts, cb) => {
190
+ app.use((f, opts, cb) => {
191
+ setImmediate(() => { cb(Error('kaboom')) })
192
+ })
193
+ cb()
194
+ }), Error('kaboom'))
195
+
196
+ t.rejects(() => app.ready(), Error('kaboom'))
197
+ })
198
+
199
+ test('mixed await use and non-awaited use ', async (t) => {
200
+ const app = {}
201
+ boot(app)
202
+ t.plan(16)
203
+
204
+ let firstLoaded = false
205
+ let secondLoaded = false
206
+ let thirdLoaded = false
207
+ let fourthLoaded = false
208
+
209
+ await app.use(first)
210
+ t.ok(firstLoaded, 'first is loaded')
211
+ t.notOk(secondLoaded, 'second is not loaded')
212
+ t.notOk(thirdLoaded, 'third is not loaded')
213
+ t.notOk(fourthLoaded, 'fourth is not loaded')
214
+ app.use(second)
215
+ t.ok(firstLoaded, 'first is loaded')
216
+ t.notOk(secondLoaded, 'second is not loaded')
217
+ t.notOk(thirdLoaded, 'third is not loaded')
218
+ t.notOk(fourthLoaded, 'fourth is not loaded')
219
+ await app.use(third)
220
+ t.ok(firstLoaded, 'first is loaded')
221
+ t.ok(secondLoaded, 'second is loaded')
222
+ t.ok(thirdLoaded, 'third is loaded')
223
+ t.ok(fourthLoaded, 'fourth is loaded')
224
+ await app.ready()
225
+ t.ok(firstLoaded, 'first is loaded')
226
+ t.ok(secondLoaded, 'second is loaded')
227
+ t.ok(thirdLoaded, 'third is loaded')
228
+ t.ok(fourthLoaded, 'fourth is loaded')
229
+
230
+ async function first () {
231
+ firstLoaded = true
232
+ }
233
+
234
+ async function second () {
235
+ secondLoaded = true
236
+ }
237
+
238
+ async function third (app) {
239
+ thirdLoaded = true
240
+ app.use(fourth)
241
+ }
242
+
243
+ async function fourth () {
244
+ fourthLoaded = true
245
+ }
246
+ })
247
+
248
+ test('await use - mix of same and future tick callbacks', async (t) => {
249
+ const app = {}
250
+ boot(app, { autostart: false })
251
+ let record = ''
252
+
253
+ t.plan(4)
254
+
255
+ await app.use(async function plugin0 () {
256
+ t.pass('plugin0 init')
257
+ record += 'plugin0|'
258
+ })
259
+ await app.use(async function plugin1 () {
260
+ t.pass('plugin1 init')
261
+ await sleep(500)
262
+ record += 'plugin1|'
263
+ })
264
+ await sleep(1)
265
+ await app.use(async function plugin2 () {
266
+ t.pass('plugin2 init')
267
+ await sleep(500)
268
+ record += 'plugin2|'
269
+ })
270
+ record += 'ready'
271
+ t.equal(record, 'plugin0|plugin1|plugin2|ready')
272
+ })
273
+
274
+ test('await use - fork the promise chain', (t) => {
275
+ t.plan(3)
276
+ const app = {}
277
+ boot(app, { autostart: false })
278
+
279
+ async function setup () {
280
+ let set = false
281
+ await app.use(async function plugin0 () {
282
+ t.pass('plugin0 init')
283
+ await sleep(500)
284
+ set = true
285
+ })
286
+ t.equal(set, true)
287
+ }
288
+ setup()
289
+
290
+ app.ready((err, done) => {
291
+ t.error(err)
292
+ done()
293
+ })
294
+ })
novas/novacore-zephyr/claude-code-router/node_modules/avvio/test/basic.test.js ADDED
@@ -0,0 +1,439 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 'use strict'
2
+
3
+ const { test } = require('tap')
4
+ const boot = require('..')
5
+
6
+ test('boot an empty app', (t) => {
7
+ t.plan(1)
8
+ const app = boot()
9
+ app.on('start', () => {
10
+ t.pass('booted')
11
+ })
12
+ })
13
+
14
+ test('start returns app', (t) => {
15
+ t.plan(1)
16
+ const app = boot({}, { autostart: false })
17
+ app
18
+ .start()
19
+ .ready((err) => {
20
+ t.error(err)
21
+ })
22
+ })
23
+
24
+ test('boot an app with a plugin', (t) => {
25
+ t.plan(4)
26
+
27
+ const app = boot()
28
+ let after = false
29
+
30
+ app.use(function (server, opts, done) {
31
+ t.equal(server, app, 'the first argument is the server')
32
+ t.same(opts, {}, 'no options')
33
+ t.ok(after, 'delayed execution')
34
+ done()
35
+ })
36
+
37
+ after = true
38
+
39
+ app.on('start', () => {
40
+ t.pass('booted')
41
+ })
42
+ })
43
+
44
+ test('boot an app with a promisified plugin', (t) => {
45
+ t.plan(4)
46
+
47
+ const app = boot()
48
+ let after = false
49
+
50
+ app.use(function (server, opts) {
51
+ t.equal(server, app, 'the first argument is the server')
52
+ t.same(opts, {}, 'no options')
53
+ t.ok(after, 'delayed execution')
54
+ return Promise.resolve()
55
+ })
56
+
57
+ after = true
58
+
59
+ app.on('start', () => {
60
+ t.pass('booted')
61
+ })
62
+ })
63
+
64
+ test('boot an app with a plugin and a callback /1', (t) => {
65
+ t.plan(2)
66
+
67
+ const app = boot(() => {
68
+ t.pass('booted')
69
+ })
70
+
71
+ app.use(function (server, opts, done) {
72
+ t.pass('plugin loaded')
73
+ done()
74
+ })
75
+ })
76
+
77
+ test('boot an app with a plugin and a callback /2', (t) => {
78
+ t.plan(2)
79
+
80
+ const app = boot({}, () => {
81
+ t.pass('booted')
82
+ })
83
+
84
+ app.use(function (server, opts, done) {
85
+ t.pass('plugin loaded')
86
+ done()
87
+ })
88
+ })
89
+
90
+ test('boot a plugin with a custom server', (t) => {
91
+ t.plan(4)
92
+
93
+ const server = {}
94
+ const app = boot(server)
95
+
96
+ app.use(function (s, opts, done) {
97
+ t.equal(s, server, 'the first argument is the server')
98
+ t.same(opts, {}, 'no options')
99
+ done()
100
+ })
101
+
102
+ app.onClose(() => {
103
+ t.ok('onClose called')
104
+ })
105
+
106
+ app.on('start', () => {
107
+ app.close(() => {
108
+ t.pass('booted')
109
+ })
110
+ })
111
+ })
112
+
113
+ test('custom instance should inherits avvio methods /1', (t) => {
114
+ t.plan(6)
115
+
116
+ const server = {}
117
+ const app = boot(server, {})
118
+
119
+ server.use(function (s, opts, done) {
120
+ t.equal(s, server, 'the first argument is the server')
121
+ t.same(opts, {}, 'no options')
122
+ done()
123
+ }).after(() => {
124
+ t.ok('after called')
125
+ })
126
+
127
+ server.onClose(() => {
128
+ t.ok('onClose called')
129
+ })
130
+
131
+ server.ready(() => {
132
+ t.ok('ready called')
133
+ })
134
+
135
+ app.on('start', () => {
136
+ server.close(() => {
137
+ t.pass('booted')
138
+ })
139
+ })
140
+ })
141
+
142
+ test('custom instance should inherits avvio methods /2', (t) => {
143
+ t.plan(6)
144
+
145
+ const server = {}
146
+ const app = new boot(server, {}) // eslint-disable-line new-cap
147
+
148
+ server.use(function (s, opts, done) {
149
+ t.equal(s, server, 'the first argument is the server')
150
+ t.same(opts, {}, 'no options')
151
+ done()
152
+ }).after(() => {
153
+ t.ok('after called')
154
+ })
155
+
156
+ server.onClose(() => {
157
+ t.ok('onClose called')
158
+ })
159
+
160
+ server.ready(() => {
161
+ t.ok('ready called')
162
+ })
163
+
164
+ app.on('start', () => {
165
+ server.close(() => {
166
+ t.pass('booted')
167
+ })
168
+ })
169
+ })
170
+
171
+ test('boot a plugin with options', (t) => {
172
+ t.plan(3)
173
+
174
+ const server = {}
175
+ const app = boot(server)
176
+ const myOpts = {
177
+ hello: 'world'
178
+ }
179
+
180
+ app.use(function (s, opts, done) {
181
+ t.equal(s, server, 'the first argument is the server')
182
+ t.same(opts, myOpts, 'passed options')
183
+ done()
184
+ }, myOpts)
185
+
186
+ app.on('start', () => {
187
+ t.pass('booted')
188
+ })
189
+ })
190
+
191
+ test('boot a plugin with a function that returns the options', (t) => {
192
+ t.plan(4)
193
+
194
+ const server = {}
195
+ const app = boot(server)
196
+ const myOpts = {
197
+ hello: 'world'
198
+ }
199
+ const myOptsAsFunc = parent => {
200
+ t.equal(parent, server)
201
+ return parent.myOpts
202
+ }
203
+
204
+ app.use(function (s, opts, done) {
205
+ s.myOpts = opts
206
+ done()
207
+ }, myOpts)
208
+
209
+ app.use(function (s, opts, done) {
210
+ t.equal(s, server, 'the first argument is the server')
211
+ t.same(opts, myOpts, 'passed options via function accessing parent injected variable')
212
+ done()
213
+ }, myOptsAsFunc)
214
+
215
+ app.on('start', () => {
216
+ t.pass('booted')
217
+ })
218
+ })
219
+
220
+ test('throw on non-function use', (t) => {
221
+ t.plan(1)
222
+ const app = boot()
223
+ t.throws(() => {
224
+ app.use({})
225
+ })
226
+ })
227
+
228
+ // https://github.com/mcollina/avvio/issues/20
229
+ test('ready and nextTick', (t) => {
230
+ const app = boot()
231
+ process.nextTick(() => {
232
+ app.ready(() => {
233
+ t.end()
234
+ })
235
+ })
236
+ })
237
+
238
+ // https://github.com/mcollina/avvio/issues/20
239
+ test('promises and microtask', (t) => {
240
+ const app = boot()
241
+ Promise.resolve()
242
+ .then(() => {
243
+ app.ready(function () {
244
+ t.end()
245
+ })
246
+ })
247
+ })
248
+
249
+ test('always loads nested plugins after the current one', (t) => {
250
+ t.plan(2)
251
+
252
+ const server = {}
253
+ const app = boot(server)
254
+
255
+ let second = false
256
+
257
+ app.use(function (s, opts, done) {
258
+ app.use(function (s, opts, done) {
259
+ second = true
260
+ done()
261
+ })
262
+ t.notOk(second)
263
+
264
+ done()
265
+ })
266
+
267
+ app.on('start', () => {
268
+ t.ok(second)
269
+ })
270
+ })
271
+
272
+ test('promise long resolve', (t) => {
273
+ t.plan(2)
274
+
275
+ const app = boot()
276
+
277
+ setTimeout(function () {
278
+ t.throws(() => {
279
+ app.use((s, opts, done) => {
280
+ done()
281
+ })
282
+ }, 'root plugin has already booted')
283
+ })
284
+
285
+ app.ready(function (err) {
286
+ t.notOk(err)
287
+ })
288
+ })
289
+
290
+ test('do not autostart', (t) => {
291
+ const app = boot(null, {
292
+ autostart: false
293
+ })
294
+ app.on('start', () => {
295
+ t.fail()
296
+ })
297
+ t.end()
298
+ })
299
+
300
+ test('start with ready', (t) => {
301
+ t.plan(2)
302
+
303
+ const app = boot(null, {
304
+ autostart: false
305
+ })
306
+
307
+ app.on('start', () => {
308
+ t.pass()
309
+ })
310
+
311
+ app.ready(function (err) {
312
+ t.error(err)
313
+ })
314
+ })
315
+
316
+ test('load a plugin after start()', (t) => {
317
+ t.plan(1)
318
+
319
+ let startCalled = false
320
+ const app = boot(null, {
321
+ autostart: false
322
+ })
323
+
324
+ app.use((s, opts, done) => {
325
+ t.ok(startCalled)
326
+ done()
327
+ })
328
+
329
+ // we use a timer because
330
+ // it is more reliable than
331
+ // nextTick and setImmediate
332
+ // this almost always will come
333
+ // after those are completed
334
+ setTimeout(() => {
335
+ app.start()
336
+ startCalled = true
337
+ }, 2)
338
+ })
339
+
340
+ test('booted should be set before ready', (t) => {
341
+ t.plan(2)
342
+
343
+ const app = boot()
344
+
345
+ app.ready(function (err) {
346
+ t.error(err)
347
+ t.equal(app.booted, true)
348
+ })
349
+ })
350
+
351
+ test('start should be emitted after ready resolves', (t) => {
352
+ t.plan(1)
353
+
354
+ const app = boot()
355
+ let ready = false
356
+
357
+ app.ready().then(function () {
358
+ ready = true
359
+ })
360
+
361
+ app.on('start', function () {
362
+ t.equal(ready, true)
363
+ })
364
+ })
365
+
366
+ test('throws correctly if registering after ready', (t) => {
367
+ t.plan(1)
368
+
369
+ const app = boot()
370
+
371
+ app.ready(function () {
372
+ t.throws(() => {
373
+ app.use((a, b, done) => done())
374
+ }, 'root plugin has already booted')
375
+ })
376
+ })
377
+
378
+ test('preReady errors must be managed', (t) => {
379
+ t.plan(2)
380
+
381
+ const app = boot()
382
+
383
+ app.use((f, opts, cb) => {
384
+ cb()
385
+ })
386
+
387
+ app.on('preReady', () => {
388
+ throw new Error('boom')
389
+ })
390
+
391
+ app.ready(err => {
392
+ t.pass('ready function is called')
393
+ t.equal(err.message, 'boom')
394
+ })
395
+ })
396
+
397
+ test('preReady errors do not override plugin\'s errors', (t) => {
398
+ t.plan(3)
399
+
400
+ const app = boot()
401
+
402
+ app.use((f, opts, cb) => {
403
+ cb(new Error('baam'))
404
+ })
405
+
406
+ app.on('preReady', () => {
407
+ t.pass('preReady is executed')
408
+ throw new Error('boom')
409
+ })
410
+
411
+ app.ready(err => {
412
+ t.pass('ready function is called')
413
+ t.equal(err.message, 'baam')
414
+ })
415
+ })
416
+
417
+ test('support faux modules', (t) => {
418
+ t.plan(4)
419
+
420
+ const app = boot()
421
+ let after = false
422
+
423
+ // Faux modules are modules built with TypeScript
424
+ // or Babel that they export a .default property.
425
+ app.use({
426
+ default: function (server, opts, done) {
427
+ t.equal(server, app, 'the first argument is the server')
428
+ t.same(opts, {}, 'no options')
429
+ t.ok(after, 'delayed execution')
430
+ done()
431
+ }
432
+ })
433
+
434
+ after = true
435
+
436
+ app.on('start', () => {
437
+ t.pass('booted')
438
+ })
439
+ })
novas/novacore-zephyr/claude-code-router/node_modules/avvio/test/callbacks.test.js ADDED
@@ -0,0 +1,113 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 'use strict'
2
+
3
+ const { test } = require('tap')
4
+ const boot = require('..')
5
+
6
+ test('reentrant', (t) => {
7
+ t.plan(7)
8
+
9
+ const app = boot()
10
+ let firstLoaded = false
11
+ let secondLoaded = false
12
+
13
+ app
14
+ .use(first)
15
+ .after(() => {
16
+ t.ok(firstLoaded, 'first is loaded')
17
+ t.ok(secondLoaded, 'second is loaded')
18
+ t.pass('booted')
19
+ })
20
+
21
+ function first (s, opts, done) {
22
+ t.notOk(firstLoaded, 'first is not loaded')
23
+ t.notOk(secondLoaded, 'second is not loaded')
24
+ firstLoaded = true
25
+ s.use(second)
26
+ done()
27
+ }
28
+
29
+ function second (s, opts, done) {
30
+ t.ok(firstLoaded, 'first is loaded')
31
+ t.notOk(secondLoaded, 'second is not loaded')
32
+ secondLoaded = true
33
+ done()
34
+ }
35
+ })
36
+
37
+ test('reentrant with callbacks deferred', (t) => {
38
+ t.plan(11)
39
+
40
+ const app = boot()
41
+ let firstLoaded = false
42
+ let secondLoaded = false
43
+ let thirdLoaded = false
44
+
45
+ app.use(first)
46
+
47
+ function first (s, opts, done) {
48
+ t.notOk(firstLoaded, 'first is not loaded')
49
+ t.notOk(secondLoaded, 'second is not loaded')
50
+ t.notOk(thirdLoaded, 'third is not loaded')
51
+ firstLoaded = true
52
+ s.use(second)
53
+ setTimeout(() => {
54
+ try {
55
+ s.use(third)
56
+ } catch (err) {
57
+ t.equal(err.message, 'Root plugin has already booted')
58
+ }
59
+ }, 500)
60
+ done()
61
+ }
62
+
63
+ function second (s, opts, done) {
64
+ t.ok(firstLoaded, 'first is loaded')
65
+ t.notOk(secondLoaded, 'second is not loaded')
66
+ t.notOk(thirdLoaded, 'third is not loaded')
67
+ secondLoaded = true
68
+ done()
69
+ }
70
+
71
+ function third (s, opts, done) {
72
+ thirdLoaded = true
73
+ done()
74
+ }
75
+
76
+ app.on('start', () => {
77
+ t.ok(firstLoaded, 'first is loaded')
78
+ t.ok(secondLoaded, 'second is loaded')
79
+ t.notOk(thirdLoaded, 'third is not loaded')
80
+ t.pass('booted')
81
+ })
82
+ })
83
+
84
+ test('multiple loading time', t => {
85
+ t.plan(1)
86
+ const app = boot()
87
+
88
+ function a (instance, opts, done) {
89
+ (opts.use || []).forEach(_ => { instance.use(_, { use: opts.subUse || [] }) })
90
+ setTimeout(done, 10)
91
+ }
92
+ const pointer = a
93
+
94
+ function b (instance, opts, done) {
95
+ (opts.use || []).forEach(_ => { instance.use(_, { use: opts.subUse || [] }) })
96
+ setTimeout(done, 20)
97
+ }
98
+
99
+ function c (instance, opts, done) {
100
+ (opts.use || []).forEach(_ => { instance.use(_, { use: opts.subUse || [] }) })
101
+ setTimeout(done, 30)
102
+ }
103
+
104
+ app
105
+ .use(function a (instance, opts, done) {
106
+ instance.use(pointer, { use: [b], subUse: [c] })
107
+ .use(b)
108
+ setTimeout(done, 0)
109
+ })
110
+ .after(() => {
111
+ t.pass('booted')
112
+ })
113
+ })
novas/novacore-zephyr/claude-code-router/node_modules/avvio/test/catch-override-exception.test.js ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 'use strict'
2
+
3
+ const { test } = require('tap')
4
+ const boot = require('..')
5
+
6
+ test('catch exceptions in parent.override', (t) => {
7
+ t.plan(2)
8
+
9
+ const server = {}
10
+
11
+ const app = boot(server, {
12
+ autostart: false
13
+ })
14
+ app.override = function () {
15
+ throw Error('catch it')
16
+ }
17
+
18
+ app
19
+ .use(function () {})
20
+ .start()
21
+
22
+ app.ready(function (err) {
23
+ t.type(err, Error)
24
+ t.match(err, /catch it/)
25
+ })
26
+ })
novas/novacore-zephyr/claude-code-router/node_modules/avvio/test/chainable.test.js ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 'use strict'
2
+
3
+ const { test } = require('tap')
4
+ const boot = require('..')
5
+
6
+ test('chainable standalone', (t) => {
7
+ t.plan(5)
8
+
9
+ const readyResult = boot()
10
+ .use(function (ctx, opts, done) {
11
+ t.pass('1st plugin')
12
+ done()
13
+ }).after(function (err, done) {
14
+ t.error(err)
15
+ t.pass('2nd after')
16
+ done()
17
+ }).ready(function () {
18
+ t.pass('we are ready')
19
+ })
20
+ t.equal(readyResult, undefined)
21
+ })
22
+
23
+ test('chainable automatically binded', (t) => {
24
+ t.plan(5)
25
+
26
+ const app = {}
27
+ boot(app)
28
+
29
+ const readyResult = app
30
+ .use(function (ctx, opts, done) {
31
+ t.pass('1st plugin')
32
+ done()
33
+ }).after(function (err, done) {
34
+ t.error(err)
35
+ t.pass('2nd after')
36
+ done()
37
+ }).ready(function () {
38
+ t.pass('we are ready')
39
+ })
40
+ t.equal(readyResult, undefined)
41
+ })
42
+
43
+ test('chainable standalone with server', (t) => {
44
+ t.plan(6)
45
+
46
+ const server = {}
47
+ boot(server, {
48
+ expose: {
49
+ use: 'register'
50
+ }
51
+ })
52
+
53
+ const readyResult = server.register(function (ctx, opts, done) {
54
+ t.pass('1st plugin')
55
+ done()
56
+ }).after(function (err, done) {
57
+ t.error(err)
58
+ t.pass('2nd after')
59
+ done()
60
+ }).register(function (ctx, opts, done) {
61
+ t.pass('3rd plugin')
62
+ done()
63
+ }).ready(function () {
64
+ t.pass('we are ready')
65
+ })
66
+ t.equal(readyResult, undefined)
67
+ })
novas/novacore-zephyr/claude-code-router/node_modules/avvio/test/close.test.js ADDED
@@ -0,0 +1,544 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 'use strict'
2
+
3
+ const { test } = require('tap')
4
+ const boot = require('..')
5
+ const { AVV_ERR_CALLBACK_NOT_FN } = require('../lib/errors')
6
+
7
+ test('boot an app with a plugin', (t) => {
8
+ t.plan(4)
9
+
10
+ const app = boot()
11
+ let last = false
12
+
13
+ app.use(function (server, opts, done) {
14
+ app.onClose(() => {
15
+ t.ok('onClose called')
16
+ t.notOk(last)
17
+ last = true
18
+ })
19
+ done()
20
+ })
21
+
22
+ app.on('start', () => {
23
+ app.close(() => {
24
+ t.ok(last)
25
+ t.pass('Closed in the correct order')
26
+ })
27
+ })
28
+ })
29
+
30
+ test('onClose arguments', (t) => {
31
+ t.plan(5)
32
+
33
+ const app = boot()
34
+
35
+ app.use(function (server, opts, next) {
36
+ server.onClose((instance, done) => {
37
+ t.ok('called')
38
+ t.equal(server, instance)
39
+ done()
40
+ })
41
+ next()
42
+ })
43
+
44
+ app.use(function (server, opts, next) {
45
+ server.onClose((instance) => {
46
+ t.ok('called')
47
+ t.equal(server, instance)
48
+ })
49
+ next()
50
+ })
51
+
52
+ app.on('start', () => {
53
+ app.close(() => {
54
+ t.pass('Closed in the correct order')
55
+ })
56
+ })
57
+ })
58
+
59
+ test('onClose arguments - fastify encapsulation test case', (t) => {
60
+ t.plan(5)
61
+
62
+ const server = { my: 'server' }
63
+ const app = boot(server)
64
+
65
+ app.override = function (s, fn, opts) {
66
+ s = Object.create(s)
67
+ return s
68
+ }
69
+
70
+ app.use(function (instance, opts, next) {
71
+ instance.test = true
72
+ instance.onClose((i, done) => {
73
+ t.ok(i.test)
74
+ done()
75
+ })
76
+ next()
77
+ })
78
+
79
+ app.use(function (instance, opts, next) {
80
+ t.notOk(instance.test)
81
+ instance.onClose((i, done) => {
82
+ t.notOk(i.test)
83
+ done()
84
+ })
85
+ next()
86
+ })
87
+
88
+ app.on('start', () => {
89
+ t.notOk(app.test)
90
+ app.close(() => {
91
+ t.pass('Closed in the correct order')
92
+ })
93
+ })
94
+ })
95
+
96
+ test('onClose arguments - fastify encapsulation test case / 2', (t) => {
97
+ t.plan(5)
98
+
99
+ const server = { my: 'server' }
100
+ const app = boot(server)
101
+
102
+ app.override = function (s, fn, opts) {
103
+ s = Object.create(s)
104
+ return s
105
+ }
106
+
107
+ server.use(function (instance, opts, next) {
108
+ instance.test = true
109
+ instance.onClose((i, done) => {
110
+ t.ok(i.test)
111
+ done()
112
+ })
113
+ next()
114
+ })
115
+
116
+ server.use(function (instance, opts, next) {
117
+ t.notOk(instance.test)
118
+ instance.onClose((i, done) => {
119
+ t.notOk(i.test)
120
+ done()
121
+ })
122
+ next()
123
+ })
124
+
125
+ app.on('start', () => {
126
+ t.notOk(server.test)
127
+ try {
128
+ server.close()
129
+ t.pass()
130
+ } catch (err) {
131
+ t.fail(err)
132
+ }
133
+ })
134
+ })
135
+
136
+ test('onClose arguments - encapsulation test case no server', (t) => {
137
+ t.plan(5)
138
+
139
+ const app = boot()
140
+
141
+ app.override = function (s, fn, opts) {
142
+ s = Object.create(s)
143
+ return s
144
+ }
145
+
146
+ app.use(function (instance, opts, next) {
147
+ instance.test = true
148
+ instance.onClose((i, done) => {
149
+ t.notOk(i.test)
150
+ done()
151
+ })
152
+ next()
153
+ })
154
+
155
+ app.use(function (instance, opts, next) {
156
+ t.notOk(instance.test)
157
+ instance.onClose((i) => {
158
+ t.notOk(i.test)
159
+ })
160
+ next()
161
+ })
162
+
163
+ app.on('start', () => {
164
+ t.notOk(app.test)
165
+ app.close(() => {
166
+ t.pass('Closed in the correct order')
167
+ })
168
+ })
169
+ })
170
+
171
+ test('onClose should handle errors', (t) => {
172
+ t.plan(3)
173
+
174
+ const app = boot()
175
+
176
+ app.use(function (server, opts, done) {
177
+ app.onClose((instance, done) => {
178
+ t.ok('called')
179
+ done(new Error('some error'))
180
+ })
181
+ done()
182
+ })
183
+
184
+ app.on('start', () => {
185
+ app.close(err => {
186
+ t.equal(err.message, 'some error')
187
+ t.pass('Closed in the correct order')
188
+ })
189
+ })
190
+ })
191
+
192
+ test('#54 close handlers should receive same parameters when queue is not empty', (t) => {
193
+ t.plan(6)
194
+
195
+ const context = { test: true }
196
+ const app = boot(context)
197
+
198
+ app.use(function (server, opts, done) {
199
+ done()
200
+ })
201
+ app.on('start', () => {
202
+ app.close((err, done) => {
203
+ t.equal(err, null)
204
+ t.pass('Closed in the correct order')
205
+ setImmediate(done)
206
+ })
207
+ app.close(err => {
208
+ t.equal(err, null)
209
+ t.pass('Closed in the correct order')
210
+ })
211
+ app.close(err => {
212
+ t.equal(err, null)
213
+ t.pass('Closed in the correct order')
214
+ })
215
+ })
216
+ })
217
+
218
+ test('onClose should handle errors / 2', (t) => {
219
+ t.plan(4)
220
+
221
+ const app = boot()
222
+
223
+ app.onClose((instance, done) => {
224
+ t.ok('called')
225
+ done(new Error('some error'))
226
+ })
227
+
228
+ app.use(function (server, opts, done) {
229
+ app.onClose((instance, done) => {
230
+ t.ok('called')
231
+ done()
232
+ })
233
+ done()
234
+ })
235
+
236
+ app.on('start', () => {
237
+ app.close(err => {
238
+ t.equal(err.message, 'some error')
239
+ t.pass('Closed in the correct order')
240
+ })
241
+ })
242
+ })
243
+
244
+ test('close arguments', (t) => {
245
+ t.plan(4)
246
+
247
+ const app = boot()
248
+
249
+ app.use(function (server, opts, done) {
250
+ app.onClose((instance, done) => {
251
+ t.ok('called')
252
+ done()
253
+ })
254
+ done()
255
+ })
256
+
257
+ app.on('start', () => {
258
+ app.close((err, instance, done) => {
259
+ t.error(err)
260
+ t.equal(instance, app)
261
+ done()
262
+ t.pass('Closed in the correct order')
263
+ })
264
+ })
265
+ })
266
+
267
+ test('close event', (t) => {
268
+ t.plan(3)
269
+
270
+ const app = boot()
271
+ let last = false
272
+
273
+ app.on('start', () => {
274
+ app.close(() => {
275
+ t.notOk(last)
276
+ last = true
277
+ })
278
+ })
279
+
280
+ app.on('close', () => {
281
+ t.ok(last)
282
+ t.pass('event fired')
283
+ })
284
+ })
285
+
286
+ test('close order', (t) => {
287
+ t.plan(5)
288
+
289
+ const app = boot()
290
+ const order = [1, 2, 3, 4]
291
+
292
+ app.use(function (server, opts, done) {
293
+ app.onClose(() => {
294
+ t.equal(order.shift(), 3)
295
+ })
296
+
297
+ app.use(function (server, opts, done) {
298
+ app.onClose(() => {
299
+ t.equal(order.shift(), 2)
300
+ })
301
+ done()
302
+ })
303
+ done()
304
+ })
305
+
306
+ app.use(function (server, opts, done) {
307
+ app.onClose(() => {
308
+ t.equal(order.shift(), 1)
309
+ })
310
+ done()
311
+ })
312
+
313
+ app.on('start', () => {
314
+ app.close(() => {
315
+ t.equal(order.shift(), 4)
316
+ t.pass('Closed in the correct order')
317
+ })
318
+ })
319
+ })
320
+
321
+ test('close without a cb', (t) => {
322
+ t.plan(1)
323
+
324
+ const app = boot()
325
+
326
+ app.onClose((instance, done) => {
327
+ t.ok('called')
328
+ done()
329
+ })
330
+
331
+ app.close()
332
+ })
333
+
334
+ test('onClose with 0 parameters', (t) => {
335
+ t.plan(4)
336
+
337
+ const server = { my: 'server' }
338
+ const app = boot(server)
339
+
340
+ app.use(function (instance, opts, next) {
341
+ instance.onClose(function () {
342
+ t.ok('called')
343
+ t.equal(arguments.length, 0)
344
+ })
345
+ next()
346
+ })
347
+
348
+ app.close(err => {
349
+ t.error(err)
350
+ t.pass('Closed')
351
+ })
352
+ })
353
+
354
+ test('onClose with 1 parameter', (t) => {
355
+ t.plan(3)
356
+
357
+ const server = { my: 'server' }
358
+ const app = boot(server)
359
+
360
+ app.use(function (instance, opts, next) {
361
+ instance.onClose(function (context) {
362
+ t.equal(arguments.length, 1)
363
+ })
364
+ next()
365
+ })
366
+
367
+ app.close(err => {
368
+ t.error(err)
369
+ t.pass('Closed')
370
+ })
371
+ })
372
+
373
+ test('close passing not a function', (t) => {
374
+ t.plan(1)
375
+
376
+ const app = boot()
377
+
378
+ app.onClose((instance, done) => {
379
+ t.ok('called')
380
+ done()
381
+ })
382
+
383
+ t.throws(() => app.close({}), { message: 'not a function' })
384
+ })
385
+
386
+ test('close passing not a function', (t) => {
387
+ t.plan(1)
388
+
389
+ const app = boot()
390
+
391
+ app.onClose((instance, done) => {
392
+ t.ok('called')
393
+ done()
394
+ })
395
+
396
+ t.throws(() => app.close({}), { message: 'not a function' })
397
+ })
398
+
399
+ test('close passing not a function when wrapping', (t) => {
400
+ t.plan(1)
401
+
402
+ const app = {}
403
+ boot(app)
404
+
405
+ app.onClose((instance, done) => {
406
+ t.ok('called')
407
+ done()
408
+ })
409
+
410
+ t.throws(() => app.close({}), { message: 'not a function' })
411
+ })
412
+
413
+ test('close should trigger ready()', (t) => {
414
+ t.plan(2)
415
+
416
+ const app = boot(null, {
417
+ autostart: false
418
+ })
419
+
420
+ app.on('start', () => {
421
+ // this will be emitted after the
422
+ // callback in close() is fired
423
+ t.pass('started')
424
+ })
425
+
426
+ app.close(() => {
427
+ t.pass('closed')
428
+ })
429
+ })
430
+
431
+ test('close without a cb returns a promise', (t) => {
432
+ t.plan(1)
433
+
434
+ const app = boot()
435
+ app.close().then(() => {
436
+ t.pass('promise resolves')
437
+ })
438
+ })
439
+
440
+ test('close without a cb returns a promise when attaching to a server', (t) => {
441
+ t.plan(1)
442
+
443
+ const server = {}
444
+ boot(server)
445
+ server.close().then(() => {
446
+ t.pass('promise resolves')
447
+ })
448
+ })
449
+
450
+ test('close with async onClose handlers', t => {
451
+ t.plan(7)
452
+
453
+ const app = boot()
454
+ const order = [1, 2, 3, 4, 5, 6]
455
+
456
+ app.onClose(() => {
457
+ return new Promise(resolve => setTimeout(resolve, 500)).then(() => {
458
+ t.equal(order.shift(), 5)
459
+ })
460
+ })
461
+
462
+ app.onClose(() => {
463
+ t.equal(order.shift(), 4)
464
+ })
465
+
466
+ app.onClose(instance => {
467
+ return new Promise(resolve => setTimeout(resolve, 500)).then(() => {
468
+ t.equal(order.shift(), 3)
469
+ })
470
+ })
471
+
472
+ app.onClose(async instance => {
473
+ return new Promise(resolve => setTimeout(resolve, 500)).then(() => {
474
+ t.equal(order.shift(), 2)
475
+ })
476
+ })
477
+
478
+ app.onClose(async () => {
479
+ return new Promise(resolve => setTimeout(resolve, 500)).then(() => {
480
+ t.equal(order.shift(), 1)
481
+ })
482
+ })
483
+
484
+ app.on('start', () => {
485
+ app.close(() => {
486
+ t.equal(order.shift(), 6)
487
+ t.pass('Closed in the correct order')
488
+ })
489
+ })
490
+ })
491
+
492
+ test('onClose callback must be a function', (t) => {
493
+ t.plan(1)
494
+
495
+ const app = boot()
496
+
497
+ app.use(function (server, opts, done) {
498
+ t.throws(() => app.onClose({}), new AVV_ERR_CALLBACK_NOT_FN('onClose', 'object'))
499
+ done()
500
+ })
501
+ })
502
+
503
+ test('close custom server with async onClose handlers', t => {
504
+ t.plan(7)
505
+
506
+ const server = {}
507
+ const app = boot(server)
508
+ const order = [1, 2, 3, 4, 5, 6]
509
+
510
+ server.onClose(() => {
511
+ return new Promise(resolve => setTimeout(resolve, 500)).then(() => {
512
+ t.equal(order.shift(), 5)
513
+ })
514
+ })
515
+
516
+ server.onClose(() => {
517
+ t.equal(order.shift(), 4)
518
+ })
519
+
520
+ server.onClose(instance => {
521
+ return new Promise(resolve => setTimeout(resolve, 500)).then(() => {
522
+ t.equal(order.shift(), 3)
523
+ })
524
+ })
525
+
526
+ server.onClose(async instance => {
527
+ return new Promise(resolve => setTimeout(resolve, 500)).then(() => {
528
+ t.equal(order.shift(), 2)
529
+ })
530
+ })
531
+
532
+ server.onClose(async () => {
533
+ return new Promise(resolve => setTimeout(resolve, 500)).then(() => {
534
+ t.equal(order.shift(), 1)
535
+ })
536
+ })
537
+
538
+ app.on('start', () => {
539
+ app.close(() => {
540
+ t.equal(order.shift(), 6)
541
+ t.pass('Closed in the correct order')
542
+ })
543
+ })
544
+ })
novas/novacore-zephyr/claude-code-router/node_modules/avvio/test/errors.test.js ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 'use strict'
2
+
3
+ const { test } = require('tap')
4
+ const errors = require('../lib/errors')
5
+
6
+ test('Correct codes of AvvioErrors', t => {
7
+ const testcases = [
8
+ 'AVV_ERR_EXPOSE_ALREADY_DEFINED',
9
+ 'AVV_ERR_ATTRIBUTE_ALREADY_DEFINED',
10
+ 'AVV_ERR_CALLBACK_NOT_FN',
11
+ 'AVV_ERR_PLUGIN_NOT_VALID',
12
+ 'AVV_ERR_ROOT_PLG_BOOTED',
13
+ 'AVV_ERR_PARENT_PLG_LOADED',
14
+ 'AVV_ERR_READY_TIMEOUT',
15
+ 'AVV_ERR_PLUGIN_EXEC_TIMEOUT'
16
+ ]
17
+
18
+ t.plan(testcases.length + 1)
19
+ // errors.js exposes errors and the createError fn
20
+ t.equal(testcases.length, Object.keys(errors).length)
21
+
22
+ for (const testcase of testcases) {
23
+ const error = new errors[testcase]()
24
+ t.equal(error.code, testcase)
25
+ }
26
+ })
novas/novacore-zephyr/claude-code-router/node_modules/avvio/test/esm.mjs ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { test } from 'tap'
2
+ import boot from '../boot.js'
3
+
4
+ test('support import', async (t) => {
5
+ const app = boot()
6
+
7
+ app.use(import('./fixtures/esm.mjs'))
8
+
9
+ await app.ready()
10
+
11
+ t.equal(app.loaded, true)
12
+ })
novas/novacore-zephyr/claude-code-router/node_modules/avvio/test/esm.test.js ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 'use strict'
2
+
3
+ const { test } = require('tap')
4
+
5
+ test('support esm import', (t) => {
6
+ import('./esm.mjs').then(() => {
7
+ t.pass('esm is supported')
8
+ t.end()
9
+ }).catch((err) => {
10
+ process.nextTick(() => {
11
+ throw err
12
+ })
13
+ })
14
+ })
novas/novacore-zephyr/claude-code-router/node_modules/avvio/test/events-listeners.test.js ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 'use strict'
2
+
3
+ const { test } = require('tap')
4
+ const boot = require('..')
5
+ const noop = () => {}
6
+
7
+ test('boot a plugin and then execute a call after that', (t) => {
8
+ t.plan(1)
9
+
10
+ process.on('warning', (warning) => {
11
+ t.fail('we should not get a warning', warning)
12
+ })
13
+
14
+ const app = boot()
15
+ // eslint-disable-next-line no-var
16
+ for (var i = 0; i < 12; i++) {
17
+ app.on('preReady', noop)
18
+ }
19
+
20
+ setTimeout(() => {
21
+ t.pass('Everything ok')
22
+ }, 500)
23
+ })
novas/novacore-zephyr/claude-code-router/node_modules/avvio/test/expose.test.js ADDED
@@ -0,0 +1,80 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 'use strict'
2
+
3
+ const { test } = require('tap')
4
+ const boot = require('..')
5
+ const { AVV_ERR_EXPOSE_ALREADY_DEFINED, AVV_ERR_ATTRIBUTE_ALREADY_DEFINED } = require('../lib/errors')
6
+ const { kAvvio } = require('../lib/symbols')
7
+
8
+ for (const key of ['use', 'after', 'ready', 'onClose', 'close']) {
9
+ test('throws if ' + key + ' is by default already there', (t) => {
10
+ t.plan(1)
11
+
12
+ const app = {}
13
+ app[key] = () => { }
14
+
15
+ t.throws(() => boot(app), new AVV_ERR_EXPOSE_ALREADY_DEFINED(key, key))
16
+ })
17
+
18
+ test('throws if ' + key + ' is already there', (t) => {
19
+ t.plan(1)
20
+
21
+ const app = {}
22
+ app['cust' + key] = () => { }
23
+
24
+ t.throws(() => boot(app, { expose: { [key]: 'cust' + key } }), new AVV_ERR_EXPOSE_ALREADY_DEFINED('cust' + key, key))
25
+ })
26
+
27
+ test('support expose for ' + key, (t) => {
28
+ const app = {}
29
+ app[key] = () => { }
30
+
31
+ const expose = {}
32
+ expose[key] = 'muahah'
33
+
34
+ boot(app, {
35
+ expose
36
+ })
37
+
38
+ t.end()
39
+ })
40
+ }
41
+
42
+ test('set the kAvvio to true on the server', (t) => {
43
+ t.plan(1)
44
+
45
+ const server = {}
46
+ boot(server)
47
+
48
+ t.ok(server[kAvvio])
49
+ })
50
+
51
+ test('.then()', t => {
52
+ t.plan(3)
53
+
54
+ t.test('.then() can not be overwritten', (t) => {
55
+ t.plan(1)
56
+
57
+ const server = {
58
+ then: () => {}
59
+ }
60
+ t.throws(() => boot(server), AVV_ERR_ATTRIBUTE_ALREADY_DEFINED('then'))
61
+ })
62
+
63
+ t.test('.then() is a function', (t) => {
64
+ t.plan(1)
65
+
66
+ const server = {}
67
+ boot(server)
68
+
69
+ t.type(server.then, 'function')
70
+ })
71
+
72
+ t.test('.then() can not be overwritten', (t) => {
73
+ t.plan(1)
74
+
75
+ const server = {}
76
+ boot(server)
77
+
78
+ t.throws(() => { server.then = 'invalid' }, TypeError('Cannot set property then of #<Object> which has only a getter'))
79
+ })
80
+ })
novas/novacore-zephyr/claude-code-router/node_modules/avvio/test/fixtures/dummy.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ hello, world!
novas/novacore-zephyr/claude-code-router/node_modules/avvio/test/fixtures/esm.mjs ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ export default async function (app) {
2
+ app.loaded = true
3
+ }
novas/novacore-zephyr/claude-code-router/node_modules/avvio/test/fixtures/plugin-no-next.js ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ 'use strict'
2
+
3
+ module.exports = function noNext (app, opts, next) {
4
+ // no call to next
5
+ }
novas/novacore-zephyr/claude-code-router/node_modules/avvio/test/gh-issues/bug-205.test.js ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 'use strict'
2
+
3
+ const { test } = require('tap')
4
+ const boot = require('../..')
5
+
6
+ test('should print the time tree', (t) => {
7
+ t.plan(2)
8
+ const app = boot()
9
+
10
+ app.use(function first (instance, opts, cb) {
11
+ const out = instance.prettyPrint().split('\n')
12
+ t.equal(out[0], 'root -1 ms')
13
+ t.equal(out[1], '└── first -1 ms')
14
+ cb()
15
+ })
16
+ })
novas/novacore-zephyr/claude-code-router/node_modules/avvio/test/lib/create-promise.test.js ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 'use strict'
2
+
3
+ const { test } = require('tap')
4
+ const { createPromise } = require('../../lib/create-promise')
5
+
6
+ test('createPromise() returns an object', (t) => {
7
+ t.plan(3)
8
+ t.type(createPromise(), 'object')
9
+ t.equal(Array.isArray(createPromise()), false)
10
+ t.notOk(Array.isArray(createPromise() !== null))
11
+ })
12
+
13
+ test('createPromise() returns an attribute with attribute resolve', (t) => {
14
+ t.plan(1)
15
+ t.ok('resolve' in createPromise())
16
+ })
17
+
18
+ test('createPromise() returns an attribute with attribute reject', (t) => {
19
+ t.plan(1)
20
+ t.ok('reject' in createPromise())
21
+ })
22
+
23
+ test('createPromise() returns an attribute with attribute createPromise', (t) => {
24
+ t.plan(1)
25
+ t.ok('promise' in createPromise())
26
+ })
27
+
28
+ test('when resolve is called, createPromise attribute is resolved', (t) => {
29
+ t.plan(1)
30
+ const p = createPromise()
31
+
32
+ p.promise
33
+ .then(() => {
34
+ t.pass()
35
+ })
36
+ .catch(() => {
37
+ t.fail()
38
+ })
39
+ p.resolve()
40
+ })
41
+
42
+ test('when reject is called, createPromise attribute is rejected', (t) => {
43
+ t.plan(1)
44
+ const p = createPromise()
45
+
46
+ p.promise
47
+ .then(() => {
48
+ t.fail()
49
+ })
50
+ .catch(() => {
51
+ t.pass()
52
+ })
53
+
54
+ p.reject()
55
+ })
novas/novacore-zephyr/claude-code-router/node_modules/avvio/test/lib/execute-with-thenable.test.js ADDED
@@ -0,0 +1,82 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 'use strict'
2
+
3
+ const { test } = require('tap')
4
+ const { executeWithThenable } = require('../../lib/execute-with-thenable')
5
+ const { kAvvio } = require('../../lib/symbols')
6
+
7
+ test('executeWithThenable', (t) => {
8
+ t.plan(6)
9
+
10
+ t.test('passes the arguments to the function', (t) => {
11
+ t.plan(5)
12
+
13
+ executeWithThenable((...args) => {
14
+ t.equal(args.length, 3)
15
+ t.equal(args[0], 1)
16
+ t.equal(args[1], 2)
17
+ t.equal(args[2], 3)
18
+ }, [1, 2, 3], (err) => {
19
+ t.error(err)
20
+ })
21
+ })
22
+
23
+ t.test('function references this to itself', (t) => {
24
+ t.plan(2)
25
+
26
+ const func = function () {
27
+ t.equal(this, func)
28
+ }
29
+ executeWithThenable(func, [], (err) => {
30
+ t.error(err)
31
+ })
32
+ })
33
+
34
+ t.test('handle resolving Promise of func', (t) => {
35
+ t.plan(1)
36
+
37
+ const fn = function () {
38
+ return Promise.resolve(42)
39
+ }
40
+
41
+ executeWithThenable(fn, [], (err) => {
42
+ t.error(err)
43
+ })
44
+ })
45
+
46
+ t.test('handle rejecting Promise of func', (t) => {
47
+ t.plan(1)
48
+
49
+ const fn = function () {
50
+ return Promise.reject(new Error('Arbitrary Error'))
51
+ }
52
+
53
+ executeWithThenable(fn, [], (err) => {
54
+ t.equal(err.message, 'Arbitrary Error')
55
+ })
56
+ })
57
+
58
+ t.test('dont handle avvio mocks PromiseLike results but use callback if provided', (t) => {
59
+ t.plan(1)
60
+
61
+ const fn = function () {
62
+ const result = Promise.resolve(42)
63
+ result[kAvvio] = true
64
+ }
65
+
66
+ executeWithThenable(fn, [], (err) => {
67
+ t.error(err)
68
+ })
69
+ })
70
+
71
+ t.test('dont handle avvio mocks Promises and if no callback is provided', (t) => {
72
+ t.plan(1)
73
+
74
+ const fn = function () {
75
+ t.pass(1)
76
+ const result = Promise.resolve(42)
77
+ result[kAvvio] = true
78
+ }
79
+
80
+ executeWithThenable(fn, [])
81
+ })
82
+ })
novas/novacore-zephyr/claude-code-router/node_modules/avvio/test/lib/get-plugin-name.test.js ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 'use strict'
2
+
3
+ const { test } = require('tap')
4
+ const { getPluginName } = require('../../lib/get-plugin-name')
5
+ const { kPluginMeta } = require('../../lib/symbols')
6
+
7
+ test('getPluginName of function', (t) => {
8
+ t.plan(1)
9
+
10
+ t.equal(getPluginName(function aPlugin () { }), 'aPlugin')
11
+ })
12
+
13
+ test('getPluginName of async function', (t) => {
14
+ t.plan(1)
15
+
16
+ t.equal(getPluginName(async function aPlugin () { }), 'aPlugin')
17
+ })
18
+
19
+ test('getPluginName of arrow function without name', (t) => {
20
+ t.plan(2)
21
+
22
+ t.equal(getPluginName(() => { }), '() => { }')
23
+ t.equal(getPluginName(() => { return 'random' }), '() => { return \'random\' }')
24
+ })
25
+
26
+ test('getPluginName of arrow function assigned to variable', (t) => {
27
+ t.plan(1)
28
+
29
+ const namedArrowFunction = () => { }
30
+ t.equal(getPluginName(namedArrowFunction), 'namedArrowFunction')
31
+ })
32
+
33
+ test("getPluginName based on Symbol 'plugin-meta' /1", (t) => {
34
+ t.plan(1)
35
+
36
+ function plugin () {
37
+
38
+ }
39
+
40
+ plugin[kPluginMeta] = {}
41
+ t.equal(getPluginName(plugin), 'plugin')
42
+ })
43
+
44
+ test("getPluginName based on Symbol 'plugin-meta' /2", (t) => {
45
+ t.plan(1)
46
+
47
+ function plugin () {
48
+
49
+ }
50
+
51
+ plugin[kPluginMeta] = {
52
+ name: 'fastify-non-existent'
53
+ }
54
+ t.equal(getPluginName(plugin), 'fastify-non-existent')
55
+ })
56
+
57
+ test('getPluginName if null is provided as options', (t) => {
58
+ t.plan(1)
59
+
60
+ t.equal(getPluginName(function a () {}, null), 'a')
61
+ })
62
+
63
+ test('getPluginName if name is provided in options', (t) => {
64
+ t.plan(1)
65
+
66
+ t.equal(getPluginName(function defaultName () {}, { name: 'providedName' }), 'providedName')
67
+ })
novas/novacore-zephyr/claude-code-router/node_modules/avvio/test/lib/is-bundled-or-typescript-plugin.test.js ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 'use strict'
2
+
3
+ const { test } = require('tap')
4
+ const { isBundledOrTypescriptPlugin } = require('../../lib/is-bundled-or-typescript-plugin')
5
+
6
+ test('isBundledOrTypescriptPlugin', (t) => {
7
+ t.plan(9)
8
+
9
+ t.equal(isBundledOrTypescriptPlugin(1), false)
10
+ t.equal(isBundledOrTypescriptPlugin('function'), false)
11
+ t.equal(isBundledOrTypescriptPlugin({}), false)
12
+ t.equal(isBundledOrTypescriptPlugin([]), false)
13
+ t.equal(isBundledOrTypescriptPlugin(null), false)
14
+
15
+ t.equal(isBundledOrTypescriptPlugin(function () {}), false)
16
+ t.equal(isBundledOrTypescriptPlugin(new Promise((resolve) => resolve)), false)
17
+ t.equal(isBundledOrTypescriptPlugin(Promise.resolve()), false)
18
+
19
+ t.equal(isBundledOrTypescriptPlugin({ default: () => {} }), true)
20
+ })
novas/novacore-zephyr/claude-code-router/node_modules/avvio/test/lib/is-promise-like.test.js ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 'use strict'
2
+
3
+ const { test } = require('tap')
4
+ const { isPromiseLike } = require('../../lib/is-promise-like')
5
+
6
+ test('isPromiseLike', (t) => {
7
+ t.plan(9)
8
+
9
+ t.equal(isPromiseLike(1), false)
10
+ t.equal(isPromiseLike('function'), false)
11
+ t.equal(isPromiseLike({}), false)
12
+ t.equal(isPromiseLike([]), false)
13
+ t.equal(isPromiseLike(null), false)
14
+
15
+ t.equal(isPromiseLike(function () {}), false)
16
+ t.equal(isPromiseLike(new Promise((resolve) => resolve)), true)
17
+ t.equal(isPromiseLike(Promise.resolve()), true)
18
+
19
+ t.equal(isPromiseLike({ then: () => {} }), true)
20
+ })
novas/novacore-zephyr/claude-code-router/node_modules/avvio/test/lib/thenify.test.js ADDED
@@ -0,0 +1,123 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 'use strict'
2
+
3
+ const { test, mockRequire } = require('tap')
4
+ const { kThenifyDoNotWrap } = require('../../lib/symbols')
5
+
6
+ test('thenify', (t) => {
7
+ t.plan(7)
8
+
9
+ t.test('return undefined if booted', (t) => {
10
+ t.plan(2)
11
+
12
+ const { thenify } = mockRequire('../../lib/thenify', {
13
+ '../../lib/debug': {
14
+ debug: (message) => { t.equal(message, 'thenify returning undefined because we are already booted') }
15
+ }
16
+ })
17
+ const result = thenify.call({
18
+ booted: true
19
+ })
20
+ t.equal(result, undefined)
21
+ })
22
+
23
+ t.test('return undefined if kThenifyDoNotWrap is true', (t) => {
24
+ t.plan(1)
25
+
26
+ const { thenify } = require('../../lib/thenify')
27
+ const result = thenify.call({
28
+ [kThenifyDoNotWrap]: true
29
+ })
30
+ t.equal(result, undefined)
31
+ })
32
+
33
+ t.test('return PromiseConstructorLike if kThenifyDoNotWrap is false', (t) => {
34
+ t.plan(3)
35
+
36
+ const { thenify } = mockRequire('../../lib/thenify', {
37
+ '../../lib/debug': {
38
+ debug: (message) => { t.equal(message, 'thenify') }
39
+ }
40
+ })
41
+ const promiseContructorLike = thenify.call({
42
+ [kThenifyDoNotWrap]: false
43
+ })
44
+
45
+ t.type(promiseContructorLike, 'function')
46
+ t.equal(promiseContructorLike.length, 2)
47
+ })
48
+
49
+ t.test('return PromiseConstructorLike', (t) => {
50
+ t.plan(3)
51
+
52
+ const { thenify } = mockRequire('../../lib/thenify', {
53
+ '../../lib/debug': {
54
+ debug: (message) => { t.equal(message, 'thenify') }
55
+ }
56
+ })
57
+ const promiseContructorLike = thenify.call({})
58
+
59
+ t.type(promiseContructorLike, 'function')
60
+ t.equal(promiseContructorLike.length, 2)
61
+ })
62
+
63
+ t.test('resolve should return _server', async (t) => {
64
+ t.plan(1)
65
+
66
+ const { thenify } = require('../../lib/thenify')
67
+
68
+ const server = {
69
+ _loadRegistered: () => {
70
+ return Promise.resolve()
71
+ },
72
+ _server: 'server'
73
+ }
74
+ const promiseContructorLike = thenify.call(server)
75
+
76
+ promiseContructorLike(function (value) {
77
+ t.equal(value, 'server')
78
+ }, function (reason) {
79
+ t.error(reason)
80
+ })
81
+ })
82
+
83
+ t.test('resolving should set kThenifyDoNotWrap to true', async (t) => {
84
+ t.plan(1)
85
+
86
+ const { thenify } = require('../../lib/thenify')
87
+
88
+ const server = {
89
+ _loadRegistered: () => {
90
+ return Promise.resolve()
91
+ },
92
+ [kThenifyDoNotWrap]: false,
93
+ _server: 'server'
94
+ }
95
+ const promiseContructorLike = thenify.call(server)
96
+
97
+ promiseContructorLike(function (value) {
98
+ t.equal(server[kThenifyDoNotWrap], true)
99
+ }, function (reason) {
100
+ t.error(reason)
101
+ })
102
+ })
103
+
104
+ t.test('rejection should pass through to reject', async (t) => {
105
+ t.plan(1)
106
+
107
+ const { thenify } = require('../../lib/thenify')
108
+
109
+ const server = {
110
+ _loadRegistered: () => {
111
+ return Promise.reject(new Error('Arbitrary rejection'))
112
+ },
113
+ _server: 'server'
114
+ }
115
+ const promiseContructorLike = thenify.call(server)
116
+
117
+ promiseContructorLike(function (value) {
118
+ t.error(value)
119
+ }, function (reason) {
120
+ t.equal(reason.message, 'Arbitrary rejection')
121
+ })
122
+ })
123
+ })
novas/novacore-zephyr/claude-code-router/node_modules/avvio/test/lib/time-tree.test.js ADDED
@@ -0,0 +1,391 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 'use strict'
2
+
3
+ const { test } = require('tap')
4
+ const { TimeTree } = require('../../lib/time-tree')
5
+
6
+ test('TimeTree is constructed with a root attribute, set to null', t => {
7
+ t.plan(1)
8
+
9
+ const tree = new TimeTree()
10
+ t.equal(tree.root, null)
11
+ })
12
+
13
+ test('TimeTree is constructed with an empty tableId-Map', t => {
14
+ t.plan(2)
15
+
16
+ const tree = new TimeTree()
17
+ t.ok(tree.tableId instanceof Map)
18
+ t.equal(tree.tableId.size, 0)
19
+ })
20
+
21
+ test('TimeTree is constructed with an empty tableLabel-Map', t => {
22
+ t.plan(2)
23
+
24
+ const tree = new TimeTree()
25
+ t.ok(tree.tableLabel instanceof Map)
26
+ t.equal(tree.tableLabel.size, 0)
27
+ })
28
+
29
+ test('TimeTree#toJSON dumps the content of the TimeTree', t => {
30
+ t.plan(1)
31
+
32
+ const tree = new TimeTree()
33
+ t.same(tree.toJSON(), {})
34
+ })
35
+
36
+ test('TimeTree#toJSON is creating new instances of its content, ensuring being immutable', t => {
37
+ t.plan(1)
38
+
39
+ const tree = new TimeTree()
40
+ t.not(tree.toJSON(), tree.toJSON())
41
+ })
42
+
43
+ test('TimeTree#start is adding a node with correct shape, root-node', t => {
44
+ t.plan(15)
45
+
46
+ const tree = new TimeTree()
47
+ tree.start(null, 'root')
48
+
49
+ const rootNode = tree.root
50
+
51
+ t.equal(Object.keys(rootNode).length, 7)
52
+ t.ok('parent' in rootNode)
53
+ t.equal(rootNode.parent, null)
54
+ t.ok('id' in rootNode)
55
+ t.type(rootNode.id, 'string')
56
+ t.ok('label' in rootNode)
57
+ t.type(rootNode.label, 'string')
58
+ t.ok('nodes' in rootNode)
59
+ t.ok(Array.isArray(rootNode.nodes))
60
+ t.ok('start' in rootNode)
61
+ t.ok(Number.isInteger(rootNode.start))
62
+ t.ok('stop' in rootNode)
63
+ t.type(rootNode.stop, 'null')
64
+ t.ok('diff' in rootNode)
65
+ t.type(rootNode.diff, 'number')
66
+ })
67
+
68
+ test('TimeTree#start is adding a node with correct shape, child-node', t => {
69
+ t.plan(16)
70
+
71
+ const tree = new TimeTree()
72
+ tree.start(null, 'root')
73
+ tree.start('root', 'child')
74
+
75
+ const rootNode = tree.root
76
+
77
+ t.equal(rootNode.nodes.length, 1)
78
+
79
+ const childNode = rootNode.nodes[0]
80
+
81
+ t.equal(Object.keys(childNode).length, 7)
82
+ t.ok('parent' in childNode)
83
+ t.type(childNode.parent, 'string')
84
+ t.ok('id' in childNode)
85
+ t.type(childNode.id, 'string')
86
+ t.ok('label' in childNode)
87
+ t.type(childNode.label, 'string')
88
+ t.ok('nodes' in childNode)
89
+ t.ok(Array.isArray(childNode.nodes))
90
+ t.ok('start' in childNode)
91
+ t.ok(Number.isInteger(childNode.start))
92
+ t.ok('stop' in childNode)
93
+ t.type(childNode.stop, 'null')
94
+ t.ok('diff' in childNode)
95
+ t.type(childNode.diff, 'number')
96
+ })
97
+
98
+ test('TimeTree#start is adding a root element when parent is null', t => {
99
+ t.plan(9)
100
+
101
+ const tree = new TimeTree()
102
+ tree.start(null, 'root')
103
+
104
+ const rootNode = tree.root
105
+
106
+ t.type(rootNode, 'object')
107
+ t.equal(Object.keys(rootNode).length, 7)
108
+ t.equal(rootNode.parent, null)
109
+ t.equal(rootNode.id, 'root')
110
+ t.equal(rootNode.label, 'root')
111
+ t.ok(Array.isArray(rootNode.nodes))
112
+ t.equal(rootNode.nodes.length, 0)
113
+ t.ok(Number.isInteger(rootNode.start))
114
+ t.type(rootNode.diff, 'number')
115
+ })
116
+
117
+ test('TimeTree#start is adding a root element when parent does not exist', t => {
118
+ t.plan(9)
119
+
120
+ const tree = new TimeTree()
121
+ tree.start('invalid', 'root')
122
+
123
+ const rootNode = tree.root
124
+
125
+ t.type(rootNode, 'object')
126
+ t.equal(Object.keys(rootNode).length, 7)
127
+ t.equal(rootNode.parent, null)
128
+ t.equal(rootNode.id, 'root')
129
+ t.equal(rootNode.label, 'root')
130
+ t.ok(Array.isArray(rootNode.nodes))
131
+ t.equal(rootNode.nodes.length, 0)
132
+ t.ok(Number.isInteger(rootNode.start))
133
+ t.type(rootNode.diff, 'number')
134
+ })
135
+
136
+ test('TimeTree#start parameter start can override automatically generated start time', t => {
137
+ t.plan(1)
138
+
139
+ const tree = new TimeTree()
140
+ tree.start(null, 'root', 1337)
141
+
142
+ t.ok(tree.root.start, 1337)
143
+ })
144
+
145
+ test('TimeTree#start returns id of root, when adding a root node /1', t => {
146
+ t.plan(1)
147
+
148
+ const tree = new TimeTree()
149
+ t.equal(tree.start(null, 'root'), 'root')
150
+ })
151
+
152
+ test('TimeTree#start returns id of root, when adding a root node /2', t => {
153
+ t.plan(1)
154
+
155
+ const tree = new TimeTree()
156
+ t.equal(tree.start(null, '/'), 'root')
157
+ })
158
+
159
+ test('TimeTree#start returns id of child, when adding a child node', t => {
160
+ t.plan(1)
161
+
162
+ const tree = new TimeTree()
163
+ tree.start(null, 'root')
164
+ t.match(tree.start('root', 'child'), /^child-[0-9.]+$/)
165
+ })
166
+
167
+ test('TimeTree tracks node ids /1', t => {
168
+ t.plan(3)
169
+
170
+ const tree = new TimeTree()
171
+ tree.start(null, 'root')
172
+ tree.start('root', 'child')
173
+
174
+ t.equal(tree.tableId.size, 2)
175
+ t.ok(tree.tableId.has('root'))
176
+ t.ok(tree.tableId.has(tree.root.nodes[0].id))
177
+ })
178
+
179
+ test('TimeTree tracks node ids /2', t => {
180
+ t.plan(4)
181
+
182
+ const tree = new TimeTree()
183
+ tree.start(null, 'root')
184
+ tree.start('root', 'child')
185
+ tree.start('child', 'grandchild')
186
+
187
+ t.equal(tree.tableId.size, 3)
188
+ t.ok(tree.tableId.has('root'))
189
+ t.ok(tree.tableId.has(tree.root.nodes[0].id))
190
+ t.ok(tree.tableId.has(tree.root.nodes[0].nodes[0].id))
191
+ })
192
+
193
+ test('TimeTree tracks node ids /3', t => {
194
+ t.plan(4)
195
+
196
+ const tree = new TimeTree()
197
+ tree.start(null, 'root')
198
+ tree.start('root', 'child')
199
+ tree.start('root', 'child')
200
+
201
+ t.equal(tree.tableId.size, 3)
202
+ t.ok(tree.tableId.has('root'))
203
+ t.ok(tree.tableId.has(tree.root.nodes[0].id))
204
+ t.ok(tree.tableId.has(tree.root.nodes[1].id))
205
+ })
206
+
207
+ test('TimeTree tracks node labels /1', t => {
208
+ t.plan(4)
209
+
210
+ const tree = new TimeTree()
211
+ tree.start(null, 'root')
212
+ tree.start('root', 'child')
213
+ tree.start('root', 'sibling')
214
+
215
+ t.equal(tree.tableLabel.size, 3)
216
+ t.ok(tree.tableLabel.has('root'))
217
+ t.ok(tree.tableLabel.has('child'))
218
+ t.ok(tree.tableLabel.has('sibling'))
219
+ })
220
+
221
+ test('TimeTree tracks node labels /2', t => {
222
+ t.plan(3)
223
+
224
+ const tree = new TimeTree()
225
+ tree.start(null, 'root')
226
+ tree.start('root', 'child')
227
+ tree.start('root', 'child')
228
+
229
+ t.equal(tree.tableLabel.size, 2)
230
+ t.ok(tree.tableLabel.has('root'))
231
+ t.ok(tree.tableLabel.has('child'))
232
+ })
233
+
234
+ test('TimeTree#stop returns undefined', t => {
235
+ t.plan(1)
236
+
237
+ const tree = new TimeTree()
238
+ tree.start(null, 'root')
239
+
240
+ t.type(tree.stop('root'), 'undefined')
241
+ })
242
+
243
+ test('TimeTree#stop sets stop value of node', t => {
244
+ t.plan(3)
245
+
246
+ const tree = new TimeTree()
247
+ tree.start(null, 'root')
248
+ t.type(tree.root.stop, 'null')
249
+
250
+ tree.stop('root')
251
+ t.type(tree.root.stop, 'number')
252
+ t.ok(Number.isInteger(tree.root.stop))
253
+ })
254
+
255
+ test('TimeTree#stop parameter stop is used as stop value of node', t => {
256
+ t.plan(3)
257
+
258
+ const tree = new TimeTree()
259
+ tree.start(null, 'root')
260
+ t.type(tree.root.stop, 'null')
261
+
262
+ tree.stop('root', 1337)
263
+ t.type(tree.root.stop, 'number')
264
+ t.equal(tree.root.stop, 1337)
265
+ })
266
+
267
+ test('TimeTree#stop calculates the diff', t => {
268
+ t.plan(4)
269
+
270
+ const tree = new TimeTree()
271
+ tree.start(null, 'root', 1)
272
+ t.type(tree.root.diff, 'number')
273
+ t.equal(tree.root.diff, -1)
274
+ tree.stop('root', 5)
275
+
276
+ t.type(tree.root.diff, 'number')
277
+ t.equal(tree.root.diff, 4)
278
+ })
279
+
280
+ test('TimeTree#stop does nothing when node is not found', t => {
281
+ t.plan(2)
282
+
283
+ const tree = new TimeTree()
284
+ tree.start(null, 'root')
285
+ t.type(tree.root.stop, 'null')
286
+
287
+ tree.stop('invalid')
288
+ t.type(tree.root.stop, 'null')
289
+ })
290
+
291
+ test('TimeTree untracks node ids /1', t => {
292
+ t.plan(2)
293
+
294
+ const tree = new TimeTree()
295
+ tree.start(null, 'root')
296
+ tree.start('root', 'child')
297
+
298
+ tree.stop(tree.root.nodes[0].id)
299
+ t.equal(tree.tableId.size, 1)
300
+ t.ok(tree.tableId.has('root'))
301
+ })
302
+
303
+ test('TimeTree untracks node ids /2', t => {
304
+ t.plan(3)
305
+
306
+ const tree = new TimeTree()
307
+ tree.start(null, 'root')
308
+ tree.start('root', 'child')
309
+ tree.start('child', 'grandchild')
310
+
311
+ tree.stop(tree.root.nodes[0].nodes[0].id)
312
+
313
+ t.equal(tree.tableId.size, 2)
314
+ t.ok(tree.tableId.has('root'))
315
+ t.ok(tree.tableId.has(tree.root.nodes[0].id))
316
+ })
317
+
318
+ test('TimeTree untracks node ids /3', t => {
319
+ t.plan(3)
320
+
321
+ const tree = new TimeTree()
322
+ tree.start(null, 'root')
323
+ tree.start('root', 'child')
324
+ tree.start('root', 'child')
325
+
326
+ tree.stop(tree.root.nodes[0].id)
327
+
328
+ t.equal(tree.tableId.size, 2)
329
+ t.ok(tree.tableId.has('root'))
330
+ t.ok(tree.tableId.has(tree.root.nodes[1].id))
331
+ })
332
+
333
+ test('TimeTree untracks node ids /4', t => {
334
+ t.plan(3)
335
+
336
+ const tree = new TimeTree()
337
+ tree.start(null, 'root')
338
+ tree.start('root', 'child')
339
+ tree.start('root', 'child')
340
+
341
+ tree.stop(tree.root.nodes[1].id)
342
+
343
+ t.equal(tree.tableId.size, 2)
344
+ t.ok(tree.tableId.has('root'))
345
+ t.ok(tree.tableId.has(tree.root.nodes[0].id))
346
+ })
347
+
348
+ test('TimeTree untracks node labels /1', t => {
349
+ t.plan(3)
350
+
351
+ const tree = new TimeTree()
352
+ tree.start(null, 'root')
353
+ tree.start('root', 'child')
354
+ tree.start('root', 'sibling')
355
+
356
+ tree.stop(tree.root.nodes[1].id)
357
+
358
+ t.equal(tree.tableLabel.size, 2)
359
+ t.ok(tree.tableLabel.has('root'))
360
+ t.ok(tree.tableLabel.has('child'))
361
+ })
362
+
363
+ test('TimeTree untracks node labels /2', t => {
364
+ t.plan(3)
365
+
366
+ const tree = new TimeTree()
367
+ tree.start(null, 'root')
368
+ tree.start('root', 'child')
369
+ tree.start('root', 'sibling')
370
+
371
+ tree.stop(tree.root.nodes[0].id)
372
+
373
+ t.equal(tree.tableLabel.size, 2)
374
+ t.ok(tree.tableLabel.has('root'))
375
+ t.ok(tree.tableLabel.has('sibling'))
376
+ })
377
+
378
+ test('TimeTree does not untrack label if used by other node', t => {
379
+ t.plan(3)
380
+
381
+ const tree = new TimeTree()
382
+ tree.start(null, 'root')
383
+ tree.start('root', 'child')
384
+ tree.start('root', 'child')
385
+
386
+ tree.stop(tree.root.nodes[0].id)
387
+
388
+ t.equal(tree.tableLabel.size, 2)
389
+ t.ok(tree.tableLabel.has('root'))
390
+ t.ok(tree.tableLabel.has('child'))
391
+ })
novas/novacore-zephyr/claude-code-router/node_modules/avvio/test/lib/validate-plugin.test.js ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 'use strict'
2
+
3
+ const { test } = require('tap')
4
+ const { validatePlugin } = require('../../lib/validate-plugin')
5
+ const { AVV_ERR_PLUGIN_NOT_VALID } = require('../../lib/errors')
6
+
7
+ test('validatePlugin', (t) => {
8
+ t.plan(8)
9
+
10
+ t.throws(() => validatePlugin(1), new AVV_ERR_PLUGIN_NOT_VALID('number'))
11
+ t.throws(() => validatePlugin('function'), new AVV_ERR_PLUGIN_NOT_VALID('string'))
12
+ t.throws(() => validatePlugin({}), new AVV_ERR_PLUGIN_NOT_VALID('object'))
13
+ t.throws(() => validatePlugin([]), new AVV_ERR_PLUGIN_NOT_VALID('array'))
14
+ t.throws(() => validatePlugin(null), new AVV_ERR_PLUGIN_NOT_VALID('null'))
15
+
16
+ t.doesNotThrow(() => validatePlugin(function () {}))
17
+ t.doesNotThrow(() => validatePlugin(new Promise((resolve) => resolve)))
18
+ t.doesNotThrow(() => validatePlugin(Promise.resolve()))
19
+ })
novas/novacore-zephyr/claude-code-router/node_modules/avvio/test/load-plugin.test.js ADDED
@@ -0,0 +1,123 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 'use strict'
2
+
3
+ const fastq = require('fastq')
4
+ const boot = require('..')
5
+ const { test } = require('tap')
6
+ const { Plugin } = require('../lib/plugin')
7
+
8
+ test('successfully load a plugin with sync function', (t) => {
9
+ t.plan(1)
10
+ const app = boot({})
11
+
12
+ const plugin = new Plugin(fastq(app, app._loadPluginNextTick, 1), function (instance, opts, done) {
13
+ done()
14
+ }, false, 0)
15
+
16
+ app._loadPlugin(plugin, function (err) {
17
+ t.equal(err, undefined)
18
+ })
19
+ })
20
+
21
+ test('catch an error when loading a plugin with sync function', (t) => {
22
+ t.plan(1)
23
+ const app = boot({})
24
+
25
+ const plugin = new Plugin(fastq(app, app._loadPluginNextTick, 1), function (instance, opts, done) {
26
+ done(Error('ArbitraryError'))
27
+ }, false, 0)
28
+
29
+ app._loadPlugin(plugin, function (err) {
30
+ t.equal(err.message, 'ArbitraryError')
31
+ })
32
+ })
33
+
34
+ test('successfully load a plugin with sync function without done as a parameter', (t) => {
35
+ t.plan(1)
36
+ const app = boot({})
37
+
38
+ const plugin = new Plugin(fastq(app, app._loadPluginNextTick, 1), function (instance, opts) { }, false, 0)
39
+
40
+ app._loadPlugin(plugin, function (err) {
41
+ t.equal(err, undefined)
42
+ })
43
+ })
44
+
45
+ test('successfully load a plugin with async function', (t) => {
46
+ t.plan(1)
47
+ const app = boot({})
48
+
49
+ const plugin = new Plugin(fastq(app, app._loadPluginNextTick, 1), async function (instance, opts) { }, false, 0)
50
+
51
+ app._loadPlugin(plugin, function (err) {
52
+ t.equal(err, undefined)
53
+ })
54
+ })
55
+
56
+ test('catch an error when loading a plugin with async function', (t) => {
57
+ t.plan(1)
58
+ const app = boot({})
59
+
60
+ const plugin = new Plugin(fastq(app, app._loadPluginNextTick, 1), async function (instance, opts) {
61
+ throw Error('ArbitraryError')
62
+ }, false, 0)
63
+
64
+ app._loadPlugin(plugin, function (err) {
65
+ t.equal(err.message, 'ArbitraryError')
66
+ })
67
+ })
68
+
69
+ test('successfully load a plugin when function is a Promise, which resolves to a function', (t) => {
70
+ t.plan(1)
71
+ const app = boot({})
72
+
73
+ const plugin = new Plugin(fastq(app, app._loadPluginNextTick, 1), new Promise(resolve => resolve(function (instance, opts, done) {
74
+ done()
75
+ })), false, 0)
76
+
77
+ app._loadPlugin(plugin, function (err) {
78
+ t.equal(err, undefined)
79
+ })
80
+ })
81
+
82
+ test('catch an error when loading a plugin when function is a Promise, which resolves to a function', (t) => {
83
+ t.plan(1)
84
+ const app = boot({})
85
+
86
+ const plugin = new Plugin(fastq(app, app._loadPluginNextTick, 1), new Promise(resolve => resolve(function (instance, opts, done) {
87
+ done(Error('ArbitraryError'))
88
+ })), false, 0)
89
+
90
+ app._loadPlugin(plugin, function (err) {
91
+ t.equal(err.message, 'ArbitraryError')
92
+ })
93
+ })
94
+
95
+ test('successfully load a plugin when function is a Promise, which resolves to a function, which is wrapped in default', (t) => {
96
+ t.plan(1)
97
+ const app = boot({})
98
+
99
+ const plugin = new Plugin(fastq(app, app._loadPluginNextTick, 1), new Promise(resolve => resolve({
100
+ default: function (instance, opts, done) {
101
+ done()
102
+ }
103
+ })), false, 0)
104
+
105
+ app._loadPlugin(plugin, function (err) {
106
+ t.equal(err, undefined)
107
+ })
108
+ })
109
+
110
+ test('catch an error when loading a plugin when function is a Promise, which resolves to a function, which is wrapped in default', (t) => {
111
+ t.plan(1)
112
+ const app = boot({})
113
+
114
+ const plugin = new Plugin(fastq(app, app._loadPluginNextTick, 1), new Promise(resolve => resolve({
115
+ default: function (instance, opts, done) {
116
+ done(Error('ArbitraryError'))
117
+ }
118
+ })), false, 0)
119
+
120
+ app._loadPlugin(plugin, function (err) {
121
+ t.equal(err.message, 'ArbitraryError')
122
+ })
123
+ })
novas/novacore-zephyr/claude-code-router/node_modules/avvio/test/no-done.test.js ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 'use strict'
2
+
3
+ const { test } = require('tap')
4
+ const boot = require('..')
5
+
6
+ test('not taking done does not throw error.', (t) => {
7
+ t.plan(2)
8
+
9
+ const app = boot()
10
+
11
+ app.use(noDone).ready((err) => {
12
+ t.notOk(err, 'no error')
13
+ })
14
+
15
+ function noDone (s, opts) {
16
+ t.pass('did not throw')
17
+ }
18
+ })